:root {
  --ground: #F1F2EE; --surf: #FFFFFF; --ink: #1E231D; --ink2: #565D52; --line: #D5D8CF;
  --accent: #4B5D36; --deep: #344226; --tint: #E4EAD7; --warn: #8A5B00; --body: #2D342B;
  --ctrl: #B7BCAE; --seg: #E3E6DC; --on-accent: #FFFFFF; --hi: #E3AC00;
  --card: #1E231D; --card-fg: #FFFFFF; --card-btn: #F2BE1A; --card-btn-fg: #1E231D;
  --disp: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --read: 'Newsreader', Georgia, serif;
  --ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --maxw: 560px;
  color-scheme: light;
}
:root[data-tema="dark"] {
  --ground: #2B2E33; --surf: #363A40; --ink: #F1F2EC; --ink2: #B3B8AE; --line: #4A4F56;
  --accent: #F2BE1A; --deep: #E3EBD0; --tint: #455239; --warn: #F0A43C; --body: #D9DDD3;
  --ctrl: #6C727A; --seg: #3F434A; --on-accent: #1E231D; --hi: #F2BE1A;
  --card: #1D1F22; --card-fg: #F1F2EC; --card-btn: #F2BE1A; --card-btn-fg: #1E231D;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="light"]) {
    --ground: #2B2E33; --surf: #363A40; --ink: #F1F2EC; --ink2: #B3B8AE; --line: #4A4F56;
    --accent: #F2BE1A; --deep: #E3EBD0; --tint: #455239; --warn: #F0A43C; --body: #D9DDD3;
    --ctrl: #6C727A; --seg: #3F434A; --on-accent: #1E231D; --hi: #F2BE1A;
    --card: #1D1F22; --card-fg: #F1F2EC; --card-btn: #F2BE1A; --card-btn-fg: #1E231D;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
::selection { background: var(--accent); color: var(--on-accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 3px; }
:root[data-tema="dark"] a, :root:not([data-tema="light"]) a { }
a:hover { color: var(--deep); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
:root[data-tema="dark"] :focus-visible { outline-color: var(--card-btn); }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { min-height: 100dvh; max-width: var(--maxw); margin: 0 auto; display: flex; flex-direction: column; background: var(--ground); }
@media (min-width: 640px) { body { background: var(--seg); } #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
main { flex: 1; padding: 8px 20px 28px; display: flex; flex-direction: column; gap: 22px; outline: none; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 0; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; font-family: var(--disp); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; border-radius: 8px; }
.iconbtn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: 12px; color: var(--ink2); text-decoration: none; }
.iconbtn:hover { background: var(--seg); color: var(--ink); }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding-right: 12px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px; }

.h1 { font-family: var(--disp); font-weight: 700; font-size: 34px; line-height: 1.06; letter-spacing: -0.025em; text-wrap: balance; }
.h2 { font-family: var(--disp); font-weight: 700; font-size: 22px; line-height: 1.15; letter-spacing: -0.015em; }
.read { font-family: var(--read); font-size: 19px; line-height: 1.5; color: var(--body); }
.read.sm { font-size: 17px; }
.muted { color: var(--ink2); }
.small { font-size: 14px; line-height: 1.45; }
.xs { font-size: 12px; line-height: 1.4; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sec { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }

.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--tint); color: var(--deep); font-size: 12px; font-weight: 600; }
:root[data-tema="dark"] .chip { color: var(--deep); }
.chip.out { background: transparent; border: 1px solid var(--line); color: var(--ink2); font-weight: 500; }
.chip.warn { background: transparent; border: 1px solid var(--warn); color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px; text-decoration: none; }
.btn:hover { background: var(--deep); color: var(--on-accent); }
:root[data-tema="dark"] .btn:hover { background: #FFD75E; }
.btn[disabled] { background: var(--line); color: var(--ink2); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ctrl); }
.btn.ghost:hover { background: var(--seg); color: var(--ink); }
.btn.block { width: 100%; }
.btn.danger { background: transparent; color: var(--warn); border: 1.5px solid var(--warn); }
.textbtn { background: none; border: 0; padding: 0; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 15px; text-align: left; }
.textbtn:hover { color: var(--deep); }
.linkrow { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; font-size: 15px; text-decoration: none; }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); min-height: 64px; }
.item:last-child { border-bottom: 1px solid var(--line); }
.item:hover .item-title { text-decoration: underline; text-underline-offset: 4px; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item-title { font-family: var(--disp); font-weight: 700; font-size: 20px; line-height: 1.15; letter-spacing: -0.01em; }
.status { font-size: 13px; color: var(--ink2); display: inline-flex; align-items: center; gap: 6px; }
.status.done { color: var(--accent); font-weight: 600; }
:root[data-tema="dark"] .status.done { color: var(--card-btn); }

.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.box { background: var(--surf); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.box b { font-size: 13px; font-weight: 600; }
.box p { font-size: 14px; line-height: 1.45; color: var(--body); }
.scope { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 14px; background: var(--surf); overflow: hidden; }
.scope > div { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.scope > div + div { border-left: 1px solid var(--line); }
.scope h3 { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.scope > div + div h3 { color: var(--ink2); }
:root[data-tema="dark"] .scope h3 { color: var(--card-btn); }
.scope p { font-size: 14px; line-height: 1.45; }
.scope > div + div p { color: var(--ink2); }
.terms { padding: 16px; border-radius: 14px; background: var(--tint); display: flex; flex-direction: column; gap: 12px; }
.terms dt { font-size: 14px; font-weight: 600; }
.terms dd { margin: 0; font-size: 14px; line-height: 1.45; }
.qcard { background: var(--card); color: var(--card-fg); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.qcard .read { color: var(--card-fg); font-size: 21px; line-height: 1.3; }
.qcard .btn { background: var(--card-btn); color: var(--card-btn-fg); }
.qcard .btn:hover { background: #FFD75E; color: var(--card-btn-fg); }
.qcard p.small { opacity: 0.82; }

.answer { width: 100%; min-height: 56px; padding: 0 18px; border-radius: 14px; display: flex; align-items: center; gap: 12px; background: var(--surf); border: 1.5px solid var(--ctrl); font-size: 16px; font-weight: 500; text-align: left; }
.answer:hover { border-color: var(--ink2); }
.answer[aria-pressed="true"] { background: var(--tint); border: 2px solid var(--accent); font-weight: 600; }
:root[data-tema="dark"] .answer[aria-pressed="true"] { border-color: var(--card-btn); }
.answer .grow { flex: 1; }
.answer .score { font-size: 12px; font-weight: 600; opacity: 0.7; }
.answer.none { justify-content: center; border-style: dashed; min-height: 48px; background: transparent; }
.answer.none[aria-pressed="true"] { background: var(--tint); border-style: solid; }
.depbox { padding: 16px; border-radius: 14px; border: 1.5px dashed var(--ctrl); display: flex; flex-direction: column; gap: 10px; }
.depbox .answer { min-height: 46px; font-size: 15px; }
.progress { display: flex; gap: 6px; }
.progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.progress i.on { background: var(--accent); }
:root[data-tema="dark"] .progress i.on { background: var(--card-btn); }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--seg); }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink2); font-weight: 500; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--surf); color: var(--ink); font-weight: 600; }

.radar { width: 100%; max-width: 420px; height: auto; margin: 0 auto; display: block; }
.rg-grid { fill: none; stroke: var(--line); stroke-width: 1; }
.rg-neutral { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 5 4; opacity: 0.7; }
.rg-area { fill: var(--accent); fill-opacity: 0.2; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.rg-pt { fill: var(--accent); stroke: var(--ground); stroke-width: 2; }
.rg-pt.few { fill: var(--ground); stroke: var(--accent); }
.rg-lab { font-size: 11.5px; font-weight: 600; fill: var(--ink); font-family: var(--ui); }
.rg-note { font-size: 10px; font-weight: 600; fill: var(--ink2); font-family: var(--ui); paint-order: stroke; stroke: var(--ground); stroke-width: 3px; }
:root[data-tema="dark"] .rg-pt { stroke: var(--ground); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; }
.legend .sw1 { width: 18px; height: 10px; border-radius: 3px; background: var(--tint); border: 2px solid var(--accent); }
.legend .sw2 { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); }

.axis { display: flex; flex-direction: column; gap: 7px; padding: 14px 0; border-top: 1px solid var(--line); }
.axis-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.axis-h b { font-size: 15px; font-weight: 600; }
.axis-h span { font-size: 12px; color: var(--ink2); text-align: right; }
.axis-h span.warn { color: var(--warn); font-weight: 600; }
.track { position: relative; height: 22px; }
.track .base { position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 2px; background: var(--line); }
.track .fill { position: absolute; top: 9px; height: 4px; background: var(--accent); }
.track .band { position: absolute; top: 10px; height: 2px; background: var(--deep); opacity: 0.35; }
:root[data-tema="dark"] .track .band { background: var(--card-fg); }
.track .mid { position: absolute; left: calc(50% - 1px); top: 3px; width: 2px; height: 16px; background: var(--ink); }
.track .dot { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--accent); border: 2.5px solid var(--ground); }
.track .dot.few { background: var(--ground); border-color: var(--accent); }
.track .dot.empty { background: var(--ground); border-color: var(--ctrl); }
.poles { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink2); }

