/* Barn – klistermärkesbok: tjock bläckkontur, hård skugga, rundad typ. Varje barn har sin färg (--me / --kid). */


:root {
    --paper: #eef3ff;
    --dots: #d5def6;
    --card: #ffffff;
    --ink: #24213d;
    --edge: #24213d;
    --line: #24213d;
    --muted: #625f80;
    --soft-line: #dcdff0;
    --star: #ffc531;
    --star-deep: #e09a00;
    --ok: #23854a;
    --ok-soft: #dcf5e4;
    --warn: #c2410c;
    --warn-soft: #ffedd5;
    --danger: #b42318;
    --kid: var(--me, #7c3aed);
    --soft-mix: 24%;
    --kid-soft: color-mix(in srgb, var(--kid) var(--soft-mix), var(--card));
    --border: 2px;
    --lift: 3px;
    --radius: 18px;
    --radius-small: 12px;
    --font: 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #17152b;
        --dots: #24213f;
        --card: #24213f;
        --ink: #f1efff;
        --edge: #07060f;
        --line: #5b5687;
        --muted: #a8a4c9;
        --soft-line: #383458;
        --ok-soft: #173826;
        --warn-soft: #3d2312;
        --soft-mix: 34%;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --paper: #17152b;
    --dots: #24213f;
    --card: #24213f;
    --ink: #f1efff;
    --edge: #07060f;
    --line: #5b5687;
    --muted: #a8a4c9;
    --soft-line: #383458;
    --ok-soft: #173826;
    --warn-soft: #3d2312;
    --soft-mix: 34%;
    color-scheme: dark;
}

html[data-mode="kid"], html[data-mode="guest"] {
    --border: 3px;
    --lift: 5px;
    --radius: 22px;
}

* { box-sizing: border-box; }
/* Barnets ljusa ton räknas fram där färgen sätts, så den följer ljust/mörkt tema */
[style*="--kid"], [style*="--swatch"] { --kid-soft: color-mix(in srgb, var(--kid) var(--soft-mix), var(--card)); }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.45;
    color: var(--ink);
    background-color: var(--paper);
    background-image: radial-gradient(var(--dots) 1.5px, transparent 1.6px);
    background-size: 22px 22px;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--kid); outline-offset: 3px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.spaced { margin-top: 1.5rem; }
.lead { margin: -0.5rem 0 1.25rem; max-width: 60ch; }
code { font-size: 0.85em; word-break: break-all; }

/* ---------- Ramverk ---------- */

.page {
    max-width: 1040px;
    margin: 0 auto;
    padding: 1.25rem 16px calc(2.5rem + env(safe-area-inset-bottom));
}
.page-kid {
    max-width: 760px;
    padding-top: calc(1rem + env(safe-area-inset-top));
    padding-bottom: calc(7rem + env(safe-area-inset-bottom));
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0.5rem 0 1.25rem; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.columns { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; margin-bottom: 1.25rem; }
.stack { display: grid; gap: 1.25rem; }

.card {
    background: var(--card);
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--lift) var(--lift) 0 var(--edge);
    padding: 1.15rem 1.25rem;
}
.card > h2 { margin-bottom: 0.75rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }

.flash {
    border: var(--border) solid var(--line);
    border-radius: var(--radius-small);
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    background: var(--card);
    font-weight: 700;
    box-shadow: 3px 3px 0 var(--edge);
}
.flash.is-ok { background: var(--ok-soft); }
.flash.is-error { background: var(--warn-soft); }

/* ---------- Knappar och formulär ---------- */

.button, button.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    font: inherit; font-weight: 800; font-size: 1rem;
    padding: 0.55rem 1.15rem;
    min-height: 44px;
    color: #fff;
    background: var(--kid);
    border: var(--border) solid var(--line);
    border-radius: 999px;
    box-shadow: 3px 3px 0 var(--edge);
    text-decoration: none;
    cursor: pointer;
    transition: transform 80ms ease, box-shadow 80ms ease;
}
.button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--edge); }
.button.small { min-height: 36px; padding: 0.3rem 0.9rem; font-size: 0.95rem; }
.button.big { min-height: 56px; font-size: 1.2rem; padding: 0.6rem 1.6rem; }
.button.ghost { background: var(--card); color: var(--ink); }
.button.danger { background: var(--danger); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }

.link-button { font: inherit; background: none; border: 0; padding: 0.2rem 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.icon-button {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    font-size: 1.05rem;
    background: var(--card);
    border: 2px solid var(--soft-line);
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
}
.icon-button:hover { border-color: var(--edge); }
.pill-button {
    font: inherit; font-weight: 700;
    min-height: 40px; padding: 0.25rem 0.9rem;
    background: var(--card); color: var(--ink);
    border: 2px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
}
.pill-button.strong { background: var(--star); color: #24213d; }
.pill-button:disabled { opacity: 0.45; }

label { display: grid; gap: 0.25rem; font-weight: 700; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
    font: inherit; font-weight: 500; font-size: 1rem;
    width: 100%;
    min-height: 44px;
    padding: 0.45rem 0.75rem;
    color: var(--ink);
    background: var(--card);
    border: 2px solid var(--soft-line);
    border-radius: var(--radius-small);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--kid); box-shadow: 0 0 0 3px color-mix(in srgb, var(--kid) 25%, transparent); }
textarea { resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.35rem; padding: 0; }
.form-stack { display: grid; gap: 1rem; }
.form-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
@media (max-width: 560px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .span-2, .form-grid .span-3 { grid-column: 1 / -1; }
}
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.check-row { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 600; }
.check-row input { width: 22px; height: 22px; margin-top: 0.1rem; accent-color: var(--kid); flex: none; }
.radio-stack { display: grid; gap: 0.5rem; }
.inline-form { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.notify-row { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.notify-row select { width: auto; }

.chip-group { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.chip-group legend { width: 100%; }
.chip input, .emoji-picker input, .color-picker input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
    display: inline-flex; align-items: center; gap: 0.3rem;
    min-height: 40px; padding: 0.2rem 0.9rem;
    font-weight: 700;
    background: var(--card);
    border: 2px solid var(--soft-line);
    border-radius: 999px;
    cursor: pointer;
}
.chip input:checked + span { background: var(--kid-soft); border-color: var(--edge); box-shadow: 2px 2px 0 var(--edge); }
.chip input:focus-visible + span { outline: 3px solid var(--kid); outline-offset: 2px; }
.chip.day span { min-width: 52px; justify-content: center; }
.chip-shortcuts { display: inline-flex; gap: 0.75rem; margin-left: 0.25rem; }
.date-other { width: auto; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.emoji-picker legend { width: 100%; }
.emoji-picker label { position: relative; }
.emoji-picker span {
    display: grid; place-items: center;
    width: 46px; height: 46px; font-size: 1.5rem;
    border: 2px solid transparent; border-radius: 14px; cursor: pointer;
}
.emoji-picker input:checked + span { border-color: var(--edge); background: var(--kid-soft); box-shadow: 2px 2px 0 var(--edge); }
.emoji-picker input:focus-visible + span { outline: 3px solid var(--kid); }

.color-picker { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.color-picker legend { width: 100%; }
.color-picker label { position: relative; }
.color-picker span {
    display: inline-flex; align-items: center; min-height: 38px; padding: 0.15rem 0.8rem 0.15rem 2.1rem;
    border: 2px solid var(--soft-line); border-radius: 999px; cursor: pointer; font-weight: 700; position: relative;
}
.color-picker span::before {
    content: ''; position: absolute; left: 8px; top: 50%; width: 20px; height: 20px; translate: 0 -50%;
    border-radius: 50%; background: var(--swatch); border: 2px solid var(--line);
}
.color-picker input:checked + span { border-color: var(--edge); background: var(--swatch-soft); color: #24213d; box-shadow: 2px 2px 0 var(--edge); }

.segmented { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.segmented button, .segmented label span {
    font: inherit; font-weight: 700; display: block;
    padding: 0.4rem 1rem; background: var(--card); color: var(--ink); border: 0; cursor: pointer;
}
.segmented label { display: block; position: relative; }
.segmented button + button, .segmented label + label span { border-left: 2px solid var(--line); }
.segmented button.active, .segmented input:checked + span { background: var(--kid); color: #fff; }

/* ---------- Klistermärken ---------- */

.sticker-avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 72px; height: 72px;
    font-size: 2.6rem; line-height: 1;
    background: var(--kid-soft);
    border: var(--border) solid var(--line);
    border-radius: 50%;
    box-shadow: 3px 3px 0 var(--edge);
    rotate: -4deg;
}
.sticker-avatar.small { width: 44px; height: 44px; font-size: 1.5rem; box-shadow: 2px 2px 0 var(--edge); border-width: 2px; }

.star-coin {
    position: relative; flex: none;
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.35rem 1rem 0.35rem 0.65rem;
    background: var(--star);
    color: #24213d;
    border: var(--border) solid var(--line);
    border-radius: 999px;
    box-shadow: 3px 3px 0 var(--edge);
    text-decoration: none;
    font-weight: 800;
}
.star-coin-star { font-size: 1.6rem; line-height: 1; }
.star-coin-value { font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.star-coin.small .star-coin-star { font-size: 1.15rem; }
.star-coin.small .star-coin-value { font-size: 1.35rem; }
.star-coin-pending {
    position: absolute; top: calc(100% + 6px); right: 0;
    white-space: nowrap; font-size: 0.8rem; font-weight: 700; color: var(--muted);
}
.star-coin.is-bumping { animation: bump 500ms cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.18) rotate(-4deg); } }

/* ---------- Barnläge ---------- */

.hero {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 1.1rem 1.5rem;
    margin-bottom: 1.25rem;
    background: var(--kid-soft);
    border: var(--border) solid var(--line);
    border-radius: 28px;
    box-shadow: var(--lift) var(--lift) 0 var(--edge);
}
.hero-text { flex: 1; min-width: 0; }
.hero-greeting { font-weight: 700; color: var(--muted); font-size: 1rem; }
.hero h1 { font-size: clamp(1.6rem, 7vw, 2.4rem); overflow-wrap: anywhere; }
@media (max-width: 420px) { .hero { gap: 0.75rem; padding: 0.9rem 0.9rem 1.4rem; } .hero-avatar { width: 60px; height: 60px; font-size: 2.1rem; } .hero .star-coin-value { font-size: 1.6rem; } }
.level { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.35rem; }
.level-label { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.level-bar, .goal-bar {
    display: block; flex: 1; height: 14px; min-width: 60px;
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.level-bar > span, .goal-bar > span { display: block; height: 100%; background: var(--kid); border-radius: 999px; }
.goal-bar > span { background: var(--star); }

.goal-strip {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1rem; margin: -0.25rem 0 1.5rem;
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 2px 2px 0 var(--edge);
}
.goal-emoji { font-size: 1.7rem; }
.goal-text { flex: 1; display: grid; gap: 0.2rem; min-width: 0; }
.goal-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-count { font-weight: 800; font-variant-numeric: tabular-nums; }

.section { margin-bottom: 1.75rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.section-head h2 { font-size: 1.6rem; }
.section-note { color: var(--muted); font-weight: 600; }
.section-link { font-weight: 800; color: var(--kid); text-underline-offset: 4px; }

.task-list { display: grid; gap: 0.85rem; }
@media (min-width: 700px) { .page-kid .task-list { grid-template-columns: 1fr 1fr; } }

.task-card {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.85rem;
    padding: 0.85rem 0.85rem 0.85rem 1rem;
    background: var(--card);
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--lift) var(--lift) 0 var(--edge);
    transition: opacity 200ms ease, transform 200ms ease;
}
.task-emoji { font-size: 2.3rem; line-height: 1; flex: none; width: 2.8rem; text-align: center; }
.task-body { flex: 1; min-width: 0; }
.task-body h3 { font-size: 1.2rem; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: center; margin-top: 0.25rem; font-size: 0.92rem; }
.task-note { color: var(--muted); font-size: 0.92rem; margin-top: 0.25rem; overflow-wrap: anywhere; }
.subject { font-weight: 800; font-size: 0.85rem; color: var(--kid); }
.points-chip {
    display: inline-block; padding: 0 0.55rem;
    font-weight: 800; color: #24213d;
    background: #ffe7a3; border: 2px solid var(--line); border-radius: 999px;
}
.state { font-weight: 700; color: var(--muted); }
.state.is-warn { color: var(--warn); }
.task-actions { display: flex; align-items: center; gap: 0.5rem; flex: none; }

.check-button {
    display: grid; place-items: center;
    width: 60px; height: 60px; flex: none;
    font: inherit; font-size: 2rem; font-weight: 800; line-height: 1;
    color: transparent;
    background: var(--card);
    border: var(--border) solid var(--line);
    border-radius: 50%;
    box-shadow: 3px 3px 0 var(--edge);
    cursor: pointer;
    transition: transform 80ms ease, box-shadow 80ms ease, background 150ms ease;
}
.check-button:hover { color: color-mix(in srgb, var(--ok) 35%, transparent); }
.check-button:active { transform: translate(3px, 3px); box-shadow: none; }
.check-button.is-checked { background: var(--ok); color: #fff; }
.check-button.is-locked { cursor: default; box-shadow: none; }
.cam-button {
    display: grid; place-items: center;
    width: 44px; height: 44px; font-size: 1.3rem;
    background: transparent; border: 2px dashed var(--soft-line); border-radius: 50%; cursor: pointer;
}
.done-photo { width: 52px; height: 52px; object-fit: cover; border-radius: 12px; border: 2px solid var(--line); }

.task-card.is-done { background: var(--ok-soft); box-shadow: 1px 1px 0 var(--edge); transform: translate(2px, 2px); }
.task-card.is-done h3 { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: color-mix(in srgb, var(--ok) 60%, transparent); }
.task-card.is-pending { background: color-mix(in srgb, var(--star) 18%, var(--card)); }
.task-card.is-pending .check-button { background: var(--star); color: #24213d; }
.task-card.is-rejected { border-style: dashed; }
.homework-card.is-soon:not(.is-done) { border-color: var(--warn); }
.task-card.is-saving { opacity: 0.6; pointer-events: none; }
.task-card.is-pop .check-button { animation: pop 450ms cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.2); } }

/* ---------- Timer (tidsbaserade uppgifter) ---------- */
.time-chip {
    display: inline-block; padding: 0 0.55rem;
    font-weight: 800;
    background: var(--kid-soft); border: 2px solid var(--line); border-radius: 999px;
}
.start-button {
    display: grid; place-items: center; align-content: center; gap: 0;
    width: 68px; height: 68px; flex: none;
    font: inherit; font-weight: 800; line-height: 1;
    color: #fff; background: var(--kid);
    border: var(--border) solid var(--line); border-radius: 50%;
    box-shadow: 3px 3px 0 var(--edge);
    cursor: pointer;
    transition: transform 80ms ease, box-shadow 80ms ease;
}
.start-button:active { transform: translate(3px, 3px); box-shadow: none; }
.start-icon { font-size: 1.5rem; margin-left: 0.15rem; }
.start-label { font-size: 0.82rem; margin-top: 0.1rem; }

.timer-panel { flex-basis: 100%; display: grid; gap: 0.45rem; padding-top: 0.15rem; }
.timer-bar {
    height: 16px; overflow: hidden;
    background: var(--card);
    border: 2px solid var(--line); border-radius: 999px;
}
.timer-bar > span {
    display: block; height: 100%;
    background: var(--kid);
    background-image: repeating-linear-gradient(-45deg, transparent 0 8px, rgb(255 255 255 / 0.28) 8px 16px);
    background-size: 22.6px 22.6px;
    border-radius: 999px;
    transition: width 500ms linear;
}
.timer-panel[data-state="running"] .timer-bar > span { animation: stripes 900ms linear infinite; }
.timer-panel[data-state="done"] .timer-bar > span { background-color: var(--ok); }
@keyframes stripes { to { background-position: 22.6px 0; } }
.timer-row { display: flex; align-items: center; gap: 0.6rem; }
.timer-time { font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.timer-panel[data-state="paused"] .timer-time { color: var(--muted); animation: blink 1.4s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.timer-done-text { display: none; font-weight: 800; color: var(--ok); font-size: 1.1rem; }
.timer-panel[data-state="done"] .timer-time { display: none; }
.timer-panel[data-state="done"] .timer-done-text { display: inline; }
.timer-controls { display: flex; gap: 0.45rem; margin-left: auto; }
.timer-button {
    display: grid; place-items: center;
    width: 48px; height: 48px;
    font: inherit; font-size: 1.25rem; line-height: 1;
    color: var(--ink); background: var(--card);
    border: 2px solid var(--line); border-radius: 50%;
    box-shadow: 2px 2px 0 var(--edge);
    cursor: pointer;
}
.timer-button.is-go { background: var(--kid); color: #fff; }
.timer-button.is-quiet { box-shadow: none; border-style: dashed; border-color: var(--soft-line); color: var(--muted); }
.timer-button:active { transform: translate(2px, 2px); box-shadow: none; }
.task-card.is-timing { border-color: var(--kid); }
.cam-button[hidden], .timer-button[hidden] { display: none; }
.check-button:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }
.task-card.is-timeup:not(.is-done) .check-button { border-color: var(--ok); animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.14); } 90% { transform: scale(0.96); } }

/* ---------- "Jag gör det om …" ---------- */
.later { margin-top: 0.45rem; }
.later summary {
    display: inline-flex; align-items: center; gap: 0.3rem;
    min-height: 34px; padding: 0.1rem 0.75rem;
    font-weight: 800; font-size: 0.92rem;
    color: var(--muted);
    border: 2px dashed var(--soft-line); border-radius: 999px;
    cursor: pointer; list-style: none;
    user-select: none;
}
.later summary::-webkit-details-marker { display: none; }
.later.has-plan summary { color: var(--ink); background: var(--kid-soft); border: 2px solid var(--line); }
.later.is-due summary { color: #fff; background: var(--warn); border: 2px solid var(--line); animation: nudge 1.6s ease-in-out infinite; }
.later[open] summary { color: var(--ink); border-style: solid; border-color: var(--line); }
.later-menu { margin-top: 0.55rem; }
.later-title { font-weight: 800; margin-bottom: 0.35rem; }
.later-options { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.later-option {
    min-height: 40px; padding: 0.2rem 0.85rem;
    font: inherit; font-weight: 800; color: var(--ink);
    background: var(--card);
    border: 2px solid var(--line); border-radius: 999px;
    box-shadow: 2px 2px 0 var(--edge);
    cursor: pointer;
}
.later-option:hover { background: var(--kid-soft); }
.later-option:active { transform: translate(2px, 2px); box-shadow: none; }
.later-option.is-clear { box-shadow: none; border-style: dashed; border-color: var(--soft-line); color: var(--muted); }
.row-status { display: block; font-size: 0.88rem; font-weight: 700; color: var(--kid); }
.field-help { width: 100%; margin-top: 0.1rem; }

@media (prefers-reduced-motion: reduce) {
    .timer-panel[data-state="running"] .timer-bar > span, .later.is-due summary,
    .task-card.is-timeup:not(.is-done) .check-button, .timer-panel[data-state="paused"] .timer-time { animation: none; }
}

.tiny-action { margin: -0.4rem 0 0.2rem 1.1rem; }

.empty-card {
    display: flex; align-items: center; gap: 0.9rem;
    padding: 1rem 1.2rem;
    border: 3px dashed var(--soft-line);
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}
.empty-card span { font-size: 2.2rem; }

.add-card {
    margin-bottom: 1.5rem;
    background: var(--card);
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--lift) var(--lift) 0 var(--edge);
}
.add-card summary {
    list-style: none; cursor: pointer;
    padding: 0.9rem 1.2rem;
    font-weight: 800; font-size: 1.2rem;
}
.add-card summary::-webkit-details-marker { display: none; }
.add-card[open] summary { border-bottom: 2px solid var(--soft-line); }
.add-card form { padding: 1rem 1.2rem 1.2rem; }

.shop-head { margin-bottom: 1rem; }
.reward-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.reward-card {
    display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start;
    padding: 1rem;
    background: var(--card);
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--lift) var(--lift) 0 var(--edge);
}
.reward-card .goal-bar { width: 100%; flex: none; }
.reward-card.can-buy { background: color-mix(in srgb, var(--star) 16%, var(--card)); }
.reward-card.is-goal { outline: 3px dashed var(--kid); outline-offset: 4px; }
.reward-card.family { margin-bottom: 0.9rem; align-items: stretch; }
.reward-top { display: flex; gap: 0.75rem; align-items: center; }
.reward-emoji { font-size: 2.8rem; line-height: 1; }
.reward-price { font-weight: 800; font-size: 1.3rem; }
.reward-meta { color: var(--muted); font-weight: 600; font-size: 0.92rem; }
.button.buy { background: var(--ok); }
.goal-toggle { margin-top: auto; }
.family-bar {
    display: flex; height: 34px;
    background: var(--paper);
    border: 2px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.family-bar span {
    display: grid; place-items: center;
    background: var(--kid);
    font-size: 1.1rem;
    overflow: hidden;
    min-width: 0;
}
.family-bar span + span { border-left: 2px solid var(--line); }
.contribute { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.plain-list li { display: flex; gap: 0.6rem; align-items: center; padding: 0.55rem 0.9rem; background: var(--card); border: 2px solid var(--soft-line); border-radius: var(--radius-small); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 0.7rem; text-align: center; box-shadow: 2px 2px 0 var(--edge); }
.stat strong { display: block; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.ledger { list-style: none; margin: 0; padding: 0; }
.ledger-day { font-weight: 800; color: var(--muted); margin: 1rem 0 0.35rem; }
.ledger-day:first-child { margin-top: 0; }
.ledger-row { display: flex; gap: 0.75rem; align-items: center; padding: 0.55rem 0.9rem; background: var(--card); border: 2px solid var(--soft-line); border-radius: var(--radius-small); margin-bottom: 0.35rem; font-weight: 600; }
.delta { font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.minus { color: var(--warn); }

.kid-nav {
    position: fixed; z-index: 20;
    left: 50%; bottom: calc(10px + env(safe-area-inset-bottom));
    translate: -50% 0;
    display: flex; gap: 0.15rem;
    width: min(560px, calc(100% - 20px));
    padding: 0.35rem;
    background: var(--card);
    border: 3px solid var(--line);
    border-radius: 26px;
    box-shadow: 4px 4px 0 var(--edge);
}
.kid-nav a {
    flex: 1; display: grid; justify-items: center; gap: 0;
    padding: 0.3rem 0.1rem 0.25rem;
    border-radius: 18px;
    text-decoration: none; font-weight: 700; font-size: 0.82rem;
    color: var(--muted);
}
.kid-nav-icon { font-size: 1.55rem; line-height: 1.2; }
.kid-nav a.active { background: var(--kid-soft); color: var(--ink); }

/* ---------- Vuxenläge ---------- */

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 0.75rem;
    padding: calc(0.55rem + env(safe-area-inset-top)) 16px 0.55rem;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--line);
}
.brand { flex: none; display: grid; }
.kid-tabs { display: flex; gap: 0.5rem; flex: 1; min-width: 0; }
.kid-tab {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.25rem 0.8rem 0.25rem 0.35rem;
    min-height: 44px;
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: 999px;
    text-decoration: none; font-weight: 800;
    min-width: 0;
}
.kid-tab-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--kid-soft); font-size: 1.15rem; flex: none; }
.kid-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kid-tab-points { font-weight: 700; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.kid-tab.active { background: var(--kid); color: #fff; box-shadow: 2px 2px 0 var(--edge); }
.kid-tab.active .kid-tab-points { color: #fff; opacity: 0.9; }
.admin-nav { display: flex; gap: 0.15rem; }
.admin-nav a { padding: 0.45rem 0.7rem; border-radius: 12px; text-decoration: none; font-weight: 700; white-space: nowrap; }
.admin-nav a.active { background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }

@media (max-width: 820px) {
    .topbar { flex-wrap: wrap; }
    .kid-tabs { order: 3; flex-basis: 100%; }
    .kid-tab { flex: 1; }
    .admin-nav { margin-left: auto; }
    .admin-nav a { font-size: 0; padding: 0.4rem 0.55rem; }
    .admin-nav a span { font-size: 1.35rem; }
}

.child-hero {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.2rem; margin-bottom: 1.25rem;
    background: var(--kid-soft);
    border: var(--border) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--lift) var(--lift) 0 var(--edge);
}
.child-hero-text { flex: 1; min-width: 0; }
.child-hero-side { display: grid; justify-items: end; gap: 0.6rem; }
@media (max-width: 520px) { .child-hero { flex-wrap: wrap; } .child-hero-side { width: 100%; grid-auto-flow: column; justify-content: space-between; align-items: center; } }

.viewas-banner {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: center; gap: 0.75rem; flex-wrap: wrap;
    padding: calc(0.5rem + env(safe-area-inset-top)) 16px 0.5rem;
    background: repeating-linear-gradient(-45deg, var(--star) 0 14px, #ffd866 14px 28px);
    color: #24213d;
    font-weight: 800;
    border-bottom: 3px solid var(--line);
    text-align: center;
}
html[data-viewing-as] .page-kid { padding-top: 1rem; }
.child-hero p { color: var(--muted); font-weight: 600; }
.card.attention { margin-bottom: 1.25rem; border-color: var(--edge); background: color-mix(in srgb, var(--star) 14%, var(--card)); }

.row-list { list-style: none; margin: 0; padding: 0; }
.row {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0;
    border-top: 2px solid var(--soft-line);
}
.row:first-child { border-top: 0; padding-top: 0.2rem; }
.row-list.compact .row { padding: 0.45rem 0; }
.row-emoji, .row-check { font-size: 1.45rem; width: 2rem; text-align: center; flex: none; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-main strong { overflow-wrap: anywhere; }
.row-main .muted { font-size: 0.9rem; }
.row-note { font-size: 0.9rem; color: var(--muted); }
.row-actions { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { display: contents; }
.row.is-done .row-main strong { color: var(--muted); }
.row.is-paused { opacity: 0.55; }
.row.is-rejected .row-main strong { text-decoration: line-through; }
.row.editing { display: block; }
.thumb img { display: block; width: 48px; height: 48px; object-fit: cover; border-radius: 10px; border: 2px solid var(--line); }
.row .goal-bar { margin-top: 0.3rem; height: 10px; }

.inline-add { margin-top: 0.9rem; border-top: 2px dashed var(--soft-line); padding-top: 0.75rem; }
.inline-add summary { cursor: pointer; font-weight: 800; color: var(--kid); }
.inline-add[open] summary { margin-bottom: 0.75rem; }
.empty-inline { display: grid; gap: 0.75rem; justify-items: start; }
.presets { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1rem; }
.pill { display: inline-block; font-size: 0.78rem; padding: 0 0.5rem; border-radius: 999px; background: var(--kid-soft); border: 1px solid var(--line); vertical-align: middle; }
.token-reveal { display: grid; gap: 0.6rem; padding: 0.9rem; margin-bottom: 0.9rem; border: 2px dashed var(--line); border-radius: var(--radius-small); }
.danger-zone { border-color: var(--danger); box-shadow: var(--lift) var(--lift) 0 var(--danger); }
.push-device { display: grid; gap: 0.6rem; margin-bottom: 0.9rem; }
.push-status { font-weight: 700; }
.push-status.is-ok { color: var(--ok); }
.push-status.is-warn { color: var(--warn); }
.notify-form { margin-top: 0.9rem; }
.logout { display: flex; justify-content: center; }

/* ---------- Inloggning ---------- */

.login { max-width: 460px; margin: 0 auto; padding-top: max(3vh, env(safe-area-inset-top)); display: grid; gap: 1.1rem; justify-items: center; text-align: center; }
.login-logo { rotate: -6deg; filter: drop-shadow(4px 4px 0 var(--edge)); }
.login-title { font-size: 2.4rem; }
.login-adult { width: 100%; text-align: left; }
.login-switch { font-weight: 800; color: var(--muted); text-underline-offset: 4px; padding: 0.5rem; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; width: 100%; }
.who-card {
    display: grid; justify-items: center; gap: 0.6rem;
    padding: 1.4rem 1rem 1.1rem;
    background: var(--kid-soft);
    border: 3px solid var(--line);
    border-radius: 28px;
    box-shadow: 5px 5px 0 var(--edge);
    text-decoration: none;
}
.who-card:active { translate: 4px 4px; box-shadow: 1px 1px 0 var(--edge); }
.who-card .sticker-avatar { width: 96px; height: 96px; font-size: 3.4rem; background: var(--card); }
.who-name { font-size: 1.5rem; font-weight: 800; }

.pin-form { display: grid; gap: 1rem; justify-items: center; width: 100%; }
.pin-who { display: grid; gap: 0.35rem; justify-items: center; }
.pin-who p { font-weight: 700; color: var(--muted); }
.pin-dots { display: flex; gap: 0.9rem; }
.pin-dots span { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); background: var(--card); transition: background 120ms ease, transform 120ms ease; }
.pin-dots span.filled { background: var(--kid); transform: scale(1.1); }
.pin-form.is-wrong .pin-dots { animation: shake 400ms ease; }
@keyframes shake { 20%, 60% { translate: -10px 0; } 40%, 80% { translate: 10px 0; } }
.pin-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pin-error { min-height: 1.5em; font-weight: 800; color: var(--warn); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 84px); gap: 0.8rem; }
.pin-pad button, .pin-back {
    display: grid; place-items: center;
    height: 72px;
    font: inherit; font-size: 2rem; font-weight: 800;
    color: var(--ink);
    background: var(--card);
    border: 3px solid var(--line);
    border-radius: 24px;
    box-shadow: 4px 4px 0 var(--edge);
    text-decoration: none;
    cursor: pointer;
}
.pin-pad button:active, .pin-back:active { translate: 4px 4px; box-shadow: none; }
.pin-back, .pin-pad [data-pin-erase] { background: transparent; box-shadow: none; border-style: dashed; font-size: 1.6rem; }

/* ---------- Feedback: toast, konfetti, flygande stjärna ---------- */

.toast {
    position: fixed; z-index: 50;
    left: 50%; bottom: calc(110px + env(safe-area-inset-bottom));
    translate: -50% 0;
    max-width: calc(100% - 32px);
    padding: 0.65rem 1.2rem;
    font-weight: 800;
    background: var(--card);
    border: 3px solid var(--line);
    border-radius: 22px;
    box-shadow: 4px 4px 0 var(--edge);
    text-align: center;
}
html[data-mode="adult"] .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
.toast.is-error { background: var(--warn-soft); }
.toast.is-in { animation: toast-in 260ms cubic-bezier(.3,1.6,.5,1); }
@keyframes toast-in { from { translate: -50% 30px; opacity: 0; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.flying-star {
    position: fixed; z-index: 61; pointer-events: none;
    font-size: 1.3rem; font-weight: 800; color: #24213d;
    display: flex; align-items: center; gap: 0.2rem;
    padding: 0.1rem 0.6rem;
    background: var(--star); border: 3px solid var(--line); border-radius: 999px;
    box-shadow: 3px 3px 0 var(--edge);
}

.empty-state { max-width: 420px; margin: 10vh auto; text-align: center; display: grid; gap: 0.6rem; }
.empty-emoji { font-size: 3rem; }

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