:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(12, 23, 40, 0.88);
  --panel-strong: rgba(10, 18, 32, 0.96);
  --line: rgba(154, 178, 212, 0.18);
  --text: #e9f1ff;
  --muted: #9cb1cf;
  --accent: #7c9cff;
  --accent-2: #55d6be;
  --chip: rgba(124, 156, 255, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(124, 156, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #091220 0%, #060d17 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 85%);
}

.page-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.hero,
.workspace,
.note-card,
.panel-card,
.composer-card {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  padding: 32px;
  border-radius: 28px;
}

.hero-copy h1 {
  margin: 12px 0 14px;
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  max-width: 11ch;
}

.hero-text {
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.7;
}

.eyebrow,
.section-label {
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7f93af;
}

.hero-actions,
.toolbar-actions,
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions {
  margin-top: 26px;
}

.hero-meta {
  margin-top: 18px;
}

.hero-meta span,
.chip {
  border: 1px solid rgba(124, 156, 255, 0.18);
  background: var(--chip);
  padding: 8px 12px;
  border-radius: 999px;
  color: #d7e2ff;
  font-size: 0.9rem;
}

.chip.alt {
  border-color: rgba(85, 214, 190, 0.18);
  background: rgba(85, 214, 190, 0.12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}

.button.primary {
  background: linear-gradient(135deg, var(--accent), #88a1ff 60%, #b4bfff);
  color: #06111f;
}

.button.secondary,
.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  padding: 22px;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric-value {
  margin-top: 6px;
  font-size: 1.1rem;
  font-weight: 600;
}

.code-card {
  border-radius: 18px;
  border: 1px solid rgba(124, 156, 255, 0.14);
  background: rgba(124, 156, 255, 0.08);
  padding: 18px;
}

.compare-bar {
  margin: 0 auto 20px;
  max-width: 860px;
}

.compare-bar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 28px;
}

.compare-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 130px;
  text-align: center;
}

.compare-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.compare-model {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.compare-metrics {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.compare-metric {
  font-size: 0.78rem;
  color: var(--text);
}

.compare-diff {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
  text-align: center;
}

.diff-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.diff-arrow {
  font-size: 0.9rem;
}

.diff-better {
  color: var(--accent-2);
}

.diff-worse {
  color: #ff8c6b;
}
  color: var(--muted);
  font-size: 0.84rem;
}

.code-card code {
  white-space: pre-wrap;
  line-height: 1.7;
  color: #f0f5ff;
}

.workspace {
  margin-top: 28px;
  border-radius: 28px;
  padding: 28px;
}

.workspace-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.workspace-toolbar h2 {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.composer-card {
  margin-top: 22px;
  border-radius: 22px;
  padding: 18px;
}

textarea,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(7, 16, 29, 0.88);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
}

textarea {
  margin-top: 10px;
  resize: vertical;
  min-height: 120px;
}

.panels-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.panel-card {
  border-radius: 24px;
  padding: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-head h3 {
  margin: 8px 0 0;
  font-size: 1.4rem;
}

.control-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.control-grid label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.metrics-strip {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics-strip div {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
}

.metrics-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metrics-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 1.12rem;
}

.response-card {
  margin-top: 18px;
  min-height: 80px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(4, 10, 18, 0.78);
  padding: 18px;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #e7eefc;
}

/* Copy button overlaid on the response card */
.copy-btn {
  float: right;
  margin-top: -58px;
  margin-right: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.panel-card:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(124, 156, 255, 0.2);
  color: var(--accent);
}

.copy-btn:active {
  opacity: 0.7;
}

.notes-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.note-card {
  border-radius: 22px;
  padding: 18px;
}

.note-card p {
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .hero,
  .panels-grid,
  .notes-grid {
    grid-template-columns: 1fr;
  }

  .workspace-toolbar {
    align-items: start;
    flex-direction: column;
  }
}

.save-notice {
  font-size: 0.76rem;
  color: var(--muted);
  align-self: center;
  padding-left: 8px;
  pointer-events: none;
}

/* ── Preset modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 20, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  width: min(480px, calc(100vw - 40px));
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 8px;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-body label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 6px;
}

.modal-body input,
.modal-body textarea {
  border-radius: 12px;
  font-size: 0.95rem;
}

.modal-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 4px 0 0;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ── Custom preset in select ───────────────────────────────── */
select optgroup.custom-opt {
  color: var(--accent-2);
  font-style: normal;
}

/* ── Light theme ───────────────────────────────────────────── */
body.theme-light {
  --bg: #f5f7ff;
  --panel: rgba(255, 255, 255, 0.90);
  --panel-strong: rgba(255, 255, 255, 0.97);
  --line: rgba(80, 100, 160, 0.18);
  --text: #1a2540;
  --muted: #5a6a8a;
  --accent: #4a5fcc;
  --accent-2: #1a9e8e;
  --chip: rgba(74, 95, 204, 0.10);
  --shadow: 0 8px 32px rgba(80, 100, 180, 0.12);
}

body.theme-light .hero {
  background: linear-gradient(135deg, #e8eeff, #f5f7ff 60%, #e8f4f2);
}

body.theme-light .section-label {
  color: var(--accent);
}

body.theme-light .composer-card,
body.theme-light .model-panel {
  background: var(--panel-strong);
  border-color: var(--line);
}

body.theme-light .toolbar-actions .button.ghost {
  color: var(--muted);
  border-color: var(--line);
}

body.theme-light .toolbar-actions .button.ghost:hover {
  background: var(--chip);
  color: var(--accent);
}

body.theme-light textarea,
body.theme-light select {
  background: var(--bg);
  color: var(--text);
  border-color: var(--line);
}

body.theme-light select optgroup {
  color: var(--muted);
}

body.theme-light .response-card {
  background: var(--panel);
  border-color: var(--line);
}

body.theme-light .response-placeholder {
  color: var(--muted);
}

body.theme-light .save-notice {
  color: var(--accent-2);
}

/* Theme toggle button */
#themeToggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 10px;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
  margin-right: 6px;
}

#themeToggle:hover {
  color: var(--accent);
  background: var(--chip);
}

/* Example prompts dropdown */
#exampleSelect {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 10px;
  transition: border-color 0.2s, background 0.2s;
}

#exampleSelect:hover {
  border-color: var(--accent);
}

body.theme-light #exampleSelect {
  background: var(--bg);
}

/* ── Keyboard shortcut hints ── */
.kbd-hints {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-dim, #888);
  background: var(--panel-weak, #1e1e1e);
  border-top: 1px solid var(--line, #333);
  flex-wrap: wrap;
}

.kbd-hint {
  display: flex;
  align-items: center;
  gap: 3px;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
  border: 1px solid var(--line, #444);
  border-radius: 4px;
  background: var(--panel, #2a2a2a);
  color: var(--text-muted, #aaa);
  line-height: 1.5;
}

body.theme-light .kbd-hints {
  color: #666;
  border-top-color: #e0e0e0;
}

body.theme-light kbd {
  border-color: #ccc;
  background: #f5f5f5;
  color: #555;
}
