/* ============================================================================
   GABBY · 2 · CONSOLE
   A darkened operations console: phosphor signal lamps, corner-ticked panels,
   monospaced telemetry, and controls that explain themselves. Built for long shifts.
   ========================================================================== */

:root {
  --void: #05070a;
  --deck: #0a0e14;
  --panel: #0e141c;
  --panel-lift: #131b25;
  --hair: #1d2733;
  --hair-bright: #2b3947;

  --text: #d6e1eb;
  /* Secondary copy must stay legible on --panel: both clear 4.5:1 there. */
  --text-dim: #a7b8c8;
  --text-faint: #8496a7;

  --phosphor: #3ee6a0;
  --amber: #ffb84d;
  --alarm: #ff5a52;
  --ice: #58c7f3;
  --violet: #a78bfa;

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --glow: 0 0 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--mono);
  font-size: 14.3px;
  line-height: 1.55;
  color: var(--text);
  background: var(--void);
  /* Faint engineering grid + a phosphor bloom in the upper left. */
  background-image:
    radial-gradient(80% 60% at 8% -5%, rgba(62, 230, 160, 0.07), transparent 55%),
    linear-gradient(var(--hair) 1px, transparent 1px),
    linear-gradient(90deg, var(--hair) 1px, transparent 1px);
  background-size: auto, 46px 46px, 46px 46px;
  background-position: 0 0, -1px -1px, -1px -1px;
  -webkit-font-smoothing: antialiased;
}

/* Scanline veil. Purely decorative, sits under all pointer events. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 3px);
}

body.booting .console-main { opacity: 0; }

/* The staged Core browser keeps the established console language while its
   Ask and Activity responsibilities remain isolated from the legacy app. */
