:root {
  color-scheme: light;
  --bg: #f8f5ef;
  --surface: #ffffff;
  --surface-strong: #fff9ec;
  --ink: #24302b;
  --muted: #69736f;
  --line: #ded7ca;
  --accent: #236b5b;
  --accent-soft: #dceee8;
  --warn: #9a5a13;
  --good: #24724f;
  --bad: #a43e32;
  --shadow: 0 18px 50px rgba(62, 52, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

code {
  border-radius: 6px;
  background: #f0eadf;
  padding: 2px 5px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 38px);
}

.login-card h1 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.login-form {
  display: grid;
  gap: 12px;
  margin: 24px 0 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 650;
}

.login-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
}

.quick-login {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.child-manager {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.5fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.child-manager label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.child-manager select,
.inline-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
}

.inline-form {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 10px;
}

.child-manager .feedback {
  grid-column: 1 / -1;
  margin: 0;
}

.account-panel {
  max-width: 620px;
}

.notification-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 1fr);
  gap: 18px 28px;
  align-items: center;
  margin-bottom: 18px;
}

.notification-form {
  display: grid;
  gap: 12px;
}

.notification-form label:not(.checkbox-label) {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.notification-form input[type="email"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

.checkbox-label {
  display: flex;
  gap: 9px;
  align-items: center;
}

.notification-panel > .muted,
.notification-panel > .feedback {
  grid-column: 1 / -1;
  margin: 0;
}

.suggestion-panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
  border-color: #9bc8b8;
  background: #eef7f3;
}

.analytics-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 28px;
  margin-top: 18px;
}

.performance-chart svg {
  display: block;
  width: 100%;
  min-height: 220px;
}

.chart-grid-line {
  stroke: #e7e1d7;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: white;
  stroke: var(--accent);
  stroke-width: 3;
}

.time-analysis {
  display: grid;
  gap: 13px;
}

.time-row {
  display: grid;
  grid-template-columns: 105px 1fr 44px;
  gap: 10px;
  align-items: center;
}

.time-row span,
.time-row small {
  color: var(--muted);
}

.time-bar {
  overflow: hidden;
  height: 11px;
  border-radius: 999px;
  background: #ece6da;
}

.time-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 28px clamp(18px, 4vw, 48px) 20px;
}

.header-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(1.9rem, 4vw, 3.6rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

h3 {
  margin-bottom: 10px;
  font-size: 1.25rem;
}

nav {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.nav-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-button.active {
  background: var(--accent);
  color: white;
}

.auth-pill {
  display: flex;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  padding: 6px 6px 6px 14px;
}

.auth-pill span {
  font-weight: 800;
}

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

.auth-pill button {
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-weight: 750;
  padding: 8px 11px;
}

main {
  padding: 0 clamp(18px, 4vw, 48px) 48px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.practice-layout,
.parent-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
}

.exercise-panel {
  min-height: 520px;
}

.session-topline,
.worksheet-header,
.answer-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.soft-counter {
  min-width: 70px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px 14px;
  text-align: center;
  font-weight: 800;
}

.exercise-card {
  display: grid;
  min-height: 250px;
  place-items: center;
  margin: 20px 0;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 24px;
  text-align: center;
}

.problem {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.problem-text {
  font-size: clamp(2.2rem, 6vw, 5rem);
  font-weight: 850;
  line-height: 1;
}

.problem-note {
  max-width: 560px;
  color: var(--muted);
  font-size: 1.05rem;
}

.child-summary {
  width: min(620px, 100%);
  text-align: left;
}

.child-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.child-summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 16px;
}

.child-summary-item strong {
  display: block;
  color: var(--accent);
  font-size: 1.8rem;
}

.child-summary-item span {
  color: var(--muted);
}

.answer-area {
  display: grid;
  gap: 10px;
}

.answer-area.hidden {
  display: none;
}

.answer-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 1.2rem;
}

.primary-action,
.secondary-action,
.text-action {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
}

.primary-action {
  background: var(--accent);
  color: white;
  padding: 14px 18px;
}

.secondary-action {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 12px 16px;
}

.danger-action {
  margin-top: 8px;
  color: var(--bad);
}

.text-action {
  justify-self: start;
  background: transparent;
  color: var(--accent);
  padding: 8px 0;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}

.subtle-action {
  color: var(--muted);
}

.answer-row button:disabled,
.answer-actions button:disabled,
.answer-row input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.resolution-card {
  display: grid;
  gap: 14px;
}

.resolution-answer {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 11px 14px;
  color: var(--ink);
  font-size: 1.05rem;
}

.feedback {
  min-height: 54px;
  margin-top: 14px;
  font-weight: 700;
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.hint-card {
  display: grid;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  padding: 16px;
  text-align: left;
  font-weight: 500;
  line-height: 1.45;
}

.hint-card > strong {
  color: var(--accent);
  font-size: 1rem;
}

.hint-card p {
  margin: 0;
}

.hint-small {
  color: var(--muted);
  font-size: 0.95rem;
}

.place-value-number {
  justify-self: start;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 8px 12px;
  font-size: 1.4rem;
  font-weight: 850;
}

.place-grid,
.step-strip,
.group-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.place-card,
.step-strip > div,
.group-box,
.group-visual.two-groups > div {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
  text-align: center;
}

.place-card span,
.step-strip span,
.group-box span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.place-card strong,
.step-strip strong,
.group-box strong,
.group-visual.two-groups strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.25rem;
}

.place-card.unknown,
.group-visual.two-groups > div {
  border-style: dashed;
  background: var(--surface-strong);
}

.step-strip {
  align-items: center;
}

.step-strip.compact {
  justify-content: flex-start;
}

.step-arrow {
  display: grid !important;
  place-items: center;
  min-width: 42px !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 900;
}

.complement-bar {
  overflow: hidden;
  height: 18px;
  border-radius: 999px;
  background: #ece6da;
}

.complement-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-soft);
  border-right: 3px solid var(--accent);
}

