:root {
  /* light theme (default) */
  --bg: #F7F8FC; /* ultra-light glassmorphism backdrop */
  --ink: #0b0b0f;
  --muted: #6b7280;
  --accent: #2f8bff;          /* light blue — same in both themes */
  --accent-2: #5aa6ff;
  --line: rgba(47, 139, 255, .30);
  --glass: rgba(255, 255, 255, .74);
  --card: #ffffff;
  --code-bg: #f4f6fa;
  --scrim: rgba(15, 18, 28, .34);
  --shadow: rgba(20, 30, 60, .06);
  --shadow-hover: rgba(47, 139, 255, .18);
  --ok: #0a8f5b;
  --warn: #b26a00;
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #9a94b4;
  --line: rgba(63, 155, 255, .32);
  --glass: rgba(18, 18, 24, .72);
  --card: #14131c;
  --code-bg: rgba(8, 8, 14, .8);
  --scrim: rgba(4, 4, 8, .62);
  --shadow: rgba(0, 0, 0, .3);
  --shadow-hover: rgba(47, 139, 255, .3);
  --ok: #9ff7c4;
  --warn: #ffcf8f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;
}

#graph { position: fixed; inset: 0; z-index: 0; transition: opacity .3s ease; }

/* fade-out/fade-in between clusters */
body.fading #graph,
body.fading #question,
body.fading #selection { opacity: 0; }

/* status pill — top left · theme toggle — top right */
#status {
  position: fixed; top: 18px; left: 18px; z-index: 5;
  font-size: 11px; letter-spacing: .04em; color: var(--muted);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 100px;
  background: var(--glass); backdrop-filter: blur(8px);
}
#status.ok { color: var(--ok); }
#status.warn { color: var(--warn); }

#themeToggle {
  position: fixed; top: 16px; right: 18px; z-index: 5; cursor: pointer;
  width: 34px; height: 34px; border-radius: 100px; font-size: 15px; line-height: 1;
  color: var(--ink); background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(8px); font-family: inherit;
  transition: border-color .12s, transform .12s;
}
#themeToggle:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ── question — top center ─────────────────────────────────────────────── */
#question {
  position: fixed; top: 34px; left: 50%; transform: translateX(-50%);
  z-index: 4; width: min(980px, 94vw); text-align: center;
  pointer-events: none; transition: opacity .3s ease;
}
#question.swap { animation: drop .45s cubic-bezier(.2,.9,.3,1); }
@keyframes drop {
  from { opacity: 0; transform: translateX(-50%) translateY(-14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.eyebrow {
  /* progress line at twice the size */
  font-size: 22px; letter-spacing: .22em; color: var(--accent);
  font-weight: 500; margin-bottom: 12px;
}
.pdot { opacity: .22; margin-right: 10px; }
.pdot.on { opacity: 1; }
#q-title {
  font-size: clamp(28px, 3.6vw, 44px); line-height: 1.08; margin: 0 0 12px;
  font-weight: 300; letter-spacing: 0.005em; color: var(--ink);
}
#q-sub {
  /* twice the previous size — subtitles carry the instruction, let them speak */
  color: var(--muted); font-size: clamp(20px, 2.2vw, 28px); line-height: 1.4;
  margin: 0; font-weight: 300;
  white-space: pre-line; /* the pick-hint sits on its own second row */
}

/* ── selection — bottom center ─────────────────────────────────────────── */
#selection {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 4; width: min(880px, 94vw);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  pointer-events: none; transition: opacity .3s ease;
}
#selection > * { pointer-events: auto; }

#extra { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
#extra:empty { display: none; }
.refine {
  flex: 1; min-width: 240px; max-width: 380px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 100px;
  color: var(--ink); padding: 9px 16px; font-size: 13px; font-family: inherit;
  backdrop-filter: blur(8px); text-align: center;
}
.refine:focus { outline: none; border-color: var(--accent); }
.refine::placeholder { color: var(--muted); }

#chips {
  display: flex; flex-wrap: wrap; gap: 7px; justify-content: center;
  /* tall enough for six full-sentence suggestions (crystallize) w/o scrolling */
  max-height: 252px; overflow-y: auto; padding: 2px;
  scrollbar-width: thin; scrollbar-color: var(--accent) transparent;
}
#chips:empty { display: none; }

