/* Colour and typography tokens live in theme.css (loaded after this file). */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar outline */
.outline {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
}
.outline h2 {
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.outline ol { list-style: none; margin: 0; padding: 0; }
.outline > ol > li { margin-bottom: 4px; }
.outline a.sec {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.outline a.sec:hover { background: var(--surface-2); }
.outline:not(.outline--player) a.sec.current { background: var(--accent); color: var(--accent-text); }
.outline ul { list-style: none; margin: 2px 0 8px 10px; padding: 0 0 0 8px; border-left: 1px solid var(--border); }
.outline li.item a {
  display: block;
  padding: 3px 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}
.outline li.item a:hover { color: var(--text); background: var(--surface-2); }

/* Main */
main { padding: 28px 36px 60px; max-width: 980px; width: 100%; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.crumbs { color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

h1 { font-size: 28px; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card .num { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.card p { margin: 8px 0 0; color: var(--muted); }
.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  margin-right: 6px;
}

.quiz { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 14px; }
.quiz-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.quiz-head .meta { color: var(--muted); font-size: 13px; }
.q { padding: 12px 0; border-bottom: 1px solid var(--border); }
.q:last-child { border-bottom: 0; }
.q p { margin: 0 0 8px; font-weight: 600; }
.q label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 400;
}
.q label:hover { background: var(--surface-2); }
.q label.right { background: var(--ok-bg); color: var(--ok); }
.q label.wrong { background: var(--bad-bg); color: var(--bad); }
.q .verdict { font-size: 13px; margin-top: 4px; }
.score {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 600;
}

.empty-note { color: var(--muted); font-size: 13px; font-style: italic; }

.overview { font-size: 15px; color: var(--text); }
.material { margin-top: 14px; }
.material h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.material p { margin: 0; color: var(--text); }
.material-list { margin: 0; padding-left: 20px; color: var(--text); }
.material-list li { margin: 3px 0; }
.figure { margin: 0; background: var(--surface-2); border-radius: 12px; padding: 12px; overflow-x: auto; }
.diagram { display: block; width: 100%; height: auto; min-width: 280px; }

.article { margin-top: 8px; color: var(--text); }
.article .art-h2 { font-size: 18px; margin: 26px 0 8px; color: var(--text); }
.article .art-h3 { font-size: 15px; margin: 16px 0 6px; color: var(--text); text-transform: none; letter-spacing: 0; }
.article p { margin: 8px 0; color: var(--text); }
.article ul, .article ol { margin: 6px 0 10px; padding-left: 22px; }
.article li { margin: 3px 0; }
.callout {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--text);
}
.table-wrap { overflow-x: auto; margin: 10px 0 14px; }
.grid-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.grid-table th, .grid-table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.grid-table th { background: var(--surface-2); }
.answers { margin-top: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 14px; }
.answers summary { cursor: pointer; font-weight: 600; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist input { margin-right: 8px; transform: scale(1.1); }

.grid-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.grid-sections a.tile {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.grid-sections a.tile:hover { border-color: var(--accent); }
.grid-sections a.tile small { color: var(--muted); display: block; margin-top: 4px; }

.menu-toggle { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .outline {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .outline.open { display: block; }
  .menu-toggle { display: inline-block; }
  main { padding: 20px 16px 48px; }
  h1 { font-size: 23px; }
}
