/* Koy Decoder: tokens de color y tipografía, layout y componentes.
   Misma paleta y mismo lenguaje visual que Koy PDF.
   Claro por defecto; oscuro por preferencia del sistema o con data-theme. */
:root {
  color-scheme: light;
  --bg: #f9f9ff; --panel: #ffffff; --panel-2: #f0f3ff; --panel-3: #e8eeff; --panel-4: #dfe8fe; --bar: rgba(255, 255, 255, .88);
  --border: #e2e8f8; --border-strong: #c2c6d4;
  --text: #131c2b; --muted: #424752; --faint: #727783;
  --accent: #125cb6; --accent-strong: #0d4a94; --accent-fill: #125cb6; --on-accent: #ffffff; --accent-soft: #e8eeff; --accent-line: rgba(105, 161, 255, .5);
  --g1: #125cb6; --g2: #69a1ff; --g3: #5fb6e8;
  --ok: #00564b; --ok-soft: rgba(95, 232, 208, .16); --ok-line: rgba(95, 232, 208, .5); --ok-dot: #69ffba;
  --danger: #b4232a; --danger-soft: #fbe7e7; --warn: #8a5a00; --warn-soft: #fbf0dc;
  --bar-before: #8a5a00; --bar-after: #125cb6;
  --radius: 16px; --radius-lg: 20px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(18, 92, 182, .05), 0 1px 8px rgba(18, 92, 182, .04); --shadow-lg: 0 8px 24px rgba(18, 92, 182, .10);
  --glow: none; --glow-ok: none;
  --font-head: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0e16; --panel: #121620; --panel-2: #181c26; --panel-3: #222734; --panel-4: #2c3242; --bar: rgba(10, 14, 22, .85);
    --border: rgba(255, 255, 255, .08); --border-strong: #334155;
    --text: #f1f5f9; --muted: #94a3b8; --faint: #64748b;
    --accent: #abc7ff; --accent-strong: #d3e2ff; --accent-fill: #69a1ff; --on-accent: #001b3f; --accent-soft: rgba(105, 161, 255, .14); --accent-line: rgba(171, 199, 255, .35);
    --g1: #abc7ff; --g2: #69a1ff; --g3: #75f1ff;
    --ok: #71f8e0; --ok-soft: #062f24; --ok-line: rgba(80, 220, 196, .3); --ok-dot: #69ffba;
    --danger: #f0888c; --danger-soft: #2a1416; --warn: #e0b46b; --warn-soft: #2a2213;
    --bar-before: #bd8433; --bar-after: #3f7fe6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 8px 30px rgba(0, 0, 0, .5);
    --glow: 0 0 16px rgba(105, 161, 255, .35); --glow-ok: 0 0 12px rgba(105, 255, 186, .2);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e16; --panel: #121620; --panel-2: #181c26; --panel-3: #222734; --panel-4: #2c3242; --bar: rgba(10, 14, 22, .85);
  --border: rgba(255, 255, 255, .08); --border-strong: #334155;
  --text: #f1f5f9; --muted: #94a3b8; --faint: #64748b;
  --accent: #abc7ff; --accent-strong: #d3e2ff; --accent-fill: #69a1ff; --on-accent: #001b3f; --accent-soft: rgba(105, 161, 255, .14); --accent-line: rgba(171, 199, 255, .35);
  --g1: #abc7ff; --g2: #69a1ff; --g3: #75f1ff;
  --ok: #71f8e0; --ok-soft: #062f24; --ok-line: rgba(80, 220, 196, .3); --ok-dot: #69ffba;
  --danger: #f0888c; --danger-soft: #2a1416; --warn: #e0b46b; --warn-soft: #2a2213;
  --bar-before: #bd8433; --bar-after: #3f7fe6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 8px 30px rgba(0, 0, 0, .5);
  --glow: 0 0 16px rgba(105, 161, 255, .35); --glow-ok: 0 0 12px rgba(105, 255, 186, .2);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
html, body { margin: 0; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100dvh; -webkit-font-smoothing: antialiased; }
body.dragging::after { content: ""; position: fixed; inset: 0; border: 3px dashed var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); pointer-events: none; z-index: 50; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.02em; margin: 0; }
p { margin: 0; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 640px) { .wrap { padding-left: 24px; padding-right: 24px; } }
main.wrap { padding-top: 14px; padding-bottom: 48px; }
.sec, #app { scroll-margin-top: 84px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 60; background: var(--panel); padding: 10px 14px; border-radius: var(--radius-sm); }

