/* pdforge — calm, warm, card-based UI inspired by mymind:
   cream surfaces, pastel tints per category, pill shapes, serif headlines. */
@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f6f2ea;         /* tinted rows, thumbs, inputs */
  --text: #1c1a17;
  --muted: #7b7268;
  --border: rgba(28, 26, 23, .09);
  --accent: #e2562a;
  --accent-hover: #c8461f;
  --accent-soft: #ffece2;
  --ok: #4a8a5c;
  --ok-soft: #dde9d3;

  --radius: 20px;
  --radius-sm: 14px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(28, 26, 23, .04), 0 18px 40px -28px rgba(226, 86, 42, .30);
  --shadow-lg: 0 24px 60px -30px rgba(226, 86, 42, .45), 0 2px 8px rgba(28, 26, 23, .06);

  --font-display: "Caveat", "Instrument Serif", ui-serif, Georgia, serif;   /* headings, tool names */
  --font-wordmark: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;

  /* Category tints: soft background + ink for icons and labels */
  --t-organize: #ffece2;  --i-organize: #b8461f;
  --t-optimize: #dfe9d4;  --i-optimize: #4a7238;
  --t-convert: #f7ecd6;   --i-convert: #8a6417;
  --t-edit: #f2eaf2;      --i-edit: #7a4a86;
  --t-security: #e4eaf4;  --i-security: #3b5d92;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --surface: #1f1c18;
    --surface-2: #272320;
    --text: #f2eee7;
    --muted: #a79d92;
    --border: rgba(255, 255, 255, .10);
    --accent: #ff7248;
    --accent-hover: #ff8b67;
    --accent-soft: #3b241b;
    --ok: #79c08d;
    --ok-soft: #26331f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -28px rgba(0, 0, 0, .8);
    --shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, .85), 0 2px 8px rgba(0, 0, 0, .4);

    --t-organize: #3a2419;  --i-organize: #ff9e78;
    --t-optimize: #223021;  --i-optimize: #8fce97;
    --t-convert: #352b16;   --i-convert: #e0b556;
    --t-edit: #2f2433;      --i-edit: #c6a0d6;
    --t-security: #1e2735;  --i-security: #8fb4e8;
  }
}
/* Deliberately monochrome: one card colour everywhere, category only hinted on hover. */
.cat-organize, .cat-optimize, .cat-convert, .cat-edit, .cat-security { --cat: var(--muted); --tint: var(--surface-2); }

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.55 var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 42px 16px 56px; }
h1 {
  font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em;
  font-size: clamp(40px, 5.6vw, 63px); line-height: 1.33; margin: 0 0 4px; text-align: center;
}
h2 { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.15; margin: 10px 0 4px; }
.lead {
  text-align: center; color: #989898; margin: 0 auto 30px; max-width: 620px;
  font-family: var(--font-display); font-size: 22px; line-height: 1.55;
}
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Top bar (floating pill) ---------- */
.topbar {
  /* brand left, tool links centred, actions right - all of it fluid. */
  position: sticky; top: 14px; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  width: min(1180px, calc(100% - 28px)); margin: 14px auto 0; padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border); border-radius: var(--pill);
  box-shadow: var(--shadow);
}
/* Frosts the strip the bar floats in, so page text dissolves instead of
   peeking through the gap above its rounded corners. */
