/* =========================================================
   Famli – grafisk profil
   Leken, fargerik og tydelig. Store trykkflater for små fingre.
   ========================================================= */

:root {
    --bg: #FFF7EC;
    --bg-dots: #FFE9C9;
    --surface: #FFFFFF;
    --surface-2: #F7F3FF;
    --ink: #2B2250;
    --muted: #7A7399;
    --border: #EEE6FF;

    --primary: #7B5CFF;
    --primary-dark: #5A3FD9;
    --primary-soft: #EDE7FF;
    --sun: #FFC93C;
    --sun-dark: #E0A800;
    --sun-soft: #FFF3CF;
    --coral: #FF6B6B;
    --coral-dark: #E04848;
    --coral-soft: #FFE3E3;
    --mint: #2EC4B6;
    --mint-dark: #1FA195;
    --mint-soft: #DDF7F4;
    --sky: #4D96FF;
    --sky-soft: #E1EEFF;
    --pink: #FF6F91;

    --radius-sm: 12px;
    --radius: 20px;
    --radius-lg: 28px;
    --shadow: 0 6px 20px rgba(60, 40, 140, .08);
    --shadow-lg: 0 12px 32px rgba(60, 40, 140, .14);

    --font-display: "Fredoka", "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
    --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

    --nav-height: 72px;
    --header-height: 64px;
    --page-width: 720px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    background-color: var(--bg);
    background-image: radial-gradient(var(--bg-dots) 1.5px, transparent 1.5px);
    background-size: 22px 22px;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.15;
    margin: 0 0 .5rem;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a { color: var(--primary-dark); }
p { margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mt-lg { margin-top: 2rem; }
.mb { margin-bottom: 1rem; }
.row { display: flex; align-items: center; gap: .75rem; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .75rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Page shell ---------- */

.page {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 1rem 16px calc(var(--nav-height) + 2rem + env(safe-area-inset-bottom));
}

.page.no-nav { padding-bottom: 2rem; }

.page-title {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .5rem 0 1.25rem;
}

.page-title h1 { margin: 0; }

.page-title .emoji {
    font-size: 2rem;
    width: 56px; height: 56px;
    display: grid; place-items: center;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

/* ---------- Header ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 247, 236, .88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding-top: env(safe-area-inset-top);
}

.app-header-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -.01em;
}

.brand-logo {
    width: 40px; height: 40px;
    border-radius: 13px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    box-shadow: 0 4px 0 var(--primary-dark);
    transform: rotate(-6deg);
}

.brand-logo svg { width: 26px; height: 26px; }
.brand span b { color: var(--primary); font-weight: 700; }

.points-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    background: var(--sun-soft);
    color: #8A5A00;
    font-family: var(--font-display);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

/* ---------- Avatar ---------- */

.avatar {
    --size: 44px;
    width: var(--size); height: var(--size);
    border-radius: 50%;
    display: inline-grid; place-items: center;
    font-size: calc(var(--size) * .55);
    background: var(--c, var(--primary));
    box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), 0 0 0 3px #fff;
    flex-shrink: 0;
    text-decoration: none;
    line-height: 1;
}

.avatar.has-photo { overflow: hidden; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

.avatar.sm { --size: 32px; }
.avatar.lg { --size: 72px; }
.avatar.xl { --size: 96px; }

/* ---------- Bottom navigation ---------- */

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    padding: 0 12px calc(10px + env(safe-area-inset-bottom));
    pointer-events: none;
}

.bottom-nav-inner {
    pointer-events: auto;
    max-width: 560px;
    margin: 0 auto;
    height: var(--nav-height);
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: stretch;
    padding: 6px;
    gap: 4px;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 18px;
    text-decoration: none;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    position: relative;
    transition: background .15s, color .15s, transform .15s;
}

.nav-item .icon { font-size: 1.45rem; line-height: 1; transition: transform .2s; }
.nav-item:hover { color: var(--ink); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav-item.active .icon { transform: scale(1.15) rotate(-4deg); }

.nav-badge {
    position: absolute;
    top: 4px; right: calc(50% - 22px);
    min-width: 20px; height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--coral);
    color: #fff;
    font-size: .7rem;
    display: grid; place-items: center;
    box-shadow: 0 0 0 2px #fff;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.card + .card { margin-top: 1rem; }
.card-title { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }

.section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 1.75rem 0 .75rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.section-title .count {
    font-size: .85rem;
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: .1rem .6rem;
    border-radius: 999px;
}

/* ---------- Hero / status ---------- */

.hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, #7B5CFF 0%, #A55CFF 45%, #FF6F91 100%);
    box-shadow: 0 8px 0 #5A3FD9, var(--shadow-lg);
    margin-bottom: 1.5rem;
}

.hero::before, .hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
}
.hero::before { width: 180px; height: 180px; right: -50px; top: -60px; }
.hero::after { width: 110px; height: 110px; right: 70px; bottom: -60px; }

.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: 1.6rem; margin: 0; }
.hero .greeting { opacity: .9; font-weight: 700; }

.level-row { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .5rem; margin-top: 1rem; font-weight: 800; }
.level-row .small { white-space: nowrap; }

.level-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgba(255,255,255,.22);
    padding: .25rem .7rem;
    border-radius: 999px;
    font-family: var(--font-display);
    font-weight: 600;
    white-space: nowrap;
}

