@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --paper: #FAF8F5;
  --paper-warm: #F5F2EC;
  --ink: #1C1917;
  --ink-light: #44403C;
  --ink-faint: #78716C;
  --rule: #D6D3D1;
  --rule-dark: #A8A29E;
  --accent: #B84323;
  --accent-hover: #9A3518;
  --code-bg: #F5F2EC;
  --code-text: #1C1917;
  --code-gutter: #EEE9E0;
  --code-gutter-text: #A8A29E;
  --code-gutter-text-strong: #57534E;
  --code-selection: rgba(184, 67, 35, 0.18);
  --code-selection-strong: rgba(184, 67, 35, 0.28);
  --code-active-line: rgba(184, 67, 35, 0.08);
  --code-cursor: #1C1917;
  --code-bracket: rgba(184, 67, 35, 0.2);
  --success: #166534;
  --error: #991B1B;
  --serif: "Crimson Pro", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Container */
.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.shell-wide {
  max-width: 1400px;
}

/* Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 32px 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  flex-shrink: 0;
  border-radius: 5px;
  transition: transform 0.15s ease;
}

.brand:hover .brand-mark {
  transform: scale(1.05);
}

.brand-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-sub {
  display: none;
}

.nav a {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-light);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper-warm);
  color: var(--ink-faint);
}

.nav-badge.tier-pro {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* Typography */
a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 42px;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 15px;
  font-family: var(--mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin-bottom: 20px;
}

h3 {
  font-size: 20px;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

/* Layout */
.content {
  display: flex;
  flex-direction: column;
  gap: 56px;
  padding-bottom: 80px;
}

section {
  display: flex;
  flex-direction: column;
}

/* Intro */
.intro {
  padding: 24px 0 8px;
}

.intro h1 {
  max-width: 580px;
  margin-bottom: 16px;
}

.intro > p {
  font-size: 18px;
  color: var(--ink-light);
  max-width: 520px;
  line-height: 1.55;
}

/* Auth */
.auth-hero {
  padding: 16px 0 8px;
}

.auth-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.auth-note {
  font-size: 14px;
  color: var(--ink-faint);
}

/* Account */
.account-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.account-avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  object-fit: cover;
  background: var(--paper-warm);
}

.account-sub {
  font-size: 14px;
  color: var(--ink-faint);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.account-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper-warm);
}

.account-value {
  font-family: var(--mono);
  font-size: 18px;
}

.account-note {
  font-size: 13px;
  color: var(--ink-faint);
}

/* Rules */
.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 0;
}

/* Page title */
.page-title {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lead {
  color: var(--ink-light);
  max-width: 600px;
}

/* Lists */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}

.list li {
  border-bottom: 1px solid var(--rule);
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding: 20px 0;
  transition: background 0.15s ease;
}

.list-item:hover {
  background: var(--paper-warm);
  margin: 0 -24px;
  padding: 20px 24px;
}

.list-title {
  font-size: 20px;
  margin-bottom: 6px;
  transition: color 0.15s ease;
}

.list-item:hover .list-title {
  color: var(--accent);
}

.card-title {
  font-size: 20px;
  margin-bottom: 6px;
  transition: color 0.15s ease;
}

.list-item:hover .card-title {
  color: var(--accent);
}

.list-item p {
  font-size: 15px;
  color: var(--ink-light);
}

.meta {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-items: center;
}

.activity-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
  text-align: right;
  row-gap: 6px;
}

.status-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  text-transform: none;
  letter-spacing: 0.05em;
}

.status-started {
  color: var(--ink-light);
  background: var(--paper-warm);
}

.status-passed {
  color: var(--success);
  background: rgba(22, 101, 52, 0.12);
  border-color: rgba(22, 101, 52, 0.35);
}

.status-unknown {
  color: var(--ink-faint);
  background: var(--paper-warm);
}

.empty-state {
  font-size: 15px;
  color: var(--ink-faint);
}

/* Module card enhancements */
.module-info {
  flex: 1;
  min-width: 0;
}

