/* ============================================================
   tryai - two tools, one quiet form vocabulary.

   Rules this file keeps to (2026-10-08 redesign):
   - Every input has a sentence-case label above it (.block-title) and, when
     it needs one, a single line of help (.block-help). No tracked uppercase
     eyebrows, no numbered badges, no nested accent boxes.
   - Text that carries meaning is never below 13px and never below 4.5:1
     against the ground it sits on, in either theme (--text-dim, --text-faint
     and --danger are tuned for that).
   - One accent, spent on the focused field, the primary button, the selected
     control and the answer. Everything else is ink on ground.
   - Focus is always visible; targets are at least 32px.
   ============================================================ */
:root {
  --font-sans: 'Geist', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', monospace;

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --bg: #0c0c0e;
  --surface-1: #151517; /* card */
  --surface-2: #1c1c1f; /* raised */
  --inset: #111113; /* input field */
  --inset-focus: #0f0f14;

  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --hover: rgba(255, 255, 255, 0.05);

  --text: #f1f1f3; /* 17:1 on --bg */
  --text-dim: #b3b3bb; /* 9.6:1 on --bg */
  --text-faint: #8f8f99; /* 5.9:1 on --bg, 5.2:1 on --surface-2 */

  --accent: #6b97ff; /* 6.9:1 on --bg */
  --accent-hover: #86a9ff;
  --accent-ink: #06080f;
  --accent-soft: rgba(107, 151, 255, 0.16);

  --danger: #f3777b; /* 6.6:1 on --bg */
  --warn: #e0a24a;

  --score: var(--accent);

  --shadow-card: 0 10px 30px -16px rgba(0, 0, 0, 0.7), 0 40px 80px -50px rgba(0, 0, 0, 0.95);
  --shadow-pop: 0 4px 12px -4px rgba(0, 0, 0, 0.6);
}

/* ---------- Theme: Light ---------- */
/* Dark is the default (the bare :root above). Light is applied when the user
   toggles to it, or when the OS prefers light - both resolved to an explicit
   [data-theme] before first paint by the inline guard in index.html. */
[data-theme='light'] {
  --bg: #f4f5f7;
  --surface-1: #ffffff;
  --surface-2: #f9fafb;
  --inset: #ffffff;
  --inset-focus: #ffffff;

  --line: rgba(17, 24, 39, 0.14);
  --line-strong: rgba(17, 24, 39, 0.24);
  --hover: rgba(17, 24, 39, 0.05);

  --text: #141a24; /* 15:1 on white */
  --text-dim: #444c5a; /* 8.7:1 on white */
  --text-faint: #5d6472; /* 5.6:1 on white, 5.1:1 on --bg */

  --accent: #2a62de; /* 5.6:1 on white */
  --accent-hover: #2252c0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 98, 222, 0.11);

  --danger: #c0282f; /* 6.3:1 on white */
  --warn: #9a5b00;

  --shadow-card: 0 1px 2px rgba(17, 24, 39, 0.05), 0 16px 36px -20px rgba(17, 24, 39, 0.22);
  --shadow-pop: 0 4px 14px -6px rgba(17, 24, 39, 0.18);
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}
body {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
html,
body {
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

.hidden,
[hidden] {
  display: none !important;
}

/* Visually hidden but available to assistive tech. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-faint);
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

a {
  color: var(--accent);
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.brand-mark svg {
  width: 17px;
  height: 17px;
}
.brand-name {
  font-weight: 600;
  font-size: 16.5px;
  letter-spacing: -0.02em;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 16px;
  min-height: 36px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: transparent;
  transition: transform 0.12s var(--ease), background 0.18s, box-shadow 0.18s, color 0.18s, opacity 0.18s;
  white-space: nowrap;
}
.btn:active {
  transform: translateY(0.5px) scale(0.992);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn svg {
  width: 15px;
  height: 15px;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 7px 12px;
  font-size: 13.5px;
}
.btn-lg {
  padding: 12px 26px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--shadow-pop);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  background: var(--surface-2);
  color: var(--text-faint);
  box-shadow: inset 0 0 0 1px var(--line);
  opacity: 1;
}
.btn-ghost {
  color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* A button that reads as text: Clear, Add option, Clear all history. */
.text-btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.text-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--hover);
}
.text-btn:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-dim);
  background: transparent;
  border: none;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.theme-toggle:hover {
  color: var(--text);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
}
/* Show the icon for the theme a click switches *to*. */
.theme-toggle .icon-moon {
  display: none;
}
.theme-toggle .icon-sun {
  display: block;
}
[data-theme='light'] .theme-toggle .icon-sun {
  display: none;
}
[data-theme='light'] .theme-toggle .icon-moon {
  display: block;
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.link:hover {
  color: var(--accent-hover);
}

.kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 9px;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  background: var(--hover);
  line-height: 1;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent-ink) 35%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}