.topbar::before {
  content: ""; position: fixed; left: 0; right: 0; top: 0; height: 90px; z-index: -1; pointer-events: none;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
  background: linear-gradient(to bottom, var(--bg) 40%, color-mix(in srgb, var(--bg) 55%, transparent) 78%, transparent);
}
@media (max-width: 520px) { .topbar::before { height: 72px; } }
/* Older browsers: keep the bar solid rather than see-through. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--surface); }
  .topbar::before { background: var(--bg); }
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-wordmark); font-weight: 400; font-size: 25px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo { display: block; width: 32px; height: 32px; }
.quicknav { flex: 1; display: flex; justify-content: center; gap: 16px; min-width: 0; }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: none; }
.quicknav a, .menu-btn {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px;
  padding: 8px 13px; border-radius: var(--pill); letter-spacing: .01em;
}
.quicknav a:hover, .menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.menu-wrap { flex: none; position: relative; }
.menu-btn { background: none; border: none; cursor: pointer; font-family: inherit; }
.chev { width: 14px; height: 14px; opacity: .65; transition: transform .16s ease; }
.menu-btn { display: inline-flex; align-items: center; gap: 6px; }
.menu-btn[aria-expanded="true"] .chev { transform: rotate(180deg); opacity: 1; }
.mega {
  /* Drops down from the All tools button, right-aligned to it and capped to the viewport. */
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px 16px;
  width: max-content; max-width: calc(100vw - 48px); max-height: calc(100vh - 110px); overflow-y: auto; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.mega-title { margin: 4px 0 6px; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.mega-link {
  display: flex; min-width: 0; white-space: nowrap; align-items: center; gap: 9px; padding: 6px 9px; margin: 0 -9px;
  border-radius: 10px; color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.mega-link:hover { background: var(--surface-2); color: var(--accent); }
.mi { width: 16px; height: 16px; color: var(--muted); flex: none; }
.mega-link:hover .mi { color: var(--accent); }
@media (max-width: 860px) {
  .quicknav { display: none; }
  .mega { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(440px, calc(100vw - 32px)); }
}

/* ---------- Home ---------- */
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; padding: 20px; }
.chip {
  font: inherit; font-size: 14.5px; font-weight: 500; padding: 9px 18px; border-radius: var(--pill); cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.tool {
  position: relative; display: block; text-align: left; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 24px 26px; color: var(--text); display: flex; flex-direction: column; gap: 5px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tool:hover, .tool:focus-visible {
  transform: translateY(-3px); outline: none; border-color: transparent;
  box-shadow: var(--shadow-lg);
}
.tool .icon {
  width: 40px; height: 40px; border-radius: var(--pill); display: grid; place-items: center; margin-bottom: 20px;
  color: var(--text); background: var(--surface-2);
}
.tool:hover .icon { color: var(--accent); background: var(--accent-soft); }
.tool .icon svg { width: 20px; height: 20px; }
.tool h3 { font-family: var(--font-display); font-weight: 400; margin: 0 0 12px; font-size: 22px; letter-spacing: -.01em; line-height: 1.2; }
.tool p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; }


/* ---------- Workspace ---------- */
.back { display: inline-flex; align-items: center; gap: 7px; background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 14px; padding: 0; }
.back .ui { width: 14px; height: 14px; }
.back:hover { color: var(--text); }
.step { max-width: 660px; margin: 0 auto; }
.step.wide { max-width: 1000px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
@media (max-width: 600px) { .card { padding: 18px; } }
.center { text-align: center; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 72px 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: background .16s, box-shadow .16s;
  box-shadow: var(--shadow);
}
.dropzone:hover, .dropzone.drag { background: var(--accent-soft); box-shadow: var(--shadow-lg); }
.dz-main {
  background: var(--accent); color: #fff; font-weight: 600; font-size: 19px;
  padding: 16px 40px; border-radius: var(--pill);
}
.dz-sub { margin-top: 14px; color: var(--muted); font-size: 14.5px; text-align: center; }
.dz-warn {
  margin: 14px 0 0; max-width: 420px; text-align: center; font-size: 14px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: var(--radius-sm);
}

/* ---------- Files: list and grid views ---------- */
.files-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.files-count { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-switch { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--pill); flex: none; }
.view-switch button {
  width: 30px; height: 26px; border: none; border-radius: var(--pill); background: none; color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
}
.view-switch .ui { width: 15px; height: 15px; }
.view-switch button:hover { color: var(--text); }
.view-switch button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(28, 26, 23, .1); }

.filelist { margin: 0 0 10px; padding: 0; }
/* "Add more" sits in the file area as a dashed tile (grid) or row (list). */
.add-tile {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm); background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; padding: 14px;
  transition: border-color .12s, color .12s, background .12s;
}
.add-tile:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.add-plus { display: grid; place-items: center; }
.add-plus .ui { width: 17px; height: 17px; }
.filelist.grid .add-tile { flex-direction: column; gap: 6px; min-height: 100%; padding: 22px 12px; }
.filelist.grid .add-plus .ui { width: 24px; height: 24px; }
.filelist.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
@media (max-width: 600px) { .filelist.grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; } }
.file-row, .file-card { position: relative; background: var(--surface-2); border-radius: var(--radius-sm); }
.file-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px; }
.file-card { display: flex; flex-direction: column; padding: 10px; gap: 9px; }
.file-thumb {
  aspect-ratio: 1 / 1.3; display: grid; place-items: center; overflow: hidden; border-radius: 10px;
  background: var(--surface); box-shadow: 0 1px 4px rgba(28, 26, 23, .12);
}
.file-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-lock { font-size: 24px; opacity: .45; }
.thumb-wait { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--muted); animation: spin .8s linear infinite; }
.file-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-card .fname { font-weight: 600; font-size: 13.5px; }
.file-card .badge { align-self: flex-start; }
.file-actions { display: flex; gap: 4px; }
.fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 15px; }
.fsize { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
/* One icon size for every interface control. */
.ui { width: 15px; height: 15px; display: block; }
.mini {
  display: grid; place-items: center;
  background: var(--surface); border: none; border-radius: var(--pill); color: var(--muted);
  cursor: pointer; width: 28px; height: 28px; flex: none;
}
.mini .ui { width: 14px; height: 14px; }
.mini:hover { color: var(--accent); }
.mini:disabled { opacity: .3; cursor: default; }
.expand {
  position: absolute; top: 7px; right: 7px; z-index: 2; width: 26px; height: 26px; border-radius: var(--pill);
  border: none; background: var(--surface); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(28, 26, 23, .16);
}
.expand .ui { width: 13px; height: 13px; }
.expand:hover { color: var(--accent); }
.file-row .expand { position: static; order: -1; box-shadow: none; background: var(--surface); }
@media (max-width: 600px) { .file-row .fsize { display: none; } }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--pill); background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