.core-workbench .console-bar { justify-content: space-between; }
.core-workbench .console-main { width: min(1180px, 100%); padding: 34px clamp(18px, 4vw, 54px) 64px; }
.core-workbench .rail-item { text-decoration: none; }
.core-workbench .rail-item.is-unavailable { opacity: 0.48; cursor: not-allowed; }
.core-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--hair-bright); }
.core-heading h2 { margin: 0 0 14px; font-size: clamp(23px, 4vw, 38px); color: #fff; letter-spacing: -0.035em; }
.core-heading > p { max-width: 570px; color: var(--text-dim); }
.eyebrow { margin: 0 0 5px; color: var(--phosphor); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; }
.core-workbench .query-form { max-width: 860px; }
.core-workbench textarea { font-size: 17px; line-height: 1.55; }
.core-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.core-answer { margin-top: 30px; max-width: 980px; }
.core-answer .result-output { min-height: 118px; }
.status-label { color: var(--ice); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.check-row { display: flex; align-items: start; gap: 9px; }
.check-row input { margin-top: 4px; }
.core-activity-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 1fr); gap: 18px; margin-top: 18px; align-items: start; }
.core-workbench .history-list button.activity-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) max-content; width: 100%; gap: 8px; align-items: center; text-align: left; color: var(--text); background: var(--panel); border: 1px solid var(--hair); padding: 11px 12px; }
.activity-row:hover, .activity-row:focus-visible { border-color: var(--phosphor); background: var(--panel-lift); }
.activity-row strong { color: var(--phosphor); text-transform: uppercase; font-size: 11px; }
.core-workbench .history-list .activity-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.core-workbench .history-list .activity-row time { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.core-workbench #activityDetail { position: sticky; top: 78px; max-height: calc(100vh - 104px); overflow: auto; }
.core-workbench #activityDetail h3 { overflow-wrap: anywhere; }
.activity-children { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--hair-bright); }
.activity-children h4 { margin: 0; color: #fff; font-size: 13px; }
.activity-children .history-list { margin-top: 10px; }
.activity-children > button { margin-top: 10px; }
.review-grid { display: grid; grid-template-columns: minmax(250px, 0.78fr) minmax(0, 1.55fr); gap: 18px; align-items: start; margin-top: 18px; }
.review-queue h3 { margin: 0 0 9px; color: var(--text-dim); font-size: 11px; font-weight: 500; letter-spacing: 0.13em; text-transform: uppercase; }
.core-workbench .review-row { display: grid; gap: 3px; align-items: start; width: 100%; padding: 12px; text-align: start; color: var(--text); background: var(--panel); border: 1px solid var(--hair); border-bottom: 0; }
.core-workbench .review-row:last-child { border-bottom: 1px solid var(--hair); }
.core-workbench .review-row:hover, .core-workbench .review-row:focus-visible, .core-workbench .review-row.is-open { background: var(--panel-lift); border-color: var(--phosphor); box-shadow: inset 2px 0 0 var(--phosphor); }
.review-row strong { color: #fff; font-size: 13px; font-weight: 600; }
.review-row small { color: var(--text-faint); font-size: 10px; }
.review-row .review-kind { color: var(--phosphor); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.core-workbench #reviewDetail { position: sticky; top: 78px; max-height: calc(100vh - 104px); overflow: auto; }
.review-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--hair-bright); padding-bottom: 9px; }
.review-header h3 { margin: 0; color: #fff; font-size: 20px; overflow-wrap: anywhere; }
.review-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 14px 0; }
.review-meta dt { color: var(--text-faint); }
.review-meta dd { margin: 0; overflow-wrap: anywhere; }
.review-brief { padding: 12px 14px; margin: 14px 0; background: var(--panel-lift); border-left: 2px solid var(--phosphor); line-height: 1.65; }
.review-effect { margin: 11px 0; padding: 10px 12px; border-left: 2px solid var(--amber); background: var(--panel-lift); color: var(--text-dim); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.review-status { color: var(--text-dim); font-size: 12px; }
.review-checks { display: grid; gap: 5px; margin: 10px 0; padding-left: 20px; color: var(--text-dim); }
.review-checks [data-outcome="passed"] { color: var(--phosphor); }
.review-checks [data-outcome="failed"], .review-checks [data-outcome="unavailable"] { color: var(--amber); }
.review-checks [data-optional="true"] { color: var(--text-dim); }
.review-editor { display: grid; gap: 12px; margin-top: 14px; padding: 14px; border: 1px dashed var(--hair-bright); background: var(--deck); }
.review-editor .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.review-editor label { display: grid; gap: 4px; color: var(--text-dim); font-size: 12px; }
.review-editor input, .review-editor textarea, .review-editor select { width: 100%; }
.review-editor textarea { min-height: 72px; font-size: 13px; }
.review-editor .review-structured { min-height: 180px; font-size: 11px; }
.review-guide { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--hair-bright); background: var(--panel); }
.review-guide h5 { margin: 0; color: var(--phosphor); font-size: 12px; font-weight: 600; }
.review-guide .empty { margin: 0; font-size: 11px; }
.review-guide > button { justify-self: start; }
.review-queue > button { margin-top: 12px; }
.source-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-top: 18px; }
.source-search-coverage { margin: 9px 0 0; color: var(--text-dim); font-size: 11px; }
.core-workbench #sourcesMore { margin-top: 15px; }
.source-card { min-width: 0; padding: 19px; border: 1px solid var(--hair-bright); border-left: 2px solid var(--ice); background: var(--panel); }
.source-card-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.source-card-header h3 { margin: 0; color: #fff; font-size: 19px; overflow-wrap: anywhere; }
.source-card .status-label[data-state="current"] { color: var(--phosphor); }
.source-card .status-label[data-state="refresh_required"] { color: var(--amber); }
.source-identity { margin: 5px 0 15px; color: var(--text-faint); font-size: 11px; overflow-wrap: anywhere; }
.source-facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 9px 12px; margin: 0; padding-top: 13px; border-top: 1px solid var(--hair-bright); font-size: 12px; }
.source-facts dt { color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; font-size: 10px; }
.source-facts dd { margin: 0; overflow-wrap: anywhere; }
.source-freshness-note { margin: 14px 0 0; padding: 9px 11px; background: var(--panel-lift); color: var(--text-dim); font-size: 11px; }
.source-card .core-actions { align-items: center; }
.source-job-status { width: 100%; margin: 0; color: var(--text-dim); font-size: 11px; }
.source-job-status[data-status="succeeded"] { color: var(--phosphor); }
.source-job-status[data-status="failed"], .source-job-status[data-status="cancelled"], .source-job-status[data-status="request_failed"] { color: var(--amber); }
.operations-grid { display: grid; grid-template-columns: minmax(310px, 0.9fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.operations-grid .detail-panel { min-width: 0; }
.sessions-panel { margin-top: 18px; }
.jobs-panel { margin-bottom: 18px; }
.job-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.job-card { min-width: 0; padding: 15px; border: 1px solid var(--hair-bright); border-left: 2px solid var(--ice); background: var(--panel-lift); }
.job-card h4 { margin: 0; color: #fff; font-size: 15px; overflow-wrap: anywhere; }
.job-card .source-facts { grid-template-columns: 86px minmax(0, 1fr); margin-top: 10px; }
.job-card .core-actions { margin-top: 10px; }
.job-card .status-label[data-state="succeeded"] { color: var(--phosphor); }
.job-card .status-label[data-state="failed"], .job-card .status-label[data-state="cancelled"] { color: var(--amber); }
#jobsMore { margin-top: 14px; }
.sessions-panel .inline-controls { margin-top: 16px; align-items: end; }
.sessions-panel #sessionsMore { margin-top: 14px; }
.key-form { display: grid; gap: 15px; }
.key-form label { display: grid; gap: 5px; color: var(--text-dim); font-size: 12px; }
.key-form input, .key-form select { width: 100%; }
.key-form fieldset { min-width: 0; border: 1px solid var(--hair-bright); padding: 11px; }
.key-form fieldset p { margin: 2px 0 12px; color: var(--text-faint); font-size: 11px; }
.key-scopes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 12px; max-height: 250px; overflow: auto; }
.key-scopes label { display: flex; align-items: start; gap: 6px; color: var(--text); overflow-wrap: anywhere; }
.key-scopes input { width: auto; margin-top: 3px; }
.key-list { display: grid; gap: 10px; margin-top: 15px; }
.key-card, .session-card { min-width: 0; padding: 15px; border: 1px solid var(--hair-bright); border-left: 2px solid var(--ice); background: var(--panel-lift); }
.key-card h4, .session-card h4 { margin: 0; color: #fff; font-size: 16px; overflow-wrap: anywhere; }
.key-card .source-facts, .session-card .source-facts { margin-top: 12px; grid-template-columns: 90px minmax(0, 1fr); }
.key-card .status-label[data-state="revoked"], .session-card .status-label[data-state="revoked"] { color: var(--text-faint); }
.key-card .status-label[data-state="active"], .session-card .status-label[data-state="active"] { color: var(--phosphor); }
.key-card .core-actions, .session-card .core-actions { margin-top: 13px; }
#keysMore { margin-top: 14px; }
.key-dialog label { display: grid; gap: 5px; }
.key-dialog input { width: 100%; margin: 5px 0 12px; }
#keyTokenValue { color: var(--phosphor); overflow-x: auto; }
.grow { flex: 1; }
.core-workbench .inline-controls .grow input { width: 100%; }
.command-dialog, .help-dialog { width: min(640px, calc(100vw - 32px)); color: var(--text); background: var(--panel); border: 1px solid var(--hair-bright); box-shadow: 0 24px 80px #000; }
.command-dialog::backdrop, .help-dialog::backdrop { background: rgba(1, 3, 5, 0.78); }
.command-dialog > input { width: 100%; margin-bottom: 10px; }
.command-list { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.command-item { text-align: left; background: var(--deck); color: var(--text); border: 1px solid var(--hair); padding: 11px; }
.command-item:hover, .command-item:focus-visible { border-color: var(--phosphor); }
.core-answer dl { display: grid; grid-template-columns: max-content 1fr; gap: 5px 16px; }
.core-answer dt { color: var(--text-dim); }
.core-answer dd { margin: 0; overflow-wrap: anywhere; }
kbd { padding: 1px 5px; color: var(--text); background: var(--deck); border: 1px solid var(--hair-bright); }

@media (max-width: 760px) {
  .core-workbench .console-body { grid-template-columns: 1fr; }
  .core-workbench .rail { position: static; width: 100%; height: auto; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--hair-bright); }
  .core-workbench .rail-item { min-width: max-content; }
  .core-heading { display: block; }
  .core-activity-grid { grid-template-columns: 1fr; }
  .core-activity-grid > div:first-child { grid-row: 2; }
  .core-workbench .history-list button.activity-row { grid-template-columns: 72px minmax(0, 1fr); gap: 3px 8px; }
  .core-workbench .history-list .activity-row time { grid-column: 2; }
  .core-workbench #activityDetail { grid-row: 1; position: static; max-height: none; }
  .review-grid { grid-template-columns: 1fr; }
  .core-workbench #reviewDetail { grid-row: 1; position: static; max-height: none; }
  .review-editor .form-grid { grid-template-columns: 1fr; }
  .source-card-grid { grid-template-columns: 1fr; }
  .operations-grid { grid-template-columns: 1fr; }
  .job-list { grid-template-columns: 1fr; }
  .key-scopes { grid-template-columns: 1fr 1fr; }
  #sources .inline-controls { flex-wrap: wrap; }
  #sources .inline-controls .grow { flex-basis: 100%; }
  #commandButton kbd { display: none; }
}

[dir="rtl"] { text-align: start; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link { position: absolute; left: -999px; z-index: 30; background: var(--phosphor); color: var(--void); padding: 10px 16px; }
.skip-link:focus { left: 12px; top: 12px; }

:focus-visible { outline: 1px solid var(--phosphor); outline-offset: 2px; }

::selection { background: rgba(62, 230, 160, 0.3); color: #fff; }

/* --------------------------------------------------------------- tooltips */

/*
 * Every control says what it is and what pressing it does (ui-flow.md rule 13).
 * `display: none` rather than a faded-out box: a laid-out invisible bubble would
 * widen the page, and the console must never scroll sideways. Hidden means
 * unanimatable, so the entrance is a keyframe on the hovered state instead — it
 * runs when `display` flips, and `both` holds the tip invisible through the
 * delay. The delay is the manners: a tip answers a question, so it waits to be
 * asked rather than firing at every pointer that crosses the rail.
 */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: max-content;
  max-width: min(320px, 62vw);
  padding: 8px 10px;
  font-size: 12.1px;
  line-height: 1.45;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  white-space: normal;
  color: var(--text);
  background: var(--panel-lift);
  border: 1px solid rgba(88, 199, 243, 0.34);
  box-shadow: 0 18px 40px -18px #000;
  pointer-events: none;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  display: block;
  animation: tip-in 130ms ease-out 600ms both;
}
@keyframes tip-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}
/* Reduced motion keeps the pause and the fade, and drops the travel. */
@media (prefers-reduced-motion: reduce) {
  @keyframes tip-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}
/* Right-aligned clusters open leftwards so the bubble stays on screen. */
.console-status [data-tip]::after, .section-heading [data-tip]::after { left: auto; right: 0; }
/* The rail scrolls, so its tips must fit inside it. */
.rail [data-tip]::after { max-width: 192px; }

/* ---------------------------------------------------------------- top bar */

.console { min-height: 100vh; display: flex; flex-direction: column; }

.console-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  height: 60px;
  background: rgba(8, 11, 16, 0.92);
  border-bottom: 1px solid var(--hair-bright);
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: baseline; gap: 10px; }

.brand .glyph {
  width: 9px; height: 9px;
  background: var(--phosphor);
  box-shadow: var(--glow) var(--phosphor);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; box-shadow: none; } }

.brand h1 {
  margin: 0;
  font-size: 17.6px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: #fff;
}

.console-status { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ------------------------------------------------------------------- rail */

.console-body { display: grid; grid-template-columns: 232px minmax(0, 1fr); flex: 1; min-height: 0; }

.rail {
  position: sticky;
  top: 60px;
  align-self: start;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 16px 10px 24px;
  background: rgba(6, 9, 13, 0.72);
  border-right: 1px solid var(--hair-bright);
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13.2px;
  letter-spacing: 0.04em;
  text-align: left;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.rail-item:hover { color: var(--text); background: var(--panel); }
.rail-item.is-active {
  color: var(--phosphor);
  background: linear-gradient(90deg, rgba(62, 230, 160, 0.1), transparent);
  border-left-color: var(--phosphor);
}
.rail-num { font-size: 11.0px; color: var(--text-faint); }
.rail-item.is-active .rail-num { color: var(--phosphor); }

/* ------------------------------------------------------------------- main */

.console-main { padding: 22px 26px 80px; min-width: 0; }

.console-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--hair-bright);
}
.console-head h2 {
  margin: 0;
  font-size: 16.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fff;
}
.console-head p { margin: 0; font-size: 12.1px; color: var(--text-faint); }

/* Exceptions strip: exists only while something needs an admin's attention. */
.alert-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 18px;
}
.alert-strip button {
  color: var(--amber);
  border-color: rgba(255, 184, 77, 0.5);
  background: rgba(255, 184, 77, 0.06);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12.1px;
}
.alert-strip button::before { content: "▲ "; font-size: 9px; vertical-align: 1px; }
.alert-strip button:hover:not(:disabled) { color: var(--amber); border-color: var(--amber); box-shadow: 0 0 10px rgba(255, 184, 77, 0.2); }

/* Anchor jumps must clear the sticky console bar. */
.pane, [id] { scroll-margin-top: 84px; }

.pane { display: none; }
.pane.is-active { display: block; animation: boot 260ms ease both; }
/* Transform only: a fade would drop secondary text under its contrast floor mid-animation. */
@keyframes boot { from { transform: translateY(5px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .pane.is-active, .brand .glyph { animation: none; }
  * { transition: none !important; }
}

/* ----------------------------------------------------------------- panels */

article,
.query-form,
.diagnostics {
  position: relative;
  padding: 18px 20px 22px;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--hair);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

/* Corner registration ticks on every panel. */
article::before,
.query-form::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px;
  width: 9px; height: 9px;
  border-top: 1px solid var(--phosphor);
  border-left: 1px solid var(--phosphor);
  opacity: 0.6;
}
article::after,
.query-form::after {
  content: "";
  position: absolute;
  bottom: -1px; right: -1px;
  width: 9px; height: 9px;
  border-bottom: 1px solid var(--phosphor);
  border-right: 1px solid var(--phosphor);
  opacity: 0.6;
}

h2 { margin: 0 0 4px; font-size: 14.3px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #fff; }
h3 { margin: 18px 0 8px; font-size: 13.2px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ice); }
h4 { margin: 14px 0 6px; font-size: 12.1px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }

.section-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px dashed var(--hair-bright);
}

.muted { color: var(--text-faint); font-size: 12.1px; }
a { color: var(--ice); }

/* ---------------------------------------------------------------- controls */

label { display: block; margin-bottom: 10px; font-size: 11.0px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }

input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13.8px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: #070a0e;
  border: 1px solid var(--hair-bright);
  border-radius: 0;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--phosphor);
  box-shadow: 0 0 0 1px rgba(62, 230, 160, 0.25), inset 0 0 18px rgba(62, 230, 160, 0.05);
}
textarea { resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: auto; margin: 0 8px 0 0; accent-color: var(--phosphor); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

fieldset { border: 1px solid var(--hair-bright); background: rgba(88, 199, 243, 0.03); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { padding: 0 8px; font-size: 9.9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ice); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 0 16px; }
.inline-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-controls input, .inline-controls select { width: auto; min-width: 146px; margin-top: 0; padding: 5px 8px; font-size: 12.7px; }
.toggles { display: flex; flex-wrap: wrap; gap: 16px; margin: 6px 0 14px; }
.toggles label, .checkbox-grid label { display: flex; align-items: center; margin: 0; font-size: 12.1px; letter-spacing: 0.06em; color: var(--text); }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); gap: 4px 14px; }
.template-row, .button-row, .batch-row, .row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }

