:root {
  --ink: #17342c;
  --muted: #6c7b74;
  --paper: #f5f1e8;
  --card: #fffdf8;
  --green: #1e6b55;
  --green-2: #2c8469;
  --lime: #c8de77;
  --peach: #ef9d78;
  --line: #ddd9ce;
  --danger: #d35f52;
  --warning: #d89530;
  --shadow: 0 24px 70px rgba(36, 57, 49, 0.10);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 4%, rgba(200, 222, 119, .20), transparent 26rem),
    radial-gradient(circle at 92% 35%, rgba(239, 157, 120, .13), transparent 24rem),
    var(--paper);
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
  min-height: 100vh;
}

button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(44, 132, 105, .3); outline-offset: 3px; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.topbar {
  height: 88px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(23, 52, 44, .12);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 500; width: max-content; }
.brand b { font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--green); border-radius: 50% 50% 50% 12%; font-family: Georgia, serif; font-size: 20px; font-weight: 700; transform: rotate(-5deg); }

.nav { display: flex; gap: 10px; padding: 5px; border: 1px solid var(--line); border-radius: 30px; background: rgba(255,255,255,.35); }
.nav-item { border: 0; background: none; color: var(--muted); padding: 8px 22px; border-radius: 22px; cursor: pointer; font-weight: 600; }
.nav-item.active { color: #fff; background: var(--ink); }
.streak-pill { justify-self: end; display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: #fff9ed; border: 1px solid #e4d6bb; border-radius: 24px; color: var(--ink); cursor: default; }

main { min-height: calc(100vh - 170px); }
.view { display: none; animation: fadeUp .35s ease; }
.active-view { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

.hero-row { display: flex; justify-content: space-between; align-items: end; padding: 54px 0 34px; }
.eyebrow { margin: 0 0 10px; font-size: 11px; letter-spacing: .18em; font-weight: 700; color: var(--green-2); }
h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-weight: 500; font-size: clamp(34px, 4vw, 53px); letter-spacing: -.035em; }
.hero-subtitle { margin: 12px 0 0; color: var(--muted); font-size: 16px; }
.daily-progress { display: flex; align-items: center; gap: 11px; padding-bottom: 3px; }
.daily-progress svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring-bg, .ring-value { fill: none; stroke-width: 4; }
.ring-bg { stroke: #dedbd1; }
.ring-value { stroke: var(--green-2); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1; transition: stroke-dashoffset .6s ease; }
.daily-progress div { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 4px; }
.daily-progress strong { font-size: 23px; }
.daily-progress span { font-size: 12px; color: var(--muted); }

.workspace { display: grid; grid-template-columns: 245px 1fr; gap: 24px; align-items: stretch; }
.scenes-panel, .practice-card, .history-card { background: rgba(255,253,248,.88); border: 1px solid rgba(23,52,44,.12); box-shadow: var(--shadow); }
.scenes-panel { border-radius: 22px; padding: 20px 14px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 14px; font-weight: 700; font-size: 14px; }
.icon-button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; color: var(--green); }
.icon-button:hover { background: #eef3e7; transform: rotate(20deg); }
.scene-list { display: grid; gap: 7px; }
.scene-button { display: grid; grid-template-columns: 38px 1fr; grid-template-rows: 1fr 1fr; column-gap: 10px; align-items: center; width: 100%; padding: 11px; text-align: left; background: transparent; border: 0; border-radius: 13px; color: var(--ink); cursor: pointer; }
.scene-button:hover { background: #f2f0e8; }
.scene-button.active { background: var(--ink); color: #fff; }
.scene-icon { grid-row: 1 / 3; width: 38px; height: 38px; display: grid; place-items: center; background: rgba(200,222,119,.35); border-radius: 11px; font-size: 18px; }
.scene-button.active .scene-icon { color: var(--ink); background: var(--lime); }
.scene-name { font-weight: 700; font-size: 14px; align-self: end; }
.scene-meta { opacity: .62; font-size: 11px; align-self: start; margin-top: 2px; }

.practice-card { min-height: 570px; border-radius: 26px; padding: 26px 36px 24px; position: relative; overflow: hidden; }
.practice-card::after { content: ""; width: 180px; height: 180px; border: 34px solid rgba(200,222,119,.10); border-radius: 50%; position: absolute; right: -105px; top: 120px; pointer-events: none; }
.card-topline { display: flex; justify-content: space-between; align-items: center; }
.level-chip { display: inline-flex; padding: 7px 12px; color: var(--green); background: #edf1df; border-radius: 20px; font-size: 12px; font-weight: 700; }
.counter { color: #9aa29e; font-size: 12px; letter-spacing: .08em; }
.prompt-block { text-align: center; padding: 26px 0 4px; }
.prompt-label, .result-kicker { margin: 0 0 9px; color: var(--muted); font-size: 12px; }
.prompt-block h2 { margin: 0 auto 17px; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(27px, 3.2vw, 40px); font-weight: 500; letter-spacing: -.02em; }
.hint-button { border: 0; background: transparent; color: var(--green-2); cursor: pointer; font-size: 13px; font-weight: 600; }
.bulb { display: inline-grid; place-items: center; width: 21px; height: 21px; margin-right: 5px; border-radius: 50%; background: var(--lime); color: var(--ink); }
.english-answer { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 11px; min-height: 31px; font-size: 20px; color: var(--green); font-weight: 600; animation: fadeUp .25s ease; }
.speak-mini { border: 0; background: #edf1df; width: 31px; height: 31px; border-radius: 50%; cursor: pointer; }

.record-area { text-align: center; padding: 20px 0 22px; }
.pulse-wrap { width: 106px; height: 106px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 50%; background: rgba(239,157,120,.16); transition: .2s; }
.record-button { width: 76px; height: 76px; border: 0; border-radius: 50%; cursor: pointer; background: var(--peach); box-shadow: 0 10px 25px rgba(210,111,80,.28), inset 0 0 0 1px rgba(255,255,255,.4); transition: transform .2s, background .2s; }
.record-button:hover { transform: scale(1.05); }
.mic-icon { display: block; width: 18px; height: 28px; margin: auto; border: 3px solid #fff; border-radius: 12px; position: relative; }
.mic-icon::before { content: ""; position: absolute; width: 28px; height: 19px; border: 3px solid #fff; border-top: 0; border-radius: 0 0 16px 16px; left: -8px; top: 12px; }
.mic-icon::after { content: ""; position: absolute; width: 3px; height: 8px; background: #fff; left: 5px; top: 28px; box-shadow: -5px 7px 0 0 #fff, 0 7px 0 0 #fff, 5px 7px 0 0 #fff; }
.pulse-wrap.listening { animation: pulse 1.4s infinite; background: rgba(239,157,120,.32); }
.pulse-wrap.listening .record-button { background: var(--danger); transform: scale(.92); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,157,120,.3); } 50% { box-shadow: 0 0 0 15px rgba(239,157,120,0); } }
.record-title { margin: 0; font-weight: 700; font-size: 14px; }
.record-tip { margin: 5px 0 0; color: #9aa29e; font-size: 11px; }

.result-panel { margin: 8px 0 22px; padding: 20px; border: 1px solid #dcded5; background: #f8f8f1; border-radius: 17px; animation: fadeUp .3s ease; }
.result-header { display: flex; align-items: center; justify-content: space-between; }
.result-header h3 { margin: 0; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.score-orb { display: flex; align-items: baseline; gap: 2px; color: var(--green); }
.score-orb strong { font-size: 30px; }
.score-orb span { font-size: 11px; }
.heard-row, .word-analysis { display: grid; grid-template-columns: 62px 1fr; gap: 10px; margin-top: 14px; align-items: start; }
.heard-row > span, .word-analysis > span { color: var(--muted); font-size: 11px; padding-top: 4px; }
.heard-row p { margin: 0; font-size: 14px; }
.word-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.word-token { padding: 4px 8px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.word-token.correct { color: var(--green); background: #e2f0e8; }
.word-token.wrong { color: var(--danger); background: #f9e4df; text-decoration: underline wavy rgba(211,95,82,.45); text-underline-offset: 3px; }
.word-token.missing { color: #ad6e15; background: #f8ebcf; border: 1px dashed #d8a654; }
.corrections { display: grid; gap: 7px; margin-top: 14px; }
.correction-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 11px; border-radius: 9px; background: #fff; border-left: 3px solid var(--peach); font-size: 12px; }
.correction-item strong { color: var(--danger); }
.correction-item button { flex: 0 0 auto; border: 0; background: #edf1df; border-radius: 16px; padding: 5px 9px; color: var(--green); cursor: pointer; }
.result-note { margin: 13px 0 0; color: #929b96; font-size: 10px; }

.card-actions { display: flex; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.secondary-button, .next-button { padding: 11px 18px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 13px; }
.secondary-button { color: var(--ink); border: 1px solid var(--line); background: transparent; }
.secondary-button:hover { background: #f2f0e8; }
.next-button { color: #fff; background: var(--green); border: 1px solid var(--green); }
.next-button:hover { background: var(--ink); }
.next-button span { margin-left: 12px; }

.learning-tip { display: flex; align-items: center; gap: 15px; margin: 24px 0 50px; padding: 18px 22px; background: rgba(255,255,255,.33); border: 1px solid rgba(23,52,44,.1); border-radius: 16px; }
.tip-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; color: var(--ink); background: var(--lime); border-radius: 50% 50% 50% 13px; font-size: 20px; }
.learning-tip p { margin: 0 0 3px; color: var(--green); font-size: 11px; font-weight: 700; }
.learning-tip strong { font-size: 13px; font-weight: 500; }

.progress-page-head { padding: 60px 0 32px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.stat-card { padding: 23px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.stat-card.accent { background: var(--ink); color: #fff; }
.stat-card span { display: block; color: inherit; opacity: .65; font-size: 12px; }
.stat-card strong { display: inline-block; margin: 12px 5px 0 0; font-size: 34px; }
.stat-card small { opacity: .65; }
.history-card { margin: 22px 0 50px; padding: 20px; border-radius: 20px; box-shadow: none; }
.history-list { display: grid; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 14px 8px; border-top: 1px solid var(--line); }
.history-item p { margin: 0 0 4px; font-weight: 600; }
.history-item span { color: var(--muted); font-size: 11px; }
.history-score { align-self: center; font-size: 18px !important; font-weight: 700; color: var(--green) !important; }
.empty-history { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

footer { display: flex; justify-content: space-between; padding: 26px 2px; border-top: 1px solid rgba(23,52,44,.12); color: var(--muted); font-size: 11px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 11px 17px; color: #fff; background: var(--ink); border-radius: 11px; box-shadow: 0 10px 35px rgba(0,0,0,.2); font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  .page-shell { width: min(100% - 24px, 680px); }
  .topbar { height: 72px; grid-template-columns: 1fr auto; }
  .nav { position: fixed; z-index: 10; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(255,253,248,.95); box-shadow: 0 8px 28px rgba(0,0,0,.16); backdrop-filter: blur(10px); }
  .streak-pill { display: none; }
  .hero-row { align-items: start; padding: 36px 0 24px; }
  .daily-progress { padding-top: 8px; }
  .workspace { grid-template-columns: 1fr; }
  .scenes-panel { padding: 12px; overflow: hidden; }
  .scenes-panel .panel-heading { display: none; }
  .scene-list { display: flex; overflow-x: auto; scrollbar-width: none; }
  .scene-button { min-width: 145px; }
  .practice-card { min-height: auto; padding: 22px 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  footer { padding-bottom: 82px; }
}

@media (max-width: 480px) {
  .brand { font-size: 16px; }
  .hero-row { display: block; }
  .daily-progress { margin-top: 20px; }
  .practice-card { padding: 18px 14px; }
  .prompt-block { padding-top: 22px; }
  .record-area { padding-top: 14px; }
  .card-actions { flex-direction: column-reverse; }
  .card-actions button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 16px; }
  .heard-row, .word-analysis { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
