/* Văn Hay Mỗi Ngày: giao diện cho trẻ tiểu học.
   Tông ấm, thẻ bo tròn, nút bấm nổi khối; điện thoại dùng thanh tab dưới đáy,
   từ 768px dùng thanh bên trái. */

:root {
  --bg: #fff7e8;
  --paper: #ffffff;
  --ink: #2b2a33;
  --ink-soft: #5d5a6b;
  --line: #efe3cc;
  --line-strong: #e2d3b4;
  --leaf: #1f8a5b;
  --leaf-dark: #146642;
  --leaf-soft: #dff5e8;
  --sun: #ffc93c;
  --sun-dark: #e0a600;
  --sun-soft: #fff1c7;
  --coin: #9a5b00;
  --sky: #2f7fd8;
  --sky-dark: #1f5fa8;
  --sky-soft: #e2efff;
  --berry: #c8344f;
  --berry-soft: #ffe3e8;
  --grape: #6d3fb5;
  --grape-soft: #efe6ff;
  --shadow: 0 2px 0 rgba(43, 42, 51, 0.05), 0 8px 24px rgba(160, 120, 40, 0.10);
  --radius: 22px;
  --tabbar: 74px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue",
    Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
}

p {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}

a {
  color: var(--leaf-dark);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Khung trang ---------- */

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 10px;
  background: rgba(255, 247, 232, 0.94);
  backdrop-filter: blur(8px);
}

.hello {
  font-weight: 800;
  font-size: 19px;
  line-height: 1.2;
}

.hello small {
  display: block;
  margin-top: 2px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.pills {
  display: flex;
  gap: 8px;
  flex: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  background: var(--paper);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.pill.coin {
  color: var(--coin);
}

.pill.fire {
  color: var(--berry);
}

main {
  padding: 4px 16px calc(var(--tabbar) + 28px);
  max-width: 980px;
  margin: 0 auto;
}

main:focus {
  outline: none;
}

.page-title {
  font-size: 24px;
  margin: 8px 0 4px;
}

.page-sub {
  color: var(--ink-soft);
  margin-bottom: 8px;
}

/* ---------- Thanh tab ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: var(--tabbar);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.tabs[hidden] {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}

.tab span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab .icon {
  font-size: 22px;
  line-height: 1;
  filter: grayscale(0.5);
}

.tab.on {
  color: var(--leaf-dark);
  background: var(--leaf-soft);
}

.tab.on .icon {
  filter: none;
}

@media (min-width: 768px) {
  :root {
    --tabbar: 0px;
  }

  .shell.authed {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    align-content: start;
  }

  .shell.authed .topbar {
    grid-column: 2;
  }

  .shell.authed main {
    grid-column: 2;
    width: 100%;
    padding: 4px 28px 48px;
  }

  .tabs {
    top: 0;
    right: auto;
    width: 220px;
    height: auto;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 6px;
    padding: 20px 14px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .tabs::before {
    content: "🌱 Văn Hay Mỗi Ngày";
    font-weight: 800;
    font-size: 17px;
    color: var(--leaf-dark);
    padding: 4px 10px 16px;
  }

  .tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 14px;
    font-size: 16px;
  }

  .tab .icon {
    font-size: 22px;
  }
}

/* ---------- Thẻ và nút ---------- */

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}

.card.inner {
  margin-top: 10px;
  padding: 14px;
  background: #fbf6ec;
  box-shadow: none;
}

.card > h2,
.card > h3 {
  font-size: 19px;
  margin-bottom: 6px;
}

.muted {
  color: var(--ink-soft);
  font-size: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  font-weight: 800;
  background: var(--leaf);
  color: #fff;
  box-shadow: 0 4px 0 var(--leaf-dark);
  transition: transform 0.08s, box-shadow 0.08s;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--leaf-dark);
}

.btn:disabled {
  opacity: 0.55;
}

.btn.block {
  width: 100%;
}

.btn.ghost {
  background: var(--paper);
  color: var(--leaf-dark);
  box-shadow: inset 0 0 0 2px var(--leaf), 0 4px 0 var(--leaf-soft);
}

.btn.ghost:active:not(:disabled) {
  box-shadow: inset 0 0 0 2px var(--leaf), 0 1px 0 var(--leaf-soft);
}

.btn.sun {
  background: var(--sun);
  color: #4a3200;
  box-shadow: 0 4px 0 var(--sun-dark);
}

.btn.danger {
  background: var(--berry);
  box-shadow: 0 4px 0 #9c2238;
}