button {
  font-family: var(--mono);
  font-size: 11.0px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 12px;
  color: var(--text-dim);
  background: var(--panel-lift);
  border: 1px solid var(--hair-bright);
  border-radius: 0;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
button:hover:not(:disabled) { color: var(--phosphor); border-color: var(--phosphor); box-shadow: 0 0 10px rgba(62, 230, 160, 0.18); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

button[type="submit"] {
  padding: 9px 20px;
  font-size: 12.1px;
  color: var(--void);
  background: var(--phosphor);
  border-color: var(--phosphor);
  font-weight: 700;
}
/* The generic button:hover turns text phosphor, which would vanish on this fill. */
button[type="submit"]:hover:not(:disabled) {
  color: var(--void);
  background: #6df3ba;
  border-color: #6df3ba;
  box-shadow: 0 0 18px rgba(62, 230, 160, 0.35);
}

button[data-action="approved"]:hover:not(:disabled),
button[data-action="approve"]:hover:not(:disabled),
button[data-action="resolved"]:hover:not(:disabled) { color: var(--phosphor); border-color: var(--phosphor); }
button[data-action="rejected"]:hover:not(:disabled),
button[data-action="dismissed"]:hover:not(:disabled) { color: var(--alarm); border-color: var(--alarm); box-shadow: 0 0 10px rgba(255, 90, 82, 0.2); }

.button-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 11.0px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ice);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}