.module-summary {
  font-size: 14px;
  color: var(--ink-light);
}

.module-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.topic-tag {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-faint);
  text-transform: lowercase;
}

.list-item:hover .topic-tag {
  background: var(--paper);
  border-color: var(--rule-dark);
}

.topic-more {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 6px;
  color: var(--ink-faint);
}

.module-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Module progress */
.module-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.progress-bar {
  width: 80px;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-text {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.module-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(22, 101, 52, 0.12);
  border: 1px solid rgba(22, 101, 52, 0.35);
  border-radius: 6px;
  color: var(--success);
}

.has-slides {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-faint);
}

.list-item:hover .has-slides {
  background: var(--paper);
  border-color: var(--accent);
  color: var(--accent);
}

/* Markdown content */
.markdown {
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  font-family: var(--serif);
  margin: 32px 0 12px;
}

.markdown h1 { font-size: 28px; }
.markdown h2 {
  font-size: 22px;
  font-family: var(--serif);
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.markdown h3 { font-size: 18px; }

.markdown p {
  margin: 0 0 16px;
}

.markdown ul,
.markdown ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.markdown li {
  margin-bottom: 8px;
}

.markdown pre {
  margin: 24px 0;
  padding: 20px 24px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  border-left: 3px solid var(--accent);
}

.markdown .trace-box {
  margin: 28px 0;
  padding: 18px 20px 12px;
  background:
    radial-gradient(circle at 12% 18%, rgba(184, 67, 35, 0.12), transparent 55%),
    linear-gradient(135deg, rgba(184, 67, 35, 0.08), rgba(250, 248, 245, 0.9));
  border: 1px solid rgba(184, 67, 35, 0.25);
  border-left: 6px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 14px 28px rgba(28, 25, 23, 0.08);
  position: relative;
  overflow: hidden;
}

.markdown .trace-box::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(184, 67, 35, 0.18), transparent 70%);
  opacity: 0.7;
  pointer-events: none;
}

.markdown .trace-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.markdown .trace-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(184, 67, 35, 0.16);
}

.markdown pre.trace-block {
  margin: 0;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.65);
  border-left: none;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(184, 67, 35, 0.12);
}

.markdown pre.trace-block code {
  color: var(--ink);
}

.markdown pre.trace-block .trace-line {
  display: block;
  white-space: pre;
}

.markdown pre.trace-block .trace-line.trace-key {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 6px;
}

.markdown pre.trace-block .trace-line.trace-step {
  padding-left: 12px;
  position: relative;
  color: var(--ink);
  border-radius: 8px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.markdown pre.trace-block .trace-line.trace-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.markdown pre.trace-block .trace-line.trace-step:hover {
  background: rgba(184, 67, 35, 0.12);
  box-shadow: inset 0 0 0 1px rgba(184, 67, 35, 0.2);
}

/* Trace value highlighting */
.markdown pre.trace-block .trace-value {
  color: #1e40af;
  background: rgba(59, 130, 246, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 500;
}

.markdown pre.trace-block .trace-var {
  color: #047857;
  font-weight: 500;
}

.markdown pre.trace-block .trace-arrow {
  color: var(--accent);
  font-weight: 600;
  padding: 0 2px;
}

/* Step numbering with CSS counters */
.markdown pre.trace-block {
  counter-reset: trace-step;
}

.markdown pre.trace-block .trace-line.trace-step {
  counter-increment: trace-step;
}

.markdown pre.trace-block .trace-line.trace-step::after {
  content: counter(trace-step);
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-faint);
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 6px;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.markdown pre.trace-block .trace-line.trace-step:hover::after {
  opacity: 1;
}

/* Dark mode support for trace */
@media (prefers-color-scheme: dark) {
  .markdown .trace-box {
    background:
      radial-gradient(circle at 12% 18%, rgba(184, 67, 35, 0.18), transparent 55%),
      linear-gradient(135deg, rgba(184, 67, 35, 0.12), rgba(30, 27, 25, 0.95));
    border-color: rgba(184, 67, 35, 0.35);
  }

  .markdown .trace-box::after {
    background: radial-gradient(circle, rgba(184, 67, 35, 0.25), transparent 70%);
  }

  .markdown pre.trace-block {
    background: rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 0 0 1px rgba(184, 67, 35, 0.18);
  }

  .markdown pre.trace-block code {
    color: #f5f5f4;
  }

  .markdown pre.trace-block .trace-line.trace-key {
    color: #a8a29e;
  }

  .markdown pre.trace-block .trace-line.trace-step {
    color: #f5f5f4;
  }

  .markdown pre.trace-block .trace-line.trace-step:hover {
    background: rgba(184, 67, 35, 0.2);
    box-shadow: inset 0 0 0 1px rgba(184, 67, 35, 0.3);
  }

  .markdown pre.trace-block .trace-value {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.15);
  }

  .markdown pre.trace-block .trace-var {
    color: #6ee7b7;
  }

  .markdown pre.trace-block .trace-line.trace-step::after {
    background: rgba(255, 255, 255, 0.08);
    color: #a8a29e;
  }
}

.markdown code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
}

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