.btn.small {
  min-height: 42px;
  padding: 8px 14px;
  font-size: 15px;
  border-radius: 13px;
}

.btn.round {
  width: 52px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  background: var(--sky);
  box-shadow: 0 4px 0 var(--sky-dark);
  font-size: 20px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.actions.spread {
  justify-content: space-between;
}

.note {
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 15px;
  background: var(--sky-soft);
}

.note.warn {
  background: var(--sun-soft);
}

.note.bad {
  background: var(--berry-soft);
}

.note.good {
  background: var(--leaf-soft);
}

.btn.round.small {
  width: 42px;
  min-height: 42px;
  height: 42px;
  font-size: 18px;
}

/* ---------- Biểu mẫu ---------- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-weight: 700;
  font-size: 15px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: #fffdf8;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--leaf);
  outline: none;
}

textarea.essay {
  min-height: 190px;
  resize: vertical;
  line-height: 1.7;
  font-size: 18px;
}

/* ---------- Đăng nhập ---------- */

.auth {
  max-width: 420px;
  margin: 24px auto;
  text-align: center;
}

.auth .mascot {
  font-size: 64px;
  line-height: 1;
}

.auth h1 {
  font-size: 26px;
  margin: 10px 0 4px;
}

.auth form {
  text-align: left;
  margin-top: 16px;
}

.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 16px;
  background: var(--sun-soft);
  margin-top: 16px;
}

.switch button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 800;
  color: var(--ink-soft);
}

.switch button.on {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------- Hôm nay ---------- */

.hero {
  position: relative;
  overflow: hidden;
  margin-top: 6px;
  padding: 18px 18px 20px;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(160deg, #2aa86f, #1f8a5b 60%, #177a4f);
}

.hero.review {
  background: linear-gradient(160deg, #4f8fe0, #2f7fd8 60%, #2668b5);
}

.hero.free {
  background: linear-gradient(160deg, #9a6be0, #6d3fb5 60%, #5a3196);
}

.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hero h2 {
  font-size: 24px;
  margin: 8px 0 2px;
}

.hero p {
  margin: 0;
  font-size: 15px;
  opacity: 0.93;
}

.timer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 700;
}

.timer .track {
  flex: 1;
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.timer .track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--sun);
}

.stepper {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin: 18px 2px 4px;
}

.stepper::before {
  content: "";
  position: absolute;
  left: 28px;
  right: 28px;
  top: 22px;
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
}

.step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 64px;
  padding: 0;
  border: 0;
  background: none;
}

.step .dot {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 21px;
  background: var(--paper);
  border: 3px solid var(--line-strong);
  transition: transform 0.15s;
}

.step .label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.2;
}

.step.done .dot {
  background: var(--leaf);
  border-color: var(--leaf);
  color: #fff;
}

.step.now .dot {
  background: var(--sun);
  border-color: var(--sun-dark);
  transform: scale(1.12);
  box-shadow: 0 0 0 6px rgba(255, 201, 60, 0.3);
}

.step.now .label {
  color: var(--ink);
}

.stage-card {
  scroll-margin-top: 80px;
}

.stage-card > h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Ôn từ */
.quiz-meaning {
  font-size: 20px;
  font-weight: 800;
  margin: 6px 0 14px;
}

.progress-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.progress-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
}

.progress-dots i.on {
  background: var(--sun-dark);
}

.options {
  display: grid;
  gap: 10px;
}

@media (min-width: 560px) {
  .options.two {
    grid-template-columns: 1fr 1fr;
  }
}

.option {
  width: 100%;
  min-height: 54px;
  padding: 10px 16px;
  border: 2px solid var(--line-strong);
  border-radius: 16px;
  background: var(--paper);
  font-weight: 700;
  text-align: left;
  box-shadow: 0 3px 0 var(--line);
}

.option:hover:not(:disabled) {
  border-color: var(--sun-dark);
}