/* ---------------------------------------------------------------- signals */

.status, .actor-chip {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 9px;
  color: var(--text-dim);
  background: var(--deck);
  border: 1px solid var(--hair-bright);
}
.status.ok { color: var(--phosphor); border-color: rgba(62, 230, 160, 0.45); box-shadow: inset 0 0 12px rgba(62, 230, 160, 0.08); }
.status.fail { color: var(--alarm); border-color: rgba(255, 90, 82, 0.5); box-shadow: inset 0 0 12px rgba(255, 90, 82, 0.1); }
.actor-chip { color: var(--violet); border-color: rgba(167, 139, 250, 0.4); }

.risk-badge { font-size: 9.9px; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 7px; border: 1px solid currentColor; color: var(--text-dim); }
.risk-high, .risk-critical { color: var(--alarm); }
.risk-medium { color: var(--amber); }
.risk-low { color: var(--phosphor); }

/* ------------------------------------------------------------------- rows */

.mapping-list, .task-list, .relation-list, .definition-list, .concept-list, .object-list,
.audit-list, .discovery-list, .decision-plan-list, .history-list, .eval-case-list,
.question-list, .observation-list, .hypothesis-list, .check-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hair);
}

.mapping-row, .task-row, .relation-row, .definition-row, .audit-row, .discovery-row,
.decision-plan-row, .list-row, .source-asset-row, .eval-case {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  width: 100%;
  padding: 9px 8px;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: 13.2px;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background 110ms ease, box-shadow 110ms ease;
}
.mapping-row:hover, .task-row:hover, .relation-row:hover, .definition-row:hover,
.audit-row:hover, .discovery-row:hover, .decision-plan-row:hover, .list-row:hover,
.source-asset-row:hover, .eval-case:hover {
  background: var(--panel-lift);
  box-shadow: inset 2px 0 0 var(--phosphor);
}

.mapping-row strong, .task-row strong, .relation-row strong, .definition-row strong,
.decision-plan-row strong, .list-row strong, .audit-row strong, .eval-case strong {
  flex: 1 1 260px;
  font-weight: 500;
  color: #fff;
}
.mapping-row span, .task-row span, .relation-row span, .definition-row span, .audit-row span,
.discovery-row span, .decision-plan-row span, .list-row span {
  font-size: 11.6px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.mapping-row button:first-of-type, .task-row button:first-of-type, .relation-row button:first-of-type,
.definition-row button:first-of-type, .decision-plan-row button:first-of-type, .list-row button:first-of-type,
.audit-row button:first-of-type, .eval-case button:first-of-type { margin-left: auto; }
.mapping-row button, .task-row button, .relation-row button, .definition-row button,
.decision-plan-row button, .list-row button, .audit-row button, .eval-case button {
  padding: 4px 8px;
  font-size: 9.9px;
  background: transparent;
}

.row-actions { margin: 0; gap: 4px; }
.load-more-button { align-self: flex-start; margin-top: 12px; }

/* Quick actions stay quiet until the row is engaged; the row itself opens the item. */
.mapping-row button, .task-row button, .relation-row button, .definition-row button,
.decision-plan-row button, .list-row button, .audit-row button, .eval-case button,
.discovery-row button {
  opacity: 0.3;
  transition: opacity 120ms ease;
}
.mapping-row:hover button, .task-row:hover button, .relation-row:hover button,
.definition-row:hover button, .decision-plan-row:hover button, .list-row:hover button,
.audit-row:hover button, .eval-case:hover button, .discovery-row:hover button,
.mapping-row:focus-within button, .task-row:focus-within button, .relation-row:focus-within button,
.definition-row:focus-within button, .decision-plan-row:focus-within button, .list-row:focus-within button,
.audit-row:focus-within button, .eval-case:focus-within button, .discovery-row:focus-within button,
.is-open button {
  opacity: 1;
}

/* Trace history: the question is prose, not a verb. */
.history-list button, .question-list button {
  display: flex;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  padding: 9px 8px;
  text-align: left;
  font-size: 13.8px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hair);
}
.history-list button:hover, .question-list button:hover {
  color: var(--text);
  background: var(--panel-lift);
  box-shadow: inset 2px 0 0 var(--ice);
}
.history-list button span, .question-list button span {
  flex: 0 0 auto;
  font-size: 9.9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.empty { padding: 16px 8px; color: var(--text-faint); font-size: 12.7px; border-top: 1px solid var(--hair); }
.error { color: var(--alarm); }

/* -------------------------------------------------------------- telemetry */

.detail-panel, .result-output, .trace-view, .preview-result,
.manual-test-result, .hypothesis-panel {
  padding: 16px 18px;
  min-height: 56px;
  background: #070a0e;
  border: 1px solid var(--hair-bright);
  border-left: 2px solid var(--ice);
  color: var(--text);
}
.result-output { font-size: 15.4px; line-height: 1.6; }

/* Cells carry their own hairline rather than showing through a filled
   container, so a partly-filled last row reads as empty instead of as a
   phantom cell. */
.trace-summary, .result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  gap: 1px;
  margin: 14px 0;
  border: 1px solid var(--hair-bright);
}
.trace-summary > div, .result-summary > div {
  background: var(--deck);
  padding: 10px 12px;
  box-shadow: 0 0 0 1px var(--hair-bright);
}
.trace-summary span, .result-summary span {
  display: block;
  font-size: 9.9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.trace-summary strong, .result-summary strong { font-size: 16.5px; color: var(--phosphor); font-weight: 500; }

.trace-block { margin: 14px 0; padding-left: 12px; border-left: 1px solid var(--hair-bright); }

/* --------------------------------------------------- structured evidence */

.evidence-panel h4 { margin: 16px 0 6px; }
.evidence-note { margin: 6px 0 10px; font-size: 13.2px; color: var(--text-dim); }
.sub-block { margin: 8px 0; padding-left: 12px; border-left: 1px dashed var(--hair); }
.sub-block h4 { margin: 8px 0 4px; }

/* Decision pipeline: where the run stopped, and in what tone. */
.pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 12px 0 16px; }
.pipe-step {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 10px;
  font-size: 11.0px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--hair);
  background: var(--deck);
  color: var(--text-faint);
}
.pipe-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; align-self: center; }
.pipe-step.is-done { color: var(--text-dim); border-color: var(--hair-bright); }
.pipe-step.is-done .pipe-dot { background: var(--phosphor); box-shadow: 0 0 6px var(--phosphor); }
.pipe-step.is-stop { border-color: currentColor; }
.pipe-step.is-stop .pipe-dot { box-shadow: 0 0 8px currentColor; }
.pipe-step.stop-ok { color: var(--phosphor); }
.pipe-step.stop-warn { color: var(--amber); }
.pipe-step.stop-fail { color: var(--alarm); }
.pipe-step.stop-info { color: var(--ice); }
.pipe-stage { font-size: 9.9px; letter-spacing: 0.08em; text-transform: lowercase; opacity: 0.85; }
.pipe-link { width: 18px; height: 1px; background: var(--hair-bright); }

