/* ── Fonts & Tokens ────────────────────────────────────────────────────── */
:root {
  --bg:        #0c0e12;
  --surface:   #111419;
  --card-bg:   #141820;
  --border:    #1d2333;
  --border-hi: #2a3347;
  --accent:    #e8c547;      /* golden amber */
  --accent2:   #4fc3f7;      /* cool blue    */
  --danger:    #ff5f6d;
  --success:   #4caf7d;
  --text:      #dde3f0;
  --muted:     #5a6580;
  --mono:      'DM Mono', 'Cascadia Code', 'Fira Mono', monospace;
  --serif:     'Fraunces', Georgia, serif;
  --radius:    6px;
  --shadow:    0 4px 24px rgba(0,0,0,.6);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
}

/* grain overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  background-repeat: repeat;
  opacity: 0.6;
}

/* subtle grid lines */
body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(232,197,71,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,197,71,.018) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 0 32px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: rgba(12,14,18,.92);
  backdrop-filter: blur(12px);
}

.nav-logo {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.05em;
}
.logo-bracket { color: var(--muted); }
.logo-sep { color: var(--accent); margin: 0 1px; }

.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 6px 14px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--border); }
.nav-link.active { color: var(--accent); }

.nav-badge {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 3px;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main {
  position: relative; z-index: 1;
  min-height: calc(100vh - 56px - 48px);
  padding: 28px 24px;
}

/* ── Studio split layout ─────────────────────────────────────────────────── */
.studio {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

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

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-label {
  font-size: 10px;
  letter-spacing: .2em;
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  background: rgba(232,197,71,.08);
  border: 1px solid rgba(232,197,71,.2);
  padding: 2px 7px;
  border-radius: 3px;
  flex-shrink: 0;
}

.card-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 300;
  color: var(--text);
  font-style: italic;
  letter-spacing: .01em;
  flex: 1;
}

.badge {
  background: var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: auto;
}

/* ── DB Provider Tabs ────────────────────────────────────────────────────── */
.db-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.db-tab {
  padding: 8px 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius);
  transition: all .15s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-tab:hover { border-color: var(--border-hi); color: var(--text); }
.db-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232,197,71,.07);
}

/* ── Form Fields ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }

.label {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,197,71,.1);
}
.input::placeholder { color: var(--muted); opacity: .6; }
.input-mono { font-family: var(--mono); font-size: 12px; resize: vertical; }
.input-lg { font-size: 14px; resize: vertical; }
.input-select { cursor: pointer; }
.input-select option { background: var(--card-bg); }

.field-hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.field-hint code {
  background: var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
}

.field-error {
  font-size: 11px;
  color: var(--danger);
  display: block;
}

.input-group { display: flex; gap: 0; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); flex: 1; }
.input-toggle {
  padding: 9px 14px;
  background: var(--border);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  border-radius: 0 var(--radius) var(--radius) 0;
  white-space: nowrap;
  transition: color .15s;
}
.input-toggle:hover { color: var(--text); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  width: 100%;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { font-size: 14px; }

.btn-primary {
  background: var(--accent);
  color: #0c0e12;
}
.btn-primary:hover:not(:disabled) {
  background: #f0d060;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232,197,71,.3);
}

.btn-accent {
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--accent2);
}
.btn-accent:hover:not(:disabled) {
  background: rgba(79,195,247,.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79,195,247,.2);
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.6;
  border-left: 3px solid;
}
.alert-error {
  background: rgba(255,95,109,.08);
  border-color: var(--danger);
  color: #ff9aa2;
}
.alert-success {
  background: rgba(76,175,125,.08);
  border-color: var(--success);
  color: #7dd3b0;
}

/* ── Schema List ─────────────────────────────────────────────────────────── */
.schema-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.schema-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s;
  gap: 8px;
}
.schema-item:hover { border-color: var(--border-hi); }

.schema-name {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none;
  color: var(--text); font-family: var(--mono); font-size: 13px;
  cursor: pointer; padding: 0; flex: 1;
  text-align: left;
  transition: color .15s;
}
.schema-name:hover { color: var(--accent2); }
.schema-icon { font-size: 14px; }

