/* Metabolic Optimal — Model Lab
   Light default; dark via html[data-theme="dark"] */

:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #faf8f4;
  --border: rgba(28, 25, 20, 0.1);
  --border-strong: rgba(28, 25, 20, 0.16);
  --text: #1c1914;
  --text-muted: #5c564c;
  --text-dim: #8a8276;
  --text-soft: #3d3830;
  --accent: #b8860b;
  --accent-soft: rgba(184, 134, 11, 0.1);
  --accent-border: rgba(184, 134, 11, 0.35);
  --success: #059669;
  --danger: #dc2626;
  --info: #2563eb;
  --header-bg: rgba(246, 244, 239, 0.88);
  --glow-a: rgba(184, 134, 11, 0.1);
  --glow-b: rgba(37, 99, 235, 0.06);
  --prompt-text: #3d3830;
  --md-body: #2a261f;
  --md-strong: #1c1914;
  --chip-bg: rgba(28, 25, 20, 0.04);
  --chip-ok-fg: #047857;
  --chip-ok-border: rgba(5, 150, 105, 0.28);
  --chip-ok-bg: rgba(5, 150, 105, 0.08);
  --chip-warn-fg: #a16207;
  --code-bg: rgba(28, 25, 20, 0.06);
  --foot-bg: rgba(28, 25, 20, 0.04);
  --hover-wash: rgba(28, 25, 20, 0.05);
  --btn-border-hover: rgba(28, 25, 20, 0.28);
  --status-err: #b91c1c;
  --status-ok: #047857;
  --chat-user-bg: rgba(37, 99, 235, 0.08);
  --chat-user-border: rgba(37, 99, 235, 0.2);
  --chat-assistant-bg: rgba(28, 25, 20, 0.03);
  --spinner-track: rgba(28, 25, 20, 0.12);
  --modal-scrim: rgba(28, 25, 20, 0.45);
  --primary-btn-text: #1a1408;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 40px rgba(28, 25, 20, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SF Mono", "Consolas", ui-monospace, monospace;
  --max: 1280px;
  --header-h: 64px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0f14;
  --bg-elevated: #12171f;
  --bg-card: #161c26;
  --bg-card-hover: #1a2230;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8ecf1;
  --text-muted: #8b95a8;
  --text-dim: #5c677a;
  --text-soft: #c5cdd9;
  --accent: #f0c674;
  --accent-soft: rgba(240, 198, 116, 0.12);
  --accent-border: rgba(240, 198, 116, 0.35);
  --success: #34d399;
  --danger: #f87171;
  --info: #60a5fa;
  --header-bg: rgba(12, 15, 20, 0.82);
  --glow-a: rgba(240, 198, 116, 0.08);
  --glow-b: rgba(96, 165, 250, 0.06);
  --prompt-text: #c5cdd9;
  --md-body: #d5dbe6;
  --md-strong: #f3f6fa;
  --chip-bg: rgba(255, 255, 255, 0.04);
  --chip-ok-fg: #a7f3d0;
  --chip-ok-border: rgba(52, 211, 153, 0.3);
  --chip-ok-bg: rgba(52, 211, 153, 0.08);
  --chip-warn-fg: #fde68a;
  --code-bg: rgba(255, 255, 255, 0.06);
  --foot-bg: rgba(0, 0, 0, 0.18);
  --hover-wash: rgba(255, 255, 255, 0.05);
  --btn-border-hover: rgba(255, 255, 255, 0.22);
  --status-err: #fca5a5;
  --status-ok: #6ee7b7;
  --chat-user-bg: rgba(96, 165, 250, 0.1);
  --chat-user-border: rgba(96, 165, 250, 0.2);
  --chat-assistant-bg: rgba(255, 255, 255, 0.04);
  --spinner-track: rgba(255, 255, 255, 0.15);
  --modal-scrim: rgba(0, 0, 0, 0.65);
  --primary-btn-text: #1a1408;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--glow-a), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, var(--glow-b), transparent 50%),
    var(--bg);
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