.progress {
    height: 16px;
    border-radius: 999px;
    background: rgba(255,255,255,.25);
    overflow: hidden;
    margin-top: .5rem;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--sun);
    background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.35) 0 8px, transparent 8px 16px);
    background-size: 23px 23px;
    animation: stripes 1s linear infinite;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
    transition: width .8s cubic-bezier(.2,.9,.3,1.2);
    min-width: 16px;
}

@keyframes stripes { to { background-position: 23px 0; } }

.stat-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: 1rem; }

.stat-chip {
    background: rgba(255,255,255,.18);
    border-radius: 16px;
    padding: .55rem .5rem;
    text-align: center;
}

.stat-chip .value { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; display: block; line-height: 1.1; }
.stat-chip .label { font-size: .72rem; opacity: .9; font-weight: 800; }

/* ---------- Alerts / banners ---------- */

.banner {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .9rem 1rem;
    border-radius: var(--radius);
    background: var(--sun-soft);
    color: #6B4700;
    text-decoration: none;
    font-weight: 800;
    margin-bottom: 1rem;
    box-shadow: 0 4px 0 #F3DE9B;
}

.banner .emoji { font-size: 1.6rem; }
.banner.info { background: var(--sky-soft); color: #1D4E9E; box-shadow: 0 4px 0 #BFD7FB; }

/* ---------- Chore cards ---------- */

.chore-list { display: flex; flex-direction: column; gap: .75rem; }

.chore {
    display: flex;
    align-items: center;
    gap: .9rem;
    background: var(--surface);
    border-radius: var(--radius);
    padding: .85rem;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: transform .15s, opacity .2s;
}

.chore:hover { transform: translateY(-2px); }

.chore-icon {
    width: 58px; height: 58px;
    flex-shrink: 0;
    display: grid; place-items: center;
    font-size: 1.9rem;
    border-radius: 18px;
    background: var(--tint, var(--primary-soft));
}

.chore:nth-child(5n+1) { --tint: var(--primary-soft); }
.chore:nth-child(5n+2) { --tint: var(--mint-soft); }
.chore:nth-child(5n+3) { --tint: var(--sun-soft); }
.chore:nth-child(5n+4) { --tint: var(--coral-soft); }
.chore:nth-child(5n+5) { --tint: var(--sky-soft); }

.chore-body { flex: 1; min-width: 0; }
.chore-title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; line-height: 1.2; }
.chore-desc { color: var(--muted); font-size: .85rem; margin-top: .1rem; }
.chore-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }

.tag {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 800;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}