.schema-actions { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; border-radius: 4px; cursor: pointer;
  transition: all .15s; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.icon-btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 24px 16px;
  color: var(--muted); font-size: 12px;
}
.empty-icon { font-size: 28px; margin-bottom: 8px; opacity: .4; }
.empty-text { line-height: 1.6; }

/* ── Translate area ──────────────────────────────────────────────────────── */
.translate-grid { display: flex; flex-direction: column; gap: 14px; }

.samples {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
}
.samples-label { font-size: 10px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.sample-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-family: var(--mono); font-size: 11px;
  padding: 4px 10px; border-radius: 20px; cursor: pointer;
  transition: all .15s;
}
.sample-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Result card ─────────────────────────────────────────────────────────── */
.result-card {
  border-top-width: 3px;
  animation: slideIn .3s ease;
}
.result-ok { border-top-color: var(--success); }
.result-err { border-top-color: var(--danger); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-header {
  display: flex; justify-content: space-between; align-items: center;
}
.result-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.result-badge {
  font-size: 10px; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 3px;
}
.badge-ok  { background: rgba(76,175,125,.15); color: #4caf7d; }
.badge-err { background: rgba(255,95,109,.15); color: var(--danger); }

.result-dialect {
  font-size: 11px; color: var(--muted); background: var(--border);
  padding: 3px 8px; border-radius: 3px;
}
.result-latency { font-size: 11px; color: var(--muted); }

.copy-btn {
  background: var(--border); border: none;
  color: var(--muted); font-family: var(--mono); font-size: 11px;
  padding: 5px 12px; border-radius: 4px; cursor: pointer;
  transition: all .15s; flex-shrink: 0;
}
.copy-btn:hover { color: var(--text); background: var(--border-hi); }

.sql-wrapper {
  background: #090b0f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 380px;
}
.sql-output {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: #c9d7f0;
  padding: 16px 18px;
  white-space: pre;
  tab-size: 2;
}

.issue-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.issue-item { font-size: 12px; color: #ff9aa2; padding: 6px 10px; background: rgba(255,95,109,.06); border-radius: 4px; }

.tables-referenced {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.tables-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.table-chip {
  background: rgba(79,195,247,.1);
  border: 1px solid rgba(79,195,247,.2);
  color: var(--accent2);
  font-size: 11px; padding: 2px 8px; border-radius: 3px;
}

.result-question {
  font-size: 11px; color: var(--muted);
  padding-top: 10px; border-top: 1px solid var(--border);
  line-height: 1.5;
}
.rq-label { color: var(--border-hi); }

/* ── Settings page ───────────────────────────────────────────────────────── */
.settings-page {
  max-width: 680px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
}
.settings-header { padding-bottom: 8px; }
.page-title { font-family: var(--serif); font-size: 28px; font-weight: 300; font-style: italic; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.settings-card, .info-card { max-width: 100%; }

.guide-list {
  list-style: decimal; padding-left: 20px;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; color: var(--muted); line-height: 1.6;
}
.guide-list strong { color: var(--text); }
.guide-list code {
  background: var(--border); padding: 1px 6px;
  border-radius: 3px; font-family: var(--mono); font-size: 12px;
}
.info-note {
  margin-top: 4px; font-size: 12px; color: var(--muted);
  background: rgba(232,197,71,.05);
  border: 1px solid rgba(232,197,71,.15);
  border-radius: var(--radius); padding: 10px 14px;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 24px;
}
.modal.open { display: flex; }

.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 780px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 4px 8px;
  transition: color .15s; border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-body {
  flex: 1; overflow: auto; padding: 16px 18px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #b0bcd4; white-space: pre;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  position: relative; z-index: 1;
  display: flex; gap: 10px; align-items: center; justify-content: center;
  height: 48px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
  letter-spacing: .05em;
}
.footer-sep { color: var(--border-hi); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .studio {
    grid-template-columns: 1fr;
  }
  .panel-left { order: 1; }
  .panel-right { order: 2; }
  .db-tabs { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .nav { padding: 0 16px; }
  .main { padding: 16px; }
  .nav-badge { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   NEW ADDITIONS — Run Query, Rating, Stats, History, Editor
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Run section ─────────────────────────────────────────────────────────── */
.run-section { padding-top: 12px; border-top: 1px solid var(--border); }

.btn-run {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 20px;
  background: rgba(76,175,125,.1);
  border: 1px solid rgba(76,175,125,.4);
  color: #4caf7d;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  border-radius: var(--radius); cursor: pointer; transition: all .15s;
}
.btn-run:hover:not(:disabled) {
  background: rgba(76,175,125,.18);
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(76,175,125,.2);
}
.btn-run:disabled { opacity:.5; cursor:not-allowed; }

.run-note {
  font-size: 11px; color: var(--muted);
  padding: 10px 14px; border: 1px dashed var(--border);
  border-radius: var(--radius); margin-top: 10px;
}

.results-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0 8px;
}

.results-table-wrap {
  overflow: auto; max-height: 340px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #090b0f;
}

.results-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--mono); font-size: 12px;
}
.results-table th {
  position: sticky; top: 0;
  background: var(--surface); color: var(--muted);
  font-weight: 500; letter-spacing: .06em; text-transform: uppercase; font-size: 10px;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.results-table td {
  padding: 6px 12px; color: var(--text); font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,.03);
  white-space: nowrap; max-width: 300px;
  overflow: hidden; text-overflow: ellipsis;
}
.results-table tr:hover td { background: rgba(255,255,255,.025); }
.null-cell { color: var(--muted); font-style: italic; }

/* ── Rating buttons ──────────────────────────────────────────────────────── */
.rate-btn {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  transition: all .15s; line-height: 1;
}
.rate-btn:hover    { border-color: var(--border-hi); transform: scale(1.1); }
.rate-btn.rated    { background: rgba(232,197,71,.1); border-color: var(--accent); }
.rate-btn-lg       { font-size: 16px; padding: 5px 12px; }

/* ── Token chip ──────────────────────────────────────────────────────────── */
.token-chip {
  background: rgba(232,197,71,.07)!important;
  border-color: rgba(232,197,71,.2)!important;
  color: var(--accent)!important;
}

/* ── Result chips ────────────────────────────────────────────────────────── */
.result-chip {
  font-size: 11px; color: var(--muted); background: var(--border);
  padding: 3px 8px; border-radius: 3px;
}
.result-actions { display:flex; gap:6px; align-items:center; flex-shrink:0; }

/* ── Stats card ──────────────────────────────────────────────────────────── */
.stats-card {}
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; text-align: center;
}
.stat-val { font-family: var(--serif); font-size: 18px; font-weight: 300; color: var(--accent); }
.stat-lbl { font-size: 10px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }

.btn-ghost {
  display: inline-block; padding: 7px 14px;
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-family: var(--mono); font-size: 11px;
  border-radius: var(--radius); cursor: pointer; text-decoration: none;
  transition: all .15s; text-align: center;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); }

/* ── History mini (on Index) ─────────────────────────────────────────────── */
.history-mini {}
.card-link { margin-left: auto; font-size: 11px; color: var(--accent2); text-decoration: none; }
.card-link:hover { text-decoration: underline; }

.history-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.history-item {
  padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; transition: background .12s; border: 1px solid transparent;
}
.history-item:hover { background: var(--surface); border-color: var(--border); }
.history-q { font-size: 12px; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.history-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.history-schema { font-size: 10px; background: var(--border); padding: 1px 6px; border-radius: 3px; color: var(--muted); }
.history-tokens { font-size: 10px; color: var(--muted); }
.history-rating { font-size: 12px; }
.history-time { font-size: 10px; color: var(--muted); margin-left: auto; }

/* ── History page ────────────────────────────────────────────────────────── */
.history-page {
  max-width: 1200px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
}

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 4px;
}
.page-title { font-family: var(--serif); font-size: 28px; font-weight: 300; font-style: italic; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.summary-bar {
  display: flex; align-items: center; gap: 0;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.summary-stat {
  flex: 1; padding: 14px 16px; text-align: center;
}
.summary-divider { width: 1px; background: var(--border); align-self: stretch; }
.summary-val {
  font-family: var(--serif); font-size: 22px; font-weight: 300;
  color: var(--text); font-style: italic;
}
.like-val    { color: var(--success); }
.dislike-val { color: var(--danger); }
.summary-lbl { font-size: 10px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }

.history-table-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.history-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--mono); font-size: 12px;
}
.history-table thead th {
  background: var(--surface); color: var(--muted);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 500;
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.history-table tbody tr { border-bottom: 1px solid rgba(255,255,255,.03); }
.history-table tbody tr:hover { background: rgba(255,255,255,.025); }
.history-table td { padding: 10px 14px; vertical-align: top; }
.row-invalid { border-left: 2px solid var(--danger); }

.td-id { color: var(--muted); font-size: 11px; }
.td-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.td-time-sub { color: var(--border-hi); font-size: 10px; margin-top: 2px; }
.td-question .q-text { color: var(--text); line-height: 1.5; margin-bottom: 4px; }
.td-question .q-tables { display: flex; flex-wrap: wrap; gap: 4px; }
.table-chip-sm {
  font-size: 9px; background: rgba(79,195,247,.08); border: 1px solid rgba(79,195,247,.15);
  color: var(--accent2); padding: 1px 5px; border-radius: 3px;
}
.td-schema .schema-chip {
  font-size: 11px; background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); padding: 2px 7px; border-radius: 3px; white-space: nowrap;
}
.td-tokens { font-size: 12px; color: var(--text); white-space: nowrap; }
.token-bar-wrap { display: flex; flex-direction: column; gap: 4px; }
.token-bar { height: 3px; background: var(--border); border-radius: 2px; width: 60px; }
.token-bar-p { height: 100%; background: var(--accent); border-radius: 2px; }
.td-latency { color: var(--muted); font-size: 11px; white-space: nowrap; }
.valid-ok { color: var(--success); font-size: 14px; }
.valid-err { color: var(--danger);  font-size: 14px; }
.rating-liked    { font-size: 14px; }
.rating-disliked { font-size: 14px; }
.rating-none     { color: var(--border-hi); }

/* Pagination */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
}
.page-btn {
  padding: 6px 12px; font-family: var(--mono); font-size: 11px;
  background: var(--card-bg); border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--radius); text-decoration: none;
  transition: all .15s;
}
.page-btn:hover { color: var(--text); border-color: var(--border-hi); }
.page-btn-active { color: var(--accent)!important; border-color: var(--accent)!important; background: rgba(232,197,71,.06)!important; }
.page-info { font-size: 11px; color: var(--muted); margin-left: 8px; }

/* ── Detail Modal (History) ──────────────────────────────────────────────── */
.modal-box-wide { max-width: 900px; }
.modal-scroll { flex: 1; overflow-y: auto; }

.dm-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.dm-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dm-section {}
.dm-label {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.dm-question {
  font-size: 14px; color: var(--text); line-height: 1.6;
  background: var(--surface); padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.dm-sql {
  font-family: var(--mono); font-size: 13px; line-height: 1.7; color: #c9d7f0;
  background: #090b0f; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; overflow-x: auto; white-space: pre;
}
.dm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dm-tokens { display: flex; flex-direction: column; gap: 6px; }
.dm-token-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.dm-token-row:last-child { border-bottom: none; }
.dm-token-total { color: var(--text); font-weight: 500; }
.dm-token-val { color: var(--accent); }

.dm-details {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.dm-details-summary {
  padding: 8px 14px; cursor: pointer; font-size: 11px;
  color: var(--muted); letter-spacing: .08em; text-transform: uppercase;
  background: var(--surface); list-style: none;
  transition: color .15s;
}
.dm-details-summary:hover { color: var(--text); }
.dm-details[open] .dm-details-summary { border-bottom: 1px solid var(--border); }
.dm-prompt {
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  color: var(--muted); padding: 14px 16px; white-space: pre-wrap;
  word-break: break-word; max-height: 260px; overflow-y: auto;
}

/* ── Responsive additions ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .summary-bar { flex-wrap: wrap; }
  .summary-divider { display: none; }
  .summary-stat { flex: 0 0 33.33%; border-bottom: 1px solid var(--border); }
  .dm-grid { grid-template-columns: 1fr; }
  .history-table th:nth-child(6),
  .history-table td:nth-child(6) { display: none; }
}
@media (max-width: 640px) {
  .page-header { flex-direction: column; gap: 10px; }
  .history-table th:nth-child(7),
  .history-table td:nth-child(7) { display: none; }
}

/* ── ARK additions ─────────────────────────────────────────────────── */
.seg-tabs { display:flex; gap:6px; margin-bottom:14px; border-bottom:1px solid var(--border); }
.seg-tab { background:transparent; color:var(--muted); border:none; padding:8px 14px; cursor:pointer; font-size:13px; border-bottom:2px solid transparent; }
.seg-tab.active { color:var(--text); border-bottom-color:var(--accent,#6cf); }
.seg-pane { padding-top:4px; }
.field-grid { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.label-hint { color:var(--muted); font-weight:400; font-size:10px; margin-left:4px; }
.checkbox-row { display:flex; gap:8px; align-items:center; font-size:12px; color:var(--text); cursor:pointer; }
.schema-item-rich { flex-direction:column; align-items:stretch; padding:10px 12px; }
.schema-row { display:flex; align-items:center; justify-content:space-between; }
.schema-meta { margin-top:6px; }
.schema-desc { font-size:11px; color:var(--muted); margin-bottom:4px; line-height:1.4; }
.schema-tags { display:flex; flex-wrap:wrap; gap:4px; }
.meta-tag { font-size:10px; padding:2px 6px; border-radius:4px; background:rgba(255,255,255,0.04); color:var(--muted); border:1px solid var(--border); }
.meta-tag-warn { background:rgba(255,180,0,0.08); border-color:rgba(255,180,0,0.3); color:#ffb84d; }
.history-model { font-size:10px; color:var(--muted); }

/* ── SaaS additions: landing, auth, agent ──────────────────────────── */
.landing { max-width: 1100px; margin: 0 auto; padding: 40px 24px 80px; }
.landing-hero { text-align: center; padding: 60px 0 48px; }
.landing-tag { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 4px; color: var(--muted); margin-bottom: 18px; }
.landing-title { font-family: 'Fraunces', serif; font-weight: 300; font-size: 56px; line-height: 1.08; letter-spacing: -1px; margin: 0 0 18px; }
.landing-lede { color: var(--muted); font-size: 15px; line-height: 1.7; max-width: 640px; margin: 0 auto 28px; }
.landing-cta { display: flex; gap: 12px; justify-content: center; }
.landing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 48px; }
.landing-card { padding: 22px 24px; }
.landing-card p { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 8px 0; }
.landing-card strong { color: var(--text); font-weight: 500; }
.landing-callout { margin-top: 28px; padding: 28px 32px; }
.landing-callout p { color: var(--muted); font-size: 13px; line-height: 1.7; max-width: 760px; }

.auth-page { max-width: 480px; margin: 60px auto; padding: 0 24px; }
.auth-card { padding: 28px 32px; }
.auth-foot { color: var(--muted); font-size: 11px; margin-top: 14px; text-align: center; }

.nav-user { display:flex; align-items:center; gap:12px; }
.nav-user-email { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link-btn { background:transparent; border:none; cursor:pointer; padding:0; font: inherit; }
.nav-cta { color: var(--text)!important; }

.agent-steps { list-style: none; padding: 0; margin: 0; counter-reset: agent-step; }
.agent-step { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12px; counter-increment: agent-step; }
.agent-step:last-child { border-bottom: none; }
.agent-step::before { content: counter(agent-step); font-family: 'DM Mono', monospace; color: var(--muted); width: 18px; flex-shrink: 0; }
.agent-step-label { color: var(--text); font-weight: 500; min-width: 140px; flex-shrink: 0; }
.agent-step-detail { color: var(--muted); flex: 1; }
.agent-step-time { color: var(--muted); font-family: 'DM Mono', monospace; font-size: 10px; }

@media (max-width: 760px) {
  .landing-grid { grid-template-columns: 1fr; }
  .landing-title { font-size: 38px; }
}