.complement-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.group-box {
  min-width: 76px;
}

.calm-box {
  background: #fffdf7;
}

.calm-box p:last-of-type {
  color: var(--muted);
  line-height: 1.55;
}

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

.today-stats div,
.progress-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.round-history-panel {
  margin-top: 18px;
}

.round-history {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.round-history-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(5, minmax(80px, 1fr));
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.round-history-row span,
.round-history-row small {
  color: var(--muted);
}

.today-stats strong {
  display: block;
  font-size: 1.8rem;
}

.today-stats span {
  color: var(--muted);
}

.level-progress {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.level-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.level-progress-label strong {
  color: var(--ink);
}

.motivation-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

.topic-settings,
.progress-summary {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.topic-toggle {
  display: flex;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
}

.topic-toggle input {
  margin-top: 4px;
}

.topic-toggle small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.settings-row,
.worksheet-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 16px 0;
}

.settings-note {
  max-width: 620px;
  margin-top: -6px;
  font-size: 0.92rem;
}

.settings-row label,
.worksheet-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.settings-row input,
.worksheet-controls input,
.worksheet-controls select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

.progress-card {
  display: grid;
  gap: 6px;
}

.progress-card strong {
  font-size: 1.3rem;
}

.bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #ece6da;
}

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

.worksheet {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: white;
}

.worksheet h3 {
  margin-bottom: 4px;
}

.worksheet ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 42px;
  padding-left: 24px;
  font-size: 1.2rem;
}

.worksheet li {
  break-inside: avoid;
}

.worksheet.worksheet-wide ol {
  grid-template-columns: 1fr;
}

.worksheet-task {
  display: grid;
  gap: 8px;
}

.worksheet-visual {
  overflow: visible;
}

.worksheet .number-line {
  display: block;
  width: min(640px, 100%);
  height: 74px;
}

.number-line {
  width: min(520px, 100%);
  height: 60px;
}

.interactive-number-line {
  height: 82px;
  cursor: crosshair;
  touch-action: manipulation;
}


@media (max-width: 820px) {
  .app-header,
  .session-topline,
  .worksheet-header {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    align-self: start;
  }

  .practice-layout,
  .parent-grid {
    grid-template-columns: 1fr;
  }

  .worksheet ol {
    grid-template-columns: 1fr;
  }

  .round-history-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .child-manager,
  .notification-panel,
  .analytics-panel,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-column: auto;
  }

  .suggestion-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .child-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }

  .app-header,
  .login-view,
  .worksheet-controls,
  #practice,
  #parent,
  #printWorksheet {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .view,
  #worksheets {
    display: block !important;
  }

  .panel,
  .worksheet {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
