/* DevForge — Claude-inspired warm light theme. */
:root {
  --bg: #f5f2ec; /* warm paper */
  --surface: #ffffff; /* cards */
  --surface-2: #f1ece3; /* insets / subtle fills */
  --border: #e7e1d5; /* soft warm border */
  --text: #2a2723; /* warm near-black */
  --muted: #766e62; /* warm gray */
  --accent: #c96442; /* Claude coral */
  --accent-2: #ae5234; /* coral, darker (hover) */
  --accent-soft: rgba(201, 100, 66, 0.12);
  --green: #3f7a52;
  --amber: #9a6a16;
  --red: #b4432e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(50, 38, 28, 0.04), 0 2px 6px rgba(50, 38, 28, 0.04);
  --header-bg: rgba(255, 255, 255, 0.7);
  --font-serif:
    "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color-scheme: light;
}

/* Night theme — applied when <html data-theme="dark"> (set before paint by an inline
   script from localStorage or the OS preference; toggled from the navbar). */
:root[data-theme="dark"] {
  --bg: #181511; /* warm near-black */
  --surface: #211d18; /* cards */
  --surface-2: #2a251f; /* insets / subtle fills */
  --border: #39322b; /* warm border */
  --text: #ece6db; /* warm off-white */
  --muted: #a99e8d; /* warm gray */
  --accent: #e0795a; /* coral, brighter for dark */
  --accent-2: #ee9070; /* coral hover */
  --accent-soft: rgba(224, 121, 90, 0.16);
  --green: #6fb389;
  --amber: #d6a95e;
  --red: #e5806b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(24, 21, 17, 0.8);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: saturate(120%) blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.site-header .brand span {
  color: var(--accent);
}
.site-header nav {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}
.site-header nav a {
  color: var(--muted);
  font-size: 0.9rem;
}
.site-header nav a:hover {
  color: var(--text);
  text-decoration: none;
}
.site-header .nav-signout {
  display: inline-flex;
}

/* Mobile burger toggle (hidden on desktop) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 42px;
  height: 38px;
  padding: 9px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}
.nav-toggle-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.narrow {
  max-width: 760px;
}

h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.9rem;
  letter-spacing: -0.015em;
  margin: 0 0 0.35rem;
}
h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 1.02rem;
  margin: 1.25rem 0 0.5rem;
}
.subtitle {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: 1.02rem;
}

/* Progress stats */
.stats {
  margin-bottom: 1.75rem;
}
.bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar.bar-sm {
  height: 5px;
  margin: 0.25rem 0 0.5rem;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition:
    width 0.3s,
    background-color 0.3s;
}
.bar-fill.complete {
  background: var(--green);
}
/* Fold / unfold controls */
.fold-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.fold-controls-sub {
  margin: 0.35rem 0 0.85rem;
}
.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}
.fold-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
}
.fold-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Multiple projects + history */
.project-challenge {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-top: 1.25rem;
}
.project-challenge:last-child {
  margin-bottom: 0;
}
.project-challenge-head,
.project-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 1.02rem;
  font-weight: 600;
}
.project-challenge-head::-webkit-details-marker,
.project-card-head::-webkit-details-marker {
  display: none;
}
.project-challenge[open] > .project-challenge-head {
  margin-bottom: 0.75rem;
}
.project-card[open] > .project-card-head {
  margin-bottom: 0.6rem;
}
.project-challenge-head .fa-chevron-right,
.project-card-head .fa-chevron-right {
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform 0.15s;
}
.project-challenge[open] > .project-challenge-head .fa-chevron-right,
.project-card[open] > .project-card-head .fa-chevron-right {
  transform: rotate(90deg);
}
.project-submission {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.history-item {
  margin-bottom: 1rem;
}
.history-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
}
.history-head::-webkit-details-marker {
  display: none;
}
.history-meta {
  margin-left: auto;
  font-size: 0.8rem;
}

.history-actions {
  text-align: right;
  margin: 0.6rem 0;
}

/* Links tab */
.links-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.link-main {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.link-actions {
  display: inline-flex;
  gap: 0.3rem;
}
.link-action {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
}
.link-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.link-del {
  display: inline;
  margin: 0;
}
.link-edit {
  flex-basis: 100%;
}
.link-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.link-form input[type="text"],
.link-form input[type="url"] {
  flex: 1;
  min-width: 160px;
  width: auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}
.chip {
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* AI mentor checkup */
.dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 122, 82, 0.15);
}
.dot.warn {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(154, 106, 22, 0.15);
}
.dot.err {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 67, 46, 0.15);
}

.ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.ai-pill:hover {
  color: var(--text);
  border-color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.35rem 0.6rem;
  color: var(--muted);
  transition:
    border-color 0.15s,
    color 0.15s;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.lang-form {
  display: inline-flex;
  margin: 0;
}
.lang-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1;
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  transition:
    border-color 0.15s,
    color 0.15s;
}
.lang-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
.lang-flag {
  font-size: 1.05rem;
  padding: 0.3rem 0.55rem;
  line-height: 1;
}

.ai-status-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ai-status-head strong {
  font-weight: 600;
}
.ai-status .chips {
  margin-top: 0.6rem;
}
.ai-status .small {
  font-size: 0.8rem;
  margin: 0.55rem 0 0;
}
.ai-status .err-text {
  color: var(--red);
}
.ai-status .ai-recheck {
  font-size: 0.78rem;
  margin-left: auto;
}
.ai-status code {
  background: var(--surface-2);
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  font-size: 0.85em;
}

.usage {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.65rem;
}
.usage-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.usage-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.usage .xsmall {
  font-size: 0.72rem;
  margin-top: 0.22rem;
}
.usage-raw {
  white-space: pre-wrap;
  font-size: 0.8rem;
  background: var(--surface-2);
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  margin: 0;
}

.ai-settings {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}
.ai-settings-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.ai-settings-row > div {
  flex: 1;
}
.ai-settings label {
  margin-bottom: 0.25rem;
}
.ai-settings select {
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

/* AI mentor modal */
.ai-modal {
  border: none;
  padding: 0;
  margin: auto;
  background: transparent;
  max-width: 440px;
  width: calc(100% - 2rem);
}
.ai-modal::backdrop {
  background: rgba(42, 39, 35, 0.45);
  backdrop-filter: blur(2px);
}
.ai-modal-body {
  position: relative;
}
.ai-modal .ai-status {
  margin-bottom: 0;
  box-shadow: 0 12px 40px rgba(50, 38, 28, 0.2);
}
.ai-modal-close {
  position: absolute;
  top: 0.45rem;
  right: 0.6rem;
  z-index: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
}
.ai-modal-close:hover {
  color: var(--text);
}

/* Review callout */
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  margin-top: 1.5rem;
}
.callout h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.callout ul {
  margin: 0;
  padding-left: 1.1rem;
}

/* Phases & subjects */
.phase {
  margin-bottom: 2.5rem;
}
.phase-head {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.phase-head::-webkit-details-marker {
  display: none;
}
.phase-head-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.phase-head .phase-count {
  margin-left: auto;
  font-size: 0.85rem;
}
.phase-head .fa-chevron-right {
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform 0.15s;
}
.phase[open] > .phase-head .fa-chevron-right {
  transform: rotate(90deg);
}
.phase-head .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}
.phase-desc {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0.2rem 0 1rem;
}

.subject {
  margin: 0 0 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}
.subject-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  margin: 0.4rem 0 0.5rem;
  font-size: 1.02rem;
  color: var(--text);
  user-select: none;
}
.subject-head::-webkit-details-marker {
  display: none;
}
.subject-head:hover {
  color: var(--accent);
}
.subject-head .fa-chevron-right {
  font-size: 0.75em;
  color: var(--muted);
  transition: transform 0.15s;
}
.subject[open] > .subject-head .fa-chevron-right {
  transform: rotate(90deg);
}
.subject-name {
  font-weight: 600;
}
.subject-count {
  font-size: 0.8rem;
  margin-left: auto;
}
.subject-desc {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0 0 0.6rem;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}
.topic-card {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
}
.topic-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.topic-card.locked {
  opacity: 0.6;
  pointer-events: none;
}
.topic-card .title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.topic-card .desc {
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}
.badge.completed {
  background: rgba(63, 122, 82, 0.14);
  color: var(--green);
}
.badge.in_progress {
  background: rgba(154, 106, 22, 0.16);
  color: var(--amber);
}
.badge.available {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.locked {
  background: var(--surface-2);
  color: var(--muted);
}

/* Cards & sections */
.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-top: 1.25rem;
  box-shadow: var(--shadow);
}
.card h2 {
  margin-top: 0;
}
.objectives {
  margin: 0;
  padding-left: 1.2rem;
}
.objectives li {
  margin-bottom: 0.35rem;
}

/* Forms & buttons */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  resize: vertical;
  min-height: 240px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
textarea.code {
  min-height: 320px;
}

