/* Timer — hvidt papir, mørkeblå skrift, Time Timer-rød, stjernegul.
   Kun lys tilstand, med vilje: Time Timeren på væggen er hvid, og de to
   ting skal ligne den samme genstand. */
:root {
  --paper: #ffffff;
  --paper-2: #f3f1ec;
  --card: #ffffff;
  --ink: #1d2437;
  --ink-2: #5c6780;
  --ink-3: #9ba5b8;
  --line: #e3e0d9;
  --red: #e8342a;
  --red-soft: #fbd9d5;
  --bank: #23a06b;
  --bank-soft: #d3f0e2;
  --warn: #e08a00;
  --warn-soft: #fbe6c2;
  --gold: #f6b90a;
  --gold-soft: #fdeec0;
  --sky: #3a7bd0;
  --shadow: 0 14px 34px -22px rgba(29, 36, 55, .30);
  --radius: 24px;
  --display: "Fredoka", "Avenir Next Rounded", "Nunito", system-ui, sans-serif;
  --body: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color-scheme: light only;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 460px at 85% -14%, color-mix(in oklab, var(--red) 5%, transparent), transparent 62%),
    radial-gradient(900px 400px at -12% 26%, color-mix(in oklab, var(--sky) 5%, transparent), transparent 62%);
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.12rem; }
.muted { color: var(--ink-2); }
.tiny { font-size: .8rem; color: var(--ink-3); }
.center { text-align: center; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: max(14px, env(safe-area-inset-top)) 18px 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--display); font-size: 1.22rem; font-weight: 600; }
.brand-mark { width: 24px; height: 24px; border-radius: 50%; background: conic-gradient(var(--red) 0 25%, var(--paper-2) 0 100%); border: 2.5px solid var(--ink); display: inline-block; }
.topbar-right { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: .92rem; }
.view { flex: 1; padding: 6px 18px 26px; }
.stack > * + * { margin-top: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.btn {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  border-radius: 999px; padding: 12px 20px; font-weight: 700; font-family: var(--display);
  cursor: pointer; transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.go { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 7px 14px; font-size: .88rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in oklab, var(--red) 40%, var(--line)); background: transparent; }
.btn.block { display: block; width: 100%; }
.link { background: none; border: 0; color: var(--sky); font-weight: 700; cursor: pointer; padding: 4px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }

input[type="text"], input[type="time"], select {
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2);
  padding: 11px 14px; width: 100%; -webkit-user-select: text; user-select: text;
}
label.field { display: block; }
label.field > span { display: block; font-size: .82rem; color: var(--ink-2); font-weight: 700; margin: 0 0 4px 4px; }
label.row > input[type="checkbox"] { align-self: flex-start; margin-top: 4px; flex: 0 0 auto; }

