/*
 * Juniper Analyze — visual identity ("Liquid Glass", light-only).
 *
 * The estate's design language: floating glass capsules over a soft pastel
 * mesh, real translucency with lensing edges, capsule controls, Inter for
 * UI and a mono face for ids/metrics. Token VALUES mirror the estate's
 * canonical glass skin; light-only by rule ("No dark UI. Ever.").
 */

/* ── tokens ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #e6ecf9;
  --surface:      #ffffff;
  --surface-2:    #eef3fc;
  --surface-3:    #e3ecf8;

  --border:       #d7e2f1;
  --border-strong:#c1d0e8;
  --border-soft:  #e8f0fb;

  --ink:          #0b1428;
  --ink-2:        #33405a;
  --ink-3:        #5d6c87;
  --ink-4:        #909eb8;

  --brand:        #3257ec;
  --brand-2:      #1f3fd0;
  --brand-soft:   #e9f0ff;
  --brand-tint:   #d2e0ff;
  --brand-line:   #bccefb;

  --good:         #02835c;
  --good-soft:    #e6fbf2;
  --good-line:    #a9e9cd;
  --warn:         #ad5f06;
  --warn-soft:    #fff5e6;
  --warn-line:    #f2d39a;
  --bad:          #c81e1e;
  --bad-soft:     #fdeded;
  --bad-line:     #f6c7c7;

  --prov-anthropic: #b45309;
  --prov-openai:    #0f766e;
  --prov-google:    #1d4ed8;
  --prov-custom:    #6d28d9;

  --toast-bg:     rgba(15, 23, 44, 0.78);
  --toast-ink:    #ffffff;

  --grad-brand:   linear-gradient(135deg, #5b7cfa 0%, #6e8bff 48%, #8f7dff 100%);
  --grad-dot:     linear-gradient(135deg, #3257ec 0%, #14b8a6 55%, #c81e1e 100%);

  --glass:        linear-gradient(180deg, rgba(255,255,255,0.56) 0%, rgba(255,255,255,0.30) 42%, rgba(255,255,255,0.24) 100%);
  --glass-2:      linear-gradient(180deg, rgba(255,255,255,0.76) 0%, rgba(255,255,255,0.52) 44%, rgba(255,255,255,0.46) 100%);
  --glass-solid:  rgba(255, 255, 255, 0.97);
  --glass-hi:     rgba(255, 255, 255, 0.92);
  --glass-edge:   rgba(255, 255, 255, 0.55);
  --glass-shadow: 0 22px 56px -18px rgba(20, 32, 70, 0.34), 0 6px 18px -10px rgba(20, 32, 70, 0.20);
  --hairline:     rgba(13, 27, 62, 0.07);
  --seg-track:    rgba(20, 32, 70, 0.05);
  --blur:         30px;

  --r-sm: 10px;
  --r-md: 15px;
  --r-lg: 24px;
  --r-xl: 32px;

  --s-1:    0 1px 2px rgba(16, 28, 62, 0.07);
  --s-2:    0 1px 2px rgba(16, 28, 62, 0.07), 0 3px 8px rgba(16, 28, 62, 0.06);
  --s-lift: 0 28px 64px -18px rgba(20, 32, 70, 0.40), 0 8px 20px -8px rgba(20, 32, 70, 0.24);

  --f-ui:   'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* ── reset / base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(1150px 820px at 6% -6%,   rgba(136, 168, 240, 0.50), transparent 58%),
    radial-gradient(1000px 780px at 100% 20%, rgba(176, 150, 232, 0.42), transparent 56%),
    radial-gradient(1150px 860px at 88% 108%, rgba(247, 178, 128, 0.46), transparent 58%),
    radial-gradient(950px 720px at 6% 102%,   rgba(146, 216, 168, 0.40), transparent 58%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding: 92px 18px 110px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 17px; letter-spacing: -0.01em; margin: 0; }
.mono  { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.dim   { color: var(--ink-4); font-weight: 400; }
.hide  { display: none !important; }
.flex1 { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ── glass material ──────────────────────────────────────────────────── */
.glass, .glass-solid {
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.6);
  backdrop-filter: blur(var(--blur)) saturate(1.6);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi);
}
.glass-solid { background: var(--glass-solid); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .glass-solid { background: var(--surface); }
}

