:root {
  color-scheme: light dark;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1c2333;
  --muted: #4a5568;
  --accent: #2f4a8a;
  --on-accent: #ffffff;
  --border: #c9c4b8;
  --field-border: #6f6a5e;
  --warn-bg: #fff3d1;
  --warn-text: #4a3500;
  --warn-border: #b07a00;
  --danger: #a4262c;
  --on-danger: #ffffff;
  --crisis-bg: #fde8e8;
  --tag-bg: #e3e9f8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141f;
    --surface: #1a2030;
    --text: #e8eaf0;
    --muted: #b3bace;
    --accent: #a9bcff;
    --on-accent: #10141f;
    --border: #3a4463;
    --field-border: #8a93b0;
    --warn-bg: #3a2e0a;
    --warn-text: #ffe9a8;
    --warn-border: #d9a520;
    --danger: #ffa3a3;
    --on-danger: #2a0a0a;
    --crisis-bg: #3b1518;
    --tag-bg: #2a3350;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-underline-offset: 0.15em; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.6em 0 0.4em; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 1.2em 0 0.4em; }
h3 { font-size: 1.05rem; margin: 1em 0 0.3em; }
p, ul, ol, dl { margin: 0 0 0.8em; }
li { margin-bottom: 0.35em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.75rem 1rem; z-index: 10; }
.skip:focus { left: 0.5rem; top: 0.5rem; }
.wrap { max-width: 42rem; margin: 0 auto; padding: 0 1rem; }
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.brand svg { width: 26px; height: 26px; }
.lang { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.5rem; }
main { padding-bottom: 2rem; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.92rem; padding: 1.2rem 0 6rem; }
.site-footer ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.2rem 1.1rem; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0.6rem 1.1rem; border-radius: 10px; border: 2px solid var(--accent); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; margin: 0.3rem 0.4rem 0.3rem 0; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-plain { background: transparent; color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.hero .btn { width: 100%; font-size: 1.1rem; }
.hero p.lead { font-size: 1.15rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin: 1rem 0; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.warning { background: var(--warn-bg); color: var(--warn-text); border: 2px solid var(--warn-border); }
.warning h2 { font-size: 1.1rem; }
.crisis { background: var(--crisis-bg); border: 2px solid var(--danger); }
.lines { list-style: none; padding: 0; }
.lines a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 600; }
.hint, .week { color: var(--muted); font-size: 0.95rem; }
.week { font-weight: 600; margin-top: -0.3em; }
.big { font-size: 1.35rem; font-weight: 700; }
.tag { display: inline-block; background: var(--tag-bg); color: var(--text); border-radius: 999px; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.6rem; margin-left: 0.5rem; vertical-align: middle; }
.tag-quiet { background: transparent; border: 1px solid var(--field-border); }
.flash { background: var(--tag-bg); border-radius: 10px; padding: 0.7rem 1rem; margin-top: 1rem; font-weight: 600; }
.banner { background: var(--warn-bg); color: var(--warn-text); border: 2px solid var(--warn-border); border-radius: 10px; padding: 0.7rem 1rem; margin-top: 1rem; font-weight: 600; }
.help-link { margin-top: 2rem; }
.help-link a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 600; }
.block { display: block; font-weight: 400; }
.sleepy-action { margin-top: 0.6rem; }
.nights li, .worries li, .flash { overflow-wrap: anywhere; }
.error { color: var(--danger); font-weight: 600; margin: 0.25rem 0 0; }
.error:empty { display: none; }
.steps { padding-left: 1.3rem; }

.field { margin: 1rem 0; }
.field label, legend { display: block; font-weight: 600; margin-bottom: 0.35rem; padding: 0; }
input[type="text"], input[type="time"], input[type="date"], input[type="file"] { width: 100%; min-height: 48px; padding: 0.5rem 0.7rem; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--field-border); border-radius: 10px; }
input.invalid, fieldset.invalid { border-color: var(--danger); }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem 1rem; margin: 1rem 0; min-width: 0; background: var(--surface); }
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 48px; min-width: 48px; padding: 0.3rem 0.8rem; border: 2px solid var(--field-border); border-radius: 10px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--tag-bg); }
.choice input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); margin: 0; flex: none; }
.scale { flex-direction: column; }
.optin { border: 2px dashed var(--accent); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.stats div { background: var(--bg); border-radius: 10px; padding: 0.6rem 0.8rem; }
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 0; font-weight: 700; font-size: 1.15rem; }
.nights, .worries, .links { list-style: none; padding: 0; }
.nights li, .worries li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 1rem; margin-bottom: 0.6rem; }
.nights li strong { display: block; }
.worries li.done strong { text-decoration: line-through; color: var(--muted); }
.worries .choice { border: 0; padding-left: 0; }
.links a { display: inline-flex; min-height: 44px; align-items: center; }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 1rem; margin: 0.6rem 0; }
details[open] { padding-bottom: 0.8rem; }
summary { cursor: pointer; font-weight: 600; min-height: 48px; display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem; }
.lesson-week { color: var(--muted); font-weight: 400; }
figure { margin: 1.2rem 0; }
figcaption { font-weight: 600; margin-bottom: 0.3rem; }
.chart { width: 100%; height: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.chart-line { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.chart-dot { fill: var(--accent); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-value { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart-band { fill: var(--accent); opacity: 0.12; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.refs li { margin-bottom: 0.8em; overflow-wrap: anywhere; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 56px; font-size: 0.9rem; font-weight: 600; color: var(--muted); text-decoration: none; border-top: 3px solid transparent; }
.tab[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }
#app { min-height: 60vh; }
@media (min-width: 720px) {
  .tabs { position: static; border: 1px solid var(--border); border-radius: 12px; margin-top: 1rem; overflow: hidden; }
  .hero .btn { width: auto; }
  .site-footer { padding-bottom: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
@media print {
  .tabs, .site-header, .site-footer, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}
