@font-face { font-family: "Source Sans 3"; font-weight: 400; font-display: swap; src: url(fonts/source-sans-3-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 600; font-display: swap; src: url(fonts/source-sans-3-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 700; font-display: swap; src: url(fonts/source-sans-3-latin-700-normal.woff2) format("woff2"); }

/* Layout: top app bar with menus, full-width pages; one dark charcoal theme with a blue accent. */
:root {
  color-scheme: dark;
  --bg: #1d1d1d;          /* page */
  --bar: #222222;         /* app bar */
  --surface: #2a2a2a;     /* cards, panels */
  --surface-2: #323232;   /* hover, raised */
  --surface-3: #3b3b3b;   /* pressed, chips */
  --field: #1a1a1a;       /* inputs */
  --canvas: #141414;      /* behind PDF pages */
  --border: #3d3d3d;
  --border-strong: #555555;
  --text: #f2f2f2;
  --muted: #b3b3b3;
  --faint: #8c8c8c;
  --primary: #3d6dff;
  --primary-hover: #5884ff;
  --primary-press: #2f5ae6;
  --primary-soft: rgba(61, 109, 255, .16);
  --primary-line: rgba(61, 109, 255, .55);
  --danger: #ff5c5c;
  --danger-soft: rgba(255, 92, 92, .14);
  --success: #3fcf7f;
  --success-soft: rgba(63, 207, 127, .14);
  --warn-bg: rgba(250, 204, 21, .1);
  --warn-text: #f5d76e;
  --paper: #ffffff;
  --radius: 8px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--primary-hover); outline-offset: 2px; }
::selection { background: rgba(61, 109, 255, .45); }
* { scrollbar-width: thin; scrollbar-color: #4a4a4a transparent; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- App bar ---------- */
.appbar {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  height: 64px; padding: 0 var(--gut-r) 0 var(--gut-l);
  background: var(--bar); border-bottom: 1px solid #2f2f2f; position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 6px 8px 6px 4px; border-radius: 8px; margin-right: 18px; flex-shrink: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #5a8bff 0%, #3d6dff 55%, #6b4dff 100%); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.005em; white-space: nowrap; }
.topnav { display: flex; align-items: stretch; height: 100%; gap: 4px; min-width: 0; }
.tn-item { position: relative; display: flex; align-items: stretch; }
.tn-link {
  display: flex; align-items: center; gap: 4px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  font-size: 16px; color: #d8d8d8; text-decoration: none; white-space: nowrap; position: relative;
}
.tn-link:hover { color: #fff; }
.tn-link svg { width: 16px; height: 16px; stroke-width: 2.4; opacity: .85; }
.tn-link.active { color: #fff; }
.tn-link.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: #fff; }
.tn-menu {
  position: absolute; top: calc(100% - 4px); left: 0; min-width: 300px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  display: none; z-index: 40;
}
.tn-item.open .tn-menu { display: block; }
.tn-menu a { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; text-decoration: none; }
.tn-menu a:hover, .tn-menu a:focus-visible { background: var(--surface-2); }
.tn-menu a svg { color: var(--accent); margin-top: 1px; }
.tn-menu b { display: block; font-weight: 600; font-size: 15px; }
.tn-menu small { display: block; color: var(--muted); font-size: 13px; margin-top: 1px; }
.appbar-end { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.appbar .menu-btn { display: none; }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 2px solid transparent; cursor: pointer;
  font-weight: 700; font-size: 15px; text-decoration: none; transition: background .15s, border-color .15s;
}
.pill svg { width: 18px; height: 18px; }
.pill.primary { background: var(--primary); color: #fff; }
.pill.primary:hover { background: var(--primary-hover); }
.pill.primary:active { background: var(--primary-press); }
.pill.outline { background: transparent; border-color: #cfcfcf; color: #f2f2f2; }
.pill.outline:hover { background: rgba(255, 255, 255, .08); }
.pill.lg { height: 46px; padding: 0 24px; font-size: 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn.round { border-radius: 50%; color: #e0e0e0; }
.icon-btn.round svg { width: 22px; height: 22px; }

/* ---------- Mobile drawer ---------- */
.drawer {
  position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); z-index: 60; background: var(--bar);
  border-right: 1px solid var(--border); transform: translateX(-102%); transition: transform .22s ease;
  display: flex; flex-direction: column; padding-bottom: var(--safe-b);
}
.app.menu-open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px var(--gut-l); padding-top: max(14px, env(safe-area-inset-top)); }
.drawer-head b { font-size: 17px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-group { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px; border: 0; border-radius: 8px;
  background: none; color: #dcdcdc; font-size: 16px; text-align: left; cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: #fff; }
.nav-item.active { background: var(--primary-soft); color: #fff; }
.nav-item svg { color: var(--accent, var(--muted)); }
.scrim { display: none; }
.app.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 55; }

/* ---------- Main & page head ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pagehead {
  display: flex; align-items: center; gap: 14px; flex-shrink: 0;
  padding: 14px var(--gut-r) 14px var(--gut-l); border-bottom: 1px solid #2c2c2c; background: var(--bg);
}
.pagehead[hidden] { display: none; }
.back-link { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 14px; padding: 6px 10px 6px 4px; border-radius: 6px; margin-right: 4px; }
.back-link:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.back-link svg { width: 18px; height: 18px; }
.title-icon { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); flex-shrink: 0; }
.title-icon svg { width: 22px; height: 22px; }
.title-wrap { min-width: 0; }
.pagehead h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.pagehead p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.content { flex: 1; overflow-y: auto; position: relative; }
.tool-wrap { max-width: 1120px; margin: 0 auto; padding: 28px var(--gut-r) 120px var(--gut-l); }

/* ---------- Home ---------- */
.home { max-width: 1840px; margin: 0 auto; padding: 22px var(--gut-r) 60px var(--gut-l); }
.hero-band { position: relative; border-radius: 10px; padding: 22px 0 0; }
.hero-band::before {
  content: ""; position: absolute; left: -2%; right: -2%; top: 0; height: 64%; border-radius: 0;
  background: linear-gradient(100deg, #233a8f 0%, #3d6dff 34%, #2bb0ff 58%, #9fd8ff 70%, rgba(170, 180, 200, .55) 100%);
  opacity: .9; z-index: 0;
}
.hero {
  position: relative; z-index: 1; display: grid; grid-template-columns: 300px minmax(0, 1fr) auto; align-items: center; gap: 28px;
  margin: 0 3.4%; padding: 34px 48px 34px 24px; background: #2b2b2b; border: 1px solid #3a3a3a; border-radius: 10px; overflow: hidden;
}
.hero::before { content: ""; position: absolute; left: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle at 70% 70%, #8fb0ff 0%, #4a73ff 45%, transparent 70%); opacity: .55; }
.hero::after { content: ""; position: absolute; right: -90px; bottom: -120px; width: 260px; height: 320px; border-radius: 50%; background: linear-gradient(200deg, #4a73ff, #6b4dff 60%, transparent); opacity: .45; }
.hero-art { position: relative; z-index: 1; display: grid; place-items: center; }
.hero-art svg { width: 200px; height: 170px; stroke: none; }
.hero-text { position: relative; z-index: 1; min-width: 0; }
.hero-text .hello { margin: 0 0 6px; font-weight: 700; font-size: 17px; }
.hero-text h2 { margin: 0 0 14px; font-size: clamp(26px, 2.6vw, 36px); font-weight: 700; letter-spacing: -.015em; line-height: 1.15; text-wrap: balance; }
.ticks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ticks li { display: flex; gap: 12px; align-items: flex-start; font-size: 18px; color: #d9d9d9; line-height: 1.35; }
.ticks svg { color: var(--success); width: 20px; height: 20px; margin-top: 2px; stroke-width: 2.6; }
.hero-cta { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.hero-cta .pill.primary { box-shadow: 0 0 0 3px rgba(61, 109, 255, .35); }
.hero-toggle { position: absolute; right: 14px; top: 12px; z-index: 2; }
.hero.collapsed { grid-template-columns: minmax(0, 1fr) auto; padding: 16px 64px 16px 24px; }
.hero.collapsed .hero-art, .hero.collapsed .ticks { display: none; }
.hero.collapsed .hero-text h2 { margin: 0; font-size: 20px; }
.hero.collapsed .hero-text .hello { display: none; }
.hero.collapsed + .x { display: none; }

.tabsbar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 40px 0 18px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; cursor: pointer; padding: 8px 8px 10px; font-size: 18px; color: #cfcfcf; position: relative; white-space: nowrap; }
.tab:hover { color: #fff; }
.tab.on { color: #fff; font-weight: 600; }
.tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 2px; background: #fff; }
.tabsbar .grow { flex: 1; }
.text-link { color: #e8e8e8; font-size: 17px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; background: none; border: 0; padding: 4px; }
.text-link:hover { color: #fff; }

.tool-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 22px 24px; }
.tool-card {
  display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 22px; border-radius: 6px; cursor: pointer;
  background: #2b2b2b; border: 1px solid #424242; text-align: left; font-size: 16px; color: var(--text); text-decoration: none;
  transition: background .12s, border-color .12s;
}
.tool-card:hover { background: #333; border-color: #5a5a5a; }
.tool-card svg { width: 26px; height: 26px; color: var(--accent); stroke-width: 1.7; }
.tool-card span { min-width: 0; }

.section-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.all-tools { display: grid; gap: 36px; }
.all-tools .tool-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.tool-card.big { align-items: flex-start; padding: 18px; min-height: 0; }
.tool-card.big b { display: block; font-weight: 600; }
.tool-card.big small { display: block; color: var(--muted); font-size: 14px; margin-top: 3px; line-height: 1.4; }

.recent { margin-top: 56px; }
.recent .tabsbar { margin: 0 0 18px; }
.rtable { width: 100%; border-collapse: collapse; }
.rtable th { text-align: left; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #cfcfcf; padding: 14px 16px; }
.rtable td { padding: 14px 16px; border-top: 1px solid #333; vertical-align: middle; }
.rtable tbody tr { background: #262626; cursor: pointer; }
.rtable tbody tr:hover { background: #2e2e2e; }
.rtable .rname { display: flex; align-items: center; gap: 22px; min-width: 0; }
.rtable .doc-ic { width: 40px; height: 48px; border: 1.5px solid #d0d0d0; border-radius: 3px; display: grid; place-items: center; flex-shrink: 0; position: relative; font-size: 10px; font-weight: 700; color: #e6e6e6; }
.rtable .doc-ic::after { content: ""; position: absolute; top: -1.5px; right: -1.5px; width: 10px; height: 10px; background: #262626; border-left: 1.5px solid #d0d0d0; border-bottom: 1.5px solid #d0d0d0; }
.rtable tr:hover .doc-ic::after { background: #2e2e2e; }
.rtable .rname b { display: block; font-weight: 400; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtable .rname small { display: block; color: var(--muted); font-size: 14px; margin-top: 3px; }
.rtable .num { font-variant-numeric: tabular-nums; color: #e0e0e0; white-space: nowrap; }
.rtable .act { width: 56px; text-align: right; }
.col-name { width: 60%; }
.recent-empty { padding: 34px 16px; text-align: center; color: var(--muted); border: 1px dashed #444; border-radius: 8px; }
.recent-empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 4px; }
.drop-overlay { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: rgba(20, 30, 60, .78); border: 3px dashed var(--primary-hover); color: #fff; font-size: 24px; font-weight: 700; }
.drop-overlay.on { display: grid; }

/* ---------- Search palette ---------- */
.palette { width: min(560px, calc(100vw - 32px)); }
.palette form { padding: 14px; }
.palette .input { width: 100%; font-size: 17px; padding: 12px 14px; }
.palette-list { margin-top: 10px; max-height: 50vh; overflow-y: auto; display: grid; gap: 2px; }
.palette-list a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; text-decoration: none; }
.palette-list a.on, .palette-list a:hover { background: var(--surface-2); }
.palette-list a svg { color: var(--accent); }
.palette-list small { color: var(--muted); margin-left: auto; font-size: 13px; text-align: right; }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 10px; padding: 56px 24px; border: 2px dashed var(--border-strong); border-radius: 12px;
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: #262c3d; }
.dropzone .dz-icon { width: 64px; height: 64px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: #8fadff; margin-bottom: 6px; }
.dropzone .dz-icon svg { width: 30px; height: 30px; }
.dropzone strong { font-size: 19px; }
.dropzone span { color: var(--muted); font-size: 15px; }
.dropzone.compact { padding: 20px 16px; flex-direction: row; gap: 14px; }
.dropzone.compact .dz-icon { width: 44px; height: 44px; margin: 0; }
.dropzone.compact .dz-icon svg { width: 22px; height: 22px; }
.dropzone.compact strong { font-size: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px; border: 2px solid #8a8a8a;
  background: transparent; font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; color: var(--text);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(255, 255, 255, .08); border-color: #bdbdbd; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.lg { padding: 11px 26px; font-size: 16px; }
.btn.sm { padding: 5px 13px; font-size: 14px; border-width: 1.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- File bar & panels ---------- */
.filebar {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.file-badge { width: 40px; height: 48px; border-radius: 3px; border: 1.5px solid #d0d0d0; color: #ff6b6b; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.file-meta { min-width: 0; flex: 1; }
.file-meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 16px; }
.file-meta small { color: var(--muted); font-size: 14px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.row + .row { margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; font-size: 13px; }
.input, select.input {
  padding: 8px 12px; border: 1px solid #4d4d4d; border-radius: 6px; background: var(--field); min-width: 0; font-size: 15px; color: var(--text);
}
.input:hover { border-color: #666; }
.input:focus { outline: 2px solid var(--primary-line); outline-offset: 0; border-color: var(--primary); }
select.input option, select.input optgroup { background: #2a2a2a; color: var(--text); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--field); border: 1px solid #3f3f3f; border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: #fff; box-shadow: inset 0 0 0 1px #5a5a5a; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { font-size: 14px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 14px; line-height: 1.5; margin-top: 12px; border: 1px solid rgba(250, 204, 21, .2); }
.note svg { width: 18px; height: 18px; margin-top: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid #555; background: transparent; color: var(--text); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: #888; background: rgba(255, 255, 255, .06); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.size-input { display: inline-flex; align-items: stretch; }
.size-input .input { width: 110px; border-radius: 6px 0 0 6px; font-variant-numeric: tabular-nums; }
.size-input select.input { width: auto; border-radius: 0 6px 6px 0; border-left: 0; }
.big-target { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.meter { margin-top: 14px; display: grid; gap: 6px; }
.meter-bar { position: relative; height: 10px; border-radius: 5px; background: var(--field); border: 1px solid #3a3a3a; overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #3d6dff, #5bb0ff); border-radius: 5px; }
.meter-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; }
.meter-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Thumbnails ---------- */
.grid-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.grid-toolbar .count { margin-left: auto; font-size: 14px; color: var(--muted); }
.grid-toolbar .input { padding: 5px 10px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.thumb {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px; border-radius: 8px; background: var(--surface); border: 2px solid transparent;
  outline: 1px solid var(--border); user-select: none; -webkit-user-select: none;
}
.thumb.selectable { cursor: pointer; }
.thumb.selectable:hover { background: var(--surface-2); }
.thumb.selected { border-color: var(--primary); outline-color: transparent; background: #263052; }
.thumb.selected.del { border-color: var(--danger); background: #3a2426; }
.thumb.selected.del .thumb-page { opacity: .4; }
.thumb.sortable { cursor: grab; }
.thumb.sortable-ghost { opacity: .35; }
.thumb.sortable-chosen { box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.thumb-page { width: 100%; aspect-ratio: 1 / 1.3; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb-page canvas, .thumb-page img { max-width: 100%; max-height: 100%; background: var(--paper); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); transition: transform .2s; }
.thumb-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.thumb-check {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  background: #1f1f1f; border: 2px solid #777; display: grid; place-items: center; color: #fff;
}
.thumb-check svg { width: 14px; height: 14px; stroke-width: 3; }
.thumb.selected .thumb-check { background: var(--primary); border-color: var(--primary); }
.thumb.selected.del .thumb-check { background: var(--danger); border-color: var(--danger); }
.thumb-actions { display: flex; gap: 4px; }
.thumb-actions .icon-btn { width: 32px; height: 32px; }
.thumb-actions svg { width: 17px; height: 17px; }
.thumb-remove { position: absolute; top: 6px; right: 6px; background: #1f1f1f; border: 1px solid #555; width: 28px; height: 28px; border-radius: 50%; }
.thumb-remove svg { width: 15px; height: 15px; }
.insert-marker { border: 2px dashed #a3e635; background: rgba(163, 230, 53, .08); color: #c6f37a; display: grid; place-items: center; font-weight: 700; font-size: 14px; border-radius: 8px; min-height: 120px; text-align: center; padding: 10px; }

/* ---------- File list (merge) ---------- */
.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.file-item canvas { width: 46px; height: 60px; object-fit: contain; background: var(--paper); border-radius: 2px; }
.file-item .handle { cursor: grab; color: var(--muted); padding: 6px; display: flex; }
.file-item.sortable-ghost { opacity: .4; }

/* ---------- Action bar ---------- */
.actionbar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; justify-content: flex-end;
  margin: 24px calc(-1 * var(--gut-r)) -120px calc(-1 * var(--gut-l)); padding: 14px var(--gut-r) calc(14px + var(--safe-b)) var(--gut-l);
  background: rgba(29, 29, 29, .94); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
}
.actionbar .summary { margin-right: auto; color: var(--muted); font-size: 15px; }

/* ---------- Result ---------- */
.result { text-align: center; padding: 40px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.result .ok { width: 64px; height: 64px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin: 0 auto 14px; }
.result .ok.warn { background: var(--warn-bg); color: var(--warn-text); }
.result .ok svg { width: 32px; height: 32px; }
.result h2 { margin: 0 0 6px; font-size: 24px; }
.result p { margin: 0 0 22px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.result .btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.result-files { max-width: 560px; margin: 22px auto 0; text-align: left; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.result-files a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; font-size: 15px; }
.result-files a:hover { background: var(--surface-2); }
.result-files a span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-files a small { color: var(--muted); }
.stat { display: inline-flex; gap: 28px; justify-content: center; margin: 4px 0 22px; padding: 14px 26px; background: var(--field); border: 1px solid #333; border-radius: 10px; }
.stat div { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); }
.stat b { font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .good { color: var(--success); }
.stat .bad { color: var(--warn-text); }
.again { max-width: 620px; margin: 26px auto 0; padding: 18px 20px; text-align: left; background: var(--field); border: 1px solid #383838; border-radius: 10px; }
.again h4 { margin: 0 0 4px; font-size: 17px; }
.again p { margin: 0 0 14px; font-size: 14px; }
.again .row { gap: 10px; }

/* ---------- Viewer ---------- */
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 6px 16px;
  background: var(--bar); border-bottom: 1px solid #2f2f2f; position: relative; z-index: 3;
}
.viewer-toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 6px; }
.viewer-toolbar .page-ind { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.viewer-toolbar .page-ind input { width: 54px; text-align: center; padding: 5px 4px; }
.viewer-toolbar select.input { padding: 5px 8px; font-size: 15px; }
.viewer-toolbar .grow { flex: 1; }
.viewer-toolbar .fname { font-weight: 600; font-size: 15px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px; }
.search-box { display: flex; align-items: center; gap: 4px; }
.search-box input { width: 190px; padding: 5px 10px; font-size: 15px; }
.search-box small { font-size: 13px; color: var(--muted); min-width: 54px; }
.viewer-body { flex: 1; display: flex; min-height: 0; }
.viewer-side { width: 190px; overflow-y: auto; background: #202020; border-right: 1px solid #2f2f2f; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.viewer-side[hidden] { display: none; }
.vthumb { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 6px; font-size: 13px; color: var(--muted); border: 2px solid transparent; }
.vthumb:hover { background: var(--surface-2); }
.vthumb.on { border-color: var(--primary); color: #fff; font-weight: 600; }
.vthumb .ph { width: 130px; min-height: 60px; display: flex; justify-content: center; }
.vthumb canvas { max-width: 130px; box-shadow: 0 1px 4px rgba(0, 0, 0, .6); background: var(--paper); }
.viewer-scroll { flex: 1; overflow: auto; background: var(--canvas); padding: 24px 16px; position: relative; }
.viewer-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.vpage { position: relative; background: var(--paper); box-shadow: 0 2px 14px rgba(0, 0, 0, .6); }
.vpage canvas { display: block; }
.viewer-info { width: 300px; overflow-y: auto; background: var(--bar); border-left: 1px solid #2f2f2f; padding: 18px; font-size: 15px; }
.viewer-info[hidden] { display: none; }
.viewer-info h4 { margin: 0 0 14px; font-size: 16px; }
.viewer-info dl { margin: 0; display: grid; gap: 12px; }
.viewer-info dt { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.viewer-info dd { margin: 2px 0 0; word-break: break-word; }
.viewer-empty { padding: 32px var(--gut-r) 32px var(--gut-l); max-width: 900px; margin: 0 auto; width: 100%; }

/* pdf.js text layer */
.textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0 0; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer .hl { background: rgba(250, 204, 21, .45); border-radius: 2px; }
.textLayer .hl.cur { background: rgba(249, 115, 22, .55); }
.textLayer ::selection { background: rgba(61, 109, 255, .35); }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: -1; cursor: default; user-select: none; }

/* ---------- Busy / modal / toast ---------- */
.busy { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 100; }
.busy[hidden] { display: none; }
.busy-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px 32px; min-width: 300px; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow); }
.busy-card p { margin: 14px 0 12px; font-weight: 600; }
.spinner { width: 40px; height: 40px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; border-radius: 3px; background: var(--field); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.modal { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal form { padding: 24px; }
.modal h3 { margin: 0 0 6px; font-size: 20px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.modal .input { width: 100%; }
.modal .btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal .err { color: var(--danger); font-size: 14px; margin-top: 8px; min-height: 1em; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #f2f2f2; color: #161616; padding: 12px 18px; border-radius: 8px; font-size: 15px; font-weight: 600; z-index: 120;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #d93b3b; color: #fff; }

/* ---------- Edit PDF ---------- */
.ed-view { display: flex; flex-direction: column; height: 100%; }
.ed-bar { display: flex; gap: 4px; padding: 6px 16px; background: var(--bar); border-bottom: 1px solid #2f2f2f; overflow-x: auto; }
.ed-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 10px; min-width: 70px; border: 0; border-radius: 8px; background: none; color: #cfcfcf; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ed-tool:hover { background: var(--surface-2); color: #fff; }
.ed-tool.on { background: var(--primary-soft); color: #fff; box-shadow: inset 0 0 0 1px var(--primary-line); }
.ed-tool.on svg { color: #8fadff; }
.ed-tool svg { width: 21px; height: 21px; }
.ed-props { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 16px; background: #1f1f1f; border-bottom: 1px solid #2f2f2f; min-height: 54px; }
.ed-props .grow { flex: 1; }
.ed-props .btn.primary { padding: 7px 18px; }
.ed-grp { display: inline-flex; align-items: center; gap: 6px; }
.ed-grp[hidden] { display: none; }
.input.sm { padding: 6px 8px; font-size: 14px; }
.ed-color { width: 36px; height: 34px; padding: 2px; border: 1px solid #4d4d4d; border-radius: 6px; background: var(--field); cursor: pointer; }
.tog { width: 34px; height: 34px; border: 1px solid #4d4d4d; border-radius: 6px; background: var(--field); cursor: pointer; font-size: 15px; color: var(--text); }
.tog.on { background: var(--primary-soft); border-color: var(--primary); color: #fff; }
.tog:disabled { opacity: .4; cursor: default; }
.ed-hint { font-size: 14px; color: var(--muted); }
.ed-scroll { flex: 1; overflow: auto; background: var(--canvas); padding: 24px 16px 80px; }
.ed-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.ed-page { position: relative; background: var(--paper); box-shadow: 0 2px 14px rgba(0, 0, 0, .6); flex-shrink: 0; }
.ed-page canvas { display: block; }
.ed-layer { position: absolute; inset: 0; z-index: 2; overflow: hidden; }
.m-text .ed-layer { cursor: text; }
.m-draw .ed-layer, .m-highlight .ed-layer, .m-rect .ed-layer, .m-whiteout .ed-layer, .m-editimage .ed-layer { cursor: crosshair; touch-action: none; }
.m-draw .ed-obj, .m-highlight .ed-obj, .m-rect .ed-obj, .m-whiteout .ed-obj { pointer-events: none; }
.ed-obj { position: absolute; box-sizing: border-box; touch-action: none; cursor: move; user-select: none; -webkit-user-select: none; }
.ed-obj.sel { outline: 2px solid var(--primary); outline-offset: 2px; }
.ed-tmp { pointer-events: none; }
.ed-text { white-space: pre; line-height: 1.2; }
.ed-text .t { outline: none; min-width: 6px; min-height: 1.2em; }
.ed-text .t:empty::before { content: 'Type here'; color: #94a3b8; }
.ed-text.editing { cursor: text; user-select: text; -webkit-user-select: text; outline: 2px dashed var(--primary); outline-offset: 2px; }
.ed-text.editing .t { user-select: text; -webkit-user-select: text; }
.ed-highlight { opacity: .4; mix-blend-mode: multiply; }
.ed-rect { border-style: solid; }
.ed-image img { width: 100%; height: 100%; display: block; pointer-events: none; }
.ed-ink svg { position: absolute; left: 0; top: 0; overflow: visible; fill: none; }
.ed-handle { position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); cursor: nwse-resize; display: none; }
.ed-obj.sel .ed-handle { display: block; }
.ed-hot { position: absolute; display: none; border-radius: 3px; cursor: text; }
.m-edittext .ed-hot { display: block; box-shadow: inset 0 0 0 1px rgba(61, 109, 255, .35); }
.m-edittext .ed-hot.scan { box-shadow: inset 0 0 0 1px rgba(236, 72, 153, .4); }
.m-edittext .ed-hot:hover { background: rgba(61, 109, 255, .12); box-shadow: inset 0 0 0 2px rgba(61, 109, 255, .8); }
.ed-hot[hidden] { display: none !important; }
.ed-ocr { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: none; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: rgba(20, 20, 20, .9); color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; z-index: 3; }
.m-edittext .ed-ocr { display: flex; }
.ed-ocr.retry { cursor: pointer; background: #b91c1c; }
.ed-ocr .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; border-top-color: transparent; animation: spin .8s linear infinite; }
.ed-imghot { position: absolute; display: none; pointer-events: none; border-radius: 2px; }
.m-editimage .ed-imghot { display: block; box-shadow: inset 0 0 0 2px rgba(168, 85, 247, .6); background: rgba(168, 85, 247, .06); }
.ed-marquee { border: 2px dashed #a855f7; background: rgba(168, 85, 247, .12); }
.modal.wide { width: min(640px, calc(100vw - 24px)); }
.sig-pad { width: 100%; height: auto; aspect-ratio: 900 / 330; border: 2px dashed #666; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.sig-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px #777; cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--primary-hover); }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
  .tool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .topnav .tn-link { padding: 0 9px; font-size: 15px; }
  .hero { grid-template-columns: 200px minmax(0, 1fr); padding-right: 56px; }
  .hero-art svg { width: 160px; height: 136px; }
  .hero-cta { grid-column: 2; flex-direction: row; }
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .topnav { display: none; }
  .appbar .menu-btn { display: inline-flex; margin-left: -6px; }
  .appbar { height: 56px; padding-top: env(safe-area-inset-top, 0px); height: calc(56px + env(safe-area-inset-top, 0px)); }
  .brand { margin-right: 0; }
  .brand-name { font-size: 17px; }
  .pill#installBtn span { display: none; }
  .pill#installBtn { padding: 0 10px; height: 36px; }
  .pagehead { padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .pagehead h1 { font-size: 18px; }
  .pagehead p { font-size: 13px; }
  .back-link span { display: none; }
  .title-icon { width: 34px; height: 34px; }
  .home { padding-top: 14px; }
  .hero-band { padding-top: 12px; }
  .hero { grid-template-columns: minmax(0, 1fr); margin: 0; padding: 24px 20px; gap: 16px; }
  .hero-art { display: none; }
  .hero-cta { grid-column: auto; flex-direction: column; }
  .ticks li { font-size: 16px; }
  .hero.collapsed { grid-template-columns: minmax(0, 1fr); padding: 14px 56px 14px 18px; }
  .hero.collapsed .hero-cta { display: none; }
  .tabsbar { margin: 26px 0 14px; gap: 10px; }
  .tab { font-size: 16px; }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tool-card { min-height: 60px; padding: 10px 14px; font-size: 15px; gap: 10px; }
  .tool-card svg { width: 22px; height: 22px; }
  .rtable .hide-sm, .rtable th.hide-sm { display: none; }
  .rtable td, .rtable th { padding: 12px 10px; }
  .rtable .rname { gap: 14px; }
  .rtable .rname b { font-size: 16px; }
  .col-name { width: auto; }
  .tool-wrap { padding-top: 16px; padding-bottom: 110px; }
  .actionbar { margin-bottom: -110px; padding-top: 12px; padding-bottom: calc(12px + var(--safe-b)); }
  .actionbar .btn.lg { flex: 1; }
  .actionbar .summary { display: none; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .thumb { padding: 6px; }
  .viewer-toolbar { padding: 6px 8px; }
  .viewer-toolbar .fname, .viewer-toolbar .hide-sm { display: none; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; min-width: 80px; }
  .viewer-toolbar .grow { display: none; }
  .viewer-side { position: absolute; z-index: 4; top: 0; bottom: 0; left: 0; box-shadow: 4px 0 20px rgba(0, 0, 0, .5); }
  .viewer-body { position: relative; }
  .viewer-info { position: absolute; z-index: 4; top: 0; bottom: 0; right: 0; width: min(300px, 90vw); box-shadow: -4px 0 20px rgba(0, 0, 0, .5); }
  .viewer-scroll { padding: 12px 6px; }
  .dropzone { padding: 40px 16px; }
  .ed-bar { padding: 6px 8px; }
  .ed-tool { min-width: 60px; padding: 6px; font-size: 12px; }
  .ed-props { padding: 6px 8px; gap: 6px; }
  .ed-props .ed-hint { display: none; }
  .ed-scroll { padding: 12px 6px 80px; }
  .ed-props .btn.primary { margin-left: auto; }
  .stat { gap: 18px; padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ed-ocr .dot, .spinner { animation: none; }
  .drawer { transition: none; }
}
