/* ---------- Tokens ---------- */
:root {
  --bg: #fbfbf9; --sheet: #ffffff;
  --ink: #16181d; --ink-2: #5c616b; --ink-3: #9a9fa8;
  --line: #e4e5e9; --line-2: #cfd1d7;
  --accent: #2743e8; --accent-ink: #ffffff; --accent-soft: #e9ecfc; --accent-soft-2: #d4daf9;
  --warn: #b5471b; --warn-soft: #fbeee7; --danger: #c0262d;
  --c-blue: #2743e8; --c-green: #1f7a4d; --c-amber: #b4650a; --c-violet: #6b3fd6; --c-red: #c0262d;
  --c-blue-soft: #e9ecfc; --c-green-soft: #e3f3ea; --c-amber-soft: #fbeedd; --c-violet-soft: #ede7fb; --c-red-soft: #fbe6e7;
  --shadow: 0 1px 2px rgba(22, 24, 29, .06), 0 8px 24px -12px rgba(22, 24, 29, .18);
  --radius: 10px; --radius-sm: 6px;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --panel-w: 340px; --top-h: 53px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316; --sheet: #1b1d22; --ink: #eceef1; --ink-2: #a3a8b2; --ink-3: #6f747e;
    --line: #2a2d34; --line-2: #3a3e47; --accent: #7f90ff; --accent-ink: #0d1140;
    --accent-soft: #23284a; --accent-soft-2: #2f3666; --warn: #ff9f73; --warn-soft: #3a2518; --danger: #ff7b81;
    --c-blue: #7f90ff; --c-green: #5ccf93; --c-amber: #f0a84a; --c-violet: #b095ff; --c-red: #ff7b81;
    --c-blue-soft: #23284a; --c-green-soft: #16301f; --c-amber-soft: #3a2a12; --c-violet-soft: #2a2140; --c-red-soft: #3a1b1d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; font-feature-settings: "tnum" 1; min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
b, strong { font-weight: 600; }
small { font-size: 12.5px; color: var(--ink-2); }
canvas, img { max-width: 100%; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Cabecera ---------- */
.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: var(--top-h); border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.brand svg { color: var(--accent); }
.top__nav { display: flex; align-items: center; gap: 4px; }
.top__nav a, .top__menu { padding: 7px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px; border: 0; background: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.top__nav a:hover, .top__menu:hover, .top__menu[aria-expanded="true"] { color: var(--ink); background: var(--accent-soft); }
.top__privacy { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.top__privacy svg { color: var(--accent); flex: none; }
.menu { position: absolute; left: 0; right: 0; top: var(--top-h); background: var(--sheet); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); display: none; padding: 20px 24px 24px; z-index: 30; max-height: calc(100dvh - var(--top-h)); overflow: auto; }
.menu.is-open { display: block; }
.menu__cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px 24px; max-width: 1200px; margin: 0 auto; }
.menu__col h3 { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 6px; }
.menu__item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 14px; }
.menu__item:hover { background: var(--accent-soft); }
.menu__icon { display: grid; place-items: center; width: 22px; height: 22px; color: var(--cat, var(--accent)); }
.menu__icon svg { width: 18px; height: 18px; }

.c-blue { --cat: var(--c-blue); --cat-soft: var(--c-blue-soft); }
.c-green { --cat: var(--c-green); --cat-soft: var(--c-green-soft); }
.c-amber { --cat: var(--c-amber); --cat-soft: var(--c-amber-soft); }
.c-violet { --cat: var(--c-violet); --cat-soft: var(--c-violet-soft); }
.c-red { --cat: var(--c-red); --cat-soft: var(--c-red-soft); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; font-weight: 500; line-height: 1.2; white-space: nowrap; text-decoration: none; color: inherit; transition: background-color .15s, border-color .15s, color .15s, transform .08s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:not(:disabled):hover { filter: brightness(1.08); }
.btn--ghost { border-color: var(--line-2); color: var(--ink); background: var(--sheet); }
.btn--ghost:not(:disabled):hover { border-color: var(--ink-3); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--lg { padding: 13px 22px; font-size: 16px; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--icon { padding: 6px; border-radius: 6px; color: var(--ink-3); }
.btn--icon:hover { color: var(--ink); background: var(--accent-soft); }
.btn svg { flex: none; }

/* ---------- Inicio ---------- */
.home { flex: 1; width: 100%; max-width: 1160px; margin: 0 auto; padding: clamp(28px, 6vh, 72px) 24px 72px; }
.home__hero { max-width: 760px; }
.home__title { font-size: clamp(28px, 4.4vw, 42px); font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.home__lead { margin-top: 14px; max-width: 56ch; color: var(--ink-2); font-size: 16px; }
.search { margin-top: 24px; display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--sheet); color: var(--ink-3); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.search input { flex: 1; border: 0; background: none; padding: 11px 0; outline: none; font-size: 15px; color: var(--ink); min-width: 0; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.home__sections { margin-top: 40px; display: grid; gap: 36px; }
.home__cat-title { font-size: 13.5px; font-weight: 600; color: var(--ink-2); padding-bottom: 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.toolgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.toolcard { display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: start; padding: 14px 14px 14px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); color: var(--ink); text-decoration: none; transition: border-color .12s, background-color .12s; }
.toolcard:hover { border-color: var(--cat); background: var(--cat-soft); }
.toolcard__icon { grid-row: 1 / 3; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--cat-soft); color: var(--cat); }
.toolcard:hover .toolcard__icon { background: var(--sheet); }
.toolcard__icon svg { width: 20px; height: 20px; }
.toolcard__name { font-weight: 600; font-size: 14.5px; }
.toolcard__short { color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.home__empty { color: var(--ink-2); }

/* ---------- Herramienta: cabecera y selección ---------- */
.tool { flex: 1; display: flex; flex-direction: column; }
.tool__head { max-width: 760px; margin: 0 auto; padding: clamp(24px, 5vh, 56px) 24px 0; text-align: center; width: 100%; }
.tool__back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); text-decoration: none; margin-bottom: 14px; }
.tool__back::before { content: "←"; }
.tool__back:hover { color: var(--accent); }
.tool__title { font-size: clamp(26px, 4vw, 38px); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.tool__desc { margin: 12px auto 0; max-width: 56ch; color: var(--ink-2); font-size: 16px; }
.tool__pick { padding: 32px 24px 64px; }
.tool__note { max-width: 560px; margin: 16px auto 0; text-align: center; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.work:not([hidden]) + .tool__head, .tool:has(.work:not([hidden])) .tool__head, .tool:has(.done:not([hidden])) .tool__head { display: none; }

.drop { position: relative; margin: 0 auto; max-width: 560px; padding: 36px 24px 32px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--sheet); display: flex; flex-direction: column; align-items: center; gap: 22px; cursor: pointer; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.drop:hover, .drop:focus-visible { border-color: var(--accent); box-shadow: var(--shadow); }
.drop__sheet { position: relative; width: 92px; height: 118px; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--sheet); box-shadow: 6px 6px 0 -1px var(--sheet), 6px 6px 0 0 var(--ink-3); }
.drop__fold { position: absolute; top: -1.5px; right: -1.5px; width: 22px; height: 22px; background: var(--sheet); border-left: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); clip-path: polygon(0 0, 100% 100%, 0 100%); }
.drop__fold::after { content: ""; position: absolute; inset: 0; background: var(--bg); clip-path: polygon(0 0, 100% 100%, 100% 0); }
.drop__cut { position: absolute; left: -10px; right: -10px; top: 58px; height: 0; border-top: 2px dashed var(--accent); transition: transform .25s; }
.drop:hover .drop__cut { transform: translateY(14px); }
.drop__text { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.drop__text p { color: var(--ink-2); font-size: 14px; }

/* ---------- Espacio de trabajo ---------- */
.work { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); flex: 1; min-height: calc(100dvh - var(--top-h)); }
.stage { padding: 0 24px 48px; min-width: 0; }
.filebar { position: sticky; top: var(--top-h); z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 0 12px; margin-bottom: 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.filebar__meta { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.filebar__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.filebar__info { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.filebar__actions { display: flex; align-items: center; gap: 12px; }
.filebar__hint { color: var(--ink-2); font-size: 13px; }
.stage__body { padding-top: 12px; display: grid; gap: 20px; align-content: start; }

.panel { position: sticky; top: var(--top-h); align-self: start; height: calc(100dvh - var(--top-h)); display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--sheet); }
.panel__body { flex: 1; overflow: auto; padding: 20px; display: grid; align-content: start; gap: 18px; }
.panel__foot { padding: 16px 20px 20px; border-top: 1px solid var(--line); display: grid; gap: 12px; background: var(--sheet); }
.summary { color: var(--ink-2); font-size: 14px; }
.summary b { color: var(--ink); }
.summary:empty { display: none; }

.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: 1px solid var(--line); margin: -20px -20px 0; }
.tab { padding: 14px 4px 12px; border: 0; background: none; color: var(--ink-2); font-weight: 500; font-size: 14px; position: relative; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); }
.tabpanel { display: grid; gap: 16px; }
.fset { display: grid; gap: 12px; }
.fset__title { font-weight: 600; font-size: 14px; }
.fset + .fset { padding-top: 16px; border-top: 1px solid var(--line); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.seg button { padding: 7px 8px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font-weight: 500; font-size: 13.5px; transition: background-color .12s, color .12s; }
.seg button[aria-checked="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg--tight { padding: 2px; }
.seg--tight button { padding: 6px 10px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; color: var(--ink-2); }
.field input:not([type=checkbox]):not([type=range]):not([type=color]), .field select, .field textarea { width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg); min-width: 0; }
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field input.is-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.field__row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.field__row--color { grid-template-columns: 44px 1fr; }
.field input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg); }
.field__suffix { color: var(--ink-2); font-size: 13.5px; }
.field__help { color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.field__error { font-size: 13px; color: var(--warn); line-height: 1.45; }
.field__warn { font-size: 13px; color: var(--warn); line-height: 1.45; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); }
.field__empty { font-size: 13.5px; color: var(--ink-2); padding: 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }
.field--range output { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.check span { display: grid; gap: 2px; }
.posgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 112px; padding: 4px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); }
.posgrid button { aspect-ratio: 1; border: 0; border-radius: 4px; background: var(--line); }
.posgrid button:hover { background: var(--line-2); }
.posgrid button[aria-checked="true"] { background: var(--accent); }

/* ---------- Miniaturas ---------- */
.pages { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px 14px; }
.tile { --w: 124px; position: relative; width: var(--w); flex: none; display: grid; align-content: start; gap: 7px; padding: 0; border: 0; background: none; text-align: center; color: var(--ink-2); font-size: 12.5px; }
.tile__paper { width: 100%; aspect-ratio: var(--ar, 0.7071); border: 1px solid var(--line-2); border-radius: 3px; background: #fff; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06); display: grid; place-items: center; transition: border-color .12s, box-shadow .12s, transform .25s; }
.tile__paper img, .tile__paper canvas { width: 100%; height: 100%; display: block; object-fit: contain; }
.tile__paper--img { background: var(--line); }
.tile__paper--img img { object-fit: cover; }
.tile__paper.is-rotated img { transform: rotate(var(--rot)); transition: transform .25s; object-fit: contain; }
.tile__ext { font-weight: 600; color: var(--ink-3); font-size: 14px; }
.tile__foot { display: flex; justify-content: center; gap: 6px; line-height: 1; }
.tile__badge { position: absolute; top: 6px; left: 6px; padding: 2px 6px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 600; }
.tile--selectable { cursor: pointer; }
.tile--selectable:hover .tile__paper { border-color: var(--ink-3); }
.tile--selectable[aria-pressed="true"] .tile__paper { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.tile--selectable[aria-pressed="true"] .tile__num { color: var(--accent); font-weight: 600; }
.tile--selectable[aria-pressed="true"]::after { content: ""; position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 8.3 2.6 2.6L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat; }
.tile--muted .tile__paper { filter: grayscale(1); opacity: .5; }
.tile--muted .tile__num { color: var(--ink-3); }
.tile--draggable { cursor: grab; }
.tile.is-ghost { opacity: .3; }
.tile.is-chosen .tile__paper { box-shadow: 0 0 0 3px var(--accent-soft-2); border-color: var(--accent); }
.tile__actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.tile:hover .tile__actions, .tile:focus-within .tile__actions { opacity: 1; }
.tile__act { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--sheet); color: var(--ink-2); display: grid; place-items: center; padding: 0; }
.tile__act:hover { color: var(--accent); border-color: var(--accent); }
.tile--removed .tile__paper { opacity: .35; filter: grayscale(1); }
.tile--removed::before { content: ""; position: absolute; inset: 0 0 24px; background: linear-gradient(to top right, transparent 48.5%, var(--danger) 48.5%, var(--danger) 51.5%, transparent 51.5%); pointer-events: none; }

/* Grupos (dividir) */
.group { display: grid; gap: 10px; }
.group__head { display: flex; align-items: center; gap: 8px 12px; min-height: 24px; flex-wrap: wrap; }
.group__title { font-weight: 600; font-size: 14px; white-space: nowrap; }
.group__sub { color: var(--ink-2); font-size: 13px; }
.group__join { margin-left: auto; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--sheet); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.group__join:hover { color: var(--accent); border-color: var(--accent); }
.group--rest .group__title { color: var(--ink-2); font-weight: 500; }
.group--rest .tile { opacity: .45; }
.group__pages { display: flex; flex-wrap: wrap; align-items: stretch; row-gap: 20px; }
.cut { position: relative; flex: none; width: 24px; align-self: stretch; border: 0; padding: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.cut::before { content: ""; position: absolute; top: 0; bottom: 26px; left: 50%; border-left: 2px dashed var(--accent); opacity: 0; transition: opacity .12s; }
.cut__ico { position: relative; z-index: 1; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; opacity: 0; transform: scale(.7); transition: opacity .12s, transform .12s; margin-bottom: 26px; }
.cut:hover::before, .cut:focus-visible::before { opacity: 1; }
.cut:hover .cut__ico, .cut:focus-visible .cut__ico { opacity: 1; transform: scale(1); }
.cut--static { cursor: default; }
.cut--static::before, .cut--static .cut__ico { display: none; }

/* Lista de archivos (unir) */
.filecards { display: flex; flex-wrap: wrap; gap: 20px 14px; align-items: flex-start; }
.filecard { --w: 150px; }
.filecard .tile__num { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.filecard .tile__meta { font-size: 11.5px; color: var(--ink-3); }
.addcard { width: 150px; aspect-ratio: 0.7071; border: 1px dashed var(--line-2); border-radius: 6px; background: none; color: var(--ink-2); display: grid; place-content: center; gap: 6px; justify-items: center; font-size: 13px; }
.addcard:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Visor ---------- */
.viewer { display: grid; gap: 12px; justify-items: center; }
.viewer__frame { position: relative; background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line-2); user-select: none; touch-action: none; }
.viewer__canvas { position: absolute; inset: 0; }
.viewer__canvas canvas { display: block; }
.viewer__overlay { position: absolute; inset: 0; }
.viewer__overlay.is-drawing { cursor: crosshair; }
.viewer__nav { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13.5px; }
.vbox { position: absolute; border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); cursor: move; outline: none; box-sizing: border-box; }
.vbox:focus, .vbox.is-selected { box-shadow: 0 0 0 3px var(--accent-soft-2); }
.vbox--draw { pointer-events: none; }
.vbox__h { position: absolute; width: 12px; height: 12px; background: var(--sheet); border: 1.5px solid var(--accent); border-radius: 2px; }
.vbox__h--nw { left: -7px; top: -7px; cursor: nwse-resize; } .vbox__h--ne { right: -7px; top: -7px; cursor: nesw-resize; }
.vbox__h--sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .vbox__h--se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.vbox img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.vbox--redact { background: #000; border-color: #000; }
.vbox--crop { background: transparent; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); cursor: move; }
.vbox--text { background: transparent; }
.vbox--text .vbox__text { position: absolute; inset: 0; padding: 0; white-space: pre-wrap; overflow: hidden; line-height: 1.2; }
.pad { display: block; width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; }

/* ---------- Resultados ---------- */
.done { flex: 1; padding: clamp(32px, 7vh, 80px) 24px 64px; }
.done__inner { max-width: 680px; margin: 0 auto; display: grid; gap: 20px; justify-items: start; }
.done__title { font-size: clamp(28px, 4vw, 38px); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.done__lead { color: var(--ink-2); font-size: 16px; }
.done__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.results { width: 100%; border-top: 1px solid var(--line); margin-top: 8px; }
.result { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.result__thumb { width: 56px; height: 56px; flex: none; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; background: var(--line); }
.result__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result__body { flex: 1; min-width: 0; }
.result__name { font-weight: 500; overflow-wrap: anywhere; }
.result__meta { color: var(--ink-2); font-size: 13px; }
.result__dl { color: var(--accent); text-decoration: none; font-weight: 500; white-space: nowrap; }
.result__dl:hover { text-decoration: underline; }
.done__next { display: grid; gap: 10px; width: 100%; }
.done__next p { font-size: 13.5px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--sheet); font-size: 13.5px; font-weight: 500; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip__icon { display: grid; place-items: center; width: 18px; height: 18px; color: var(--ink-3); }
.chip__icon svg { width: 16px; height: 16px; }
.chip:hover .chip__icon { color: var(--accent); }

/* ---------- Superposiciones ---------- */
.busy { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(4px); }
.busy__card { width: min(380px, calc(100% - 48px)); padding: 22px 24px; border-radius: var(--radius); background: var(--sheet); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 12px; }
.busy__bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; position: relative; }
.busy__bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.busy__bar span.is-indeterminate { width: 40% !important; position: absolute; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { left: -40%; } 100% { left: 100%; } }
.busy p { font-size: 14px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 48px); }
.dropveil { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: color-mix(in srgb, var(--accent-soft) 85%, transparent); border: 3px dashed var(--accent); font-size: 20px; font-weight: 600; color: var(--accent); pointer-events: none; }
.dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); color: var(--ink); padding: 0; box-shadow: var(--shadow); width: min(420px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(2px); }
.dlg__form { padding: 22px 24px; display: grid; gap: 14px; }
.dlg__title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.dlg__text { color: var(--ink-2); font-size: 14px; }
.dlg__fields { display: grid; gap: 12px; }
.dlg__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Comparación */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare__col { display: grid; gap: 8px; }
.compare__col h3 { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare__canvas { width: 100%; border: 1px solid var(--line-2); background: #fff; }
.diff { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sheet); max-height: 420px; overflow: auto; }
.diff ins { background: var(--c-green-soft); color: var(--c-green); text-decoration: none; }
.diff del { background: var(--c-red-soft); color: var(--c-red); }

/* Escáner */
.scanner { display: grid; gap: 12px; }
.scanner video { width: 100%; max-height: 60vh; background: #000; border-radius: var(--radius); object-fit: contain; }
.scanner__ctrl { display: flex; gap: 10px; flex-wrap: wrap; }

/* Texto editable (editor) */
.editbar { display: flex; flex-wrap: wrap; gap: 6px; }
.editbar .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .top__nav a { display: none; }
}
@media (max-width: 920px) {
  .work { grid-template-columns: 1fr; min-height: 0; }
  .panel { position: static; height: auto; border-left: 0; border-bottom: 1px solid var(--line); order: -1; }
  .panel__body { overflow: visible; }
  .panel__foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; grid-template-columns: 1fr auto; align-items: center; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -12px rgba(0,0,0,.18); }
  .panel__foot .btn { width: auto; }
  .stage { padding-bottom: 96px; }
  .filebar { top: 0; }
  .filebar__hint { display: none; }
  .compare { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .top { padding: 0 16px; gap: 12px; position: static; }
  .top__privacy span { display: none; }
  .home, .done, .stage, .tool__pick, .tool__head { padding-left: 16px; padding-right: 16px; }
  .drop { padding: 28px 16px 24px; }
  .tile { --w: 96px; }
  .cut { width: 18px; }
  .tabs .tab { font-size: 13px; padding: 12px 2px 10px; }
  .filebar__name { max-width: 100%; }
  .done__actions .btn { flex: 1; }
  .menu { position: fixed; top: 0; bottom: 0; max-height: none; }
  .toolgrid { grid-template-columns: 1fr 1fr; }
  .toolcard { grid-template-columns: 1fr; padding: 12px; }
  .toolcard__icon { grid-row: auto; margin-bottom: 8px; }
}

/* Listas auxiliares */
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
.orderlist { display: grid; gap: 4px; }
.orderlist__item { display: grid; grid-template-columns: 20px 1fr auto auto; align-items: center; gap: 6px; font-size: 13.5px; }
.orderlist__n { color: var(--ink-3); }
.orderlist__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranges { display: grid; gap: 8px; }
.range { display: grid; grid-template-columns: 22px 1fr 16px 1fr 28px; align-items: center; gap: 6px; }
.range__idx { font-size: 13px; color: var(--ink-2); }
.range__dash { text-align: center; color: var(--ink-3); }
.range input { width: 100%; padding: 7px 9px; text-align: center; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg); min-width: 0; }
.range input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.range input.is-bad { border-color: var(--warn); }
.range__del { justify-self: end; }