.btn {
  display: inline-block;
  padding: 0.58rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s;
}
.btn:hover {
  text-decoration: none;
  background: var(--accent-2);
  color: #fff;
}
.btn:active {
  transform: translateY(1px);
}
.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.btn.ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}
.btn.ghost:hover {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.75rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}
.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.flash.notice {
  background: rgba(63, 122, 82, 0.1);
  color: var(--green);
  border-color: rgba(63, 122, 82, 0.25);
}
.flash.alert {
  background: rgba(180, 67, 46, 0.1);
  color: var(--red);
  border-color: rgba(180, 67, 46, 0.25);
}

/* Markdown rendered content */
.prose {
  font-size: 0.96rem;
}
.prose h1,
.prose h2,
.prose h3 {
  margin-top: 1.2rem;
  font-family: var(--font-sans);
}
.prose code {
  background: var(--surface-2);
  padding: 0.12rem 0.38rem;
  border-radius: 5px;
  font-size: 0.85em;
}
.prose pre {
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
  border: 1px solid #3a342d;
  background: #2a2622;
  color: #e8e3d8;
}
.prose pre code {
  background: none;
  padding: 0;
}
.prose ul,
.prose ol {
  padding-left: 1.3rem;
}
/* Inline prose: keep short generated text (options, card fronts) on one line while still styling `code`. */
.prose-inline {
  display: inline;
  font-size: inherit;
}
/* Tighten block prose (e.g. a code block) when embedded in compact spots. */
.qtext .prose,
.flashcard .front .prose,
.flashcard .back .prose {
  margin: 0.4rem 0 0;
  font-size: inherit;
}
.qtext .prose p,
.flashcard .prose p {
  margin: 0.3rem 0;
}
.prose blockquote {
  border-left: 3px solid var(--border);
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
}

/* Loading shimmer */
.loading {
  color: var(--muted);
  font-style: italic;
}
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Topic nav tabs */
/* Topic status strip (sits under the title) */
.topic-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 0.9rem;
  margin: 0 0 1.5rem;
}
.topic-status-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.topic-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.topic-status-actions form {
  margin: 0;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.tabs button {
  font: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0.9rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover {
  color: var(--text);
}
.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Feynman chat */
.chat {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.chat .msg {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  max-width: 85%;
}
.chat .msg.user {
  align-self: flex-end;
  background: var(--accent-soft);
}
.chat .msg.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chat .msg .who {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

/* Auth pages */
.auth-wrap {
  max-width: 380px;
  margin: 8vh auto;
}
.auth-wrap .card {
  padding: 1.75rem;
}
.field {
  margin-bottom: 1rem;
}

/* Quiz */
.question {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-top: 1rem;
  background: var(--surface-2);
}
.question .qtext {
  font-weight: 600;
  margin-bottom: 0.6rem;
}
.choices label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--text);
  margin-bottom: 0.4rem;
  cursor: pointer;
}
.choices input {
  width: auto;
}
.score {
  font-weight: 700;
}
.score.high {
  color: var(--green);
}
.score.mid {
  color: var(--amber);
}
.score.low {
  color: var(--red);
}

/* Flashcards */
.flashcard {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  background: var(--surface-2);
}
.flashcard .front {
  font-weight: 600;
}
.flashcard .back {
  color: var(--muted);
  margin-top: 0.4rem;
}
.flashcard .tags {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.4rem;
}

/* Curriculum editor */
.edit-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.edit-actions {
  white-space: nowrap;
  display: inline-flex;
  gap: 0.3rem;
}
.edit-actions .btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}
.edit-topics {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}
.edit-topics li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.edit-topics li:hover {
  background: var(--surface-2);
}

/* ---- Responsive / mobile ---- */

/* Never let long words, URLs, code, or wide media force horizontal scrolling. */
html {
  -webkit-text-size-adjust: 100%;
}
img,
pre {
  max-width: 100%;
}
.prose {
  overflow-wrap: break-word;
}
.prose table {
  display: block;
  overflow-x: auto;
}
.topic-card .desc,
.flashcard .front,
.flashcard .back,
.chat .msg {
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .container {
    padding: 1.25rem 1rem;
  }

  .site-header {
    padding: 0.7rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
  }
  .nav-toggle {
    display: flex;
  }
  .site-header nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    margin-top: 0.25rem;
  }
  .site-header nav.open {
    display: flex;
  }
  .site-header nav a {
    padding: 0.55rem 0.15rem;
    font-size: 1rem;
  }
  .site-header nav .ai-pill {
    justify-content: flex-start;
  }
  .site-header .nav-signout,
  .site-header nav .lang-form {
    display: flex;
  }
  .site-header nav .nav-signout .btn,
  .site-header nav .lang-form .lang-toggle {
    width: 100%;
  }

  h1 {
    font-size: 1.6rem;
  }
  h2 {
    font-size: 1.15rem;
    margin-top: 1.5rem;
  }

  /* Prevent iOS Safari from zooming when focusing an input. */
  textarea,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="url"],
  select {
    font-size: 16px;
  }

  /* Editor: stack titles above their actions so buttons never overflow. */
  .edit-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
  .edit-topics li {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .edit-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .edit-actions .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Tabs scroll horizontally instead of wrapping into several rows. */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar {
    height: 0;
  }
  .tabs button {
    white-space: nowrap;
  }

  .chat .msg {
    max-width: 92%;
  }
  .topic-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .container {
    padding: 1rem 0.85rem;
  }
  h1 {
    font-size: 1.45rem;
  }
  /* Stack action rows full-width for comfortable tap targets. */
  .btn-row .btn,
  .btn-row > form,
  .btn-row > form > .btn {
    width: 100%;
  }
}