.markdown .math-block {
  margin: 20px 0;
  overflow-x: auto;
}

.markdown .katex-display {
  margin: 0;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
}

.markdown th,
.markdown td {
  border: 1px solid var(--muted);
  padding: 10px 14px;
  text-align: left;
}

.markdown th {
  background: var(--code-bg);
  font-weight: 600;
}

.markdown tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

/* Meta line */
.meta-line {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Problem page layout - unified editor panel */
.problem-layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
}

.problem-header {
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.problem-title h1 {
  font-size: 26px;
  margin-bottom: 4px;
}

/* Split pane - problem + editor */
.split-pane {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(400px, 1.2fr);
  gap: 32px;
  flex: 1;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.pane-problem {
  overflow-y: auto;
  padding-right: 24px;
}

.pane-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Unified Editor Panel */
.editor-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}

/* Editor Toolbar - language picker + reset */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--rule);
}

/* Language picker */
.lang-picker {
  display: flex;
  gap: 1px;
  background: var(--rule);
  border-radius: 4px;
  padding: 1px;
}

.lang-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  background: transparent;
  color: var(--ink-faint);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.lang-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
}

.lang-btn.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Reset button */
.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-reset:hover {
  color: var(--accent);
  background: rgba(184, 67, 35, 0.08);
}

/* Editor form wrapper */
.editor-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Code editor with CodeMirror */
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  background: var(--code-bg);
  overflow: hidden;
}

.editor-container textarea[data-editor] {
  width: 100%;
  height: 100%;
  min-height: 280px;
  padding: 12px 14px;
  background: transparent;
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  border: none;
  resize: none;
  tab-size: 4;
}

.editor-container textarea[data-editor]:focus {
  outline: none;
}

/* CodeMirror wrapper */
.cm-wrapper {
  flex: 1;
  overflow: hidden;
}

.cm-wrapper .cm-editor {
  height: 100%;
  background: var(--code-bg);
}

.cm-wrapper .cm-scroller {
  font-family: var(--mono);
}

.cm-lintRange {
  background-image: linear-gradient(to right, rgba(248, 113, 113, 0.75) 50%, rgba(248, 113, 113, 0) 50%);
  background-position: left bottom;
  background-repeat: repeat-x;
  background-size: 6px 2px;
}

.cm-tooltip.cm-tooltip-lint {
  background: #1c1917;
  color: #fafaf9;
  border: 1px solid rgba(250, 250, 249, 0.15);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 10px 25px rgba(12, 10, 9, 0.35);
}

.cm-tooltip.cm-tooltip-lint .cm-diagnosticText {
  white-space: pre-wrap;
}

/* Diagnostics panel */
.diagnostics {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}

.diagnostics-header {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--ink-faint);
  margin-bottom: 8px;
}

.diagnostics-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.diagnostics-item {
  line-height: 1.4;
}

/* Actions */
.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.auto-advance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  cursor: pointer;
}

.auto-advance input {
  accent-color: var(--accent);
  cursor: pointer;
}

