/* Joyful Village digital brand kit: shared light and dark palettes.
   Calendar category hues retain the existing printed legend. */
:root {
  color-scheme: light;
  --jv-purple: #5F4090;
  --jv-purple-action: #6F3D98;
  --jv-purple-dark: #460869;
  --jv-yellow: #FCBB0B;
  --jv-terracotta: #D7503C;
  --jv-green: #3F9142;
  --jv-background: #FCF3EE;
  --jv-surface: #FDF8F6;
  --jv-green-light: #ECF7EA;
  --jv-yellow-light: #FFF0D8;
  --jv-lavender: #DBBFE6;
  /* Fixed brand colors remain available independently of functional theme tokens. */
  --jv-brand-purple: #5F4090;
  --jv-brand-purple-action: #6F3D98;
  --jv-brand-purple-dark: #460869;
  --jv-brand-yellow: #FCBB0B;
  --jv-brand-green: #3F9142;
  --jv-brand-terracotta: #D7503C;
  --jv-surface-elevated: #FFFFFF;
  --jv-border-subtle: #E7DCE8;
  --jv-border: #AA96B7;
  --jv-text-primary: #30223C;
  --jv-text-secondary: #736879;
  --jv-on-primary: #FFFFFF;
  --jv-primary-hover: color-mix(in srgb, var(--brand) 90%, var(--ink));
  --jv-focus: #6F3D98;
  --jv-success: #357A38;
  --jv-error: #B2392A;
  --jv-info-bg: #F3EAF7;
  --radius-card: 28px;
  --radius-section: 18px;
  --radius-button: 14px;
  --shadow-header: 0 4px 16px rgb(0 0 0 / 8%);
  --shadow-card: 0 12px 32px rgb(139 94 60 / 10%);
  --font-primary: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: var(--jv-background);
  --surface: var(--jv-surface);
  --field: var(--jv-surface-elevated);
  --ink: var(--jv-text-primary);
  --heading: var(--jv-purple-dark);
  --muted: var(--jv-text-secondary);
  --line: var(--jv-border-subtle);
  --brand: var(--jv-purple-action);
  --on-brand: var(--jv-on-primary);
  --hero: var(--jv-surface);
  --yellow: var(--jv-yellow);
  --on-yellow: var(--jv-purple-dark);
  --lavender: var(--jv-info-bg);
  --warm: var(--jv-yellow-light);
  --calm: var(--jv-green-light);
  --success: var(--jv-success);
  --danger: var(--jv-error);
  --control-line: var(--jv-border);
  --songs: #6a2bb8;
  --rel: #0b8a34;
  --mind: #d5232a;
  --video: #d96f00;
  --goals: #0b4fb8;
  --on-cat: #FFFFFF;
  --switch-track: color-mix(in srgb, var(--jv-lavender) 30%, var(--jv-surface));
  --switch-border: var(--jv-lavender);
  --switch-idle: var(--jv-purple);
  --display: var(--font-primary);
  --body: var(--font-primary);
}