.btn-ghost .spinner {
  border-color: var(--line);
  border-top-color: var(--accent);
}
.spinner.big {
  width: 28px;
  height: 28px;
  border-width: 3px;
  border-color: var(--line);
  border-top-color: var(--accent);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Focus ---------- */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  border-radius: var(--r-sm);
}

/* ---------- Boot ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
}

/* ---------- Inputs ---------- */
input,
textarea {
  width: 100%;
  background: var(--inset);
  color: var(--text);
  font: inherit;
  border: none;
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  min-height: 40px;
  transition: box-shadow 0.16s, background 0.16s;
}
input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
  opacity: 1;
}
input:focus,
textarea:focus {
  outline: none;
  background: var(--inset-focus);
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft);
}
[data-theme='light'] input:focus,
[data-theme='light'] textarea:focus,
[data-theme='light'] .field-box:focus-within {
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
input.mono {
  font-family: var(--font-mono);
  font-size: 13.5px;
}

/* ---------- Auth ---------- */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 408px;
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: 30px;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
}
.auth-card .brand {
  margin-bottom: 26px;
}
.auth-card .theme-toggle {
  position: absolute;
  top: 22px;
  right: 22px;
}
.auth-head {
  margin-bottom: 22px;
}
.auth-title {
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 7px;
}
.auth-sub {
  color: var(--text-dim);
  margin: 0;
  font-size: 14.5px;
}

.field {
  display: block;
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 13.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.input-wrap {
  position: relative;
}
.input-wrap input {
  padding-right: 44px;
}
.reveal {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.reveal:hover {
  color: var(--text-dim);
  background: var(--hover);
}
.reveal svg {
  width: 17px;
  height: 17px;
}
.reveal .eye-off {
  display: none;
}
.reveal[aria-pressed='true'] .eye {
  display: none;
}
.reveal[aria-pressed='true'] .eye-off {
  display: block;
}

.form-error {
  color: var(--danger);
  font-size: 13.5px;
  margin: 2px 0 12px;
}
.console .form-error {
  margin: 0;
}
#auth-submit {
  margin-top: 6px;
}
.btn-oauth {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 11px 16px;
}
.btn-oauth:hover:not(:disabled) {
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-oauth .oauth-mark {
  width: 17px;
  height: 17px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-toggle {
  text-align: center;
  margin: 20px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* ============================================================
   App shell
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 24px;
}
.account {
  display: flex;
  align-items: center;
  gap: 10px;
}
.who {
  color: var(--text-dim);
  font-size: 13.5px;
  margin-right: 4px;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(12px, 4vh, 36px) 24px 64px;
}

/* ---------- Tool tabs: two plain links, the current one underlined ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 28px;
  border-bottom: 1px solid var(--line);
}
.tab {
  display: inline-block;
  padding: 10px 14px 12px;
  margin-bottom: -1px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover {
  color: var(--text);
}
.tab[aria-current='page'] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.tab:focus-visible {
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

/* ---------- Intro ---------- */
.intro {
  margin: 0 0 28px;
}
.intro h1 {
  font-weight: 600;
  font-size: clamp(26px, 3.6vw, 32px);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 8px;
}
.lede {
  color: var(--text-dim);
  max-width: 58ch;
  margin: 0;
  font-size: 15.5px;
  line-height: 1.55;
}

/* ============================================================
   Form blocks - the one vocabulary both tools use
   ============================================================ */
.console {
  display: grid;
  gap: 26px;
}
.block {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 12px;
  min-height: 20px;
}
.block-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.block-help {
  font-size: 13.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 0;
}
.block-head .block-help {
  flex: 1 1 auto;
}
.block-head .text-btn {
  margin-left: auto;
}
.block-help code,
.notice code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

/* A multi-line text field: the textarea and its footer (badge, clear, count)
   share one bordered box so the counter reads as part of the field. */
.field-box {
  position: relative;
  display: grid;
  background: var(--inset);
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.18s, background 0.18s;
}
.field-box:focus-within {
  background: var(--inset-focus);
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft);
}
.field-box.over {
  box-shadow: inset 0 0 0 1px var(--danger);
}
.field-box textarea {
  background: transparent;
  box-shadow: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: 13px 14px 6px;
  min-height: 150px;
  resize: vertical;
  line-height: 1.6;
  font-size: 15px;
}
.field-box textarea:focus {
  background: transparent;
  box-shadow: none;
}
.field-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 4px 14px 10px;
  min-height: 30px;
}
.field-foot .text-btn {
  margin: 0;
}
.count {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  transition: color 0.16s;
}
.count.zero {
  color: var(--text-faint);
}
.count.warn {
  color: var(--warn);
}
.count.over {
  color: var(--danger);
}
.badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
  margin-right: auto;
}