/* Rouge syntax highlighting (Base16 light) */
.highlight table td {
  padding: 5px;
}
.highlight table pre {
  margin: 0;
}
.highlight,
.highlight .w {
  color: #383838;
}
.highlight .err {
  color: #181818;
  background-color: #ab4642;
}
.highlight .c,
.highlight .ch,
.highlight .cd,
.highlight .cm,
.highlight .cpf,
.highlight .c1,
.highlight .cs {
  color: #585858;
}
.highlight .cp {
  color: #f7ca88;
}
.highlight .nt {
  color: #f7ca88;
}
.highlight .o,
.highlight .ow {
  color: #d8d8d8;
}
.highlight .p,
.highlight .pi {
  color: #d8d8d8;
}
.highlight .gi {
  color: #a1b56c;
}
.highlight .gd {
  color: #ab4642;
}
.highlight .gh {
  color: #7cafc2;
  background-color: #181818;
  font-weight: bold;
}
.highlight .ge {
  font-style: italic;
}
.highlight .ges {
  font-weight: bold;
  font-style: italic;
}
.highlight .gs {
  font-weight: bold;
}
.highlight .k,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kv {
  color: #ba8baf;
}
.highlight .kc {
  color: #dc9656;
}
.highlight .kt {
  color: #dc9656;
}
.highlight .kd {
  color: #dc9656;
}
.highlight .s,
.highlight .sb,
.highlight .sc,
.highlight .dl,
.highlight .sd,
.highlight .s2,
.highlight .sh,
.highlight .sx,
.highlight .s1 {
  color: #a1b56c;
}
.highlight .sa {
  color: #ba8baf;
}
.highlight .sr {
  color: #86c1b9;
}
.highlight .si {
  color: #a16946;
}
.highlight .se {
  color: #a16946;
}
.highlight .nn {
  color: #f7ca88;
}
.highlight .nc {
  color: #f7ca88;
}
.highlight .no {
  color: #f7ca88;
}
.highlight .na {
  color: #7cafc2;
}
.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .il,
.highlight .mo,
.highlight .mx {
  color: #a1b56c;
}
.highlight .ss {
  color: #a1b56c;
}

/* ---- Code-block dark panel ----
   Overrides the light Rouge theme above so fenced code blocks stand out on a dark
   panel (inline `code` keeps its light chip styling via .prose code). */
.prose pre code {
  color: #e8e3d8;
}
.highlight {
  background: transparent;
  color: #e8e3d8;
}
.highlight .c,
.highlight .ch,
.highlight .cd,
.highlight .cm,
.highlight .cpf,
.highlight .c1,
.highlight .cs {
  color: #9a9081;
  font-style: italic;
}
.highlight .k,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kv,
.highlight .kd {
  color: #e6a07a;
}
.highlight .kc,
.highlight .kt {
  color: #e6c07a;
}
.highlight .s,
.highlight .sb,
.highlight .sc,
.highlight .dl,
.highlight .sd,
.highlight .s2,
.highlight .sh,
.highlight .sx,
.highlight .s1,
.highlight .sr,
.highlight .sa,
.highlight .se,
.highlight .si {
  color: #a8c98a;
}
.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .il,
.highlight .mo,
.highlight .mx,
.highlight .ss {
  color: #e6c07a;
}
.highlight .nf,
.highlight .na,
.highlight .nb,
.highlight .bp {
  color: #88c0b0;
}
.highlight .nc,
.highlight .nn,
.highlight .no,
.highlight .nt,
.highlight .nd {
  color: #e6c07a;
}
.highlight .o,
.highlight .ow,
.highlight .p,
.highlight .pi {
  color: #d4be98;
}
.highlight .gi {
  color: #a8c98a;
}
.highlight .gd {
  color: #e6816a;
}
.highlight .gh {
  color: #88c0b0;
}
.highlight .err {
  color: #ff9b8a;
}
