:root {
  --bg: #0B0E14;
  --bg-elevated: #111620;
  --bg-panel: #0E131C;
  --border: #1F2733;
  --border-soft: #171E29;
  --text-primary: #E6EDF3;
  --text-muted: #7D8590;
  --text-faint: #4B5563;
  --add: #3FB950;
  --add-dim: rgba(63, 185, 80, 0.12);
  --del: #F85149;
  --del-dim: rgba(248, 81, 73, 0.12);
  --amber: #D29922;
  --violet: #A371F7;
  --blue: #58A6FF;
  --add-hover: rgba(63, 185, 80, 0.22);
  --add-end: #2ea043;
  --violet-dim: rgba(163, 113, 247, 0.12);
  --violet-hover: rgba(163, 113, 247, 0.22);
  --heat-1: rgba(63, 185, 80, 0.25);
  --heat-2: rgba(63, 185, 80, 0.48);
  --heat-3: rgba(63, 185, 80, 0.72);
  --panel-shadow: none;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  /* Soft cool-grey "paper": the page is the darkest surface, panels sit a step
     lighter, and inset things (tracks, chips, title bars) a step darker.
     No pure white anywhere, so nothing glares. */
  --bg: #E6E9EE;
  --bg-elevated: #DFE4EA;
  --bg-panel: #F2F4F7;
  --border: #C6CDD7;
  --border-soft: #D5DAE2;
  --text-primary: #262D38;
  --text-muted: #465160;
  --text-faint: #5E6978;
  --add: #2A7440;
  --add-dim: rgba(42, 116, 64, 0.12);
  --del: #B03A36;
  --del-dim: rgba(176, 58, 54, 0.10);
  --amber: #8A6410;
  --violet: #6B4DC4;
  --blue: #2A64AD;
  --add-hover: rgba(42, 116, 64, 0.20);
  --add-end: #3A8A52;
  --violet-dim: rgba(107, 77, 196, 0.10);
  --violet-hover: rgba(107, 77, 196, 0.18);
  --heat-1: rgba(42, 116, 64, 0.22);
  --heat-2: rgba(42, 116, 64, 0.44);
  --heat-3: rgba(42, 116, 64, 0.70);
  --panel-shadow: 0 1px 2px rgba(38, 45, 56, 0.06), 0 4px 14px rgba(38, 45, 56, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--sans);
  line-height: 1.5;
  padding-left: 48px;
  transition: background 0.2s ease, color 0.2s ease;
}

::selection { background: var(--add-dim); color: var(--add); }

/* ---------- Gutter signature element ---------- */
.gutter {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 48px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.gutter-line {
  position: absolute;
  top: 40px;
  bottom: 40px;
  left: 50%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--border) 4%, var(--border) 96%, transparent);
  transform: translateX(-50%);
}
.gutter-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  left: 50%;
  transform: translateX(-50%);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.gutter-dot[data-target="hero"] { top: 6%; }
.gutter-dot[data-target="health"] { top: 20%; }
.gutter-dot[data-target="commits"] { top: 34%; }
.gutter-dot[data-target="contributors"] { top: 48%; }
.gutter-dot[data-target="languages"] { top: 62%; }
.gutter-dot[data-target="issues"] { top: 76%; }
.gutter-dot[data-target="ai-summary"] { top: 90%; }
.gutter-dot.active {
  background: var(--add);
  border-color: var(--add);
  box-shadow: 0 0 0 4px var(--add-dim);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
}
.prompt { color: var(--text-primary); font-weight: 600; }
.prompt::before { content: '> '; color: var(--add); }
.topbar-sub { color: var(--text-faint); font-size: 0.85rem; }

.theme-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 5px 12px 5px 10px;
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--blue); color: var(--text-primary); }
.theme-toggle-icon { font-size: 0.9rem; }

.offline-banner {
  background: var(--amber);
  color: #14181F;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 8px 12px;
}
.offline-banner.hidden { display: none; }

main { max-width: 900px; margin: 0 auto; padding: 0 32px; }

.section { padding: 88px 0; border-bottom: 1px solid var(--border-soft); }
.section:last-of-type { border-bottom: none; }
.section.hidden { display: none; }

.commit-hash {
  font-family: var(--mono);
  color: var(--amber);
  font-size: 0.8rem;
  margin: 0 0 14px;
}

/* ---------- Hero ---------- */
.hero { padding-top: 64px; }
.hero h1 {
  font-family: var(--mono);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.12;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}
.lede {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 540px;
  margin: 0 0 40px;
}

