/* Academy — Shared Stylesheet */
/* Inspired by Tufte: clean typography, generous margins, minimal chrome */

:root {
  --color-bg: #1d2026;
  --color-text: #e4e4e7;
  --color-muted: #9ca0a8;
  --color-accent: #60a5fa;
  --color-accent-light: #1e3a5f;
  --color-border: #363a42;
  --color-code-bg: #282c33;
  --color-success: #4ade80;
  --color-warning: #fbbf24;
  --color-error: #f87171;
  --font-serif: 'Georgia', 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  --max-width: 680px;
  --sidebar-width: 280px;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2.5rem;
  --spacing-2xl: 4rem;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  padding: var(--spacing-xl) var(--spacing-md);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Typography */
h1 {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
  letter-spacing: -0.02em;
}

h2 {
  font-family: var(--font-sans);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--spacing-2xl);
  margin-bottom: var(--spacing-md);
  letter-spacing: -0.01em;
}

h3 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-sm);
}

p {
  margin-bottom: var(--spacing-md);
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

a:hover {
  border-bottom-color: var(--color-accent);
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--color-code-bg);
  border-left: 3px solid var(--color-border);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
}

/* Lists */
ul, ol {
  margin: var(--spacing-sm) 0 var(--spacing-md) var(--spacing-lg);
}

li {
  margin-bottom: var(--spacing-xs);
}

/* Blockquotes — used for key insights */
blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--spacing-sm) var(--spacing-md);
  margin: var(--spacing-md) 0;
  background: var(--color-accent-light);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Tables. Each one sits in a `.table-scroll` container (`server.mjs`). A table
   wider than the text column spreads past it, centred on it, up to the full
   width of `#shell-main` (`100cqw`, the query container declared on it); only
   a table wider than that scrolls horizontally, so it doesn't widen the page.
   A table that fits still takes the column's full width. */
#shell-main {
  container-type: inline-size;
}

