:root {
  --night: #13213f;
  --night-deep: #0b1530;
  --snow: #f4f7ff;
  --frost: #a9bde6;
  --window: #ffd98a;
  --window-glow: #ffb547;
  --wood: #c2412d;
  --wood-dark: #8e2a1c;
  --pine: #2f7d5b;
  --pine-dark: #1d5a40;
  --ink: #23263a;
  --muted: #5b5f78;
  --paper: #fffaf0;
  --paper-2: #f1ead8;
  --line: #e6dcc4;
  --star: #ffc93c;
  --font-display: "Pacifico", "Comic Sans MS", cursive;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(120% 80% at 50% 0%, var(--night) 0%, var(--night-deep) 70%) fixed, var(--night-deep);
  color: var(--snow);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.wrap {
  position: relative; z-index: 1;
  max-width: 1040px; margin: 0 auto;
  padding-block: 16px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 24px;
}
header { text-align: center; display: grid; gap: 6px; }
h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.15;
  margin: 0; color: var(--window); text-wrap: balance;
  text-shadow: 0 0 24px rgba(255, 181, 71, .45);
}
.sub { margin: 0; color: var(--frost); font-size: 1.05rem; text-wrap: balance; }
code { background: rgba(0,0,0,.08); border-radius: 4px; padding: 0 4px; }

.nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.nav a {
  color: var(--frost); text-decoration: none; font-weight: 800; font-size: .95rem;
  padding: 6px 14px; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(169,189,230,.35);
}
.nav a:hover { color: var(--snow); }
.nav a[aria-current="page"] { background: var(--window); color: var(--wood-dark); box-shadow: none; }
.nav a:focus-visible { outline: 3px solid var(--star); outline-offset: 2px; }

.panel, dialog { color-scheme: light; }
.panel { background: var(--paper); color: var(--ink); border-radius: 18px; padding: 20px clamp(14px, 3vw, 26px); display: grid; gap: 14px; min-width: 0; }
.panel h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; margin: 0; color: var(--wood-dark); line-height: 1.3; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.hint { margin: 0; color: var(--muted); font-size: .92rem; }

