/* Mis Apuntes — cuaderno de cuadrícula */

@font-face { font-family: "Literata"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/literata-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Literata"; font-weight: 400; font-style: italic; font-display: swap; src: url("/fonts/literata-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Literata"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/literata-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Literata"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/literata-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Reenie Beanie"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/reenie-beanie-latin-400-normal.woff2") format("woff2"); }

:root {
  --paper: #f8fafb;
  --grid: rgba(35, 70, 176, .075);
  --sheet: #ffffff;
  --ink: #16233b;
  --muted: #586a82;
  --pen: #2346b0;
  --pen-hover: #1a3689;
  --pen-soft: #e7edfb;
  --margin: #d8453b;
  --line: #d8e1ea;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --err: #b42318;
  --shadow: 0 1px 2px rgba(22, 35, 59, .06), 0 8px 24px -12px rgba(22, 35, 59, .18);
  --ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --read: "Literata", Georgia, "Times New Roman", serif;
  --hand: "Reenie Beanie", "Segoe Print", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1522;
    --grid: rgba(138, 168, 255, .06);
    --sheet: #141d2d;
    --ink: #e6ecf7;
    --muted: #9aaac1;
    --pen: #8aa8ff;
    --pen-hover: #a9bfff;
    --pen-soft: #1c2a4a;
    --margin: #ff7b70;
    --line: #29364d;
    --ok: #5fd39a;
    --warn: #f2b45a;
    --err: #ff8b80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--ui);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: 12px; top: -48px; background: var(--pen); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 50; text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- Botones ---------- */
.btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; font-weight: 700; line-height: 1.2;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--pen); color: var(--pen); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.big { min-height: 50px; font-size: 17px; width: 100%; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--pen); border-color: var(--pen); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--pen-hover); border-color: var(--pen-hover); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e1522; } .btn.primary:hover:not(:disabled) { color: #0e1522; } }
.link { background: none; border: 0; padding: 0; color: var(--pen); text-decoration: underline; cursor: pointer; font-weight: 700; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1320px; margin: 0 auto; padding: 14px 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--pen); text-decoration: none; }
.wordmark { white-space: nowrap; font-family: var(--read); font-weight: 700; font-size: 21px; color: var(--ink); letter-spacing: -.01em; }

/* ---------- Estructura ---------- */
.layout {
  display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 32px;
  max-width: 1320px; margin: 0 auto; padding: 8px 24px 48px; align-items: start;
}

/* Panel izquierdo, plano */
.bench { display: flex; flex-direction: column; gap: 28px; }
.bench-head h1 { margin: 0 0 6px; font-family: var(--read); font-size: 32px; line-height: 1.15; letter-spacing: -.015em; font-weight: 700; }
.bench-head p { margin: 0; color: var(--muted); max-width: 38ch; }

.step { padding-top: 20px; border-top: 1px solid var(--line); }
.step h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.step h2 .n {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--pen); color: #fff; font-size: 14px; font-weight: 700;
}
@media (prefers-color-scheme: dark) { .step h2 .n { color: #0e1522; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.note { margin: 0; font-size: 14px; color: var(--muted); }

/* Selector de modo */
.mode { display: inline-flex; padding: 3px; margin-bottom: 14px; background: var(--pen-soft); border-radius: 10px; }
.mode-btn { border: 0; background: transparent; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--muted); min-height: 36px; }
.mode-btn.active { background: var(--sheet); color: var(--pen); box-shadow: 0 1px 2px rgba(22, 35, 59, .15); }

/* Zona de carga con esquinas de escáner */
.drop {
  --c: var(--pen); --l: 22px; --t: 3px;
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 28px 18px 22px; background-color: var(--sheet); cursor: pointer; border-radius: 4px;
  background-image:
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c));
  background-repeat: no-repeat;
  background-size: var(--l) var(--t), var(--t) var(--l), var(--l) var(--t), var(--t) var(--l), var(--l) var(--t), var(--t) var(--l), var(--l) var(--t), var(--t) var(--l);
  background-position: 0 0, 0 0, 100% 0, 100% 0, 0 100%, 0 100%, 100% 100%, 100% 100%;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color .15s;
}
.drop:hover, .drop.over { background-color: var(--pen-soft); }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--pen-soft); color: var(--pen); margin-bottom: 4px; }
.drop strong { font-size: 17px; }
.drop-sub { color: var(--muted); font-size: 14px; max-width: 30ch; }
.drop-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }

/* Lista de archivos */
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 8px; background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; }
.thumb { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 6px; background: var(--pen-soft); color: var(--pen); font-weight: 700; font-size: 13px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { flex: 1; min-width: 0; }
.name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 13px; color: var(--muted); }
.sub .err { color: var(--err); }
.ops { display: flex; gap: 2px; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; }
.icon-btn:hover:not(:disabled) { background: var(--pen-soft); color: var(--pen); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* Texto pegado: líneas de cuaderno */
.paste, .transcript {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 4px; background-color: var(--sheet);
  font-family: var(--read); font-size: 16px; line-height: 32px; padding: 0 16px 0 16px;
  background-image: linear-gradient(transparent 31px, var(--grid) 31px);
  background-size: 100% 32px; background-attachment: local;
}
.paste { min-height: 224px; }

/* Ajustes */
.options { display: flex; flex-direction: column; gap: 14px; }
.options label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select {
  min-height: 42px; padding: 8px 36px 8px 12px; background-color: var(--sheet); border: 1px solid var(--line); border-radius: 8px;
  font-weight: 400; font-size: 15px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23586a82' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.options .check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--muted); }
.options .check strong { color: var(--ink); }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--pen); flex: none; }

/* Procesar y progreso */
.cta { display: flex; flex-direction: column; gap: 8px; }
.steps { list-style: none; margin: 20px 0 0; padding: 0; position: relative; }
.steps li { position: relative; display: flex; align-items: center; gap: 12px; padding: 7px 0; color: var(--muted); font-size: 15px; }
.steps li::before { content: ""; position: absolute; left: 8px; top: -50%; bottom: 50%; width: 2px; background: var(--line); }
.steps li:first-child::before { display: none; }
.steps i { position: relative; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); }
.steps li.active { color: var(--ink); font-weight: 700; }
.steps li.active i { border-color: var(--pen); border-top-color: transparent; animation: spin .8s linear infinite; }
.steps li.done { color: var(--ink); }
.steps li.done i { background: var(--ok); border-color: var(--ok); }
.steps li.done i::after { content: ""; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.steps li.done::before, .steps li.active::before { background: var(--pen); }
.steps li.error { color: var(--err); font-weight: 700; }
.steps li.error i { background: var(--err); border-color: var(--err); }
.steps li.skipped { opacity: .5; text-decoration: line-through; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hoja de resultados ---------- */
.sheet {
  position: relative; background: var(--sheet); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  min-height: 560px; display: flex; flex-direction: column;
}
.tabs { display: flex; gap: 2px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; margin-bottom: -1px;
  background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0;
  cursor: pointer; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--sheet); border-color: var(--line); color: var(--pen); box-shadow: inset 0 3px 0 var(--pen); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.tab[data-status="loading"] .dot { background: var(--pen); animation: pulse 1s ease-in-out infinite; }
.tab[data-status="done"] .dot { background: var(--ok); }
.tab[data-status="error"] .dot { background: var(--err); }
@keyframes pulse { 50% { opacity: .25; } }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.stats { font-size: 14px; color: var(--muted); }
.tool-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.results:has(#empty:not([hidden])) .tabs,
.results:has(#empty:not([hidden])) .toolbar,
.results:has(#empty:not([hidden])) .footnote { display: none; }

.panes { flex: 1; display: flex; flex-direction: column; }
.pane { display: none; flex: 1; }
.pane.active:not([hidden]) { display: flex; flex-direction: column; }

.banner { margin: 16px 16px 0; padding: 10px 14px; background: var(--pen-soft); border-radius: 8px; font-size: 14px; }

.transcript { flex: 1; min-height: 480px; border: 0; border-radius: 0; padding-left: 80px; padding-right: 24px; outline-offset: -3px; background-image: linear-gradient(transparent 31px, var(--grid) 31px), linear-gradient(90deg, transparent 63px, var(--margin) 63px, var(--margin) 64px, transparent 64px); background-attachment: local, local; background-size: 100% 32px, 100% 100%; }

/* Folio con margen rojo */
.paper {
  position: relative; flex: 1; padding: 28px 32px 36px 88px; font-family: var(--read); font-size: 17px; line-height: 1.7;
  max-width: 100%; overflow-wrap: anywhere;
}
.paper::before { content: ""; position: absolute; left: 64px; top: 0; bottom: 0; width: 1px; background: var(--margin); opacity: .8; }
.paper > * { max-width: 68ch; }
.paper h1, .paper h2, .paper h3, .paper h4 { font-weight: 700; line-height: 1.25; letter-spacing: -.01em; margin: 1.6em 0 .5em; }
.paper > :first-child { margin-top: 0; }
.paper h1 { font-size: 28px; }
.paper h2 { font-size: 22px; }
.paper h3 { font-size: 18px; }
.paper p { margin: 0 0 1em; }
.paper ul, .paper ol { padding-left: 1.4em; margin: 0 0 1em; }
.paper li { margin: .3em 0; }
.paper li::marker { color: var(--pen); }
.paper strong { font-weight: 700; }
.paper blockquote { margin: 1em 0; padding: 2px 16px; border-left: 3px solid var(--pen); color: var(--muted); }
.paper code { font-size: .88em; background: var(--pen-soft); padding: 1px 5px; border-radius: 4px; }
.paper table { border-collapse: collapse; margin: 1em 0; font-size: 15px; display: block; overflow-x: auto; }
.paper th, .paper td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.paper th { background: var(--pen-soft); }
.paper.streaming::after { content: ""; display: inline-block; width: 8px; height: 1.1em; margin-left: 2px; background: var(--pen); vertical-align: text-bottom; animation: pulse 1s steps(2) infinite; }

.footnote { margin: 0; padding: 14px 24px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.footnote code { background: var(--pen-soft); padding: 0 4px; border-radius: 3px; }

/* ---------- Estado vacío: de tu letra a texto digital ---------- */
.empty { display: flex; flex-direction: column; justify-content: center; gap: 40px; padding: 40px 32px; flex: 1; }
.demo { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.page { margin: 0; width: 280px; }
.page > div { min-height: 190px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 4px; }
.page figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); text-align: center; }
.page-hand > div {
  background-color: #fffdf6;
  background-image: linear-gradient(transparent 31px, rgba(35, 70, 176, .22) 31px); background-size: 100% 32px;
  font-family: var(--hand); font-size: 25px; line-height: 32px; color: #1f2f8a; padding-top: 0;
  box-shadow: 0 6px 14px -8px rgba(22, 35, 59, .35); transform: rotate(-1.2deg);
}
@media (prefers-color-scheme: dark) { .page-hand > div { background-color: #e9e4d2; color: #1f2f8a; } }
.hand p { margin: 0; transform: rotate(var(--r, 0deg)); white-space: nowrap; }
.page-type > div { background: var(--sheet); font-family: var(--read); box-shadow: var(--shadow); position: relative; padding-left: 36px; }
.page-type > div::before { content: ""; position: absolute; left: 24px; top: 0; bottom: 0; width: 1px; background: var(--margin); opacity: .8; }
.typed h3 { margin: 0 0 8px; font-size: 18px; line-height: 1.3; }
.typed ul { margin: 0; padding-left: 1.2em; font-size: 15px; line-height: 1.6; }
.typed li::marker { color: var(--pen); }
.demo-arrow { color: var(--margin); flex: none; transform: translateY(-14px); }

.gives { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 0; max-width: 760px; align-self: center; }
.gives dt { font-weight: 700; margin-bottom: 4px; }
.gives dd { margin: 0; font-size: 14px; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .typed [style*="--i"] { opacity: 0; animation: reveal .5s ease forwards; animation-delay: calc(.5s + var(--i) * .35s); }
  .demo-arrow path { stroke-dasharray: 140; stroke-dashoffset: 140; animation: draw .8s ease forwards .3s; }
  @keyframes reveal { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}

/* ---------- Avisos y diálogo ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(92vw, 440px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 8px; background: #16233b; color: #fff; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); border-left: 4px solid #8aa8ff; pointer-events: auto; }
.toast.ok { border-left-color: #5fd39a; }
.toast.warn { border-left-color: #f2b45a; }
.toast.error { border-left-color: #ff8b80; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: var(--sheet); color: var(--ink); width: min(92vw, 380px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(14, 21, 34, .55); }
dialog h3 { margin: 0 0 6px; font-family: var(--read); font-size: 20px; }
dialog input { width: 100%; min-height: 44px; margin: 14px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Adaptación ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; gap: 28px; padding: 8px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .bench-head h1 { font-size: 28px; }
  .sheet { min-height: 0; }
  .paper { padding: 22px 18px 28px 44px; font-size: 16px; }
  .paper::before { left: 28px; }
  .transcript { padding-left: 44px; background-image: linear-gradient(transparent 31px, var(--grid) 31px), linear-gradient(90deg, transparent 27px, var(--margin) 27px, var(--margin) 28px, transparent 28px); }
  .empty { padding: 28px 16px; gap: 28px; }
  .demo-arrow { transform: rotate(90deg); }
  .gives { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 480px) {
  .wordmark { font-size: 18px; }
  .topbar .btn { padding: 6px 10px; font-size: 14px; min-height: 38px; }
  .pair { grid-template-columns: 1fr; }
  .page { width: 100%; max-width: 300px; }
  .tool-buttons .btn { flex: 1 1 auto; }
}
@media print { body { background: none; } .topbar, .bench, .tabs, .toolbar, .footnote { display: none; } .layout { display: block; padding: 0; } .sheet { border: 0; box-shadow: none; } }
