:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --ink: #17171c;
  --ink-2: #3a3a42;
  --muted: #6b6a72;
  --line: #e3dfd6;
  --line-strong: #cfc9bd;
  --accent: #e4572e;
  --danger: #c23a3a;
  --ok: #1d7f55;
  --radius: 10px;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  /* one transit-line colour per tool group */
  --g-organizar: #3f73d9;
  --g-optimizar: #1f9668;
  --g-desde: #d9771f;
  --g-a: #c9416f;
  --g-editar: #7a55d9;
  --g-seguridad: #2b2b38;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
main.wrap { flex: 1; padding-top: 40px; padding-bottom: 72px; }
.muted { color: var(--muted); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246, 244, 239, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; letter-spacing: -.01em; flex: none; }
.brand img { display: block; }
.crumb { display: flex; align-items: baseline; gap: 6px; }
.crumb-station { color: var(--muted); font-weight: 500; }
.crumb-slash { color: var(--line-strong); }
.crumb b { font-weight: 600; }
.brand:hover .crumb-station { color: var(--ink-2); }

.menu-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 14.5px; color: var(--ink-2);
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.menu-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn .chev { transition: transform .15s; }
.menu-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu-btn .burger { display: none; }

.search-box { position: relative; flex: 1; max-width: 360px; margin-left: auto; }
.search-box > svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; pointer-events: none; }
#search {
  width: 100%; padding: 8px 34px 8px 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
#search:focus { border-color: var(--ink); }
#search::-webkit-search-cancel-button { display: none; }
.search-box kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; background: var(--paper);
}
.search-box:focus-within kbd { display: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(23,23,28,.1); z-index: 30;
}
.search-results li a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; text-decoration: none; font-size: 14px;
}
.search-results li a small { margin-left: auto; color: var(--muted); font-size: 12px; }
.search-results li[aria-selected="true"] a, .search-results li a:hover { background: var(--surface-2); }
.search-results .empty { padding: 10px; color: var(--muted); font-size: 14px; }
.mini-ico { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--gc) 12%, var(--surface)); color: var(--gc); }
.mini-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.mega { border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 16px 30px rgba(23,23,28,.06); }
.mega-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 24px; padding-top: 22px; padding-bottom: 26px; }
.mega-col h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mega-col ul { list-style: none; margin: 0; padding: 0; }
.mega-col a {
  display: flex; align-items: center; gap: 10px; margin: 0 -8px; padding: 6px 8px; border-radius: 8px;
  font-size: 14px; text-decoration: none; color: var(--ink-2);
}
.mega-col a:hover { color: var(--ink); background: var(--paper); }
.mega-col a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--paper); }
.mega-col .mini-ico { width: 28px; height: 28px; border-radius: 7px; }
.mega-col .mini-ico svg { width: 17px; height: 17px; }
@media (max-width: 1000px) { .mega-grid { grid-template-columns: repeat(3, 1fr); } }
.mega-station { display: none; }
@media (max-width: 640px) {
  .mega-station { display: block; grid-column: 1 / -1; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
}
.station-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.station-link:hover { color: var(--ink); }
.station-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* footer */
.site-footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: 14px; }
.footer-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* home */
.hero { margin-bottom: 40px; }
.eyebrow { margin: 0 0 12px; font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0; font-size: clamp(30px, 4vw, 44px); line-height: 1.1; letter-spacing: -.025em; font-weight: 600; max-width: 16em; }
.hero p { margin: 14px 0 0; color: var(--ink-2); font-size: 17px; max-width: 36em; }
/* category filter */
.chips {
  display: flex; gap: 8px; margin: 0 0 32px; padding: 4px; overflow-x: auto; scrollbar-width: none;
  width: fit-content; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 8px 14px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.chip span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--paper); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip[aria-pressed="true"] span { color: rgba(246, 244, 239, .6); }
.chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.group { margin-bottom: 40px; }
.group-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.group-head h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.group-head span { font-size: 13px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--ink); transform: translateY(-1px); }
.card.off { opacity: .6; }
.ico {
  width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--gc) 12%, var(--surface)); color: var(--gc);
}
.ico svg, .tool-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.card .warn { font-size: 12px; color: var(--danger); }