/* ── floating chrome ─────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  width: min(1240px, calc(100% - 24px));
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-radius: 999px; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--grad-dot);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.55), 0 2px 6px rgba(20,32,70,0.30);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14.5px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-text .sub { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.14em; }

.seg {
  display: flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--seg-track); margin-inline: auto;
}
.seg a {
  padding: 6px 14px; border-radius: 999px; color: var(--ink-2);
  font-weight: 600; font-size: 12.5px; white-space: nowrap;
}
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--surface); color: var(--brand-2); box-shadow: var(--s-2); }

.keychip {
  font-family: var(--f-mono); font-size: 11px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-3); white-space: nowrap;
}
.keychip.ok { color: var(--good); border-color: var(--good-line); background: var(--good-soft); }
.keychip:hover { text-decoration: none; box-shadow: var(--s-2); }

.foot {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  padding: 8px 20px; border-radius: 999px; z-index: 40;
  font-size: 11.5px; color: var(--ink-3); white-space: nowrap;
}

/* ── layout ──────────────────────────────────────────────────────────── */
#main { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.view { display: flex; flex-direction: column; gap: 18px; }
.card { border-radius: var(--r-lg); padding: 20px 22px; }

.row-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.row-tools { display: flex; gap: 8px; align-items: center; }
.note { margin: 8px 0 14px; font-size: 12.5px; }

/* ── controls ────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 13px;
  cursor: pointer; color: var(--ink-2); box-shadow: var(--s-1);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { box-shadow: var(--s-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--grad-brand); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px -6px rgba(50, 87, 236, 0.55), inset 0 1px 0 rgba(255,255,255,0.35);
}
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn.lg { padding: 11px 26px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 11px; color: var(--ink);
  width: 100%; min-width: 0;
}
textarea { resize: vertical; font-family: var(--f-ui); line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ── composer ────────────────────────────────────────────────────────── */
.composer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.lib-row { display: flex; gap: 8px; align-items: center; }
.lib-row select { width: 220px; }
#prompt { font-size: 14.5px; }
.sys { margin-top: 10px; }
.sys summary { cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.sys textarea { margin-top: 8px; }

.contenders { margin-top: 14px; }
.contenders .lbl { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; box-shadow: var(--s-1);
  transition: transform 0.1s ease;
}
.chip:hover { transform: translateY(-1px); box-shadow: var(--s-2); }
.chip[aria-pressed="true"] {
  border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 2px 8px -2px rgba(50,87,236,0.35);
}
.prov-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: inset 0 1px 1px rgba(255,255,255,0.5), 0 0 0 1px rgba(255,255,255,0.9); }
.prov-dot.anthropic { background: var(--prov-anthropic); }
.prov-dot.openai    { background: var(--prov-openai); }
.prov-dot.google    { background: var(--prov-google); }
.prov-dot.custom    { background: var(--prov-custom); }