.terminal {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-panel);
  max-width: 640px;
  box-shadow: var(--panel-shadow);
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--del); }
.dot.amber { background: var(--amber); }
.dot.green { background: var(--add); }
.terminal-title {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-left: 8px;
}
.terminal-body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  font-family: var(--mono);
}
.terminal-prompt { color: var(--add); white-space: nowrap; font-size: 0.95rem; }
#repo-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.95rem;
  min-width: 0;
}
#repo-input::placeholder { color: var(--text-faint); }
#run-btn {
  background: var(--add-dim);
  color: var(--add);
  border: 1px solid var(--add);
  border-radius: 5px;
  padding: 7px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
#run-btn:hover { background: var(--add-hover); }
#run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-faint);
  font-family: var(--mono);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--blue);
  border-radius: 5px;
  padding: 3px 9px;
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--blue); }

.hint.hidden { display: none; }

.heatmap-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  margin: 18px 0 8px;
}
.commit-heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--border-soft);
  display: inline-block;
}
.heatmap-cell[data-level="1"] { background: var(--heat-1); }
.heatmap-cell[data-level="2"] { background: var(--heat-2); }
.heatmap-cell[data-level="3"] { background: var(--heat-3); }
.heatmap-cell[data-level="4"] { background: var(--add); }

.rate-note {
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--text-faint);
  max-width: 520px;
}

/* ---------- GitHub token ---------- */
.token-row { margin-top: 16px; }
.token-toggle {
  background: none;
  border: none;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}
.token-toggle:hover { text-decoration: underline; }
.token-panel {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  max-width: 520px;
  box-shadow: var(--panel-shadow);
}
.token-panel.hidden { display: none; }
.token-panel-row { display: flex; gap: 8px; }
#token-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
  min-width: 0;
}
#token-input:focus { border-color: var(--blue); }
#token-save-btn, .token-clear {
  background: var(--add-dim);
  color: var(--add);
  border: 1px solid var(--add);
  border-radius: 5px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.token-clear {
  background: var(--del-dim);
  color: var(--del);
  border-color: var(--del);
}
.token-clear.hidden { display: none; }
.token-note {
  margin: 10px 0 0;
  font-size: 0.74rem;
  color: var(--text-faint);
  line-height: 1.5;
}
.token-note a { color: var(--text-faint); }
.rate-status {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-faint);
  min-height: 1.2em;
}
.rate-status.token-active { color: var(--add); }

.status {
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.2em;
}
.status.loading::before { content: '⟳ '; color: var(--amber); }
.status.done::before { content: '✓ '; color: var(--add); }

/* ---------- Repo meta ---------- */
.repo-meta {
  padding: 40px 0 0;
}
.repo-meta.hidden { display: none; }
.repo-meta-inner {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  background: var(--bg-panel);
  box-shadow: var(--panel-shadow);
}
.repo-meta-name {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 8px;
}
.repo-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.repo-meta-name { margin: 0; }
.repo-meta-name a { color: var(--text-primary); text-decoration: none; border-bottom: 1px dashed var(--border); }
.repo-meta-name a:hover { color: var(--blue); border-color: var(--blue); }
.share-btn {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
}
.share-btn:hover { border-color: var(--blue); color: var(--blue); }
.repo-meta-desc { color: var(--text-muted); margin: 14px 0 18px; max-width: 640px; }
.repo-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  font-family: var(--mono);
  font-size: 0.88rem;
}
.repo-stat { color: var(--text-muted); }
.repo-stat b { color: var(--text-primary); font-weight: 600; }

/* ---------- Section headers ---------- */
h2 {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 8px;
}
.section-hash { color: var(--violet); margin-right: 6px; }
.section-note {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 28px;
  max-width: 560px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  padding: 24px;
  box-shadow: var(--panel-shadow);
}
.panel-split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  align-items: center;
}

/* Fixed heights so Chart.js's responsive resizing can't enter a feedback loop
   with an unconstrained parent (this was the cause of the post-first-run freeze). */
#commits-chart, #languages-chart, #sentiment-chart {
  max-height: 220px;
}
@media (max-width: 640px) {
  .panel-split { grid-template-columns: 1fr; }
}