.option.ok {
  border-color: var(--leaf);
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

.option.no {
  border-color: var(--berry);
  background: var(--berry-soft);
  color: var(--berry);
}

/* Thẻ từ */
.flash-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .flash-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.flash {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 132px;
  padding: 16px;
  border: 0;
  border-radius: 20px;
  text-align: left;
  background: var(--sun-soft);
  box-shadow: inset 0 -4px 0 rgba(224, 166, 0, 0.35);
}

.flash .hint {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.flash .word {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
}

.flash[aria-pressed="true"] {
  background: var(--sky-soft);
  box-shadow: inset 0 -4px 0 rgba(47, 127, 216, 0.25);
}

.flash .meaning {
  font-weight: 700;
}

.flash .example {
  font-style: italic;
  color: var(--ink-soft);
}

/* Soi câu hay */
.compare {
  display: grid;
  gap: 10px;
}

.sentence {
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 18px;
  line-height: 1.8;
}

.sentence small {
  display: block;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.sentence.plain {
  background: #f4efe4;
  color: var(--ink-soft);
}

.sentence.good {
  background: var(--leaf-soft);
  color: var(--ink);
  font-weight: 600;
}

.sentence.good small {
  font-family: inherit;
  color: var(--leaf-dark);
}

.hl {
  padding: 1px 8px;
  margin: 0 1px;
  border: 0;
  border-radius: 10px;
  background: var(--sun);
  font: inherit;
  font-weight: 700;
  box-shadow: 0 2px 0 var(--sun-dark);
}

.hl.seen {
  background: var(--sun-soft);
  box-shadow: inset 0 0 0 2px var(--sun-dark);
}

/* Ngữ pháp */
.grammar {
  margin-top: 6px;
}

.parsed-box {
  margin-top: 12px;
  border-radius: 18px;
  padding: 14px 16px;
  background: #fbf6ec;
}

.parsed-box small {
  display: block;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.parsed {
  font-size: 18px;
  line-height: 2.6;
  margin: 0;
}

.chunk {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: top;
  margin: 0 2px;
  line-height: 1.3;
}

.chunk-text {
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 700;
  border-bottom: 3px solid currentColor;
}

.chunk-label {
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}

.tone-a { color: #1f5fa8; }
.tone-a .chunk-text { background: var(--sky-soft); }
.tone-b { color: var(--leaf-dark); }
.tone-b .chunk-text { background: var(--leaf-soft); }
.tone-c { color: #8a4b00; }
.tone-c .chunk-text { background: var(--sun-soft); }
.tone-d { color: var(--grape); }
.tone-d .chunk-text { background: var(--grape-soft); }
.tone-e { color: var(--berry); }
.tone-e .chunk-text { background: var(--berry-soft); }

.tap-line {
  white-space: pre-line;
  font-size: 18px;
  line-height: 2.4;
  margin: 6px 0 0;
}

.tap {
  margin: 0 1px;
  padding: 4px 8px;
  border: 2px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
}

.tap:hover:not(:disabled) {
  border-color: var(--sun-dark);
}

.tap.ok {
  border: 2px solid var(--leaf);
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

.tap.no {
  border: 2px solid var(--berry);
  background: var(--berry-soft);
  animation: shake 0.35s;
}

/* Trò chơi */
.game-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  margin: 18px 0 6px;
}

.match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.match h4 {
  margin-bottom: 6px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.chip {
  width: 100%;
  min-height: 52px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 700;
}

.chip.sel {
  border-color: var(--sun-dark);
  background: var(--sun-soft);
}

.chip.ok {
  border-color: var(--leaf);
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

.chip.shake {
  border-color: var(--berry);
  animation: shake 0.35s;
}

@keyframes shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.blank {
  display: inline-block;
  min-width: 70px;
  border-bottom: 3px dashed var(--sun-dark);
  text-align: center;
  font-weight: 800;
  color: var(--leaf-dark);
}

.idiom {
  border-radius: 18px;
  padding: 16px;
  background: var(--grape-soft);
  color: #3b1f6b;
}

.idiom q {
  display: block;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.why {
  margin-top: 8px;
  font-size: 15px;
  color: var(--leaf-dark);
  font-weight: 600;
}

/* Viết */
.prompt {
  border-left: 6px solid var(--sun);
  padding: 10px 14px;
  border-radius: 6px 16px 16px 6px;
  background: var(--sun-soft);
  font-size: 18px;
  font-weight: 700;
}

.checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14.5px;
  font-weight: 700;
}

.check[aria-pressed="true"] {
  border-color: var(--leaf);
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

.counter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -4px;
  font-size: 14px;
  font-weight: 700;
}

.counter span {
  padding: 3px 10px;
  border-radius: 999px;
  background: #f4efe4;
  color: var(--ink-soft);
}

.counter span.ok {
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

details.sample {
  margin-top: 12px;
  border-radius: 16px;
  background: #f7f2e8;
  padding: 10px 14px;
}

details.sample summary {
  cursor: pointer;
  font-weight: 800;
  min-height: 32px;
}

details.sample p {
  margin-top: 8px;
  font-size: 17px;
}

/* ---------- Kết quả chấm ---------- */

.score {
  display: flex;
  gap: 16px;
  align-items: center;
}

.ring {
  flex: none;
  width: 104px;
  height: 104px;
}

.ring .bg {
  stroke: var(--line);
}

.ring .fg {
  transition: stroke-dasharray 0.6s ease-out;
}

.ring .num {
  font-weight: 800;
  font-size: 26px;
  fill: var(--ink);
}

.ring .den {
  font-size: 11px;
  fill: var(--ink-soft);
}

.bars {
  flex: 1;
  display: grid;
  gap: 7px;
  min-width: 0;
}

.bar {
  display: grid;
  grid-template-columns: 1fr 28px;
  gap: 2px 8px;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
}

.bar .name {
  grid-column: 1 / -1;
  color: var(--ink-soft);
}

.bar .track {
  height: 10px;
  border-radius: 10px;
  background: var(--line);
  overflow: hidden;
}

.bar .track i {
  display: block;
  height: 100%;
  border-radius: 10px;
  background: var(--sky);
}

.bar .track i.low {
  background: var(--berry);
}

.bar .track i.high {
  background: var(--leaf);
}

.bar b {
  text-align: right;
}

.fixes {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.fixes li {
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 15px;
  background: var(--berry-soft);
}

.fixes li b {
  color: var(--berry);
}

.fixes li.spell {
  background: var(--sun-soft);
}

.fixes li.spell b {
  color: var(--coin);
}

.comment {
  margin-top: 12px;
  font-style: italic;
}

.analysis {
  margin-top: 14px;
}

.analysis h4 {
  font-size: 15px;
  margin-bottom: 6px;
}

.analysis .fixes {
  margin-top: 0;
}

.good-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.good-list li {
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 15px;
  background: var(--leaf-soft);
}

details.sentences {
  border-radius: 16px;
  background: #f7f2e8;
  padding: 10px 14px;
}

details.sentences summary {
  min-height: 32px;
  font-weight: 800;
  cursor: pointer;
}

details.sentences ol {
  margin: 8px 0 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
}

details.sentences q {
  display: block;
  font-weight: 700;
}

details.sentences li p {
  margin: 2px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.rewrite {
  margin-top: 14px;
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--sky-soft);
  border-left: 6px solid var(--sky);
}

.rewrite h4 {
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--sky-dark);
}

.rewrite p {
  font-size: 17px;
  line-height: 1.75;
  margin-bottom: 6px;
}

.rewrite small {
  color: var(--ink-soft);
  font-size: 13px;
}

.reward {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.reward div {
  flex: 1;
  padding: 10px;
  border-radius: 16px;
  text-align: center;
  font-weight: 800;
}

.reward .c {
  background: var(--sun-soft);
  color: var(--coin);
}

.reward .x {
  background: var(--grape-soft);
  color: var(--grape);
}

/* ---------- Hoàn thành ---------- */

.celebrate {
  text-align: center;
  padding: 28px 18px;
}

.celebrate .big {
  font-size: 72px;
  line-height: 1;
  animation: pop 0.6s ease-out;
}

.celebrate h2 {
  font-size: 24px;
  margin: 12px 0 6px;
}

@keyframes pop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: fall 2.2s ease-in forwards;
}

@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.7; }
}

/* ---------- Lộ trình ---------- */

.stage {
  margin-top: 18px;
}

.stage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stage-head h2 {
  font-size: 18px;
}

.stage-head span {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.lessons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.lesson {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 96px;
  padding: 12px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.lesson .num {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.lesson .title {
  font-weight: 800;
  line-height: 1.3;
}

.lesson .state {
  margin-top: auto;
  font-size: 13.5px;
  font-weight: 700;
}

.lesson.done {
  background: var(--leaf-soft);
}

.lesson.done .state {
  color: var(--leaf-dark);
}

.lesson.now {
  background: var(--sun-soft);
  box-shadow: inset 0 0 0 3px var(--sun-dark);
}

.lesson.locked {
  background: #f4efe4;
  box-shadow: none;
  color: #8f897b;
}

/* ---------- Kho từ ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.toggle {
  min-height: 40px;
  padding: 6px 14px;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 700;
  font-size: 14.5px;
}

.toggle[aria-pressed="true"] {
  border-color: var(--leaf);
  background: var(--leaf);
  color: #fff;
}

.word-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

@media (min-width: 640px) {
  .word-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.word-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.word-card h3 {
  font-size: 20px;
}

.word-card p {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 15px;
}

.word-card .example {
  font-style: italic;
  color: var(--ink-soft);
}

.level {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.level i {
  width: 14px;
  height: 6px;
  border-radius: 6px;
  background: var(--line-strong);
}

.level i.on {
  background: var(--leaf);
}

/* ---------- Bài viết ---------- */

.essay-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
  margin-top: 10px;
  color: inherit;
  text-decoration: none;
}

.essay-item .badge-score {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 18px;
  background: var(--sky-soft);
  color: var(--sky-dark);
}

.essay-item .badge-score.none {
  background: #f4efe4;
  color: var(--ink-soft);
  font-size: 13px;
}

.essay-item .meta {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.essay-item .preview {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.essay-text {
  font-size: 18px;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ---------- Tiến bộ ---------- */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (min-width: 900px) {
  .tiles {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tile {
  padding: 14px;
  border-radius: 20px;
}

.tile b {
  display: block;
  font-size: 26px;
  line-height: 1.15;
}

.tile span {
  font-size: 13px;
  font-weight: 700;
}

.tile.c {
  background: var(--sun-soft);
  color: var(--coin);
}

.tile.f {
  background: var(--berry-soft);
  color: var(--berry);
}

.tile.x {
  background: var(--grape-soft);
  color: var(--grape);
}

.tile.l {
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

.mini {
  height: 8px;
  margin-top: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.mini i {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: currentColor;
}

.grid-2 {
  display: grid;
  gap: 0 14px;
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart .grid-line {
  stroke: var(--line);
  stroke-dasharray: 4 4;
}

.chart .label {
  font-size: 11px;
  font-weight: 700;
  fill: var(--ink-soft);
}

.chart .val {
  font-size: 12px;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  font-weight: 800;
}

.chart .plus {
  fill: var(--leaf);
}

.chart .minus {
  fill: #e07a1f;
}

.chart .val.plus {
  fill: var(--leaf-dark);
}

.chart .val.minus {
  fill: #a34f00;
}

.chart .line {
  fill: none;
  stroke: var(--sky);
  stroke-width: 3;
  stroke-linejoin: round;
}

.chart .pt {
  fill: var(--paper);
  stroke: var(--sky);
  stroke-width: 3;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cal-head h3 {
  font-size: 18px;
}

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.cal .h {
  font-size: 11.5px;
  color: var(--ink-soft);
}

.cal .d {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 10px;
  background: #f4efe4;
  color: #8f897b;
}

.cal .d.ok {
  background: var(--leaf);
  color: #fff;
}

.cal .d.ex {
  background: var(--sun);
  color: #4a3200;
}

.cal .d.miss {
  background: var(--berry-soft);
  color: var(--berry);
}

.cal .d.today {
  box-shadow: inset 0 0 0 3px var(--ink);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 4px;
  vertical-align: -1px;
}

.legend .sw-ok { background: var(--leaf); }
.legend .sw-ex { background: var(--sun); }
.legend .sw-miss { background: var(--berry-soft); box-shadow: inset 0 0 0 1px var(--berry); }
.legend .sw-plus { background: var(--leaf); }
.legend .sw-minus { background: #e07a1f; }

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  background: var(--sun-soft);
  color: var(--coin);
}

.badge.off {
  background: #f4efe4;
  color: #a39d8f;
  filter: grayscale(1);
}

.ledger {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ledger li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line-strong);
}

.ledger li:last-child {
  border-bottom: 0;
}

.ledger small {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
}

.ledger .amt {
  font-weight: 800;
  font-size: 17px;
}

.ledger .amt.p {
  color: var(--leaf-dark);
}

.ledger .amt.m {
  color: var(--berry);
}

.spell-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spell-list span {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--sun-soft);
  font-size: 14.5px;
  font-weight: 600;
}

/* ---------- Cài đặt ---------- */

.panel {
  margin-top: 12px;
  border-radius: 18px;
  background: #fbf6ec;
}

.panel > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.panel > summary::-webkit-details-marker {
  display: none;
}

.panel > summary::after {
  content: "›";
  margin-left: auto;
  font-size: 24px;
  transition: transform 0.2s;
}

.panel[open] > summary::after {
  transform: rotate(90deg);
}

.panel > div {
  padding: 4px 16px 16px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.seg button {
  min-height: 50px;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 800;
}

.seg button[aria-pressed="true"] {
  border-color: var(--leaf);
  background: var(--leaf-soft);
  color: var(--leaf-dark);
}

.key-saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 8px 8px 8px 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: var(--leaf-soft);
  font-weight: 700;
}

.key-saved code {
  font-size: 15px;
}

/* ---------- Thông báo ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + 16px);
  z-index: 30;
  max-width: min(92vw, 480px);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.loading {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .confetti {
    display: none;
  }
}
