[hidden] { display: none !important; }

:root {
    --bg: #f4efe6;
    --ink: #1b1713;
    --muted: #6a6258;
    --card: #fffdf9;
    --line: rgba(27, 23, 19, 0.08);
    --hero: #d24b1a;
    --hero-2: #f06a32;
    --gold: #e8b23a;
    --ok: #1a7a52;
    --ok-soft: #e5f5ee;
    --bad: #b42318;
    --bad-soft: #fdecea;
    --shadow: 0 1px 2px rgba(27, 23, 19, 0.04), 0 10px 28px rgba(27, 23, 19, 0.06);
    --radius: 18px;
    --tap: 48px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--hero); }
button, input, select { font: inherit; }
img { max-width: 100%; display: block; }

.app {
    width: min(430px, 100%);
    margin: 0 auto;
    padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
}
.app-bare { padding-bottom: 32px; width: min(430px, 100%); }
.mode-parent .app { width: min(520px, 100%); }

.brand {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--hero);
}
h1 { font-size: 1.65rem; margin: 0.2em 0 0.25em; letter-spacing: -0.03em; line-height: 1.15; }
h2, .h2 { font-size: 0.95rem; margin: 1.5rem 0 0.65rem; letter-spacing: -0.01em; }
.lead, .muted, .fine { color: var(--muted); margin: 0; }
.lead { margin-bottom: 1rem; }
.fine { font-size: 0.8rem; margin-top: 0.8rem; }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.68rem; color: var(--muted); margin: 0 0 0.15rem; font-weight: 700; }
.top { margin-bottom: 1.1rem; }
.back {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 650;
    text-decoration: none;
    margin-bottom: 0.35rem;
}