/* Segmented control: the question-type radio group. */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--inset);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg-wide {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}
.seg-item {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: calc(var(--r-md) - 3px);
  padding: 8px 14px;
  min-height: 36px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.seg-item:hover {
  color: var(--text);
}
.seg-item[aria-checked='true'] {
  color: var(--text);
  font-weight: 600;
  background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 0 0 1px var(--line-strong);
}
[data-theme='light'] .seg-item[aria-checked='true'] {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08), inset 0 0 0 1px var(--line);
}
.seg-item:focus-visible {
  position: relative;
  z-index: 1;
}

/* Example chips: pressed = loaded. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 13px;
  min-height: 34px;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.chip:hover {
  color: var(--text);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.chip[aria-pressed='true'] {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* A native select, dressed like the inputs. */
.select-wrap {
  position: relative;
}
.select-wrap select {
  width: 100%;
  min-height: 40px;
  padding: 9px 40px 9px 12px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--inset);
  border: none;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: box-shadow 0.16s;
}
.select-wrap select:hover {
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.select-wrap select:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft);
}
.select-wrap::after {
  content: '';
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 1.6px solid var(--text-dim);
  border-bottom: 1.6px solid var(--text-dim);
  transform: rotate(45deg);
  pointer-events: none;
}

/* The question: the type, an Instructions box, then Criteria and id behind
   one disclosure. Labels are Jev's own names. */
