/*
 * Calma en la web: panel con barra lateral y tarjetas. Sin recursos externos (la CSP no permite fuentes ni
 * imágenes de fuera): letra del sistema e iconos SVG propios. Claro u oscuro según el sistema, o el que se elija
 * con el botón (atributo data-theme en <html>, solo en memoria).
 */
:root {
  /* Paleta de la app (Design.kt): verde bosque, terracota y ocre. En la web, sobre blanco y grises neutros
     (no el crema de la app, que en pantalla grande parecía viejo). */
  --bg: #f1f3f2;
  --surface: #ffffff;
  --surface-2: #f7f8f7;
  --surface-3: #edf0ee;
  --text: #252f29;
  --muted: #56615a;
  --border: #e1e5e2;
  --accent: #284e3e;
  --accent-strong: #233f30;
  --accent-soft: #dce7d9;
  --on-accent: #ffffff;
  --grad-a: #3b6a55;
  --grad-b: #1f3d30;
  --primary: #284e3e;  --primary-soft: #dce7d9;
  --sage: #2f6a3c;     --sage-soft: #e1ecd9;
  --clay: #854c3a;     --clay-soft: #f2d9cc;
  --ochre: #7a5517;    --ochre-soft: #f2dfbb;
  --error: #9b2c22;    --error-soft: #f9dedb;
  --amber: #f2dfbb;    --on-amber: #4b3718;
  --toast-action: #f2dfbb;
  --cta-a: #9a5843;    --cta-b: #7a3d2c;    --on-cta-button: #7a3d2c;
  --glow: rgba(31, 61, 48, .55);
  --shadow: 0 1px 2px rgba(37, 47, 41, .04), 0 12px 32px -12px rgba(37, 47, 41, .16);
  --shadow-strong: 0 24px 48px -20px rgba(37, 47, 41, .3);
  --radius: 22px;
  --radius-sm: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d120f; --surface: #1d2520; --surface-2: #151b17; --surface-3: #263029;
    --text: #edece2; --muted: #bdc9bf; --border: #313d34;
    --accent: #b6d7c5; --accent-strong: #dfede3; --accent-soft: #294b3c; --on-accent: #183d30;
    --grad-a: #3a6853; --grad-b: #1d3a2d;
    --primary: #b6d7c5; --primary-soft: #294b3c; --sage: #a8d5b1; --sage-soft: #23382a;
    --clay: #e5b3a2; --clay-soft: #593c31; --ochre: #f0cf95; --ochre-soft: #51412a;
    --error: #ffb4a9; --error-soft: #5c1a14;
    --amber: #e8c98f; --on-amber: #2a1f00; --toast-action: #284e3e;
    --cta-a: #8f523e; --cta-b: #6b3426; --on-cta-button: #6b3426;
    --glow: rgba(0, 0, 0, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -14px rgba(0, 0, 0, .6);
    --shadow-strong: 0 24px 48px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0d120f; --surface: #1d2520; --surface-2: #151b17; --surface-3: #263029;
    --text: #edece2; --muted: #bdc9bf; --border: #313d34;
    --accent: #b6d7c5; --accent-strong: #dfede3; --accent-soft: #294b3c; --on-accent: #183d30;
    --grad-a: #3a6853; --grad-b: #1d3a2d;
    --primary: #b6d7c5; --primary-soft: #294b3c; --sage: #a8d5b1; --sage-soft: #23382a;
    --clay: #e5b3a2; --clay-soft: #593c31; --ochre: #f0cf95; --ochre-soft: #51412a;
    --error: #ffb4a9; --error-soft: #5c1a14;
    --amber: #e8c98f; --on-amber: #2a1f00; --toast-action: #284e3e;
    --cta-a: #8f523e; --cta-b: #6b3426; --on-cta-button: #6b3426;
    --glow: rgba(0, 0, 0, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -14px rgba(0, 0, 0, .6);
    --shadow-strong: 0 24px 48px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* Base */
* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 1rem/1.5 "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
.noscript { padding: 2rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Botones */
button {
  font: inherit; font-weight: 600; font-size: .95rem; min-height: 44px; padding: .55rem 1.15rem; border-radius: 999px;
  cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button > .label { white-space: nowrap; }
.item .label, .row-button .label { white-space: normal; }
button.primary {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b)); color: #fff;
  box-shadow: 0 10px 22px -10px var(--glow);
}
button.primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 14px 26px -10px var(--glow); }
button.tonal { background: var(--accent-soft); color: var(--accent-strong); }
button.ghost { background: var(--surface-2); border-color: var(--border); }
button.ghost:not(:disabled):hover, button.tonal:not(:disabled):hover { border-color: var(--accent); }
button.danger { background: var(--error-soft); color: var(--error); }
button.amber { background: var(--amber); color: var(--on-amber); width: 100%; }
button.wide { flex: 1 1 auto; }
.icon-button { width: 44px; padding: 0; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.icon-button:not(:disabled):hover { color: var(--accent); border-color: var(--accent); }
.narrow-only { display: none; }
.icon-button.round { width: 32px; min-height: 32px; height: 32px; background: var(--amber); color: var(--on-amber); border: 0; }
.icon-button.round .icon { width: 1rem; height: 1rem; stroke-width: 2.4; }
.link-button { min-height: 36px; padding: .2rem .5rem; color: var(--accent); flex-direction: row-reverse; gap: .2rem; font-size: .9rem; }
.link-button .icon { width: 1rem; height: 1rem; }

/* Campos */
label { display: block; font-weight: 600; font-size: .9rem; margin: 1rem 0 .35rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .3rem 0 0; }
input[type=text], input[type=search], input[type=password], input[type=url], input[type=date], select, textarea {
  font: inherit; width: 100%; min-height: 46px; padding: .6rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
textarea { min-height: 9rem; resize: vertical; }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }

/* Mensajes */
.message {
  display: flex; gap: .6rem; align-items: flex-start; border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 0 0 1.25rem;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 500;
}
.message p { margin: 0; }
.message.error { background: var(--error-soft); color: var(--error); }
.message .icon { margin-top: .1rem; }

/* Tarjetas, iconos de color y barras */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(1.1rem, 2.5vw, 1.6rem); box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 1.1rem; margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.tile { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; }
.tile.small { width: 34px; height: 34px; border-radius: 11px; }
.tile.small .icon { width: 1.05rem; height: 1.05rem; }
.tone-primary { background: var(--primary-soft); color: var(--primary); }
.tone-sage { background: var(--sage-soft); color: var(--sage); }
.tone-clay { background: var(--clay-soft); color: var(--clay); }
.tone-error { background: var(--error-soft); color: var(--error); }
.tone-ochre { background: var(--ochre-soft); color: var(--ochre); }
.text-primary { color: var(--primary); } .text-sage { color: var(--sage); } .text-error { color: var(--error); }
.bar { display: block; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; width: 0; transition: width .4s ease; }
.bar-fill.tone-primary { background: var(--primary); }
.bar-fill.tone-sage { background: var(--sage); }
.bar-fill.tone-clay { background: var(--clay); }
.bar-fill.tone-ochre { background: var(--ochre); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 999px; padding: .1rem .6rem; background: var(--surface-3); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.sage { background: var(--sage-soft); color: var(--sage); }
.badge.error { background: var(--error-soft); color: var(--error); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 1rem; margin: 0; }
.empty.small { padding: .5rem 0; text-align: left; }

/* Logo */
.logo { display: flex; align-items: center; gap: .7rem; }
.logo-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b)); box-shadow: 0 10px 20px -10px var(--glow);
}
.logo-mark .icon { width: 1.5rem; height: 1.5rem; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text strong { font-size: 1.15rem; }
.logo-text span { font-size: .8rem; color: var(--muted); }

/* ---------- Pantallas de bienvenida (abrir y vista previa) ---------- */
.welcome { min-height: 100vh; display: flex; flex-direction: column; }
.welcome-top { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem clamp(1rem, 4vw, 3rem); }
.welcome main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem) 3rem; }
.welcome-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(1.25rem, 3vw, 2.5rem); align-items: stretch; }
.welcome-hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: clamp(1.5rem, 4vw, 3rem); color: #fff;
  background: radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, .12), transparent 55%), linear-gradient(140deg, var(--grad-a), var(--grad-b));
  box-shadow: var(--shadow-strong); min-height: 520px; display: flex; flex-direction: column;
}
.welcome-hero::after { content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%; right: -140px; bottom: -160px; background: rgba(255, 255, 255, .1); }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.welcome-hero .eyebrow { background: rgba(255, 255, 255, .18); padding: .3rem .75rem; border-radius: 999px; align-self: flex-start; }
.welcome-hero h1 { font-size: clamp(2rem, 4.2vw, 3rem); margin: 1rem 0 .75rem; max-width: 14ch; }
.hero-lead { font-size: 1.08rem; max-width: 38ch; margin: 0 0 1.75rem; }
.features { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; position: relative; z-index: 1; }
.features li { display: flex; gap: .8rem; align-items: center; }
.features li > span:last-child { display: flex; flex-direction: column; font-size: .9rem; line-height: 1.35; }
.features strong { font-size: 1rem; }
.feature-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, .18); flex: none; }
.hero-art { position: relative; flex: 1; min-height: 140px; margin-top: 1.5rem; z-index: 1; }
.float-card {
  position: absolute; display: flex; gap: .75rem; align-items: center; padding: .8rem 1rem; border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: 0 18px 36px -18px rgba(0, 0, 0, .45); min-width: 220px;
}
.float-card > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.float-card > span:last-child span { font-size: .8rem; color: var(--muted); }
.float-card.one { right: 8%; bottom: 46%; transform: rotate(-3deg); }
.float-card.two { right: 22%; bottom: 6%; transform: rotate(2deg); }
.open-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(1.4rem, 3vw, 2.4rem); }
.open-card h2 { font-size: 1.6rem; margin: 0 0 .5rem; }
.open-card > .muted { margin: 0 0 1.25rem; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .25rem; margin: 0; padding: 1.6rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 18px; background: var(--surface-2); transition: border-color .15s ease, background-color .15s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.file-input:focus-visible + .dropzone { outline: 3px solid var(--accent); outline-offset: 2px; }
.drop-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: .35rem; }
.drop-title { font-weight: 700; overflow-wrap: anywhere; }
.drop-hint { font-weight: 400; font-size: .85rem; color: var(--muted); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 1.6rem 0 1.2rem; }
input[type=email] { font: inherit; width: 100%; min-height: 46px; padding: .6rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.privacy { display: flex; gap: .55rem; align-items: flex-start; color: var(--muted); font-size: .88rem; margin: 1.25rem 0 0; }
.privacy .icon { width: 1.05rem; height: 1.05rem; margin-top: .15rem; }

.preview-card { max-width: 760px; margin: 1rem auto 0; padding: clamp(1.4rem, 3vw, 2.4rem); }
.preview-card .eyebrow { color: var(--accent); }
.preview-card h1 { font-size: 1.8rem; margin: .4rem 0 .25rem; }
.preview-card h2 { margin-top: 1.75rem; font-size: 1.05rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; list-style: none; padding: 0; margin: 1.5rem 0 0; }
.stat-tiles li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .8rem; align-items: center; padding: .9rem; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); }
.stat-tiles .tile { grid-row: span 2; }
.stat-tiles strong { font-size: 1.5rem; line-height: 1.1; }
.stat-tiles li > span:last-child { color: var(--muted); font-size: .88rem; }
.sample { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; }
.sample li { display: flex; gap: .75rem; align-items: center; overflow-wrap: anywhere; }