/* The JS sets data-theme before the application renders. Keep an OS fallback. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --jv-purple: #B99BE9; --jv-purple-action: #C39BE8;
    --jv-purple-dark: #460869; --jv-yellow: #FCBB0B; --jv-lavender: #DBBFE6;
    --jv-background: #17121F; --jv-surface: #231A30; --jv-surface-elevated: #30233D;
    --jv-border-subtle: #493654; --jv-border: #806D92; --jv-neutral: #C4B7CC;
    --jv-text-primary: #FCF3EE; --jv-text-secondary: #C4B7CC;
    --jv-on-primary: #241432; --jv-primary-hover: #D2B1EF; --jv-focus: #FCBB0B;
    --jv-green: #83CF85; --jv-green-light: #203629;
    --jv-terracotta: #F58E7E; --jv-yellow-light: #3A2D15;
    --jv-success: #83CF85; --jv-success-bg: #203629;
    --jv-warning: #FCBB0B; --jv-warning-bg: #3A2D15;
    --jv-error: #F58E7E; --jv-error-bg: #3B2428;
    --jv-info: #DBBFE6; --jv-info-bg: #30233D;
    --heading: var(--jv-text-primary);
    --hero: var(--jv-surface-elevated);
    --switch-track: var(--jv-background);
    --switch-border: var(--jv-border);
    --switch-idle: var(--jv-text-secondary);
    --songs: #bd92ff; --rel: #4ccb7c; --mind: #ff7479; --video: #ffa44d; --goals: #74a8ff;
    --on-cat: #150f27;
    --shadow-header: 0 4px 16px rgb(0 0 0 / 30%);
    --shadow-card: 0 12px 32px rgb(0 0 0 / 24%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --jv-purple: #B99BE9; --jv-purple-action: #C39BE8;
  --jv-purple-dark: #460869; --jv-yellow: #FCBB0B; --jv-lavender: #DBBFE6;
  --jv-background: #17121F; --jv-surface: #231A30; --jv-surface-elevated: #30233D;
  --jv-border-subtle: #493654; --jv-border: #806D92; --jv-neutral: #C4B7CC;
  --jv-text-primary: #FCF3EE; --jv-text-secondary: #C4B7CC;
  --jv-on-primary: #241432; --jv-primary-hover: #D2B1EF; --jv-focus: #FCBB0B;
  --jv-green: #83CF85; --jv-green-light: #203629;
  --jv-terracotta: #F58E7E; --jv-yellow-light: #3A2D15;
  --jv-success: #83CF85; --jv-success-bg: #203629;
  --jv-warning: #FCBB0B; --jv-warning-bg: #3A2D15;
  --jv-error: #F58E7E; --jv-error-bg: #3B2428;
  --jv-info: #DBBFE6; --jv-info-bg: #30233D;
  --heading: var(--jv-text-primary);
  --hero: var(--jv-surface-elevated);
  --switch-track: var(--jv-background);
  --switch-border: var(--jv-border);
  --switch-idle: var(--jv-text-secondary);
  --songs: #bd92ff; --rel: #4ccb7c; --mind: #ff7479; --video: #ffa44d; --goals: #74a8ff;
  --on-cat: #150f27;
  --shadow-header: 0 4px 16px rgb(0 0 0 / 30%);
  --shadow-card: 0 12px 32px rgb(0 0 0 / 24%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; padding-bottom: 48px; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--body); }
.wrap { width: 100%; max-width: 1124px; margin-inline: auto; padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { margin: 0; color: var(--heading); font-family: var(--display); font-weight: 700; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 32px; letter-spacing: -.01em; }
h2, h3 { font-size: 20px; }
:focus-visible { outline: 3px solid var(--jv-focus); outline-offset: 4px; }
a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }

/* The transparent original logo sits directly on the themed masthead. */
.masthead { background: var(--hero); box-shadow: var(--shadow-header); padding-top: env(safe-area-inset-top, 0px); }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 88px; padding-block: 10px; }
.brand { display: inline-flex; flex: none; align-items: center; margin: 0; padding: 0; background: transparent; }
.brand img { display: block; width: 104px; height: auto; }
.hero-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding-block: 32px 28px; }
.hero-heading { min-width: 0; }
.hero-heading h1::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--yellow); margin-bottom: 12px; }
.sub { margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; max-width: 560px; }
.tab { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--heading); font-size: 14px; font-weight: 600; line-height: 1.4; text-align: center; text-decoration: none; }
.tab:hover { border-color: var(--brand); background: var(--lavender); }
.tab[aria-current="page"] { border-color: var(--brand); background: var(--brand); color: var(--on-brand); box-shadow: 0 3px 8px rgb(95 64 144 / 12%); }