.tag.points { background: var(--sun-soft); color: #8A5A00; }
.tag.money { background: var(--mint-soft); color: #11756C; }
.tag.mine { background: var(--primary-soft); color: var(--primary-dark); }
.tag.pending { background: var(--sky-soft); color: #1D4E9E; }
.tag.off { background: #EEE; color: #888; }

.chore.is-pending { border-color: var(--sky-soft); }
.chore.is-done { opacity: .62; box-shadow: none; background: rgba(255,255,255,.6); }
.chore.is-done .chore-title { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--mint); }

.done-stamp {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--mint);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: inset 0 -4px 0 rgba(0,0,0,.15);
    flex-shrink: 0;
}

.done-stamp.other { background: var(--surface-2); font-size: 1.5rem; box-shadow: none; }

.approval-actions { flex-basis: 100%; display: grid; grid-template-columns: 1fr 1.6fr; gap: .6rem; }
.approval-actions form { margin: 0; }

/* ---------- Buttons ---------- */

.btn {
    --b: var(--primary);
    --b-dark: var(--primary-dark);
    --b-text: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .75rem 1.25rem;
    min-height: 48px;
    border: 0;
    border-radius: 16px;
    background: var(--b);
    color: var(--b-text);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--b-dark);
    transform: translateY(0);
    transition: transform .08s, box-shadow .08s, filter .15s;
    user-select: none;
    white-space: nowrap;
}

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(5px); box-shadow: 0 0 0 var(--b-dark); }
.btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

.btn.block { width: 100%; }
.btn.lg { min-height: 58px; font-size: 1.2rem; border-radius: 18px; }
.btn.sm { min-height: 38px; padding: .4rem .85rem; font-size: .9rem; border-radius: 12px; box-shadow: 0 3px 0 var(--b-dark); }
.btn.sm:active { transform: translateY(3px); }