/* ---- cabecera ---- */
.top { position: sticky; top: 0; z-index: 40; background: var(--bar); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top, 0px); }
.top-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 64px; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand .logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--g1), var(--g2)); color: var(--on-accent); box-shadow: var(--glow); transition: transform .15s; }
.brand:hover .logo { transform: scale(1.05); }
.brand .bname { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.nav { display: none; gap: 22px; margin-left: 20px; font-size: .88rem; font-weight: 500; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--accent); }
@media (min-width: 1000px) { .nav { display: flex; } }
.topbtns { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbtns a, .topbtns button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; color: var(--muted); text-decoration: none; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; transition: color .15s, border-color .15s; }
.topbtns a:hover, .topbtns button:hover { color: var(--accent); border-color: var(--accent-line); }
.topbtns #themeBtn { padding: 0; }
.i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .i-sun { display: none; } :root:not([data-theme="light"]) .i-moon { display: inline; } }
:root[data-theme="dark"] .i-sun { display: none; } :root[data-theme="dark"] .i-moon { display: inline; }
:root[data-theme="light"] .i-sun { display: inline; } :root[data-theme="light"] .i-moon { display: none; }

/* ---- titular ---- */
.hero { text-align: center; margin: 10px auto 16px; max-width: 900px; }
.hero h1 { font-size: clamp(1.5rem, 1.05rem + 1.8vw, 2.3rem); line-height: 1.12; margin: 0 0 8px; font-weight: 700; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--g1), var(--g2), var(--g3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { color: var(--muted); margin: 0 auto; max-width: 720px; font-size: .98rem; }
@media (max-width: 520px) { .hero .lead { font-size: .9rem; } }

/* ---- tarjeta y zona de carga ---- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
@media (min-width: 640px) { .card { padding: 18px; } }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px dashed var(--accent-line); border-radius: var(--radius); background: var(--panel-2); padding: 30px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop .dicon { width: 60px; height: 60px; border-radius: 16px; background: var(--panel-4); color: var(--accent); display: grid; place-items: center; margin-bottom: 8px; box-shadow: var(--glow); transition: transform .15s; }
.drop:hover .dicon, .drop.drag .dicon { transform: scale(1.06); }
.drop strong { display: block; font-family: var(--font-head); font-size: 1.25rem; letter-spacing: -.01em; }
.drop span { color: var(--muted); font-size: .92rem; }
.drop small { display: block; color: var(--faint); font-size: .78rem; margin-top: 8px; max-width: 600px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.chip { font-size: .74rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--panel-3); color: var(--accent); }
.touch-only { display: none !important; }
@media (pointer: coarse) {
  .pointer-only { display: none !important; }
  .drop strong.touch-only { display: block !important; }
  .drop span.touch-only { display: inline !important; }
}
@media (max-width: 520px) { .drop { padding: 24px 14px; } .drop .dicon { width: 56px; height: 56px; } .drop strong { font-size: 1.1rem; } }

.file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 14px; }
.file-row .ic { color: var(--accent); flex: 0 0 auto; display: flex; }
.file-row .meta { min-width: 0; flex: 1 1 180px; }
.file-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .size { color: var(--muted); font-size: .8rem; }
.file-row .kind { font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--panel-3); color: var(--accent); white-space: nowrap; }
.file-row button.link { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; font-size: .85rem; padding: 4px; text-decoration: underline; }

/* ---- resultado ---- */
.out { margin-top: 18px; }
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; padding: 16px 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.verdict .big { font-family: var(--font-head); font-weight: 700; font-size: clamp(2.6rem, 1.6rem + 4vw, 4rem); line-height: 1; letter-spacing: -.04em; color: var(--accent); font-variant-numeric: tabular-nums; }
.verdict .cap { color: var(--muted); font-size: .95rem; max-width: 40ch; }

.bars { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.btop { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.bname { font-size: .88rem; font-weight: 600; }
.bval { font-family: var(--font-mono); font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.track { height: 22px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.fill { height: 100%; border-radius: 999px; min-width: 4px; transition: width .45s cubic-bezier(.2, .75, .3, 1); }
.fill.before { background: var(--bar-before); }
.fill.after { background: var(--bar-after); }
.bnote { margin-top: 6px; font-size: .78rem; color: var(--faint); }

.meters { margin: 22px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.meters > div { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.meters dt { font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--faint); }
.meters dd { margin: 5px 0 0; font-family: var(--font-head); font-size: 1.24rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.meters dd small { font-size: .74rem; font-weight: 500; color: var(--faint); }

.msg { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.info { background: var(--accent-soft); color: var(--accent); }
.msg.err { background: var(--danger-soft); color: var(--danger); }

/* ---- ocr ---- */
.ocr { margin-top: 22px; padding: 16px; border: 1px solid var(--accent-line); border-radius: var(--radius); background: var(--accent-soft); }
.ocr h3 { font-size: 1.05rem; font-weight: 700; }
.ocr p { margin-top: 5px; font-size: .86rem; color: var(--muted); max-width: 70ch; }
.ocr .btn { margin-top: 14px; }
.ocrbar { margin-top: 14px; }
.ocrtrack { height: 8px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.ocrfill { height: 100%; width: 0; border-radius: 999px; background: var(--accent-fill); transition: width .3s ease; }
.ocrtext { display: block; margin-top: 7px; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- selector de contenido ---- */
.pickr { margin-top: 22px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.pick-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; justify-content: space-between; }
.pick-head h3 { font-size: 1.05rem; font-weight: 700; }
.pick-btns { display: flex; gap: 6px; }
.pick-list { list-style: none; margin: 14px 0 0; padding: 0; max-height: 340px; overflow: auto; }
.pick { border-top: 1px solid var(--border); }
.pick:first-child { border-top: none; }
.pick.lv2 .pick-name { padding-left: 14px; }
.pick.lv3 .pick-name { padding-left: 28px; }
.pick-top { display: flex; align-items: center; gap: 10px; padding: 9px 2px; cursor: pointer; }
.pick-top input { width: 17px; height: 17px; accent-color: var(--accent-fill); flex: none; cursor: pointer; }
.pick-name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-tok { font-family: var(--font-mono); font-size: .76rem; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick-top input:not(:checked) ~ .pick-name, .pick-top input:not(:checked) ~ .pick-tok { color: var(--faint); text-decoration: line-through; }
.cols { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 10px 30px; }
.cols-t { flex: 1 1 100%; font-size: .74rem; color: var(--faint); }
.col { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); font-size: .78rem; cursor: pointer; }
.col input { width: 14px; height: 14px; accent-color: var(--accent-fill); cursor: pointer; }
.col input:not(:checked) + span { color: var(--faint); text-decoration: line-through; }

/* ---- descarga ---- */
.grab { margin-top: 22px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.grab h3 { font-size: 1.05rem; font-weight: 700; }
.grab-lead { margin-top: 4px; font-size: .84rem; color: var(--muted); }
.fmts { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.fmt { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; color: var(--text); cursor: pointer; font: inherit; transition: border-color .15s, box-shadow .15s, background .15s; }
.fmt:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.fmt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.fmt b { display: block; font-family: var(--font-head); font-size: .92rem; font-weight: 600; }
.fmt span { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.fmt .rec { display: block; margin-top: 6px; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); font-style: normal; }
.grab-acts { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.grab-acts > * { flex: 1 1 200px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--radius-sm); padding: 13px 16px; font: inherit; font-size: .95rem; font-weight: 700; cursor: pointer; text-decoration: none; border: 1px solid transparent; transition: filter .15s, border-color .15s; }
.btn.primary { background: var(--accent-fill); color: var(--on-accent); box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--border); font-weight: 600; }
.btn.secondary:hover { border-color: var(--accent-line); }

.tabs { display: flex; gap: 6px; margin-top: 22px; }
.tab { flex: 0 0 auto; font-size: .84rem; font-weight: 600; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s; }
.tab:hover { color: var(--accent); border-color: var(--accent-line); }
.tab[aria-selected="true"] { background: var(--accent-fill); color: var(--on-accent); border-color: transparent; box-shadow: var(--glow); }
.pane { margin: 10px 0 0; padding: 14px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 320px; overflow: auto; font-family: var(--font-mono); font-size: .78rem; line-height: 1.6; white-space: pre; color: var(--muted); }

/* ---- secciones ---- */
.sec { margin-top: 44px; }
.sec h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.75rem); font-weight: 700; }
.sec > .lead { margin-top: 8px; color: var(--muted); max-width: 70ch; }

.trust { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 16px; }
.trust > div { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.trust .ti { width: 36px; height: 36px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin-bottom: 10px; }
.trust b { font-family: var(--font-head); font-size: .98rem; }
.trust p { margin-top: 4px; color: var(--muted); font-size: .86rem; }

.hows { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.hows > div { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.hows .hi { width: 38px; height: 38px; border-radius: 10px; background: var(--panel-3); color: var(--accent); display: grid; place-items: center; margin-bottom: 10px; }
.hows h3 { font-size: .98rem; font-weight: 600; }
.hows p { margin-top: 5px; color: var(--muted); font-size: .86rem; }

.faq { margin-top: 14px; }
.faq details { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; box-shadow: var(--shadow); }
.faq summary { padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: .95rem; list-style: none; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "\2013"; }
.faq p { padding: 0 16px 14px; color: var(--muted); font-size: .88rem; }

footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 22px 0 calc(28px + env(safe-area-inset-bottom, 0px)); color: var(--faint); font-size: .8rem; line-height: 1.7; }
footer .frow { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
footer .fmethod { margin-top: 10px; max-width: 90ch; font-size: .76rem; }
footer a { color: var(--muted); }