.table-scroll {
  overflow-x: auto;
  margin: var(--spacing-md) 0;
  width: max-content;
  min-width: 100%;
  max-width: 100cqw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

th {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}

/* Lesson-specific: header, nav, quiz */
.lesson-header {
  margin-bottom: var(--spacing-2xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.lesson-meta {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: var(--spacing-sm);
}

/* A link whose target is off in this instance (the "Flashcards" links locally) */
.unavailable {
  color: var(--color-error);
}

.lesson-nav {
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.lesson-nav--top {
  margin-bottom: var(--spacing-2xl);
}

.lesson-nav:not(.lesson-nav--top) {
  margin-top: var(--spacing-2xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

.nav-prevnext {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-md);
}

/* Quiz widget */
.quiz {
  background: var(--color-accent-light);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: var(--spacing-lg);
  margin: var(--spacing-lg) 0;
}

.quiz h3 {
  margin-top: 0;
  color: var(--color-accent);
}

.quiz-options {
  list-style: none;
  margin: var(--spacing-md) 0 0 0;
  padding: 0;
}

.quiz-options li {
  margin-bottom: var(--spacing-sm);
}

.quiz-options label {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.quiz-options label:hover {
  border-color: var(--color-accent);
}

.quiz-options input[type="radio"] {
  margin-right: var(--spacing-sm);
}

.quiz-feedback {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  display: none;
}

.quiz-feedback.correct {
  display: block;
  background: #052e16;
  border: 1px solid #166534;
  color: var(--color-success);
}

.quiz-feedback.incorrect {
  display: block;
  background: #450a0a;
  border: 1px solid #7f1d1d;
  color: var(--color-error);
}

/* Callout boxes */
.callout {
  padding: var(--spacing-md);
  border-radius: 6px;
  margin: var(--spacing-md) 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.callout.tip {
  background: #052e16;
  border: 1px solid #166534;
}

.callout.warning {
  background: #422006;
  border: 1px solid #713f12;
}

.callout.danger {
  background: #450a0a;
  border: 1px solid #7f1d1d;
}

.callout strong {
  display: block;
  margin-bottom: var(--spacing-xs);
}

/* Footer */
.lesson-footer {
  margin-top: var(--spacing-2xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  text-align: center;
}

/* Shell sidebar (layout.mjs). Below the width cut it is a panel that
   `#shell-sidebar-toggle` opens (`shell.js` sets `body.sidebar-open`); from
   the cut up it is a fixed column with its own scroll and the toggle is gone. */

#shell-sidebar {
  display: none;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
}

#shell-sidebar-toggle {
  position: fixed;
  top: var(--spacing-sm);
  left: var(--spacing-sm);
  z-index: 20;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.3em 0.8em;
  cursor: pointer;
}

/* `shell.js` closes the open panel on a `click` that reaches the document.
   iOS Safari has been documented (WebKit bug 171105) not to deliver that
   `click` for a tap on an element it doesn't consider clickable, such as
   text or an empty area; `cursor: pointer` marks every element as
   clickable while the panel is open. */
body.sidebar-open {
  cursor: pointer;
}

.sidebar-open #shell-sidebar {
  display: block;
  width: min(85vw, 320px);
  padding: calc(var(--spacing-xl) + var(--spacing-sm)) var(--spacing-md) var(--spacing-lg);
}

@media (min-width: 1024px) {
  body {
    padding-left: calc(var(--sidebar-width) + var(--spacing-md));
  }

  /* A panel opened below the cut keeps `sidebar-open` after a widening;
     from the cut up the column is fixed and the cursor stays as it is. */
  body.sidebar-open {
    cursor: auto;
  }

  #shell-sidebar-toggle {
    display: none;
  }

  #shell-sidebar,
  .sidebar-open #shell-sidebar {
    display: block;
    font-size: 0.8rem;
    width: var(--sidebar-width);
    padding: var(--spacing-lg) var(--spacing-md);
  }
}

/* Below the cut, inside a topic, the panel shows the topic view until its
   button switches it to the tree (`shell.js` sets `sidebar--show-tree`). */
.sidebar--in-topic .sidebar-tree,
.sidebar--show-tree .sidebar-focus {
  display: none;
}

.sidebar--show-tree .sidebar-tree {
  display: block;
}

/* From the cut up the column is always the tree (`layout.mjs`); declared
   after the rules above, which have the same specificity. */
@media (min-width: 1024px) {
  .sidebar .sidebar-focus {
    display: none;
  }

  .sidebar .sidebar-tree {
    display: block;
  }
}

.sidebar-focus {
  margin-top: var(--spacing-md);
}

.sidebar-show-tree {
  font: inherit;
  color: var(--color-accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  margin-bottom: var(--spacing-sm);
}

.sidebar-focus-topic {
  font-weight: 600;
  margin: 0;
}

.sidebar ul,
.sidebar ol {
  list-style: none;
  margin: 0;
}

.sidebar li {
  margin: 0 0 var(--spacing-sm);
}

/* Below the cut the panel's text is bigger (`#shell-sidebar`) and its links
   further apart, for a finger; from the cut up, closer. */
@media (min-width: 1024px) {
  .sidebar li {
    margin-bottom: var(--spacing-xs);
  }
}

/* The sidebar's three parts: the brand, the study modes over every topic and
   the topics (`sidebar` in `layout.mjs`). */
.sidebar-brand {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--spacing-sm);
}

.sidebar-brand a,
.sidebar-brand a.current {
  color: var(--color-text);
  border-bottom: 0;
}

.sidebar .sidebar-modes {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

.sidebar .sidebar-modes li {
  margin-bottom: 2px;
}

.sidebar-modes a,
.sidebar-modes .unavailable {
  display: block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 4px;
  border-bottom: 0;
  font-family: var(--font-sans);
  text-decoration: none;
}

.sidebar-modes a {
  color: var(--color-text);
}

.sidebar-modes a:hover {
  background: var(--color-code-bg);
}

.sidebar-modes a.current {
  background: var(--color-accent-light);
}

.sidebar-section {
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--spacing-sm);
}

/* A study mode's icon, in the sidebar and in the home's cards. */
.mode-flashcards > :first-child::before,
.mode-podcasts > :first-child::before {
  margin-right: 0.4em;
}

.mode-flashcards > :first-child::before {
  content: '🔦';
}

.mode-podcasts > :first-child::before {
  content: '🎧';
}

.sidebar-topics ul {
  padding-left: var(--spacing-md);
}

/* A topic's audit status before its name (`auditMark` in `layout.mjs`). */
.audit-mark {
  margin-right: 0.3em;
  font-size: 0.85em;
}

/* The page's topic, its name and its contents (`currentTopic` in
   `layout.mjs`), on a background of its own. */
.sidebar-current {
  background: var(--color-code-bg);
  border-radius: 4px;
  padding: var(--spacing-xs) var(--spacing-sm);
  margin: 0 calc(-1 * var(--spacing-sm));
}

.sidebar-topic {
  margin: var(--spacing-xs) 0 var(--spacing-sm);
  padding-left: var(--spacing-sm);
  border-left: 1px solid var(--color-border);
}

.sidebar-topic ol {
  list-style: decimal;
  padding-left: 1.4em;
}

.sidebar-topic ul {
  padding-left: 0;
}

.sidebar-group {
  color: var(--color-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: var(--spacing-sm) 0 var(--spacing-xs);
}

/* A block of lessons (`bloque:` in their frontmatter, `lessonLists`). */
.sidebar-block {
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 600;
  margin: var(--spacing-xs) 0 2px;
}

/* The schema's and flashcards' icon in a topic's references (`referenceItem`
   in `layout.mjs`). */
.ref-esquema > a::before,
.ref-flashcards > a::before,
.ref-glosario > a::before {
  margin-right: 0.3em;
}

.ref-esquema > a::before {
  content: '🗺️';
}

.ref-flashcards > a::before {
  content: '🔦';
}

.ref-glosario > a::before {
  content: '🔤';
}

.ref-podcast {
  list-style: none;
}

.topic-references > .ref-podcast {
  list-style: disc outside;
}

.sidebar a.current {
  color: var(--color-text);
  font-weight: 600;
}

/* Podcasts — compact controls in topic References and the sidebar, detailed
   controls in `/podcasts`, and the player above the content (`player.js`). */
.podcasts {
  list-style: none;
  margin-left: 0;
}

/* A detailed part on one line in `/podcasts`: control, date and "Contenido". */
.podcasts > li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--spacing-sm);
}

.podcast-play {
  font: inherit;
  color: var(--color-accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.podcast-play::before {
  content: '🎙️';
  margin-right: 0.3em;
}

.podcast-play:hover {
  text-decoration: underline;
}

.podcast-date {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.podcast-refs {
  color: var(--color-muted);
  font-size: 0.85rem;
  font-family: var(--font-sans);
}

.podcast-refs summary {
  cursor: pointer;
  width: fit-content;
}

.podcast-refs ul {
  list-style: none;
  margin: var(--spacing-xs) 0 0 var(--spacing-md);
}

#shell-player {
  max-width: var(--max-width);
  margin: 0 auto var(--spacing-lg);
}

.player {
  font-family: var(--font-sans);
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: var(--spacing-sm) var(--spacing-md);
}

.player-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.player-title {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Three rows: title and ✕ (`.player-head`), position bar and time
   (`.player-position`), then the controls (`.player-controls`): play and ±5 s
   on the left (`.player-transport`), the speed buttons on the right
   (`.player-speeds`). When both don't fit in one row, the speeds wrap to the
   next one and stay on the right. */
.player-position {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.player-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-xs) var(--spacing-sm);
}

.player-transport,
.player-speeds {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.player-speeds {
  margin-left: auto;
}

.player-btn {
  font-size: 0.85rem;
  color: var(--color-text);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.2em 0.6em;
  cursor: pointer;
}

.player-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.player-seek {
  flex: 1;
  min-width: 6rem;
  accent-color: var(--color-accent);
}

.player-time {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--color-muted);
}

.player-rate[aria-pressed="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Print styles */
@media print {
  body { padding: 0; font-size: 12pt; background: #fff; color: #000; }
  .lesson-nav, .quiz, .lesson-footer, #shell-sidebar, #shell-sidebar-toggle, #shell-player { display: none; }
  a { border-bottom: 1px solid #000; color: #0000ee; }
  pre { border: 1px solid #ccc; background: #f5f5f5; }
  code { background: #f5f5f5; }
  blockquote { background: #f5f5f5; border-color: #2563eb; }
  .callout.tip { background: #f0fdf4; border-color: #bbf7d0; }
  .callout.warning { background: #fffbeb; border-color: #fde68a; }
  .callout.danger { background: #fef2f2; border-color: #fecaca; }
}

/* Flashcards — reference/flashcards-<topic>.md en modo evocacion (assets/flashcards.js) */
.fc-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin: calc(var(--spacing-2xl) * -1 + var(--spacing-lg)) 0 var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border);
}

.fc-count {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.fc-btn {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.2em 0.7em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.fc-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.fc-heading {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: var(--spacing-sm);
}

.fc-heading .fc-btn {
  margin-left: auto;
  align-self: center;
}

.fc-chevron {
  color: var(--color-muted);
  font-size: 0.8em;
  flex: none;
}

.fc {
  cursor: pointer;
  border-radius: 3px;
  padding: 0.1em 0.3em;
  margin-left: -0.3em;
  transition: background 0.15s;
}

.fc:hover, .fc:focus-visible {
  background: var(--color-code-bg);
  outline: none;
}

.fc:focus-visible {
  box-shadow: inset 2px 0 0 var(--color-accent);
}

.fc .fc-a {
  display: none;
}

.fc.fc-open .fc-a {
  display: inline;
}

.fc:not(.fc-open) .fc-q::after {
  content: ' · · ·';
  color: var(--color-muted);
  font-weight: 400;
}

/* A single card inside a lesson (`flashcards.js`, last block): the chevron
   says it can be clicked, as the section headings of the flashcards file do. */
.fc-single .fc-q::before {
  content: '▸ ';
  color: var(--color-muted);
}

.fc-single.fc-open .fc-q::before {
  content: '▾ ';
}

@media print {
  .fc-bar, .fc-btn, .fc-chevron { display: none; }
  .fc-single .fc-q::before { content: ''; }
  .fc .fc-a { display: inline; }
  .fc:not(.fc-open) .fc-q::after { content: ''; }
}

.fc-heading-text {
  flex: 1;
  min-width: 0;
}

/* Flashcards — sesión de flashcards (assets/flashcards-session.js) */
.flashcards-setup h2 {
  margin-top: 0;
}

/* One topic per line, in two columns read top to bottom (alphabetical order
   runs down the first column, then the second); one column on a phone. */
.flashcards-topics {
  margin-bottom: var(--spacing-lg);
}

@media (min-width: 640px) {
  .flashcards-topics {
    columns: 2;
    column-gap: var(--spacing-lg);
  }
}

.flashcards-topic-choice {
  display: block;
  break-inside: avoid;
  padding: 0.2em 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

/* A topic and its nested `##` sections, kept in one column. The chevron
   folds the sections; a topic with a single section has none and keeps the
   chevron's width so the boxes line up. */
.flashcards-topic-group {
  break-inside: avoid;
}

.flashcards-topic-row {
  display: flex;
  align-items: baseline;
  gap: 0.3em;
}

.flashcards-topic-row .flashcards-topic-choice {
  flex: 1;
  min-width: 0;
}

.flashcards-topic-toggle {
  width: 1.4em;
  flex: none;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.flashcards-topic-toggle[hidden] {
  display: inline-block;
  visibility: hidden;
}

.flashcards-sections {
  margin-left: 2.4em;
  margin-bottom: var(--spacing-sm);
}

.flashcards-sections[hidden] {
  display: none;
}

.flashcards-topic-stats {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.flashcards-topics-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.flashcards-btn-small {
  font-size: 0.8rem;
  padding: 0.3em 0.8em;
}

.flashcards-batch-choice {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  margin-bottom: var(--spacing-lg);
}

.flashcards-batch-choice input {
  font-family: var(--font-sans);
  background: var(--color-code-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.2em 0.5em;
  width: 5em;
  margin-left: var(--spacing-sm);
}

.flashcards-error {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-error);
  margin-bottom: var(--spacing-md);
}

.flashcards-btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.5em 1.2em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.flashcards-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.flashcards-btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.flashcards-btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
}

.flashcards-btn-primary:hover {
  color: var(--color-bg);
  opacity: 0.9;
}

.flashcards-card {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-code-bg);
  padding: var(--spacing-lg);
}

/* The ignore button sits in the card's top-right corner; the topic and the
   question leave it room so their text never runs under it. */
.flashcards-ignore {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  border: none;
  background: none;
  color: var(--color-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: var(--spacing-sm);
  cursor: pointer;
}

.flashcards-ignore:hover {
  color: var(--color-error);
}

.flashcards-card .flashcards-topic,
.flashcards-card .flashcards-question {
  padding-right: 2rem;
}

.flashcards-card-ignored .flashcards-question {
  color: var(--color-muted);
  text-decoration: line-through;
  cursor: default;
}

.flashcards-dialog {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-code-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  padding: var(--spacing-lg);
  max-width: 24rem;
  /* The global reset zeroes every margin; `auto` puts back the centering a
     modal `<dialog>` gets from the browser. */
  margin: auto;
}

.flashcards-dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.flashcards-dialog p {
  margin: 0 0 var(--spacing-lg);
}

.flashcards-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
}

.flashcards-ignored-notice {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: var(--spacing-lg);
}

.flashcards-topic {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-sm);
}

.flashcards-question {
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: var(--spacing-lg);
  /* Clicking the question, or the eye beside it, reveals it. */
  cursor: pointer;
}

.flashcards-eye {
  font-size: 1rem;
}

.flashcards-answer {
  margin-bottom: var(--spacing-lg);
}

.flashcards-section {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-bottom: var(--spacing-sm);
}

.flashcards-answer-text {
  font-size: 1.05rem;
}

.flashcards-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.flashcards-progress {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.flashcards-end {
  padding: var(--spacing-lg) 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-md);
}

/* Login page (`auth.mjs`): a narrow form, outside the shell's layout. */
.login {
  max-width: 22rem;
  padding-top: var(--spacing-2xl);
}

.login form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  font-family: var(--font-sans);
}

.login label {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.login input {
  padding: var(--spacing-sm);
  font: inherit;
  color: var(--color-text);
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.login button {
  padding: var(--spacing-sm);
  font: inherit;
  color: var(--color-bg);
  background: var(--color-accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.login-error {
  color: var(--color-error);
}

/* Home (`homeIndex` in `server.mjs`): the study modes as cards, then the
   topics with each group as a block, packed in columns so a one-topic block
   is only as tall as its name. */
.home-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.home-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
}

a.home-card:hover {
  border-color: var(--color-accent);
  background: var(--color-code-bg);
}

.home-card-title {
  font-family: var(--font-sans);
  font-weight: 700;
}

.home-card-desc {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.home-topics-title {
  margin-bottom: 0;
}

ul.topics {
  list-style: none;
  padding: 0;
  margin: var(--spacing-md) 0 0;
  columns: 3 180px;
  column-gap: var(--spacing-md);
  font-family: var(--font-sans);
}

ul.topics > li {
  break-inside: avoid;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin: 0 0 var(--spacing-md);
}

ul.topics > li > a {
  font-weight: 700;
}

ul.topics ul {
  list-style: none;
  padding: 0;
  margin: var(--spacing-xs) 0 0;
  font-size: 0.85rem;
}

ul.topics ul li {
  margin: 0;
}

/* Gravity explorer (`gravity-explorer.js`), lessons of `gravitacion` */
.gravity-explorer {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.ge-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(6rem, 2fr) 2.5rem;
  gap: var(--spacing-sm);
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.ge-row input[type="range"] { width: 100%; accent-color: var(--color-accent); }
.ge-value { text-align: right; font-family: var(--font-mono); }
.ge-result { margin: var(--spacing-md) 0 0; font-size: 1rem; }
.ge-result strong { font-family: var(--font-mono); color: var(--color-accent); font-size: 1.2rem; }
.ge-steps { color: var(--color-muted); font-family: var(--font-mono); font-size: 0.85rem; }