/* Geometry matches the existing pointer-drag logic: a 96px switch, 48px travel. */
.theme-switch { --theme-position: 0; position: relative; display: grid; grid-template-columns: repeat(2, 36px); gap: 12px; flex: none; align-items: center; justify-content: center; width: 96px; height: 48px; padding: 4px; border: 2px solid var(--switch-border); border-radius: 999px; background: var(--switch-track); color: var(--switch-idle); cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.theme-switch:hover { border-color: var(--jv-purple-action); }
.theme-switch:focus-visible { outline-color: var(--jv-focus); }
.theme-thumb { position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%; background: var(--jv-purple-action); box-shadow: 0 2px 5px rgb(70 8 105 / 15%); transform: translateX(calc(var(--theme-position) * 48px)); transition: transform .2s ease; }
.theme-switch svg { position: relative; z-index: 1; justify-self: center; width: 20px; height: 20px; pointer-events: none; transition: color .2s ease; }
.theme-sun { color: var(--jv-on-primary); }
.theme-moon { color: var(--switch-idle); }
.theme-switch[aria-checked="true"] .theme-sun { color: var(--switch-idle); }
.theme-switch[aria-checked="true"] .theme-moon { color: var(--jv-on-primary); }
.theme-switch.is-dragging { cursor: grabbing; }
.theme-switch.is-dragging .theme-thumb { transition: none; }

main { display: flex; flex-direction: column; gap: 24px; padding-top: 0; }
#app { display: flex; flex-direction: column; gap: 24px; }
.lead { max-width: 66ch; margin: 12px 0 0; color: var(--muted); }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 28px; }
.level { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); text-decoration: none; transition: border-color .18s, transform .18s; }
.level:hover { border-color: var(--brand); transform: translateY(-3px); }
.level .age { padding: 6px 12px; border-radius: 10px; background: var(--lavender); color: var(--heading); font-size: 14px; font-weight: 600; }
.level:nth-child(2) .age { background: var(--warm); }
.level:nth-child(3) .age { background: var(--calm); }
.level b { font-size: 22px; line-height: 1.25; font-weight: 700; color: var(--heading); }
.level span.go { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; margin-top: auto; padding-top: 12px; font-size: 15px; font-weight: 600; color: var(--brand); }
.level .go::after, .rcard .lk::after { font-size: 20px; line-height: 1; }
.level .go::after { content: "→"; }
.rcard .lk::after { content: "↗"; }
.top { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; align-items: stretch; }
.card { padding: 28px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.card, .month, .level, .rcard, .dh > div { min-width: 0; }
.lead, .note, .item, .rcard, .level, .sub, .tab { overflow-wrap: anywhere; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.online-fields { margin-top: 20px; }
.online-action { display: flex; grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 8px; color: var(--ink); font-size: 16px; font-weight: 500; }
input[type=text], textarea, select { width: 100%; min-width: 0; min-height: 50px; padding: 12px 14px; border: 1px solid var(--control-line); border-radius: 14px; background: var(--field); color: var(--ink); font: 400 16px/1.5 var(--body); }
input[type=text]:hover, textarea:hover, select:hover { border-color: var(--brand); }
textarea { resize: vertical; min-height: 96px; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
input:disabled, textarea:disabled { cursor: not-allowed; }
.streak { display: flex; flex-direction: column; justify-content: center; gap: 16px; border-color: color-mix(in srgb, var(--yellow) 40%, var(--line)); border-radius: var(--radius-section); background: var(--warm); box-shadow: none; }
.streak h2 { color: var(--heading); font-size: 20px; }
.streak .num { color: var(--heading); font: 700 44px/1.15 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.streak .num small { color: var(--muted); font-size: 16px; font-weight: 400; letter-spacing: 0; }
.bar { height: 8px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--brand) 16%, var(--warm)); }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .3s; }
.pts { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid color-mix(in srgb, var(--yellow) 35%, var(--line)); padding-top: 16px; color: var(--muted); font-weight: 500; }
.pts b { color: var(--heading); font-size: 28px; line-height: 1.2; font-weight: 700; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.streak .note { margin: 0; }
details.card > summary { color: var(--heading); font-size: 18px; font-weight: 600; line-height: 1.5; cursor: pointer; list-style-position: inside; }
details.card > summary::marker { color: var(--brand); }
details.card[open] > summary { margin-bottom: 20px; }
ol.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 40px; margin: 0; padding-left: 24px; font-size: 15px; line-height: 1.6; }
ol.steps li { padding-left: 4px; }
ol.steps li::marker { color: var(--brand); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid color-mix(in srgb, var(--c) 25%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--c) 7%, var(--surface)); color: color-mix(in srgb, var(--c) 70%, var(--ink)); font-size: 14px; font-weight: 600; }
.chip svg { width: 18px; height: 18px; }
.songs { --c: var(--songs); } .rel { --c: var(--rel); } .mind { --c: var(--mind); } .video { --c: var(--video); } .goals { --c: var(--goals); }
.months { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 20px; }
.month { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.month h3 { margin-bottom: 24px; font-size: 20px; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.wd { padding-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 500; text-align: center; }
.day { position: relative; display: flex; justify-content: center; align-items: center; min-width: 0; min-height: 72px; padding: 26px 2px 8px; border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--c) 8%, var(--surface)); color: var(--c); font: inherit; cursor: pointer; }
.day:hover { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.day svg { width: 24px; height: 24px; }
.day .n { position: absolute; top: 5px; left: 7px; color: var(--ink); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day .sg { position: absolute; bottom: 1px; right: 4px; font-size: 13px; font-weight: 700; }
.day[data-done="true"] { border-color: var(--c); background: var(--c); color: var(--on-cat); }
.day[data-done="true"] .n { color: var(--on-cat); }
/* Keep small completed-day numbers readable on orange and green. */
.day.video[data-done="true"] { --on-cat: #26164A; }
.day.rel[data-done="true"] { background: color-mix(in srgb, var(--c) 90%, var(--ink)); }
.day.off { border: 1px dashed var(--line); background: transparent; color: var(--muted); cursor: default; }
.day.off .n { color: var(--muted); font-weight: 400; }
.day.blank { border: 0; background: none; cursor: default; }
.day.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--brand); }
.day:focus-visible { z-index: 1; }
.materials { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 24px; }
.materials ul, .bhc ol { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 0; padding-left: 22px; }
.materials li::marker { color: var(--brand); }
.bhc { background: var(--calm); box-shadow: none; }
.res { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.rcard { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-height: 164px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-section); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .18s, transform .18s; }
.rcard small { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.rcard b { color: var(--heading); font-size: 18px; font-weight: 600; line-height: 1.35; }
a.rcard:hover { border-color: var(--brand); transform: translateY(-2px); }
.rcard .lk { display: inline-flex; align-items: center; justify-content: space-between; align-self: stretch; gap: 8px; margin-top: auto; padding-top: 12px; color: var(--brand); font-size: 14px; font-weight: 600; }
.rcard.soon { border-style: dashed; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 22px; border: 1px solid var(--brand); border-radius: var(--radius-button); background: var(--brand); color: var(--on-brand); font: 600 16px/1.5 var(--body); text-align: center; cursor: pointer; }
.btn:hover { background: var(--jv-primary-hover); }
.btn.ghost { background: var(--surface); color: var(--brand); }
.btn.warn { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn.warn:hover { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.btn.warn.armed { border-color: var(--danger); background: var(--danger); color: var(--surface); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
#resetBtn { margin-left: auto; }
.village-summary .lead { margin-bottom: 20px; }
#sumtxt { min-height: 220px; background: var(--field); font: 400 16px/1.7 ui-monospace, Menlo, Consolas, monospace; }
.flash { color: var(--success); font-size: 14px; font-weight: 500; }

/* Daily required worksheet and extras, using the native modal dialog. */
dialog { width: calc(100% - 32px); max-width: 660px; max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-card); padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgb(30 15 40 / 24%); }
dialog::backdrop { background: rgb(30 15 40 / 60%); }
.dh { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); padding: 22px 24px; background: var(--surface); }
.dh .ic { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 20px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); }
.dh .ic svg { width: 26px; height: 26px; }
.dh h2 { font-size: 20px; overflow-wrap: anywhere; }
.dh p { margin: 5px 0 0; color: color-mix(in srgb, var(--c) 70%, var(--ink)); font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.dh .x { flex: none; width: 44px; height: 44px; margin-left: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--field); color: var(--heading); font: 400 24px/1 var(--body); cursor: pointer; }
.dh .x:hover { border-color: var(--brand); }
.db { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.hint { margin: 0 0 4px; border-radius: 14px; padding: 12px 14px; background: var(--warm); color: var(--ink); font-size: 14px; font-weight: 500; line-height: 1.5; }
.item { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius-section); padding: 16px; background: var(--field); }
.item:has(input[type=checkbox]:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 7%, var(--surface)); }
.item label { display: flex; align-items: flex-start; gap: 12px; min-height: 32px; cursor: pointer; }
.item input[type=checkbox] { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--c); }
.item.dis { opacity: .65; border-style: dashed; }
.item.dis label { cursor: not-allowed; }
.ans, .emo, .rl { padding-left: 36px; }
.ans textarea { min-height: 80px; }
.emo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rl { display: flex; flex-wrap: wrap; gap: 10px; }
.rl a { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--c) 8%, var(--surface)); color: color-mix(in srgb, var(--c) 60%, var(--ink)); font-size: 14px; font-weight: 600; line-height: 1.5; text-decoration: none; overflow-wrap: anywhere; }
.rl a:hover { border-color: var(--c); }
.rl a[aria-disabled="true"] { cursor: not-allowed; }
.wizer-card { --c: var(--brand); border-width: 2px; }
.wizer-card h3, .wizer-card p { margin: 0; }
.wizer-topic, .wizer-direction { overflow-wrap: anywhere; }
.wizer-direction { color: var(--muted); }
.wizer-link { align-self: flex-start; max-width: 100%; text-decoration: none; }
.extras-title { margin: 8px 0 0; }
.legacy-progress { margin-top: 24px; }
.legacy-progress .btn { margin-top: 16px; }
#dDone { min-width: 120px; }

