@font-face {
  font-family: "Atkinson Next";
  src: url("/assets/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Next";
  src: url("/assets/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #ffffff;
  --page: #f6f8fb;
  --ink: #1c2a4a;
  --muted: #55607a;
  --grid: #dde7f3;
  --rule: #c7d5e8;
  --margin: #c9313d;
  --marker: #fff27a;
  --marker-ink: #1c2a4a;
  --field: #ffffff;
  --focus: #2f6fd6;
  --font: "Atkinson Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --measure: 40rem;
  --cell: 24px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #151c2b;
    --page: #0f1420;
    --ink: #e4eaf5;
    --muted: #a3aec6;
    --grid: #1f2b42;
    --rule: #2c3b57;
    --margin: #ec6b74;
    --marker: #6b5f12;
    --marker-ink: #fff8c9;
    --field: #0f1420;
    --focus: #7fb0ff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151c2b;
  --page: #0f1420;
  --ink: #e4eaf5;
  --muted: #a3aec6;
  --grid: #1f2b42;
  --rule: #2c3b57;
  --margin: #ec6b74;
  --marker: #6b5f12;
  --marker-ink: #fff8c9;
  --field: #0f1420;
  --focus: #7fb0ff;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
}
.ledger, .money input { font-variant-numeric: tabular-nums; }

img, svg { max-width: 100%; height: auto; }

a { color: inherit; text-decoration-color: var(--margin); text-underline-offset: 0.18em; text-decoration-thickness: 2px; }
a:hover { text-decoration-thickness: 3px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 0.5rem 1rem; z-index: 20; }
.skip:focus { left: 1rem; top: calc(env(safe-area-inset-top, 0px) + 0.5rem); }

/* Cabecera */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.wordmark svg { width: 28px; height: 28px; flex: none; }
.site-nav { display: flex; gap: 1.25rem; font-size: 0.95rem; }
.site-nav a { text-decoration: none; color: var(--muted); }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--margin); }

.wrap { max-width: 64rem; margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem; }

/* Tipografía de contenido */
main { padding-bottom: 4rem; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); font-weight: 700; max-width: 20ch; }
h2 { font-size: clamp(1.35rem, 3vw, 1.7rem); margin-top: 2.75rem; }
h3 { font-size: 1.15rem; margin-top: 1.75rem; }
p, ul, ol { margin: 0.9rem 0 0; }
.prose { max-width: var(--measure); }
.prose li + li { margin-top: 0.35rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 36rem; margin-top: 1rem; }
.updated { font-size: 0.9rem; color: var(--muted); margin-top: 0.75rem; }

.page-head { padding: 2.5rem 0 1.5rem; }

/* La hoja de cuadrícula: el elemento con personalidad */
.sheet {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 1.25rem 1.75rem 2.75rem;
}
.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1.6rem;
  width: 2px;
  background: var(--margin);
  opacity: 0.85;
}

/* Calculadora */
.calc { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .calc { grid-template-columns: minmax(0, 23rem) minmax(0, 1fr); align-items: start; }
}

.form-panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 1.25rem;
}
.field { margin-top: 1.35rem; border: 0; padding: 0; min-width: 0; }
.field:first-child { margin-top: 0; }
.field > label, .field > legend { display: block; font-weight: 700; margin-bottom: 0.4rem; padding: 0; }
.hint { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 0.3rem; line-height: 1.45; }

input[type="number"], input[type="text"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  min-height: 2.9rem;
}
input[type="number"]:focus, select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }

.money { position: relative; }
.money input { padding-right: 2rem; font-size: 1.2rem; font-weight: 700; }
.money::after { content: "€"; position: absolute; right: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--field);
  min-height: 2.75rem;
  line-height: 1.6;
}
.choice input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--paper); font-weight: 700; }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.stack { display: grid; gap: 0.5rem; }
.option { display: flex; gap: 0.6rem; align-items: flex-start; line-height: 1.4; cursor: pointer; }
.option input { margin-top: 0.2rem; width: 1.15rem; height: 1.15rem; flex: none; accent-color: var(--ink); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.two label { font-weight: 400; font-size: 0.95rem; display: block; margin-bottom: 0.3rem; }

.error { color: var(--margin); font-weight: 700; font-size: 0.95rem; margin-top: 0.5rem; }

/* Resultado: la cuenta hecha a mano */
.result-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.25rem; line-height: var(--cell); }
.result-sub { color: var(--muted); font-size: 0.95rem; margin: 0 0 var(--cell); line-height: var(--cell); }