.button {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule-dark);
}

.button.secondary:hover {
  border-color: var(--ink);
  background: var(--paper-warm);
}

.button.danger {
  background: var(--error);
  color: #fff;
}

.button.danger:hover {
  background: #b91c1c;
}

/* Editor Action Bar */
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--paper-warm);
  border-top: 1px solid var(--rule);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-run, .btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-run {
  background: var(--accent);
  color: white;
}

.btn-run:hover {
  background: var(--accent-hover);
}

.btn-run .btn-icon {
  flex-shrink: 0;
}

.btn-submit {
  background: var(--ink);
  color: var(--paper);
}

.btn-submit:hover {
  background: var(--ink-light);
}

/* Button loading states */
.btn-run .btn-loading,
.btn-submit .btn-loading {
  display: none;
}

.btn-run.htmx-request .btn-text,
.btn-submit.htmx-request .btn-text,
.btn-run.htmx-request .btn-icon {
  display: none;
}

.btn-run.htmx-request .btn-loading,
.btn-submit.htmx-request .btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-run.htmx-request::after,
.btn-submit.htmx-request::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-run[disabled],
.btn-submit[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Output Panel - results/diagnostics */
.output-panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.output-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--rule);
}

.output-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 8px 12px;
  background: transparent;
  color: var(--ink-faint);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.output-tab:hover {
  color: var(--ink);
}

.output-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  background: var(--paper);
}

.tab-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  background: var(--error);
  color: white;
  border-radius: 8px;
}

.output-content {
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
}

.output-pane {
  display: none;
  padding: 12px;
}

.output-pane.active {
  display: block;
}

/* Results placeholder */
.results-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 12px;
}

/* Diagnostics in output panel */
.diagnostics-content {
  font-family: var(--mono);
  font-size: 12px;
}

.diagnostics-placeholder {
  color: var(--ink-faint);
  padding: 16px;
  text-align: center;
  font-size: 12px;
}

.diagnostics-content .diagnostics-list:not(:empty) + .diagnostics-placeholder {
  display: none;
}

/* Result panel styling */
.result-panel {
  border-radius: 8px;
  overflow: hidden;
}

.result-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--rule);
}

.result-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-icon {
  flex-shrink: 0;
}

.status-icon.pass {
  color: var(--success);
}

.status-icon.fail {
  color: var(--error);
}

.status-text {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
}

.result-panel.pass .status-text {
  color: var(--success);
}

.result-panel.fail .status-text {
  color: var(--error);
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.duration-badge, .mode-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 8px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.result-output {
  padding: 12px 16px;
  background: var(--code-bg);
}

.hint-panel {
  padding: 16px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.hint-header {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.hint-list {
  display: grid;
  gap: 12px;
}

.hint-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper-warm);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.hint-card:hover {
  border-color: var(--accent);
  background: var(--paper);
}

.hint-title {
  font-size: 16px;
  font-family: var(--serif);
  color: var(--ink);
}

.hint-excerpt {
  font-size: 13px;
  color: var(--ink-light);
  line-height: 1.5;
}

.hint-link {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.output-pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
}

.result-actions {
  padding: 12px 16px;
  background: var(--paper-warm);
  border-top: 1px solid var(--rule);
}

.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.btn-next:hover {
  background: var(--ink-light);
}

/* Slides link with icons */
.slides-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 14px;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-light);
  text-decoration: none;
  transition: all 0.15s ease;
}

.slides-link:hover {
  background: var(--paper);
  border-color: var(--accent);
  color: var(--accent);
}

.slides-link svg {
  flex-shrink: 0;
}

.slides-link .external-icon {
  opacity: 0.5;
}

.slides-link:hover .external-icon {
  opacity: 1;
}

.similar-modules {
  margin-top: 16px;
  font-size: 14px;
  color: var(--ink-light);
}

.similar-label {
  color: var(--ink-faint);
  margin-right: 8px;
}

.similar-link {
  color: var(--accent);
  text-decoration: none;
  margin-right: 12px;
}