.run-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.param { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.param input { width: 90px; padding: 6px 9px; font-family: var(--f-mono); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.check input { width: auto; }

.msg { margin-top: 12px; padding: 10px 14px; border-radius: var(--r-md); font-size: 13px; font-weight: 600;
  background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); }

/* ── verdict bar ─────────────────────────────────────────────────────── */
.verdict { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 20px; }
.verdict .vt { font-weight: 700; font-size: 13.5px; }
.verdict input { flex: 1; min-width: 200px; }

/* ── results grid / panes ────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; align-items: start; }
.pane { border-radius: var(--r-lg); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pane.winner { border-color: rgba(50, 87, 236, 0.65); box-shadow: 0 0 0 2px var(--brand-line), var(--glass-shadow); }

.pane-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px 11px; border-bottom: 1px solid var(--hairline); }
.pane-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pane-title strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-title .mid { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crown { font-size: 14px; }

.status { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-4); }
.pane.running .sdot { background: var(--brand); animation: pulse 1.1s ease-in-out infinite; }
.pane.done    .sdot { background: var(--good); }
.pane.error   .sdot { background: var(--bad); }
.pane.stopped .sdot { background: var(--warn); }
.stext { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
@keyframes pulse { 50% { opacity: 0.35; } }

.metrics { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 16px; border-bottom: 1px solid var(--hairline); }
.mchip {
  font-family: var(--f-mono); font-size: 10.5px; padding: 3px 9px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--ink-2);
  white-space: nowrap;
}
.mchip.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

.tabs { display: flex; gap: 2px; padding: 8px 12px 0; }
.tab {
  border: none; background: transparent; padding: 6px 12px; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--ink-3);
  border-radius: 999px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--seg-track); color: var(--brand-2); }

.pane-body { padding: 12px 16px 14px; min-height: 120px; }
.out {
  max-height: 420px; overflow: auto; font-size: 13px;
  overscroll-behavior: contain;
}
.out.raw { font-family: var(--f-mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.out p { margin: 0 0 10px; }
.out h1, .out h2, .out h3 { font-size: 14.5px; margin: 14px 0 8px; }
.out ul, .out ol { margin: 0 0 10px; padding-left: 22px; }
.out li { margin: 3px 0; }
.out blockquote { margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--brand-line); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.out pre {
  background: #f6f8fd; border: 1px solid var(--border-soft); border-radius: var(--r-sm);
  padding: 10px 12px; overflow: auto; margin: 0 0 10px;
  font-family: var(--f-mono); font-size: 11.5px; line-height: 1.5;
}
.out code { font-family: var(--f-mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.out pre code { background: none; padding: 0; }
.out hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.preview-frame { width: 100%; height: 420px; border: 1px solid var(--border); border-radius: var(--r-md); background: #fff; }
.preview-empty { padding: 30px 10px; text-align: center; color: var(--ink-4); font-size: 12.5px; }

.pane-foot { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--hairline); flex-wrap: wrap; align-items: center; }
.perr { padding: 10px 16px; margin: 10px 16px; border-radius: var(--r-md); background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad); font-size: 12.5px; font-family: var(--f-mono); word-break: break-word; }

/* ── history ─────────────────────────────────────────────────────────── */
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  cursor: pointer; transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.hist-row:hover { box-shadow: var(--s-2); transform: translateY(-1px); }
.hist-main { min-width: 0; flex: 1; }
.hist-prompt { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-4); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.hist-models { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--f-mono); font-size: 10px; padding: 3px 9px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--ink-2);
  white-space: nowrap;
}
.tag.win { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-2); font-weight: 700; }
.empty { padding: 34px 10px; text-align: center; color: var(--ink-4); font-size: 13px; }

/* ── leaderboard ─────────────────────────────────────────────────────── */
.board-rows { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.brow { display: grid; grid-template-columns: 200px 1fr auto; gap: 12px; align-items: center; }
.brow .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brow .who strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track { height: 18px; background: var(--seg-track); border-radius: 4px; position: relative; overflow: hidden; }
.fill {
  position: absolute; inset: 0 auto 0 0; background: var(--brand);
  border-radius: 0 4px 4px 0; min-width: 2px;
  transition: width 0.4s ease;
}
.fill.zero { background: transparent; }
.bstat { display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) { .brow { grid-template-columns: 1fr; gap: 6px; } }

/* ── settings ────────────────────────────────────────────────────────── */
.key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 6px 0 4px; }
.key-grid label { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.key-grid input { flex: 1; font-family: var(--f-mono); font-size: 12px; }

.roster { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.roster-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--border-soft); border-radius: var(--r-sm); background: var(--surface);
}
.roster-row .mono { font-size: 11px; color: var(--ink-3); }
.roster-row strong { font-size: 12.5px; }
.roster-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.roster-add select { flex: 0 1 230px; }
.roster-add input { flex: 1 1 190px; }
.roster-add button { flex: none; }
.roster-custom { display: contents; }
.roster-row .mono.dim { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }

.price-list { display: flex; flex-direction: column; gap: 6px; }
.price-row { display: grid; grid-template-columns: minmax(160px, 1fr) 110px 110px; gap: 8px; align-items: center; }
.price-row .mono { font-size: 11px; }
.price-row input { font-family: var(--f-mono); font-size: 12px; padding: 5px 9px; }
.price-head { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-4); }

.prose { font-size: 13px; color: var(--ink-2); }
.prose ol { padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose code { font-family: var(--f-mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ── modal ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(16, 28, 62, 0.35);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 20px;
}
.modal-card {
  width: min(1100px, 100%); height: min(86vh, 900px);
  border-radius: var(--r-lg); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--s-lift);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--hairline); }
.modal-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.modal-body { flex: 1; min-height: 0; padding: 0; }
.modal-body iframe { width: 100%; height: 100%; border: none; background: #fff; }

/* ── toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 64px; left: 50%; transform: translate(-50%, 16px);
  background: var(--toast-bg); color: var(--toast-ink);
  padding: 10px 20px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 70; max-width: min(90vw, 560px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── small screens / motion ──────────────────────────────────────────── */
@media (max-width: 860px) {
  body { padding-top: 130px; }
  .topbar { flex-wrap: wrap; justify-content: center; border-radius: var(--r-lg); }
  .keychip { order: 2; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
