:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e2ea;
  --paper: #f7fafc;
  --panel: #ffffff;
  --blue: #2364aa;
  --green: #2d7d46;
  --coral: #c94f4f;
  --gold: #b7791f;
  --teal: #227c7c;
  --shadow: 0 14px 35px rgba(21, 37, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #edf5f7 0%, #f8fafc 42%, #eef3f0 100%);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(16px, 4vw, 48px);
}

.topbar h1,
.section-heading h2,
.hero-copy h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 2rem;
}

.version {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-pill,
.token-box,
.counter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  white-space: nowrap;
}

.progress-pill span {
  display: block;
  color: var(--green);
  font-size: 1.5rem;
}

.progress-pill small {
  color: var(--muted);
}

.app-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto 36px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  color: var(--ink);
  background: #dfeaf0;
}

.tab.is-active {
  color: #fff;
  background: var(--ink);
}

.hero-panel {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f2431;
  box-shadow: var(--shadow);
}

#geometryCanvas {
  display: block;
  width: 100%;
  height: 250px;
}

.hero-copy {
  position: absolute;
  inset: 24px auto 24px 24px;
  width: min(520px, calc(100% - 48px));
  color: #fff;
}

.hero-copy .eyebrow {
  color: #9be0cf;
}

.hero-copy h2 {
  max-width: 13ch;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
}

.hero-copy p:last-child {
  max-width: 56ch;
  line-height: 1.45;
}

.view {
  display: none;
  margin-top: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.view.is-visible {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.icon-button {
  width: 64px;
  padding: 0;
  color: var(--ink);
  background: #dfeaf0;
  font-size: 0.85rem;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 12px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.overview-card,
.study-loop {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.overview-card h3,
.study-loop h3 {
  margin: 0 0 8px;
}

.overview-card p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.overview-card ul,
.study-loop ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.study-loop {
  margin-top: 14px;
  background: #f7fafc;
}

.day-card {
  min-height: 210px;
  border: 1px solid var(--line);
  border-left: 7px solid var(--blue);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.file-list {
  margin: 12px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #f5f8fb;
  color: var(--muted);
  font-size: 0.9rem;
}

.day-card.done {
  border-left-color: var(--green);
  background: #f3fbf5;
}

.day-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.day-card p,
.day-card li {
  color: var(--muted);
  line-height: 1.45;
}

.day-card ul,
.parent-grid ul {
  padding-left: 20px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-weight: 800;
}

.check-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--green);
}

.timer-layout {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 340px);
  gap: 18px;
}

.timer-face,
.flashcard,
.quiz-box,
.study-card,
.exam-card,
.parent-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
}

.study-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.exam-start {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 220px) auto;
  align-items: end;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.exam-start h3 {
  margin: 0 0 6px;
}

.exam-start p {
  margin: 0;
  color: var(--muted);
}

.exam-start label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.exam-start select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.exam-card {
  margin-top: 14px;
}

.exam-card p:first-child {
  margin: 0 0 8px;
  color: var(--teal);
  font-weight: 900;
  text-transform: uppercase;
}

.exam-card h3 {
  margin: 0 0 18px;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  letter-spacing: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.exam-results {
  margin-top: 14px;
}

.result-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #eef7f2;
  color: var(--green);
  font-weight: 900;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.result-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.topic-result {
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  background: #f5f8fb;
}

.topic-result strong {
  display: block;
}

.study-toolbar label,
.work-pad label,
.answer-check label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.study-toolbar select,
.work-pad textarea,
.answer-check input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.study-card p:first-child {
  margin: 0 0 8px;
  color: var(--teal);
  font-weight: 900;
  text-transform: uppercase;
}

.study-card h3 {
  margin: 0 0 18px;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  letter-spacing: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.question-diagram {
  display: block;
  width: 100%;
  max-height: 300px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.source-reference {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfdff;
}

.source-reference h4 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: #eef4f7;
}

.source-reference iframe {
  display: block;
  width: 100%;
  height: 320px;
  border: 0;
  background: #fff;
}

.work-pad {
  margin-bottom: 16px;
}

.work-pad textarea,
.answer-check input {
  width: 100%;
}

.work-pad textarea {
  resize: vertical;
}

.answer-check {
  margin-bottom: 16px;
}

#liveAnswerFeedback {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
}

#liveAnswerFeedback.good {
  color: var(--green);
}

#liveAnswerFeedback.close {
  color: var(--gold);
}

.hint-box,
.step-panel,
.explanation-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f7fafc;
}

.step-panel h4,
.explanation-box h4 {
  margin: 0 0 10px;
}

.step-panel li,
.explanation-box li {
  margin: 8px 0;
  line-height: 1.45;
}

.explanation-box p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.timer-face {
  display: grid;
  place-items: center;
  min-height: 260px;
  text-align: center;
}

.timer-face span {
  color: var(--coral);
  font-weight: 900;
  text-transform: uppercase;
}

.timer-face strong {
  display: block;
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 1;
}

.timer-face p {
  max-width: 36ch;
  margin: 0;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: start;
}

.controls button:nth-child(2) {
  background: var(--gold);
}

.controls button:nth-child(3) {
  background: var(--coral);
}

.controls button:nth-child(4) {
  background: var(--green);
}

.flashcard {
  min-height: 255px;
}

.flashcard p,
.quiz-box p:first-child {
  margin: 0 0 8px;
  color: var(--teal);
  font-weight: 900;
  text-transform: uppercase;
}

.flashcard h3,
.quiz-box h3 {
  margin: 0 0 18px;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  letter-spacing: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.answer {
  margin-top: 18px;
  padding: 16px;
  border-radius: 8px;
  background: #eef7f2;
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.choice {
  min-height: 58px;
  color: var(--ink);
  background: #edf2f7;
  border: 1px solid var(--line);
}

.choice.correct {
  color: #fff;
  background: var(--green);
}

.choice.wrong {
  color: #fff;
  background: var(--coral);
}

.feedback {
  min-height: 28px;
  color: var(--ink);
  font-weight: 800;
}

.parent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 12px;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.material-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
}

.material-card h3 {
  margin: 0 0 8px;
}

.material-card p {
  color: var(--muted);
  line-height: 1.45;
}

.material-card code {
  display: block;
  margin-top: 10px;
  white-space: normal;
  word-break: break-word;
  color: var(--ink);
}

.semester-map {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f7fafc;
}

.semester-map h3 {
  margin: 0 0 12px;
}

.weight-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr minmax(42px, auto);
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.bar {
  height: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: #dde7ed;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.parent-grid h3 {
  margin-top: 0;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .timer-layout {
    grid-template-columns: 1fr;
  }

  .exam-start {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    inset: 18px;
  }
}

@media (max-width: 470px) {
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