.btn {
  font: 800 1rem var(--font-body); border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; text-decoration: none;
}
.btn.main { background: var(--pine); color: var(--paper); }
.btn.main.is-done { background: var(--star); color: var(--ink); }
.btn.warm { background: var(--wood); color: var(--paper); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px #d8cfb8; }
.btn.small { font-size: .88rem; padding: 6px 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--star); outline-offset: 2px; }
.btn[data-armed] { background: var(--wood-dark); color: var(--paper); box-shadow: none; }
.icon-btn { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; color: inherit; padding: 4px 8px; border-radius: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .grow { flex: 1 1 200px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 0; font: 700 .9rem var(--font-body); cursor: pointer;
  padding: 5px 12px; border-radius: 999px; background: var(--paper-2); color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip small { font-weight: 600; opacity: .7; }
.tag.age { background: #efe6ff; color: #5a3a8f; }
.tag.warn { background: #ffd9d2; color: var(--wood-dark); }
.chip:focus-visible { outline: 3px solid var(--star); outline-offset: 1px; }
.tag { display: inline-block; font-size: .78rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--paper-2); color: var(--muted); white-space: nowrap; }
.tag.free { background: #dff2e8; color: var(--pine-dark); }
.tag.busy { background: #ffe9c2; color: #7a4a00; }
.tag.mine { background: #e5e9ff; color: #3a3f8f; }
.score { color: #b07800; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; }

input[type="search"], .field input:not([type="range"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]), .field textarea {
  font: inherit; color: var(--ink); background: #fff; width: 100%;
  border: 2px solid #ddd3bb; border-radius: 12px; padding: 8px 12px;
}
input:focus-visible, textarea:focus-visible { outline: 3px solid var(--star); outline-offset: 1px; }
.field { display: grid; gap: 4px; font-weight: 800; font-size: .9rem; min-width: 0; border: 0; padding: 0; margin: 0; }
.field textarea { resize: vertical; font-weight: 400; }
.field input[type="range"] { accent-color: var(--pine); width: 100%; }
.row2 { display: flex; gap: 10px; }
.row2 .field:last-child { flex: 1; }
.audio-field { background: var(--paper-2); border-radius: 12px; padding: 10px 12px; }
.audio-field legend { font-weight: 800; padding: 0; float: left; width: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 700; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--pine); flex: none; }
.field .items { display: flex; flex-wrap: wrap; gap: 8px 18px; font-weight: 700; }
.field legend { padding: 0; margin-bottom: 6px; }

dialog {
  border: 0; padding: 0; border-radius: 22px; width: min(460px, calc(100vw - 32px));
  background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(11,21,48,.75); }
dialog.sheet { width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.sheet > * { padding: 18px clamp(14px, 3vw, 24px); }
.editor { display: grid; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; margin: 0; color: var(--wood-dark); line-height: 1.3; }

.pick-rows { display: grid; gap: 6px; }
.tr-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: min(50vh, 440px); overflow: auto; overscroll-behavior: contain; }
.tr-rows li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 10px; background: var(--paper-2); }
.tr-rows li > div { min-width: 0; }
.tr-rows .meta { display: flex; flex-wrap: wrap; gap: 4px; }
.tr-rows select { font: inherit; color: var(--ink); background: #fff; border: 2px solid #ddd3bb; border-radius: 10px; padding: 6px 8px; max-width: 100%; }
.tr-rows select:focus-visible { outline: 3px solid var(--star); outline-offset: 1px; }
.link { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; justify-self: start; }
.link:focus-visible { outline: 3px solid var(--star); }
.pin-dlg::backdrop { background: var(--night-deep); }
.pin-title { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; margin: 0; color: var(--wood-dark); }
.pin-reveal { max-width: 420px; text-align: center; }
.pin-big {
  margin: 0; padding: 14px 18px; border-radius: 16px; background: var(--paper-2); box-shadow: inset 0 0 0 3px var(--star);
  font-family: var(--font-display); font-size: clamp(3rem, 16vw, 4.6rem); line-height: 1.2; letter-spacing: .12em; color: var(--wood-dark);
  overflow-wrap: anywhere; user-select: all;
}
.pin-warn { margin: 0; text-align: left; color: var(--wood-dark); background: #ffe9e4; border-radius: 12px; padding: 10px 12px; font-size: .95rem; }
.pin-tips { margin: 0; padding: 0; list-style: none; text-align: left; display: grid; gap: 6px; font-size: .95rem; }
.rec { display: flex; gap: 14px; align-items: center; }
.rec-time { font-weight: 900; font-variant-numeric: tabular-nums; font-size: 1.3rem; }
.field select { font: inherit; color: var(--ink); background: #fff; border: 2px solid #ddd3bb; border-radius: 10px; padding: 4px 8px; }
dialog.finale { width: min(520px, calc(100vw - 32px)); overflow: hidden; }
.finale canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.finale .card { position: relative; padding: 32px 24px 24px; display: grid; gap: 14px; text-align: center; }
.finale .big-pic { font-size: 5.5rem; line-height: 1; }
.finale h2 { font-family: var(--font-display); font-weight: 400; font-size: 2rem; line-height: 1.25; margin: 0; color: var(--wood-dark); }
.finale .kid { font-size: 1.2rem; font-weight: 700; margin: 0; }
.credits { text-align: center; color: var(--frost); opacity: .75; font-size: .8rem; line-height: 1.5; max-width: 720px; margin: 8px auto 0; text-wrap: balance; }
.credits a { color: inherit; }
.credits a:focus-visible { outline: 2px solid var(--star); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-weight: 700;
  max-width: calc(100vw - 32px); transition: transform .25s ease; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { transform: translate(-50%, 0); }

.task-card { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: 4px 12px; align-items: start; }
.task-card .pic { font-size: 2.2rem; line-height: 1.1; text-align: center; }
.task-card .body { display: grid; gap: 4px; min-width: 0; }
.task-card .t { font-weight: 900; font-size: 1.05rem; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.task-card p { margin: 0; }
.task-card .tip { color: var(--muted); font-size: .92rem; }
.task-card .prep, .task-card .ahead { font-size: .9rem; }
.task-card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-card .ops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
