:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #5c6962;
  --paper: #fffdf7;
  --line: #d8ddd8;
  --field: #f5f7f2;
  --green: #2f7b5b;
  --blue: #2365a2;
  --coral: #c9583e;
  --gold: #d99a28;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(47, 123, 91, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(35, 101, 162, 0.07) 1px, transparent 1px),
    var(--field);
  background-size: 36px 36px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.55fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.rail,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 18px 50px rgba(23, 33, 29, 0.08);
}

.rail {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 32px;
}

.eyebrow,
.kicker {
  margin: 0;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 18px;
  max-width: 560px;
  font-size: clamp(2.4rem, 5vw, 4.9rem);
  line-height: 1.02;
}

h2 {
  color: var(--ink);
  font-size: clamp(1.25rem, 2.3vw, 2rem);
  line-height: 1.18;
}

.intro {
  max-width: 520px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.8;
}

.metrics {
  display: grid;
  gap: 12px;
  margin: 0;
}

.metrics div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  border: 1px solid #e6dcc8;
  border-radius: 8px;
  background: #f8edda;
  padding: 16px;
}

.metrics dt {
  color: #665f52;
  font-size: 0.9rem;
}

.metrics dd {
  margin: 0;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 800;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
  gap: 24px;
}

.panel {
  padding: 24px;
}

.practice-panel {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading h2 {
  margin-top: 8px;
}

.compact h2 {
  font-size: 1.35rem;
}

.topic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab,
.answer-grid button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--ink);
  font-weight: 800;
}

.tab:focus-visible,
.answer-grid button:focus-visible,
.next-button:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid rgba(35, 101, 162, 0.32);
  outline-offset: 2px;
}

.tab {
  padding: 0 14px;
}

.tab.active {
  border-color: rgba(47, 123, 91, 0.5);
  background: #e8f4ef;
  color: var(--green);
}

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

.answer-grid button {
  padding: 16px;
  font-size: 1rem;
  line-height: 1.35;
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.answer-grid button:hover:not(:disabled),
.next-button:hover {
  transform: translateY(-1px);
}

.answer-grid button:disabled {
  cursor: default;
}

.answer-grid button.is-correct {
  border-color: rgba(47, 123, 91, 0.75);
  background: #dff4e9;
  color: var(--green);
}

.answer-grid button.is-wrong {
  border-color: rgba(201, 88, 62, 0.65);
  background: #fff0ec;
  color: var(--coral);
}

.step-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.step-strip span {
  border-radius: 8px;
  background: #edf3ff;
  color: var(--blue);
  padding: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.practice-meta,
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.practice-meta {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.practice-actions {
  margin-top: 18px;
}

.feedback {
  min-height: 26px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.next-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 18px;
  font-weight: 800;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.next-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.formula-badge {
  border-radius: 8px;
  background: #fff1e8;
  color: var(--coral);
  padding: 10px 12px;
  font-weight: 800;
}

.graph {
  display: block;
  width: 100%;
  min-height: 340px;
  margin-top: 18px;
  border: 1px solid #cfdcd7;
  border-radius: 8px;
  background: #eef7f3;
}

.grid-line {
  fill: none;
  stroke: #aec0ba;
  stroke-width: 2;
}

.graph-line {
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-width: 6;
}

.point {
  fill: var(--coral);
  stroke: #fff;
  stroke-width: 3;
}

.graph text {
  fill: var(--blue);
  font-size: 18px;
  font-weight: 800;
}

.axis-line {
  fill: none;
  stroke: #788b84;
  stroke-width: 2.2;
}

.grid-minor {
  fill: none;
  stroke: rgba(120, 139, 132, 0.28);
  stroke-width: 1;
}

.control-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.control-grid label {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.control-grid span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.track-list {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.track-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
}

.track-list span,
.track-list strong {
  font-size: 0.95rem;
}

.track-list strong {
  color: var(--muted);
}

progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e5ebe7;
}

progress::-webkit-progress-bar {
  background: #e5ebe7;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--green), var(--blue));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.geometry-panel,
.formula-panel {
  align-self: start;
}

.triangle-board {
  display: block;
  width: 100%;
  min-height: 300px;
  margin-top: 18px;
  border: 1px solid #cfdcd7;
  border-radius: 8px;
  background: #fbf7ef;
}

.triangle-shape {
  fill: rgba(217, 154, 40, 0.32);
  stroke: var(--gold);
  stroke-linejoin: round;
  stroke-width: 5;
}

.triangle-board text {
  fill: #6a5a45;
  font-size: 16px;
  font-weight: 800;
}

.formula-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.formula-list article {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid #dfe4e0;
  border-radius: 8px;
  background: #f8faf8;
  padding: 14px;
}

.formula-list strong {
  color: var(--muted);
}

.formula-list span {
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 800;
}

@media (max-width: 980px) {
  .workspace,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .rail {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .workspace {
    gap: 16px;
    padding: 12px;
  }

  .rail,
  .panel {
    padding: 18px;
  }

  .panel-heading,
  .step-strip,
  .formula-list article {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    display: grid;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .step-strip {
    display: grid;
  }
}