a:hover {
  text-decoration: underline;
}

/* —— Header —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--btn-border-hover);
  background: var(--bg-card-hover);
}

.theme-toggle .theme-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.theme-toggle .theme-label-dark {
  display: none;
}

html[data-theme="dark"] .theme-toggle .theme-label-light {
  display: none;
}

html[data-theme="dark"] .theme-toggle .theme-label-dark {
  display: inline;
}

.site-header .inner {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #f0c674, #c9892e 55%, #7c5a1e);
  box-shadow: 0 0 0 1px rgba(240, 198, 116, 0.3), 0 8px 24px rgba(240, 198, 116, 0.15);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav a:hover {
  color: var(--text);
  background: var(--hover-wash);
  text-decoration: none;
}

/* —— Layout —— */
main {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.hero {
  margin-bottom: 2rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.hero h2 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.7rem, 3.5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero .lede {
  margin: 0;
  max-width: 52rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.disclaimer {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* —— Panels / cards —— */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.panel-header .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.prompt-box {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  color: var(--prompt-text);
  max-height: 280px;
  overflow: auto;
}

.prompt-box .sys {
  color: var(--text-dim);
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed var(--border);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--btn-border-hover);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #f5d48a, #e0b35a);
  color: var(--primary-btn-text);
  border-color: transparent;
  font-weight: 650;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe2a0, #efc06a);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

.chip.ok {
  color: var(--chip-ok-fg);
  border-color: var(--chip-ok-border);
  background: var(--chip-ok-bg);
}

.chip.warn {
  color: var(--chip-warn-fg);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* —— Comparison grid —— */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 1rem;
  flex-wrap: wrap;
}

.section-title h3 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.section-title p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
}

.view-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.view-toggle button.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.grid.stacked {
  grid-template-columns: 1fr;
}

.model-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 280px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.model-card:hover {
  border-color: var(--border-strong);
}

.model-card.joint,
.model-card.baseline {
  border-color: var(--accent-border);
  background: linear-gradient(180deg, rgba(240, 198, 116, 0.06), var(--bg-card) 40%);
}

.intro-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.intro-body .intro-p {
  margin: 0;
  color: var(--md-body);
  font-size: 0.98rem;
  max-width: 52rem;
}

.intro-body .intro-p strong {
  color: var(--md-strong);
}

.scores-note {
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 48rem;
}

.score-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.score-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 4.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
}

.score-pill .score-label {
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  line-height: 1.2;
}

.score-pill .score-value {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.02em;
}

.model-card.error {
  border-color: rgba(248, 113, 113, 0.35);
}

.model-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.model-identity {
  display: flex;
  gap: 0.7rem;
  min-width: 0;
}

.vendor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.4rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, #888) 25%, transparent);
}

.model-identity h4 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.model-identity .vendor {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.model-identity .model-id {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
  word-break: break-all;
}

.model-card-body {
  padding: 1rem 1.1rem 1.15rem;
  flex: 1;
  overflow: auto;
  max-height: 520px;
}

.grid.stacked .model-card-body {
  max-height: none;
}

.placeholder {
  color: var(--text-dim);
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  min-height: 140px;
  text-align: center;
  padding: 1rem;
}

.placeholder strong {
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

/* Markdown content */
.md {
  font-size: 0.92rem;
  color: var(--md-body);
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 1.1em 0 0.45em;
}

.md h1 { font-size: 1.15rem; }
.md h2 { font-size: 1.05rem; }
.md h3 { font-size: 0.98rem; }

.md p,
.md ul,
.md ol {
  margin: 0.55em 0;
}

.md ul,
.md ol {
  padding-left: 1.25rem;
}

.md li {
  margin: 0.25em 0;
}

.md strong {
  color: var(--md-strong);
  font-weight: 650;
}

.md code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.md pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow: auto;
}

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

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.75em 0;
}

.md th,
.md td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

.md th {
  background: var(--chip-bg);
  color: var(--text);
}

.md blockquote {
  margin: 0.75em 0;
  padding: 0.2rem 0 0.2rem 0.85rem;
  border-left: 3px solid var(--accent-border);
  color: var(--text-muted);
}

.md hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

.model-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.65rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--foot-bg);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* —— Live / discuss —— */
.live-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .live-grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.field .hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.status-line {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-height: 1.3em;
}

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

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