@media (max-width: 1000px) {
  .hero-content { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .tabs { max-width: none; }
}
@media (max-width: 900px) {
  .months { grid-template-columns: minmax(0, 1fr); }
  .levels { gap: 16px; }
  .level { padding: 24px; }
}
@media (max-width: 760px) {
  .wrap { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
  .top, .materials, .levels { grid-template-columns: minmax(0, 1fr); }
  ol.steps { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
@media (max-width: 600px) {
  body { font-size: 17px; padding-bottom: max(32px, env(safe-area-inset-bottom, 0px)); }
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  h1 { font-size: 28px; }
  .hero-top { min-height: 80px; }
  .brand img { width: 96px; }
  .hero-content { padding-block: 24px; }
  .sub { font-size: 15px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tabs .tab:last-child { grid-column: 1 / -1; }
  .tab { padding: 10px 8px; font-size: 14px; }
  .lead { margin-top: 12px; }
  .levels { margin-top: 24px; }
  .level { gap: 14px; }
  .card { padding: 22px; }
  .fields { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .online-fields { margin-top: 18px; }
  #goBtn { width: 100%; }
  .streak { padding: 24px; gap: 14px; }
  .note { font-size: 15px; }
  ol.steps { font-size: 16px; }
  .legend { gap: 8px; }
  .chip { padding: 7px 9px; }
  .month { padding: 18px; }
  .month h3 { margin-bottom: 20px; }
  .grid { gap: 4px; }
  .wd { font-size: 12px; }
  .day { min-height: 68px; border-radius: 10px; }
  .day .n { left: 5px; }
  .materials ul, .bhc ol { gap: 12px; margin-top: 18px; }
  .res { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
  .rcard { aspect-ratio: 1; min-height: 0; padding: 16px; gap: 10px; }
  .rcard b { font-size: 16px; }
  .rcard .lk { padding-top: 0; }
  .row { flex-direction: column; align-items: stretch; gap: 14px; }
  .row .btn { width: 100%; }
  #resetBtn { margin-left: 0; }
  #sumtxt { min-height: 260px; }
  dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 24px; }
  .dh { gap: 10px; padding: 18px 16px; }
  .dh .ic { width: 42px; height: 42px; border-radius: 16px; }
  .dh h2 { font-size: 18px; }
  .db { padding: 18px 16px max(24px, env(safe-area-inset-bottom, 0px)); gap: 14px; }
  .item { padding: 14px; }
  .ans, .emo, .rl { padding-left: 0; }
  .emo { grid-template-columns: minmax(0, 1fr); }
  .ans textarea { min-height: 100px; }
}
@media (max-width: 360px) {
  .card { padding: 18px; }
  .month { padding: 12px; border-radius: 22px; }
  .grid { gap: 3px; }
  .day .n { left: 4px; }
  .tab { font-size: 13px; }
  .rcard { padding: 14px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .bar i, .theme-thumb, .theme-switch svg, .level, .rcard { transition: none; }
  .level:hover, a.rcard:hover { transform: none; }
}