/* ---------- Colección: marco con barra lateral ---------- */
.shell {
  display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: calc(100vh - 32px); margin: 16px;
  background: var(--surface); border-radius: 30px; box-shadow: var(--shadow-strong); overflow: clip;
}
.sidebar {
  display: flex; flex-direction: column; gap: 1.25rem; padding: 1.5rem 1rem 1rem; border-right: 1px solid var(--border);
  position: sticky; top: 16px; height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin;
}
.sidebar .logo { padding: 0 .6rem; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.nav-item { width: 100%; justify-content: flex-start; gap: .8rem; border-radius: 14px; padding: .6rem .8rem; color: var(--muted); font-weight: 500; }
.nav-item .label { flex: 1; text-align: left; }
.nav-item:not(:disabled):hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.nav-count { font-size: .75rem; font-weight: 700; min-width: 1.6rem; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); text-align: center; }
.nav-item[aria-current="page"] .nav-count { background: var(--surface); color: var(--accent-strong); }
.side-card { margin-top: auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .75rem; padding: 1.25rem 1rem 1rem; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); }
.side-card p { margin: 0; font-size: .85rem; color: var(--muted); }
.side-art { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.side-art .icon { width: 1.9rem; height: 1.9rem; stroke-width: 1.5; }
/* Acciones de la tarjeta: la principal a todo el ancho y las demás como filas discretas, todas dentro de la tarjeta. */
.side-card .side-art { align-self: center; width: 52px; height: 52px; }
.side-card .side-art .icon { width: 1.6rem; height: 1.6rem; }
.side-card { align-items: stretch; gap: .65rem; padding: 1rem .7rem .7rem; }
.side-card button { width: 100%; min-width: 0; }
.side-card button.amber { padding: .55rem .8rem; font-size: .92rem; }
.side-card button > .label { white-space: normal; }
.side-actions { display: flex; flex-direction: column; gap: .15rem; margin-top: -.25rem; }
button.side-action { justify-content: flex-start; gap: .55rem; min-height: 44px; padding: .45rem .55rem; border-radius: 12px; font-size: .85rem; color: var(--muted); text-align: left; }
button.side-action .icon { width: 1.05rem; height: 1.05rem; flex: none; }
button.side-action:not(:disabled):hover { background: var(--surface); color: var(--accent-strong); }

.page { min-width: 0; background: var(--surface-2); display: flex; flex-direction: column; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem;
  padding: 1.6rem clamp(1rem, 3vw, 2.25rem) 1rem; position: sticky; top: 0; z-index: 3;
  background: color-mix(in srgb, var(--surface-2) 86%, transparent); backdrop-filter: blur(12px);
}
.page-title h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.1rem); }
.page-title p { margin: .25rem 0 0; color: var(--muted); font-size: .92rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.file-chip { display: flex; align-items: center; gap: .6rem; padding: .3rem .9rem .3rem .3rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); max-width: 260px; }
.file-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--amber), var(--ochre-soft)); color: var(--on-amber); flex: none; }
.file-avatar .icon { width: 1.05rem; height: 1.05rem; }
.file-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.file-name { font-weight: 700; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-state { font-size: .75rem; color: var(--muted); }
.file-chip.unsaved .file-state { color: var(--error); font-weight: 600; }
.page main { flex: 1; padding: .5rem clamp(1rem, 3vw, 2.25rem) 1rem; }
.footer { color: var(--muted); text-align: center; font-size: .82rem; padding: 1rem 1rem 1.5rem; }
.footer p { margin: .2rem 0; }
.footer .shortcuts { font-size: .78rem; opacity: .85; }
@media (hover: none) { .footer .shortcuts { display: none; } }

/* Resumen */
.overview { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.column { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.summary-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.copy-card {
  position: relative; overflow: hidden; border-radius: 20px; padding: 1.25rem 1.35rem; color: #fff; min-height: 196px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 1rem;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b)); box-shadow: 0 20px 40px -18px var(--glow);
}
.copy-card::before { content: ""; position: absolute; width: 230px; height: 230px; border-radius: 50%; right: -70px; bottom: -110px; background: rgba(255, 255, 255, .13); }
.copy-card::after { content: ""; position: absolute; width: 150px; height: 150px; border-radius: 50%; right: 40px; top: -80px; background: rgba(255, 255, 255, .08); }
.copy-card > * { position: relative; z-index: 1; }
.copy-top { display: flex; align-items: center; gap: .45rem; }
.copy-brand { font-weight: 800; font-size: 1.05rem; letter-spacing: .01em; }
.copy-kind { white-space: nowrap; margin-left: auto; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: rgba(255, 255, 255, .2); padding: .2rem .6rem; border-radius: 999px; }
.copy-count { margin: 0; font-size: 1rem; }
.copy-count strong { font-size: 2.4rem; letter-spacing: -.02em; }
.copy-bottom { display: flex; gap: 1.75rem; }
.copy-bottom > span { display: flex; flex-direction: column; min-width: 0; }
.copy-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.copy-value { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; text-align: right; }
.summary-stats li { display: flex; flex-direction: column; }
.summary-stats strong { font-size: 1.75rem; line-height: 1.1; }
.summary-stats span { color: var(--muted); font-size: .85rem; }
.progress { margin-top: 1.4rem; }
.progress-meta { display: flex; justify-content: space-between; margin-top: .55rem; font-size: .85rem; color: var(--muted); }
.progress-meta strong { color: var(--text); }

.recent { width: 100%; border-collapse: collapse; font-size: .9rem; }
.recent th { text-align: left; font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0 .5rem .6rem; border-bottom: 1px solid var(--border); }
.recent td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.recent tr:last-child td { border-bottom: 0; }
.recent td:nth-child(2), .recent td:nth-child(3) { white-space: nowrap; }
.recent td:last-child { overflow-wrap: anywhere; }
.row-button { min-height: 44px; padding: .25rem; margin-left: -.25rem; gap: .7rem; border-radius: 12px; font-weight: 600; text-align: left; justify-content: flex-start; }
.row-button:hover .row-title { color: var(--accent); }
.row-title { overflow-wrap: anywhere; }

.pinned { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.pin-card {
  width: 100%; height: 100%; flex-direction: column; align-items: flex-start; gap: .6rem; padding: 1rem; border-radius: 18px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border);
}
.pin-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.pin-date { font-size: .78rem; font-weight: 600; color: var(--muted); }
.pin-title { font-weight: 600; overflow-wrap: anywhere; }

.tag-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.tag-row { width: 100%; gap: .9rem; padding: .4rem; border-radius: 14px; justify-content: flex-start; font-weight: 500; }
.tag-row:hover { background: var(--surface-2); }
.tag-body { flex: 1; display: flex; flex-direction: column-reverse; gap: .35rem; min-width: 0; text-align: left; }
.tag-name { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-percent { font-weight: 700; font-size: 1.05rem; min-width: 3.5rem; text-align: right; }

.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.5rem; }
.upcoming { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.up-row { width: 100%; justify-content: flex-start; gap: .75rem; padding: .35rem; border-radius: 12px; text-align: left; font-weight: 600; }
.up-row:hover { background: var(--surface-2); }
.up-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.up-body .muted { font-size: .78rem; font-weight: 500; }
.cta {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 1.4rem; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; gap: .5rem;
  background: linear-gradient(150deg, var(--cta-a), var(--cta-b)); box-shadow: 0 20px 40px -20px rgba(122, 61, 44, .55); min-height: 210px;
}
.cta::before { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -50px; top: -60px; background: rgba(255, 255, 255, .14); }
.cta > * { position: relative; }
.cta h2 { font-size: 1.2rem; margin: 0; }
.cta p { margin: 0; font-size: .88rem; }
.cta-button { align-self: flex-start; background: rgba(255, 255, 255, .95); color: var(--on-cta-button); flex-direction: row-reverse; margin-top: .4rem; }
.cta-button:not(:disabled):hover { background: #fff; transform: translateX(2px); }
.cta-button { max-width: 100%; }
.cta-button .label { white-space: normal; text-align: left; }

/* Lista y detalle */
.filters { padding: 1rem 1.1rem; margin-bottom: 1.5rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.search { position: relative; flex: 1 1 260px; }
.search .icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.7rem; }
.control { flex: 0 1 200px; min-width: 150px; }
.control label { margin-top: 0; font-size: .78rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.chip { min-height: 36px; padding: .3rem .85rem; font-size: .85rem; font-weight: 500; background: var(--surface-2); border-color: var(--border); }
.chip:not(.static):hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
:root[data-theme="dark"] .chip[aria-pressed="true"] { color: var(--on-accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[aria-pressed="true"] { color: var(--on-accent); } }
.chip.static { display: inline-flex; align-items: center; min-height: 30px; border: 1px solid var(--border); border-radius: 999px; }

.library-content { display: flex; flex-direction: column-reverse; gap: 1.5rem; }
@media (min-width: 1101px) {
  .library-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
  .library-content .detail { position: sticky; top: 7.5rem; }
}
.list-card { padding: .9rem; }
.count { color: var(--muted); font-size: .85rem; font-weight: 600; margin: .1rem .4rem .7rem; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.item { width: 100%; justify-content: flex-start; text-align: left; gap: .9rem; border-radius: 16px; padding: .7rem .8rem; font-weight: 400; border: 1px solid transparent; }
.item:hover { background: var(--surface-2); }
.item[aria-current="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.item .chevron { color: var(--muted); width: 1.1rem; height: 1.1rem; }

.detail h2 { font-size: 1.35rem; margin: 0; overflow-wrap: anywhere; }
.detail-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .5rem; }
.detail-head > div { min-width: 0; }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 0; }
.detail .text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: var(--radius-sm); padding: 1rem 1.1rem; margin: 1rem 0; }
.detail img { max-width: 100%; height: auto; border-radius: 18px; display: block; margin: 1rem 0; box-shadow: var(--shadow); }
.detail .link { display: inline-flex; gap: .45rem; align-items: center; overflow-wrap: anywhere; font-weight: 600; }
.detail .link .icon { width: 1.05rem; height: 1.05rem; }
.tag-line { display: flex; flex-wrap: wrap; gap: .4rem; }
.facts { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; color: var(--muted); font-size: .88rem; }
.facts li { display: flex; gap: .4rem; align-items: center; }
.facts .icon { width: 1rem; height: 1rem; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; padding: 2rem 1rem; color: var(--muted); }
.empty-state p { margin: 0 0 .5rem; }
.empty-art { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--surface-2); color: var(--accent); }
.empty-art .icon { width: 2rem; height: 2rem; stroke-width: 1.5; }
.duplicates { margin: .4rem 0 0; }

/* ---------- Buscador de la barra superior, Reintentar y Salir ---------- */
.topbar .page-title { order: 0; }
.top-search { order: 1; flex: 1 1 220px; max-width: 420px; }
.topbar .toolbar { order: 2; }
.top-search input { min-height: 44px; border-radius: 999px; background: var(--surface); }
button.retry { color: var(--error); border-color: var(--error-soft); }
button.retry[hidden] { display: none; }

/* ---------- Avisos flotantes ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: .6rem; width: max-content; max-width: min(560px, calc(100vw - 2rem));
  padding: .5rem .5rem .5rem 1rem; border-radius: 16px; background: var(--text); color: var(--surface);
  box-shadow: var(--shadow-strong); font-weight: 500; animation: toast-in .18s ease-out;
}
.toast .icon { flex: none; width: 1.1rem; height: 1.1rem; }
.toast-text { flex: 1; min-width: 0; padding: .3rem 0; }
.toast.error { background: var(--error-soft); color: var(--error); border: 1px solid var(--error); }
button.toast-action { min-height: 40px; padding: .3rem .9rem; color: var(--toast-action); font-weight: 700; }
.toast.error button.toast-action { color: inherit; text-decoration: underline; }
.toast .toast-close { width: 40px; min-height: 40px; height: 40px; background: transparent; border: 0; color: inherit; opacity: .8; }
.toast .toast-close:hover { opacity: 1; color: inherit; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, .5rem); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Diálogo propio ---------- */
.dialog { border: 0; border-radius: var(--radius); padding: 1.5rem; max-width: min(440px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-strong); }
.dialog::backdrop { background: rgba(15, 22, 18, .45); }
.dialog h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.dialog p { margin: 0; color: var(--muted); }
.dialog .actions { justify-content: flex-end; margin-top: 1.25rem; }

/* ---------- Aviso de la frase ---------- */
.warning { display: flex; gap: .75rem; align-items: flex-start; margin: .25rem 0 .5rem; padding: .9rem 1rem; border-radius: var(--radius-sm); background: var(--ochre-soft); color: var(--on-amber); }
.warning .icon { flex: none; margin-top: .15rem; }
.warning strong { display: block; }
.warning p { margin: .25rem 0 0; font-size: .9rem; }
.open-card .check { margin-top: 1rem; font-weight: 600; }

/* ---------- Primeros pasos (colección vacía) ---------- */
.first-steps { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem; padding: clamp(2rem, 6vw, 3.5rem) 1.5rem; }
.first-steps h2 { margin: .5rem 0 0; font-size: 1.5rem; }
.first-steps p { margin: 0; max-width: 46ch; }
.first-steps .actions { justify-content: center; margin-top: .75rem; }
.first-steps .small { font-size: .88rem; margin-top: .75rem; }

/* ---------- Volver a la lista (solo en una columna) ---------- */
.back-button { display: none; }

/* ---------- Pantallas medianas y móviles ---------- */
@media (max-width: 1280px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); margin: 0; border-radius: 0; min-height: 100vh; box-shadow: none; }
  .sidebar { position: sticky; top: 0; z-index: 4; height: auto; flex-direction: row; align-items: center; gap: 1rem; padding: .6rem 1rem; border-right: 0; border-bottom: 1px solid var(--border); background: var(--surface); overflow: visible; }
  .sidebar .logo { padding: 0; }
  .sidebar .logo-text { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav-item { width: auto; white-space: nowrap; padding: .5rem .75rem; }
  .side-card { display: none; }
  .narrow-only { display: inline-flex; }
  .topbar { position: static; padding-top: 1.1rem; }
  .welcome-grid { grid-template-columns: minmax(0, 1fr); }
  /* En una columna, primero el formulario de entrar: es lo único que se puede hacer aquí. */
  .open-card { order: -1; }
  .welcome-hero { min-height: 0; }
  .hero-art { display: none; }
}
@media (max-width: 400px) { button > .label { white-space: normal; } }
@media (max-width: 640px) {
  .summary-row, .split { grid-template-columns: minmax(0, 1fr); }
  .summary-stats { flex-direction: row; justify-content: space-between; text-align: left; }
  .recent th:nth-child(2), .recent td:nth-child(2), .recent th:nth-child(4), .recent td:nth-child(4) { display: none; }
  /* El indicador de guardado sigue a la vista, compacto: sin el correo, a lo ancho de la barra. */
  .file-chip { order: -1; flex: 1 1 100%; max-width: none; padding: .2rem .8rem .2rem .2rem; }
  .file-chip .file-name { display: none; }
  .file-chip .file-avatar { width: 28px; height: 28px; }
  /* Solo se ve el nombre de la sección actual; los demás siguen ahí para el lector de pantalla. */
  .nav-item:not([aria-current="page"]) .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-item:not([aria-current="page"]) .nav-count { display: none; }
  .control { flex: 1 1 140px; }
  .toolbar { width: 100%; }
  .welcome-top .toolbar { width: auto; }
  .toolbar .primary { flex: 1; }
}

/* En una columna, lo abierto en el panel de detalle ocupa toda la pantalla, con «Volver a la lista». */
@media (max-width: 1100px) {
  body.detail-open { overflow: hidden; }
  .library-content .detail:not(.open) { display: none; }
  /* Abajo, sitio para el aviso flotante sin que tape los botones. */
  .library-content .detail.open { position: fixed; inset: 0; z-index: 30; border-radius: 0; border: 0; overflow-y: auto; padding: 1rem clamp(1rem, 4vw, 2rem) 6rem; }
  .back-button { display: inline-flex; margin: 0 0 .75rem -.5rem; padding-left: .5rem; color: var(--accent); }
}
@media (max-width: 640px) {
  .top-search { flex-basis: 100%; max-width: none; order: 1; }
  .topbar .toolbar { order: 2; }
  .toast { bottom: .75rem; }
}