/* ---------- Health score ---------- */
.health-panel { display: flex; flex-direction: column; gap: 24px; }
.health-headline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--mono);
}
.health-score-value { font-size: 3rem; font-weight: 700; line-height: 1; color: var(--text-primary); }
.health-score-max { font-size: 1.1rem; color: var(--text-faint); }
.health-grade {
  margin-left: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 20px;
}
.health-breakdown { display: flex; flex-direction: column; gap: 18px; }
.health-row-top {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.health-label { color: var(--text-primary); text-transform: capitalize; }
.health-points { color: var(--text-faint); }
.health-bar-track {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}
.health-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--add));
  border-radius: 3px;
}
.health-note {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- Compare mode ---------- */
.health-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.compare-toggle-row { margin-top: 18px; }
.compare-toggle {
  background: none;
  border: none;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}
.compare-toggle:hover { text-decoration: underline; }
.compare-toggle.hidden { display: none; }

.compare-collapse {
  height: 0;
  overflow: hidden;
  transition: height 0.3s ease;
}

.compare-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  max-width: 520px;
  box-shadow: var(--panel-shadow);
}
.compare-panel-row { display: flex; gap: 8px; }
#compare-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
  min-width: 0;
}
#compare-input:focus { border-color: var(--blue); }
#compare-run-btn {
  background: var(--add-dim);
  color: var(--add);
  border: 1px solid var(--add);
  border-radius: 5px;
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#compare-run-btn:hover { background: var(--add-hover); }
#compare-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.compare-status {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  min-height: 1.1em;
}
.compare-status.loading { color: var(--amber); }
.compare-status.error { color: var(--del); }

.compare-results { margin-top: 24px; }
.compare-results.hidden { display: none; }

.compare-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-panel);
  box-shadow: var(--panel-shadow);
}
.compare-card-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.compare-card-titlebar-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-left: 6px;
}
.compare-card-body { padding: 26px 28px 24px; }

.compare-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.compare-card-side {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.compare-card-side-right { flex-direction: row-reverse; text-align: right; }
.compare-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.compare-card-identity { min-width: 0; }
.compare-card-identity-right { text-align: right; }
.compare-card-name {
  display: block;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compare-card-name:hover { color: var(--blue); }
.compare-card-lang {
  display: block;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-faint);
  margin-top: 3px;
}
.compare-card-vs {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-health {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}
.compare-health-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-align: center;
  margin-bottom: 10px;
}
.compare-health-bar {
  display: flex;
  align-items: stretch;
  height: 34px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.compare-health-bar-a, .compare-health-bar-b {
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: width 0.4s ease;
}
.compare-health-bar-a { justify-content: flex-end; padding-right: 10px; }
.compare-health-bar-b { justify-content: flex-start; padding-left: 10px; }
.compare-health-bar-mid { width: 2px; background: var(--bg-panel); flex-shrink: 0; }

.compare-metrics {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
}
.compare-metric-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}
.compare-metric-row:last-child { border-bottom: none; }
.compare-metric-value {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compare-metric-row .compare-metric-value:first-child { text-align: right; }
.compare-metric-row .compare-metric-value:last-child { text-align: left; }
.compare-metric-value.win { color: var(--add); font-weight: 700; }
.compare-metric-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  text-align: center;
  white-space: nowrap;
  padding: 0 6px;
}

.compare-share-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.share-image-btn {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
}
.share-image-btn:hover { border-color: var(--blue); color: var(--blue); }
.share-image-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 640px) {
  .compare-card-body { padding: 20px 16px; }
  .compare-card-avatar { width: 36px; height: 36px; }
  .compare-card-name { font-size: 0.82rem; }
  .compare-metric-label { font-size: 0.6rem; }
  .compare-metric-value { font-size: 0.76rem; }
}

/* ---------- Contributors ---------- */
.contributors-list { display: flex; flex-direction: column; gap: 14px; }
.contributor-row { display: flex; align-items: center; gap: 12px; }
.contributor-row img {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.contributor-name {
  font-family: var(--mono);
  font-size: 0.88rem;
  width: 160px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contributor-name a { color: var(--text-primary); text-decoration: none; }
.contributor-name a:hover { color: var(--blue); }
.contributor-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}
.contributor-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--add), var(--add-end));
  border-radius: 4px;
}
.contributor-count {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  width: 70px;
  text-align: right;
  flex-shrink: 0;
}

/* ---------- Languages ---------- */
.languages-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.languages-list li { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 0.88rem; }
.lang-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.lang-name { flex: 1; color: var(--text-primary); }
.lang-pct { color: var(--text-faint); }

/* ---------- Issues ---------- */
.diff-counts {
  display: flex;
  gap: 28px;
  margin-bottom: 24px;
  font-family: var(--mono);
  flex-wrap: wrap;
}
.diff-count { font-size: 1.4rem; font-weight: 600; }
.diff-count.open { color: var(--add); }
.diff-count.open::before { content: '+ '; }
.diff-count.closed { color: var(--del); }
.diff-count.closed::before { content: '- '; }
.diff-count-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-weight: 400;
  margin-top: 2px;
}