.btn.success { --b: var(--mint); --b-dark: var(--mint-dark); }
.btn.sun { --b: var(--sun); --b-dark: var(--sun-dark); --b-text: #5A3B00; }
.btn.danger { --b: var(--coral); --b-dark: var(--coral-dark); }
.btn.ghost { --b: var(--surface); --b-dark: var(--border); --b-text: var(--ink); }
.btn.link { background: none; box-shadow: none; color: var(--primary-dark); padding: .25rem .5rem; min-height: auto; font-size: .9rem; }
.btn.link:active { transform: none; }

.btn-done {
    --b: var(--mint);
    --b-dark: var(--mint-dark);
    width: 62px; height: 62px;
    min-height: 0;
    padding: 0;
    border-radius: 50%;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.btn-done .label { display: none; }

@media (min-width: 520px) {
    .btn-done { width: auto; height: 52px; border-radius: 16px; padding: 0 1rem; font-size: 1.05rem; }
    .btn-done .label { display: inline; }
}

form.inline { display: inline; margin: 0; }

.invite-link { display: grid; gap: .4rem; padding: .75rem 0; border-top: 1px dashed var(--line, #e5e0f0); }
.invite-link .input { font-size: .85rem; font-family: ui-monospace, monospace; }
.chore-actions { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.chore-actions .btn.link { padding: 0; font-size: .75rem; }
.chore-actions form { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.btn-done.uploading { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* Photo documentation */
.photo-thumb {
    width: 64px; height: 64px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    cursor: zoom-in;
}

.photo-full { width: 100%; max-height: 75vh; object-fit: contain; border-radius: var(--radius); background: #000; }

/* ---------- Forms ---------- */

.form-card { max-width: 480px; margin: 0 auto; }

.field { margin-bottom: 1rem; }

.field > label, .label {
    display: block;
    font-weight: 800;
    margin-bottom: .35rem;
    font-size: .95rem;
}

.input, select.input, textarea.input {
    width: 100%;
    padding: .8rem 1rem;
    min-height: 52px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    transition: border-color .15s, box-shadow .15s;
}

textarea.input { min-height: 90px; resize: vertical; }

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.input.input-validation-error { border-color: var(--coral); }

.field-validation-error, .validation-summary-errors {
    color: var(--coral-dark);
    font-size: .875rem;
    font-weight: 800;
    margin-top: .3rem;
    display: block;
}

.validation-summary-errors ul { margin: 0 0 1rem; padding: .75rem 1rem .75rem 2rem; background: var(--coral-soft); border-radius: 14px; }
.validation-summary-valid { display: none; }

.check {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--surface-2);
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    margin-bottom: .6rem;
}

.check input { width: 22px; height: 22px; accent-color: var(--primary); flex-shrink: 0; }
.check .hint { display: block; font-weight: 600; color: var(--muted); font-size: .82rem; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.grid-2 > *, .input { min-width: 0; }

/* Emoji / colour pickers built from radio buttons */
.picker { display: flex; flex-wrap: wrap; gap: .45rem; }
.picker input { position: absolute; opacity: 0; pointer-events: none; }

.picker label {
    width: 48px; height: 48px;
    display: grid; place-items: center;
    font-size: 1.5rem;
    border-radius: 14px;
    background: var(--surface-2);
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform .12s, border-color .12s;
}

.picker label:hover { transform: scale(1.08); }
.picker input:checked + label { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.08); }
.picker input:focus-visible + label { outline: 3px solid var(--sun); }

.picker.colors label { border-radius: 50%; background: var(--c); }
.picker.colors input:checked + label { border-color: var(--ink); box-shadow: inset 0 0 0 3px #fff; }

.segmented {
    display: flex;
    background: var(--surface-2);
    border-radius: 16px;
    padding: 4px;
    gap: 4px;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label, .segmented a {
    flex: 1;
    text-align: center;
    padding: .6rem .5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 800;
    color: var(--muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.segmented button {
    flex: 1;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 800;
    color: var(--muted);
    padding: .6rem .5rem;
    border-radius: 12px;
    cursor: pointer;
}

.family-switch { margin-bottom: 1rem; padding: .9rem; }
.family-switch .label { margin-bottom: .5rem; }

.segmented input:checked + label, .segmented a.active, .segmented button.active {
    background: var(--surface);
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(60,40,140,.1);
}

/* Wrapping choice chips (radio or checkbox) */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .45rem; }
.chips.days { grid-template-columns: repeat(7, 1fr); gap: .3rem; }
.chips > span[hidden] { display: none; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }

.chips label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    min-height: 48px;
    height: 100%;
    text-align: center;
    line-height: 1.15;
    padding: .5rem .4rem;
    border-radius: 14px;
    background: var(--surface-2);
    border: 2px solid transparent;
    font-weight: 800;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}

.chips.days label { padding: .5rem 0; text-transform: capitalize; white-space: nowrap; }
.chips input:checked + label { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.chips input:focus-visible + label { outline: 3px solid var(--sun); }

[hidden] { display: none !important; }

/* ---------- Routines (checklist) ---------- */

.routine-group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .4rem; }
.routine-group + .routine-group { margin-top: .75rem; }

.routine-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .6rem .35rem;
    font-family: var(--font-display);
    font-weight: 600;
}

.routine-head .progress { flex: 1; height: 10px; margin: 0 0 0 .5rem; background: var(--surface-2); max-width: 140px; }
.routine-head .progress-bar { background-color: var(--mint); min-width: 0; animation: none; }
.routine-group.now { box-shadow: 0 0 0 3px var(--sun), var(--shadow); }

.routine {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .6rem;
    border-radius: 14px;
}

.routine + .routine { border-top: 2px solid var(--surface-2); }
.routine .r-icon { font-size: 1.5rem; width: 36px; text-align: center; }
.routine .r-title { flex: 1; font-weight: 800; }
.routine.done .r-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--mint); text-decoration-thickness: 2px; }

.tick {
    width: 44px; height: 44px;
    border-radius: 14px;
    border: 3px solid var(--border);
    background: var(--surface);
    display: grid; place-items: center;
    font-size: 1.3rem;
    color: transparent;
    cursor: pointer;
    transition: transform .1s, background .15s, border-color .15s;
    padding: 0;
}

.tick:hover { border-color: var(--mint); }
.tick:active { transform: scale(.9); }
.tick.on { background: var(--mint); border-color: var(--mint); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }

.tag.overdue { background: var(--coral-soft); color: var(--coral-dark); }
.chore.is-overdue { border-color: var(--coral-soft); }

/* ---------- Lists (members, approvals, wallet) ---------- */

.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.list-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1rem;
    text-decoration: none;
    color: inherit;
}

.list-item + .list-item { border-top: 2px solid var(--surface-2); }
a.list-item:hover { background: var(--surface-2); }
.list-item .title { font-weight: 800; }
.list-item .sub { color: var(--muted); font-size: .85rem; }
.list-item .chev { color: var(--muted); font-size: 1.2rem; }

.amount { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; white-space: nowrap; }
.amount.plus { color: var(--mint-dark); }
.amount.minus { color: var(--coral-dark); }
.amount.wait { color: var(--muted); }

/* ---------- Wallet ---------- */

.wallet-hero {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: linear-gradient(135deg, #2EC4B6 0%, #4D96FF 100%);
    color: #fff;
    box-shadow: 0 8px 0 #1F8FA3, var(--shadow-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.wallet-hero .big { font-family: var(--font-display); font-size: 3rem; font-weight: 700; line-height: 1; margin: .35rem 0; }
.wallet-hero .piggy { font-size: 3rem; display: inline-block; animation: bob 2.4s ease-in-out infinite; }

@keyframes bob { 50% { transform: translateY(-6px) rotate(4deg); } }

.wallet-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }

/* ---------- Leaderboard ---------- */

.podium {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
    gap: .5rem;
    margin: 1.5rem 0 1rem;
    text-align: center;
}

.podium-spot .name { font-weight: 800; margin-top: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-spot .pts { font-size: .85rem; color: var(--muted); font-weight: 800; }

.podium-block {
    margin-top: .5rem;
    border-radius: 16px 16px 6px 6px;
    display: grid; place-items: center;
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
}

.podium-spot.p1 .podium-block { height: 110px; background: linear-gradient(var(--sun), #FFB200); box-shadow: 0 5px 0 var(--sun-dark); }
.podium-spot.p2 .podium-block { height: 80px; background: linear-gradient(#C9C3E6, #A9A1D4); box-shadow: 0 5px 0 #8C84BC; }
.podium-spot.p3 .podium-block { height: 60px; background: linear-gradient(#FFB38A, #FF9671); box-shadow: 0 5px 0 #E07A55; }
.podium-spot.p1 .avatar { animation: bob 2s ease-in-out infinite; }
.crown { font-size: 1.6rem; display: block; margin-bottom: -.4rem; }

.rank {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface-2);
    font-family: var(--font-display);
    font-weight: 600;
    flex-shrink: 0;
}

.list-item.me { background: var(--primary-soft); }

/* ---------- Child login ("Hvem er du?") ---------- */

.kid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.kid-grid input { position: absolute; opacity: 0; pointer-events: none; }

.kid-grid label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 1rem .5rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform .12s, border-color .12s;
}

.kid-grid label:hover { transform: translateY(-3px); }
.kid-grid input:checked + label { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.04); }
.kid-grid input:focus-visible + label { outline: 3px solid var(--sun); }
.kid-name { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }

.pin-input, .code-input {
    text-align: center;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: .4em;
    min-height: 64px;
}

.code-input { text-transform: uppercase; letter-spacing: .25em; }

/* ---------- Impersonation ("bruk appen som …") ---------- */

.impersonation-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: calc(.5rem + env(safe-area-inset-top)) 16px .5rem;
    background: var(--primary);
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
}

.impersonation-bar.admin { background: var(--ink); }
.impersonation-bar + .app-header { top: 52px; }

.admin-stats .stat-chip { background: var(--surface); box-shadow: var(--shadow); }

/* ---------- Parents' overview ---------- */

.child-cards { display: flex; flex-direction: column; gap: .6rem; }

.child-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    border: 2px solid transparent;
    transition: transform .12s;
}

.child-card:hover { transform: translateY(-2px); }
.child-card.all-done { border-color: var(--mint-soft); }
.child-card .chev { color: var(--muted); font-size: 1.2rem; }
.child-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.child-body .title { font-weight: 800; }

.mini-row { display: flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 800; color: var(--muted); }
.mini-label { width: 6.2rem; white-space: nowrap; }
.mini-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: var(--mint); border-radius: 99px; }
.mini-bar.tasks > span { background: var(--sun); }
.mini-count { width: 2.5rem; text-align: right; }

.day-nav-label { flex: 1; text-align: center; display: flex; flex-direction: column; line-height: 1.2; }

.status-row { align-items: flex-start; }
.status-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    flex-shrink: 0;
    font-weight: 800;
    font-size: .9rem;
    margin-top: .1rem;
}

.st-done .status-icon { background: var(--mint); color: #fff; }
.st-pending .status-icon { background: var(--sky-soft); color: #1D4E9E; }
.st-notdone .status-icon { background: var(--surface-2); color: var(--muted); border: 2px dashed var(--border); }
.st-skipped .status-icon { background: var(--surface-2); }
.st-info .status-icon { background: var(--sun-soft); color: #8A5A00; }
.status-row .r-icon { font-size: 1.4rem; margin-top: .05rem; }

.people-status { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }

.person-chip-sm {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 800;
    background: var(--surface-2);
    color: var(--muted);
}

.person-chip-sm.st-done { background: var(--mint-soft); color: #11756C; }
.person-chip-sm.st-pending { background: var(--sky-soft); color: #1D4E9E; }
.person-chip-sm a { text-decoration: none; }

/* ---------- Calendar ---------- */

.week-nav { display: flex; align-items: center; gap: .4rem; margin-bottom: .75rem; }
.week-nav .btn.sm { min-width: 44px; }

.person-filter { display: flex; gap: .4rem; overflow-x: auto; padding: .25rem 0 .75rem; scrollbar-width: none; }
.person-filter::-webkit-scrollbar { display: none; }

.person-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .35rem .8rem .35rem .4rem;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    font-size: .88rem;
    white-space: nowrap;
    border: 2px solid transparent;
}

.person-chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

.cal-day { margin-bottom: .9rem; }
.cal-day.past { opacity: .6; }

.cal-day-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }

.cal-date {
    width: 46px; height: 46px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.cal-dow { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: var(--muted); }
.cal-num { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; }
.cal-day.today .cal-date { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.cal-day.today .cal-dow { color: rgba(255,255,255,.85); }
.cal-day-label { font-family: var(--font-display); font-weight: 600; text-transform: capitalize; }
.cal-day.today .cal-day-label { color: var(--primary-dark); }
.cal-empty { color: var(--muted); font-size: .85rem; padding: .1rem 0 .2rem 3.35rem; }

.cal-items { display: flex; flex-direction: column; gap: .45rem; padding-left: 3.35rem; }

.cal-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .75rem;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--ec, var(--primary));
    color: inherit;
    text-decoration: none;
    transition: transform .12s;
}

.cal-item:hover { transform: translateX(3px); }
.cal-time { display: flex; flex-direction: column; font-size: .8rem; line-height: 1.15; min-width: 2.6rem; text-align: center; }
.cal-time b { font-family: var(--font-display); font-size: .95rem; }
.cal-icon { font-size: 1.5rem; }
.cal-body { flex: 1; min-width: 0; }
.cal-title { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-meta { display: flex; gap: .5rem; font-size: .78rem; color: var(--muted); overflow: hidden; white-space: nowrap; }
.cal-people { display: flex; align-items: center; }

/* Multi-day events: thicker edge so they read as a "band" across the days */
.cal-item.multi-day { border-left-width: 8px; }
.day-of { color: var(--primary-dark); font-weight: 800; }

/* Events from another family (shared with us): dashed edge, read-only */
.cal-item.foreign { background: var(--surface-2); border-left-style: dashed; }
.from-family { color: var(--primary-dark); font-weight: 800; }
.share-check { background: var(--primary-soft); }

.link-child summary { cursor: pointer; list-style: none; }
.link-child summary::-webkit-details-marker { display: none; }
.link-child[open] summary { margin-bottom: .25rem; }
.cal-people .avatar + .avatar { margin-left: -8px; }

@media (max-width: 420px) {
    .cal-items, .cal-empty { padding-left: 0; }
}

.detail-row { display: flex; gap: .75rem; padding: .55rem 0; align-items: flex-start; }
.detail-row + .detail-row { border-top: 2px solid var(--surface-2); }
.detail-row > span:first-child { width: 1.5rem; text-align: center; }

.chips.people { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.chips.people label { justify-content: flex-start; gap: .4rem; }

/* Today page: today's events */
.today-events { display: flex; flex-direction: column; gap: .45rem; }

/* ---------- Install (PWA) ---------- */

.install-banner { background: var(--primary-soft); color: var(--primary-dark); box-shadow: 0 4px 0 #D9CCFF; text-align: left; }

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(43, 34, 80, .45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity .25s;
}

.sheet-backdrop.show { opacity: 1; }

.sheet {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: 28px 28px 0 0;
    padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    text-align: center;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.2,.9,.3,1.1);
    max-height: 90vh;
    overflow-y: auto;
}

.sheet-backdrop.show .sheet { transform: translateY(0); }
.sheet h2 { font-size: 1.35rem; margin-top: .5rem; }
.sheet-icon { border-radius: 18px; box-shadow: var(--shadow); }

.sheet-close {
    position: absolute;
    top: .75rem; right: .75rem;
    width: 36px; height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
}

.steps { list-style: none; padding: 0; margin: 1rem 0 0; text-align: left; }
.steps li { display: flex; gap: .75rem; align-items: flex-start; padding: .7rem 0; }
.steps li + li { border-top: 2px solid var(--surface-2); }
.steps .hint { display: block; color: var(--muted); font-size: .85rem; font-weight: 600; }

.step-no {
    width: 30px; height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
}

.ios-icon { width: 22px; height: 22px; vertical-align: -5px; color: #0A84FF; margin: 0 .15rem; }

/* ---------- Legal text ---------- */

.legal { line-height: 1.6; }
.legal h2 { font-size: 1.2rem; margin-top: 1.75rem; }
.legal h3 { font-size: 1rem; margin-top: 1rem; color: var(--primary-dark); }
.legal ul { padding-left: 1.25rem; margin: 0 0 .75rem; }
.legal li + li { margin-top: .3rem; }
.legal .lead { font-size: 1.05rem; }
.legal code { background: var(--surface-2); padding: 0 .3rem; border-radius: 6px; }

.footer-links { text-align: center; margin: 2rem 0 0; font-size: .85rem; }
.footer-links a { color: var(--muted); }

/* ---------- Invite code ---------- */

.code {
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: .25em;
    font-weight: 700;
    padding: .5rem 1rem;
    background: var(--surface-2);
    border-radius: 14px;
    display: inline-block;
    border: 2px dashed var(--primary);
    color: var(--primary-dark);
}

/* ---------- Empty states ---------- */

.empty {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty .emoji { font-size: 3.5rem; display: block; margin-bottom: .5rem; animation: bob 2.4s ease-in-out infinite; }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    top: calc(12px + env(safe-area-inset-top));
    transform: translate(-50%, -150%);
    z-index: 100;
    background: var(--ink);
    color: #fff;
    padding: .8rem 1.2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    font-weight: 800;
    max-width: calc(100vw - 32px);
    transition: transform .35s cubic-bezier(.2,.9,.3,1.3);
}

.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--coral-dark); }

/* Celebration popup */
.celebrate {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(43, 34, 80, .35);
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}

.celebrate.show { opacity: 1; pointer-events: auto; }

.celebrate-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.5rem 1.5rem;
    text-align: center;
    max-width: 340px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(.6) rotate(-4deg);
    transition: transform .4s cubic-bezier(.2,.9,.3,1.5);
}

.celebrate.show .celebrate-card { transform: scale(1) rotate(0); }
.celebrate-card .burst { font-size: 3.5rem; display: block; animation: bob 1.6s ease-in-out infinite; }
.celebrate-card h2 { font-size: 1.7rem; margin: .5rem 0 .25rem; color: var(--primary-dark); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 95; }

/* ---------- Landing ---------- */

.landing { text-align: center; padding-top: 1rem; }

.landing-art {
    position: relative;
    width: 220px; height: 220px;
    margin: 1rem auto 1.5rem;
}

.landing-art .blob {
    position: absolute; inset: 0;
    border-radius: 42% 58% 55% 45% / 50% 40% 60% 50%;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    box-shadow: 0 10px 0 var(--primary-dark);
    animation: morph 8s ease-in-out infinite;
}

.landing-art .main { position: absolute; inset: 0; display: grid; place-items: center; font-size: 6rem; }
.landing-art .float { position: absolute; font-size: 2.2rem; animation: bob 3s ease-in-out infinite; }
.landing-art .f1 { top: -10px; left: -10px; }
.landing-art .f2 { top: 10px; right: -24px; animation-delay: .6s; }
.landing-art .f3 { bottom: -6px; left: -22px; animation-delay: 1.2s; }
.landing-art .f4 { bottom: -14px; right: 0; animation-delay: 1.8s; }

@keyframes morph {
    50% { border-radius: 58% 42% 45% 55% / 40% 60% 40% 60%; transform: rotate(6deg); }
}

.landing h1 { font-size: 2.3rem; }
.landing .lead { font-size: 1.15rem; color: var(--muted); max-width: 440px; margin: 0 auto 1.5rem; }
.landing .actions { display: flex; flex-direction: column; gap: 1rem; max-width: 340px; margin: 0 auto; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-top: 2.5rem; text-align: left; }
.feature { background: var(--surface); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.feature .emoji { font-size: 2rem; }
.feature h3 { margin: .35rem 0 .2rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
