:root {
  --bg: #f7f4ff;
  --surface: #ffffff;
  --ink: #251f35;
  --muted: #6e687c;
  --primary: #6848c7;
  --primary-dark: #5337aa;
  --soft: #eee8ff;
  --success: #18794e;
  --success-bg: #e9f8f0;
  --error: #b42318;
  --error-bg: #fff0ee;
  --warning: #8a5b00;
  --border: #ddd5ef;
  --shadow: 0 12px 35px rgba(55, 38, 96, 0.10);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, #eee8ff 0, transparent 36rem), var(--bg); }
button, input { font: inherit; }
button { touch-action: manipulation; }

.app-header {
  min-height: 74px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
  background: rgba(247, 244, 255, .88);
  border-bottom: 1px solid rgba(221, 213, 239, .8);
}
.app-header #homeButton { grid-column: 1; justify-self: start; }
.brand { grid-column: 2; display: flex; align-items: center; gap: 10px; justify-self: center; }
.app-header #parentButton { grid-column: 3; justify-self: end; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--primary); color: white; font-size: 21px; transform: rotate(-6deg); }
.brand-title { font-weight: 800; font-size: 17px; line-height: 1.1; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 15px; background: var(--surface); color: var(--ink); font-size: 22px; box-shadow: 0 4px 15px rgba(55,38,96,.08); cursor: pointer; }
.icon-button:hover { transform: translateY(-1px); }
.hidden { display: none !important; }

main { width: min(940px, calc(100% - 28px)); margin: 26px auto 70px; }
.card { background: var(--surface); border: 1px solid rgba(221,213,239,.8); border-radius: 26px; box-shadow: var(--shadow); }
.hero { display: flex; align-items: center; justify-content: space-between; padding: clamp(24px, 5vw, 44px); overflow: hidden; }
.hero h1, .lesson-top h1, .result-card h1, .parent-heading h1 { margin: 5px 0 9px; font-size: clamp(29px, 6vw, 48px); line-height: 1.05; letter-spacing: -.03em; }
.hero p, .lesson-top p { color: var(--muted); margin: 0; font-size: 17px; }
.hero-star { font-size: clamp(70px, 16vw, 140px); color: #ffcb45; filter: drop-shadow(0 12px 10px rgba(170,114,0,.18)); transform: rotate(8deg); margin-right: 2vw; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px !important; font-weight: 800; color: var(--primary) !important; margin: 0; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
.summary-card { background: rgba(255,255,255,.82); border: 1px solid var(--border); border-radius: 20px; padding: 18px; text-align: center; }
.summary-card strong { display: block; font-size: 30px; color: var(--primary); }
.summary-card span { color: var(--muted); font-size: 13px; }

.next-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px; margin: 16px 0 30px; }
.next-card h2 { margin: 4px 0 6px; }
.next-card p { color: var(--muted); margin: 0; }
.primary-button, .secondary-button, .danger-button { border: 0; border-radius: 16px; padding: 13px 20px; font-weight: 800; cursor: pointer; min-height: 48px; }
.primary-button { background: var(--primary); color: white; box-shadow: 0 8px 18px rgba(104,72,199,.25); }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.secondary-button { background: var(--soft); color: var(--primary-dark); }
.danger-button { background: #ffe9e6; color: var(--error); }
.section-heading, .parent-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 15px; }
.section-heading h2 { margin: 4px 0 0; }

.week-card { margin-bottom: 16px; padding: 20px; background: rgba(255,255,255,.82); border: 1px solid var(--border); border-radius: 22px; }
.week-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 14px; }
.week-header h3 { margin: 3px 0 4px; }
.week-header p { margin: 0; color: var(--muted); font-size: 14px; }
.week-badge { white-space: nowrap; background: var(--soft); color: var(--primary-dark); border-radius: 99px; padding: 7px 11px; font-size: 12px; font-weight: 800; }
.day-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.day-button { min-height: 88px; border: 1px solid var(--border); background: var(--surface); border-radius: 17px; padding: 11px 8px; cursor: pointer; text-align: left; display: flex; flex-direction: column; justify-content: space-between; color: var(--ink); }
.day-button:hover { border-color: var(--primary); transform: translateY(-1px); }
.day-button.completed { background: var(--success-bg); border-color: #a9dfc4; }
.day-button.current { outline: 3px solid rgba(104,72,199,.18); border-color: var(--primary); }
.day-number { font-size: 12px; font-weight: 800; color: var(--muted); }
.day-title { font-size: 13px; font-weight: 750; line-height: 1.15; }
.day-status { font-size: 17px; }
.info-card { margin-top: 18px; border: 1px solid #d9c97c; background: #fffbe8; color: #5d4b00; padding: 17px 20px; border-radius: 18px; }

.lesson-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 8px 0 18px; }
.lesson-top h1 { font-size: clamp(30px, 6vw, 44px); }
.lesson-progress-text { min-width: 86px; text-align: right; color: var(--muted); }
.lesson-progress-text strong { display: block; font-size: 30px; color: var(--primary); }
.progress-track { width: 100%; height: 11px; background: #e7e0f5; border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #6848c7, #9b78ee); border-radius: inherit; transition: width .3s ease; }
.question-card { padding: clamp(22px, 5vw, 42px); min-height: 480px; display: flex; flex-direction: column; }
.skill-pill { align-self: flex-start; border-radius: 99px; padding: 7px 11px; background: var(--soft); color: var(--primary-dark); font-size: 12px; font-weight: 800; margin: 0 0 15px; }
.question-card h2 { font-size: clamp(25px, 5vw, 39px); line-height: 1.22; margin: 4px 0 25px; letter-spacing: -.02em; }
.question-visual { font-size: clamp(42px, 12vw, 84px); text-align: center; padding: 8px 0 23px; letter-spacing: .08em; }
.answer-input { display: block; width: min(360px, 100%); min-height: 70px; border: 3px solid var(--border); border-radius: 18px; font-size: 30px; font-weight: 800; text-align: center; padding: 10px 15px; color: var(--ink); background: #fcfbff; }
.answer-input:focus { outline: 4px solid rgba(104,72,199,.15); border-color: var(--primary); }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.choice-button { min-height: 66px; border: 2px solid var(--border); border-radius: 18px; background: #fcfbff; color: var(--ink); font-size: 22px; font-weight: 800; padding: 12px; cursor: pointer; }
.choice-button:hover { border-color: var(--primary); }
.choice-button.selected { background: var(--soft); border-color: var(--primary); color: var(--primary-dark); }
.choice-button.correct { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.choice-button.incorrect { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.feedback { margin-top: 19px; border-radius: 18px; padding: 15px 17px; font-weight: 700; line-height: 1.45; }
.feedback.good { background: var(--success-bg); color: var(--success); }
.feedback.try { background: #fff8e7; color: var(--warning); }
.feedback.answer { background: var(--error-bg); color: var(--error); }
.lesson-actions { margin-top: auto; padding-top: 24px; display: flex; justify-content: flex-end; }
.lesson-actions button { min-width: 155px; }

.result-card { padding: clamp(28px, 7vw, 65px); text-align: center; max-width: 680px; margin: 45px auto; }
.result-stars { color: #ffcb45; font-size: 50px; letter-spacing: 8px; }
.result-card p { color: var(--muted); }
.result-score { display: inline-flex; flex-direction: column; margin: 20px auto 30px; border-radius: 24px; padding: 18px 35px; background: var(--soft); }
.result-score strong { font-size: 43px; color: var(--primary); }
.result-score span { color: var(--muted); }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }

.parent-heading { margin-top: 8px; }
.parent-heading h1 { font-size: clamp(30px, 6vw, 44px); }
.parent-section { padding: 24px; margin-top: 17px; }
.parent-section h2 { margin: 0 0 7px; }
.muted { color: var(--muted); }
.skill-row, .history-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 15px; padding: 13px 0; border-bottom: 1px solid #eeeaf5; }
.skill-row:last-child, .history-row:last-child { border-bottom: 0; }
.skill-score { color: var(--error); font-weight: 800; }
.history-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.history-score { font-weight: 800; color: var(--primary); }
.empty-state { color: var(--muted); padding: 15px 0; }
.danger-zone { border-color: #f2c5be; }
.toast { position: fixed; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #251f35; color: white; border-radius: 99px; padding: 11px 18px; font-weight: 700; z-index: 30; box-shadow: var(--shadow); }

@media (max-width: 700px) {
  .app-header { grid-template-columns: 44px 1fr 44px; padding-left: 10px; padding-right: 10px; }
  .brand-mark { display: none; }
  .brand-title { font-size: 15px; }
  .brand-subtitle { display: none; }
  main { width: min(100% - 20px, 940px); margin-top: 15px; }
  .hero-star { font-size: 70px; }
  .summary-grid { gap: 8px; }
  .summary-card { padding: 13px 7px; }
  .summary-card strong { font-size: 24px; }
  .next-card { align-items: flex-start; flex-direction: column; }
  .next-card .primary-button { width: 100%; }
  .day-grid { grid-template-columns: repeat(2, 1fr); }
  .day-button:last-child:nth-child(odd) { grid-column: span 2; }
  .lesson-top { align-items: flex-start; }
  .lesson-progress-text { min-width: 62px; }
  .question-card { min-height: 430px; }
}

@media (max-width: 430px) {
  .hero { padding: 22px; }
  .hero-star { display: none; }
  .summary-card span { font-size: 11px; }
  .choice-grid { grid-template-columns: 1fr; }
  .lesson-actions button { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button, .secondary-button, .day-button, .choice-button, .icon-button { transition: transform .15s ease, background .15s ease, border-color .15s ease; }
  .result-stars { animation: pop .65s ease both; }
  @keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
}