.chat-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-msg {
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.88rem;
}

.chat-msg.user {
  background: var(--chat-user-bg);
  border: 1px solid var(--chat-user-border);
  align-self: flex-end;
  max-width: 92%;
}

.chat-msg.assistant {
  background: var(--chat-assistant-bg);
  border: 1px solid var(--border);
  align-self: stretch;
}

.chat-msg .role {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.loading-dots::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--spinner-track);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: -2px;
  margin-right: 0.35rem;
}

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

footer {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto 2rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* —— Modal for expanded card —— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(820px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem 1.4rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-head h3 {
  margin: 0;
}

/* —— Filters —— */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-bar button {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.filter-bar button.active {
  color: var(--text);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* —— Horizontal outcomes carousel —— */
.carousel-shell {
  --carousel-arrow-size: 3.5rem;
  position: relative;
  display: grid;
  grid-template-columns: var(--carousel-arrow-size) 1fr var(--carousel-arrow-size);
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.75rem;
}

.carousel-viewport {
  position: relative;
  min-width: 0;
  border-radius: calc(var(--radius) + 4px);
}

.carousel-viewport::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0.85rem;
  width: 2.25rem;
  z-index: 2;
  pointer-events: none;
  opacity: 0.95;
  transition: opacity 0.35s ease;
  background: linear-gradient(270deg, var(--bg), transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.carousel-track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 0.45rem 0.15rem 1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.carousel-track::-webkit-scrollbar {
  height: 8px;
}

.carousel-track::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.carousel-card {
  flex: 0 0 min(420px, calc(100vw - 7.5rem));
  width: min(420px, calc(100vw - 7.5rem));
  max-width: 420px;
  min-height: 420px;
  max-height: 560px;
  scroll-snap-align: start;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.carousel-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.carousel-card .model-card-body {
  max-height: 320px;
}

.carousel-arrow {
  appearance: none;
  width: var(--carousel-arrow-size);
  height: var(--carousel-arrow-size);
  margin: 0;
  padding: 0;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--primary-btn-text);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), transparent 45%),
    linear-gradient(160deg, #ffe2a0 0%, #f0c674 42%, #d4a017 100%);
  box-shadow:
    0 10px 28px rgba(184, 134, 11, 0.28),
    0 2px 0 rgba(255, 255, 255, 0.35) inset,
    0 -2px 0 rgba(0, 0, 0, 0.08) inset;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.28s ease,
    filter 0.28s ease,
    opacity 0.28s ease,
    background 0.28s ease;
  z-index: 3;
  flex-shrink: 0;
}

.carousel-arrow svg {
  display: block;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.carousel-arrow:hover:not(:disabled) {
  transform: scale(1.08);
  filter: brightness(1.04);
  box-shadow:
    0 14px 34px rgba(184, 134, 11, 0.38),
    0 2px 0 rgba(255, 255, 255, 0.4) inset,
    0 -2px 0 rgba(0, 0, 0, 0.08) inset;
}

.carousel-arrow-prev:hover:not(:disabled) svg {
  transform: translateX(-2px);
}

.carousel-arrow-next:hover:not(:disabled) svg {
  transform: translateX(2px);
}

.carousel-arrow:active:not(:disabled) {
  transform: scale(0.96);
  transition-duration: 0.12s;
}

.carousel-arrow:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--accent-soft),
    0 10px 28px rgba(184, 134, 11, 0.28),
    0 2px 0 rgba(255, 255, 255, 0.35) inset;
}

.carousel-arrow:disabled {
  opacity: 0.35;
  cursor: default;
  filter: grayscale(0.25);
  box-shadow: none;
  transform: none;
}

html[data-theme="dark"] .carousel-arrow {
  color: #1a1408;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.22), transparent 45%),
    linear-gradient(160deg, #f5d48a 0%, #e0b35a 48%, #b8860b 100%);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(240, 198, 116, 0.25),
    0 2px 0 rgba(255, 255, 255, 0.12) inset;
}

html[data-theme="dark"] .carousel-viewport::after {
  background: linear-gradient(270deg, var(--bg), transparent);
}

@media (max-width: 640px) {
  .carousel-shell {
    --carousel-arrow-size: 2.85rem;
    gap: 0.4rem;
  }

  .carousel-arrow svg {
    width: 22px;
    height: 22px;
  }

  .carousel-card {
    flex-basis: min(420px, calc(100vw - 6.2rem));
    width: min(420px, calc(100vw - 6.2rem));
  }
}

.score-pill.score-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}

.score-pill.score-link:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  text-decoration: none;
  transform: translateY(-1px);
}

.share-line {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* —— Graph —— */
.graph-panel {
  overflow: hidden;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  margin-bottom: 0.85rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-item .swatch.animal {
  background: #c62828;
}

.legend-item .swatch.plant {
  background: #7cb342;
}

.legend-item .swatch.intel {
  background: var(--accent);
  border-radius: 50%;
}

.graph-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  color: var(--text-dim);
}

#composition-chart {
  width: 100%;
  min-width: 640px;
  height: auto;
  display: block;
}

.chart-cluster {
  cursor: pointer;
}

.chart-cluster.is-hot .bar-animal,
.chart-cluster.is-hot .bar-plant {
  filter: brightness(1.08);
}

.chart-cluster.is-hot .intel-dot {
  stroke-width: 2.5;
  filter: drop-shadow(0 0 6px rgba(240, 198, 116, 0.55));
}

.graph-tip {
  position: absolute;
  z-index: 20;
  min-width: 200px;
  max-width: min(280px, calc(100% - 1rem));
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  opacity: 0;
  transition: opacity 0.12s ease;
}

.graph-tip.is-open {
  opacity: 1;
}

.graph-tip[hidden] {
  display: none !important;
}

.graph-tip-head {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.graph-tip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tip-dot, #888) 28%, transparent);
}

.graph-tip-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}

.graph-tip-sub {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.graph-tip-id {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  word-break: break-all;
}

.graph-tip-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.graph-tip-stat {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.graph-tip-stat span {
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.graph-tip-stat strong {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.02em;
}

.graph-tip-stat.wide {
  grid-column: 1 / -1;
}

.graph-tip-badge {
  display: inline-flex;
  margin-top: 0.55rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--chip-warn-fg);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}

.chart-bg {
  fill: var(--chip-bg);
  stroke: var(--border);
  stroke-width: 1;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.chart-axis {
  fill: var(--text-dim);
  font-size: 11px;
  font-family: var(--font);
}

.chart-axis.title {
  fill: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.chart-tick {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
}

.chart-tick.muted {
  fill: var(--text-dim);
  font-size: 10px;
}

.bar-animal {
  fill: #c62828;
  opacity: 0.92;
}

.bar-plant {
  fill: #8bc34a;
  opacity: 0.9;
}

.intel-line {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.85;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}

.intel-dot {
  fill: #f0c674;
  stroke: var(--bg-elevated);
  stroke-width: 2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

html[data-theme="dark"] .intel-dot {
  fill: #f0c674;
}

.intel-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.graph-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 1.5rem 1rem;
  margin: 0;
  font-size: 0.9rem;
}

.discuss-setup {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.discuss-setup ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--md-body);
}

.discuss-setup li {
  margin: 0.35rem 0;
}

/* Discuss layout:
   [ setup (key/model/start) | chat-log spanning setup+message rows ]
   [ your message            | (chat-log continues — bottoms align)  ]
   [ Send row                | Reddit buttons row (aligned)          ]
   [ status (full width)                                           ] */
.discuss-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  grid-template-areas:
    "setup log"
    "compose log"
    "send reddit"
    "status status";
  gap: 0.75rem 1rem;
  align-items: stretch;
}

.discuss-setup-col {
  grid-area: setup;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.discuss-log-col {
  grid-area: log;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.discuss-compose-col {
  grid-area: compose;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.discuss-send-col {
  grid-area: send;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.discuss-reddit-col {
  grid-area: reddit;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.discuss-status {
  grid-area: status;
  margin: 0;
  min-height: 1.3em;
}

.discuss-key-row {
  margin-bottom: 0.85rem;
}

.discuss-compose {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-height: 0;
}

.discuss-compose textarea {
  flex: 1 1 auto;
  min-height: 100px;
  height: 100%;
  resize: vertical;
}

/* Chat log fills the right column through setup+compose rows;
   bottom edge lines up with bottom of message box */
.discuss-log-col .chat-log {
  flex: 1 1 auto;
  height: 100%;
  min-height: 280px;
  max-height: none;
  overflow: auto;
}

.discuss-start-row,
.discuss-send-row {
  margin-bottom: 0;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
}

.discuss-send-row {
  margin-top: 0;
  min-height: 2.5rem;
}

/* Hover tip when Send is locked (disabled buttons swallow pointer events) */
.btn-tip-wrap {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
}

.btn-tip-wrap.is-locked {
  cursor: not-allowed;
}

.btn-tip-wrap.is-locked > .btn:disabled {
  pointer-events: none;
}

.btn-tip-wrap.is-locked::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%) translateY(0.15rem);
  z-index: 20;
  width: max-content;
  max-width: min(16rem, 70vw);
  padding: 0.4rem 0.6rem;
  border-radius: 0.45rem;
  border: 1px solid var(--border);
  background: var(--bg-card, #1a1a1e);
  color: var(--text, #eee);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 6px 18px color-mix(in srgb, #000 28%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}

.btn-tip-wrap.is-locked:hover::after,
.btn-tip-wrap.is-locked:focus-within::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .discuss-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "setup"
      "log"
      "compose"
      "send"
      "reddit"
      "status";
  }

  .discuss-log-col .chat-log {
    min-height: 240px;
    height: 280px;
    max-height: 360px;
  }
}

.discuss-progress {
  flex: 1 1 12rem;
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  justify-content: center;
}

.discuss-progress[hidden] {
  display: none !important;
}

.progress-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e0b35a, #f0c674, #ffe2a0);
  transition: width 0.25s ease;
}

.progress-fill.indeterminate {
  width: 40% !important;
  animation: progress-slide 1.1s ease-in-out infinite;
}

.discuss-progress.is-error .progress-fill {
  background: linear-gradient(90deg, #dc2626, #f87171);
  animation: none;
  width: 100% !important;
}

.discuss-progress.is-done .progress-fill {
  background: linear-gradient(90deg, #059669, #34d399);
}

.progress-line {
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
  max-width: 100%;
}

.discuss-progress.is-error .progress-line {
  color: var(--status-err);
}

.discuss-progress.is-done .progress-line {
  color: var(--status-ok);
}

@keyframes progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(280%);
  }
}

.reddit-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  width: 100%;
  min-height: 2.5rem;
}

.reddit-actions .hint {
  flex: 1 1 12rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

html[data-theme="dark"] .bar-animal {
  fill: #ef5350;
}

html[data-theme="dark"] .bar-plant {
  fill: #9ccc65;
}
