:root {
  --ink: #0d0d0d;
  --muted: #55555c;
  --bg: #ffffff;
  --card: #ffffff;
  --brand: #2942ff;
  --brand-dark: #1c2fc4;
  --accent: #eef1ff;
  --green: #0d7a3f;
  --green-bg: #e5f6ec;
  --red: #c81e1e;
  --red-bg: #feecec;
  --rule: #0d0d0d;
  --border: #d9d9e0;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Archivo", -apple-system, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1000px; margin: 0 auto; padding: 8px 24px 96px; }

/* Nav */
nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 2px solid var(--rule);
  padding: 16px 28px;
  display: flex;
  gap: 28px;
  align-items: baseline;
  flex-wrap: wrap;
}
nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
nav a:hover { color: var(--brand); }
nav a.brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 24px;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--ink);
  margin-right: 12px;
}
nav a.brand:hover { color: var(--brand); }
hr { display: none; }

/* Type */
h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(40px, 6.5vw, 68px);
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 48px 0 20px;
}
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin: 48px 0 14px;
  padding-top: 18px;
  border-top: 2px solid var(--rule);
}
h3 { font-family: var(--font-display); font-weight: 700; font-size: 18px; margin: 20px 0 8px; }
p.lede { font-size: 19px; color: var(--ink); max-width: 640px; margin-top: 0; line-height: 1.5; }
a { color: var(--brand); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0; margin: 32px 0; border: 2px solid var(--rule); }
.card {
  background: var(--card);
  border-right: 2px solid var(--rule);
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card:last-child { border-right: 0; }
@media (max-width: 860px) { .card { border-right: 0; border-bottom: 2px solid var(--rule); } .card:last-child { border-bottom: 0; } }
.card h2 { margin: 0; font-size: 21px; border: 0; padding: 0; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; flex: 1; }
.card .tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
}

/* Buttons */
button, input[type="submit"], .btn {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 12px 22px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.12s, color 0.12s;
}
button:hover, input[type="submit"]:hover, .btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
button:disabled { cursor: default; }
.btn-secondary, button.secondary, input[type="submit"].btn-secondary {
  background: var(--bg);
  color: var(--ink);
}
.btn-secondary:hover, input[type="submit"].btn-secondary:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* File inputs */
input[type="file"] {
  border: 2px dashed var(--ink);
  border-radius: 0;
  padding: 14px;
  width: 100%;
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--brand); }
input[type="file"]::file-selector-button {
  background: var(--ink);
  color: #fff;
  border: 0;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 12px;
  cursor: pointer;
}
form { display: flex; flex-direction: column; gap: 12px; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--rule);
  margin: 14px 0;
}
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
th {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--accent); }

.alert {
  background: var(--red-bg);
  color: var(--red);
  border-left: 4px solid var(--red);
  padding: 13px 18px;
  margin: 16px 0;
  font-size: 14.5px;
}

/* Quiz */
.question {
  border: 2px solid var(--rule);
  padding: 24px 26px;
  margin: 24px 0;
}
.question h3 { margin-top: 0; color: var(--brand); text-transform: uppercase; font-family: var(--font-body); font-size: 13px; letter-spacing: 0.1em; }
.question button[data-quiz-target="choice"] {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  margin-bottom: 10px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
}
.question button[data-quiz-target="choice"]:hover { background: var(--accent); border-color: var(--brand); color: var(--ink); }
.question button.correct { background: var(--green-bg); border-color: var(--green); color: var(--green); font-weight: 700; }
.question button.wrong { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.question br { display: none; }
.question [data-quiz-target="hint"] { background: var(--accent); border-left: 4px solid var(--brand); padding: 12px 16px; color: var(--ink); }
.question [data-quiz-target="feedback"] { font-weight: 700; font-family: var(--font-display); font-size: 17px; }
.question [data-quiz-target="explanation"] {
  border-top: 2px solid var(--rule);
  margin-top: 14px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 14.5px;
}
.question button[data-action="quiz#showHint"] {
  background: none;
  color: var(--brand);
  border: 0;
  padding: 6px 0;
  font-size: 13px;
}
.question button[data-action="quiz#showHint"]:hover { background: none; color: var(--brand-dark); text-decoration: underline; }

#quiz-score { font-family: var(--font-display); font-weight: 900; color: var(--brand); font-size: 20px; }

.concept-card {
  background: var(--ink);
  color: #fff;
  padding: 24px 28px;
  font-size: 17px;
  font-family: var(--font-display);
  line-height: 1.5;
}
.concept-card p { margin: 0; }

/* Concept list */
ol.concept-list { list-style: none; padding: 0; margin: 16px 0; border: 2px solid var(--rule); }
ol.concept-list li {
  padding: 13px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
ol.concept-list li:last-child { border-bottom: 0; }
ol.concept-list li:hover { background: var(--accent); }
ol.concept-list li a { text-decoration: none; font-weight: 600; color: var(--ink); }
ol.concept-list li a:hover { color: var(--brand); }
ol.concept-list li small { color: var(--muted); white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Pills */
.section-pills { display: flex; gap: 0; margin: 20px 0; flex-wrap: wrap; }
.section-pills a {
  border: 2px solid var(--ink);
  border-right-width: 0;
  padding: 9px 20px;
  text-decoration: none;
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  transition: all 0.12s;
}
.section-pills a:last-child { border-right-width: 2px; }
.section-pills a:hover { background: var(--accent); color: var(--brand); }
.section-pills a.active { background: var(--ink); color: #fff; }

/* Score tiles */
.scorebox { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0; margin: 24px 0; border: 2px solid var(--rule); }
.scorebox div { padding: 22px; text-align: center; border-right: 2px solid var(--rule); }
.scorebox div:last-child { border-right: 0; }
.scorebox .num { font-family: var(--font-display); font-size: 42px; font-weight: 900; color: var(--brand); }
.scorebox .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 28px 0;
  border-top: 2px solid var(--rule);
  margin-top: 40px;
}

/* Responsive */
.table-wrap { overflow-x: auto; }

@media (max-width: 700px) {
  main { padding: 4px 16px 64px; }
  nav { padding: 12px 16px; gap: 14px; }
  nav a.brand { font-size: 20px; width: 100%; }
  h1 { margin-top: 28px; }
  h2 { font-size: 22px; margin-top: 36px; }
  p.lede { font-size: 16.5px; }

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

  table { display: block; overflow-x: auto; white-space: nowrap; }

  .section-pills a { border-right-width: 2px; border-bottom-width: 0; flex: 1; text-align: center; }
  .section-pills { flex-direction: column; }
  .section-pills a:last-child { border-bottom-width: 2px; }

  .scorebox { grid-template-columns: 1fr 1fr; }
  .scorebox div { border-right: 0; border-bottom: 2px solid var(--rule); }
  .scorebox div:nth-child(odd) { border-right: 2px solid var(--rule); }
  .scorebox div:nth-last-child(-n+2) { border-bottom: 0; }

  .question { padding: 18px 16px; }
  button, input[type="submit"], .btn { width: 100%; }
  .question button[data-quiz-target="choice"] { width: 100%; }
}

/* Lessons */
.lesson-ideas { border-left: 4px solid var(--brand); padding: 4px 0 4px 18px; font-size: 16px; }
.lesson-example details summary { cursor: pointer; font-weight: 700; color: var(--brand); margin-top: 8px; }
.lesson-example details[open] summary { margin-bottom: 8px; }

.diagram { border: 2px solid var(--rule); padding: 20px; margin: 20px 0; }
.diagram svg { width: 100%; height: auto; display: block; max-width: 680px; margin: 0 auto; }