/* Score meters (terminal blocks; the CSP forbids width-styled fills). */
.meter { font-size: 12.1px; color: var(--phosphor); letter-spacing: 0.05em; white-space: nowrap; }
.meter-low { color: var(--amber); }

/* Source candidates: the chosen route against its alternatives. */
.candidate-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.candidate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  padding: 9px 12px;
  background: var(--deck);
  border: 1px solid var(--hair);
  border-left: 2px solid var(--hair-bright);
}
.candidate.is-selected { border-left-color: var(--phosphor); background: rgba(62, 230, 160, 0.05); }
.candidate strong { font-size: 13.2px; color: #fff; font-weight: 500; }
.candidate-reason { flex-basis: 100%; font-size: 11.6px; color: var(--text-faint); }
.selected-flag {
  font-size: 9.9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--phosphor);
  border: 1px solid rgba(62, 230, 160, 0.45);
  padding: 1px 7px;
}

/* Chips: compact facts (definitions used, statuses, roles). */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  font-size: 11.0px;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  color: var(--text-dim);
  background: var(--deck);
  border: 1px solid var(--hair-bright);
}

/* Join path: relation hops with their trust and confidence. */
.relation-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 10px;
  margin: 6px 0;
  background: var(--deck);
  border: 1px solid var(--hair);
}
.rel-node { font-size: 13.2px; color: #fff; }
.rel-arrow { font-size: 11.0px; letter-spacing: 0.06em; color: var(--ice); }
.relation-chain.rel-approved .rel-arrow { color: var(--phosphor); }
.relation-chain.rel-proposed .rel-arrow { color: var(--amber); }

dl { display: grid; grid-template-columns: minmax(134px, auto) 1fr; gap: 2px 14px; margin: 10px 0; }
dt { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); padding-top: 3px; }
dd { margin: 0; font-size: 13.8px; color: var(--text); }

pre {
  padding: 12px 14px;
  overflow-x: auto;
  max-height: 440px;
  font-size: 12.7px;
  line-height: 1.5;
  color: var(--phosphor);
  background: #05080b;
  border: 1px solid var(--hair);
}

details.expert-drawer, details.trace-raw { margin: 12px 0; border-top: 1px dashed var(--hair-bright); padding-top: 10px; }
summary { cursor: pointer; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); }
summary:hover { color: var(--phosphor); }

.analytics-card-grid, .source-diagnostic-grid, .assumption-grid, .diagnostic-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(242px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.analytics-card, .assumption-card, .observation-card, .profile-card, .decision-family-card {
  padding: 14px 16px;
  background: var(--deck);
  border: 1px solid var(--hair);
  border-top: 2px solid var(--hair-bright);
}
.analytics-card h4, .profile-card h3, .decision-family-card h3 { margin-top: 0; }
.analytics-ok { border-top-color: var(--phosphor); }
.analytics-warning, .analytics-warn { border-top-color: var(--amber); }
.analytics-critical, .analytics-fail { border-top-color: var(--alarm); }
.decision-family-card { margin-bottom: 14px; }

.hypothesis-callout {
  margin: 12px 0;
  padding: 12px 14px;
  color: var(--amber);
  background: rgba(255, 184, 77, 0.06);
  border: 1px dashed rgba(255, 184, 77, 0.4);
}

.list-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13.2px; }
.list-table th, .list-table td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--hair); }
.list-table th { font-size: 9.9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }

.diagnostics dl { grid-template-columns: 1fr; gap: 0; }
.diagnostics dt { padding-top: 9px; border-top: 1px solid var(--hair); }
.diagnostics dd { padding-bottom: 7px; color: var(--ice); }

/* ---------------------------------------------------------------- dialogs */

.confirmation-dialog {
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--hair-bright);
  box-shadow: 0 0 0 1px rgba(62, 230, 160, 0.12), 0 30px 80px -30px #000;
  max-width: 520px;
  width: calc(100% - 40px);
}
.confirmation-dialog::backdrop { background: rgba(3, 5, 8, 0.78); }
.confirmation-dialog form { padding: 22px 24px 20px; }
.confirmation-dialog h2 { font-size: 13.2px; color: var(--phosphor); }
.confirmation-dialog[data-level="high"] h2 { color: var(--alarm); }
.confirmation-dialog p { color: var(--text-dim); font-size: 13.8px; }

/* ------------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--hair-bright);
}
.tab-item {
  padding: 8px 14px;
  font-size: 11.6px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  box-shadow: none;
}
.tab-item:hover:not(:disabled) { color: var(--text); background: var(--panel); border-color: var(--hair-bright); box-shadow: none; }
.tab-item.is-active { color: var(--phosphor); border-bottom-color: var(--phosphor); background: linear-gradient(180deg, transparent, rgba(62, 230, 160, 0.07)); }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------------------------------------------------- master–detail grids */