.chip {
  --h: 210;
  font-family: inherit; cursor: pointer; color: var(--ink);
  background: var(--glass); border: 1px solid hsla(var(--h), 70%, 55%, .5);
  border-radius: 100px; padding: 6px 14px; font-size: 13px; font-weight: 500;
  backdrop-filter: blur(8px); display: inline-flex; align-items: center; gap: 7px;
  box-shadow: 0 1px 6px var(--shadow);
  transition: border-color .12s, transform .1s, box-shadow .12s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 14px var(--shadow-hover); }
.chip.ghosted { cursor: default; }
.chip.ghosted:hover { transform: none; box-shadow: 0 1px 6px var(--shadow); }
.chip.result { border-color: var(--line); padding: 0; overflow: hidden; }
.chip.result:hover { border-color: var(--accent); }
.chip-name {
  font-family: inherit; cursor: pointer; border: none; background: none; color: var(--ink);
  padding: 6px 4px 6px 14px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip-x {
  font-family: inherit; cursor: pointer; border: none; background: none; color: var(--muted);
  padding: 6px 10px 6px 6px; font-size: 12px;
}
.chip-x:hover { color: #ef4444; }
.chip.active { border-color: var(--accent); background: rgba(47,139,255,.12); color: var(--accent); }

/* rejection-reason picker */
.reason-row { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 6px 0 4px; align-items: center; }

/* AI scoring results */
.ai-summary {
  width: min(720px, 92vw); margin: 0 auto; padding: 14px 18px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(10px); box-shadow: 0 4px 20px var(--shadow);
  text-align: center;
}
.ai-summary-h { font-size: 11px; letter-spacing: .22em; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.ai-summary-list { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-bottom: 8px; }
.ai-summary-p { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 0; }
.chip.result-score { border-color: var(--accent); }
.detail-score { font-size: 14px; color: var(--accent); margin: 2px 0 8px; }
.detail-list { font-size: 13px; line-height: 1.55; color: var(--ink); margin: 8px 0; }
.detail-list.ok { color: #0a8f5b; }
.detail-list.warn { color: #b26a00; }

/* candidate detail panel — right side on desktop, bottom sheet on narrow */
.cand-panel {
  position: fixed; z-index: 9; top: 90px; right: 22px; bottom: 120px;
  width: min(360px, 90vw); overflow-y: auto;
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(14px); box-shadow: 0 12px 44px var(--shadow-hover);
  padding: 22px; text-align: left;
  scrollbar-width: thin; scrollbar-color: var(--accent) transparent;
}
.cand-close { position: absolute; top: 10px; right: 12px; font-size: 14px; }
.cand-crit { margin: 10px 0; border-top: 1px solid var(--line); }
.cand-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 0; border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.cand-row b { color: var(--ink); }
.cand-act { width: 100%; margin-top: 14px; }
.finalist-chip { border-color: var(--accent); cursor: grab; }
.finalist-chip:active { cursor: grabbing; }
@media (max-width: 900px) {
  .cand-panel {
    top: auto; right: 0; left: 0; bottom: 0; width: 100%;
    max-height: 55vh; border-radius: 18px 18px 0 0;
  }
}

/* workbench control bar */
.ctrl-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; width: 100%; }
.ctrl-row .chip { padding: 4px 11px; font-size: 12px; }
.ctrl-row .chip:disabled { opacity: .45; cursor: wait; transform: none; }
.ctrl-label {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; margin-right: 4px;
}
.ctrl-sep { color: var(--muted); font-size: 12px; padding: 0 3px; }
.ctrl-status { font-size: 11.5px; color: var(--muted); text-align: center; width: 100%; }
.ctrl-status b { color: var(--ink); font-weight: 500; }

/* pairwise comparison */
.duel { width: min(560px, 92vw); }
.duel-row { display: flex; gap: 12px; margin: 16px 0; }
.duel-card {
  flex: 1; font-family: inherit; cursor: pointer; text-align: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 14px; color: var(--ink);
  transition: border-color .12s, transform .1s;
}
.duel-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.duel-name { font-size: 22px; font-weight: 400; margin-bottom: 8px; }
.duel-rat { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* screening table (export) */
.screen-table { width: 100%; overflow-x: auto; }
.screen-table table {
  margin: 0 auto; border-collapse: collapse; font-size: 12.5px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(8px);
}
.screen-table th, .screen-table td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.screen-table th { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.screen-table tr:last-child td { border-bottom: none; }
.screen-table .note { color: var(--muted); font-size: 11.5px; max-width: 320px; }

/* print → PDF */
@media print {
  #graph, #status, #themeToggle, #controls, .enter, .ctl-back, .ctl-prompt { display: none !important; }
  #question, #selection { position: static; transform: none; width: auto; color: #000; }
  body { background: #fff; color: #000; overflow: visible; }
  .screen-table table { background: #fff; }
}
.chip.shuffle { color: var(--accent); border-color: var(--accent); }
.chip.shuffle:hover { background: rgba(47,139,255,.10); }
.chip.reset { color: var(--muted); }
.chip.restart { color: var(--muted); border-style: dashed; }

#controls { display: flex; align-items: center; gap: 12px; }
.enter {
  font-family: inherit; cursor: pointer; border: none;
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  color: #ffffff; font-weight: 600; font-size: 14px; padding: 10px 22px;
  border-radius: 100px; box-shadow: 0 8px 26px rgba(47, 139, 255, .35);
  transition: transform .12s, box-shadow .12s;
}
.enter:hover { transform: translateY(-1px); box-shadow: 0 10px 34px rgba(47, 139, 255, .5); }

.ctl-back, .ctl-prompt {
  font-family: inherit; cursor: pointer; color: var(--muted);
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 100px; padding: 9px 14px; font-size: 13px; font-weight: 500;
  backdrop-filter: blur(8px); transition: border-color .12s, color .12s;
}
.ctl-back:hover, .ctl-prompt:hover { border-color: var(--accent); color: var(--accent); }

#hint { font-size: 12px; color: var(--muted); }
#hint.pulse { animation: pulse-hint .5s ease; color: var(--warn); }
@keyframes pulse-hint { 0%,100% { transform: scale(1); } 40% { transform: scale(1.12); } }

.rdot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.r-low { background: #10b981; }
.r-medium, .r-med { background: #f59e0b; }
.r-high { background: #ef4444; }

/* overlay (detail + prompt) */
.overlay {
  position: fixed; inset: 0; z-index: 10; background: var(--scrim);
  backdrop-filter: blur(5px); display: grid; place-items: center;
}
.detail {
  width: min(430px, 88vw); background: var(--card); border: 1px solid var(--accent);
  border-radius: 18px; padding: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .28);
  text-align: center;
}
.detail-terr { font-size: 11px; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; }
.detail-name { font-size: 34px; font-weight: 300; margin: 8px 0 12px; letter-spacing: .01em; color: var(--ink); }
.detail p { color: var(--muted); line-height: 1.55; font-size: 14px; margin: 0 0 12px; }
.detail-avail { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 18px; }

.prompt-box { width: min(620px, 92vw); text-align: left; }
.prompt-text {
  width: 100%; min-height: 300px; margin: 12px 0 14px; resize: vertical;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); padding: 14px; font-size: 12.5px; line-height: 1.55;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.prompt-text:focus { outline: none; border-color: var(--accent); }
.prompt-row { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

@media (max-width: 640px) {
  #q-title { font-size: 24px; }
  #chips { max-height: 84px; }
}

/* ── FRAME stage ─────────────────────────────────────────────────────────── */

/* Primary / supporting chip badges — a bright tint of the stage colour so the
   label stays readable on the light theme */
.frame-chip-primary {
  font-weight: 600;
  background: hsl(var(--h, 210) 85% 88%);
  border-color: hsl(var(--h, 210) 70% 55%);
  color: var(--ink);
}
:root[data-theme='dark'] .frame-chip-primary {
  background: hsl(var(--h, 210) 70% 18%);
  border-color: hsl(var(--h, 210) 60% 40%);
}
.frame-chip-supporting { opacity: .82; }

/* Extra input fields (offering description, completion, architecture) —
   every field takes its own centered row, all fields the same width */
.frame-extra {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px;
  flex-basis: 100%; align-items: center;
}
.frame-extra .refine { width: min(480px, 100%); max-width: 480px; flex: none; }
.frame-extra-label { font-size: 11px; letter-spacing: .08em; color: var(--muted); text-align: center; }
/* the custom-answer field matches the extras exactly — equal size, own row */
#extra > .refine { flex: 0 1 480px; min-width: 240px; max-width: 480px; }
.frame-select {
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-size: 14px; padding: 8px 12px; cursor: pointer;
}
.frame-select:focus { outline: none; border-color: var(--accent); }

/* Summary / approval screen */
.frame-summary-wrap {
  display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 280px); overflow-y: auto; padding-right: 4px;
}
.frame-summary-loading {
  font-size: 12px; color: var(--muted); text-align: center;
  padding: 6px; letter-spacing: .06em;
}
.frame-block {
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.frame-block-title {
  font-size: 10px; letter-spacing: .14em; color: var(--accent); text-transform: uppercase;
}
.frame-block-title.frame-block-ai::after {
  content: ' · AI'; font-size: 9px; opacity: .6;
}
.frame-block-content {
  font-size: 14px; color: var(--ink); line-height: 1.55;
  border-radius: 8px; padding: 4px 2px; min-height: 1.55em;
  outline: none; cursor: text;
}
.frame-block-content:focus { background: var(--code-bg); padding: 6px 8px; }
.frame-block-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.frame-block-actions .chip { font-size: 11px; padding: 4px 10px; }

/* Validation warnings in chips bar */
.frame-validation-warn { color: var(--warn); border-color: var(--warn); opacity: 1; }

/* ── DISTILL stage ───────────────────────────────────────────────────────────
   Reuses .frame-summary-wrap, .frame-block, .frame-block-title, .frame-block-content,
   .frame-block-actions, and .frame-summary-loading from the FRAME block above.
   Only distill-specific overrides are needed. */

/* Distill chip — single selection, no P/S badge needed */
.distill-chip {
  font-weight: 600;
  background: hsl(var(--h, 175) 80% 88%);
  border-color: hsl(var(--h, 175) 60% 50%);
  color: var(--ink);
}
:root[data-theme='dark'] .distill-chip { background: hsl(var(--h, 175) 60% 18%); }

/* ── CONNECT stage ───────────────────────────────────────────────────────────
   Layout: two-column (main + sidebar). Pattern cards have a per-hue left border. */

.connect-layout {
  display: grid; grid-template-columns: 1fr 240px; gap: 20px;
  width: 100%; align-items: start;
  max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px;
}
@media (max-width: 700px) {
  .connect-layout { grid-template-columns: 1fr; }
}

/* Main column */
.connect-main { display: flex; flex-direction: column; gap: 16px; }
.connect-patterns-grid {
  display: flex; flex-direction: column; gap: 12px;
}

/* Pattern card */
.connect-pattern-card {
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  border-left: 3px solid hsl(var(--ph, 150) 55% 40%);
}
:root[data-theme='dark'] .connect-pattern-card { border-left-color: hsl(var(--ph, 150) 55% 55%); }

.connect-pattern-header {
  display: flex; align-items: center; gap: 8px;
}
.connect-pattern-label {
  flex: 1; font-size: 13px; font-weight: 600; color: var(--ink);
  outline: none; cursor: text; border-radius: 4px; padding: 2px 4px;
}
.connect-pattern-label:focus { background: var(--code-bg); }

.connect-center-btn { font-size: 13px; padding: 3px 8px; }
.connect-center-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.connect-del-btn { opacity: .5; }
.connect-del-btn:hover { opacity: 1; color: var(--warn); border-color: var(--warn); }

.connect-pattern-interp {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  outline: none; cursor: text; padding: 2px 0; min-height: 1.5em;
}
.connect-interp-empty { font-style: italic; }
.connect-pattern-interp:focus { background: var(--code-bg); border-radius: 6px; padding: 4px 6px; }

.connect-pattern-members { display: flex; flex-wrap: wrap; gap: 6px; }

/* Fragment chip — a bright tint of the parent pattern hue */
.connect-frag-chip {
  background: hsl(var(--h, 150) 75% 88%); border-color: hsl(var(--h, 150) 55% 50%);
  color: var(--ink); font-size: 12px; font-weight: 500;
  cursor: pointer;
}
:root[data-theme='dark'] .connect-frag-chip {
  background: hsl(var(--h, 150) 35% 18%); border-color: hsl(var(--h, 150) 40% 30%);
  color: hsl(var(--h, 150) 80% 75%);
}
.connect-frag-chip.ghosted {
  opacity: .55; background: transparent; border-style: dashed; color: var(--muted);
}

.connect-add-pattern { margin-top: 4px; }

/* Unassigned / bridge sections */
.connect-unassigned { display: flex; flex-direction: column; gap: 8px; }
.connect-section-title {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}

/* Sidebar */
.connect-sidebar { display: flex; flex-direction: column; gap: 16px; }
.connect-reference-section {
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.connect-anchor-item { font-size: 12px; color: var(--ink); line-height: 1.45; opacity: .85; }
.connect-guardrails { border-color: hsl(0 50% 35%); }
.connect-guardrail-item {
  font-size: 12px; color: hsl(0 70% 65%); line-height: 1.45;
}
:root[data-theme='dark'] .connect-guardrail-item { color: hsl(0 70% 60%); }

/* Bridge page */
.connect-bridge-wrap {
  display: flex; flex-direction: column; gap: 16px;
  width: 100%; max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px;
}
.connect-bridge-patterns {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.connect-bridge-pat-card {
  flex: 1; min-width: 140px; background: var(--glass); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; border-left: 3px solid hsl(var(--ph, 150) 55% 40%);
}
:root[data-theme='dark'] .connect-bridge-pat-card { border-left-color: hsl(var(--ph, 150) 55% 55%); }
.connect-bridge-pat-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.connect-bridge-pat-members { font-size: 11px; color: var(--muted); margin-top: 4px; }
.connect-bridge-arrow { font-size: 20px; color: var(--muted); flex-shrink: 0; }

.connect-proposals { display: flex; flex-direction: column; gap: 8px; }
.connect-proposal {
  text-align: left; white-space: normal; height: auto;
  font-size: 13px; padding: 10px 14px; line-height: 1.5; max-width: 560px;
}
.connect-proposal.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.connect-selected-bridge {
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 8px;
}
.connect-bridge-statement { font-size: 14px; color: var(--ink); outline: none; cursor: text; }
.connect-bridge-mechanism { font-size: 12px; color: var(--muted); outline: none; cursor: text; }

/* Summary page extras */
.connect-summary-members {
  font-size: 12px; color: var(--muted); line-height: 1.5;
}
.connect-guardrails-block { border-left: 3px solid hsl(0 50% 40%); }

/* ── CRYSTALLIZE stage ───────────────────────────────────────────────────────
   9-page flow: blind → reveal → evaluations → final → field → summary       */

/* Blind propositions */
.crys-proposal-list {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px;
}
.crys-proposal-card {
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s;
}
.crys-proposal-card.crys-primary  { border-color: hsl(265 60% 50%); }
.crys-proposal-card.crys-retained { border-color: hsl(30 60% 45%); }
.crys-prop-label {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--muted);
  text-transform: uppercase;
}
.crys-prop-statement { font-size: 14px; color: var(--ink); line-height: 1.6; }
.crys-prop-actions   { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* Territory reveal grid */
.crys-territory-grid {
  display: flex; flex-direction: column; gap: 14px;
  width: 100%; max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px;
}
.crys-territory-card {
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  border-left: 3px solid hsl(var(--ph, 270) 55% 45%);
}
:root[data-theme='dark'] .crys-territory-card { border-left-color: hsl(var(--ph, 270) 55% 60%); }
.crys-terr-title      { font-size: 15px; font-weight: 700; color: var(--ink); }
.crys-terr-proposition { font-size: 13px; color: var(--muted); line-height: 1.5; font-style: italic; }
.crys-terr-body       { display: flex; flex-direction: column; gap: 4px; }
.crys-terr-section    { font-size: 12px; color: var(--ink); line-height: 1.5; }
.crys-terr-vocab      { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.crys-vocab-chip      { font-size: 11px; }
.crys-terr-risk       { font-size: 11px; color: var(--warn); opacity: .8; }

/* Evaluation + final selection */
.crys-eval-list {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px;
}
.crys-eval-ref        { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.crys-eval-card {
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  border-left: 3px solid hsl(var(--ph, 270) 45% 40%);
  transition: border-color .15s;
}
:root[data-theme='dark'] .crys-eval-card { border-left-color: hsl(var(--ph, 270) 45% 55%); }
.crys-eval-card.crys-eval-selected { border-color: hsl(var(--ph, 270) 65% 55%); }
.crys-eval-card.crys-eval-primary  { border-color: hsl(270 70% 45%); background: hsl(270 70% 88%); }
:root[data-theme='dark'] .crys-eval-card.crys-eval-primary { background: hsl(270 30% 18%); border-color: hsl(270 40% 40%); }
.crys-eval-card.crys-eval-secondary{ border-color: hsl(45 65% 45%); }
.crys-eval-mechanism  { font-size: 12px; color: var(--muted); }
.crys-eval-reason {
  font-size: 12px; color: var(--ink); line-height: 1.5; outline: none;
  border-top: 1px solid var(--line); padding-top: 6px; cursor: text; min-height: 1.5em;
}
.crys-eval-reason.crys-interp-empty { color: var(--muted); font-style: italic; }
.crys-final-header    { display: flex; align-items: center; gap: 8px; }

/* Vocabulary field */
.crys-vocab-terms     { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.crys-vocab-term      { font-size: 12px; background: hsl(270 70% 90%); border-color: hsl(270 45% 60%); color: var(--ink); }
:root[data-theme='dark'] .crys-vocab-term { background: hsl(270 30% 15%); border-color: hsl(270 40% 30%); color: hsl(270 80% 80%); }
.crys-danger-term     { color: var(--warn); border-color: var(--warn); opacity: .8; }

/* Risks */
.crys-risk-item       { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; border-top: 1px solid var(--line); }
.crys-risk-item:first-of-type { border-top: none; }
.crys-risk-statement  { font-size: 12px; color: var(--warn); }
.crys-risk-mitigation { font-size: 12px; color: var(--muted); }

/* Summary page vocabulary families */
.crys-summary-fam   { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; border-top: 1px solid var(--line); }
.crys-summary-fam:first-of-type { border-top: none; }
.crys-fam-label     { font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; }
.crys-fam-terms     { font-size: 12px; color: var(--muted); }

/* ── SHORTLIST — build-your-shortlist loop ──────────────────────────────── */

/* Held/pinned favorite state — clearly retained in the shortlist */
.chip.held {
  border-color: var(--accent);
  background: rgba(47, 139, 255, .12);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(47, 139, 255, .16);
  position: relative;
}
.chip.held:hover {
  box-shadow: 0 0 18px rgba(47, 139, 255, .24);
  border-color: var(--accent-2);
}
.chip.held::before {
  content: '📌';
  margin-right: 3px;
  font-size: 11px;
}
:root[data-theme='dark'] .chip.held {
  background: rgba(95, 171, 255, .15);
  box-shadow: 0 0 12px rgba(95, 171, 255, .2);
}
:root[data-theme='dark'] .chip.held:hover {
  box-shadow: 0 0 18px rgba(95, 171, 255, .28);
}

/* Avoided/excluded state — muted and struck-through */
.chip.avoided {
  opacity: .54;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 400;
}
.chip.avoided:hover {
  opacity: .7;
  transform: none;
  box-shadow: 0 1px 6px var(--shadow);
}

/* Shortlist progress meter — "held N / target" indicator */
.shortlist-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 100px;
  backdrop-filter: blur(8px);
  font-size: 12px;
  color: var(--ink);
}
.shortlist-progress__bar {
  flex: 1;
  min-width: 80px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.shortlist-progress__bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: var(--progress, 0%);
  transition: width .3s ease;
  box-shadow: 0 0 8px rgba(47, 139, 255, .4);
}
.shortlist-progress__count {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: .06em;
}

/* Action button for avoiding words — secondary action in chips */
.btn-avoid,
.chip.avoid-action {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--muted);
  padding: 6px 8px 6px 4px;
  font-size: 12px;
  transition: color .12s;
}
.btn-avoid:hover,
.chip.avoid-action:hover {
  color: var(--warn);
}
.btn-avoid:active,
.chip.avoid-action:active {
  transform: scale(.95);
}


