/* ============================================================
   🌷 GÓC HỌC NHỎ — Cute Cozy Study Planner
   ============================================================ */

:root {
  --cream: #FFF8EC;
  --cream-2: #F7EEDF;
  --cream-3: #F1E5D2;
  --brown: #6F5547;
  --brown-dark: #4F3C34;
  --brown-soft: #A08977;
  --matcha: #BFD8B8;
  --matcha-dark: #91B58A;
  --peach: #F4C8C5;
  --peach-dark: #E3A29E;
  --butter: #F3D993;
  --butter-dark: #DCBD65;
  --sky: #C8DDEE;
  --sky-dark: #93B7D6;
  --lavender: #D8CEE8;
  --lavender-dark: #AF9FCC;
  --mint: #CDE7E3;
  --mint-dark: #8FC4BB;
  --rose: #F7D6E8;
  --rose-dark: #DBA4C4;
  --line: rgba(111, 85, 71, .14);
  --shadow: 0 6px 18px rgba(111, 85, 71, .08), 0 1px 3px rgba(111, 85, 71, .06);
  --shadow-lg: 0 14px 40px rgba(111, 85, 71, .14);
  --radius: 18px;
  --radius-sm: 12px;
  --font-head: 'Quicksand', 'Nunito', sans-serif;
  --font-body: 'Nunito', 'Quicksand', sans-serif;
  --font-hand: 'Patrick Hand', cursive;
  --header-h: 68px;
  --sidebar-w: 248px;
  --ease: cubic-bezier(.34, 1.3, .64, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--brown);
  background: var(--cream);
  /* paper texture rất nhẹ */
  background-image:
    radial-gradient(rgba(111, 85, 71, .035) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px;
  background-position: 0 0, 11px 11px;
  line-height: 1.45;
  min-height: 100vh;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; color: var(--brown-dark); letter-spacing: .01em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.muted { color: var(--brown-soft); }
.small { font-size: .85rem; }
.mt { margin-top: 18px; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  background: rgba(255, 248, 236, .92);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(6px);
}
.app-body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--cream-2);
  border-right: 1px solid var(--line);
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-inner { padding: 16px 14px 24px; display: flex; flex-direction: column; gap: 14px; }
.main { flex: 1; min-width: 0; padding: 22px 28px 60px; }
.page-enter { animation: fadeUp .3s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Header ---------- */
.menu-btn { display: none; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; color: var(--brown-dark); letter-spacing: .04em; }
.brand-tag { font-family: var(--font-hand); font-size: .95rem; color: var(--brown-soft); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  font-weight: 700; font-size: .85rem; white-space: nowrap;
}
.pill.big { font-size: 1rem; padding: 8px 16px; }
.header-coins.bump { animation: bump .5s var(--ease); }
@keyframes bump { 30% { transform: scale(1.18); background: var(--butter); } }
.header-mascot { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.header-mascot svg { width: 30px; height: 33px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; display: inline-grid; place-items: center;
  color: var(--brown); background: transparent; transition: background .2s, transform .2s;
  font-size: 1rem;
}
.icon-btn:hover { background: rgba(111, 85, 71, .08); transform: translateY(-1px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 14px;
  font-family: var(--font-head); font-weight: 700; font-size: .9rem; letter-spacing: .02em;
  border: 1px solid transparent;
  transition: transform .2s var(--ease), box-shadow .2s, background .2s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--matcha-dark); color: #fff; box-shadow: 0 4px 12px rgba(145, 181, 138, .35); }
.btn-primary:hover { background: #82a97b; }
.btn-soft { background: var(--cream-3); color: var(--brown-dark); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--brown); border-color: var(--line); }
.btn-ghost:hover { background: rgba(111, 85, 71, .06); }
.btn-danger { background: var(--peach-dark); color: #fff; }
.btn-danger-text { color: #c2736d; }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 10px; }
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn { color: var(--brown-soft); font-size: .8rem; font-weight: 700; padding: 6px 4px; text-decoration: underline dotted; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: #fff; border: 1px solid var(--line); color: var(--brown);
  transition: all .2s;
}
.chip:hover { background: var(--cream-3); }
.chip.active { background: var(--brown-dark); color: #fff; border-color: var(--brown-dark); }

/* ---------- Paper card ---------- */
.paper {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; position: relative;
}
.tape {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%) rotate(-2deg);
  width: 64px; height: 18px; background: rgba(243, 217, 147, .55);
  border-radius: 3px; pointer-events: none;
  backdrop-filter: blur(1px);
}
.tone-matcha { --tone: var(--matcha); --tone-dark: var(--matcha-dark); }
.tone-sky { --tone: var(--sky); --tone-dark: var(--sky-dark); }
.tone-lavender { --tone: var(--lavender); --tone-dark: var(--lavender-dark); }
.tone-butter { --tone: var(--butter); --tone-dark: var(--butter-dark); }
.tone-peach { --tone: var(--peach); --tone-dark: var(--peach-dark); }
.tone-mint { --tone: var(--mint); --tone-dark: var(--mint-dark); }
.tone-rose { --tone: var(--rose); --tone-dark: var(--rose-dark); }

/* ---------- Titles ---------- */
.page-title { font-size: 1.45rem; font-weight: 700; letter-spacing: .04em; }
.page-sub { margin: 4px 0 0; color: var(--brown-soft); font-family: var(--font-hand); font-size: 1.05rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page > .page-title + .page-sub { margin-bottom: 20px; }
.side-title { font-size: .78rem; letter-spacing: .1em; color: var(--brown-soft); font-weight: 700; margin-bottom: 10px; text-transform: uppercase; }
.sub-title { font-size: .85rem; margin: 16px 0 8px; color: var(--brown-dark); }
.back-link { display: inline-block; color: var(--brown-soft); font-weight: 700; font-size: .85rem; margin-bottom: 8px; }

/* ---------- Sidebar blocks ---------- */
.side-block { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; text-align: left; width: 100%; color: inherit; }
.side-foot { font-size: .75rem; color: var(--brown-soft); margin-top: 8px; }
.side-big { font-size: .8rem; color: var(--brown-soft); line-height: 1.3; margin-bottom: 8px; }
.side-big strong { font-size: 1.1rem; color: var(--brown-dark); font-family: var(--font-head); }
.side-goal { transition: transform .2s var(--ease), box-shadow .2s; cursor: pointer; }
.side-goal:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.goal-name { font-weight: 800; color: var(--brown-dark); margin-bottom: 4px; }
.goal-days { font-size: .85rem; margin-bottom: 8px; }
.goal-days strong { font-size: 1.15rem; color: var(--lavender-dark); font-family: var(--font-head); }

.mini-progress { display: flex; flex-direction: column; gap: 6px; }
.mini-row { display: grid; grid-template-columns: 26px 1fr 36px; align-items: center; gap: 8px; font-size: .75rem; }
.mini-row.today .mini-label { color: var(--peach-dark); font-weight: 800; }
.mini-label { font-weight: 700; color: var(--brown-soft); }
.mini-label.wide { width: auto; }
.subject-bars .mini-row { grid-template-columns: 96px 1fr 36px; }
.mini-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { background: rgba(111, 85, 71, .09); border-radius: 999px; overflow: hidden; width: 100%; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .5s var(--ease); }

.mini-bars { display: flex; gap: 6px; height: 54px; align-items: flex-end; }
.mini-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.mini-bar { width: 100%; background: var(--sky-dark); border-radius: 4px 4px 2px 2px; transition: height .5s var(--ease); min-height: 3px; }
.mini-bar-col span { font-size: .6rem; color: var(--brown-soft); font-weight: 700; }

.side-mascot { display: flex; align-items: center; gap: 10px; background: var(--cream-2); }
.side-mascot .mascot-wrap { flex: 0 0 auto; cursor: pointer; }
.mascot-bubble {
  margin: 0; font-family: var(--font-hand); font-size: 1rem; color: var(--brown-dark);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; position: relative;
}
.mascot-bubble::before { content: ''; position: absolute; left: -6px; top: 50%; width: 10px; height: 10px; background: #fff; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  font-weight: 700; font-size: .9rem; color: var(--brown); transition: background .2s, transform .2s;
}
.nav-item:hover { background: rgba(255, 255, 255, .8); transform: translateX(2px); }
.nav-item.active { background: var(--matcha); color: var(--brown-dark); box-shadow: inset 3px 0 0 var(--matcha-dark); }
.nav-icon { width: 22px; text-align: center; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-title { font-size: .78rem; letter-spacing: .1em; font-weight: 700; color: var(--brown-soft); }
.cal-nav { width: 28px; height: 28px; font-size: 1.1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow span { font-size: .62rem; text-align: center; color: var(--brown-soft); font-weight: 700; padding: 2px 0; }
.cal-cell {
  aspect-ratio: 1; border-radius: 8px; font-size: .72rem; font-weight: 700; color: var(--brown);
  display: grid; place-items: center; position: relative; transition: background .15s, transform .15s;
}
.cal-cell:hover { background: var(--cream-3); transform: scale(1.08); }
.cal-cell.empty { pointer-events: none; }
.cal-cell.in-week { background: var(--cream-2); }
.cal-cell.today { background: var(--peach); color: var(--brown-dark); box-shadow: 0 0 0 2px var(--peach-dark); }
.cal-dot { position: absolute; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--brown-soft); }
.cal-cell.st-good .cal-dot { background: var(--matcha-dark); }
.cal-cell.st-partial .cal-dot { background: var(--butter-dark); }
.cal-cell.st-missed .cal-dot { background: var(--peach-dark); }

/* ---------- Today bar ---------- */
.today-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(120deg, #fff, var(--cream-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.today-main { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .9rem; }
.today-label { font-family: var(--font-head); font-weight: 700; letter-spacing: .08em; color: var(--brown-dark); }
.today-date { font-weight: 700; }
.today-prog strong { color: var(--matcha-dark); font-size: 1.05rem; }
.today-goal { color: var(--brown-soft); font-family: var(--font-hand); font-size: 1rem; }
.today-side { display: flex; align-items: center; gap: 10px; }
.mood-mini { display: flex; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.mood-mini-btn { width: 30px; height: 30px; border-radius: 50%; font-size: 1rem; transition: transform .2s var(--ease), background .2s; opacity: .65; }
.mood-mini-btn:hover { transform: scale(1.15); opacity: 1; }
.mood-mini-btn.active { background: var(--butter); opacity: 1; transform: scale(1.1); }

/* ---------- PLANNER ---------- */
.planner-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.planner-head .page-title { flex: 1 1 auto; }
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-range {
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--brown-dark);
  padding: 6px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line); min-width: 130px;
  font-variant-numeric: tabular-nums;
}
.week-range:hover { background: var(--cream-3); }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.day-tabs { display: none; }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; align-items: start; }

.day-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 12px 12px; position: relative;
  display: flex; flex-direction: column; gap: 10px; min-height: 340px;
  transition: transform .25s var(--ease), box-shadow .25s, opacity .3s;
  background-image: linear-gradient(180deg, var(--tone) 0, var(--tone) 58px, #fff 58px);
}
.day-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.day-card .tape { background: var(--tone-dark); opacity: .45; width: 52px; }
.day-card.is-today { box-shadow: 0 0 0 3px var(--tone-dark), var(--shadow-lg); }
.day-card.is-past { opacity: .78; filter: saturate(.85); }
.day-card.is-complete { background-image: linear-gradient(180deg, var(--matcha) 0, var(--matcha) 58px, #fff 58px); }
.sticker-done {
  position: absolute; top: 10px; right: -6px; transform: rotate(8deg);
  background: var(--butter); color: var(--brown-dark); font-family: var(--font-hand); font-size: .85rem;
  padding: 3px 9px; border-radius: 8px; box-shadow: 0 3px 8px rgba(111, 85, 71, .15); animation: stickerIn .4s var(--ease);
  z-index: 2;
}
@keyframes stickerIn { from { transform: rotate(8deg) scale(0); } to { transform: rotate(8deg) scale(1); } }

.day-head { display: flex; align-items: center; gap: 8px; min-height: 42px; padding-right: 26px; }
.sticker-today {
  position: absolute; top: 10px; right: -6px; transform: rotate(6deg);
  background: #fff; color: var(--peach-dark); font-family: var(--font-hand); font-size: .8rem;
  padding: 2px 8px; border-radius: 8px; box-shadow: 0 3px 8px rgba(111, 85, 71, .15); z-index: 2;
}
.day-icon { font-size: 1.4rem; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .08)); }
.day-name { font-family: var(--font-head); font-weight: 700; font-size: .85rem; letter-spacing: .06em; color: var(--brown-dark); }
.day-date { font-size: .75rem; color: var(--brown); font-weight: 700; opacity: .8; }

.day-progress { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 4px; text-align: center; }
.day-progress-text { display: flex; align-items: baseline; gap: 4px; line-height: 1.15; white-space: nowrap; }
.day-progress-text strong { font-family: var(--font-head); font-size: 1.05rem; color: var(--brown-dark); }
.day-progress-text span { font-size: .72rem; color: var(--brown-soft); }
.ring { position: relative; display: inline-grid; place-items: center; flex: 0 0 auto; }
.ring svg { display: block; }
.ring-fill { transition: stroke-dashoffset .6s var(--ease); }
.ring-label { position: absolute; font-family: var(--font-head); font-weight: 700; font-size: .95rem; color: var(--brown-dark); }

.day-subject {
  align-self: center; font-family: var(--font-head); font-weight: 700; font-size: .72rem; letter-spacing: .08em;
  padding: 4px 10px; border-radius: 999px; background: var(--sub); color: var(--brown-dark);
}

.day-tasks { flex: 1; min-height: 0; }
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task { display: flex; align-items: flex-start; gap: 8px; padding: 5px 4px; border-radius: 10px; transition: background .2s; }
.task:hover { background: var(--cream-2); }
.task.done .task-title { color: var(--brown-soft); text-decoration: line-through; text-decoration-color: rgba(111, 85, 71, .35); }
.task-title { text-align: left; font-size: .86rem; font-weight: 600; line-height: 1.3; flex: 1; min-width: 0; word-break: break-word; display: flex; flex-direction: column; gap: 1px; color: var(--brown-dark); }
.task-meta { font-size: .68rem; color: var(--brown-soft); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.task.done .task-meta { text-decoration: none; }
.subject-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.task-list.compact .task { padding: 8px 6px; }

.checkbox {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 8px; margin-top: 1px;
  border: 2px solid var(--brown-soft); background: #fff; display: grid; place-items: center;
  transition: all .25s var(--ease); position: relative;
}
.checkbox:hover { border-color: var(--matcha-dark); transform: scale(1.08); }
.checkbox .check-mark { color: #fff; font-size: .8rem; font-weight: 900; transform: scale(0); transition: transform .25s var(--ease); }
.checkbox.checked { background: var(--matcha-dark); border-color: var(--matcha-dark); }
.checkbox.checked .check-mark { transform: scale(1); }
.checkbox.animating { animation: checkPop .4s var(--ease); }
@keyframes checkPop { 40% { transform: scale(1.3) rotate(-6deg); } }
.checkbox.static { cursor: default; }

.day-foot { display: flex; align-items: center; gap: 10px; font-size: .72rem; color: var(--brown-soft); font-weight: 700; border-top: 1px dashed var(--line); padding-top: 8px; flex-wrap: wrap; }
.add-mini { margin-left: auto; width: 28px; height: 28px; border-radius: 50%; background: var(--cream-2); font-size: 1.1rem; }

.empty-day { text-align: center; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-day p { margin: 4px 0 0; font-weight: 700; font-size: .85rem; color: var(--brown-dark); }
.empty-day small { color: var(--brown-soft); font-family: var(--font-hand); font-size: .95rem; margin-bottom: 6px; }
.empty-mascot { opacity: .85; }

/* Slide when switching day on mobile */
.week-grid.slide-left { animation: slideL .3s var(--ease); }
.week-grid.slide-right { animation: slideR .3s var(--ease); }
@keyframes slideL { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes slideR { from { transform: translateX(-24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- Forms ---------- */
.task-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: .75rem; font-weight: 700; letter-spacing: .04em; color: var(--brown-soft); text-transform: uppercase; }
.field legend { margin-bottom: 6px; padding: 0; }
.field input, .field select, .field textarea, .select {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--cream);
  outline: none; transition: border .2s, box-shadow .2s; color: var(--brown-dark);
}
.field input:focus, .field select:focus, .field textarea:focus, .select:focus { border-color: var(--matcha-dark); box-shadow: 0 0 0 3px rgba(145, 181, 138, .25); background: #fff; }
.field textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-radio input, .color-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: .8rem; font-weight: 700; cursor: pointer; transition: all .2s; }
.chip-radio input:checked + span { background: var(--butter); border-color: var(--butter-dark); color: var(--brown-dark); }
.chip-group.icons .chip-radio span { font-size: 1.1rem; padding: 5px 9px; }
.color-radio span { display: block; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; transition: transform .2s; }
.color-radio input:checked + span { box-shadow: 0 0 0 2px var(--brown-dark); transform: scale(1.1); }
.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--cream); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; }
.switch input { position: absolute; opacity: 0; }
.switch-track { width: 42px; height: 24px; border-radius: 999px; background: rgba(111, 85, 71, .2); position: relative; transition: background .2s; flex: 0 0 auto; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + .switch-track { background: var(--matcha-dark); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(79, 60, 52, .35);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; }
.modal-backdrop.closing { opacity: 0; }
.modal {
  background: var(--cream); border-radius: 22px; box-shadow: var(--shadow-lg);
  width: 100%; max-height: calc(100vh - 32px); overflow-y: auto;
  transform: translateY(16px) scale(.97); transition: transform .25s var(--ease);
  border: 1px solid var(--line);
}
.modal-backdrop.open .modal { transform: none; }
.modal-sm { max-width: 400px; } .modal-md { max-width: 560px; } .modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head:empty { display: none; }
.modal-title { font-size: 1.05rem; }
.modal-title:empty { display: none; }
.modal-body { padding: 14px 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.modal-actions.spread { justify-content: space-between; }
.left-actions, .right-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.confirm-msg { margin: 0 0 14px; line-height: 1.5; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--brown-dark); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px) scale(.95); transition: all .25s var(--ease);
}
.toast.show { opacity: 1; transform: none; }

/* ---------- Reward effects ---------- */
#reward-root { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.coin-float { position: absolute; transform: translate(-50%, -100%); font-weight: 800; color: var(--butter-dark); font-family: var(--font-head); font-size: 1rem; animation: coinUp 1.1s ease-out forwards; text-shadow: 0 1px 0 #fff; }
@keyframes coinUp { to { transform: translate(-50%, -260%); opacity: 0; } }
.sparkle { position: absolute; font-size: 1rem; transform: translate(-50%, -50%); animation: sparkleOut .85s ease-out forwards; }
@keyframes sparkleOut { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.4); opacity: 0; } }
.confetti { position: absolute; top: -10px; width: 8px; height: 12px; border-radius: 2px; animation: confettiFall 2.4s ease-in forwards; }
@keyframes confettiFall { to { transform: translateY(110vh) rotate(var(--rot)); opacity: .6; } }
.reward-popup { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0; }
.reward-title { font-size: 1.4rem; }
.reward-sub { margin: 0; color: var(--brown-soft); }
.reward-list { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 6px 0 10px; }
.reward-list li { background: #fff; border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.unlock-item { font-size: 4rem; animation: popIn .5s var(--ease); filter: drop-shadow(0 6px 10px rgba(111, 85, 71, .2)); }
@keyframes popIn { from { transform: scale(0) rotate(-20deg); } to { transform: none; } }
.reward-mascot { animation: popIn .5s var(--ease); }

/* ---------- Day detail ---------- */
.day-detail-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.day-detail-stats span { background: #fff; border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.mood-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mood-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--line); min-width: 70px; transition: all .2s var(--ease); }
.mood-btn span { font-size: 1.4rem; }
.mood-btn small { font-size: .65rem; color: var(--brown-soft); font-weight: 700; }
.mood-btn:hover { transform: translateY(-2px); }
.mood-btn.active { background: var(--butter); border-color: var(--butter-dark); }
.day-note { width: 100%; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; resize: vertical; }

/* ---------- Pomodoro ---------- */
.pomo-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.pomo-card { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 28px 20px; }
.pomo-modes { display: flex; gap: 6px; }
.pomo-ring { position: relative; display: grid; place-items: center; }
.pomo-ring svg { display: block; }
#pomo-arc { transition: stroke-dashoffset .3s linear, stroke .3s; }
.pomo-time { position: absolute; font-family: var(--font-head); font-weight: 700; font-size: 3rem; color: var(--brown-dark); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.pomo-state { position: absolute; margin-top: 78px; font-family: var(--font-hand); color: var(--brown-soft); font-size: 1rem; }
.pomo-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pomo-presets { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pomo-side { display: flex; flex-direction: column; gap: 14px; }
.pomo-mascot-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--cream-2); }
.pomo-mascot-box .mascot-bubble::before { display: none; }
.pomo-today { display: flex; gap: 12px; margin-top: 10px; font-size: .85rem; flex-wrap: wrap; }
.timer-pill {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: var(--brown-dark); color: #fff; font-weight: 700; box-shadow: var(--shadow-lg);
  animation: floaty 3s ease-in-out infinite;
}
.timer-pill small { opacity: .7; font-size: .7rem; }
@keyframes floaty { 50% { transform: translateY(-3px); } }

/* ---------- Subjects ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.subject-card { display: block; transition: transform .25s var(--ease), box-shadow .25s; background-image: linear-gradient(180deg, var(--sub) 0, var(--sub) 64px, #fff 64px); }
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.subject-head { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; min-height: 30px; }
.subject-icon { font-size: 1.6rem; }
.subject-head h3 { font-size: 1rem; letter-spacing: .06em; }
.subject-pct { font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; margin: 6px 0 10px; color: var(--brown-dark); }
.subject-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.subject-stats dt { font-size: .65rem; color: var(--brown-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.subject-stats dd { margin: 0; font-weight: 800; font-size: .85rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.chapter-list li, .score-list li, .settings-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.score-list li strong { font-family: var(--font-head); font-size: 1.1rem; color: var(--matcha-dark); }
.score-list li span { flex: 1; }
.score-list li small { color: var(--brown-soft); }

/* ---------- Room (scene & panel chi tiết: room.css + motion.css) ---------- */
@keyframes sway { 50% { transform: rotate(3deg); } }
@keyframes twinkle { 50% { opacity: .3; transform: scale(.7); } }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 10px; font-weight: 700; font-size: .82rem; color: var(--brown-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--brown-dark); border-color: var(--matcha-dark); }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 16px 10px; background: linear-gradient(180deg, var(--tone) 0, #fff 70%); }
.stat-icon { font-size: 1.4rem; }
.stat-card strong { font-family: var(--font-head); font-size: 1.3rem; color: var(--brown-dark); }
.stat-card strong small { font-size: .8rem; color: var(--brown-soft); }
.stat-card span:last-child { font-size: .72rem; color: var(--brown-soft); font-weight: 700; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.chart-bars { display: flex; gap: 4px; height: 120px; align-items: flex-end; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; }
.chart-bar { width: 100%; border-radius: 6px 6px 3px 3px; transition: height .6s var(--ease); min-height: 3px; }
.chart-col span { font-size: .6rem; color: var(--brown-soft); font-weight: 700; }
.mood-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mood-stat { display: flex; flex-direction: column; align-items: center; background: var(--cream); border-radius: 12px; padding: 10px 4px; }
.mood-emoji { font-size: 1.5rem; }
.mood-stat strong { font-family: var(--font-head); font-size: 1.2rem; }
.mood-stat small { font-size: .62rem; color: var(--brown-soft); font-weight: 700; text-align: center; }

/* ---------- Goals ---------- */
.goal-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.goal-hero { text-align: center; padding: 30px 22px 22px; background: linear-gradient(180deg, var(--tone) 0, #fff 60%); }
.goal-icon-big { font-size: 3.4rem; filter: drop-shadow(0 6px 10px rgba(111, 85, 71, .15)); }
.goal-hero h2 { font-size: 1.5rem; margin: 6px 0 16px; }
.goal-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.goal-meta div { display: flex; flex-direction: column; background: rgba(255, 255, 255, .7); border-radius: 12px; padding: 8px; }
.goal-meta small { font-size: .65rem; color: var(--brown-soft); font-weight: 700; text-transform: uppercase; }
.goal-meta strong { font-family: var(--font-head); font-size: 1.05rem; }
.goal-pct { font-size: .8rem; color: var(--brown-soft); margin-top: 6px; font-weight: 700; }
.goal-note { font-family: var(--font-hand); font-size: 1.1rem; margin: 12px 0 0; color: var(--brown-dark); }
.timeline { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding-left: 8px; }
.timeline li { position: relative; padding: 0 0 18px 24px; font-weight: 700; font-size: .9rem; }
.timeline li::before { content: ''; position: absolute; left: 3px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--lavender); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--lavender-dark); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 20px; bottom: 0; width: 2px; background: repeating-linear-gradient(180deg, var(--lavender-dark) 0 4px, transparent 4px 8px); }
.timeline li:last-child::after { display: none; }
.timeline li.current::before { background: var(--matcha-dark); transform: scale(1.3); }
.timeline li.current span { color: var(--matcha-dark); }
.timeline li.exam::before { background: var(--peach-dark); transform: scale(1.4); }
.timeline li.exam span { color: var(--peach-dark); font-family: var(--font-head); }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.danger-zone { border-color: rgba(227, 162, 158, .5); }

/* ---------- Bottom nav / drawer (mobile only, hidden on desktop) ---------- */
.bottom-nav, .drawer-backdrop { display: none; }
