:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f6f6f4;
  --surface-3: #efefec;
  --ink: #111214;
  --ink-2: #36383d;
  --ink-3: #6b6f76;
  --ink-4: #9aa0a8;
  --line: #e7e7e3;
  --line-2: #efefeb;
  --accent-h: 245;
  --accent: oklch(0.58 0.17 var(--accent-h));
  --accent-soft: oklch(0.95 0.04 var(--accent-h));
  --accent-ink: oklch(0.38 0.15 var(--accent-h));
  --ok: oklch(0.62 0.14 150);
  --warn: oklch(0.72 0.15 70);
  --danger: oklch(0.6 0.18 25);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 0 rgba(17,18,20,0.04), 0 1px 2px rgba(17,18,20,0.04);
  --shadow-md: 0 1px 0 rgba(17,18,20,0.04), 0 6px 20px -8px rgba(17,18,20,0.1);
  --shadow-lg: 0 1px 0 rgba(17,18,20,0.04), 0 24px 48px -16px rgba(17,18,20,0.16);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-serif: "Instrument Serif", "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ====== App shell ====== */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 12px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ink);
  display: grid; place-items: center;
  color: #fff;
  font-weight: 600;
  font-family: var(--font-serif);
  font-size: 18px;
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.22), transparent 60%);
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
}
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font-weight: 450;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--ink);
  color: #fff;
}
.nav-item .num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  width: 18px;
}
.nav-item.active .num { color: rgba(255,255,255,0.55); }
.nav-item .dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--ink-4);
}
.nav-item.active .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(255,255,255,0.15); }
.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--line-2);
  font-size: 11px;
  color: var(--ink-4);
}

.main {
  min-width: 0;
  padding: 28px 40px 80px;
  max-width: 1240px;
}

/* ====== Typography ====== */
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
.h-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
.h-display {
  font-size: 56px;
  line-height: 1.02;
  font-weight: 500;
  letter-spacing: -0.035em;
}
.h-display .serif {
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
}
.h-section {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 550;
  letter-spacing: -0.025em;
}
.h-card {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.lede {
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 56ch;
}
.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-3); }

/* ====== Controls ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn.primary:hover { background: #2b2d31; }
.btn.accent {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.btn.accent:hover { filter: brightness(0.96); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}
.chip.accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}
.chip.ok { background: color-mix(in oklch, var(--ok), white 85%); color: color-mix(in oklch, var(--ok), black 20%); border-color: transparent; }
.chip.warn { background: color-mix(in oklch, var(--warn), white 82%); color: color-mix(in oklch, var(--warn), black 30%); border-color: transparent; }
.chip.danger { background: color-mix(in oklch, var(--danger), white 86%); color: color-mix(in oklch, var(--danger), black 18%); border-color: transparent; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-pad-lg { padding: 28px; }

/* ====== Grid helpers ====== */
.row { display: flex; gap: 12px; align-items: center; }
.row-space { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.hr { height: 1px; background: var(--line-2); border: 0; margin: 0; }

/* ====== Photo placeholders ====== */
.photo {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
}
.photo.square { aspect-ratio: 1/1; }
.photo.wide { aspect-ratio: 16/9; }
.photo-stripes {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(135deg,
      #f1f1ee 0 14px,
      #e9e9e5 14px 15px);
  display: grid;
  place-items: center;
}
.photo-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  background: rgba(255,255,255,0.85);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  letter-spacing: 0.02em;
}
.photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* ====== Reasoning / timeline ====== */
.trace {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  max-height: 320px;
  overflow: auto;
}
.trace .t-line { display: flex; gap: 10px; padding: 2px 0; }
.trace .t-ts { color: var(--ink-4); width: 58px; flex-shrink: 0; }
.trace .t-badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 6px;
}
.tb-think { background: #ececf5; color: #4a4a80; }
.tb-tool { background: #eaf1fb; color: #2d5aa5; }
.tb-result { background: #e7f5ec; color: #2b7048; }
.tb-final { background: #18181b; color: #fff; }
.trace .t-text { white-space: pre-wrap; color: var(--ink-2); min-width: 0; flex: 1; }

/* Step pill progress */
.steps {
  display: flex;
  gap: 0;
  align-items: center;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}
.step {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  gap: 6px;
  align-items: center;
}
.step.done { color: var(--ink); }
.step.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}

/* Confidence bar */
.conf {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
  align-items: center;
}
.conf-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.conf-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width 600ms cubic-bezier(.2,.8,.2,1);
}
.conf-num { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); text-align: right; }

/* Tool call row */
.tool-call {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12.5px;
}
.tool-call + .tool-call { margin-top: 6px; }
.tool-call .t-name { font-family: var(--font-mono); color: var(--ink); font-weight: 500; }
.tool-call .t-arg { color: var(--ink-3); font-family: var(--font-mono); font-size: 11.5px; }
.tool-call .t-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3);
  font-family: var(--font-mono);
}
.pulse {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 1.3s infinite;
}
.pulse.done { background: var(--ok); animation: none; box-shadow: none; }
.pulse.idle { background: var(--ink-4); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent), transparent 40%); }
  70% { box-shadow: 0 0 0 8px color-mix(in oklch, var(--accent), transparent 100%); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent), transparent 100%); }
}

