/* WePDF web app. Themes mirror the Android app's Light / Dark / Accent colour schemes. */

:root {
  --bg: #F6F8FC;
  --surface: #FFFFFF;
  --surface-2: #EEF2FA;
  --border: #E6EAF5;
  --ink: #0F1B3C;
  --muted: #5B6785;
  --primary: #2563EB;
  --on-primary: #FFFFFF;
  --primary-soft: #E3ECFF;
  --primary-ink: #1D4ED8; /* text on --primary-soft: 4.5:1+ */
  --secondary: #14B8A6;
  --danger: #DC2626;
  --success: #16A34A;
  --added-bg: #DCFCE7;
  --removed-bg: #FEE2E2;
  --brand-red: #E8412C;
  --shadow: 0 1px 2px rgb(15 27 60 / 0.06), 0 4px 16px rgb(15 27 60 / 0.06);
  --shadow-lg: 0 12px 40px rgb(15 27 60 / 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Helvetica, Arial, sans-serif;
  --rail-w: 248px;
  --topbar-h: 60px;
  --bottom-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0B1020;
  --surface: #10162C;
  --surface-2: #161E3A;
  --border: #232B4A;
  --ink: #E7ECFB;
  --muted: #AEB8DD;
  --primary: #5B8DFF;
  --on-primary: #0B1020;
  --primary-soft: #1C2A55;
  --primary-ink: #A9C1FF;
  --secondary: #2DD4BF;
  --danger: #F87171;
  --success: #4ADE80;
  --added-bg: #123D26;
  --removed-bg: #4A1A1D;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

:root[data-theme="accent"] {
  --bg: #FAF5FF;
  --surface: #FFFFFF;
  --surface-2: #F3E8FF;
  --border: #EADCF8;
  --ink: #2A123F;
  --muted: #7C6690;
  --primary: #7C3AED;
  --on-primary: #FFFFFF;
  --primary-soft: #EDE3FD;
  --primary-ink: #6425D0;
  --secondary: #EC4899;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; margin: 0; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.visually-hidden, .sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Shell ---------- */

.app { display: flex; min-height: 100%; }

.rail {
  width: var(--rail-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px;
  border-inline-end: 1px solid var(--border);
  background: var(--surface);
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; text-decoration: none; color: var(--ink); }
.rail-brand img { width: 34px; height: 34px; }
.wordmark { font-weight: 800; font-size: 21px; letter-spacing: -0.02em; }
.wordmark .we { background: linear-gradient(135deg, #FF7A45, #E03131); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-link {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); }
.rail-spacer { flex: 1; }
.rail-foot { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--border); }
.rail-foot a { font-size: 13px; color: var(--muted); text-decoration: none; padding: 6px 14px; border-radius: 8px; }
.rail-foot a:hover { color: var(--ink); background: var(--surface-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-mark { display: grid; place-items: center; min-width: 44px; min-height: 44px; margin-inline: 2px 0; border-radius: 10px; }
.topbar-mark img { width: 28px; height: 28px; }
.topbar-title { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }

#view { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 20px 16px 120px; }

.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: none; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 0; padding-inline: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.bottom-nav a > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav a .pill { padding: 3px 14px; border-radius: 999px; }
.bottom-nav a[aria-current="page"] { color: var(--ink); }
.bottom-nav a[aria-current="page"] .pill { background: var(--primary-soft); color: var(--primary-ink); }

@media (max-width: 899px) {
  .rail { display: none; }
  .bottom-nav { display: grid; }
  #view { padding-bottom: calc(var(--bottom-h) + 110px); }
}
@media (min-width: 900px) {
  .topbar-mark { display: none; }
}

/* ---------- Buttons & controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); background: var(--primary); }
.btn.tonal { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }
.btn.text { background: none; border-color: transparent; color: var(--primary); padding: 0 12px; }
.btn.text:hover { background: var(--primary-soft); }
.btn.danger { color: var(--danger); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.lg { min-height: 50px; font-size: 16px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.on { color: #F5A524; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-input, select.field-input, textarea.field-input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
textarea.field-input { min-height: 90px; resize: vertical; }
.field-input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.field-error { color: var(--danger); font-size: 13px; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface); gap: 2px; }
.segmented button, .segmented label { display: inline-flex; align-items: center; min-height: 40px; border: 0; background: none; padding: 0 16px; border-radius: 999px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"], .segmented label:has(input:checked) { background: var(--primary-soft); color: var(--primary-ink); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (pointer: coarse) { .segmented button, .segmented label { min-height: 44px; } }

/* Descriptive single-choice options (e.g. compression level). Native radios underneath. */
.option-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.option-cards label {
  position: relative; display: block; padding: 14px 16px 14px 44px; min-height: 44px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.option-cards label::before {
  content: ""; position: absolute; inset-inline-start: 16px; top: 17px; width: 16px; height: 16px;
  border-radius: 50%; border: 2px solid var(--muted); box-sizing: border-box;
}
.option-cards label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.option-cards label:has(input:checked)::before { border: 5px solid var(--primary); }
.option-cards label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.option-cards .option-body { display: grid; gap: 2px; }
.option-cards .option-label { font-weight: 700; }
.option-cards .option-desc { font-size: 13px; color: var(--muted); }
[dir="rtl"] .option-cards label { padding: 14px 44px 14px 16px; }

details.advanced { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
details.advanced > summary { min-height: 44px; display: flex; align-items: center; padding: 0 14px; cursor: pointer; font-weight: 600; color: var(--primary); }
details.advanced[open] > summary { border-bottom: 1px solid var(--border); }
details.advanced > div { padding: 14px; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + span::after { transform: translateX(-18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

input[type="range"] { width: 100%; accent-color: var(--primary); }
input[type="checkbox"] { accent-color: var(--primary); width: 18px; height: 18px; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }

/* ---------- Layout helpers ---------- */

.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card.flat { box-shadow: none; }
.card.link { display: block; text-decoration: none; color: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.card.link:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow); }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.lead { color: var(--muted); max-width: 62ch; }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 4px 0; }

/* ---------- Home ---------- */

.home-top { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .home-top { grid-template-columns: 1.2fr 1fr; } }
.streak-card { display: flex; align-items: center; gap: 14px; }
.streak-card .flame { font-size: 30px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, #F97316 14%, var(--surface)); }
.streak-card h3 { font-size: 17px; }
.seasonal { display: flex; align-items: center; gap: 12px; background: color-mix(in srgb, var(--secondary) 12%, var(--surface)); border-color: color-mix(in srgb, var(--secondary) 30%, var(--border)); }
.seasonal .emoji { font-size: 26px; }

.doc-list { display: grid; gap: 8px; }
.doc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s, background .3s;
}
.doc-row:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.doc-row.selected { border-color: var(--primary); background: var(--primary-soft); }
.doc-row.highlight { animation: highlight 2.4s ease-out; }
@keyframes highlight { 0%, 30% { background: color-mix(in srgb, var(--secondary) 22%, var(--surface)); border-color: var(--secondary); } }
.doc-thumb {
  width: 42px; height: 52px; flex: none; border-radius: 6px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand-red) 10%, var(--surface)); color: var(--brand-red); font-size: 11px; font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--brand-red) 20%, transparent);
}
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.lock { background: color-mix(in srgb, #F59E0B 18%, var(--surface)); color: #B45309; }
:root[data-theme="dark"] .tag.lock { color: #FBBF24; }
.doc-actions { display: flex; align-items: center; }
@media (max-width: 560px) { .doc-actions .hide-sm { display: none; } }

.selection-bar {
  position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 15;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: var(--radius); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg);
}
.selection-bar .btn { min-height: 36px; background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.selection-bar .icon-btn { color: inherit; }

.empty { text-align: center; padding: 48px 16px; display: grid; justify-items: center; gap: 10px; }
.empty .empty-art { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }

.fab-stack { position: fixed; inset-inline-end: 22px; bottom: 26px; z-index: 25; display: grid; gap: 12px; justify-items: end; }
@media (max-width: 899px) { .fab-stack { bottom: calc(var(--bottom-h) + 18px + env(safe-area-inset-bottom, 0px)); } }
.fab { display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 20px; border: 0; border-radius: 18px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-lg); background: var(--primary); color: var(--on-primary); }
.fab.secondary { height: 48px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); }

.drop-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 18%, transparent); backdrop-filter: blur(3px);
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
.drop-overlay.show { opacity: 1; }
.drop-overlay .drop-card { padding: 28px 36px; border-radius: 22px; background: var(--surface); border: 2px dashed var(--primary); font-weight: 700; box-shadow: var(--shadow-lg); }

/* ---------- Toolkit ---------- */

.tool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tool-tile {
  display: grid; gap: 10px; align-content: start; padding: 16px; min-height: 112px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; color: var(--ink); font-weight: 650; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tool-tile:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow); transform: translateY(-1px); }
.tool-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--tint, var(--primary)); background: color-mix(in srgb, var(--tint, var(--primary)) 13%, var(--surface)); }

/* ---------- Tool wizard ---------- */

.tool-hero { display: grid; gap: 8px; }
.privacy-notice { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; font-weight: 600; color: #15803D; }
.privacy-notice .icon { margin-top: 1px; }
:root[data-theme="dark"] .privacy-notice { color: var(--success); }
.privacy-notice .dot { color: var(--muted); }

.drop-zone {
  display: grid; justify-items: center; gap: 8px; text-align: center;
  padding: 32px 20px; border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 18px; background: color-mix(in srgb, var(--primary) 4%, var(--surface));
  cursor: pointer; transition: border-color .15s, background .15s, transform .15s;
}
.drop-zone:hover { border-color: var(--primary); }
.drop-zone.dragover { border-color: var(--primary); border-style: solid; background: var(--primary-soft); transform: scale(1.01); }
.drop-zone-art { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.drop-zone-title { font-size: 17px; font-weight: 700; }
.drop-zone.compact { grid-auto-flow: column; justify-content: start; align-items: center; text-align: start; padding: 14px 16px; gap: 12px; }
.drop-zone.compact .drop-zone-title { font-size: 15px; }
.drop-zone.compact .drop-zone-or { display: none; }
.drop-zone.compact .btn.lg { min-height: 44px; font-size: 15px; }
@media (max-width: 560px) {
  /* On phones the button is the primary path; dragging is rare. */
  .drop-zone { padding: 22px 16px; }
  .drop-zone .drop-zone-title, .drop-zone .drop-zone-or { display: none; }
  .drop-zone .btn.lg { width: 100%; }
  .drop-zone.compact { grid-auto-flow: row; justify-content: stretch; }
}
.file-errors { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-error {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}
.file-error-name { font-weight: 650; overflow-wrap: anywhere; }

.picker-title { font-size: 14px; font-weight: 700; color: var(--muted); }
.pick-row.chosen { cursor: default; border-color: var(--primary); background: var(--primary-soft); }

/* One dominant action; sticks to the bottom on small screens so it's always within reach. */
.cta-bar { display: grid; gap: 6px; justify-items: start; }
.cta-hint { color: var(--muted); }
@media (max-width: 899px) {
  .cta-bar {
    position: sticky; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px)); z-index: 12;
    margin-inline: -16px; padding: 10px 16px; justify-items: stretch;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
  }
  .cta-bar .btn { width: 100%; }
  .cta-hint { text-align: center; }
}

.feedback { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--radius); border: 1px solid; }
.feedback.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.feedback.warn { border-color: color-mix(in srgb, #F59E0B 55%, var(--border)); background: color-mix(in srgb, #F59E0B 9%, var(--surface)); }
.feedback-ico {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 14px; color: #fff; background: #B91C1C;
}
.feedback.warn .feedback-ico { background: #B45309; }
.feedback-title { font-size: 17px; font-weight: 750; }
.feedback-title:focus { outline: none; }
.tips { margin: 0; padding-inline-start: 20px; display: grid; gap: 2px; }

.success-panel { display: grid; gap: 16px; justify-items: start; }
.success-head { display: flex; align-items: center; gap: 14px; }
.success-mark { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #15803D; flex: none; }
.success-title { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.success-title:focus { outline: none; }
.result-stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; margin: 0; padding: 14px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.result-stats dt { color: var(--muted); }
.result-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-stats dd.strong { color: #15803D; font-size: 18px; font-weight: 800; }
:root[data-theme="dark"] .result-stats dd.strong { color: var(--success); }
.result-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; width: 100%; max-height: 360px; overflow-y: auto; }
.result-file { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.result-thumb { width: 42px; height: 52px; object-fit: cover; border-radius: 6px; flex: none; background: #fff; box-shadow: 0 0 0 1px var(--border); }
.success-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
@media (max-width: 560px) { .success-actions, .success-actions .btn { width: 100%; } }
.start-again { padding-inline: 8px; }
.related { display: grid; gap: 10px; width: 100%; padding-top: 16px; border-top: 1px solid var(--border); }
.tool-grid.compact .tool-tile { min-height: 0; grid-auto-flow: column; justify-content: start; align-items: center; padding: 12px; }
.tool-grid.compact .tool-ico { width: 36px; height: 36px; }
.tag.added { background: var(--added-bg); color: var(--ink); }
.tag.removed { background: var(--removed-bg); color: var(--ink); }
.show-pw { flex: none; }

.wizard { display: grid; gap: 18px; max-width: 760px; }
.wizard > .btn, .wizard section > .btn { justify-self: start; }
.step-title { font-size: 15px; font-weight: 700; }
.picker { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; padding: 2px; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.pick-row:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.pick-row[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); }
.pick-order { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 2px solid var(--border); color: var(--muted); }
.pick-row[aria-checked="true"] .pick-order { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.result-card { display: grid; gap: 12px; border-color: color-mix(in srgb, var(--success) 40%, var(--border)); background: color-mix(in srgb, var(--success) 7%, var(--surface)); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .2s; }

.thumb-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.thumb {
  position: relative; display: grid; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.thumb.off { opacity: .45; }
.thumb canvas, .thumb img { width: 100%; height: auto; border-radius: 4px; background: #fff; box-shadow: 0 0 0 1px var(--border); transition: transform .2s; }
.thumb-label { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.thumb-tools { display: flex; justify-content: center; flex-wrap: wrap; }
.thumb-tools .icon-btn { width: 36px; height: 36px; }
@media (pointer: coarse) { .thumb-tools .icon-btn { width: 44px; height: 44px; } }
.thumb.dragging { opacity: .4; }
.thumb.drop-target { outline: 2px dashed var(--primary); }

.page-stage { position: relative; width: 100%; max-width: 640px; margin: 0 auto; user-select: none; touch-action: none; }
.page-stage canvas.page { display: block; width: 100% !important; height: auto !important; background: #fff; border-radius: 4px; box-shadow: var(--shadow); }
.page-stage .overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.stamp { position: absolute; border: 1.5px dashed var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); cursor: grab; touch-action: none; }
.stamp img { width: 100%; height: 100%; display: block; pointer-events: none; }
.stamp:active { cursor: grabbing; }
.pending-field { position: absolute; border: 1.5px solid var(--secondary); background: color-mix(in srgb, var(--secondary) 15%, transparent); border-radius: 3px; font-size: 10px; padding: 1px 3px; color: var(--ink); overflow: hidden; white-space: nowrap; pointer-events: none; }

.sig-pad { width: 100%; height: 200px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; display: block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; flex: none; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

.diff { font: 13px/1.55 ui-monospace, "SF Mono", Consolas, monospace; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: auto; max-height: 70vh; background: var(--surface); }
.diff div { padding: 1px 10px; white-space: pre-wrap; word-break: break-word; }
.diff .ADDED { background: var(--added-bg); }
.diff .REMOVED { background: var(--removed-bg); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.diff .ADDED::before { content: "+ "; color: var(--success); font-weight: 700; }
.diff .REMOVED::before { content: "− "; color: var(--danger); font-weight: 700; }
.diff .UNCHANGED::before { content: "  "; }

/* ---------- Viewer ---------- */

/* Zoomed-in pages scroll sideways inside the viewer rather than widening the page. */
.viewer { display: grid; gap: 16px; justify-items: safe center; width: 100%; overflow-x: auto; padding: 4px 0 12px; }
.viewer-page { background: #fff; box-shadow: var(--shadow); border-radius: 3px; position: relative; }
.viewer-page canvas { display: block; }
.viewer-page .page-no { position: absolute; bottom: -22px; inset-inline: 0; text-align: center; font-size: 12px; color: var(--muted); }
.viewer-toolbar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 10; display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* ---------- Search ---------- */

.search-box { position: relative; }
.search-box .icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-inline-start: 46px; border-radius: 999px; min-height: 50px; }
mark { background: color-mix(in srgb, #FACC15 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Insights ---------- */

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }
.stat { display: grid; gap: 2px; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.xp-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.xp-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 150px; padding-top: 8px; }
.bar { display: grid; gap: 6px; justify-items: center; align-items: end; height: 100%; grid-template-rows: 1fr auto auto; }
.bar-fill { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: color-mix(in srgb, var(--primary) 75%, transparent); min-height: 3px; align-self: end; }
.bar.today .bar-fill { background: var(--secondary); }
.bar-count { font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-day { font-size: 12px; color: var(--muted); }
.badge-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.badge { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 14px 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.badge .emoji { font-size: 30px; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.badge-title { font-weight: 700; font-size: 14px; }
.badge-desc { font-size: 12px; color: var(--muted); }
.wrapped-card { background: linear-gradient(135deg, #1C2E73, #4F46E5 55%, #EC4899); color: #fff; border: 0; }
.wrapped-card .muted { color: rgb(255 255 255 / .8); }
.wrapped-hero { padding: 28px 22px; border-radius: 22px; color: #fff; background: linear-gradient(135deg, #0A1128, #1C2E73 45%, #7C3AED 80%, #EC4899); }
.wrapped-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ---------- Settings ---------- */

.settings-group { display: grid; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.setting { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: inherit; background: none; border: 0; width: 100%; text-align: start; cursor: pointer; }
.setting + .setting { border-top: 1px solid var(--border); }
button.setting:hover, a.setting:hover { background: var(--surface-2); }
.setting .icon { color: var(--muted); }
.setting-title { font-weight: 600; }
.setting-desc { font-size: 13px; color: var(--muted); }
.theme-options { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); padding: 14px 16px; }
@media (max-width: 560px) { .theme-options { grid-template-columns: 1fr; } }
.theme-option { display: grid; gap: 8px; padding: 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; text-align: start; }
.theme-option[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.swatch-row { display: flex; gap: 4px; }
.swatch-row i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgb(0 0 0 / .08); }

/* ---------- Dialogs, snackbar, busy ---------- */

.dialog { border: 0; padding: 0; border-radius: 22px; background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(10 17 40 / .45); backdrop-filter: blur(2px); }
.dialog-inner { display: grid; gap: 14px; padding: 22px; }
.dialog-title { font-size: 19px; font-weight: 750; }
.dialog-text { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.lang-list { display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; }
.lang-list button { text-align: start; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; }
.lang-list button:hover { background: var(--surface-2); }
.lang-list button[aria-checked="true"] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }

#snackbar {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 12px; max-width: min(560px, calc(100vw - 32px));
  padding: 12px 12px 12px 18px; border-radius: 12px; background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow-lg); font-weight: 500;
  visibility: hidden; opacity: 0; transition: transform .2s ease, opacity .2s ease, visibility 0s linear .2s;
}
#snackbar.show { transform: translate(-50%, 0); visibility: visible; opacity: 1; transition: transform .2s ease, opacity .2s ease; }
@media (max-width: 899px) { #snackbar { bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom, 0px)); } }
.snack-action { border: 0; background: none; color: color-mix(in srgb, var(--primary) 60%, var(--bg)); font-weight: 800; padding: 6px 10px; border-radius: 8px; cursor: pointer; text-transform: uppercase; letter-spacing: .03em; }

.busy { position: fixed; inset: 0; z-index: 110; display: grid; place-content: center; justify-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(3px); }
.busy-card { display: grid; justify-items: center; gap: 14px; width: min(360px, calc(100vw - 32px)); padding: 24px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.busy-progress { width: 100%; height: 8px; }
.busy-stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; justify-self: stretch; }
.busy-stages li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.busy-stages li.active { color: var(--ink); font-weight: 650; }
.busy-stages li.done { color: var(--success); }
.stage-mark { width: 18px; text-align: center; font-weight: 800; }
.busy-text { font-weight: 600; color: var(--ink); max-width: 80vw; text-align: center; }
.spinner { width: 42px; height: 42px; 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); } }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot img { width: 64px; height: 64px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Tool page search content (server-rendered below the tool on /compress-pdf etc.) ---------- */

.main.has-seo #view { padding-bottom: 32px; }
.seo-info { border-top: 1px solid var(--border); background: var(--surface); }
.seo-inner { max-width: 1040px; margin: 0 auto; padding: 28px 16px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.seo-inner > * { max-width: 760px; }
.seo-inner h2 { font-size: 20px; font-weight: 750; margin-top: 12px; }
.seo-intro { color: var(--muted); }
.seo-steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }
.seo-faq { display: grid; gap: 8px; }
.seo-faq details { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.seo-faq summary { min-height: 44px; display: flex; align-items: center; padding: 8px 14px; font-weight: 650; cursor: pointer; }
.seo-faq details p { padding: 0 14px 14px; color: var(--muted); }
.seo-related { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.seo-related a { display: grid; gap: 2px; height: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink); text-decoration: none; }
.seo-related a:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.seo-related span { font-size: 13px; color: var(--muted); }
@media (max-width: 899px) {
  .main.has-seo #view { padding-bottom: 24px; }
  .seo-inner { padding-bottom: calc(var(--bottom-h) + 40px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Main area focus (moved there on navigation for screen readers; no visible box) ---------- */
#view:focus, #view:focus-visible { outline: none; }

/* ---------- Merge order (drag to reorder) ---------- */
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  transition: box-shadow .15s, transform .15s;
}
.order-item.dragging { box-shadow: var(--shadow-lg); border-color: var(--primary); transform: scale(1.01); position: relative; z-index: 2; }
.drag-handle { display: grid; place-items: center; width: 44px; height: 44px; flex: none; color: var(--muted); cursor: grab; touch-action: none; border-radius: 8px; }
.drag-handle:hover { background: var(--surface-2); color: var(--ink); }
.order-item.dragging .drag-handle { cursor: grabbing; }
.order-num { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--primary); color: var(--on-primary); }

/* ---------- Result preview ---------- */
.result-summary { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.result-preview { display: block; flex: none; border-radius: 6px; background: #fff; box-shadow: var(--shadow), 0 0 0 1px var(--border); line-height: 0; }
a.result-preview:hover { box-shadow: var(--shadow-lg), 0 0 0 2px var(--primary); }
canvas.pdf-thumb { display: block; min-height: 190px; border-radius: 6px; background: #fff; }
canvas.result-thumb { flex: none; min-height: 52px; border-radius: 4px; background: #fff; box-shadow: 0 0 0 1px var(--border); }
canvas.thumb-failed { min-height: 52px; background: var(--surface-2); }

/* ---------- Empty library ---------- */
.empty-links { display: flex; gap: 6px; justify-content: center; }
.empty-links a { font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Wide tools (e-Sign, Redact, Crop) ---------- */
.wizard.wide { max-width: 1120px; }
.esign-work { display: grid; gap: 18px; }
@media (min-width: 1100px) {
  .esign-work.signing { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .esign-work.signing .esign-controls { position: sticky; top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 24px); overflow-y: auto; padding: 4px 4px 0; }
  /* Add signature stays visible at the bottom of the side panel however long it gets. */
  .esign-work.signing .esign-controls .cta-bar { position: sticky; bottom: 0; z-index: 2; padding: 10px 0 12px; background: var(--bg); border-top: 1px solid var(--border); }
}
.page-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.strip-page { flex: none; display: grid; justify-items: center; gap: 2px; padding: 4px; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; min-width: 44px; }
.strip-page canvas { width: 64px; min-height: 80px; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); }
.strip-page[aria-selected="true"] { border-color: var(--primary); color: var(--primary); }
.text-stamp {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; line-height: 1.2;
  color: #0B1F5C; font-family: system-ui, sans-serif; padding: 1px 3px; cursor: grab; touch-action: none;
  border: 1.5px dashed var(--secondary); background: color-mix(in srgb, var(--secondary) 10%, transparent); border-radius: 3px;
}
.text-stamp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

/* ---------- Redact / Crop drawing ---------- */
.draw-layer { cursor: crosshair; }
.draw-box { position: absolute; }
.draw-box.live { border: 2px dashed var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.redact-box { background: #000; outline: 2px solid color-mix(in srgb, var(--danger) 70%, transparent); }
.box-remove {
  position: absolute; top: -14px; inset-inline-end: -14px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; border: 0; background: var(--danger); color: #fff; cursor: pointer; box-shadow: var(--shadow);
}
@media (pointer: coarse) { .box-remove { width: 36px; height: 36px; top: -18px; inset-inline-end: -18px; } }
.crop-shade { position: absolute; background: rgb(10 17 40 / .45); pointer-events: none; }
.crop-box { border: 2px solid var(--primary); pointer-events: none; }

/* ---------- Compress target size ---------- */
.target-box { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.target-box .chip-row { flex-wrap: wrap; overflow: visible; }
.target-box .chip { min-height: 40px; }

/* ---------- Page grid (Split, Page Numbers) ---------- */
.page-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); max-height: 520px; overflow-y: auto; padding: 4px; }
.page-tile { display: grid; gap: 4px; justify-items: center; padding: 6px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; color: var(--muted); font-weight: 700; font-size: 12px; }
.page-tile:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.page-tile[aria-checked="true"] { border-color: var(--primary-ink); background: var(--primary-soft); color: var(--primary-ink); }
.page-canvas { position: relative; display: block; line-height: 0; }
.page-canvas canvas { width: 88px; min-height: 110px; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); }
.page-tile[aria-checked="false"] .page-canvas canvas { opacity: .55; }
.page-badge { position: absolute; font-size: 10px; line-height: 1; font-weight: 800; padding: 2px 4px; border-radius: 4px; background: var(--primary); color: var(--on-primary); }
.page-badge.pos-bottom-center { bottom: 4px; left: 50%; transform: translateX(-50%); }
.page-badge.pos-bottom-right { bottom: 4px; right: 4px; }
.page-badge.pos-top-right { top: 4px; right: 4px; }
.page-tile:not(.pos-set) .page-badge:not([class*="pos-"]) { bottom: 4px; left: 50%; transform: translateX(-50%); }

/* ---------- Install ---------- */
.install-slot:empty { display: none; }
.install-slot { padding: 8px 4px 0; }
.install-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