/* The detail lives beside its list, so opening a row lands where you look. */
@media (min-width: 1240px) {
  .md { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
  .md-work { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
  .md-detail {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
  }
}

/* Selected row stays visibly open while its detail is shown. */
.is-open.mapping-row, .is-open.task-row, .is-open.relation-row, .is-open.definition-row,
.is-open.audit-row, .is-open.discovery-row, .is-open.decision-plan-row, .is-open.list-row,
.is-open.source-asset-row, .is-open.eval-case, .is-open.decision-family-card,
.history-list button.is-open {
  background: var(--panel-lift);
  box-shadow: inset 2px 0 0 var(--ice);
}

/* ---------------------------------------------------------------- drawers */

/* Editors and heavyweight forms open on demand; browsing stays data-first. */
details.editor-drawer {
  margin: 12px 0;
  border: 1px dashed var(--hair-bright);
  background: rgba(88, 199, 243, 0.02);
}
details.editor-drawer > summary {
  padding: 9px 12px;
  font-size: 11.0px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ice);
  list-style: none;
}
details.editor-drawer > summary::before { content: "+ "; color: var(--phosphor); }
details.editor-drawer[open] > summary::before { content: "− "; }
details.editor-drawer[open] > summary { border-bottom: 1px dashed var(--hair-bright); margin-bottom: 12px; }
details.editor-drawer > summary:hover { color: var(--phosphor); background: var(--panel); }
details.editor-drawer > *:not(summary) { margin-left: 12px; margin-right: 12px; }
details.editor-drawer > form { padding-bottom: 12px; }
details.opt-drawer { margin: 10px 0 16px; }

/* ----------------------------------------------------------------- toasts */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 36px));
}
.toast {
  padding: 11px 14px;
  font-size: 12.7px;
  color: var(--text);
  background: var(--panel-lift);
  border: 1px solid var(--hair-bright);
  border-left: 2px solid var(--phosphor);
  box-shadow: 0 18px 50px -20px #000;
  cursor: pointer;
  animation: toast-in 180ms ease both;
}
.toast-error { border-left-color: var(--alarm); color: #ffd9d7; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ----------------------------------------------------------------- badges */

.rail-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  font-size: 9.9px;
  text-align: center;
  color: var(--ice);
  border: 1px solid rgba(88, 199, 243, 0.45);
  background: rgba(88, 199, 243, 0.08);
}
.rail-item.is-active .rail-badge { color: var(--phosphor); border-color: rgba(62, 230, 160, 0.45); background: rgba(62, 230, 160, 0.08); }

/* -------------------------------------------------------------- workspace */

/* One primary action per workspace; bookkeeping is a quiet text row. */
.primary-action {
  padding: 9px 20px;
  font-size: 12.1px;
  font-weight: 700;
  color: var(--void);
  background: var(--phosphor);
  border-color: var(--phosphor);
}
.primary-action:hover:not(:disabled) {
  color: var(--void);
  background: #6df3ba;
  border-color: #6df3ba;
  box-shadow: 0 0 18px rgba(62, 230, 160, 0.35);
}

.quiet-row { margin: 10px 0 4px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.link-button {
  padding: 0;
  font-size: 11.0px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--text-faint);
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--hair-bright);
}
.link-button:hover:not(:disabled) { color: var(--text-dim); border-color: var(--text-dim); box-shadow: none; background: none; }

.meta-line { margin: 2px 0 12px; font-size: 11.6px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.question-text { margin: 12px 0; padding: 12px 14px; font-size: 14.9px; line-height: 1.6; color: var(--text); background: var(--deck); border-left: 2px solid var(--ice); }

.queue-split { margin-top: 26px; }
.filter-drawer { margin: 8px 0 10px; border-style: solid; border-color: var(--hair); background: none; }
.filter-drawer > summary { color: var(--text-faint); }
.filter-drawer[open] > summary { border-bottom: 0; margin-bottom: 4px; }
.filter-drawer .inline-controls { padding-bottom: 10px; }

/* ----------------------------------------------------------------- answer */

.answer-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 11.6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  background: var(--deck);
}
.answer-banner::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.answer-answered { color: var(--phosphor); }
.answer-hypothesis { color: var(--amber); }
.answer-needs_curation, .answer-needs_clarification { color: var(--ice); }
.answer-blocked, .answer-failed { color: var(--alarm); }
/* A dry run did everything it was asked to; it is not a stop. */
.answer-dry_run { color: var(--violet); }
.answer-actions { margin: 12px 0 0; }

@media (max-width: 900px) {
  /* The bar carries brand, status and actor: it must wrap rather than push the page wide. */
  .console-bar {
    position: static;
    height: auto;
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 10px 14px;
  }
  .console-status { flex-wrap: wrap; gap: 6px; }
  .console-body { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; border-right: 0; border-bottom: 1px solid var(--hair-bright); }
  .rail-item { width: auto; }
  .console-head { flex-wrap: wrap; }
  .console-main { padding: 16px 14px 60px; }
  .pane, [id] { scroll-margin-top: 12px; }
}

/* ==========================================================================
   QUERY ENGINE · answer, evidence, trust ledger
   Surfaces for the grounded query engine: the answer as a value, the trust
   ledger as the reason, and structure-level curation work.
   ========================================================================== */

/* --------------------------------------------------------- answer as value */

.answer-value {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 4px 0 10px;
  overflow-wrap: anywhere;
}
.answer-value-list { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 20px; }
.answer-compare { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-size: 18px; color: var(--text-dim); }
.answer-sep { font-size: 11.6px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }
.answer-caption { color: var(--text-dim); margin: 0 0 10px; }
.answer-confidence {
  font-size: 10.4px;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  color: var(--text-dim);
  border: 1px solid var(--hair-bright);
}
.engine-note { margin: -6px 0 12px; font-size: 12.1px; color: var(--amber); }

/* Composition: how several observations became one answer. */
.composition {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin: 0 0 14px;
  padding: 8px 12px;
  border-left: 2px solid var(--violet);
  background: var(--deck);
}
.composition-label {
  font-size: 10.0px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ------------------------------------------------------------- follow-ups */

/* Curation and clarification are independent of trust: each is its own block. */
.follow-up {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--hair-bright);
  border-left-width: 2px;
  background: var(--deck);
}
.follow-up h4 { margin: 0 0 6px; font-size: 12.1px; letter-spacing: 0.08em; text-transform: uppercase; }
.follow-up p { margin: 0 0 8px; }
.follow-up p:last-child { margin-bottom: 0; }
.follow-up-clarify { border-left-color: var(--ice); }
.follow-up-clarify h4 { color: var(--ice); }
.follow-up-curate { border-left-color: var(--amber); }
.follow-up-curate h4 { color: var(--amber); }
.follow-up-blocked { border-left-color: var(--alarm); }
.follow-up-blocked h4 { color: var(--alarm); }