/* ---------- Form controls ---------- */
.field { margin: 18px 0 0; }
.field > label { display: block; font-weight: 600; margin-bottom: 7px; font-size: 13.5px; }
/* Password box with show/hide */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { width: 100%; padding-right: 44px !important; }
.eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 34px; height: 32px;
  display: grid; place-items: center; border: none; background: none; cursor: pointer; border-radius: var(--pill);
  color: var(--muted);
}
.eye:hover, .eye.on { color: var(--accent); }
.eye-icon { width: 17px; height: 17px; }
.protect-opt { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 22px; }
.protect-opt .check-row { margin-top: 0; font-weight: 600; }

.field input[type=password], .field input[type=text], .field input[type=number], .field select {
  width: 100%; padding: 12px 15px; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
}
.field input:focus, .field select:focus, .picker-bar input:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.field input[type=color] { width: 62px; height: 42px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.hint { font-size: 12.5px; color: var(--muted); margin: 7px 0 0; }
.note { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 15px; font-size: 14px; margin: 14px 0 0; color: var(--muted); }
.note.blocked { background: var(--accent-soft); color: var(--text); }
.note.blocked strong { display: block; margin-bottom: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } }
.disabled { opacity: .45; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label {
  flex: 1; min-width: 90px; text-align: center; padding: 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 13.5px; margin: 0; background: var(--surface);
}
.seg label:hover { border-color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.seg label:has(input:checked) { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg.tall label { padding: 14px 10px; }
@media (max-width: 520px) {
  .seg.tall { flex-direction: column; }
  .seg.tall label { text-align: left; padding: 11px 15px; }
}
.seg.wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.seg.wrap label { min-width: 0; }
.seg.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 220px; }
.seg.grid3 label { min-width: 0; padding: 9px; }
.seg.grid3 .ui { width: 16px; height: 16px; margin: 0 auto; }

.range { display: flex; align-items: center; gap: 8px; min-width: 0; }
.range input { flex: 1; min-width: 0; accent-color: var(--accent); }
.range output { min-width: 44px; text-align: right; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; margin: 12px 0 0; line-height: 1.3; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; margin: 0; }
.check-row > span { display: inline-flex; align-items: center; gap: 8px; }
.check-icon { width: 16px; height: 16px; flex: none; color: var(--muted); }
.check-row input:checked + span .check-icon { color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 5px; }
.badge-icon { width: 12px; height: 12px; flex: none; }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.primary, .ghost {
  font: inherit; font-weight: 600; border-radius: var(--pill); padding: 13px 26px; cursor: pointer; border: 1px solid transparent;
  text-decoration: none; display: inline-block;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.primary.big { font-size: 18px; padding: 16px 46px; margin: 22px 0 8px; }
.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.ghost.sm { padding: 8px 15px; font-size: 13.5px; }
.link { display: block; margin: 10px auto 0; background: none; border: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.link.left { margin: 0 0 10px; }
.link.inline { display: inline; margin: 0; padding: 0; }

.error { color: var(--accent); font-weight: 600; margin: 16px 0 0; font-size: 14.5px; }
.spinner {
  width: 40px; height: 40px; margin: 8px auto 14px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.check {
  width: 62px; height: 62px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok);
}
.check svg { width: 28px; height: 28px; }

/* ---------- Options with live preview ---------- */
.opt-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; align-items: start; }
@media (max-width: 760px) { .opt-grid { grid-template-columns: 1fr; } }
/* Only pin the preview beside the controls; stacked, a sticky preview would cover them. */
@media (min-width: 761px) { .preview { position: sticky; top: 90px; } }
.pv-page {
  position: relative; overflow: hidden; margin: 0 auto; max-width: min(380px, 100%); max-height: 62vh;
  border-radius: 10px; box-shadow: 0 10px 30px -18px rgba(28, 26, 23, .5); background: #fff;
}
.pv-page img { display: block; width: 100%; height: auto; }
.pv-bar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }
.pv-bar button { padding: 6px 12px; display: grid; place-items: center; }
.pv-bar .ui { width: 15px; height: 15px; }
.pv-bar .pv-label { font-size: 12.5px; color: var(--muted); min-width: 96px; text-align: center; }
.pv-layer { position: absolute; inset: 0; pointer-events: none; font-family: Helvetica, Arial, sans-serif; }
.pv-text { position: absolute; white-space: nowrap; line-height: 1; }
.pv-text.mid { transform: translate(-50%, -50%); }
.pv-text.dark { color: #222; }
.pv-rot { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.pv-note {
  position: absolute; left: 8px; right: 8px; bottom: 8px; font-size: 12px; text-align: center;
  background: rgba(28, 26, 23, .7); color: #fff; padding: 7px; border-radius: 8px;
}
.pv-shade { position: absolute; background: rgba(28, 26, 23, .45); }
.pv-cropbox { position: absolute; border: 2px dashed var(--accent); }
.controls > .field:first-child { margin-top: 0; }

/* ---------- Page grids (Select pages, Organize) ---------- */
.picker-bar { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.picker-bar input {
  flex: 1; min-width: 200px; padding: 11px 15px; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
}
.grow { flex: 1; margin: 0; text-align: right; }
/* A full sentence (not a short label) reads better left-aligned when it wraps. */
.extract-bar { justify-content: space-between; }
.extract-bar .hint { text-align: left; }
.extract-bar button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pages {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px;
  margin-top: 14px; max-height: 62vh; overflow-y: auto; padding: 4px;
}
.page {
  position: relative; padding: 9px 9px 30px; background: var(--surface-2); border: 2px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; font: inherit; color: var(--text); transition: border-color .12s, background .12s;
}
.page:hover { border-color: var(--border); }
.page img { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; box-shadow: 0 1px 4px rgba(28, 26, 23, .16); }
.page-no { position: absolute; left: 0; right: 0; bottom: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: center; }
.page-check {
  position: absolute; top: 12px; right: 12px; width: 25px; height: 25px; border-radius: 50%;
  background: var(--accent); color: #fff; display: none; place-items: center;
}
.page-check .ui { width: 14px; height: 14px; }
.page.on { border-color: var(--accent); background: var(--accent-soft); }
.page.on .page-no { color: var(--accent); }
.page.on .page-check { display: grid; }
.page-zoom { opacity: 0; transition: opacity .12s; }
.page:hover .page-zoom, .page:focus-within .page-zoom, .page.show-tools .page-zoom { opacity: 1; }
@media (hover: none) { .page-zoom { opacity: 1; } }
.org-page .page-zoom { top: 36px; }
.pages-msg { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 34px 8px; }
.link.inline { display: inline; margin: 0; padding: 0; }

.org-page { cursor: grab; }
.org-page.dragging { opacity: .35; }
.org-page.drop-before { box-shadow: -5px 0 0 -1px var(--accent); }
.org-page.drop-after { box-shadow: 5px 0 0 -1px var(--accent); }
.org-thumb { aspect-ratio: 1 / 1.3; display: grid; place-items: center; overflow: hidden; }
.org-thumb > * { transition: transform .15s ease; max-height: 100%; }
.blank-page { width: 77%; aspect-ratio: 1 / 1.29; background: #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(28, 26, 23, .16); }
.org-tools {
  position: absolute; left: 5px; right: 5px; top: 5px; display: flex; justify-content: center; gap: 3px;
  opacity: 0; transition: opacity .12s;
}
.org-page:hover .org-tools, .org-page.show-tools .org-tools, .org-page:focus-within .org-tools { opacity: 1; }
.org-tools button {
  width: 24px; height: 24px; padding: 0; border: none; border-radius: var(--pill); cursor: pointer;
  background: rgba(28, 26, 23, .78); color: #fff; display: grid; place-items: center;
}
.org-tools .ui { width: 12px; height: 12px; }
.org-tools button:hover { background: var(--accent); }
.org-tools button:disabled { opacity: .3; cursor: default; background: rgba(28, 26, 23, .78); }
@media (hover: none) { .org-tools { opacity: 1; } }

.med-page { cursor: default; padding-bottom: 9px; }
.med-page img { aspect-ratio: 1 / 1.3; object-fit: cover; }
.med-page.needs-review { border-color: var(--accent); }
.med-flag { position: absolute; top: 12px; left: 12px; }
.med-fields { display: grid; gap: 6px; margin-top: 9px; }
.med-fields select, .med-fields input[type="date"] {
  width: 100%; padding: 7px 9px; font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px;
}

.claims-wrap { margin-top: 22px; }
.claims-wrap .picker-bar button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.claims-wrap .picker-bar button .ui { width: 14px; height: 14px; flex: none; }
.claims-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 10px; }
.claims-grid { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
.claims-grid th, .claims-grid td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.claims-grid th { background: var(--surface-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.claims-grid tr.selected td { background: var(--accent-soft); }
.claims-grid td.claim-line { color: var(--muted); font-variant-numeric: tabular-nums; }
.claims-grid td.claim-check { text-align: center; }
.claims-grid input:not([type="checkbox"]) {
  width: 130px; padding: 5px 7px; font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--surface); border: 1px solid transparent; border-radius: 6px;
}
.claims-grid input:not([type="checkbox"]):hover, .claims-grid input:not([type="checkbox"]):focus { border-color: var(--border); }
#claimTotal { text-align: right; font-weight: 600; color: var(--text); }

/* ---------- Result ---------- */
.saved-note { margin: 0 0 6px; font-size: 14px; color: var(--ok); font-weight: 600; word-break: break-all; }

/* ---------- Modals: download panel and expanded preview ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(28, 26, 23, .45); backdrop-filter: blur(3px);
}
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-lg);
}
.modal h2 { margin: 0 44px 26px 0; font-size: 40px; }
.modal a:not(.dl-btn):not(.primary) { color: var(--accent); }
.modal-close {
  position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border: none; border-radius: var(--pill);
  background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 14px;
}
.modal-close { display: grid; place-items: center; }
.modal-close:hover { color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dl-reason { margin: 0 0 14px; padding: 12px 15px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: 14.5px; }
.dl-main { text-align: center; }
.dl-main .hint { margin: 0 0 10px; }
.dl-main .primary { width: 100%; margin: 0; }
.dl-main .link { margin-top: 12px; font-size: 13.5px; }
.dl-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dl-main:not([hidden]) + .dl-buttons { margin-top: 14px; }
@media (max-width: 480px) { .dl-buttons { grid-template-columns: 1fr; } }
.dl-btn {
  display: flex; flex-direction: column; gap: 2px; padding: 13px 16px; border-radius: var(--radius-sm); text-decoration: none;
  border: 1px solid transparent; color: var(--text); background: var(--surface-2);
}
.dl-btn span { font-size: 12.5px; color: var(--muted); }
.dl-btn:hover { border-color: var(--accent); }
.dl-btn.suggested { background: var(--accent-soft); }
.dl-btn.suggested strong::after { content: " · Recommended"; font-weight: 600; font-size: 11.5px; color: var(--accent); }
.dl-help { margin: 18px 0 8px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; }
.dl-help p { margin: 0; color: var(--muted); line-height: 1.5; }
.dl-help strong { color: var(--text); }
.dl-steps { margin-top: 16px; }
.dl-steps p + p { margin-top: 10px; }
.dl-code { margin: 10px 0 0; position: relative; }
.dl-code code {
  display: block; padding: 9px 42px 9px 12px; font-family: ui-monospace, monospace; font-size: 12.5px;
  color: var(--text); background: var(--surface-2); border-radius: 7px; white-space: pre-wrap; word-break: break-all;
}
.dl-copy {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border: none; border-radius: 6px;
  background: var(--border); color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.dl-copy:hover { color: var(--text); }
.dl-copy .ui { width: 14px; height: 14px; }
.dl-phone p { margin: 0 0 12px; color: var(--muted); }
.dl-phone strong { color: var(--text); }
.dl-phone .primary { width: 100%; }

.preview-modal { width: min(1000px, 100%); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.preview-head { display: flex; align-items: center; gap: 12px; }
.preview-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-head .modal-close { position: static; flex: none; }
.preview-stage {
  position: relative; display: grid; place-items: center; min-height: 40vh; max-height: calc(100vh - 190px);
  overflow: auto; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px;
}
.preview-stage img { max-width: 100%; max-height: calc(100vh - 220px); border-radius: 6px; box-shadow: 0 10px 30px -16px rgba(28, 26, 23, .55); background: #fff; }
.preview-stage .spinner { position: absolute; }
.pv-error { color: var(--accent); font-weight: 600; text-align: center; }
.preview-bar { display: flex; align-items: center; justify-content: center; gap: 14px; }
.preview-bar button { min-width: 44px; display: grid; place-items: center; }
.preview-bar .ui { width: 18px; height: 18px; }
.preview-bar button:disabled { opacity: .35; cursor: default; }

/* ---------- Download app button / phone nudge ---------- */
.get-app {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  padding: 9px 17px; border-radius: var(--pill); border: none; background: var(--accent); color: #fff;
}
.get-app:hover { background: var(--accent-hover); }
.desktop-nudge {
  display: none; order: -1; flex-direction: column; align-items: flex-end; line-height: 1.2;
  background: none; border: none; padding: 2px 4px; cursor: pointer; font: inherit; font-size: 11px; color: var(--muted); text-align: right;
}
.desktop-nudge span:last-child { color: var(--accent); font-weight: 700; }
body.phone .get-app { display: none !important; }
body.phone .desktop-nudge { display: flex; }
.narrow-only { display: none; }
@media (max-width: 520px) {
  main { padding-top: 34px; }
  .chips { padding: 14px 0 18px; }
  .topbar { padding: 9px 12px; gap: 8px; width: calc(100% - 20px); margin-top: 10px; }
  .bar-actions { gap: 8px; }
  .brand { font-size: 21px; }
  .logo { width: 28px; height: 28px; }
  .get-app { padding: 7px 13px; font-size: 13px; }
  .menu-btn { padding: 8px 8px; font-size: 13px; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  main { padding: 26px 14px 40px; }
}

body[data-desktop="1"] .web-only { display: none !important; }
body:not([data-desktop="1"]) .desktop-only { display: none !important; }

footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 26px 16px; }
footer a, footer .link.inline { color: inherit; text-decoration: underline; font-weight: inherit; font-size: inherit; }