.similar-link:hover {
  text-decoration: underline;
}

.similar-link:not(:last-child)::after {
  content: ",";
  color: var(--ink-faint);
}

.next-actions {
  margin-top: 16px;
}

/* Quiz */
.quiz {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quiz-item {
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #fff;
}

.quiz-prompt {
  font-weight: 600;
  margin-bottom: 12px;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.quiz-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 13px;
}

.quiz-results {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.quiz-check {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: #fff;
}

.quiz-check.pass {
  border-color: rgba(22, 101, 52, 0.35);
  background: rgba(22, 101, 52, 0.06);
}

.quiz-check.fail {
  border-color: rgba(153, 27, 27, 0.35);
  background: rgba(153, 27, 27, 0.06);
}

.quiz-check-title {
  font-weight: 600;
}

.quiz-check-meta {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 4px;
}

.quiz-check-explain {
  font-size: 12px;
  margin-top: 6px;
}

/* Results */
.result {
  margin-top: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--rule);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.status {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status.pass {
  color: var(--success);
}

.status.fail {
  color: var(--error);
}

.duration {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.output {
  margin: 0;
  padding: 16px 20px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Footer */
.site-footer {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
  padding: 32px 0 48px;
  border-top: 1px solid var(--rule);
  margin-top: 48px;
  letter-spacing: 0.02em;
}

/* Responsive */
@media (max-width: 1024px) {
  .split-pane {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

@media (max-width: 900px) {
  .problem-layout {
    min-height: auto;
  }

  .split-pane {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .pane-problem {
    padding-right: 0;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--rule);
    max-height: 35vh;
    overflow-y: auto;
  }

  .editor-panel {
    border-radius: 6px;
  }

  .editor-container {
    min-height: 250px;
  }

  .output-content {
    max-height: 180px;
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  h1 {
    font-size: 32px;
  }

  .problem-title h1 {
    font-size: 22px;
  }

  .list-item {
    flex-direction: column;
    gap: 12px;
  }

  .meta {
    align-self: flex-start;
  }

  .content {
    gap: 40px;
  }

  /* Editor panel mobile */
  .editor-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .editor-actions {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .action-buttons {
    flex: 1;
    min-width: 0;
  }

  .btn-run, .btn-submit {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
  }

  .auto-advance {
    width: 100%;
    justify-content: flex-end;
  }

  .output-content {
    min-height: 100px;
    max-height: 160px;
  }

  .output-tabs {
    padding: 0 8px;
  }

  .output-tab {
    padding: 6px 10px;
    font-size: 10px;
  }
}

/* Search */
.search-section {
  max-width: 720px;
}

.search-section h1 {
  margin-bottom: 24px;
}

.search-form {
  margin-bottom: 32px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--ink-faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  font-family: var(--sans);
  font-size: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 67, 35, 0.12);
}

.search-input::placeholder {
  color: var(--ink-faint);
}

/* Search results */
.search-count,
.search-message {
  font-size: 14px;
  color: var(--ink-light);
  margin-bottom: 16px;
}

.search-count strong,
.search-message strong {
  color: var(--ink);
}

.search-empty,
.search-no-results {
  padding: 32px 0;
  text-align: center;
}

.search-hint {
  color: var(--ink-faint);
  font-size: 15px;
}

.search-suggestions {
  margin-top: 24px;
  text-align: left;
}

.suggestions-label {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-snippet {
  font-size: 14px;
  color: var(--ink-light);
  line-height: 1.5;
  margin-top: 4px;
}

.search-snippet mark {
  background: rgba(184, 67, 35, 0.15);
  color: var(--ink);
  padding: 1px 2px;
  border-radius: 2px;
}

/* Type badges */
.type-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  color: var(--ink-faint);
}

.type-module {
  border-color: rgba(22, 101, 52, 0.3);
  color: var(--success);
  background: rgba(22, 101, 52, 0.08);
}

.type-problem {
  border-color: rgba(184, 67, 35, 0.3);
  color: var(--accent);
  background: rgba(184, 67, 35, 0.08);
}

.type-quiz {
  border-color: rgba(59, 130, 246, 0.3);
  color: #2563eb;
  background: rgba(59, 130, 246, 0.08);
}

/* Nav spacing for multiple links */
.nav {
  display: flex;
  gap: 20px;
}

/* Pack tabs navigation */
.packs-section {
  display: flex;
  flex-direction: column;
}

.pack-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}

.pack-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  background: var(--paper);
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pack-tab:hover {
  color: var(--ink);
  border-color: var(--rule-dark);
  background: var(--paper-warm);
}

.pack-tab.active {
  color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.pack-count,
.pack-progress {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

.pack-tab.active .pack-count,
.pack-tab.active .pack-progress {
  background: rgba(255, 255, 255, 0.2);
}

.pack-progress {
  color: var(--success);
  background: rgba(22, 101, 52, 0.15);
}

.pack-tab.active .pack-progress {
  background: rgba(22, 101, 52, 0.3);
  color: #86efac;
}

.pack-check {
  color: var(--success);
  flex-shrink: 0;
}

.pack-tab.active .pack-check {
  color: #86efac;
}

.pack-tab.pack-complete {
  border-color: rgba(22, 101, 52, 0.4);
}

.pack-tab.pack-complete:not(.active) {
  background: rgba(22, 101, 52, 0.08);
}

.pack-panels {
  margin-top: 24px;
}

.pack-panel {
  display: none;
}

.pack-panel.active {
  display: block;
}

.pack-description {
  font-size: 15px;
  color: var(--ink-light);
  margin-bottom: 20px;
  max-width: 600px;
}

/* Responsive pack tabs */
@media (max-width: 640px) {
  .pack-tabs {
    gap: 4px;
  }

  .pack-tab {
    font-size: 11px;
    padding: 6px 10px;
  }

  .pack-count {
    display: none;
  }
}

/* Admin */
.admin-content {
  gap: 40px;
}

.admin-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-hero p {
  color: var(--ink-light);
  max-width: 720px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.admin-card {
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-subcard {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-form.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  align-items: end;
}

.admin-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-light);
}

.field span {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.field input,
.field textarea,
.field select {
  font-family: var(--sans);
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
}

.field textarea {
  font-family: var(--mono);
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.admin-notice {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  background: rgba(184, 67, 35, 0.1);
  color: var(--ink);
}

.admin-notice.success {
  background: rgba(22, 101, 52, 0.12);
  color: var(--success);
}

.admin-notice.error {
  background: rgba(153, 27, 27, 0.12);
  color: var(--error);
}

.admin-notice.info {
  background: rgba(37, 99, 235, 0.12);
  color: var(--ink);
}

.admin-notice.info a {
  color: inherit;
  font-weight: 600;
}

.admin-inline {
  font-size: 13px;
}

.admin-inline.success {
  color: var(--success);
}

.admin-inline.error {
  color: var(--error);
}

.field-status {
  font-size: 12px;
  color: var(--ink-faint);
}

.field-status.ok {
  color: var(--success);
}

.field-status.error {
  color: var(--error);
}

.admin-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-list li {
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-list-title {
  font-weight: 600;
  font-size: 16px;
}

.admin-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.status-success {
  color: var(--success);
}

.status-failed {
  color: var(--error);
}

.status-running {
  color: var(--accent);
}

.admin-sub {
  font-size: 14px;
  color: var(--ink-light);
}

.admin-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.admin-breadcrumbs {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-breadcrumbs a {
  text-decoration: none;
  color: var(--ink-light);
}

.admin-issues {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 12px 16px;
  background: #fff;
}

.admin-issues ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--ink-light);
}

.admin-item-row {
  display: grid;
  grid-template-columns: 40px 80px 1fr 1fr auto;
  gap: 12px;
  align-items: center;
}

.admin-file {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 12px 16px;
  background: #fff;
  margin-bottom: 12px;
}

.admin-file summary {
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}

.admin-file-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-job-status {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-log {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 800px) {
  .admin-item-row {
    grid-template-columns: 1fr;
  }
}