.sheet { padding-top: 1.2rem; }
.center { text-align: center; }
.stack { display: grid; gap: 0.8rem; }
label { display: grid; gap: 0.35rem; font-weight: 650; font-size: 0.88rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=file], select {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 0.75rem 0.9rem;
}
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 500; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.05rem;
    margin: 0 0 0.75rem;
}
.card.soft { box-shadow: none; }
.card.slim { padding: 0.8rem 1rem; }
.card.warn { border-color: #f0c9a0; background: #fff8f0; }
.goal h2 { margin: 0.15rem 0 0.55rem; font-size: 1.15rem; }
.goal p:last-child { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.88rem; }

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: var(--tap);
    border: 0;
    border-radius: 14px;
    padding: 0.7rem 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    color: var(--ink);
    background: #efe8de;
}
.btn-hero { background: var(--hero); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn.is-on { box-shadow: inset 0 0 0 2px var(--ink); }
.row { display: flex; gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; }
.row .btn { flex: 1; }
.linkish { background: none; border: 0; color: var(--hero); font-weight: 700; cursor: pointer; padding: 0.4rem; min-height: auto; }

.flash { border-radius: 14px; padding: 0.75rem 1rem; margin-bottom: 0.8rem; font-weight: 600; }
.flash-ok { background: var(--ok-soft); color: #145c3d; }
.flash-error { background: var(--bad-soft); color: #8a1c14; }

.who { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-bottom: 1rem; }
.who-card {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 1.15rem 0.7rem 1rem;
    display: grid;
    justify-items: center;
    gap: 0.3rem;
    cursor: pointer;
    color: inherit;
    min-height: 148px;
}
.who-card img, .who-emoji {
    width: 68px; height: 68px; border-radius: 50%;
    display: grid; place-items: center;
    background: #f3e8dc;
    font-size: 2rem; object-fit: cover;
}
.who-card strong { font-size: 1.05rem; }
.who-card em { font-style: normal; color: var(--muted); font-size: 0.82rem; text-align: center; }
.who-parent { grid-column: 1 / -1; min-height: 0; grid-template-columns: auto 1fr; grid-auto-flow: column; justify-items: start; align-items: center; text-align: left; padding: 0.9rem 1rem; gap: 0.8rem; }
.who-parent .who-emoji { width: 52px; height: 52px; font-size: 1.5rem; }
.who-parent strong, .who-parent em { justify-self: start; }

.avatar {
    --c: var(--hero);
    width: 52px; height: 52px; border-radius: 50%;
    display: grid; place-items: center;
    background: #f3e8dc;
    font-size: 1.5rem; flex-shrink: 0;
}
.avatar.sm { width: 42px; height: 42px; font-size: 1.2rem; }

.hello { display: flex; align-items: center; gap: 0.75rem; }
.hello h1 { margin: 0; }
.streak {
    margin-left: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.4rem 0.7rem;
    font-weight: 800;
    font-size: 0.9rem;
}

.ring-wrap { position: relative; width: 200px; height: 200px; margin: 0.4rem auto 0.3rem; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #eadfd2; stroke-width: 11; }
.ring-fg { fill: none; stroke: var(--hero); stroke-width: 11; stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label strong { font-size: 2.7rem; letter-spacing: -0.04em; line-height: 1; }
.ring-label span { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.target-line { text-align: center; color: var(--muted); margin: 0 0 1rem; font-size: 0.92rem; }

.bar { height: 8px; background: #eadfd2; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--hero); }
.bar.gold i { background: var(--gold); }

.quests { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.quest button {
    width: 100%;
    display: flex; align-items: center; gap: 0.7rem;
    text-align: left; border: 1px solid var(--line); background: var(--card);
    border-radius: 16px; padding: 0.8rem; box-shadow: var(--shadow); cursor: pointer; color: inherit;
    min-height: 64px;
}
.q-icon { font-size: 1.4rem; width: 40px; text-align: center; flex-shrink: 0; }
.q-body { flex: 1; display: grid; gap: 0.2rem; min-width: 0; }
.q-body strong { font-size: 0.95rem; }
.pills { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.pill {
    font-style: normal; font-size: 0.7rem; font-weight: 700;
    background: #f3e8dc; color: var(--ink); border-radius: 999px; padding: 0.12rem 0.45rem;
}
.pill.pts { background: var(--ok-soft); color: var(--ok); }
.q-check {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid #e0cfc0; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 0.85rem;
}
.quest.is-done .q-check { background: var(--ok); border-color: var(--ok); }
.quest.is-done .q-body strong { text-decoration: line-through; opacity: 0.55; }

.shop { display: grid; grid-template-columns: 1fr; gap: 0.65rem; }
@media (min-width: 400px) { .shop { grid-template-columns: 1fr 1fr; } }
.shop-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 0.95rem; box-shadow: var(--shadow); display: grid; gap: 0.4rem; align-content: start; }
.shop-card h3 { margin: 0; font-size: 0.95rem; }
.shop-card p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.shop-ico { font-size: 1.6rem; }
.shop-row { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; }
.cost { font-weight: 800; color: var(--hero); }
.shop-card.cant { opacity: 0.72; }
.balance-chip { display: inline-block; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.7rem; font-weight: 800; }

.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.feed li { display: grid; grid-template-columns: 28px 1fr auto; gap: 0.55rem; align-items: start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem 0.8rem; }
.feed small { display: block; color: var(--muted); }
.plus { color: var(--ok); }
.minus { color: var(--bad); }

.tabbar {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: 0; width: min(430px, 100%);
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: rgba(255, 253, 249, 0.94);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 0.35rem 0.2rem calc(0.4rem + env(safe-area-inset-bottom));
    z-index: 10;
}
.mode-parent .tabbar { width: min(520px, 100%); }
.tabbar a {
    text-decoration: none; color: var(--muted); font-size: 0.68rem; font-weight: 750;
    display: grid; justify-items: center; gap: 0.12rem; padding: 0.25rem 0;
}
.tabbar a span { font-size: 1.15rem; line-height: 1; }
.tabbar a.is-on { color: var(--hero); }

.kid-cards { display: grid; gap: 0.7rem; }
.kid-card { margin: 0; }
.kid-card header { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 0.75rem; }
.kid-card header > div { display: grid; min-width: 0; }
.kid-card header strong { font-size: 1.05rem; }
.kid-card header span + div span { color: var(--muted); font-size: 0.82rem; }

.panel {
    margin-top: 0.75rem;
    padding: 0.55rem;
    background: #f7f2ea;
    border-radius: 14px;
    display: grid;
    gap: 0.4rem;
}
.pick {
    width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
    border: 0; background: #fff; border-radius: 12px; padding: 0.75rem 0.8rem; cursor: pointer;
    min-height: 48px; text-align: left; color: inherit;
}
.pick b { color: var(--ok); flex-shrink: 0; }
.panel-minus .pick b { color: var(--bad); }

.inline-custom {
    display: grid;
    gap: 0.45rem;
    padding-top: 0.25rem;
}
.inline-custom .custom-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 0.45rem;
}
.pending { padding: 0.55rem 0 0; }
.pending + .pending { border-top: 1px solid var(--line); margin-top: 0.55rem; }
.pending p { margin: 0 0 0.5rem; }

.list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.4rem; }
.list li { display: flex; align-items: center; gap: 0.3rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.25rem 0.45rem 0.25rem 0.15rem; }
.list a { flex: 1; display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: inherit; padding: 0.5rem; min-width: 0; }
.list a div { min-width: 0; }
.list small { display: block; color: var(--muted); }
.list em { margin-left: auto; color: var(--muted); flex-shrink: 0; }
.dim { opacity: 0.45; }

.menu { display: grid; gap: 0.4rem; margin: 0.4rem 0 1.2rem; }
.menu a { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.95rem 1rem; text-decoration: none; color: inherit; font-weight: 700; box-shadow: var(--shadow); }

.emoji-grid, .color-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.emoji-pick { position: relative; }
.emoji-pick input { position: absolute; opacity: 0; }
.emoji-pick span {
    display: grid; place-items: center; width: 44px; height: 44px;
    border-radius: 12px; background: #fff; border: 2px solid transparent; font-size: 1.25rem;
}
.emoji-pick input:checked + span { border-color: var(--hero); }
.color-pick { width: 32px; height: 32px; border-radius: 50%; background: var(--c); position: relative; }
.color-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.color-pick:has(input:checked) { outline: 3px solid var(--ink); outline-offset: 2px; }

.pin-input {
    text-align: center; font-size: 1.7rem; letter-spacing: 0.35em;
    width: 11rem; margin: 0 auto; display: block;
}
.keypad {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
    max-width: 248px; margin: 0.5rem auto 0.8rem;
}
.keypad button {
    height: 56px; border: 0; border-radius: 14px; background: #fff;
    border: 1px solid var(--line);
    font-size: 1.25rem; font-weight: 800; cursor: pointer;
}

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.stat { text-align: center; margin: 0; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: 0.8rem; }
.bars { display: flex; align-items: flex-end; gap: 0.4rem; height: 100px; padding: 0.4rem 0 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 0.25rem; }
.bar-col i { width: 100%; max-width: 26px; background: var(--hero); border-radius: 7px 7px 3px 3px; min-height: 4px; }
.bar-col span { font-size: 0.68rem; color: var(--muted); }

.badges { list-style: none; padding: 0; display: grid; gap: 0.4rem; }
.badges li { display: flex; gap: 0.65rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem; }
.badges .off { opacity: 0.38; filter: grayscale(1); }
.badges span { font-size: 1.4rem; }

.empty { color: var(--muted); padding: 0.6rem 0; list-style: none; }
.logout { margin-top: 1.4rem; text-align: center; }

.celebrate {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    place-items: center;
    background: rgba(27, 23, 19, 0.52);
    text-align: center;
    color: #fff;
    pointer-events: none;
}
.celebrate.is-on {
    display: grid;
    pointer-events: auto;
}
.celebrate-points { font-size: 3.4rem; font-weight: 900; margin: 0; }
.celebrate-text { font-size: 1.1rem; font-weight: 700; padding: 0 1.5rem; }
.celebrate-burst {
    width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(circle, var(--gold), transparent 70%);
}

.kid-head { margin-bottom: 0.4rem; }
