:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: #202733;
  background: #f1f2f3;
  --ink: #202733;
  --muted: #727b87;
  --line: #dfe2e5;
  --panel: #fbfbfa;
  --blue: #245fc5;
  --blue-hover: #174fae;
  --blue-soft: #edf3ff;
  --green: #218357;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-width: 320px; margin: 0; overflow: hidden; }
body { font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: inherit; }
[hidden] { display: none !important; }
.icon { display: block; width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid #d9dde1; border-radius: 8px; background: #fff; color: var(--blue); }
.button { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 11px 15px; border: 0; border-radius: 7px; font-size: 14px; font-weight: 650; transition: background .15s ease, transform .15s ease; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--blue-hover); }
.button-primary:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .upload-zone:focus-within { outline: 3px solid #83a7eb; outline-offset: 2px; }

/* Sign-in */
.login-view { display: grid; grid-template-rows: auto 1fr auto; align-items: center; width: 100%; height: 100%; padding: 30px 44px; background: #f1f2f3; }
.login-mark { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; }
.login-mark em { color: #818995; font-style: normal; font-weight: 450; }
.login-card { width: min(390px, 100%); justify-self: center; align-self: center; padding: 32px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.login-card h1 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.8px; }
.login-card p { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-card label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.login-card input { display: block; width: 100%; height: 46px; margin-bottom: 14px; padding: 10px 12px; border: 1px solid #d4d9df; border-radius: 7px; background: #fff; outline: 0; }
.login-card input:focus { border-color: #7698d8; box-shadow: 0 0 0 3px #245fc51a; }
.login-card .button { width: 100%; }
.login-footer { display: flex; justify-content: space-between; color: #8a929c; font-size: 11px; letter-spacing: .6px; }

/* Print workspace */
.app-shell { position: relative; display: flex; flex-direction: column; width: 100%; height: 100dvh; min-height: 0; background: #f1f2f3; }
.topbar { z-index: 2; display: flex; align-items: center; justify-content: space-between; flex: 0 0 60px; height: 60px; padding: 0 22px; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font-size: 15px; font-weight: 750; letter-spacing: -.2px; }
.brand-name span { color: #727b87; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.agent-status { display: flex; align-items: center; gap: 9px; color: #46505d; font-size: 13px; font-weight: 600; }
.dot { display: block; width: 9px; height: 9px; border-radius: 50%; background: #a2a9b1; }
.dot.online { background: var(--green); box-shadow: 0 0 0 4px #21835718; }
.topbar-button { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: #65707c; font-size: 13px; }
.topbar-button:hover { background: #f1f3f5; color: var(--ink); }
.topbar-button .icon { width: 17px; height: 17px; }
.drop-overlay { position: absolute; z-index: 50; inset: 8px; display: grid; place-items: center; border: 2px dashed #6487d1; border-radius: 14px; background: #edf3ffed; box-shadow: inset 0 0 0 4px #ffffff80; pointer-events: none; backdrop-filter: blur(2px); }
.drop-prompt { display: flex; width: min(390px, calc(100% - 32px)); flex-direction: column; align-items: center; gap: 11px; padding: 30px 26px; border: 1px solid #d8e0ed; border-radius: 13px; background: #fff; box-shadow: 0 16px 42px #1b2d481f; text-align: center; }
.drop-icon { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; background: #eaf1ff; color: var(--blue); }
.drop-icon .icon { width: 29px; height: 29px; }
.drop-prompt strong { color: #273445; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.drop-prompt > span:last-child { color: #687586; font-size: 15px; line-height: 1.4; }
.workspace-body { display: grid; grid-template-columns: minmax(340px, 360px) minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 22px 20px 18px; border-right: 1px solid var(--line); background: var(--panel); }
.file-panel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sidebar-heading h1 { margin: 0; font-size: 22px; font-weight: 680; letter-spacing: -.6px; }
.count-badge { display: grid; min-width: 28px; height: 26px; padding: 0 7px; place-items: center; border-radius: 14px; background: #e9ecef; color: #535e6b; font-size: 13px; font-weight: 650; }
#uploadform { flex: none; margin: 0 0 16px; }
.upload-zone { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; min-height: 52px; padding: 12px 14px; border: 1px dashed #aeb9c7; border-radius: 8px; background: #fff; color: #374453; font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.upload-zone:hover, .upload-zone.over { border-color: var(--blue); background: var(--blue-soft); }
.upload-zone .icon { width: 20px; height: 20px; color: var(--blue); }
.upload-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.upload-progress { min-height: 0; margin: 7px 1px 0; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.upload-progress:empty { display: none; }
.file-list { display: grid; align-content: start; gap: 8px; min-height: 80px; padding: 1px 2px 12px 1px; overflow: auto; }
.files-empty { margin: 5px 0; color: #7c8590; font-size: 13px; }
.file-tile-row { position: relative; min-width: 0; }
.file-tile { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 11px; width: 100%; min-height: 66px; padding: 7px 34px 7px 7px; border: 1px solid transparent; border-radius: 8px; background: #f0f2f4; color: inherit; text-align: left; transition: background .15s ease, border-color .15s ease; }
.file-tile:hover { border-color: #d4d9df; background: #f7f8f9; }
.file-tile-row.selected .file-tile { border-color: #7b9cdb; background: #eff4ff; box-shadow: 0 0 0 1px #7b9cdb; }
.file-tile-preview { position: relative; display: grid; width: 46px; height: 52px; place-items: center; overflow: hidden; border: 1px solid #e5e8eb; border-radius: 3px; background: #fff; }
.file-tile-preview canvas { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.file-tile-preview.loading::after { position: absolute; width: 13px; height: 13px; border: 2px solid #d0d7df; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; content: ""; }
.file-tile-preview.fallback::after { position: absolute; inset: 0; display: grid; place-items: center; color: #727b87; font-size: 10px; content: "PDF"; }
@keyframes spin { to { transform: rotate(360deg); } }
.file-description { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.file-name { display: -webkit-box; min-width: 0; max-height: 38px; overflow: hidden; color: #303b48; font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.file-pages { color: #737d89; font-size: 12px; }
.file-remove { position: absolute; top: 50%; right: 8px; display: grid; width: 28px; height: 28px; padding: 0; place-items: center; transform: translateY(-50%); border: 0; border-radius: 6px; background: transparent; color: #78828e; }
.file-remove:hover { background: #e3e7ec; color: #26313e; }
.file-remove .icon { width: 16px; height: 16px; }
.settings-panel { flex: none; padding-top: 15px; border-top: 1px solid var(--line); }
.settings-heading { display: flex; align-items: center; justify-content: space-between; min-height: 29px; margin-bottom: 11px; }
.settings-heading h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.settings-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; }
.settings-toggle .icon { display: none; }
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 10px; }
.setting-fields { display: contents; }
.setting-label { display: block; min-width: 0; color: #525e6c; font-size: 12px; font-weight: 600; }
.setting-label > span { display: block; margin-bottom: 5px; }
.setting-label input { display: block; width: 100%; height: 41px; padding: 8px 10px; border: 1px solid #d4dbe2; border-radius: 6px; background: #fff; color: #253140; font-size: 14px; outline: 0; }
.setting-label input:focus { border-color: #7595d5; box-shadow: 0 0 0 3px #245fc51a; }
.choice { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 0; }
.choice .setting-label { flex: none; }
.choice-trigger { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 41px; padding: 8px 9px; border: 1px solid #d4dbe2; border-radius: 6px; background: #fff; color: #344151; font-size: 13px; text-align: left; }
.choice-trigger:hover { border-color: #a9b8ca; }
.choice-trigger[aria-expanded="true"] { border-color: #6486ce; box-shadow: 0 0 0 2px #245fc51a; }
.choice-trigger > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-trigger .icon { width: 17px; height: 17px; }
.choice-menu { position: absolute; z-index: 10; top: calc(100% + 5px); left: 0; min-width: 100%; width: max-content; max-width: calc(100vw - 28px); padding: 4px; border: 1px solid #d8dfe6; border-radius: 7px; background: #fff; box-shadow: 0 10px 25px #15243a20; }
.choice-menu.above { top: auto; bottom: calc(100% + 5px); }
.choice-option { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; padding: 8px 9px; border: 0; border-radius: 4px; background: #fff; color: #303b49; font-size: 13px; text-align: left; white-space: nowrap; }
.choice-option:hover, .choice-option:focus-visible { background: #f0f4f8; outline: 0; }
.choice-option > span { flex: 1; }
.choice-option .icon { width: 17px; height: 17px; }
.choice-option > svg:last-child { visibility: hidden; width: 15px; }
.choice-option[aria-selected="true"] { background: var(--blue-soft); color: #1f4c9a; }
.choice-option[aria-selected="true"] > svg:last-child { visibility: visible; }
.confirm-button { grid-column: 1 / -1; gap: 9px; width: 100%; min-height: 48px; margin-top: 2px; }

/* Page viewer */
.viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #eceef0; }
.viewer-header { display: flex; flex: 0 0 62px; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; height: 62px; padding: 0 23px; border-bottom: 1px solid #dfe2e5; background: #fff; }
.viewer-title { min-width: 0; }
.viewer-title h2 { max-width: min(68vw, 760px); margin: 0; overflow: hidden; color: #283341; font-size: 17px; font-weight: 650; letter-spacing: -.3px; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title span { display: block; margin-top: 3px; color: #747e89; font-size: 12px; }
.remove-preview { display: flex; flex: none; align-items: center; gap: 7px; min-height: 36px; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: #697482; font-size: 12px; }
.remove-preview:hover { background: #f0f2f4; color: #273340; }
.remove-preview .icon { width: 16px; height: 16px; }
.viewer-content { display: grid; grid-template-columns: 82px minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }
.page-strip { display: flex; min-width: 0; min-height: 0; flex-direction: column; padding: 13px 8px; border-right: 1px solid #dfe2e5; background: #f5f6f7; }
.page-thumbs { display: flex; min-height: 0; flex: 1; flex-direction: column; align-items: center; gap: 8px; padding: 2px 1px 8px; overflow: auto; }
.page-thumb { position: relative; display: flex; width: 63px; flex: none; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border: 1px solid #d8dde3; border-radius: 5px; background: #eceff2; color: #657180; font-size: 11px; cursor: pointer; }
.page-thumb:hover { border-color: #94a9cf; }
.page-thumb.active { border-color: #4675cd; background: var(--blue-soft); color: #244f9f; box-shadow: 0 0 0 1px #4675cd; }
.page-thumb canvas { display: block; width: 52px; height: 68px; object-fit: contain; background: #fff; }
.page-thumb.loading canvas { opacity: 0; }
.page-thumb.loading::before { position: absolute; top: 28px; width: 13px; height: 13px; border: 2px solid #d0d7df; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; content: ""; }
.page-thumb.fallback::before { position: absolute; top: 32px; color: #727b87; font-size: 10px; content: "PDF"; }
.canvas-region { display: flex; min-width: 0; min-height: 0; flex-direction: column; padding: 0 15px 15px; }
.viewer-toolbar { display: flex; height: 45px; flex: none; align-items: center; justify-content: center; gap: 11px; color: #4b5764; }
.icon-button { display: grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 1px solid #d4dae0; border-radius: 6px; background: #fff; color: #475565; }
.icon-button:hover:not(:disabled) { border-color: #a6b7d0; background: #f8faff; color: #214f9e; }
.icon-button .icon { width: 17px; height: 17px; }
.page-label { min-width: 45px; color: #475463; font-size: 13px; font-weight: 600; text-align: center; }
.open-link { display: grid; width: 32px; height: 32px; margin-left: 8px; place-items: center; border-radius: 6px; color: #657181; }
.open-link:hover { background: #fff; color: var(--blue); }
.open-link .icon { width: 17px; height: 17px; }
.paper-stage { position: relative; display: flex; min-width: 0; min-height: 0; flex: 1; align-items: center; justify-content: center; overflow: hidden; border: 1px solid #d9dde1; border-radius: 8px; background: #e5e7e9; }
.paper-stage canvas { display: block; flex: none; background: #fff; box-shadow: 0 3px 12px #18253520; }
.paper-stage #paper.gray { filter: grayscale(1); }
.preview-empty { display: flex; align-items: center; gap: 12px; padding: 20px; color: #78828d; }
.preview-empty .icon { width: 25px; height: 25px; color: #7d8996; }
.preview-empty strong { font-size: 15px; font-weight: 550; }
.paper-stage #previewmessage { position: absolute; top: 50%; left: 50%; margin: 0; transform: translate(-50%, -50%); color: #65717e; font-size: 13px; text-align: center; }
#notice { position: fixed; z-index: 30; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid #d7dde4; border-radius: 8px; background: #fff; color: #354252; box-shadow: 0 8px 24px #18253622; font-size: 13px; line-height: 1.45; }

.viewer:has(#previewempty:not([hidden])) .page-strip,
.viewer:has(#previewempty:not([hidden])) .viewer-toolbar { visibility: hidden; }

@media (max-width: 760px) {
  .app-shell { height: 100dvh; }
  .topbar { flex-basis: calc(54px + env(safe-area-inset-top)); height: calc(54px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 13px 0; }
  .brand { gap: 8px; }
  .logo { width: 31px; height: 31px; }
  .brand-name { font-size: 14px; }
  .topbar-actions { gap: 9px; }
  .agent-status { gap: 7px; font-size: 12px; }
  .topbar-button { width: 36px; height: 36px; justify-content: center; padding: 0; }
  .topbar-button span { display: none; }
  .workspace-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .viewer { order: 0; }
  .sidebar { order: 1; max-height: min(42dvh, 350px); padding: 10px 13px calc(10px + env(safe-area-inset-bottom)); overflow-y: auto; border-top: 1px solid var(--line); border-right: 0; }
  .sidebar-heading { margin-bottom: 8px; }
  .sidebar-heading h1 { font-size: 18px; }
  .count-badge { min-width: 25px; height: 23px; font-size: 12px; }
  #uploadform { margin-bottom: 7px; }
  .upload-zone { min-height: 42px; padding: 8px 11px; font-size: 13px; }
  .upload-zone .icon { width: 18px; height: 18px; }
  .upload-progress { margin-top: 4px; font-size: 12px; }
  .file-list { display: flex; min-height: 60px; flex: none; gap: 7px; padding: 0 1px 5px; overflow-x: auto; overflow-y: hidden; }
  .files-empty { align-self: center; margin: 0; font-size: 13px; }
  .file-tile-row { width: 190px; flex: 0 0 190px; }
  .file-tile { grid-template-columns: 39px minmax(0, 1fr); gap: 8px; min-height: 54px; padding: 5px 32px 5px 5px; }
  .file-tile-preview { width: 37px; height: 43px; }
  .file-name { max-height: 34px; font-size: 12px; }
  .file-pages { font-size: 11px; }
  .file-remove { right: 4px; width: 27px; height: 27px; }
  .settings-panel { padding-top: 8px; }
  .settings-heading { min-height: 32px; margin: 0; }
  .settings-heading h2, .settings-toggle { font-size: 15px; }
  .settings-toggle { min-height: 32px; }
  .settings-toggle .icon { display: block; width: 17px; height: 17px; transition: transform .15s ease; }
  .settings-panel.open .settings-toggle .icon { transform: rotate(180deg); }
  .settings-form { gap: 7px 8px; }
  .settings-panel:not(.open) .setting-fields { display: none; }
  .setting-label { font-size: 11px; }
  .setting-label > span { margin-bottom: 3px; }
  .setting-label input, .choice-trigger { min-height: 36px; height: 36px; padding: 6px 8px; font-size: 13px; }
  .setting-label input { font-size: 16px; }
  .choice-trigger .icon { width: 15px; height: 15px; }
  .choice-option { min-height: 42px; font-size: 14px; }
  .confirm-button { min-height: 42px; margin-top: 2px; font-size: 14px; }
  .viewer-header { flex-basis: 48px; height: 48px; padding: 0 13px; }
  .viewer-title h2 { max-width: 67vw; font-size: 15px; }
  .viewer-title span { margin-top: 2px; font-size: 11px; }
  .remove-preview { min-height: 34px; padding: 6px; font-size: 0; }
  .remove-preview .icon { width: 17px; height: 17px; }
  #notice { top: calc(62px + env(safe-area-inset-top)); bottom: auto; }
  .drop-overlay { inset: 5px; border-radius: 10px; }
  .drop-prompt { width: min(340px, calc(100% - 24px)); gap: 9px; padding: 25px 18px; }
  .drop-icon { width: 52px; height: 52px; }
  .drop-icon .icon { width: 26px; height: 26px; }
  .drop-prompt strong { font-size: 20px; }
  .drop-prompt > span:last-child { font-size: 14px; }
  .viewer-content { display: flex; flex-direction: column; }
  .page-strip { height: 57px; flex: 0 0 57px; flex-direction: row; padding: 5px 10px; border-right: 0; border-bottom: 1px solid #dfe2e5; }
  .page-thumbs { flex-direction: row; align-items: center; gap: 7px; padding: 1px 2px 3px; overflow-x: auto; overflow-y: hidden; }
  .page-thumb { width: 40px; flex: 0 0 40px; gap: 2px; padding: 2px; font-size: 10px; }
  .page-thumb canvas { width: 33px; height: 38px; }
  .page-thumb.loading::before { top: 12px; width: 11px; height: 11px; }
  .page-thumb.fallback::before { top: 14px; }
  .canvas-region { flex: 1; padding: 0 8px 8px; }
  .viewer-toolbar { height: 38px; gap: 9px; }
  .icon-button { width: 32px; height: 32px; }
  .page-label { min-width: 42px; font-size: 12px; }
  .open-link { width: 30px; height: 30px; margin-left: 1px; }
  .paper-stage { border-radius: 5px; }
  .preview-empty { gap: 9px; padding: 12px; }
  .preview-empty .icon { width: 21px; height: 21px; }
  .preview-empty strong { font-size: 13px; }
  #notice { right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
}

@media (max-width: 370px) {
  .sidebar { padding-right: 10px; padding-left: 10px; }
  .topbar { padding-right: 10px; padding-left: 10px; }
  .brand-name { display: none; }
  .settings-form { column-gap: 6px; }
  .file-tile-row { width: 164px; flex-basis: 164px; }
}