/* ---------- børn og rutiner ---------- */
.kidrow { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.kidrow::-webkit-scrollbar { display: none; }
.kidchip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 16px 8px 8px; font-family: var(--display); font-weight: 600; cursor: pointer;
}
.kidchip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.kidchip .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--kid, var(--sky)); color: #fff; font-size: 1rem; font-weight: 700; }
.kid-sun { --kid: #f0a500; } .kid-sky { --kid: #3a7bd0; } .kid-leaf { --kid: #35a06a; }
.kid-berry { --kid: #d3486c; } .kid-plum { --kid: #8257c4; } .kid-coral { --kid: #ef6a3c; }

.routine-card { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; cursor: pointer; }
.routine-card .ic { font-size: 2rem; line-height: 1; width: 52px; height: 52px; display: grid; place-items: center; background: var(--paper-2); border-radius: 18px; flex: 0 0 auto; }
.routine-card .meta { flex: 1; min-width: 0; }
.routine-card .meta h3 { margin-bottom: 1px; }
.routine-card .meta .tiny { font-size: 1.05rem; letter-spacing: .06em; }
.routine-card .go-arrow { font-size: 1.5rem; color: var(--ink-3); }

/* ---------- skiven ---------- */
.dialwrap { position: relative; width: min(84vw, 340px); margin: 0 auto; aspect-ratio: 1; }
.dialwrap.big { width: min(86vw, 46dvh, 380px); }
.dial { width: 100%; height: 100%; display: block; touch-action: none; }
.dial .face { fill: var(--card); stroke: var(--line); stroke-width: 2; }
.dial .tick { stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; }
.dial .tick.major { stroke: var(--ink-2); stroke-width: 3; }
.dial .num { fill: var(--ink-2); font-family: var(--display); font-size: 13px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; }
.dial .wedge { fill: var(--red); }
.dial .over { fill: var(--warn); opacity: .55; }
.dial .hub { fill: var(--ink); }
.dial .grab { fill: var(--red); stroke: var(--card); stroke-width: 3; }
.dial.editable { cursor: grab; }

.dial-centre { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.dial-centre .big {
  font-family: var(--display); font-weight: 600; font-size: clamp(2.6rem, 15vw, 4rem); line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: color-mix(in oklab, var(--card) 88%, transparent); border-radius: 20px; padding: 2px 16px;
}
.dial-centre .big.over { color: var(--warn); }
.dial-centre .lbl { font-size: .9rem; color: var(--ink-2); margin-top: 5px; background: color-mix(in oklab, var(--card) 88%, transparent); border-radius: 999px; padding: 1px 12px; }

/* ---------- tingene, der skal nås ---------- */
.taskgrid { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 8px; }
.taskgrid .taskcard { flex: 0 1 92px; }
.taskgrid.small { gap: 6px; }
.taskgrid.small .taskcard { flex: 0 1 76px; }
.flowarrow { align-self: center; color: var(--ink-3); font-weight: 900; font-size: 1.1rem; line-height: 1; }
.taskcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); border-radius: 18px;
  padding: 10px 6px 8px; color: var(--ink); transition: transform .08s ease;
}
.taskcard:active { transform: scale(.96); }
.taskcard .ic { font-size: 2rem; line-height: 1.05; }
.taskgrid.small .taskcard .ic { font-size: 1.5rem; }
.taskcard .cap { font-size: .72rem; font-weight: 800; line-height: 1.15; text-align: center; color: var(--ink-2); }
.taskcard.waiting { opacity: .42; border-style: dashed; }
.taskcard.off { opacity: .4; border-style: dashed; background: var(--paper-2); }
.taskcard.off .ic { filter: grayscale(1); }
.pill.on { background: var(--bank-soft); color: var(--bank); }

/* Kæden mellem to ting: knappen sidder oven på skillestregen i stedet for at
   lægge beslag på sin egen linje. */
.list li.linkrow { height: 0; padding: 0; justify-content: center; border-top: 1px solid var(--line); }
.list li.linkrow + li { border-top: 0; padding-top: 16px; }
.list li:has(+ li.linkrow) { padding-bottom: 16px; }
.chain {
  position: relative; z-index: 1;
  border: 0; cursor: pointer; padding: 3px 10px; border-radius: 999px; min-width: 44px;
  background: var(--card); color: var(--ink-3);
  font-size: .74rem; font-weight: 800; line-height: 1.3; letter-spacing: .01em;
}
.chain:hover { color: var(--ink-2); }
.chain.on {
  color: var(--sky); background: color-mix(in oklab, var(--sky) 12%, var(--card));
  box-shadow: 0 0 0 4px var(--card);
}
.taskcard.done { border-color: var(--bank); background: var(--bank-soft); }
.taskcard.done .ic { opacity: .4; }
.taskcard.done .cap { color: var(--bank); text-decoration: line-through; }
.taskcard.done::after { content: "✓"; position: absolute; top: 3px; right: 8px; font-size: .85rem; color: var(--bank); font-weight: 900; }

/* ---------- ikonvælgeren ---------- */
.icongrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; }
.iconbtn-pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  border: 2px solid transparent; background: var(--paper-2); border-radius: 16px; padding: 8px 4px 6px; color: var(--ink);
}
.iconbtn-pick .ic { font-size: 1.7rem; line-height: 1.05; }
.iconbtn-pick .cap { font-size: .66rem; font-weight: 700; color: var(--ink-2); text-align: center; line-height: 1.1; }
.iconbtn-pick.on { border-color: var(--bank); background: var(--bank-soft); }

/* ---------- stjerner ---------- */
.stars { display: inline-flex; gap: 4px; align-items: center; }
.stars svg { width: 30px; height: 30px; overflow: visible; }
.stars .bg { fill: color-mix(in oklab, var(--ink-3) 22%, transparent); }
.stars.xl svg { width: 74px; height: 74px; }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.stars.pop svg { animation: pop .45s cubic-bezier(.34,1.56,.64,1) both; }
.stars.pop svg:nth-child(2) { animation-delay: .12s; }
.stars.pop svg:nth-child(3) { animation-delay: .24s; }