/* Tags */
.tag-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
}
.tag .tag-conf {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
}
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

/* Bounding box */
.bbox-layer { position: absolute; inset: 0; pointer-events: none; }
.bbox {
  position: absolute;
  border: 1.5px solid var(--accent);
  background: color-mix(in oklch, var(--accent), transparent 88%);
  border-radius: 4px;
  transition: opacity 240ms ease, transform 240ms ease;
}
.bbox-label {
  position: absolute;
  top: -22px; left: -1px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px 4px 4px 0;
  white-space: nowrap;
}

/* Slider comparison */
.compare {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  border: 1px solid var(--line);
}
.compare .c-after, .compare .c-before {
  position: absolute; inset: 0;
}
.compare .c-after { clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare .c-handle {
  position: absolute; top: 0; bottom: 0;
  left: var(--pos, 50%);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
  transform: translateX(-1px);
}
.compare .c-knob {
  position: absolute;
  top: 50%; left: var(--pos, 50%);
  transform: translate(-50%, -50%);
  width: 38px; height: 38px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  display: grid; place-items: center;
  cursor: ew-resize;
  color: var(--ink);
  font-size: 12px;
}
.compare .c-tag {
  position: absolute;
  top: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.08em;
}
.compare .c-tag.before { left: 10px; }
.compare .c-tag.after { right: 10px; }

/* Uploader */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface-2);
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { display: none; }

/* Small utility */
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-weight: 450; }
.kv dd { margin: 0; color: var(--ink); }

.divider-label {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-4);
  margin: 24px 0 12px;
}
.divider-label::before, .divider-label::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  right: 20px; bottom: 20px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  overflow: hidden;
}
.tweaks-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  font-weight: 600;
  font-size: 13px;
}
.tweaks-body { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.tweaks-row { display: flex; flex-direction: column; gap: 6px; }
.tweaks-row label { font-size: 11.5px; color: var(--ink-3); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }
.seg {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px;
  border-radius: 8px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--ink-2);
}
.seg button.on { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--ink); font-weight: 500; }

/* Refinable signal slider — styled to match the confidence bar. */
.signal-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: ew-resize;
  padding: 0;
  margin: 0;
  outline: none;
}
.signal-slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 999px;
}
.signal-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--accent, var(--ink)) 0 var(--value, 0%),
    var(--surface-3) var(--value, 0%) 100%);
}
.signal-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(17,18,20,0.18);
  border-radius: 999px;
  cursor: ew-resize;
  transition: transform 80ms ease;
}
.signal-slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.signal-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--accent, var(--ink)) 0 var(--value, 0%),
    var(--surface-3) var(--value, 0%) 100%);
}
.signal-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(17,18,20,0.18);
  border-radius: 999px;
  cursor: ew-resize;
}

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp 400ms cubic-bezier(.2,.8,.2,1) both; }

/* Subtle hero ornament */
.hero-ornament {
  position: absolute;
  pointer-events: none;
  inset: 0;
  background:
    radial-gradient(700px 360px at 95% -20%, color-mix(in oklch, var(--accent), transparent 88%), transparent 60%),
    radial-gradient(500px 260px at -10% 110%, color-mix(in oklch, var(--accent), transparent 92%), transparent 60%);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
