:root {
    --bg: #f5efe1;
    --card: #fffdf7;
    --ink: #2b2733;
    --muted: #6d6676;
    --line: #e4dac3;
    --plum: #45346f;
    --plum-soft: #ece6f7;
    --gold: #c08a1e;
    --gold-soft: #fbf0d3;
    --heart: #d64545;
    --ok: #3f7d3a;
    --ok-soft: #e5f1df;
    --warn: #a2611b;
    --warn-soft: #fbead5;
    --earth: #5e8c3a;
    --wind: #4a93c0;
    --water: #2f7fc1;
    --fire: #e2572b;
    --radius: 14px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 Nunito, system-ui, sans-serif;
}
a { color: var(--plum); }
h1, h2, h3 { font-family: Cinzel, Georgia, serif; color: var(--plum); margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
    padding: .6rem 1.25rem;
    background: var(--plum);
    color: #fff;
    border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-family: Cinzel, Georgia, serif; font-weight: 700; font-size: 1.15rem; }
.brand-emblems { display: inline-flex; gap: 2px; background: #fff; border-radius: 999px; padding: 3px 6px; }
.topbar nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.topbar nav a, .topbar .linklike { color: #e9e3f7; text-decoration: none; padding: .35rem .7rem; border-radius: 999px; font-weight: 700; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar form { margin: 0; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--gold); color: #fff; font-size: .75rem; text-align: center; }

.page { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 460px; margin: 3rem auto; padding: 0 1rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.crumbs a { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: 0 1px 0 rgba(0,0,0,.03); }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stack > * + * { margin-top: 1rem; }

.flash { background: var(--ok-soft); border: 1px solid #c4dfb9; color: #24501f; border-radius: 10px; padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 600; }
.flash.error { background: #fbe4e1; border-color: #efc1ba; color: #8a2a1d; }
.tip { background: var(--gold-soft); border: 1px solid #ecd9a4; border-radius: 10px; padding: .6rem .85rem; font-size: .9rem; color: #5c4510; }
.tip strong { color: #4a370b; }
.warn { color: var(--warn); font-weight: 700; }

.btn, button.btn {
    display: inline-flex; align-items: center; gap: .35rem;
    border: 1px solid var(--plum); background: var(--plum); color: #fff;
    border-radius: 999px; padding: .4rem .95rem; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.secondary { background: #fff; color: var(--plum); }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.danger { background: #fff; color: #a3321f; border-color: #e0b1a8; }
.btn.small { padding: .2rem .65rem; font-size: .85rem; }
.btn:hover { filter: brightness(1.08); }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; color: var(--plum); padding: 0; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
    width: 100%; padding: .45rem .6rem; border: 1px solid #d5c9ad; border-radius: 9px; background: #fff; font: inherit; color: var(--ink);
}
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9a7e6; border-color: var(--plum); }
.field { margin-bottom: .8rem; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.check { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; margin-right: .6rem; }
.daypicker { display: flex; gap: .3rem; flex-wrap: wrap; }
.daypicker label { margin: 0; }
.daypicker input { display: none; }
.daypicker span { display: inline-block; min-width: 2.8rem; text-align: center; padding: .3rem .5rem; border: 1px solid #d5c9ad; border-radius: 999px; background: #fff; cursor: pointer; font-weight: 700; font-size: .85rem; }
.daypicker input:checked + span { background: var(--plum); border-color: var(--plum); color: #fff; }

.icon { vertical-align: middle; flex: none; }
.meter { display: flex; flex-wrap: wrap; gap: 1px; align-items: center; }
.meter-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); font-weight: 700; margin: .35rem 0 .1rem; }
.gold-amount { display: inline-flex; align-items: center; gap: .3rem; font-weight: 800; font-size: 1.1rem; color: #7a5810; }

.hero-card { display: grid; grid-template-columns: 124px 1fr; gap: 1rem; align-items: start; }
.hero-card .doll { width: 124px; height: 124px; border-radius: 12px; border: 3px solid var(--line); background: #fff; }
.doll.weary { filter: saturate(.35) brightness(.95); }
.hero-name { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem .4rem; margin-bottom: .1rem; }
.hero-name h2 { margin: 0; font-size: 1.35rem; }
.el-earth { border-color: var(--earth) !important; }
.el-wind { border-color: var(--wind) !important; }
.el-water { border-color: var(--water) !important; }
.el-fire { border-color: var(--fire) !important; }
.pill { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--plum-soft); color: var(--plum); }
.pill.earth { background: #e6efd8; color: #3b4a27; }
.pill.wind { background: #e3f1fa; color: #2c5677; }
.pill.water { background: #dcebf8; color: #1d3f66; }
.pill.fire { background: #fde6da; color: #7a2a1a; }
.pill.weary { background: #efe7e7; color: #7c4b4b; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.progress { height: 8px; background: #efe7d3; border-radius: 999px; overflow: hidden; margin: .25rem 0 .1rem; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #8a6fd1, var(--plum)); }
.hero-links { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; white-space: nowrap; }
.pos { color: var(--ok); font-weight: 800; }
.neg { color: #a3321f; font-weight: 800; }
.type { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .5rem; min-height: 200px; }
.day.today { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.day h3 { font-size: .9rem; margin: 0 0 .4rem; display: flex; justify-content: space-between; }
.slot { display: block; text-decoration: none; color: var(--ink); border-radius: 8px; padding: .35rem .45rem; margin-bottom: .35rem; border-left: 4px solid; font-size: .82rem; line-height: 1.3; }
.slot:hover { filter: brightness(.97); }
.slot .t { font-weight: 800; }
.slot .meta { color: var(--muted); font-size: .75rem; }
.slot.class { background: #ece6f7; border-color: #7a63c2; }
.slot.chore_pack { background: #e6f0de; border-color: #5e8c3a; }
.slot.break { background: #f0ece4; border-color: #b9ad94; }
.day-total { font-size: .75rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: .3rem; margin-top: .3rem; }
.legend { display: flex; gap: .8rem; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .25rem; vertical-align: -1px; }

.agenda-item { display: flex; gap: .8rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.agenda-item:last-child { border-bottom: 0; }
.agenda-time { width: 4.2rem; flex: none; font-weight: 800; color: var(--plum); }
.agenda-body { flex: 1; }
.chores { list-style: none; padding: 0; margin: .3rem 0 0; }
.chores li { display: flex; justify-content: space-between; gap: .5rem; align-items: center; padding: .2rem 0; font-size: .92rem; }
.rewards { font-size: .8rem; color: var(--muted); white-space: nowrap; }

.chore-rows .chore-row { display: grid; grid-template-columns: 1fr 110px 90px 34px; gap: .4rem; margin-bottom: .4rem; align-items: center; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.6rem; letter-spacing: .25em; font-weight: 800; color: var(--plum); }

.templates { display: grid; gap: .4rem; margin-bottom: .6rem; }
.template { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; border: 1px solid var(--line); border-radius: 10px; padding: .45rem .6rem; background: #fff; cursor: pointer; }
.template input { margin-top: .3rem; }
.template .small { display: block; }
.badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge-chip { font-size: .75rem; font-weight: 800; padding: .1rem .55rem; border-radius: 999px; border: 1px dashed #d5c9ad; color: var(--muted); }
.badge-chip.earned { border: 1px solid var(--gold); background: var(--gold-soft); color: #7a5810; }
.table-scroll { overflow-x: auto; }
.week-table .dot-col { text-align: center; padding: .4rem .2rem; }
.dot { display: inline-block; min-width: 2.6rem; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: .1rem .3rem; }
.dot.full { background: var(--ok); color: #fff; }
.dot.part { background: var(--gold-soft); color: #7a5810; }
.dot.miss { background: #f3e1dc; color: #8a2a1d; }
.dot.none { color: var(--muted); }

.print-page { background: #fff; padding: 1rem; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .8rem; }
.print-actions { display: flex; gap: .4rem; }
.print-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.print-day { border: 2px solid var(--plum); border-radius: 10px; padding: .4rem; break-inside: avoid; }
.print-day h2 { font-size: .95rem; text-align: center; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.print-item { margin-bottom: .4rem; font-size: .8rem; line-height: 1.25; }
.print-item.break { color: var(--muted); }
.print-row { display: flex; gap: .35rem; align-items: flex-start; }
.print-row.chore { margin-left: .9rem; }
.print-time { font-weight: 800; color: var(--plum); }
.box { flex: none; width: .85rem; height: .85rem; border: 1.5px solid var(--ink); border-radius: 3px; margin-top: .1rem; }
.box.blank { border-color: transparent; }
.print-foot { font-size: .7rem; color: var(--muted); margin-top: .6rem; }
@media print {
    @page { size: landscape; margin: 10mm; }
    .print-actions { display: none; }
    .print-page { padding: 0; }
}

@media (max-width: 900px) {
    .week { grid-template-columns: 1fr; }
    .day { min-height: 0; }
    .print-week { grid-template-columns: 1fr 1fr; }
    .hero-card { grid-template-columns: 110px 1fr; }
    .hero-card .doll { width: 110px; height: 110px; }
}

fieldset[data-kind-only] { border: 0; padding: 0; margin: 0; min-width: 0; }
.certpicker span { min-width: 0; font-weight: 600; }
.certpicker input:checked + span { background: var(--gold); border-color: var(--gold); }
.chore-rows .chore-certs { grid-column: 1 / -1; margin-top: -.15rem; }
.steps { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.step { font-size: .8rem; font-weight: 800; padding: .2rem .65rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--card); }
.step.done { background: var(--plum-soft); color: var(--plum); border-color: transparent; }
.step.current { background: var(--plum); color: #fff; border-color: var(--plum); }
.intro-card { display: flex; gap: .8rem; align-items: flex-start; }
.intro-card h2 { margin: 0 0 .2rem; }
.intro-icon { font-size: 1.6rem; line-height: 1; flex: none; width: 2rem; text-align: center; }
.onboarding-nav { margin-top: 1.25rem; }

.report-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; border: 1px solid var(--plum); border-radius: 999px; overflow: hidden; }
.segmented a { padding: .25rem .8rem; font-weight: 700; font-size: .85rem; text-decoration: none; color: var(--plum); background: #fff; }
.segmented a + a { border-left: 1px solid var(--plum); }
.segmented a.active { background: var(--plum); color: #fff; }
.stats { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--ink); line-height: 1.2; }
.stat-label { font-size: .78rem; font-weight: 700; color: var(--muted); }
.chart { margin: .3rem 0 .8rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: #cbbfa3; stroke-width: 1; }
.chart .axis { font-size: 13px; fill: var(--muted); font-family: Nunito, system-ui, sans-serif; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot-mark { stroke: var(--card); stroke-width: 2; }
.chart .dot-mark.hidden { opacity: 0; }
.chart .dot-mark.hidden:hover { opacity: 1; }
.chart rect:hover { filter: brightness(1.12); }
.chart-legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .8rem; color: var(--muted); font-weight: 700; margin-bottom: .2rem; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.swatch.line { height: .2rem; border-radius: 2px; vertical-align: 3px; }
.tone-1 { fill: #6a52a8; stroke: #6a52a8; }
.tone-2 { fill: #b07a12; stroke: #b07a12; }
.tone-3 { fill: #2f7fc1; stroke: #2f7fc1; }
.tone-4 { fill: #d64545; stroke: #d64545; }
.tone-track { fill: #e9e1cd; stroke: #e9e1cd; }
.swatch.tone-1 { background: #6a52a8; }
.swatch.tone-2 { background: #b07a12; }
.swatch.tone-3 { background: #2f7fc1; }
.swatch.tone-4 { background: #d64545; }
.swatch.tone-track { background: #e9e1cd; }
.events { list-style: none; padding: 0; margin: 0; }
.events li { display: flex; gap: .6rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.events .when { width: 4.5rem; flex: none; color: var(--muted); font-weight: 700; }
.report-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }

.plan-choice { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem .3rem; }
.plan-choice legend { font-weight: 700; padding: 0 .3rem; }
.plan-choice label { display: block; font-weight: 700; margin-bottom: .5rem; cursor: pointer; }
.plan-choice .hint { display: block; font-weight: 400; margin-left: 1.5rem; }
.guest-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; max-width: 1180px; margin: 0 auto; padding: .8rem 1rem; }
.guest-bar .brand { color: var(--plum); }
.guest-bar nav a { margin-left: 1rem; font-weight: 700; text-decoration: none; }

.planner-scroll { overflow-x: auto; padding-bottom: .25rem; }
.planner { --hour: 56px; display: grid; grid-template-columns: 2.8rem repeat(7, minmax(7rem, 1fr)); gap: 0 .35rem; min-width: 56rem; }
.p-head { font-weight: 800; font-size: .9rem; padding: .3rem .4rem; display: flex; justify-content: space-between; }
.p-head.today { color: var(--gold); }
.p-axis { position: relative; }
.p-axis span { position: absolute; right: .3rem; transform: translateY(-50%); font-size: .7rem; color: var(--muted); }
.p-col { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px; touch-action: pan-y; background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.p-col.today { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.p-col.drop { background-color: var(--plum-soft); }
.p-card { position: absolute; box-sizing: border-box; overflow: hidden; min-height: 22px; display: block; padding: .2rem .4rem .5rem; border-radius: 8px; border-left: 4px solid; font-size: .78rem; line-height: 1.25; color: var(--ink); text-decoration: none; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.p-card:hover { filter: brightness(.97); }
.p-card.class { background: #ece6f7; border-color: #7a63c2; }
.p-card.chore_pack { background: #e6f0de; border-color: #5e8c3a; }
.p-card.break { background: #f0ece4; border-color: #b9ad94; }
.p-card .t { font-weight: 800; }
.p-card .meta { color: var(--muted); font-size: .72rem; }
.p-card.dragging { z-index: 5; cursor: grabbing; box-shadow: 0 6px 18px rgba(43, 39, 51, .25); opacity: .92; }
.p-card.saving { opacity: .6; }
.p-card .grip { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; cursor: ns-resize; touch-action: none; }
.p-card .grip::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 22px; height: 3px; margin-left: -11px; border-radius: 2px; background: currentColor; opacity: .3; }
.planner-toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .55rem 1rem; border-radius: 10px; font-size: .85rem; z-index: 20; }
.planner-toast.error { background: var(--heart); }