.ledger { width: 100%; border-collapse: collapse; font-size: 1.05rem; }
.ledger th, .ledger td { padding: 0; height: calc(var(--cell) * 1.5); text-align: right; white-space: nowrap; }
.ledger th[scope="row"] { text-align: left; font-weight: 400; white-space: normal; padding-right: 0.75rem; }
.ledger thead th { font-size: 0.9rem; color: var(--muted); font-weight: 700; vertical-align: bottom; }
.ledger td + td, .ledger th + th { padding-left: 1rem; }
.ledger .minus td { color: var(--muted); }
.ledger .total th, .ledger .total td { border-top: 2px solid var(--ink); font-weight: 700; }
.ledger .per td, .ledger .per th { font-weight: 700; font-size: 1.15rem; }
.mark {
  background: linear-gradient(transparent 12%, var(--marker) 12%, var(--marker) 88%, transparent 88%);
  color: var(--marker-ink);
  padding: 0 0.2em;
  margin-right: -0.2em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.verdict {
  margin-top: calc(var(--cell) * 1.25);
  font-size: 1.15rem;
  line-height: 1.55;
  max-width: 34rem;
}
.verdict strong { font-weight: 700; }
.fineprint { font-size: 0.9rem; color: var(--muted); margin-top: 1rem; max-width: 34rem; }

.empty { color: var(--muted); font-size: 1.05rem; max-width: 26rem; line-height: 1.6; }

/* Bloques de texto auxiliares */
.note {
  border-left: 3px solid var(--margin);
  padding: 0.25rem 0 0.25rem 1rem;
  margin-top: 1.5rem;
  max-width: var(--measure);
}
.faq dt { font-weight: 700; margin-top: 1.5rem; }
.faq dd { margin: 0.4rem 0 0; }

.tool-link {
  display: block;
  text-decoration: none;
  margin-top: 2rem;
  max-width: 34rem;
}
.tool-link h2 { margin: 0; font-size: 1.35rem; }
.tool-link p { color: var(--muted); }
.tool-link .go { display: inline-block; margin-top: 0.9rem; font-weight: 700; text-decoration: underline; text-decoration-color: var(--margin); text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.tool-link:hover .go { text-decoration-thickness: 3px; }

table.data { border-collapse: collapse; margin-top: 1rem; width: 100%; max-width: var(--measure); font-size: 0.98rem; }
table.data th, table.data td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--rule); text-align: left; }
table.data td.num, table.data th.num { text-align: right; }
table.data td { font-variant-numeric: tabular-nums; }
.ledger thead th:first-child { text-align: left; }
.scroll { overflow-x: auto; }

/* Pie */
.site-footer { border-top: 1px solid var(--rule); background: var(--paper); font-size: 0.92rem; color: var(--muted); }
.site-footer .wrap { padding-top: 1.75rem; padding-bottom: 2rem; display: grid; gap: 0.9rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.site-footer a { color: var(--muted); }

.see-result {
  display: none;
  width: 100%;
  margin-top: 1.75rem;
  font: inherit;
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 4px;
  min-height: 3rem;
  cursor: pointer;
}
@media (max-width: 899px) { .see-result { display: block; } }

@media (max-width: 600px) {
  .site-header .wrap { flex-wrap: wrap; gap: 0.35rem 1rem; }
  .site-nav { width: 100%; font-size: 0.9rem; }
}

@media (max-width: 560px) {
  table.data { font-size: 0.86rem; }
  table.data th, table.data td { padding-right: 0.45rem; }
  .sheet { padding-left: 2.25rem; padding-right: 0.9rem; }
  .sheet::before { left: 1.2rem; }
  .ledger { font-size: 0.95rem; }
  .ledger td + td, .ledger th + th { padding-left: 0.6rem; }
  .ledger .per td, .ledger .per th { font-size: 1.05rem; }
  .site-nav { gap: 0.9rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .result-live { animation: settle 0.35s ease-out; }
  @keyframes settle { from { opacity: 0.4; } to { opacity: 1; } }
}

@media print {
  .site-header, .site-footer, .form-panel { display: none; }
  .sheet { border: 0; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