.q-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 4px;
}
.q-instr {
  font-size: 15px;
  font-weight: 500;
}
.q-id {
  display: grid;
  grid-template-columns: auto 200px;
  justify-content: start;
  align-items: center;
  gap: 10px;
}
.q-id-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
}
.q-id input {
  min-height: 34px;
  padding: 6px 10px;
}
.more {
  margin-top: 2px;
}
.more summary {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
}
.more-body {
  display: grid;
  gap: 14px;
  padding: 12px 14px 14px;
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px var(--line);
}
.crit {
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
}
.crit-legend {
  padding: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
}
.crit-rows {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.crit-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.crit-noul .crit-row {
  grid-template-columns: 36px 1fr;
}
.crit-choice .crit-row {
  grid-template-columns: minmax(96px, 150px) 1fr auto;
}
.crit-key {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.crit-row input {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 14px;
}
.crit-choice .crit-name {
  font-weight: 600;
}
.crit-del {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-faint);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.crit-del svg {
  width: 14px;
  height: 14px;
}
.crit-del:hover:not(:disabled) {
  color: var(--danger);
  background: var(--hover);
}
.crit-del:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.crit-add {
  justify-self: start;
  margin: 2px 0 0;
  padding: 6px 8px;
  color: var(--accent);
}
.crit-add:hover:not(:disabled) {
  color: var(--accent-hover);
}

/* The workbench: inputs left, the answer right and in view while you edit. */
.jev {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.jev-in {
  display: grid;
  gap: 22px;
  min-width: 0;
}
.jev-in .form-error {
  margin: -10px 0 0;
}
.jev-out {
  min-width: 0;
  padding: 20px 22px 22px;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line);
  display: grid;
  gap: 14px;
}
.jev-out .notice {
  margin: 0;
}
.answer-empty {
  display: grid;
  gap: 8px;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  min-height: 150px;
}
.answer-empty p {
  margin: 0;
  max-width: 44ch;
}
.answer-empty-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}
@media (min-width: 900px) {
  .jev {
    grid-template-columns: minmax(0, 11fr) minmax(0, 9fr);
    gap: 36px;
  }
  .jev-out {
    position: sticky;
    top: 24px;
  }
}

/* Action row */
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}
.actions-note {
  margin-left: auto;
  font-size: 13.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* Two texts side by side on the calculator */
.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* ============================================================
   Similarity result - a number, a label, and the raw cosine
   ============================================================ */
.result {
  position: relative;
  margin-top: 30px;
  max-width: 720px;
  padding: 36px 30px 32px;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}
.result.is-loading,
.result.is-empty {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}
.result-score {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-mono);
  line-height: 1;
}
.result-num {
  font-size: clamp(64px, 12vw, 84px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  color: var(--score);
}
.is-loading .result-num,
.is-empty .result-num {
  color: var(--text-faint);
  letter-spacing: 0;
}
.result-unit {
  font-size: clamp(26px, 5vw, 32px);
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 4px;
}
.is-empty .result-unit {
  opacity: 0;
}
.result-label {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 10px;
  color: var(--text);
}
.is-empty .result-label,
.is-loading .result-label {
  color: var(--text-dim);
}
.is-loading .result-label {
  animation: pulse 1.2s var(--ease) infinite;
}
.result-cosine {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 8px;
}
.result-cosine span {
  color: var(--text-dim);
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.8;
  }
}
.result-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
}
.result-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-height: 32px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.result-copy svg {
  width: 14px;
  height: 14px;
}
.result-copy:hover {
  color: var(--text);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.result-copy.copied {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
@media (max-width: 520px) {
  .result-copy-label {
    display: none;
  }
  .result-copy {
    padding: 7px;
  }
}

/* History button + count badge */
#history-btn {
  position: relative;
  overflow: visible;
}
.count-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
  z-index: 1;
}

/* ============================================================
   History drawer
   ============================================================ */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 5, 8, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.drawer-scrim.open {
  opacity: 1;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 41;
  width: min(440px, 92vw);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  box-shadow: inset 1px 0 0 var(--line);
  transform: translateX(100%);
  transition: transform 0.36s var(--ease), box-shadow 0.36s var(--ease);
  will-change: transform;
}
.drawer.open {
  transform: translateX(0);
  box-shadow: inset 1px 0 0 var(--line), -30px 0 80px -40px rgba(0, 0, 0, 0.6);
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-head .eyebrow {
  margin-bottom: 6px;
}
.drawer-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.icon-btn {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-dim);
  background: transparent;
  border: none;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.drawer-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.link.danger {
  color: var(--text-dim);
}
.link.danger:hover {
  color: var(--danger);
}
.link.danger.armed {
  color: var(--danger);
  font-weight: 600;
}

/* history entries */
.hist-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  padding: 60px 30px;
  line-height: 1.6;
}
.hist-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  transition: background 0.14s;
}
.hist-row:hover {
  background: var(--hover);
}
.hist {
  min-width: 0;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 8px 14px 24px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
}
.hist-score {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-align: right;
}
.hist-score small {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 1px;
}
.hist-texts {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hist-a,
.hist-b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  line-height: 1.45;
}
.hist-a {
  color: var(--text);
}
.hist-b {
  color: var(--text-faint);
}
.hist-time {
  justify-self: end;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
}
.hist-del {
  width: 44px;
  align-self: stretch;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.14s, color 0.14s;
}
.hist-row:hover .hist-del {
  opacity: 1;
}
.hist-del svg {
  width: 15px;
  height: 15px;
}
.hist-del:hover,
.hist-del:focus-visible {
  color: var(--danger);
  opacity: 1;
}

/* ============================================================
   Disclosures: own key, the request we sent, the explainers
   ============================================================ */
.disclosure summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  user-select: none;
}
.disclosure summary::-webkit-details-marker {
  display: none;
}
.disclosure summary::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  flex: none;
}
.disclosure[open] summary::before {
  transform: rotate(45deg);
}
.disclosure summary:hover {
  color: var(--accent);
}
.disclosure-body {
  margin-top: 12px;
}