.chip-action {
  cursor: pointer;
  font-family: inherit;
  transition: color 120ms ease, border-color 120ms ease;
}
.chip-action:hover { color: var(--text); border-color: var(--ice); }

/* --------------------------------------------------------------- progress */

.query-progress { padding: 4px 0; }
.progress-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.progress-head strong { font-size: 11.6px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--phosphor); }
.progress-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--phosphor);
  box-shadow: 0 0 10px var(--phosphor);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Seven engine stages must stay readable inside the narrow detail column. */
.pipeline { row-gap: 6px; }
.pipe-step { font-size: 10.4px; padding: 3px 7px; }
.pipe-link { width: 10px; }

.pipe-step.is-failed { color: var(--alarm); border-color: currentColor; }
.pipe-step.is-failed .pipe-dot { background: var(--alarm); box-shadow: 0 0 8px var(--alarm); }
.pipe-step.is-skipped { opacity: 0.4; }
.pipe-step.is-pending { opacity: 0.55; }

/* The stage the server says it is on right now. */
.pipe-step.is-active { color: var(--phosphor); border-color: var(--phosphor); }
.pipe-step.is-active .pipe-dot {
  background: var(--phosphor);
  box-shadow: 0 0 8px var(--phosphor);
  animation: pulse 1.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .pipe-step.is-active .pipe-dot { animation: none; }
}

/* ----------------------------------------------------------- trust ledger */

.ledger { margin: 8px 0 14px; border-top: 1px solid var(--hair); }

/* Identity on the first line, reason underneath: reads at any column width. */
.ledger-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "kind id authority fix"
    "reason reason reason reason";
  gap: 2px 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--hair);
}
.ledger-row .link-button { grid-area: fix; justify-self: end; align-self: center; }
.ledger-kind {
  grid-area: kind;
  font-size: 10.0px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ledger-id { grid-area: id; color: var(--text); overflow-wrap: anywhere; }
.ledger-authority { grid-area: authority; font-size: 11.0px; color: var(--text-faint); }
.ledger-reason { grid-area: reason; font-size: 12.8px; color: var(--text-dim); }
.ledger-row.is-untrusted { border-left: 2px solid var(--amber); padding-left: 10px; }
.ledger-row.is-untrusted .ledger-kind { color: var(--amber); }

/* --------------------------------------------------------- observations */

.observation-card {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--hair);
  background: var(--panel-lift);
}
.observation-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.observation-head strong { letter-spacing: 0.05em; }
.observation-card h4 { margin: 10px 0 4px; font-size: 11.0px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }

.reason-list { margin: 6px 0 12px; padding-left: 18px; color: var(--text-dim); font-size: 12.8px; }
.reason-list li { margin: 3px 0; }
.reason-list.is-warn { color: var(--amber); }

.trace-error {
  margin: 12px 0;
  padding: 10px 14px;
  color: var(--alarm);
  border: 1px solid currentColor;
  background: var(--deck);
}
.trace-error p { margin: 4px 0 0; color: var(--text-dim); }

/* ------------------------------------------- classes that had no rules yet */

/* Action rows above evidence panels. */
.trace-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* Drawer-hosted forms: tighter than a full-width surface form. */
.compact-form { max-width: 620px; }
.compact-form button[type="submit"] { margin-top: 4px; }

/* Definition/relation term lists inside a detail panel. */
.key-value-list { margin: 8px 0 14px; }
.key-value-list dt {
  font-size: 10.4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 8px;
}
.key-value-list dd { margin: 2px 0 0; color: var(--text); overflow-wrap: anywhere; }

/* Grouped blocks inside the decision-plan review. */
.decision-subsection { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--hair); }
.decision-subsection:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.decision-subsection > h3, .decision-subsection > h4 {
  margin: 0 0 8px;
  font-size: 11.0px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Source-preference fieldset in the definition editor. */
.source-preference-panel {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--hair);
  background: var(--deck);
}
.source-preference-panel legend {
  padding: 0 6px;
  font-size: 10.4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Header logout: present, never competing with the work. */
.secondary-button { color: var(--text-dim); border-color: var(--hair-bright); background: var(--deck); }
.secondary-button:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }

/* -------------------------------------------------- query knowledge index */

.index-state { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 12px; }
.index-state strong { letter-spacing: 0.1em; text-transform: uppercase; font-size: 11.6px; }
.index-ok strong { color: var(--phosphor); }
.index-warn strong { color: var(--amber); }
.index-bad strong { color: var(--alarm); }

@media (prefers-reduced-motion: reduce) {
  .progress-pulse { animation: none; }
}

@media (max-width: 900px) {
  .answer-value { font-size: 24px; }
}

/* ==========================================================================
   QUEUE ROWS
   A list is only useful when its rows differ at a glance. Headline first,
   supporting facts on one quiet line, priority readable without reading.
   ========================================================================== */

.queue-row {
  align-items: baseline;
  padding: 11px 10px 11px 12px;
  border-left: 2px solid transparent;
}
.queue-row strong {
  flex: 1 1 320px;
  font-size: 13.8px;
  line-height: 1.4;
  color: #fff;
}
/* The supporting line never competes with the headline. */
.queue-row .row-meta {
  flex: 1 1 100%;
  margin-top: 2px;
  font-size: 11.6px;
  color: var(--text-faint);
}
.queue-row .row-arrow { margin: 0 6px; color: var(--text-faint); font-weight: 400; }
.queue-row .row-technical { color: var(--text-dim); font-weight: 400; }

/* Priority is a colour you scan, not a word you read. */
.priority-critical { border-left-color: var(--alarm); }
.priority-high { border-left-color: var(--amber); }
.priority-medium { border-left-color: var(--ice); }
.priority-low { border-left-color: var(--hair-bright); }

.confidence-stat { font-size: 13.2px; color: var(--text-dim); white-space: nowrap; }
.confidence-unit { font-size: 10.4px; color: var(--text-faint); margin-left: 2px; }

/* Row actions stay quiet until the row is under the pointer. */
.queue-row .row-action { opacity: 0; transition: opacity 120ms ease; }
.queue-row:hover .row-action,
.queue-row:focus-within .row-action { opacity: 1; }
@media (hover: none) {
  .queue-row .row-action { opacity: 1; }
}

/* Volume before detail: what am I looking at, and how much of it is urgent. */
.list-summary {
  margin: 0 0 4px;
  padding: 0 2px 8px;
  font-size: 11.6px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--hair);
}

/* Date-range inputs must say which end they are. */
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 10.4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.field-label input { margin: 0; }

