/* Governed Agentic SDLC — sober EY style. No external fonts or assets (CSP default-src 'self'). */

:root {
  --ink: #2e2e38;          /* EY charcoal */
  --ink-2: #4a4a57;
  --muted: #6b6b78;
  --line: #dcdce3;
  --bg: #f4f4f6;
  --card: #ffffff;
  --yellow: #ffe600;       /* EY yellow, used sparingly */
  --ok: #16784a;
  --ok-bg: #e9f5ef;
  --bad: #b3261e;
  --bad-bg: #fbeceb;
  --warn-bg: #fff8cc;
  --real: #16784a;
  --standin: #8a5a00;
  --recorded: #3d4f9f;
  --radius: 6px;
  --gutter: 16px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
h4 { font-size: 0.95rem; }
p { margin: 0 0 8px; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 700; }
.mono { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.85em; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
[hidden] { display: none !important; }

/* ---- Header ------------------------------------------------------------------------------- */

.topbar { background: var(--ink); color: #fff; }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 12px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand-logo { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-org { font-size: 0.85rem; color: #c9c9d3; }

.topbar-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.persona { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 8px; min-width: 0; }
.persona-label { font-size: 0.8rem; color: #c9c9d3; }
.persona select {
  font: inherit; font-size: 0.9rem; padding: 6px 8px; border-radius: var(--radius);
  border: 1px solid #6b6b78; background: #3a3a46; color: #fff; max-width: 100%; min-width: 0;
}
.persona-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 0.8rem; }
.persona-identity { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; color: #c9c9d3; }
.topbar .badge { background: #3a3a46; color: #e8e8ee; border-color: #5a5a68; }
.topbar .component-name { color: #c9c9d3; }
.topbar .chip-role { background: #4a4a57; color: #fff; border-color: #5a5a68; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.fidelity-strip {
  margin: 0; padding: 6px var(--gutter); font-size: 0.85rem; text-align: center;
  background: #23232b; color: #e8e8ee; border-top: 2px solid var(--yellow);
}

/* ---- Buttons and form fields ---------------------------------------------------------------- */

.btn {
  font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--ink);
  background: #fff; color: var(--ink); line-height: 1.2;
}
.btn:hover { background: #f0f0f3; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #45454f; }
.btn-ghost { background: transparent; color: #fff; border-color: #8a8a96; }
.btn-ghost:hover { background: #3a3a46; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }
.btn[disabled] { cursor: not-allowed; opacity: 0.45; background: #f0f0f3; color: var(--muted); border-color: var(--line); }

input[type="text"], textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #b9b9c4; border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
.json-editor { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.8rem; line-height: 1.4; }

/* ---- Layout ----------------------------------------------------------------------------------- */

main { max-width: 1280px; margin: 0 auto; padding: 24px var(--gutter) 48px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; min-width: 0;
}
.section-title { margin: 24px 0 12px; }

.workspace-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.workspace-main { min-width: 0; }

.projects { margin-bottom: 0; }
.projects h2 { margin-bottom: 4px; }
.project-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.project-item {
  display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--line); text-decoration: none; background: #fff;
}
.project-item:hover { border-color: var(--ink-2); }
.project-item.is-selected { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--yellow); }
.project-name { font-weight: 700; }
.project-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; margin: 12px 0 0; }
.facts dt { font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* ---- Chips and badges --------------------------------------------------------------------------- */

.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  border: 1px solid var(--line); background: #f4f4f6; color: var(--ink-2); white-space: nowrap;
}
.chip-ticket { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-weight: 400; }
.class-public { background: #eef6ff; border-color: #c4dcf5; }
.class-internal { background: #f1efff; border-color: #d4cdf5; }
.class-confidential { background: #fff2e5; border-color: #f2d1ad; }
.class-highly-confidential { background: #fbeceb; border-color: #efc2bf; }
.state-approved { background: var(--ok-bg); color: var(--ok); border-color: #b5dcc6; }
.state-draft { background: var(--warn-bg); color: #6b5800; border-color: #eadc8a; }
.state-superseded { background: #ececf0; color: var(--muted); }
.chip-flag { background: var(--bad-bg); color: var(--bad); border-color: #efc2bf; }
.chip-registered { background: var(--ok-bg); color: var(--ok); border-color: #b5dcc6; white-space: normal; }
.chip-mode { white-space: normal; }
.chip-mode.mode-live { background: var(--yellow); border-color: #d8c200; color: var(--ink); }
.chip-mode.mode-recorded { background: #eef0fa; border-color: #b9c1e6; color: #24306b; }
.chip-chosen { background: var(--yellow); border-color: #d8c200; color: var(--ink); }
.status-completed { background: var(--ok-bg); color: var(--ok); border-color: #b5dcc6; }
.status-blocked, .status-failed { background: var(--bad-bg); color: var(--bad); border-color: #efc2bf; }

.badge {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; max-width: 100%;
  padding: 1px 8px; border-radius: 4px; font-size: 0.75rem; line-height: 1.45;
  border: 1px solid var(--line); background: #fafafc; color: var(--ink-2);
}
.badge-provider { overflow-wrap: anywhere; }
.badge-sep { white-space: pre; }
.badge-fidelity { font-weight: 700; }
.badge-real .badge-fidelity { color: var(--real); }
.badge-standin .badge-fidelity { color: var(--standin); }
.badge-recorded .badge-fidelity { color: var(--recorded); }
/* On the dark header (badge background #3a3a46): Stand-in 8.8:1, Real 7.0:1, Recorded 6.6:1. */
.topbar .badge .badge-fidelity { color: #ffe600; }
.topbar .badge-real .badge-fidelity { color: #7fe0a6; }
.topbar .badge-recorded .badge-fidelity { color: #b9c4ff; }

.component { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; max-width: 100%; }
.component-name { font-weight: 700; color: var(--ink-2); }
.decision .component, .run-head .component, .run-output .component, .card > .component { margin-top: 6px; display: flex; }
.component-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }

/* ---- Notices (control answers) ----------------------------------------------------------------- */

.notice { border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; border-left: 4px solid; }
.notice p:last-child { margin-bottom: 0; }
.notice-allowed { background: var(--ok-bg); border-color: var(--ok); }
.notice-refused { background: var(--bad-bg); border-color: var(--bad); }
.notice-error { background: #ececf0; border-color: var(--ink-2); }
.notice-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; }
.notice-allowed .notice-mark { color: var(--ok); }
.notice-refused .notice-mark { color: var(--bad); }
.notice-why { font-size: 0.9rem; color: var(--ink-2); }
.rule-id {
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.78rem; font-weight: 700;
  padding: 1px 6px; border-radius: 4px; background: var(--ink); color: #fff; white-space: nowrap;
}

/* ---- Intent and capabilities -------------------------------------------------------------------- */

.intent-form { display: flex; gap: 8px; align-items: flex-start; }
.intent-form textarea { flex: 1; min-width: 0; }
.proposal { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.not-enabled { font-size: 0.82rem; font-style: italic; color: var(--muted); }

.cap-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 12px; }
.cap-group h3 { font-size: 0.95rem; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.cap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cap { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.cap-text { display: flex; flex-direction: column; min-width: 0; }
.cap-name { font-weight: 700; }
.cap.is-disabled { background: #f6f6f8; }
.cap.is-disabled .cap-name { color: var(--muted); }
.cap .btn { flex: none; }

/* ---- Artefacts -------------------------------------------------------------------------------- */

.artefact-head { display: flex; justify-content: space-between; gap: 12px; }
.state-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.registered { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.approvals { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.actions-label { margin-right: 4px; }
.content { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.content summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.content-body { margin-top: 8px; }
.editor { margin-top: 16px; padding: 16px; border: 1px solid var(--ink); border-radius: var(--radius); background: #fcfcfd; }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.req-list li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; }
.req-id { font-weight: 700; font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.85rem; }
.req-notes { margin-top: 10px; font-size: 0.9rem; color: var(--ink-2); }
pre.json { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; background: #f6f6f8; padding: 12px; border-radius: var(--radius); }

/* ---- Tables ----------------------------------------------------------------------------------- */

.table-wrap { width: 100%; margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); border-bottom: 2px solid var(--ink); padding: 6px 8px;
}
.data-table td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; overflow-wrap: break-word; }
.data-table .steps { margin: 0; padding-left: 18px; }
.scenarios td:nth-child(1), .scenarios td:nth-child(3) { white-space: nowrap; }
.scenarios td:nth-child(1) { font-weight: 700; }
.scenarios td:nth-child(4) { font-weight: 700; }

/* ---- Run view ------------------------------------------------------------------------------------ */

.back { margin-bottom: 12px; }
.run-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.decision-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.decision-grid .card { margin-bottom: 16px; }
.big { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.permitted { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.permitted li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.permitted li.is-chosen { font-weight: 700; }
.redaction-box { margin-top: 12px; }
.redactions { margin: 0; padding-left: 18px; font-size: 0.88rem; }
.tools { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.tools li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools li.ok .notice-mark { color: var(--ok); }
.tools li.refused .notice-mark { color: var(--bad); }

.run-output { border-top: 4px solid var(--ink); }
.output-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.output-head h2 { margin: 0; }
.mode-label {
  margin: 0; padding: 6px 12px; border-radius: var(--radius); font-weight: 700; font-size: 0.92rem;
  border: 2px solid var(--ink); background: #fff;
}
.mode-live { background: var(--yellow); border-color: var(--ink); }
.mode-recorded { background: #eef0fa; border-color: var(--recorded); color: #24306b; }
.cost-line { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---- Entry ------------------------------------------------------------------------------------ */

.entry { display: flex; justify-content: center; padding-top: 32px; }
.entry-card {
  width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--line);
  border-top: 4px solid var(--yellow); border-radius: var(--radius); padding: 32px;
}
.entry-logo { display: block; width: 56px; height: 56px; background: var(--ink); padding: 8px; border-radius: var(--radius); margin-bottom: 16px; }
.entry-lede { color: var(--ink-2); }
.entry-form { display: grid; gap: 8px; margin-top: 20px; }
.entry-form label { font-weight: 700; font-size: 0.9rem; }
.entry-form input { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.form-error { color: var(--bad); min-height: 1.5em; font-size: 0.9rem; margin: 0; }

/* ---- Tour overlay ------------------------------------------------------------------------------- */

body.tour-open { overflow: hidden; }
.tour-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(35, 35, 43, 0.55);
  display: flex; justify-content: center; align-items: flex-start; padding: 24px var(--gutter);
  overflow-y: auto; overscroll-behavior: contain;
}
.tour-card {
  width: 100%; max-width: 760px; background: var(--card); border-radius: var(--radius);
  border-top: 6px solid var(--yellow); padding: 20px 24px 24px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  min-width: 0;
}
.tour-card h2 { font-size: 1.45rem; margin: 6px 0 12px; }
.tour-card h2:focus { outline: none; }
.tour-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tour-top .eyebrow { margin: 0; }
.tour-progress { list-style: none; display: flex; gap: 6px; margin: 10px 0 0; padding: 0; }
.tour-progress li { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.tour-progress li.done { background: var(--ink); }
.tour-progress li.now { background: var(--yellow); box-shadow: inset 0 0 0 1px #d8c200; }
.tour-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--muted); margin: 0 0 2px; }
.tour-sponsor { font-size: 1.08rem; line-height: 1.5; }
.tour-note { background: var(--warn-bg); border-left: 4px solid #d8c200; padding: 8px 12px; border-radius: var(--radius); font-size: 0.92rem; }
.tour-mode { display: inline-block; margin: 4px 0 12px; font-size: 1rem; }
.tour-sub { font-size: 0.95rem; margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--ink); }
.tour-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tour-actions .btn { padding: 10px 18px; font-size: 0.95rem; }
.tour-why { margin-top: 14px; padding: 10px 12px; background: #f4f4f6; border-radius: var(--radius); }
.tour-data { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.tour-data p:last-child { margin-bottom: 0; }
.tour-facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 4px 12px; margin: 0 0 8px; font-size: 0.9rem; }
.tour-facts dt { color: var(--muted); font-weight: 700; }
.tour-facts dd { margin: 0; overflow-wrap: anywhere; }
.tour-card .reconstruction { margin: 12px 0 0; padding: 16px; }
.tour-failed .notice-head { display: block; }

.outcomes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.outcome { padding: 10px 12px; border-radius: var(--radius); border-left: 4px solid; }
.outcome.ok { background: var(--ok-bg); border-color: var(--ok); }
.outcome.refused { background: var(--bad-bg); border-color: var(--bad); }
.outcome p { margin: 0 0 4px; }
.outcome p:last-child { margin-bottom: 0; }
.outcome-head { display: flex; gap: 8px; align-items: baseline; }
.outcome-head .notice-mark { font-weight: 700; }
.outcome.ok .notice-mark { color: var(--ok); }
.outcome.refused .notice-mark { color: var(--bad); }
.outcome-meta { color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.outcome-why { color: var(--ink-2); }

/* ---- Evidence panel --------------------------------------------------------------------------- */

.evidence { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fafafc; }
.evidence > summary { cursor: pointer; font-weight: 700; padding: 10px 12px; }
.evidence[open] > summary { border-bottom: 1px solid var(--line); }
.evidence-body { padding: 12px; }
.ev-concept { margin-bottom: 10px; }
.ev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 8px 10px; min-width: 0; }
.ev-allowed { border-left-color: var(--ok); }
.ev-denied { border-left-color: var(--bad); }
.ev-info { border-left-color: var(--recorded); }
.ev-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ev-seq { font-weight: 700; }
.ev-type { font-weight: 700; }
.ev-who { margin: 4px 0; }
.ev-details { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 2px 10px; margin: 4px 0; font-size: 0.85rem; }
.ev-details dt { color: var(--muted); font-weight: 700; }
.ev-details dd { margin: 0; overflow-wrap: anywhere; }
.ev-chain { margin: 4px 0 0; font-size: 0.75rem; color: var(--ink-2); }
.ev-foot { margin: 10px 0 0; }
.outcome-allowed { background: var(--ok-bg); color: var(--ok); border-color: #b5dcc6; }
.outcome-denied { background: var(--bad-bg); color: var(--bad); border-color: #efc2bf; }
.outcome-info { background: #eef0fa; color: #24306b; border-color: #b9c1e6; }

/* ---- Reconstruction ------------------------------------------------------------------------------ */

.recon-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.recon-head h2 { margin: 0; }
.chain { margin: 0; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 0.9rem; display: inline-flex; gap: 6px; align-items: center; }
.chain-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.chain-bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-step { position: relative; padding: 0 0 12px 28px; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 2px 12px; }
.tl-step::before { content: ""; position: absolute; left: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.tl-label { font-weight: 700; margin: 0; }
.tl-body { min-width: 0; overflow-wrap: anywhere; }
.tl-body p { margin: 0 0 2px; }
.tl-body .tools { margin: 0; }
.tl-mode { display: inline-block; margin-top: 4px !important; font-size: 0.85rem; }
.tl-decisions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tl-decisions li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.tl-decisions li.ok .notice-mark { color: var(--ok); }
.tl-decisions li.refused .notice-mark { color: var(--bad); }
.recon-evidence { margin-top: 4px; }

/* ---- Command line ------------------------------------------------------------------------------ */

.console-wrap { max-width: 960px; margin: 0 auto; }
.term { background: #1e1e26; color: #e8e8ee; border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.term-log { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.term-entry { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid #3a3a46; }
.term-out {
  margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85rem; line-height: 1.45;
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
}
.term-prompt { color: #ffe600; font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-size: 0.85rem; white-space: nowrap; }
.term-cmd { font-weight: 700; }
.term-ok { color: #7fe0a6; }
.term-denied { color: #ffb4ab; }
.term-foot { margin: 6px 0 0; font-size: 0.78rem; color: #b8b8c4; }
.term .evidence { background: #fafafc; color: var(--ink); margin-top: 8px; }
.term-form { display: flex; align-items: center; gap: 8px; }
.term-input {
  flex: 1; min-width: 0; background: #2a2a34 !important; color: #fff !important; border-color: #5a5a68 !important;
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace !important; font-size: 0.9rem !important;
}
.term-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.btn-example { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; font-weight: 400; padding: 3px 8px; }
.term-mini { margin-top: 8px; }
.term-mini .term-foot { color: #b8b8c4; }

/* ---- Narrow screens (390 px phones) ----------------------------------------------------------- */

@media (max-width: 860px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .decision-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 640px) {
  main { padding-top: 16px; }
  .card { padding: 16px; }
  h1 { font-size: 1.35rem; }
  .topbar-inner { padding: 10px var(--gutter); gap: 10px; }
  .topbar-controls { width: 100%; gap: 10px; }
  .persona { width: 100%; }
  .persona select { width: 100%; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
  .intent-form { flex-direction: column; align-items: stretch; }
  .cap { flex-direction: column; }
  .entry-card { padding: 20px; }
  .entry { padding-top: 8px; }

  /* Tables become stacked cards, each cell labelled. */
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; margin-bottom: 8px; }
  .data-table td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; }
  .data-table td::before { content: attr(data-label); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); padding-top: 2px; overflow-wrap: normal; }
  .scenarios td:nth-child(1), .scenarios td:nth-child(3) { white-space: normal; }

  .topbar-actions .btn { flex: 1 1 40%; }
  .tour-overlay { padding: 8px; }
  .tour-card { padding: 14px 14px 18px; }
  .tour-card h2 { font-size: 1.25rem; }
  .tour-sponsor { font-size: 1rem; }
  .tour-top { align-items: flex-start; }
  .tour-actions .btn { flex: 1 1 100%; }
  .tour-facts, .ev-details { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tour-facts dd, .ev-details dd { margin-bottom: 4px; }
  .tl-step { grid-template-columns: minmax(0, 1fr); padding-left: 28px; }
  .term { padding: 10px; }
  .term-form { flex-wrap: wrap; }
  .term-form .term-input { flex: 1 1 60%; }
}