/* tool page */
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); text-decoration: none; margin-bottom: 18px; font-size: 14px; }
.back:hover { color: var(--ink); }
.back svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.tool-ico { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--gc) 12%, var(--surface)); color: var(--gc); }
.tool-ico svg { width: 30px; height: 30px; }
.tool-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; font-weight: 600; }
.tool-head p { margin: 2px 0 0; color: var(--muted); }
.tool-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .tool-layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }

.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 44px 16px; text-align: center; cursor: pointer;
  color: var(--muted); transition: border-color .15s, background .15s; background: var(--paper);
}
.drop.over, .drop:hover, .drop:focus-visible { border-color: var(--ink); background: var(--surface-2); outline: none; }
.drop strong { display: block; color: var(--ink); font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.files { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  background: var(--paper); border: 1px solid var(--line); cursor: grab;
}
.files li.dragging { opacity: .4; }
.files .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .size, .hint { color: var(--muted); font-size: 12.5px; }
.hint { margin: 12px 0 0; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-2); }
.field input[type=text], .field input[type=number], .field input[type=password], .field select, .field input[type=file] {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); outline: none; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--ink); }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.field.check label { color: var(--ink); font-size: 14px; }
.field input[type=color] { width: 100%; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 11px 18px;
  border: 1px solid var(--ink); border-radius: 8px; background: var(--ink); color: var(--paper); font-weight: 500; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--ink-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.status { margin-top: 12px; font-size: 14px; }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }
.status a { color: var(--ink); font-weight: 600; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* option cards and segmented choices */
.field-label { font-size: 13px; color: var(--ink-2); }
.opt-cards { display: flex; flex-direction: column; gap: 8px; }
.opt-card {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 13px 14px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt-card:hover { border-color: var(--line-strong); }
.opt-card[aria-checked="true"] { border-color: var(--ink); background: var(--surface); }
.opt-radio { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; }
.opt-card[aria-checked="true"] .opt-radio { border-color: var(--ink); }
.opt-card[aria-checked="true"] .opt-radio::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.opt-text { display: flex; flex-direction: column; gap: 2px; }
.opt-text strong { font-size: 14.5px; font-weight: 600; }
.opt-desc { font-size: 13px; color: var(--muted); }
.opt-est { font: 500 12.5px var(--mono); color: var(--ok); }
.opt-est:empty { display: none; }

/* file list thumbnails */
.file-thumb { flex: none; width: 34px; height: 44px; border-radius: 4px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* compression result */
.savings { display: flex; align-items: center; gap: 16px; margin: 4px 0 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.savings strong { display: block; font-size: 14.5px; }
.savings span { font: 13px var(--mono); color: var(--ink-2); }
.ring-wrap { position: relative; width: 64px; height: 64px; flex: none; }
.ring { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring-fg { fill: none; stroke: var(--ok); stroke-width: 7; stroke-linecap: round; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font: 600 14px var(--sans) !important; color: var(--ink) !important; }

/* unlock password prompt */
.pw-panel { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.pw-panel strong { font-size: 15px; }
.pw-panel p { margin: 0; font-size: 13px; color: var(--muted); }
.pw-row { display: flex; flex-direction: column; gap: 4px; }
.pw-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-box { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.pw-box:focus-within { border-color: var(--ink); }
.pw-input { flex: 1; padding: 9px 11px; border: 0; background: transparent; outline: none; }
.pw-wrong { font-size: 12.5px; color: var(--danger); }

/* scan */
.camera-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.camera-row .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }

/* redact terms box in the editor toolbar */
.terms { min-width: 260px; flex: 1; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); resize: vertical; font-size: 13.5px; }

/* crop */
.crop-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 14px; }
.crop-pager-label { font: 13px var(--mono); color: var(--muted); }
.crop-stage { display: flex; justify-content: center; }
.crop-page { position: relative; width: min(100%, 520px); background: #fff; box-shadow: 0 2px 10px rgba(23,23,28,.12); touch-action: none; user-select: none; cursor: crosshair; }
.crop-page img { display: block; width: 100%; height: 100%; }
.crop-shade { position: absolute; inset: 0; background: rgba(23, 23, 28, .45); }
.crop-area { position: absolute; border: 2px solid var(--accent); cursor: move; }
.crop-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--accent); border-radius: 3px; }
.crop-handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }

/* forms */
.form-fields section { margin-bottom: 18px; }
.form-page { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.empty-state { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-state .row { display: flex; gap: 8px; margin-top: 6px; }

/* page picker */
.page-picker { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.picker-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.picker-head p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.picker-head .picker-info { font: 12px var(--mono); color: var(--muted); }
.pthumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.pthumb {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 10px 10px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.pthumb:hover { border-color: var(--line-strong); background: var(--surface); }
.pthumb:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pframe { width: 124px; height: 168px; display: grid; place-items: center; }
.pthumb img { max-width: 124px; max-height: 168px; background: #fff; box-shadow: 0 1px 4px rgba(23,23,28,.16); transition: transform .2s, opacity .15s; }

/* while choosing pages, the drop zone becomes a slim bar */
.panel.picking .drop { padding: 14px 16px; }
.panel.picking .drop strong { display: inline; font-size: 14px; margin: 0 6px 0 0; }
.panel.picking .hint { display: none; }
.pnum { font: 11.5px var(--mono); color: var(--muted); }
.pmark {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: none; place-items: center; background: var(--ink); color: var(--paper);
}
.pmark svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pthumb.sel { border-color: var(--ink); background: var(--surface); }
.pthumb.sel .pmark { display: grid; }
.pthumb.sel .pnum { color: var(--ink); font-weight: 500; }
/* "remove" marks pages that will disappear */
[data-tool="remove"] .pthumb.sel { border-color: var(--danger); border-style: dashed; }
[data-tool="remove"] .pthumb.sel .pmark {
  top: 12px; left: 50%; right: auto; width: 124px; height: 168px; transform: translateX(-50%);
  border-radius: 0; background: transparent; color: var(--danger);
}
[data-tool="remove"] .pthumb.sel .pmark svg { width: 46px; height: 46px; stroke-width: 2; }
[data-tool="remove"] .pthumb.sel img { opacity: .3; }
[data-tool="remove"] .pthumb.sel .pnum { color: var(--danger); text-decoration: line-through; }

/* split */
.split-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .split-layout { grid-template-columns: 1fr; } }
.split-right { position: sticky; top: 84px; }
.file-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.file-bar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.file-bar .size { color: var(--muted); font-size: 13px; }
.file-bar .btn { margin-left: auto; }
.btn.small { padding: 6px 12px; font-size: 13.5px; }

.range-groups { display: flex; flex-wrap: wrap; gap: 16px; }
.range-group { margin: 0; padding: 10px; border: 1.5px dashed var(--line-strong); border-radius: 12px; }
.range-group figcaption { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 8px 2px; }
.range-pages { display: flex; align-items: center; gap: 8px; }
.range-pages .pthumb { cursor: default; }
.range-dots { font-size: 22px; color: var(--muted); letter-spacing: 2px; }
.file-card { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.file-card .pthumb { cursor: default; }
.file-card-name { font-size: 13px; color: var(--ink-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.split-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 11px; }
.split-tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
}
.split-tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.split-tab:hover { color: var(--ink); }
.split-tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(23,23,28,.1); }
.split-body { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.ctl-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; }
.seg-btn { flex: 1; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.seg-btn[aria-pressed="true"], .seg-btn[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.seg { flex-wrap: wrap; }
.seg:has(> :nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; }

/* tiles: square choices with an icon */
.opt-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.opt-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink-2);
  font-size: 13px; cursor: pointer; transition: border-color .12s, background .12s;
}
.opt-tile svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.opt-tile:hover { border-color: var(--line-strong); }
.opt-tile[aria-checked="true"] { border-color: var(--ink); background: var(--surface); color: var(--ink); font-weight: 600; }

/* position: six clickable spots on a page drawing */
.pos-page {
  position: relative; width: 120px; aspect-ratio: 210 / 297; display: grid; grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto 1fr auto; align-content: space-between; padding: 6px;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 6px;
}
.pos-lines { position: absolute; inset: 30% 18% 30%; background: repeating-linear-gradient(var(--line) 0 3px, transparent 3px 11px); pointer-events: none; }
.pos-spot { grid-row: 1; display: grid; place-items: center; height: 26px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.pos-spot[data-pos^="bottom"] { grid-row: 3; }
.pos-spot:hover { background: var(--paper); }
.pos-dot { width: 14px; height: 7px; border-radius: 2px; background: var(--line-strong); }
.pos-spot[aria-checked="true"] .pos-dot { background: var(--ink); width: 18px; }

/* image to PDF preview */
.img-preview { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.img-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.img-item { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.img-page { width: 112px; box-sizing: border-box; background: #fff; box-shadow: 0 1px 5px rgba(23,23,28,.18); display: flex; align-items: center; justify-content: center; transition: aspect-ratio .2s, padding .2s; }
.img-page img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.img-item figcaption { font-size: 12px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.range-list { display: flex; flex-direction: column; gap: 8px; }
.range-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.range-row .range-name { color: var(--ink); font-weight: 500; min-width: 64px; }
.num, .text-in { width: 72px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); outline: none; }
.num.wide { width: 120px; }
.text-in { width: 100%; }
.num:focus, .text-in:focus { border-color: var(--ink); }
.add-range { align-self: flex-start; padding: 7px 14px; font-size: 13.5px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; margin: 0; }
.field.inline label { color: var(--ink-2); font-size: 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.info-box { margin: 0 0 14px; padding: 11px 13px; border-radius: 9px; background: var(--paper); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); }

/* organize */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 16px; }
.thumb {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: grab;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.thumb.dragging { opacity: .4; }
.thumb.over { border-color: var(--ink); }
.thumb .frame { width: 120px; height: 160px; display: grid; place-items: center; }
.thumb img { max-width: 120px; max-height: 160px; box-shadow: 0 1px 4px rgba(23,23,28,.15); background: #fff; transition: transform .2s; }
.thumb .num { font: 12px var(--mono); color: var(--muted); }
.thumb .actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.thumb:hover .actions, .thumb:focus-within .actions { opacity: 1; }
.thumb .actions .icon-btn { background: var(--surface); border: 1px solid var(--line); }
@media (hover: none) { .thumb .actions { opacity: 1; } }

/* editor */
.edit-toolbar {
  position: sticky; top: 72px; z-index: 10; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 10px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.tbtn { padding: 7px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 14px; }
.tbtn:hover { border-color: var(--line-strong); }
.tbtn.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.edit-toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.edit-toolbar input[type=color] { width: 36px; height: 32px; border: 0; background: none; padding: 0; }
.edit-toolbar input[type=number] { width: 64px; padding: 6px; border-radius: 7px; border: 1px solid var(--line); background: var(--paper); }
.edit-toolbar .grow { flex: 1; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.epage { position: relative; box-shadow: 0 2px 10px rgba(23,23,28,.1); background: #fff; user-select: none; max-width: 100%; }
.epage img { display: block; width: 100%; }
.epage .layer { position: absolute; inset: 0; }
.epage svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.eitem { position: absolute; cursor: move; }
.eitem.sel { outline: 2px dashed var(--accent); outline-offset: 2px; }
.eitem.text { white-space: pre; line-height: 1; font-family: Helvetica, Arial, sans-serif; }
.eitem img { width: 100%; height: 100%; display: block; pointer-events: none; }
.eitem.whiteout { background: #fff; outline: 1px dotted #bbb; }
.eitem.highlight { opacity: .4; }
.eitem.rect { border-style: solid; }
.eitem .grip { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; background: var(--accent); border-radius: 3px; cursor: nwse-resize; }
.text-input { position: absolute; z-index: 5; min-width: 120px; font-family: Helvetica, Arial, sans-serif; line-height: 1; padding: 0; border: 1px dashed var(--accent); background: rgba(255,255,255,.92); color: #000; resize: both; }

.modal-back { position: fixed; inset: 0; background: rgba(23,23,28,.45); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; padding: 20px; width: min(560px, 92vw); }
.modal h3 { margin: 0 0 12px; font-weight: 600; }
.modal canvas { width: 100%; height: 200px; background: #fff; border: 1px solid var(--line); border-radius: 8px; touch-action: none; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px; transition: .2s; z-index: 60; font-size: 14px;
}
#toast.show { transform: translateX(-50%); opacity: 1; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 28px; }
  .topbar-row { gap: 10px; }
  .crumb-station, .crumb-slash { display: none; }
  .search-box { max-width: none; }
  .search-box kbd { display: none; }
  .menu-btn { order: 3; padding: 8px; border-color: var(--line); background: var(--surface); }
  .menu-btn span, .menu-btn .chev { display: none; }
  .menu-btn .burger { display: block; width: 18px; height: 18px; }
  .station-link { display: none; }
  .mega { max-height: calc(100vh - 64px); overflow-y: auto; }
  .mega-grid { grid-template-columns: 1fr 1fr; gap: 20px 16px; }
  .tool-head h1 { font-size: 23px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card p { display: none; }
  .edit-toolbar { top: 64px; }
}
