* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #657085;
  --line: #dde5ef;
  --panel: #ffffff;
  --soft: #f5f8fc;
  --mint: #dff7ea;
  --mint-ink: #11653b;
  --peach: #ffe8d8;
  --peach-ink: #8a3b11;
  --berry: #f9d7e6;
  --blue: #ddebff;
  --yellow: #fff1b8;
  --ok: #1d8f55;
  --bad: #d44747;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7fb 100%);
  color: var(--ink);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: #172033; color: white; font-size: 22px;
}
.role-tabs { display: flex; gap: 8px; padding: 5px; background: #eef3f8; border-radius: 14px; }
.role-tabs button {
  padding: 10px 14px; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700;
}
.role-tabs button.active { background: white; color: var(--ink); box-shadow: 0 4px 14px rgba(24,40,72,.08); }
.page { width: min(1180px, calc(100% - 32px)); margin: 24px auto 44px; }
.grid { display: grid; gap: 18px; }
.student-layout { grid-template-columns: 280px minmax(0, 1fr) 330px; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 34px rgba(28,47,72,.06);
}
.panel-pad { padding: 18px; }
.kid-card { background: linear-gradient(135deg, #ffffff, #eef9f1); }
.kid-avatar {
  width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center;
  background: var(--yellow); font-size: 40px; margin-bottom: 12px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; line-height: 1.15; margin-bottom: 8px; letter-spacing: 0; }
h2 { font-size: 20px; margin-bottom: 12px; }
h3 { font-size: 15px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--mint-ink); font-weight: 800; font-size: 13px; margin-bottom: 8px; text-transform: uppercase; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { padding: 12px; background: var(--soft); border-radius: 8px; min-height: 78px; }
.stat strong { display: block; font-size: 22px; }
.daily-rule {
  margin-top: 14px; padding: 12px; border-radius: 8px; background: var(--mint);
  color: var(--mint-ink); font-weight: 700; line-height: 1.35;
}
.section-head { padding: 18px 18px 4px; display: flex; justify-content: space-between; gap: 14px; }
.lesson-card {
  padding: 18px; display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: center;
  border-bottom: 1px solid var(--line);
}
.lesson-card:last-child { border-bottom: 0; }
.lesson-card.active-lesson { background: #fbfffd; }
.lesson-card.locked-lesson { opacity: .72; }
.lesson-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; font-size: 32px; background: var(--peach); }
.lesson-title { font-weight: 800; margin-bottom: 4px; }
.mini-meta { display: inline-block; margin-top: 8px; padding: 5px 8px; border-radius: 999px; background: #eef3f8; color: var(--muted); font-weight: 700; font-size: 12px; }
.primary, .secondary {
  padding: 12px 16px; border-radius: 12px; font-weight: 800; white-space: nowrap;
}
.primary { background: #172033; color: white; }
.secondary { background: #edf3f8; color: #172033; }
.lock-btn {
  padding: 12px 16px; border-radius: 12px; font-weight: 800; white-space: nowrap;
  background: #f0f2f5; color: #8b95a5; cursor: not-allowed;
}
.exercise { padding: 22px; }
.lesson-progress { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.timer-card {
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  padding: 13px 14px; border-radius: 8px; background: #eef8ff; border: 1px solid #cae3f7;
  color: #164b6d; margin-bottom: 16px;
}
.timer-card span { color: #42677d; font-weight: 700; }
.step {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 999px;
  background: #edf3f8; color: var(--muted); font-weight: 800; font-size: 13px;
}
.step span {
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  background: white; color: inherit;
}
.step.active { background: #172033; color: white; }
.question {
  background: #fffaf0; border: 1px solid #f5df9c; border-radius: 8px; padding: 18px;
}
.objects { font-size: 34px; line-height: 1.55; letter-spacing: 0; margin: 14px 0; }
.objects.expression {
  font-size: 30px; font-weight: 900; color: #172033;
  background: white; border: 1px dashed #d6c071; border-radius: 8px; padding: 14px;
}
.scratchpad {
  margin-top: 14px; border: 1px solid #d9e2ec; border-radius: 8px; overflow: hidden;
  background: #fff;
}
.scratch-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid #d9e2ec; background: #f7fbff;
}
.scratch-head div { display: grid; gap: 4px; }
.scratch-head strong { font-size: 15px; }
.scratch-head span { color: var(--muted); font-size: 13px; line-height: 1.3; }
.icon-btn {
  flex: 0 0 auto; padding: 9px 11px; border-radius: 10px; background: #edf3f8;
  color: #172033; font-weight: 800;
}
.scratchpad textarea {
  display: block; width: 100%; min-height: 220px; resize: vertical; border: 0; outline: none;
  padding: 14px 16px; color: #172033; line-height: 32px; font-size: 18px;
  background:
    linear-gradient(#ffffff 31px, #dfeaf4 32px);
  background-size: 100% 32px;
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}
.answer-row { display: flex; gap: 10px; margin-top: 14px; }
.answer-row input {
  width: 120px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 22px; font-weight: 800; text-align: center;
}
.teacher-note { margin: 14px 0 0; color: var(--peach-ink); font-weight: 700; font-size: 14px; }
.success-card { background: #f0fff6; border-color: #b9e9cb; }
.homework-grid { display: grid; gap: 12px; margin-bottom: 16px; }
.homework-card {
  padding: 14px; border-radius: 8px; background: #f8fbff; border: 1px solid var(--line);
  display: grid; gap: 6px;
}
.homework-card strong { font-size: 15px; }
.homework-card span { color: var(--muted); line-height: 1.35; }
.teacher {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(680px, calc(100vh - 116px));
  min-height: 480px;
  overflow: hidden;
  position: sticky;
  top: 86px;
}
.teacher-head { padding: 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.teacher-face { width: 48px; height: 48px; border-radius: 16px; background: var(--blue); display: grid; place-items: center; font-size: 28px; }
.chat {
  min-height: 0; padding: 16px; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain;
}
.bubble { padding: 11px 12px; border-radius: 14px; line-height: 1.35; max-width: 94%; }
.ai { background: #eef6ff; align-self: flex-start; }
.me { background: #e8f8ef; align-self: flex-end; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.parent-layout { grid-template-columns: 1fr 360px; align-items: start; }
.progress-list { display: grid; gap: 12px; }
.insight-grid { display: grid; gap: 12px; }
.insight {
  display: grid; gap: 6px; padding: 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff;
}
.insight strong { font-size: 14px; }
.insight span { color: var(--muted); line-height: 1.35; }
.insight.good { border-color: #bae7ca; background: #f1fff6; }
.insight.warn { border-color: #efd27e; background: #fff9e8; }
.insight.info { border-color: #c9dcf7; background: #f3f8ff; }
.progress-item { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.bar { height: 10px; background: #edf2f7; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: #2fa66a; }
.alert { background: #fff7df; border: 1px solid #efd27e; color: #65480f; padding: 14px; border-radius: 8px; }
.timeline { display: grid; gap: 10px; }
.timeline-item { display: grid; grid-template-columns: 80px 1fr; gap: 10px; color: var(--muted); }
.reward-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.reward { width: 38px; height: 38px; border-radius: 12px; background: var(--yellow); display: grid; place-items: center; }
.parent-day {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.parent-day:last-child { border-bottom: 0; }
.parent-day em { font-style: normal; color: var(--muted); font-weight: 700; }
.parent-day.active em { color: var(--ok); }
.parent-day.locked { opacity: .7; }
@media (max-width: 1040px) {
  .student-layout, .parent-layout { grid-template-columns: 1fr; }
  .teacher { height: 520px; min-height: 420px; position: static; }
}
@media (max-width: 620px) {
  .topbar { height: auto; padding: 12px; align-items: stretch; flex-direction: column; gap: 10px; }
  .role-tabs { width: 100%; }
  .role-tabs button { flex: 1; }
  .lesson-card { grid-template-columns: 54px 1fr; }
  .lesson-card .primary, .lesson-card .lock-btn { grid-column: 1 / -1; width: 100%; }
  .answer-row { flex-wrap: wrap; }
  .answer-row .primary, .answer-row .secondary { flex: 1; }
  .parent-day { grid-template-columns: 1fr; gap: 4px; }
  .timer-card { align-items: flex-start; flex-direction: column; }
  .scratch-head { align-items: stretch; flex-direction: column; }
  .icon-btn { width: 100%; }
  .scratchpad textarea { min-height: 180px; font-size: 16px; }
}