/* An idle workspace gives its width back to the queue it serves. */
@media (min-width: 1240px) {
  .md.is-idle { grid-template-columns: minmax(0, 1fr); }
  .md.is-idle .md-detail { display: none; }
}

/* Priority sits with the headline so a row stays two lines, not three. */
.queue-row .risk-badge { margin-left: auto; align-self: center; }
.queue-row .confidence-stat { margin-left: auto; }

/* Mappings group by the concept they define; a curator opens one at a time and
   works its backlog. The left border reads urgency (weakest confidence) at a glance. */
.concept-group { border-left: 3px solid transparent; border-bottom: 1px solid var(--hair); }
.concept-group > summary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  padding: 11px 10px 11px 28px;
  font-size: 13.8px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  list-style: none;
}
/* An expandable row must say so. */
.concept-group > summary::-webkit-details-marker { display: none; }
.concept-group > summary::before {
  content: "▸";
  position: absolute;
  left: 12px;
  color: var(--text-faint);
}
.concept-group[open] > summary::before { content: "▾"; }
.concept-group > summary:hover { background: var(--panel-lift); color: var(--text); }
.concept-group > summary:hover::before { color: var(--phosphor); }
.concept-group[open] > summary { background: var(--panel-lift); }
.concept-group > summary strong { flex: 1 1 auto; color: #fff; font-weight: 500; }
.concept-group > summary .row-meta {
  flex: 1 1 100%;
  margin-top: 2px;
  font-size: 11.6px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-faint);
}
.concept-group-body { padding-left: 8px; }
.concept-group-body.empty { padding: 8px 12px; color: var(--text-faint); font-size: 11.6px; }

/* ----------------------------------------------------------------- manual */

/* Long-form prose, so it gets a reading measure instead of the console grid. */
.manual-body { max-width: 74ch; }
.manual-body h3 {
  margin: 32px 0 10px;
  font-size: 13.2px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor);
}
.manual-body > h3:first-child { margin-top: 4px; }
.manual-body p { margin: 0 0 12px; color: var(--text-dim); line-height: 1.72; }
.manual-body em { color: var(--text); font-style: normal; border-bottom: 1px dotted var(--hair-bright); }
.manual-body strong { color: var(--text); font-weight: 500; }
.manual-body code { color: var(--ice); white-space: nowrap; }
.manual-body ul, .manual-body ol { margin: 0 0 12px; padding-left: 22px; color: var(--text-dim); line-height: 1.72; }
.manual-body li { margin-bottom: 8px; }
.manual-body dl { margin: 0 0 12px; }
.manual-body dt {
  margin-top: 14px;
  font-size: 12.1px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.manual-body dd { margin: 3px 0 0; color: var(--text-dim); line-height: 1.68; }

/* Core desktop workbench: readable decisions with technical detail close by. */
.core-workbench .console-main { width: min(1560px, 100%); padding-inline: clamp(20px, 3vw, 44px); }
.core-workbench .query-form { max-width: 1020px; }
.core-workbench .core-answer { max-width: 1200px; }
.core-workbench .review-grid { grid-template-columns: minmax(260px, 0.62fr) minmax(0, 1.65fr); gap: 24px; }
.core-workbench .review-row small, .core-workbench .review-kind,
.core-workbench .history-list .activity-row span, .core-workbench .history-list .activity-row time,
.core-workbench .source-identity, .core-workbench .source-facts dt,
.core-workbench .source-freshness-note, .core-workbench .source-job-status { font-size: 12px; }
.core-workbench .review-row strong { font-size: 14px; }
.core-workbench .review-status, .core-workbench .review-effect, .core-workbench .source-facts { font-size: 13px; }
.core-workbench .review-editor { padding: 20px; gap: 16px; border-style: solid; }
.core-workbench .review-editor label { font-size: 13px; }
.core-workbench .review-editor input, .core-workbench .review-editor select { min-height: 38px; }
.core-workbench .check-row { display: flex; align-items: start; gap: 9px; }
.core-workbench .check-row input { width: auto; min-height: 0; flex: 0 0 auto; margin-top: 4px; }
.guided-meaning { display: grid; gap: 16px; }
.guided-meaning h5 { margin: 0; font-size: 16px; color: var(--phosphor); }
.guided-pin { margin: 0; font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.guided-meaning fieldset { min-width: 0; border: 1px solid var(--hair-bright); padding: 14px; }
.guided-meaning legend { padding: 0 6px; color: var(--ice); font-size: 13px; }
.guided-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 16px; }
.guided-groups > p { grid-column: 1 / -1; margin: 0 0 5px; color: var(--text-dim); }
.guided-predicates > p, .guided-private-note { color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.guided-predicate-row { display: grid; grid-template-columns: minmax(130px, 1.25fr) minmax(110px, 1fr) minmax(100px, 1fr); gap: 12px; padding-block: 12px; border-top: 1px solid var(--hair); }
.guided-predicate-row .check-row { align-self: center; }
.guided-predicate-row > button { justify-self: start; align-self: end; }
.model-wording-preview { padding: 14px; border: 1px solid var(--hair-bright); background: var(--deck); }
.model-wording-preview summary { color: var(--ice); }
.model-wording-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow: auto; font-size: 12px; line-height: 1.6; }
.wording-digest { font-size: 11px; color: var(--text-dim); overflow-wrap: anywhere; }
.simulated-notice { padding: 9px 12px; border-left: 2px solid var(--amber); background: var(--panel-lift); color: var(--amber); font-size: 13px; }
.core-workbench .status-label[data-state="trusted"] { color: var(--phosphor); }
.core-workbench .status-label[data-state="hypothesis"], .core-workbench .status-label[data-state="clarification"] { color: var(--amber); }
@media (max-width: 900px) {
  .core-workbench .review-grid { grid-template-columns: 1fr; }
  .core-workbench #reviewDetail { position: static; max-height: none; }
  .guided-predicate-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .guided-groups, .guided-predicate-row, .core-workbench .review-editor .form-grid { grid-template-columns: 1fr; }
}
.core-workbench .inline-controls { flex-wrap: wrap; }
.core-workbench .review-editor p { margin: 0; font-size: 13px; line-height: 1.6; }
.core-workbench .review-editor h4 { margin: 0; }
.core-workbench #reviewDetail:has(.review-editor) { position: static; max-height: none; overflow: visible; }
.core-workbench .presentation-line { font-size: 18px; line-height: 1.7; overflow-wrap: anywhere; }
.core-workbench .core-heading h2 { font-size: clamp(26px, 2.1vw, 36px); }
.core-workbench .core-heading > p { max-width: 430px; font-size: 13px; line-height: 1.6; }
.core-workbench .query-form > textarea { height: 112px; }