/* ---------- AI summary ---------- */
.ai-badge {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--violet);
  background: var(--violet-dim);
  border: 1px solid var(--violet);
  border-radius: 20px;
  padding: 2px 9px;
  vertical-align: middle;
  margin-left: 8px;
  letter-spacing: 0.02em;
}
.ai-panel { display: flex; flex-direction: column; gap: 14px; }
.ai-action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.ai-model-note {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}
#ai-generate-btn {
  background: var(--violet-dim);
  color: var(--violet);
  border: 1px solid var(--violet);
  border-radius: 5px;
  padding: 8px 18px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#ai-generate-btn:hover { background: var(--violet-hover); }
#ai-generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-output {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 0;
}
.ai-output p { margin: 0 0 14px; }
.ai-output p:last-child { margin-bottom: 0; }
.ai-output-list {
  margin: 0 0 14px;
  padding-left: 1.3em;
  list-style: none;
}
.ai-output-list li {
  position: relative;
  margin-bottom: 8px;
}
.ai-output-list li::before {
  content: '▸';
  position: absolute;
  left: -1.2em;
  color: var(--violet);
}
.ai-output-list li:last-child { margin-bottom: 0; }
.ai-output-list + p { margin-top: -4px; }
.ai-cursor {
  display: inline-block;
  width: 7px;
  height: 0.95em;
  background: var(--violet);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: ai-blink 0.9s steps(1) infinite;
}
@keyframes ai-blink { 50% { opacity: 0; } }
.ai-fallback-note {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint) !important;
  margin-top: 4px;
}
.ai-output.ai-loading {
  font-family: var(--mono);
  color: var(--amber);
  font-size: 0.88rem;
}
.ai-output.ai-error {
  font-family: var(--mono);
  color: var(--del);
  font-size: 0.88rem;
}

/* ---------- Share card (off-screen template, captured to PNG) ---------- */
.share-card {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 680px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-panel);
  font-family: var(--sans);
}
.share-card-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.share-card-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.share-card-dot.red { background: var(--del); }
.share-card-dot.amber { background: var(--amber); }
.share-card-dot.green { background: var(--add); }
.share-card-titlebar-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-left: 6px;
}
.share-card-body { padding: 28px 32px 8px; }
.share-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.share-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.share-card-title { flex: 1; min-width: 0; }
.share-card-name {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-card-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 4px;
}
.share-card-score-badge {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-family: var(--mono);
}
.share-card-score-value { font-size: 1.6rem; font-weight: 700; }
.share-card-score-max { font-size: 0.8rem; color: var(--text-faint); }
.share-card-grade {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
  font-weight: 600;
}
.share-card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 20px 0 0;
}
.share-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}
.share-card-stat { text-align: left; }
.share-card-stat-value {
  display: block;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}
.share-card-stat-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.share-card-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}
.share-card-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.share-card-lang-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.share-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  margin-top: 20px;
  border-top: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ---------- Error ---------- */
.error-panel {
  max-width: 900px;
  margin: 0 auto 40px;
  padding: 0 32px;
}
.error-panel.hidden { display: none; }
.error-box {
  border: 1px solid var(--del);
  background: var(--del-dim);
  border-radius: 8px;
  padding: 18px 20px;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--del);
}
.error-box::before { content: '✗ '; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px;
  color: var(--text-faint);
  font-size: 0.8rem;
  font-family: var(--mono);
}

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  body { padding-left: 0; }
  .gutter { display: none; }
  main { padding: 0 20px; }
  .topbar { padding: 16px 20px; }
  .section { padding: 56px 0; }
}
/* ---------- Light theme refinements ---------- */
:root[data-theme="light"] .offline-banner { color: #FFFFFF; background: var(--amber); }
:root[data-theme="light"] ::selection { background: rgba(42, 100, 173, 0.22); color: var(--text-primary); }
:root[data-theme="light"] .compare-health-bar-a,
:root[data-theme="light"] .compare-health-bar-b { text-shadow: none; }
:root[data-theme="light"] .chip,
:root[data-theme="light"] .share-btn,
:root[data-theme="light"] .share-image-btn,
:root[data-theme="light"] .theme-toggle { background: var(--bg-panel); }
:root[data-theme="light"] #token-input,
:root[data-theme="light"] #compare-input { background: var(--bg); }