/* Tema "Wayfinders' Abacus": tokens claros estilo shadcn y tipografía Geist + Cormorant Garamond.
   Va después de app.css, abaco.css y shell.css y reemplaza sus colores y tamaños.
   Accesibilidad: texto de 14 px como mínimo, texto secundario con contraste de 10:1, bordes de controles con 4.7:1,
   controles de 44 px de alto y foco visible. */

@font-face { font-family: "Geist"; font-weight: 100 900; font-display: swap; src: url("/static/fonts/geist-latin.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 300; font-display: swap; src: url("/static/fonts/cormorant-garamond-latin.woff2") format("woff2"); }

:root {
  --bg: #F5F5F5;            /* fondo de fichas dentro de las tarjetas (muted) */
  --surface: #FFFFFF;
  --line: #E5E5E5;
  --line-strong: #737373;   /* bordes de controles: 4.7:1 sobre blanco */
  --ink: #0A0A0A;
  --ink-2: #3F3F46;         /* texto secundario: 10:1 */
  --ink-3: #3F3F46;
  --accent: #171717;
  --accent-deep: #0A0A0A;
  --accent-soft: #E5E5E5;
  --mint: #F5F5F5; --peach: #F5F5F5; --lavender: #F5F5F5; --sky: #F5F5F5; --rose: #F5F5F5;
  --good: #166534; --warn: #92400E; --bad: #B91C1C;
  --good-soft: #DCFCE7; --warn-soft: #FEF3C7; --bad-soft: #FEE2E2;
  --radius: 10px;
  --radius-sm: 8px;
  --gap: 24px;
  --topbar-h: 72px;
  --serif: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
  font-family: "Geist", "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
}
html, body { background: #FFFFFF; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.skip-link { position: absolute; left: 16px; top: -64px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- Barra superior ---------- */
.app { display: block; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 28px; min-height: var(--topbar-h); padding: 8px 40px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; padding: 4px; border-radius: var(--radius-sm); }
.brand-mark { width: 40px; height: 40px; object-fit: contain; flex: none; }
.brand-name { font-weight: 600; font-size: 17px; }
.topnav { display: flex; align-items: center; gap: 6px; flex: 1; flex-wrap: wrap; }
.nav-link { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500; }
.nav-link:hover { background: var(--bg); }
.nav-link[aria-current="page"] { background: var(--bg); font-weight: 600; }
.nav-link.primary { font-size: 18px; font-weight: 600; padding: 8px 20px; }
.top-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 14px; font-size: 14px; font-weight: 500; color: var(--ink); background: #fff; }
.status-pill.offline { color: var(--bad); border-color: var(--bad); }

.main { position: relative; padding: 40px 48px 72px; max-width: 1560px; margin: 0 auto; min-width: 0; }
.tab { max-width: none; }

/* Pestañas de la sección dentro de la página */
.subtabs { display: inline-flex; flex-wrap: wrap; margin-bottom: var(--gap); }
.subtabs[hidden] { display: none; }
.subtabs button { border: 0; background: transparent; padding: 8px 16px; min-height: 40px; border-radius: 8px; font-weight: 500; font-size: 15px; color: var(--ink-2); cursor: pointer; }
.subtabs button:hover { color: var(--ink); }
.subtabs button[aria-selected="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }

/* ---------- Tipografía ---------- */
.page-head h1 { font-family: var(--serif); font-weight: 300; font-size: clamp(44px, 5vw, 56px); line-height: 1.05; letter-spacing: -0.01em; }
.page-head p { color: var(--ink-2); font-weight: 400; font-size: 17px; margin-top: 8px; }
.section-title { font-family: var(--serif); font-weight: 300; font-size: 34px; line-height: 1.1; margin-top: 16px; }
.card-title { font-size: 20px; font-weight: 600; }
.card-sub, .note, .muted { font-size: 15px; font-weight: 400; color: var(--ink-2); }
.tile-label, .sensor-label, .robot-id, .robot-meta, .chip, .legend, .formula-meta, .method, .method summary, .small-input, .field, .check { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.step-label, .formula-name { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.badge { font-size: 13px; }
.band-range, .triple span::before { font-size: 12px; }
.tile-foot { font-size: 14px; color: var(--ink-2); }
.hero { font-weight: 500; }

/* ---------- Botones y controles ---------- */
.btn { min-height: 44px; padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 15px; background: var(--bg); color: var(--ink); border: 1px solid transparent; }
.btn:hover { background: var(--line); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #262626; }
.btn.big { min-height: 52px; padding: 12px 32px; font-size: 17px; }
.btn.quiet { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn.quiet:hover { background: var(--bg); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { background: #991B1B; }
.btn.nudge { min-height: 44px; padding: 8px 12px; }
.btn.danger.small { min-height: 40px; }
.segmented { background: var(--bg); border: 0; border-radius: 10px; padding: 4px; }
.segmented button { min-height: 40px; padding: 8px 16px; border-radius: 8px; font-weight: 500; font-size: 15px; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
select, .tape-field input, .sim-input input, .small-input input, .sequence-input, .review-table input, .add-fields .tape-field input, .id-field { min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; font-size: 16px; font-weight: 500; color: var(--ink); }
.tape-field input, .sim-input input { font-size: 22px; }
select { padding: 8px 12px; }
.tape-field input:focus, .sim-input input:focus, .small-input input:focus, .sequence-input:focus, .review-table input:focus, .id-field:focus-within { border-color: var(--ink); outline: 3px solid var(--ink); outline-offset: 2px; }
.tape-field input[aria-invalid="true"], .sim-input input[aria-invalid="true"], .small-input input[aria-invalid="true"], .sequence-input[aria-invalid="true"], .review-table input[aria-invalid="true"] { border-color: var(--bad); }
.add-fields .id-field input { border: 0; min-height: 40px; }

/* ---------- Tarjetas, fichas y avisos ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.robot-top { flex-wrap: wrap; row-gap: 4px; }
.robot-id { white-space: nowrap; }
.robot-state { font-size: 14px; }
small { font-size: max(0.85em, 14px); }
.robot[data-robot], .robot { background: #fff; }
.page-card { border: 1px solid var(--line); }
.page-card.over { border-color: var(--ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.tape-card { border: 1px solid var(--ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.tile, .sensor, .formula, .placeholder { background: var(--bg); }
.formula.alt { background: transparent; }
.robot { border-width: 1px; border-color: var(--line); }
.robot[aria-pressed="true"] { border: 2px solid var(--ink); }
.robot.add { border-width: 2px; }
.chip.accent, .badge.estimate { background: var(--accent-soft); color: var(--ink); }
.chip.good, .badge.effect { background: var(--good-soft); color: var(--good); }
.chip.warn, .badge.insufficient { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--bg); }
.demo-banner, .mode-banner { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; font-size: 15px; font-weight: 400; top: calc(var(--topbar-h) + 16px); max-width: none; }
.demo-banner strong, .mode-banner strong { font-weight: 600; font-size: 15px; }
.mode-banner.sim, .mode-banner.real { background: #fff; color: var(--ink); border-color: var(--line); }
.mode-banner.offline { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.progress { background: var(--accent-soft); }
.toast { background: var(--ink); border-radius: var(--radius-sm); font-size: 15px; }

/* ---------- Tablas ---------- */
table { font-size: 15px; }
th, td { padding: 12px 14px; }
th { font-size: 14px; font-weight: 600; color: var(--ink); background: var(--bg); }
td { font-weight: 400; }
table.compact th, table.compact td { padding: 10px 12px; font-size: 14px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); }
.steps-table tr.current td { background: var(--accent-soft); }

/* ---------- Ábaco ---------- */
.abaco > .col:first-child { top: calc(var(--topbar-h) + 24px); }
.mat-wrap { background: #E5E5E5; }
.map-zoom, .map-btn { color: var(--ink); }
.mode-switch .segmented button { font-size: 14px; }

/* ---------- Inicio ---------- */
.home { min-height: calc(100vh - var(--topbar-h) - 112px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px; text-align: center; }
.home-wordmark { font-size: 14px; letter-spacing: 0.22em; text-transform: uppercase; font-weight: 600; color: var(--ink-2); }
.home-title { font-family: var(--serif); font-weight: 300; font-size: clamp(72px, 10vw, 120px); line-height: 1; letter-spacing: -0.01em; margin: 6px 0 0; }
.home-stage { position: relative; display: flex; align-items: center; justify-content: center; gap: 96px; width: 100%; overflow-x: clip; padding: 24px 0; }
.home-options { list-style: none; margin: 0; padding: 0; text-align: left; flex: none; width: 640px; max-width: 100%; transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.5s ease; }
.home-stage[data-closed="true"] .home-options { opacity: 0; transform: translateX(-72px); pointer-events: none; }
/* La BOLT y "Comenzar" viajan juntas: cerrada queda centrada y al abrir se desliza a la derecha */
.home-bolt-wrap { position: relative; flex: none; width: 340px; transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1); will-change: transform; }
.home-stage[data-closed="true"] .home-bolt-wrap { transform: translateX(-368px) scale(1.2); }
.home-bolt { display: block; width: 100%; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.home-bolt img { display: block; width: 100%; height: auto; }
.home-start { position: absolute; left: calc(100% + 40px); top: 50%; translate: 0 -50%; border: 0; background: none; cursor: pointer; font: inherit; font-size: 26px; font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 8px; text-decoration-thickness: 2px; padding: 14px 4px; white-space: nowrap; transition: opacity 0.35s ease; }
.home-stage[data-closed="false"] .home-start { opacity: 0; pointer-events: none; }
.home-option { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 4px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); min-height: 64px; }
.home-option:hover strong { text-decoration: underline; text-underline-offset: 6px; }
.home-option strong { display: block; font-size: 26px; font-weight: 500; line-height: 1.15; }
.home-option span { display: block; font-size: 16px; color: var(--ink-2); margin-top: 2px; }
.home-option .arrow { font-size: 28px; flex: none; }
.home-option.primary { padding: 32px 4px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.home-option.primary strong { font-size: 56px; font-weight: 600; letter-spacing: -0.01em; }
.home-option.primary span { font-size: 18px; }
.home-option.primary .arrow { font-size: 44px; }

/* ---------- Menú plegable y vista móvil ---------- */
.menu-btn { display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; cursor: pointer; padding: 0; place-items: center; }
.menu-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.menu-btn .icon-close, .topbar.open .menu-btn .icon-open { display: none; }
.topbar.open .menu-btn .icon-close { display: block; }
.view-settings > summary { display: none; }

@media (max-width: 900px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; padding: 10px 16px; min-height: 0; }
  .menu-btn { display: grid; }
  .topnav { display: none; grid-column: 1 / -1; flex-direction: column; align-items: stretch; gap: 0; flex: none; }
  .top-status { display: none; grid-column: 1 / -1; justify-content: flex-start; padding: 8px 0 4px; }
  .topbar.open .topnav, .topbar.open .top-status { display: flex; }
  .nav-link { min-height: 52px; padding: 12px; font-size: 20px; justify-content: space-between; border-radius: 0; border-bottom: 1px solid var(--line); }
  .nav-link::after { content: "→"; }
  .nav-link.primary { font-size: 26px; padding: 16px 12px; }
  .nav-link[aria-current="page"] { background: var(--bg); border-radius: var(--radius-sm); }
  .main { padding: 16px 16px 56px; }
  .demo-banner, .mode-banner { position: static; flex-wrap: wrap; }
  .subtabs { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; margin-bottom: 16px; }
  .subtabs button { flex: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 36px; }
  .chart { height: 240px; }
  .chart.tall { height: 260px; }
  .card { padding: 16px; }
  .card table { display: block; overflow-x: auto; max-width: 100%; }
  .tab, .card, .col { min-width: 0; max-width: 100%; }
  .page-head p, .note, .card-sub { overflow-wrap: anywhere; }
  .table-wrap { overflow-x: auto; max-width: 100%; }

  /* Ábaco: la operación y el mapa van juntos arriba; ajustes y preparación después */
  .abaco { grid-template-columns: minmax(0, 1fr); }
  .abaco > .col { display: contents; position: static; }
  .op-card { order: 1; }
  .mat-card { order: 2; display: flex; flex-direction: column; }
  .prep-card { order: 3; }
  .events-card { order: 4; }
  .mat-card > * { order: 1; }
  .mat-card > :first-child { order: 0; }
  .mat-card > .mat-legend { order: 2; }
  .mat-card > .view-settings { order: 3; margin-top: 14px; }
  .view-settings > summary { display: flex; align-items: center; min-height: 44px; font-weight: 600; font-size: 16px; cursor: pointer; list-style: none; }
  .view-settings > summary::-webkit-details-marker { display: none; }
  .view-settings > summary::after { content: "▾"; margin-left: auto; font-size: 18px; }
  .view-settings[open] > summary::after { content: "▴"; }
  .op-card .stack > * { order: 3; }
  .op-card .stack > .calc { order: 1; }
  .op-card .stack > .actions { order: 2; }
  .calc .tape-field { flex: 1 1 110px; }
  .calc .tape-field input { width: 100%; }
  .op-card .actions .btn { flex: 1 1 auto; }

  .home-stage { flex-direction: column-reverse; gap: 24px; }
  .home-stage[data-closed="true"] .home-bolt-wrap { transform: none; }
  .home-stage[data-closed="true"] .home-options { display: none; }
  .home-bolt-wrap { width: min(300px, 70vw); }
  .home-start { position: static; display: block; translate: none; margin: 8px auto 0; }
  .home-option.primary strong { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-bolt-wrap, .home-options, .home-start { transition: none; }
}

/* Aviso de navegador sin Bluetooth */
.status-pill.warn { background: #FFF4D6; color: #5C3B00; border-color: #C98A00; }
.ble-warning { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(20, 22, 38, 0.55); }
.ble-warning-card { background: var(--surface, #fff); color: var(--ink); max-width: 460px; width: 100%; border-radius: var(--radius, 14px); padding: 24px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.ble-warning-card h2 { margin: 0; font-size: 20px; }
.ble-warning-card p { margin: 0; font-size: 16px; line-height: 1.5; }
.ble-warning-card .btn { justify-self: start; }