.tabs { position: sticky; bottom: 0; display: flex; padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surf); border-top: 1px solid var(--line); }
.tabs a { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink2); font-size: 12px; font-weight: 500; text-decoration: none; border-radius: 10px; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
:root[data-tema="dark"] .tabs a[aria-current="page"] { color: var(--card-btn); }

.banner { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--tint); border-radius: 14px; }
.banner p { flex: 1; font-size: 14px; line-height: 1.4; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--card); color: var(--card-fg); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; max-width: calc(100vw - 40px); z-index: 20; }
dialog { border: 0; border-radius: 18px; padding: 22px; max-width: min(440px, calc(100vw - 32px)); background: var(--surf); color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 28, 0.55); }
dialog h2 { margin-bottom: 8px; }
dialog .row { margin-top: 18px; justify-content: flex-end; }
.setting { display: flex; flex-direction: column; gap: 10px; padding: 18px 0; border-top: 1px solid var(--line); }
.empty { padding: 26px 20px; border: 1.5px dashed var(--ctrl); border-radius: 16px; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.foot { font-size: 12px; color: var(--ink2); padding-top: 4px; }

@media (prefers-reduced-motion: no-preference) {
  main.entra { animation: entra 220ms cubic-bezier(0.22, 1, 0.36, 1); }
  @keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

.check-row { display: flex; gap: 14px; align-items: flex-start; }
.check { flex-shrink: 0; width: 26px; height: 26px; margin-top: 1px; border-radius: 8px; border: 2px solid var(--ctrl); background: var(--surf); display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--on-accent); }
.check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.campo { flex: 1; min-width: 0; height: 50px; border-radius: 12px; border: 1.5px solid var(--ctrl); background: var(--surf); padding: 0 14px; font-size: 16px; }