/* Pool notice */
.notice {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border-left: 3px solid var(--accent);
  box-shadow: inset 0 0 0 1px var(--line);
}
.notice-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.notice-body {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- Explainer / FAQ (crawlable content below the tool) ---------- */
.explainer {
  margin-top: 44px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  max-width: 64ch;
  color: var(--text-dim);
}
.explainer-body {
  margin-top: 16px;
}
.explainer h2 {
  color: var(--text);
  font-weight: 600;
  font-size: 16.5px;
  letter-spacing: -0.02em;
  margin: 24px 0 8px;
}
.explainer-body > p:first-child,
.explainer h2:first-child {
  margin-top: 0;
}
.explainer p {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.6;
}
.explainer strong {
  color: var(--text);
  font-weight: 600;
}
.explainer code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}
.faq {
  margin: 0;
}
.faq dt {
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  margin-top: 16px;
}
.faq dd {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
}

.foot {
  text-align: center;
  margin-top: 28px;
  color: var(--text-faint);
  font-size: 13px;
}
.foot code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ============================================================
   Jev results
   ============================================================ */
.answer {
  display: grid;
  gap: 14px;
}
.is-loading .answer {
  opacity: 0.8;
}
.answer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.answer-id {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}
.answer-type {
  font-size: 13px;
  color: var(--text-faint);
}
.answer-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--text-dim);
}
.is-loading .answer-main {
  animation: pulse 1.2s var(--ease) infinite;
  font-size: 15px;
}
.answer-value {
  font-family: var(--font-mono);
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--score);
  font-variant-numeric: tabular-nums;
}
.answer-value small {
  font-size: 0.5em;
  color: var(--text-faint);
  letter-spacing: 0;
}
.answer-sub {
  font-size: 14px;
}
.bars {
  display: grid;
  gap: 8px;
}
.bar {
  display: grid;
  grid-template-columns: minmax(70px, 34%) 1fr 48px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.bar-label em {
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 13px;
  margin-left: 6px;
  color: var(--text-faint);
}
.bar.strong .bar-label,
.bar.strong .bar-pct {
  color: var(--text);
  font-weight: 600;
}
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: width 0.6s var(--ease);
}
.bar.strong .bar-fill {
  background: var(--accent);
}
.bar-pct {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.jev-cost {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* "The request we sent" */
.request summary {
  font-size: 14px;
}
.request-model {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-faint);
}
.code-block {
  margin-top: 12px;
  border-radius: var(--r-md);
  background: var(--inset);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
}
.code-block pre {
  margin: 0;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

/* A Noul answer: the probability on a 0 to 1 scale between no and yes. */
.noul-scale {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}
.noul-end em {
  font-style: normal;
  font-family: var(--font-sans);
  color: var(--text-faint);
}
.noul-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--hover), color-mix(in srgb, var(--accent) 35%, transparent));
  box-shadow: inset 0 0 0 1px var(--line);
}
.noul-mid {
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--line-strong);
}
.noul-dot {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface-1), 0 0 0 4px var(--accent);
  transition: left 0.6s var(--ease);
}
/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 680px) {
  .panes {
    grid-template-columns: 1fr;
  }
  .actions {
    flex-wrap: wrap;
  }
  .actions .btn-lg {
    width: 100%;
  }
  .kbd {
    display: none;
  }
  .actions-note {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }
  .q-id {
    grid-template-columns: auto 1fr;
  }
  /* Name and remove on the first line, the description full width below. */
  .crit-choice .crit-row {
    grid-template-columns: 1fr auto;
  }
  .crit-choice .crit-del {
    grid-column: 2;
    grid-row: 1;
  }
  .crit-choice .crit-row input:not(.crit-name) {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .bar {
    grid-template-columns: minmax(60px, 40%) 1fr 44px;
  }
}

@media (max-width: 560px) {
  .seg-item {
    padding: 8px 6px;
  }
}

@media (max-width: 520px) {
  .who {
    display: none;
  }
  #history-btn span:not(.count-badge) {
    display: none;
  }
  .topbar {
    padding: 16px 18px;
  }
  .topbar .brand-name {
    display: none;
  }
  .stage {
    padding: 12px 16px 56px;
  }
  .tabs {
    margin-bottom: 22px;
  }
  .tab {
    padding: 10px 10px 12px;
  }
  .field-box textarea {
    min-height: 124px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