/* ---------- kørselsskærmen ---------- */
body.running .tabs, body.running .topbar { display: none; }
.run { display: flex; flex-direction: column; min-height: 100dvh; padding: max(10px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); gap: 12px; }
.run-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.run-top .who { font-family: var(--display); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.run-actions { display: flex; gap: 10px; align-items: stretch; margin-top: auto; padding-top: 4px; }
.bigbtn {
  flex: 1; border: 0; border-radius: 22px; padding: 20px 16px; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 1.35rem;
  background: var(--bank); color: #fff; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; gap: 10px; transition: transform .08s ease;
}
.bigbtn:active { transform: scale(.98); }
.bigbtn.locked { background: var(--paper-2); color: var(--ink-3); box-shadow: none; border: 2px dashed var(--line); }
.bigbtn.finish { background: var(--gold); color: #40320a; }
.iconbtn { flex: 0 0 auto; width: 64px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-size: 1.4rem; cursor: pointer; }

.finish-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 100dvh; padding: 24px; text-align: center; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }

/* ---------- lister ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .ic { font-size: 1.35rem; width: 38px; height: 38px; display: grid; place-items: center; background: var(--paper-2); border-radius: 12px; flex: 0 0 auto; }
.list .grow { flex: 1; min-width: 0; }
.list .grow .name { font-weight: 700; }
.pill { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); }
.stepchip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: .86rem; font-weight: 700; color: var(--ink-2);
}
.stepchip.done { border-color: var(--bank); color: var(--bank); background: var(--bank-soft); }

.budgetbar { display: flex; align-items: center; justify-content: center; gap: 12px; }
.budgetbar .val { font-family: var(--display); font-size: 2.1rem; font-weight: 600; min-width: 116px; text-align: center; font-variant-numeric: tabular-nums; }
.budgetbar button { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper-2); font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.week { display: flex; gap: 6px; justify-content: space-between; }
.week .day { flex: 1; text-align: center; }
.week .day .box { border-radius: 14px; background: var(--paper-2); padding: 8px 2px; border: 1px solid var(--line); }
.week .day .box.has { background: var(--gold-soft); border-color: color-mix(in oklab, var(--gold) 45%, transparent); }
.week .day .s { font-size: .8rem; color: var(--gold); font-weight: 800; }
.week .day .lbl { font-size: .7rem; color: var(--ink-3); margin-top: 3px; }

/* ---------- faner, ark, toast ---------- */
.tabs {
  position: sticky; bottom: 0; display: flex; justify-content: space-around; gap: 4px;
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
}
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 12px; color: var(--ink-3); cursor: pointer; font-size: .7rem; font-weight: 800; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-selected="true"] { color: var(--ink); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 28, .45); z-index: 50; }
.sheet {
  position: fixed; left: 50%; transform: translate(-50%, var(--dy, 0px)); bottom: 0; width: min(560px, 100%); z-index: 51;
  background: var(--card); border-radius: 26px 26px 0 0; border: 1px solid var(--line); border-bottom: 0;
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; padding: 0 18px max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px -30px rgba(0,0,0,.6);
  transition: transform .2s ease-out; animation: sheet-in .22s ease-out;
}
.sheet.dragging { transition: none; }
@keyframes sheet-in { from { transform: translate(-50%, 100%); } }
/* Grebet er hele den øverste stribe, ikke kun den lille streg — træk ned for at lukke */
.sheet-grip { position: sticky; top: 0; z-index: 1; background: var(--card); padding: 12px 0 10px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.sheet-grip:active { cursor: grabbing; }
.sheet-handle { width: 42px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px; z-index: 60;
  font-weight: 700; font-size: .92rem; max-width: 90vw; text-align: center;
}
.empty { text-align: center; color: var(--ink-2); padding: 24px 10px; }
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login input { text-align: center; font-size: 1.15rem; margin-top: 8px; }
.code-box { text-align: center; padding: 10px 0 4px; }
.code-box .code { font-family: var(--display); font-size: 3.1rem; letter-spacing: .28em; padding-left: .28em; line-height: 1.1; }

/* ---------- testtilstand (kun for voksne) ---------- */
.testbar {
  display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap;
  background: var(--paper-2); border: 1px dashed var(--ink-3); border-radius: 16px;
  padding: 8px 10px; font-size: .82rem; font-weight: 800; color: var(--ink-2);
}
.testbar button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 5px 11px; font-weight: 700; cursor: pointer; }
.testbar .seg { background: var(--card); }
.testbar .seg button { border: 0; padding: 4px 10px; }
.testbar .seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
