@font-face {
  font-family: "Onest";
  src: url("fonty/onest-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Onest";
  src: url("fonty/onest-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Theme tokens. Dark values repeat for the system setting and for the explicit toggle choice. */
:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --fg: #14161A;
  --muted: #5C6370;
  --line: #E2E4E9;
  --accent: #1F5EFF;
  --tint: #F0F1F4;
  --raised: #FFFFFF;
  --track: #D5D8DE;
  --signal: #D93036;
  --star: #A86A00;
  --plane: rgba(20, 22, 26, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131418;
    --fg: #EDEEF0;
    --muted: #A4A9B3;
    --line: #2C2E36;
    --accent: #8DB0FF;
    --tint: #1F2127;
    --raised: #34373F;
    --track: #3A3E48;
    --signal: #FF8A8E;
    --star: #F0C36D;
    --plane: rgba(237, 238, 240, 0.05);
  }
  :root:not([data-theme="light"]) .tone {
    --tone-bg: var(--board-bg);
    --tone-fg: var(--board-fg);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131418;
  --fg: #EDEEF0;
  --muted: #A4A9B3;
  --line: #2C2E36;
  --accent: #8DB0FF;
  --tint: #1F2127;
  --raised: #34373F;
  --track: #3A3E48;
  --signal: #FF8A8E;
  --star: #F0C36D;
  --plane: rgba(237, 238, 240, 0.05);
}
:root[data-theme="dark"] .tone {
  --tone-bg: var(--board-bg);
  --tone-fg: var(--board-fg);
}

/* Subject colours arrive as inline custom properties from the index build. */
.tone {
  --tone-bg: var(--paper-bg);
  --tone-fg: var(--paper-fg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 24px 16px 96px;
  color: var(--fg);
  font: 400 18px/1.6 "Onest", system-ui, sans-serif;
  background: var(--bg);
}

a { color: inherit; text-underline-offset: 4px; }
p { margin: 0 0 16px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page { margin: 0 auto; }
.page-index { max-width: 1120px; }
.page-note { max-width: 860px; }

/* Theme switch, filled in by motiv.js */
.theme-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0;
  border: 0;
  color: inherit;
  font: inherit;
  font-size: 16px;
  background: transparent;
  cursor: pointer;
}

.theme-track {
  position: relative;
  display: block;
  width: 60px;
  height: 34px;
  border-radius: 17px;
  background: var(--track);
}

.theme-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--bg);
  background: var(--fg);
  transition: transform 160ms ease;
}

.theme-toggle[aria-pressed="true"] .theme-thumb { transform: translateX(26px); }
.theme-toggle[aria-pressed="true"] .icon-sun,
.theme-toggle[aria-pressed="false"] .icon-moon { display: none; }

@media (prefers-reduced-motion: reduce) {
  .theme-thumb { transition: none; }
}

/* Index */
.index-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 32px;
  margin: 16px 0 32px;
}

.index-intro { flex: 1 1 420px; min-width: 0; }

.index-title {
  margin: 0 0 12px;
  font-size: clamp(48px, 9vw, 68px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.index-lead {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.5;
}

.subject-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 22px;
  color: var(--tone-fg);
  font-size: 17px;
  font-weight: 500;
  text-decoration: none;
  background: var(--tone-bg);
}

.chip-all {
  --tone-bg: var(--tint);
  --tone-fg: var(--fg);
}

.chip[aria-current] {
  color: var(--tone-bg);
  background: var(--tone-fg);
}

.chip-all[aria-current] {
  color: var(--bg);
  background: var(--fg);
}

.chip:hover { text-decoration: underline; }

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 16px;
}

.subject {
  padding: 28px 32px 20px;
  border-radius: 24px;
  color: var(--tone-fg);
  background: var(--tone-bg);
}

.subject h2 {
  margin: 0 0 20px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.toc {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-item {
  padding: 14px 0;
  border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}

.toc-link {
  display: block;
  text-decoration: none;
}

.toc-title {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.toc-link:hover .toc-title { text-decoration: underline; }

.toc-text {
  display: block;
  margin-top: 2px;
  line-height: 1.5;
}

.toc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 500;
}

/* Note pages */
.note-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 56px;
}

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

@media (max-width: 420px) {
  .back { font-size: 16px; }
  .note-top .theme-toggle { gap: 8px; font-size: 15px; }
}

.note-subjects {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 16px;
}

.note-title {
  margin: 0 0 20px;
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.note-lead {
  max-width: 56ch;
  margin-bottom: 48px;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.5;
}

.note-text { max-width: 660px; }

.note-text h2 {
  margin: 40px 0 12px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.note-text h2:first-child { margin-top: 0; }

/* Shared controls for interactive notes */
.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--tint);
}

.segmented button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  background: transparent;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  color: var(--fg);
  font-weight: 600;
  background: var(--raised);
}

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  background: transparent;
  cursor: pointer;
}

.button:hover { background: var(--tint); }

input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 32px;
  margin: 0;
  accent-color: var(--accent);
}
