:root {
  --bg: #0c1018;
  --panel: #11161f;
  --panel-2: #171e2a;
  --line: #2b3547;
  --line-soft: #212a39;
  --text: #e7edf7;
  --dim: #a6b2c6;
  --dim-2: #8492a8;
  --accent: #63a4ff;
  --accent-dim: #1c2f4d;
  --green: #2dd4bf;
  --green-dim: #0f2e2b;
  --red: #ff8a70;
  --red-dim: #3a1f1a;
  --amber: #f2c75e;
  /* Okabe-Ito derived, colour-blind-safe ramp (teal / yellow / blue / purple / grey) */
  --cb-junior: #2dd4bf;
  --cb-mid: #f2c75e;
  --cb-senior: #7ab8ff;
  --cb-manager: #d99bff;
  --cb-na: #9aa8bd;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.6 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(button, a, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid #8ec5ff;
  outline-offset: 2px;
}

/* ---------------- layout ---------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 320px) 7px minmax(0, 1fr);
  height: 100vh;
}

/* draggable splitters */
.resizer { position: relative; z-index: 7; touch-action: none; background: transparent; flex-shrink: 0; }
.resizer.v { cursor: col-resize; }
.resizer.h { cursor: row-resize; height: 7px; }
.resizer::after {
  content: "";
  position: absolute;
  background: var(--line);
  transition: background .15s ease, width .15s ease, height .15s ease;
}
.resizer.v::after { left: 3px; top: 0; bottom: 0; width: 1px; }
.resizer.h::after { top: 3px; left: 0; right: 0; height: 1px; }
.resizer::before {
  content: "";
  position: absolute;
  border-radius: 99px;
  background: #55647c;
  opacity: .85;
  transition: background .15s ease, opacity .15s ease;
}
.resizer.v::before { width: 3px; height: 40px; left: 2px; top: 50%; transform: translateY(-50%); }
.resizer.h::before { height: 3px; width: 40px; top: 2px; left: 50%; transform: translateX(-50%); }
.resizer:hover::after, .resizer.dragging::after, .resizer:focus-visible::after { background: var(--accent); }
.resizer:hover::before, .resizer.dragging::before, .resizer:focus-visible::before { background: var(--accent); opacity: 1; }
.resizer:focus-visible { outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing.row { cursor: row-resize; }

/* ---------------- sidebar ---------------- */
.sidebar {
  border-right: none;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.brand {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.brand h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: .02em;
  font-weight: 650;
}
.brand .sub {
  margin-top: 3px;
  color: var(--dim-2);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.progress-wrap { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.progress-top .lbl { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.progress-top .val { font-family: var(--mono); font-size: 12px; color: var(--text); }
.bar { height: 5px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), #6fb1ff); width: 0; transition: width .25s ease; }

.side-tools { padding: 12px 12px 8px; display: grid; gap: 8px; }
.search {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12.5px;
  outline: none;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--dim-2); }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 11px;
  letter-spacing: .02em;
}
.chip:hover { color: var(--text); border-color: var(--dim-2); }
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: #cfe0ff; }

.list { overflow-y: auto; flex: 1; padding: 4px 8px 20px; min-height: 0; }

/* practising queue */
.queue-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 6px;
  border-top: 1px solid var(--line-soft);
}
.queue-title {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.queue-count {
  font-family: var(--mono);
  font-size: 10px;
  color: #9fc0ff;
  background: var(--accent-dim);
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  padding: 0 5px;
}
.queue-list { flex: 1 1 0; min-height: 0; padding-bottom: 8px; }


/* queue rows */
.qrow {
  display: grid;
  grid-template-columns: 18px 18px minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 6px;
  color: var(--dim);
  font-size: 13.2px;
  text-align: left;
}
.qrow { cursor: pointer; }
.qrow:hover { background: var(--panel-2); color: var(--text); }
.qrow.on { background: var(--panel-2); border-color: var(--line); color: #fff; }
.qrow .qn { font-family: var(--mono); font-size: 11px; color: var(--dim-2); text-align: right; }
.qrow .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow .k { font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); }
.qrow .k.k-sen { color: var(--cb-senior); font-weight: 600; }
.qrow.now { box-shadow: inset 2px 0 0 var(--accent); }
.qrow .mini {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim-2);
  border-radius: 5px;
  width: 18px;
  height: 18px;
  line-height: 1;
  font-size: 12px;
  padding: 0;
  display: grid;
  place-items: center;
}
.qrow .mini:hover { color: var(--text); border-color: var(--dim-2); }
.qrow .mini.x:hover { color: var(--red); border-color: #4a2630; }

.add-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim-2);
  border-radius: 5px;
  width: 18px;
  height: 18px;
  line-height: 1;
  font-size: 12px;
  padding: 0;
  display: grid;
  place-items: center;
  justify-self: end;
}
.add-btn:hover { color: var(--accent); border-color: var(--accent); }
.add-btn.queued { color: var(--dim-2); border-color: transparent; cursor: default; }
.add-btn.queued:hover { color: var(--dim-2); border-color: transparent; }


.group-h {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim-2);
  padding: 12px 8px 5px;
}

.item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto 20px;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 8px;
  color: var(--dim);
  font-size: 13px;
}
.item:hover { background: var(--panel-2); color: var(--text); }
.item.on { background: var(--panel-2); border-color: var(--line); color: #fff; }
.item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .lvl { justify-self: end; }

.done-mark {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 99px;
  border: 1px solid #3a465c;
  background: transparent;
  color: transparent;
  display: grid;
  place-items: center;
  justify-self: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.done-mark span { transform: translateY(-0.5px); }
.done-mark:hover, .qrow:hover .done-mark:not(.on), .item:hover .done-mark:not(.on) {
  border-color: var(--green);
  color: var(--green);
}
.done-mark.on {
  background: var(--green-dim);
  border-color: #1f4a45;
  color: var(--green);
}
.done-mark:focus-visible { outline: 2px solid #8ec5ff; outline-offset: 1px; }

.lvl {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--dim-2);
}
/* difficulty: outline only, so it never competes with the filled level pill */
.lvl.l1 { color: var(--cb-junior); border-color: #1f4a45; }
.lvl.l2 { color: var(--cb-mid); border-color: #4a4021; }
.lvl.l3 { color: #ff9a7a; border-color: #4a2b21; }

/* seniority label from the scraped source report: filled + text, not colour alone */
.lvl.sen { font-weight: 600; letter-spacing: .02em; }
.lvl.sen-junior { color: var(--cb-junior); border-color: #1f4a45; background: #0d2422; }
.lvl.sen-mid { color: var(--cb-mid); border-color: #4a4021; background: #211d0f; }
.lvl.sen-senior { color: var(--cb-senior); border-color: #2b4470; background: #121c2c; }
.lvl.sen-manager { color: var(--cb-manager); border-color: #432b52; background: #1c1226; }
.lvl.sen-na { color: var(--cb-na); border-color: #2f3a4d; background: #141a24; }
.lvl-slot { display: block; }

.tag-sen { font-weight: 600; }
.tag-sen.sen-junior { color: var(--cb-junior); border-color: #1f4a45; background: #0d2422; }
.tag-sen.sen-mid { color: var(--cb-mid); border-color: #4a4021; background: #211d0f; }
.tag-sen.sen-senior { color: var(--cb-senior); border-color: #2b4470; background: #121c2c; }
.tag-sen.sen-manager { color: var(--cb-manager); border-color: #432b52; background: #1c1226; }
.tag-sen.sen-na { color: var(--cb-na); border-color: #2f3a4d; background: #141a24; }
.tag-date { color: #8b98ad; font-variant-numeric: tabular-nums; }

/* ---------------- main ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  flex-shrink: 0;
}
.topbar .title { font-weight: 600; font-size: 14.5px; }
.topbar .sig { font-family: var(--mono); font-size: 12px; color: var(--dim-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
}
.btn:hover { border-color: var(--dim-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06122b; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.run { background: var(--green); border-color: var(--green); color: #04221c; font-weight: 650; }
.btn.run:hover { filter: brightness(1.08); }
#btn-done.primary { background: transparent; border-color: var(--line); color: var(--text); font-weight: 500; }
#btn-done.primary:hover { filter: none; border-color: var(--dim-2); }
#btn-done.is-done { border-color: #1f4a45; color: var(--green); background: var(--green-dim); }
#btn-done.is-done:hover { border-color: var(--green); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 9px; font-size: 11.5px; }
.btn:disabled { opacity: .45; cursor: default; }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  border: 1px solid #33405a;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  color: var(--dim);
  background: #0e1520;
  margin-left: 5px;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: var(--doc-w, minmax(340px, 1fr)) 7px minmax(320px, 1fr) 0 0;
  min-height: 0;
}
.workspace.ai-open {
  grid-template-columns: var(--doc-w, minmax(340px, 1fr)) 7px minmax(320px, 1fr) 7px var(--ai-w, 360px);
}
#resize-ai, .ai-pane { display: none; }
.workspace.ai-open #resize-ai { display: block; }
.workspace.ai-open .ai-pane { display: flex; }

/* ---------------- prompt pane ---------------- */
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane.left { background: var(--panel); }

.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim-2);
  padding: 10px 10px 8px;
  font-size: 12px;
  letter-spacing: .02em;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  margin-left: 5px;
  border-radius: 99px;
  background: var(--accent-dim);
  color: #9fc0ff;
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.doc { overflow-y: auto; padding: 20px 24px 48px; flex: 1; min-height: 0; }

.doc h2 { font-size: 19px; margin: 0 0 6px; letter-spacing: -.01em; }
.meta-row { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}
.body-text { color: #c6d1e2; font-size: 14.5px; line-height: 1.72; white-space: pre-wrap; max-width: 84ch; }
.body-text strong { color: #fff; }
.code-inline { font-family: var(--mono); font-size: 12.5px; background: #0a0f18; border: 1px solid var(--line-soft); border-radius: 4px; padding: 1px 5px; color: #c7d5f0; }

.sigbox {
  margin-top: 14px;
  background: #0a0f18;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: #9ec1ff;
  white-space: pre-wrap;
  overflow-x: auto;
}

.section-h {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 8px;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.section-h::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.hint {
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  background: #17140c;
  border-radius: 7px;
  padding: 10px 13px;
  margin-bottom: 8px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #e0dac9;
  animation: fade .18s ease;
}
.hint .n {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--amber);
  letter-spacing: .08em;
  display: block;
  margin-bottom: 3px;
}
@keyframes fade { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

pre.code {
  margin: 0;
  background: #080c13;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.2px;
  line-height: 1.68;
  color: #d7e2f2;
}
pre.code .kw, .tok-kw { color: #7ab8ff; font-weight: 600; }
pre.code .cm, .tok-com { color: #8494a8; font-style: italic; }
pre.code .st, .tok-str { color: #4dd4ac; }
pre.code .nu, .tok-num { color: #f5a65b; }
.tok-fn { color: #f2d06b; font-weight: 600; }
.tok-punc, .tok-op { color: #a9b6ca; }

.cx { font-family: var(--mono); font-size: 12.5px; color: #5eead4; margin-top: 8px; }

/* ---------------- AI hint ---------------- */
.tab .ai-spark { color: var(--cb-manager); font-size: 10px; margin-left: 4px; vertical-align: 1px; }
.ai-intro { color: var(--dim); font-size: 13.5px; }
.ai-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin: 16px 0 4px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.ai-verdict-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.ai-verdict-note {
  flex-basis: 100%;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
}
.ai-verdict.on-track { border-color: #1f4a45; background: #0d2422; }
.ai-verdict.on-track .ai-verdict-label { color: var(--cb-junior); }
.ai-verdict.wrong { border-color: #5c3125; background: #2a1611; }
.ai-verdict.wrong .ai-verdict-label { color: var(--red); }
.ai-verdict.unclear { border-color: #2f3a4d; background: #141a24; }
.ai-verdict.unclear .ai-verdict-label { color: var(--cb-na); }
.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--dim);
  font-size: 13.5px;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--cb-manager);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-code {
  margin: 0;
  background: #080c13;
  border: 1px solid var(--line);
  border-left: 2px solid var(--cb-manager);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: #d7e2f2;
}
.ai-why { margin-top: 10px; color: var(--dim); font-size: 13.5px; font-style: italic; }
.ai-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ai-empty { margin-top: 16px; }
.ai-note { margin-top: 10px; color: var(--dim-2); font-size: 12.5px; }
.ai-selection {
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--amber);
  border: 1px solid #4a4021;
  background: #17140c;
  border-radius: 5px;
  padding: 4px 7px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-explain {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 11px 12px;
  margin-top: 8px;
}
.ai-explain-term {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--cb-senior);
  border: 1px solid #2b4470;
  background: #121c2c;
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 6px;
}
.ai-explain-body {
  color: #c6d1e2;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.ai-explain-example {
  margin: 8px 0 0;
  background: #080c13;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: #d7e2f2;
  white-space: pre-wrap;
}
.ai-error {
  margin-top: 16px;
  border: 1px solid #5c3125;
  background: var(--red-dim);
  color: #ffd6cb;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  display: grid;
  gap: 4px;
}
.ai-disclaimer { margin-top: 18px; }
.review-summary {
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-left: 2px solid var(--accent);
  background: var(--panel-2);
  border-radius: 0 8px 8px 0;
}
.review-block { margin-top: 12px; }
.review-block h4 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.review-block ul {
  margin: 0;
  padding-left: 18px;
  color: #c6d1e2;
  font-size: 13.5px;
  line-height: 1.65;
}
.review-block li { margin-bottom: 5px; }
.review-block p {
  margin: 0;
  color: #c6d1e2;
  font-size: 13.5px;
  line-height: 1.65;
}
.review-area {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--cb-senior);
  border: 1px solid #2b4470;
  background: #121c2c;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 7px;
  vertical-align: 1px;
}
.review-empty { margin-top: 4px; }
.solve-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.solve-changes-wrap { margin-top: 12px; }
.solve-changes { margin: 0; padding-left: 18px; color: var(--dim); font-size: 13px; line-height: 1.6; }
.solve-changes li { margin-bottom: 4px; }
.solve-steps { margin: 0; padding-left: 20px; }
.solve-steps li { margin-bottom: 9px; color: #c6d1e2; font-size: 13.5px; line-height: 1.6; }
.solve-steps li b { display: block; color: var(--text); margin-bottom: 2px; }
.solve-steps li span { display: block; color: var(--dim); }
.solve-code { max-height: 420px; overflow: auto; margin-top: 10px; }
.diff-line { display: block; }
.diff-add { background: rgba(45, 212, 191, .10); box-shadow: inset 2px 0 0 var(--cb-junior); }
.solve-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim-2);
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: rgba(45, 212, 191, .18);
  box-shadow: inset 2px 0 0 var(--cb-junior);
  display: inline-block;
}
.solve-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.solve-empty { margin-top: 4px; }
.ai-pane {
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow: hidden;
}
.ai-pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.ai-pane-title {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--cb-manager);
}
.ai-pane-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.ai-pane-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 40px; }
.ai-pane-body .ai-intro { font-size: 12.5px; }
.btn.ghost.on { border-color: var(--accent); color: #cfe0ff; background: var(--accent-dim); }
.tag-ai { color: var(--cb-manager); border-color: #432b52; background: #1c1226; }
.tag-stale { color: var(--amber); border-color: #4a4021; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.callout {
  border: 1px dashed #4a4021;
  background: #17140c;
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #ded2ae;
  margin-top: 10px;
}
.callout b { color: var(--amber); }

.empty { color: var(--dim-2); font-size: 13.5px; padding: 8px 0; }

/* notes */
textarea.notes {
  width: 100%;
  min-height: 200px;
  background: #0a0f18;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}
textarea.notes:focus { border-color: var(--accent); }

/* ---------------- editor pane ---------------- */
.pane.right { background: #0a0e15; }

.editor-wrap { position: relative; flex: 1; display: flex; min-height: 0; overflow: hidden; }
/* CodeMirror 6 editor (vendor/codemirror.bundle.js); colours live in its theme */
.code-host { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; --ed-font: 14px; }
.code-host .cm-editor { position: absolute; inset: 0; }

.editor-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.editor-bar .status { font-size: 12.5px; color: var(--dim); font-family: var(--mono); }
.editor-bar .status.ok { color: var(--green); }
.editor-bar .status.bad { color: var(--red); }
.editor-bar .status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* language picker (js/ml-runtimes.js) */
.lang-pick { position: relative; }
.lang-pick[hidden] { display: none; }
.lang-btn { font-family: var(--mono); display: inline-flex; gap: 6px; align-items: center; }
.lang-btn .caret { color: var(--dim-2); font-size: 10px; }
.lang-menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 40; width: 300px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45); }
.lang-menu[hidden] { display: none; }
.lang-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.lang-opt:hover, .lang-opt:focus-visible { background: var(--accent-dim); outline: none; }
.lang-opt.on { box-shadow: inset 3px 0 0 var(--accent); background: rgba(99, 164, 255, .08); }
.lang-opt.on .lang-name { color: var(--accent); }
.lang-opt.off { cursor: not-allowed; opacity: .5; }
.lang-opt.off:hover { background: transparent; }
.lang-name { font: 600 13px/1.2 var(--mono); }
.lang-sub { font-size: 11.5px; color: var(--dim-2); line-height: 1.3; }
.lang-opt.off { opacity: .62; }
.lang-hint { font: 600 11px/1.4 var(--mono); color: #f5c46b; white-space: nowrap; background: #2a2414; padding: 0 4px; border-radius: 4px; }
.lang-badge { font: 600 11px/1 var(--mono); padding: 4px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--dim); white-space: nowrap; cursor: help; }
.lang-badge[hidden] { display: none; }
.lang-badge.jsonly { color: #f5c46b; border-color: #5a4a26; background: #2a2414; }
.lang-badge.subset { color: var(--accent); border-color: var(--accent-dim); }
.results-h .run-lang, .results-h .run-subset { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--dim); }
.results-h .run-subset { color: var(--accent); border-color: var(--accent-dim); cursor: help; }
.case.skip { opacity: .6; }
.case.skip .mark { color: var(--dim-2); }
.sol-lang { font: 600 11px/1 var(--mono); padding: 2px 6px; margin-left: 6px; border-radius: 5px; border: 1px solid var(--accent-dim); color: var(--accent); vertical-align: middle; }

/* ---------------- test dock (official results + custom test) ---------------- */
#resize-results { flex-shrink: 0; }
#resize-results.hidden { display: none; }
.test-dock {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: var(--results-h, 240px);
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-top: none;
  min-width: 0;
}
.test-dock.hidden { display: none; }
.test-dock.collapsed { height: auto; }
.test-dock.collapsed .test-dock-body { display: none; }
.test-dock-tabs {
  flex-shrink: 0;
  align-items: center;
}
.test-dock-tabs .spacer { flex: 1; }
.test-dock-tabs .btn { margin: 4px 8px 4px 0; }
.test-dock-body {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.results {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
}
.results.hidden { display: none; }
.results-empty {
  padding: 18px 16px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.55;
}
.results-empty kbd { margin: 0 2px; }
.results-h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.results-h .score { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.results-h .score.ok { color: var(--green); }
.results-h .score.bad { color: var(--red); }
.run-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim-2);
  white-space: nowrap;
}
.run-stale {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--amber);
  border: 1px solid #4a4021;
  border-radius: 4px;
  padding: 0 5px;
}

/* console captured from the test worker */
.console-panel { border-bottom: 1px solid var(--line); background: #0a0e15; }
.console-h { display: flex; align-items: center; gap: 8px; padding: 7px 14px 6px; }
.console-title {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.console-count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #9ec1ff;
  background: var(--accent-dim);
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  padding: 0 5px;
}
.console-out {
  max-height: 172px;
  overflow-y: auto;
  padding: 0 14px 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #c6d1e2;
}
.console-line {
  padding-left: 1.15em;
  text-indent: -1.15em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.console-line::before { content: "› "; color: #6f7f96; }
.console-line.lvl-warn::before, .console-line.lvl-error::before { content: ""; }
.console-line.lvl-warn { color: var(--amber); }
.console-line.lvl-error { color: var(--red); }
.console-arg { white-space: pre-wrap; }
.console-sep { color: #5d6a80; margin: 0 4px; }
.console-type {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .02em;
  color: #8b98ad;
  background: #121823;
  border: 1px solid #2f3a4d;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 5px;
  vertical-align: 1px;
  white-space: nowrap;
}
.console-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 7px;
}
.console-empty { color: var(--dim-2); font-family: var(--sans); font-size: 12.5px; padding: 2px 0; }
.console-empty code { font-family: var(--mono); color: #c7d5f0; }

.case {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.case:last-child { border-bottom: none; }
.case .mark { font-family: var(--mono); font-weight: 700; }
.case.pass .mark { color: var(--green); }
.case.fail .mark { color: var(--red); }
.case .input { font-family: var(--mono); font-size: 12.5px; color: #b6c3d8; overflow-x: auto; white-space: pre-wrap; }
.case .input-steps {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: #b6c3d8;
  background: #0a0e15;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 8px 10px;
  overflow-x: auto;
  white-space: pre-wrap;
  tab-size: 2;
}
.case .row { margin-top: 3px; font-family: var(--mono); font-size: 12px; }
.case .row .lbl { color: var(--dim-2); display: inline-block; min-width: 62px; }
.case .row.exp { color: var(--green); }
.case .row.act { color: var(--red); }
.case .note { color: var(--dim-2); font-size: 12px; margin-top: 3px; font-style: italic; }
.fatal {
  margin: 12px 14px;
  border: 1px solid #5c3125;
  background: var(--red-dim);
  color: #ffd6cb;
  border-radius: 7px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
}


/* ---------------- custom test ---------------- */
.custom-test {
  flex: 1 1 0%;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.custom-test.hidden { display: none; }
.custom-label {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.custom-optional {
  letter-spacing: 0;
  text-transform: none;
  color: var(--dim-2);
  font-size: 11px;
}
.custom-input {
  width: 100%;
  background: #0a0f18;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  outline: none;
  resize: vertical;
}
input.custom-input { resize: none; }
.custom-input:focus { border-color: var(--accent); }
.custom-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.custom-out {
  margin-top: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0a0e15;
  overflow: auto;
  overscroll-behavior: contain;
  flex: 0 0 auto;
  max-height: 240px;
}
.custom-out .case { border-bottom: none; }
.custom-out .console-panel { border-bottom: 1px solid var(--line-soft); }

/* ---------------- design view ---------------- */
.design-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.topic-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.topic {
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 99px;
  padding: 3px 10px;
  color: var(--dim);
}
.topic:hover { color: var(--text); border-color: var(--accent); }

/* ---------------- plan view ---------------- */
.plan-day { border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; margin-bottom: 10px; background: var(--panel-2); }
.plan-day h3 { margin: 0 0 8px; font-size: 14px; color: #cfe0ff; }
.plan-day ul { margin: 0; padding-left: 18px; color: #c2cddd; font-size: 13.2px; line-height: 1.65; }
.plan-day li { margin-bottom: 5px; }

.framework { display: grid; gap: 8px; margin-top: 10px; }
.fw-step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--panel-2);
}
.fw-step .num { font-family: var(--mono); color: var(--accent); font-size: 12px; padding-top: 1px; }
.fw-step .txt { font-size: 12.5px; color: #b7c3d6; }
.fw-step .txt b { color: #e8eefb; display: block; margin-bottom: 2px; }

/* ---------------- modal / toast ---------------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, .72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal-back.on { display: flex; }
body.modal-open { overflow: hidden; }
.modal {
  width: min(720px, 100%);
  max-height: 84vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.modal-h { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 14px; }
.modal-b { padding: 16px; overflow-y: auto; }

/* ---------------- code graph ---------------- */
.graph-modal { width: min(1180px, 96vw); height: 88vh; max-height: 88vh; }
.graph-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.graph-body { flex: 1; min-height: 0; position: relative; background: #0a0e15; }
#graph-frame { width: 100%; height: 100%; border: 0; display: block; background: #0a0e15; }
.graph-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 32px;
  color: var(--dim);
}
.graph-empty.hidden { display: none; }
.graph-empty h4 { margin: 0; color: var(--text); font-size: 16px; }
.graph-empty p { margin: 0; font-size: 13.5px; line-height: 1.6; max-width: 48ch; }
.graph-msg { font-family: var(--mono); font-size: 11.5px; color: var(--dim-2); min-height: 16px; }

.modal-f { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #182033;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: all .2s ease;
  z-index: 60;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1279px) {
  #resize-ai, .ai-pane { display: none !important; }
  .workspace.ai-open { grid-template-columns: var(--doc-w, minmax(340px, 1fr)) 7px minmax(320px, 1fr) 0 0; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .resizer { display: none; }
  #resize-results { display: block; }
  .workspace, .workspace.ai-open { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .pane.left { border-bottom: 1px solid var(--line); }
}

/* ---------------- Goldman-specific bits ---------------- */
.tag-gs {
  color: #9ec1ff;
  border-color: #2b4470;
  background: #14203a;
  font-weight: 600;
}
.group-h.gs-group { color: #8fb3f0; }
.group-h.ai-group { color: var(--cb-manager); }
.group-h.industry-group { color: #e4c99a; }
.group-h.fundamentals-group { color: #8fc9b8; }
.group-h.ref-group { color: #cfe0ff; }
.group-h .cnt {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim-2);
  margin-left: 4px;
}
.lvl.gs {
  color: #9ec1ff;
  border-color: #2b4470;
  background: #101a2c;
  font-weight: 600;
}
.callout.gs-evidence {
  border-style: solid;
  border-color: #2b4470;
  background: #101828;
  color: #b8c8e2;
}
.callout.gs-evidence b { color: #cfe0ff; }
.srcs { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; }
.srcs a {
  color: #8fc2ff;
  font-size: 12.5px;
  text-decoration: none;
  line-height: 1.5;
}
.srcs a:hover { color: #b8d8ff; text-decoration: underline; }

.rnum {
  display: inline-grid;
  place-items: center;
  width: 17px; height: 17px;
  margin-right: 7px;
  border-radius: 99px;
  background: var(--accent-dim);
  color: #9fc0ff;
  font-family: var(--mono);
  font-size: 10px;
  vertical-align: 1px;
}
.rrow { display: grid; grid-template-columns: 58px 1fr; gap: 10px; font-size: 12.5px; color: #b3bfd2; margin-bottom: 6px; }
.rlbl {
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim-2);
  padding-top: 3px;
}

/* ============================================================
   System design — interactive architecture maps
   ============================================================ */
.group-h.design-group { color: var(--cb-senior); }
.group-h.design-group .cnt { color: var(--cb-senior); border-color: #2b4470; }
.lvl.map {
  color: var(--cb-senior);
  background: #121c2c;
  border-color: #2b4470;
  letter-spacing: .04em;
}
.qrow .k.k-map { color: var(--cb-senior); border-color: #2b4470; background: #121c2c; }

.arch-cta {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 14px 0 16px;
  padding: 13px 15px;
  border: 1px solid #2b4470;
  border-radius: 10px;
  background:
    radial-gradient(420px 120px at 0% 0%, rgba(122, 184, 255, .10), transparent 70%),
    linear-gradient(135deg, #101a29, #0d1420);
}
.arch-cta-copy { display: flex; flex: 1 1 100%; flex-direction: column; gap: 3px; min-width: 0; }
.arch-cta-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cb-senior);
}
.arch-cta-copy b { font-size: 15px; color: var(--text); }
.arch-cta-copy > span:last-child { color: var(--dim); font-size: 12px; line-height: 1.45; }
.arch-cta .btn { margin-left: 0; width: 100%; justify-content: center; }

/* ---------- modal shell ---------- */
.arch-modal {
  width: min(1380px, 97vw);
  height: 90vh;
  max-height: 92vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.arch-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.arch-head-copy { min-width: 0; }
.arch-head h3 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.arch-sub {
  margin-top: 2px;
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 620px;
}
.arch-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  font-family: var(--mono);
  font-size: 11px;
  max-width: 170px;
}
.arch-select:disabled { opacity: .45; }
.arch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.arch-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim);
}
.arch-legend-item i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.arch-legend-sep { width: 1px; height: 14px; background: var(--line); align-self: center; }
.arch-edge-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim);
}
.arch-key-dot { width: 7px; height: 7px; display: inline-block; }
.arch-key-dot.sync { border-radius: 50%; background: #5f9fe8; box-shadow: 0 0 6px rgba(95, 159, 232, .55); }
.arch-key-dot.async { width: 7px; height: 7px; border-radius: 1px; background: #d6a63f; transform: rotate(45deg); }
.arch-key-dot.obs { width: 6px; height: 6px; border-radius: 1px; background: #96a3b7; }
.arch-key-dot.return { width: 8px; height: 8px; border-radius: 50%; background: transparent; border: 2px solid #7ee0c2; }
.arch-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 342px;
}
.arch-canvas {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: #080d14;
  background-image: radial-gradient(rgba(126, 150, 180, .14) 1px, transparent 1px);
  background-size: 18px 18px;
}
.arch-canvas svg { flex: 1 1 0; min-height: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.arch-canvas svg.dragging { cursor: grabbing; }

/* ---------- graph ---------- */
.arch-layer {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .16em;
  opacity: .8;
}
.arch-node { cursor: pointer; transition: opacity .14s ease; }
.arch-node-box { fill: #101720; }
.arch-node-bar { opacity: .95; }
.arch-node-label {
  fill: #e6edf7;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}
.arch-node-sub {
  fill: #7f8da4;
  font-family: var(--mono);
  font-size: 10.5px;
}
.arch-node:hover .arch-node-box { fill: #141e2a; stroke-opacity: 1; }
.arch-node.dim { opacity: .14; }
.arch-node.hot .arch-node-box { fill: #142030; stroke-opacity: 1; }
.arch-node.selected .arch-node-box { stroke: #e6edf7; stroke-width: 1.6; }
.arch-node.fail .arch-node-box { fill: #2a1318; stroke: #ff7b7b; stroke-opacity: 1; }
.arch-node.warn .arch-node-box { fill: #2a2413; stroke: #f2c75e; stroke-opacity: 1; }
.arch-node.fail .arch-node-label, .arch-node.warn .arch-node-label { fill: #ffe9e9; }

.arch-edge { fill: none; stroke: #55677e; stroke-width: 1.35; stroke-linecap: round; }
.arch-edge.sync { stroke: #5f9fe8; }
.arch-edge.async { stroke: #d6a63f; stroke-dasharray: 5 5; }
.arch-edge.obs { stroke: #7f8da4; stroke-dasharray: 2 5; opacity: .55; }
.arch-edge-group { transition: opacity .14s ease; }
.arch-edge-group.dim { opacity: .12; }
.arch-edge-group.hot .arch-edge { stroke-width: 2.1; }
.arch-edge-group.return .arch-edge { stroke: #7ee0c2; stroke-dasharray: 3 4; }
.arch-edge-group.return .arch-edge-label { fill: #9ff0d8; }
.arch-edge-group.return .packet-core { fill: #a7f3df; }
.arch-edge-group.return .packet-halo { fill: #2dd4bf; opacity: .18; }
.arch-edge-group.fail .arch-edge { stroke: #ff7b7b; stroke-width: 2.2; }
.arch-edge-group.flowing .arch-edge {
  stroke-width: 2.5;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, .18));
}
.arch-edge-label {
  fill: #7b8ba3;
  font-family: var(--mono);
  font-size: 9.5px;
  paint-order: stroke;
  stroke: #080d14;
  stroke-width: 3px;
  stroke-linejoin: round;
}
.arch-edge-label.sync { fill: #8fc5ff; }
.arch-edge-label.async { fill: #e8c46c; }
.arch-edge-label.obs { fill: #9aa8bd; }
.arch-edge-group.hot .arch-edge-label { fill: #e6edf7; }
.arch-edge-group.fail .arch-edge-label { fill: #ffb3b3; }

.arch-packet { pointer-events: none; }
.arch-packet .packet-core { fill: #8cc4ff; }
.arch-packet .packet-halo { fill: #5f9fe8; opacity: .16; }
.arch-packet.async .packet-core { fill: #f2c75e; }
.arch-packet.async .packet-halo { fill: #d6a63f; opacity: .16; }
.arch-packet.obs .packet-core { fill: #aab6c8; }
.arch-packet.obs .packet-halo { fill: #7f8da4; opacity: .10; }
.arch-edge-group.fail .packet-core { fill: #ff7b7b; }
.arch-edge-group.fail .packet-halo { fill: #ff7b7b; }
.arch-edge-group.flowing .arch-packet .packet-halo { animation: arch-packetpulse .8s ease-in-out infinite alternate; }
@keyframes arch-packetpulse { from { opacity: .12; } to { opacity: .45; } }
.arch-node.hot .arch-node-box { animation: arch-nodepulse 1.4s ease-in-out infinite alternate; }
@keyframes arch-nodepulse { from { stroke-opacity: .5; } to { stroke-opacity: 1; } }
.arch-node.selected .arch-node-box { animation: none; stroke-opacity: 1; }

/* ---------- inspector ---------- */
.arch-side {
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
.arch-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 2px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.arch-tabs button {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
  border-radius: 5px;
  padding: 5px 6px;
  font-size: 11px;
  font-family: var(--sans);
  cursor: pointer;
}
.arch-tabs button:hover { color: var(--text); }
.arch-tabs button.on { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.arch-panel { padding: 15px 16px 28px; }
.arch-panel-kicker {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cb-junior);
  margin-bottom: 7px;
}
.arch-panel-kicker.danger { color: #ff7b7b; }
.arch-panel h4 { margin: 0 0 6px; font-size: 16px; line-height: 1.3; }
.arch-panel-sub { margin: 0 0 11px; color: var(--dim); font-size: 12.5px; line-height: 1.55; }
.arch-panel-body { margin: 0 0 11px; color: #c6d1e2; font-size: 13px; line-height: 1.6; }
.arch-panel-block {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}
.arch-panel-block > span {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.arch-panel-block p { margin: 0; color: #c6d1e2; font-size: 12.5px; line-height: 1.55; }
.arch-panel-block b { color: var(--text); }
.arch-list { margin: 0; padding-left: 17px; }
.arch-list li { color: #b9c7da; font-size: 12.5px; line-height: 1.58; margin-bottom: 8px; }
.arch-list li::marker { color: var(--cb-junior); }
.arch-stats { display: flex; gap: 7px; margin: 4px 0 12px; }
.arch-stats > div {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  text-align: center;
}
.arch-stats b { display: block; font-size: 19px; color: var(--text); font-family: var(--mono); }
.arch-stats span { font-size: 9.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.arch-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.arch-tag {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--dim);
  border-radius: 4px;
  padding: 2px 6px;
}
.arch-tag.fail { color: #ffb3b3; border-color: #552b31; background: #241216; }
.arch-tag.warn { color: #f2d99a; border-color: #4a4021; background: #1c180d; }
.arch-defs { display: flex; gap: 8px; margin-top: 12px; }
.arch-defs > div {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}
.arch-defs span { display: block; font-size: 9.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.arch-defs b { font-size: 12px; color: var(--text); }
.arch-hint {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--dim-2);
  font-size: 11.5px;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  .arch-packet { display: none; }
  .arch-node.hot .arch-node-box { animation: none; }
  .arch-edge-group.flowing .arch-packet .packet-halo { animation: none; }
}
@media (max-width: 1100px) {
  .arch-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 240px; }
  .arch-side { border-left: 0; border-top: 1px solid var(--line); }
  .arch-sub { max-width: 330px; }
  .arch-select { max-width: 130px; }
  .arch-head { flex-wrap: wrap; }
}
@media (max-width: 860px) {
  .arch-sub { max-width: 100%; }
}

/* ============================================================
   System design workspace (separate from the coding IDE)
   ============================================================ */
.design-stage {
  display: none;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #080d14;
}
body.mode-design .workspace { display: none; }
body.mode-design .design-stage { display: flex; }
body.mode-design #btn-run,
body.mode-design #btn-run-2,
body.mode-design .topbar #btn-notes,
body.mode-design .topbar #btn-hint,
body.mode-design .topbar #btn-graph { display: none; }
body.mode-design .page-title { display: none; }

.design-stage-main {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
.design-stage-main > #arch-modal { flex: 1; min-height: 0; }

.design-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px;
  text-align: center;
  background:
    radial-gradient(600px 260px at 50% 30%, rgba(122, 184, 255, .10), transparent 70%),
    #080d14;
}
.design-empty.hidden { display: none; }
.design-empty-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--cb-senior);
}
.design-empty h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.design-empty p { margin: 0; max-width: 480px; color: var(--dim); font-size: 13.5px; line-height: 1.6; }
.design-empty .btn { margin-top: 6px; }

/* inline architecture panel */
#arch-modal.inline {
  position: static;
  display: flex;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  z-index: auto;
  align-items: stretch;
  justify-content: stretch;
}
#arch-modal.inline .arch-modal {
  width: 100%;
  height: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
#arch-modal.inline .arch-head { padding: 10px 14px; }
#arch-modal.inline .arch-legend { padding: 7px 14px; }
#arch-modal.inline #arch-close { display: none; }
#arch-modal.inline .arch-extra { display: inline-flex; }
.arch-extra { display: none; }
#arch-modal.inline .arch-main {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  position: relative;
}
#arch-modal.inline .arch-side {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 42vw);
  transform: translateX(101%);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1);
  z-index: 8;
  border-left: 1px solid var(--line);
  border-top: 0;
  box-shadow: -18px 0 46px rgba(0, 0, 0, .38);
  background: var(--panel);
}
#arch-modal.inline.inspector-open .arch-side { transform: none; }
#arch-modal.inline .arch-side-close { display: grid; flex: 0 0 24px; width: 24px; height: 24px; }
.arch-side-close {
  display: none;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--dim);
  font-size: 11px;
  padding: 0;
}
.arch-side-close:hover { color: var(--text); border-color: var(--dim-2); }

.arch-zoom-label {
  min-width: 38px;
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim-2);
  font-variant-numeric: tabular-nums;
}

/* design brief drawer */
.design-brief {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(440px, 90vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transform: translateX(-101%);
  visibility: hidden;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .18s;
  z-index: 12;
  box-shadow: 22px 0 54px rgba(0, 0, 0, .42);
}
.design-brief.on {
  transform: none;
  visibility: visible;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), visibility 0s linear 0s;
}
.design-brief-head {
  flex: 0 0 auto;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.design-brief-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cb-senior);
}
.design-brief-mount { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.design-brief-mount > .pane { width: 100%; height: 100%; }
.design-brief .arch-cta { display: none; }
.design-scrim {
  position: absolute;
  inset: 0;
  z-index: 11;
  background: rgba(4, 7, 12, .48);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.design-stage.brief-open .design-scrim { opacity: 1; pointer-events: auto; }

#arch-inspector.on { border-color: var(--accent); color: #cfe0ff; background: var(--accent-dim); }

/* smoother canvas input */
.arch-canvas { overscroll-behavior: contain; }
.arch-canvas svg { will-change: auto; }

@media (max-width: 1100px) {
  #arch-modal.inline .arch-side { width: min(340px, 55vw); }
  .design-brief { width: min(400px, 92vw); }
}

/* ============================================================
   Page nav: Algorithm | System Design
   ============================================================ */
.page-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b111a;
  flex: 0 0 auto;
}
.page-nav button {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.page-nav button:hover { color: var(--text); background: var(--panel-2); }
.page-nav button.on {
  color: #dbe8ff;
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px #2b4470;
}
.page-title { min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.side-code { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-design {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
body.mode-design .side-code { display: none; }
body.mode-design .side-design { display: flex; }
.design-tools { padding: 8px 12px 4px; border-top: 1px solid var(--line-soft); }
.design-tools .search { width: 100%; }
.design-head { border-top: 1px solid var(--line-soft); }
.design-item {
  grid-template-columns: 16px minmax(0, 1fr) auto;
  cursor: pointer;
}
.design-item .t { white-space: normal; line-height: 1.35; }
.design-item .lvl { font-size: 9.5px; }
.design-item .lvl.map { color: var(--cb-senior); border-color: #2b4470; background: #121c2c; }
.design-item.on { background: var(--panel-2); border-color: var(--line); }

/* ============================================================
   Global top nav: Algorithm | System Design
   ============================================================ */
.skip {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; top: 8px; left: 8px; z-index: 200; width: auto; height: auto; margin: 0; clip: auto; overflow: visible;
  padding: 8px 12px; border-radius: 8px; background: var(--panel); color: var(--text); border: 2px solid var(--accent);
  font: 600 13px/1.2 var(--sans, system-ui); text-decoration: none;
}

.global-nav {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}
.global-brand { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.global-title { display: inline-flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; color: var(--text); white-space: nowrap; }
.brand-wordmark { height: 24px; width: auto; flex: 0 0 auto; display: block; color: var(--text); } /* MochiCode wordmark: the mark keeps its own colours, the outlined name follows --text */
.global-sub {
  padding-left: 25px; /* lines up under the name, beside the mark */
  font-size: 10.5px;
  color: var(--dim-2);
  letter-spacing: .04em;
  white-space: nowrap;
}
.app { height: calc(100vh - 52px); }
@media (max-width: 980px) {
  .global-nav { gap: 10px; padding: 0 10px; }
  .global-brand { display: none; }
}

/* return-to-user edges must keep their mint identity over kind colors */
#arch-svg .arch-edge-group.return:not(.fail) .arch-edge-label { fill: #9ff0d8; }
#arch-svg .arch-edge-group.return:not(.fail) .packet-core { fill: #a7f3df; }
#arch-svg .arch-edge-group.return:not(.fail) .packet-halo { fill: #2dd4bf; }

/* ============================================================
   Ask AI side chat (docked as an extra .app column)
   ============================================================ */
#resize-chat, .chat-pane { display: none; }
body.chat-open .app { grid-template-columns: minmax(0, var(--sidebar-w, 320px)) 7px minmax(0, 1fr) 7px var(--chat-w, 380px); }
body.chat-open #resize-chat { display: block; }
body.chat-open .chat-pane { display: flex; }
.chat-toggle { border-color: #2b4470; background: var(--accent-dim); color: #dbe8ff; }
.chat-toggle.on { background: var(--accent); color: #06122b; border-color: var(--accent); font-weight: 650; }
.chat-toggle.on kbd { color: #06122b; border-color: rgba(6, 18, 43, .35); }
.chat-pane {
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.chat-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-head-copy { display: flex; flex-direction: column; min-width: 0; }
.chat-title { font-weight: 650; font-size: 13.5px; color: #dbe8ff; }
.chat-ctx { font-size: 11px; color: var(--dim-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--dim); font-size: 12.5px; line-height: 1.55; }
.chat-empty b { color: var(--text); font-size: 13.5px; }
.chat-msg { display: flex; flex-direction: column; }
.chat-msg.user { align-items: flex-end; }
.chat-bubble { max-width: 100%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-msg.user .chat-bubble { background: var(--accent-dim); border: 1px solid #2b4470; color: #e3ecfb; border-bottom-right-radius: 4px; max-width: 88%; }
.chat-msg.ai .chat-bubble { background: var(--panel-2); border: 1px solid var(--line-soft); color: #d5deeb; border-bottom-left-radius: 4px; }
.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble h5 { margin: 10px 0 4px; font-size: 13px; color: var(--text); }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.chat-bubble li { margin-bottom: 3px; }
.chat-bubble code { font-family: var(--mono); font-size: 12px; background: #0d131c; border: 1px solid var(--line-soft); border-radius: 4px; padding: 0 4px; }
.chat-bubble strong { color: var(--text); }
.chat-code { margin: 6px 0 8px; padding: 9px 10px; background: #0a0f17; border: 1px solid var(--line-soft); border-radius: 7px; font-family: var(--mono); font-size: 11.5px; overflow-x: auto; white-space: pre; }
.chat-table { border-collapse: collapse; margin: 6px 0 8px; font-size: 12px; width: 100%; }
.chat-table th, .chat-table td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; }
.chat-table th { background: #121a26; color: var(--text); }
.chat-msg-actions { display: flex; gap: 4px; margin-top: 3px; opacity: 0; transition: opacity .12s; }
.chat-msg:hover .chat-msg-actions { opacity: 1; }
.chat-mini { border: 1px solid var(--line); background: transparent; color: var(--dim-2); border-radius: 5px; font-size: 10.5px; padding: 1px 7px; }
.chat-mini:hover { color: var(--text); }
.chat-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim-2); animation: chat-dot 1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-error { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 10px 12px; border: 1px solid #4a2630; background: var(--red-dim); border-radius: 9px; font-size: 12.5px; color: #ffd2c7; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 0; }
.chat-chip { border: 1px solid #2b4470; background: #101a29; color: #bcd3f5; border-radius: 999px; padding: 4px 10px; font-size: 11.5px; text-align: left; }
.chat-chip:hover { background: var(--accent-dim); color: #fff; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 12px; }
.chat-form textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 160px;
  background: #0b111a; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; font-size: 13px; line-height: 1.45; outline: none;
}
.chat-form textarea:focus { border-color: var(--accent); }
/* On mid-size screens the chat stays a docked, freely resizable column
   (see the "No overlap" rules below). It only goes full-screen on phones. */

/* ============================================================
   Design stage: map + docked "Your design" study panel
   ============================================================ */
.study-pane {
  flex: 0 0 var(--study-w, 420px);
  width: var(--study-w, 420px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel);
  z-index: 9;
}
.design-stage.study-collapsed .study-pane { display: none; }
.study-reopen {
  display: none;
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  writing-mode: vertical-rl; z-index: 9;
  border: 1px solid #2b4470; border-right: 0; border-radius: 8px 0 0 8px;
  background: var(--accent-dim); color: #dbe8ff; padding: 12px 6px; font-size: 12px; font-weight: 600;
}
.design-stage.study-collapsed .study-reopen { display: block; }
.study-top { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.study-tabs { display: flex; gap: 2px; flex: 1; min-width: 0; }
.study-tab { border: 1px solid transparent; background: transparent; color: var(--dim); border-radius: 6px; padding: 5px 9px; font-size: 12px; white-space: nowrap; }
.study-tab:hover { color: var(--text); }
.study-tab.on { background: var(--panel-2); border-color: var(--line); color: var(--text); font-weight: 600; }
.study-timer { border: 1px solid var(--line); background: #0b111a; color: var(--dim); border-radius: 6px; padding: 3px 8px; font-family: var(--mono); font-size: 11px; }
.study-timer.running { color: var(--green); border-color: #1f4a45; }
.study-timer.low { color: var(--amber); border-color: #4a4021; }
.study-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 40px; }
.study-intro { color: var(--dim); font-size: 12.5px; line-height: 1.55; margin-bottom: 12px; }
.study-h { display: flex; align-items: center; gap: 6px; margin: 18px 0 8px; font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim-2); }
.study-h span { color: var(--cb-senior); }
.linklike { border: 0; background: none; padding: 0; color: #8ec5ff; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linklike:hover { color: #cfe6ff; }
.ask-ai-btn { border-color: #2b4470; color: #bcd3f5; background: #101a29; }
.ask-ai-btn:hover { background: var(--accent-dim); color: #fff; }
.ask-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* what you are being asked */
.ask-card { padding: 14px; border: 1px solid #2b4470; border-radius: 11px; background: linear-gradient(160deg, #111c2d, #0e1520); }
.ask-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--cb-senior); margin-bottom: 6px; }
.ask-main { margin: 0 0 10px; font-size: 14px; line-height: 1.55; color: var(--text); font-weight: 550; }
.ask-h { font-size: 11.5px; color: var(--dim-2); margin: 10px 0 5px; font-weight: 600; }
.ask-examples, .ask-deliver { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ask-examples li { position: relative; padding: 7px 10px 7px 26px; background: #0b121c; border: 1px solid var(--line-soft); border-radius: 7px; font-size: 12.5px; line-height: 1.5; color: #c9d5e6; }
.ask-examples li::before { content: "e.g."; position: absolute; left: 7px; top: 8px; font-family: var(--mono); font-size: 8.5px; color: var(--cb-junior); }
.ask-deliver li { padding-left: 18px; position: relative; font-size: 12.5px; color: #c9d5e6; }
.ask-deliver li::before { content: "□"; position: absolute; left: 0; color: var(--cb-mid); }
.ask-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 12px; }

/* steps */
.steps-head { margin: 18px 0 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.steps-head b { font-size: 15px; }
.steps-head span { font-size: 12px; color: var(--dim-2); }
.steps-bar { flex: 1 1 100%; height: 4px; border-radius: 99px; background: var(--panel-2); overflow: hidden; margin-top: 4px; }
.steps-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width .2s ease; }
.map-mode { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); padding: 7px 10px; margin-bottom: 8px; border: 1px dashed var(--line); border-radius: 7px; }
.stage { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #0f151e; overflow: hidden; }
.stage.open { border-color: #34507a; background: #101824; }
.stage-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: transparent; text-align: left; }
.stage-head:hover { background: #131c29; }
.stage-num { flex: 0 0 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--dim); }
.stage.open .stage-num { border-color: var(--accent); color: #cfe0ff; }
.stage.done .stage-num { background: var(--green-dim); border-color: #1f4a45; color: var(--green); }
.stage-title { flex: 1; font-weight: 600; font-size: 13.5px; }
.stage-min { font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); }
.stage-body { padding: 0 12px 12px; }
.stage-goal { margin: 0 0 6px; font-size: 12.5px; color: #c6d1e2; }
.stage-prompts { margin: 0 0 10px; padding-left: 18px; font-size: 12px; color: var(--dim); }
.stage-prompts li { margin-bottom: 2px; }
.stage-label { display: block; font-size: 11px; font-weight: 600; color: var(--dim-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.stage-answer {
  width: 100%; min-height: 120px; resize: vertical; overflow: hidden;
  background: #090e15; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 11px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--text); outline: none;
}
.stage-answer:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 164, 255, .12); }
.stage-answer::placeholder { color: #4f5d74; }
.stage-body > .btn { margin-top: 8px; }
.stage-tips { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.tip { font-size: 12.5px; line-height: 1.55; color: #d8e2f0; padding: 8px 10px; border-left: 3px solid var(--cb-mid); background: #17150d; border-radius: 0 6px 6px 0; }
.stage-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 8px; font-size: 11.5px; color: var(--dim); }
.stage-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.compare-out { margin-top: 8px; }
.compare-sum { font-size: 12.5px; color: var(--text); }
.compare-sum span { color: var(--dim-2); font-size: 11px; }
.arch-tag.ok { color: #9ff0d8; border-color: #1f4a45; background: #0d2422; }
button.arch-tag { cursor: pointer; }
button.arch-tag:hover { color: var(--text); border-color: var(--dim-2); }
.old-notes { margin-top: 14px; font-size: 12px; color: var(--dim); }
.old-notes pre { white-space: pre-wrap; font-family: var(--mono); font-size: 11.5px; background: #0b111a; padding: 8px; border-radius: 6px; border: 1px solid var(--line-soft); }

/* evaluation */
.eval-card { margin-top: 14px; padding: 14px; border: 1px solid #34507a; border-radius: 11px; background: linear-gradient(160deg, #121c2b, #0e141d); scroll-margin-top: 10px; }
.eval-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.eval-head b { font-size: 14.5px; }
.eval-head span { font-family: var(--mono); font-size: 11px; color: var(--dim-2); }
.eval-copy { margin: 0 0 10px; font-size: 12.5px; color: var(--dim); }
.eval-btn { width: 100%; justify-content: center; }
.eval-score { display: flex; gap: 12px; align-items: center; margin: 14px 0 10px; }
.eval-score p { margin: 2px 0 0; font-size: 12.5px; color: #c6d1e2; line-height: 1.5; }
.score-level { font-weight: 650; font-size: 13px; }
.score-ring { flex: 0 0 58px; height: 58px; border-radius: 50%; display: flex; align-items: baseline; justify-content: center; padding-top: 14px; border: 3px solid var(--line); }
.score-ring b { font-size: 22px; font-family: var(--mono); }
.score-ring span { font-size: 11px; color: var(--dim-2); }
.score-ring.s1, .score-ring.s2 { border-color: var(--red); }
.score-ring.s3 { border-color: var(--amber); }
.score-ring.s4, .score-ring.s5 { border-color: var(--green); }
.rubric { display: flex; flex-direction: column; gap: 8px; }
.rubric-row { display: grid; grid-template-columns: 1fr 80px 14px; gap: 2px 8px; align-items: center; }
.rubric-area { font-size: 12px; font-weight: 600; }
.rubric-bar { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.rubric-bar i { display: block; height: 100%; }
.rubric-bar i.s1, .rubric-bar i.s2 { background: var(--red); }
.rubric-bar i.s3 { background: var(--amber); }
.rubric-bar i.s4, .rubric-bar i.s5 { background: var(--green); }
.rubric-n { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.rubric-row p { grid-column: 1 / -1; margin: 0; font-size: 11.5px; color: var(--dim); line-height: 1.45; }
.eval-h { margin: 14px 0 5px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--dim-2); }
.eval-h.good { color: var(--green); }
.eval-h.bad { color: var(--red); }
.eval-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: #c9d5e6; line-height: 1.55; }
.eval-list li { margin-bottom: 4px; }
.eval-next { margin-top: 12px; padding: 9px 11px; border-radius: 8px; background: #17150d; border-left: 3px solid var(--cb-mid); font-size: 12.5px; color: #e9e1c6; }
.followups { display: flex; flex-direction: column; gap: 6px; }
.followup { display: flex; justify-content: space-between; gap: 10px; text-align: left; border: 1px solid var(--line); background: #0b111a; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: #d4deec; }
.followup i { font-style: normal; color: #8ec5ff; white-space: nowrap; font-size: 11.5px; }
.followup:hover { border-color: #34507a; }

.design-empty-actions { display: flex; gap: 8px; margin-top: 6px; }
@media (max-width: 1100px) {
  .study-pane { --study-w: 360px; }
}

/* ============================================================
   Canvas: component shapes, Paths layout, expanded mode
   ============================================================ */
.arch-node .arch-node-box { fill: #101720; stroke: var(--node-color); stroke-opacity: .6; stroke-width: 1.3; }
.arch-node .arch-node-bar { fill: var(--node-color); }
.arch-node .arch-node-cap { fill: none; stroke: var(--node-color); stroke-opacity: .7; stroke-width: 1.3; }
.arch-node .arch-node-cap.faint { stroke-opacity: .28; }
.arch-node .arch-node-slot { stroke: var(--node-color); stroke-opacity: .55; stroke-width: 2; }
.arch-node .arch-node-box.dashed { stroke-dasharray: 6 4; }
.arch-node .arch-node-box.dotted { stroke-dasharray: 2 3; fill: #0d1219; }
.arch-node.shape-db .arch-node-box { fill: #19130b; }
.arch-node.shape-cache .arch-node-box { fill: #1a1009; }
.arch-node.shape-queue .arch-node-box { fill: #17140a; }
.arch-node.shape-edge .arch-node-box { fill: #140f1d; }
.arch-node.shape-client .arch-node-box { fill: #0d1726; }
.arch-node.shape-external .arch-node-box { fill: #120f19; }
.arch-node-badge { font-family: var(--mono); font-size: 7.5px; letter-spacing: .1em; fill: var(--node-color); opacity: .85; }
.arch-node:hover .arch-node-box { fill: #18222f; stroke-opacity: 1; }
.arch-node.hot .arch-node-box { fill: #142030; stroke-opacity: 1; }
.arch-node.selected .arch-node-box { stroke: #e6edf7; stroke-width: 1.8; stroke-opacity: 1; }
.arch-node.fail .arch-node-box { fill: #2a1318; stroke: #ff7b7b; stroke-opacity: 1; }
.arch-node.warn .arch-node-box { fill: #2a2413; stroke: #f2c75e; stroke-opacity: 1; }
.legend-shape { flex: 0 0 auto; overflow: visible; }
.legend-shape .arch-node-box { fill: #121a24; stroke: #9fb3cc; stroke-width: 1.2; }
.legend-shape .arch-node-box.dashed { stroke-dasharray: 4 2; }
.legend-shape .arch-node-box.dotted { stroke-dasharray: 1.5 2; }
.legend-shape .arch-node-cap { fill: none; stroke: #9fb3cc; stroke-width: 1.1; }
.legend-shape .arch-node-cap.faint { display: none; }
.legend-shape .arch-node-slot { stroke: #9fb3cc; stroke-width: 1.2; }
.legend-shape .arch-node-bar { fill: #9fb3cc; }
.legend-shape.shape-db .arch-node-box, .legend-shape.shape-db .arch-node-cap,
.legend-shape.shape-cache .arch-node-box, .legend-shape.shape-cache .arch-node-cap { stroke: #f5a65b; }
.legend-shape.shape-queue .arch-node-box, .legend-shape.shape-queue .arch-node-slot { stroke: #f2c75e; }
.legend-shape.shape-edge .arch-node-box { stroke: #d99bff; }
.legend-shape.shape-client .arch-node-box { stroke: #7ab8ff; }
.legend-shape.shape-service .arch-node-box { stroke: #2dd4bf; }
.legend-shape.shape-service .arch-node-bar { fill: #2dd4bf; }
.arch-legend-item.shape { gap: 6px; }
.shape-key { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--dim); }
.shape-key span { display: inline-flex; align-items: center; gap: 6px; }

.arch-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.arch-seg button { border: 0; background: transparent; color: var(--dim); padding: 4px 10px; font-size: 11.5px; }
.arch-seg button + button { border-left: 1px solid var(--line); }
.arch-seg button.on { background: var(--accent-dim); color: #dbe8ff; font-weight: 600; }
#arch-expand.on { border-color: var(--accent); color: #cfe0ff; background: var(--accent-dim); }

.path-row-bg { fill: rgba(122, 150, 190, .035); stroke: rgba(122, 150, 190, .12); }
.path-row-title { font-family: var(--sans); font-size: 12.5px; font-weight: 650; fill: #cfe0ff; }
.path-row { transition: opacity .15s ease; }
.path-row.off { opacity: .28; }
.hop-badge circle { fill: #0b111a; stroke: #63a4ff; stroke-width: 1.2; }
.hop-badge text { font-family: var(--mono); font-size: 9px; font-weight: 700; fill: #cfe0ff; }
.arch-edge-group.return .hop-badge circle { stroke: #7ee0c2; }
.arch-edge-group.async .hop-badge circle { stroke: #d6a63f; }

/* expanded canvas: fills the window, above the side panels */
#arch-modal.expanded,
#arch-modal.inline.expanded {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  background: #080d14;
  padding: 0;
}
#arch-modal.expanded .arch-modal { width: 100vw; height: 100vh; max-height: none; border-radius: 0; border: 0; }
body.arch-expanded .chat-pane { z-index: 90; }


/* ============================================================
   Inspector extras: concept cards, hops, connections, terms
   ============================================================ */
.arch-section-h { margin: 14px 0 6px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim-2); }
.arch-panel-block.warn { border-color: #4a2630; background: #1c1013; }
.arch-legend-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.hop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hop { display: flex; gap: 9px; padding: 8px 9px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 7px; background: var(--panel-2); cursor: pointer; }
.hop.sync { border-left-color: #5f9fe8; }
.hop.async { border-left-color: #d6a63f; }
.hop.obs { border-left-color: #7f8da4; }
.hop:hover { border-color: #3a4d67; }
.hop-n { flex: 0 0 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: #0b111a; font-family: var(--mono); font-size: 10px; color: #cfe0ff; }
.hop-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hop-body b { font-size: 12.5px; }
.hop-kind { font-family: var(--mono); font-size: 10px; color: var(--dim-2); }
.hop-detail { font-size: 12px; color: var(--dim); line-height: 1.45; }
.conn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.conn-list li { display: flex; align-items: baseline; gap: 7px; padding: 5px 8px; border-radius: 6px; background: var(--panel-2); cursor: pointer; font-size: 12.5px; }
.conn-list li:hover { background: #1c2533; }
.conn-dir { color: var(--accent); font-family: var(--mono); }
.conn-list .hop-kind { margin-left: auto; }
.read-steps { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: #c6d1e2; line-height: 1.55; }
.read-steps li { margin-bottom: 8px; }
.concept-card, .learn-card { margin-top: 14px; border: 1px solid #2b4470; border-radius: 9px; background: #0e1623; overflow: hidden; }
.concept-head { display: flex; align-items: baseline; gap: 8px; padding: 9px 11px; border-bottom: 1px solid var(--line-soft); background: #111c2d; }
.concept-head b { font-size: 13.5px; }
.concept-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--cb-senior); }
.concept-row { padding: 7px 11px; }
.concept-row + .concept-row { border-top: 1px solid var(--line-soft); }
.concept-row > span { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim-2); margin-bottom: 3px; }
.concept-row p { margin: 0; font-size: 12.5px; color: #c9d5e6; line-height: 1.55; }
.concept-row ul { margin: 0; padding-left: 16px; font-size: 12.5px; color: #c9d5e6; line-height: 1.55; }
.used-by { display: flex; flex-wrap: wrap; gap: 4px; }
.used-by i { font-style: normal; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #17202e; border: 1px solid var(--line); color: #c9d5e6; }
.ask-row .ask-ai-btn, .arch-panel > .ask-ai-btn { margin-top: 12px; }
.term {
  border: 0; background: none; padding: 0; font: inherit; color: inherit;
  text-decoration: underline dotted #6f9bd6; text-underline-offset: 3px; cursor: help;
}
.term:hover { color: #cfe6ff; }
.concept-pop {
  position: fixed; z-index: 120; display: none; width: 320px; padding: 12px;
  border: 1px solid #2b4470; border-radius: 10px; background: #0f1724; box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  font-size: 12.5px; line-height: 1.55; color: #c9d5e6;
}
.concept-pop.on { display: block; }
.concept-pop p { margin: 0 0 6px; }
.concept-pop .dim, .learn-body .dim { color: var(--dim); }
.concept-pop-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.concept-pop-h b { font-size: 13.5px; color: var(--text); }
.concept-pop .btn { margin-top: 8px; }

/* learn / practice / toolkit tabs */
.learn-card { margin-top: 6px; }
.learn-card summary { display: flex; align-items: center; gap: 8px; padding: 9px 11px; cursor: pointer; list-style: none; }
.learn-card summary::-webkit-details-marker { display: none; }
.learn-card summary b { font-size: 13px; flex: 1; }
.learn-card[open] summary { border-bottom: 1px solid var(--line-soft); background: #111c2d; }
.learn-meta { font-size: 11px; color: var(--dim-2); }
.learn-body { padding: 4px 0 10px; }
.learn-body > p { margin: 6px 11px; font-size: 12.5px; }
.learn-body > .used-by { padding: 0 11px; }
.learn-body .ask-row { padding: 0 11px; }
.learn-nodes { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 11px 2px; }
.quiz-progress { height: 5px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.quiz-progress div { height: 100%; background: var(--green); transition: width .2s; }
.quiz-stats { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); margin: 5px 0 10px; }
.quiz-card { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #0f151e; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.quiz-tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--cb-senior); }
.quiz-q { font-size: 14px; font-weight: 600; line-height: 1.5; }
.quiz-a { font-size: 12.5px; color: #c9d5e6; line-height: 1.6; padding: 10px; border-radius: 8px; background: #0b111a; border: 1px solid var(--line-soft); width: 100%; }
.quiz-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calc-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--dim-2); }
.calc-grid input { background: #0b111a; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: var(--mono); font-size: 12.5px; outline: none; }
.calc-grid input:focus { border-color: var(--accent); }
.calc-out { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.calc-out div { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 6px 9px; border-radius: 6px; background: var(--panel-2); }
.calc-out span { font-size: 12px; color: var(--dim); }
.calc-out b { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.calc-out i { grid-column: 1 / -1; font-style: normal; font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); }
.num-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.num-table td { padding: 5px 8px; border-bottom: 1px solid var(--line-soft); color: #c9d5e6; }
.num-table td:last-child { text-align: right; font-family: var(--mono); color: var(--text); white-space: nowrap; }
.gloss-list { margin-top: 8px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.help-card { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.help-card b { font-size: 13px; }
.help-card p { margin: 4px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.icon-btn { width: 28px; height: 26px; padding: 0; display: inline-grid; place-items: center; font-size: 15px; line-height: 1; }

/* ============================================================
   Design page views: ① Brief | ② Map | Draw | Compare
   ============================================================ */
.design-views { display: none; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #0b111a; }
body.mode-design .design-views { display: flex; }
.design-views button { display: flex; flex-direction: column; align-items: flex-start; gap: 0; border: 0; background: transparent; color: var(--dim); border-radius: 7px; padding: 5px 14px; line-height: 1.25; }
.design-views button b { font-size: 13px; }
.design-views button span { font-size: 10.5px; color: var(--dim-2); }
.design-views button:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.design-views button.on { background: var(--accent-dim); color: #dbe8ff; box-shadow: inset 0 0 0 1px #2b4470; }
.design-views button.on span { color: #a9c6f0; }
.design-views button:disabled { opacity: .4; cursor: not-allowed; }
.design-views-arrow { font-style: normal; color: var(--dim-2); font-size: 12px; }

.brief-view { display: none; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }
.design-stage.view-brief .brief-view { display: block; }
.design-stage.view-brief .design-stage-main,
.design-stage.view-brief .study-pane,
.design-stage.view-brief .study-reopen { display: none !important; }
.brief-grid { display: grid; grid-template-columns: minmax(300px, 440px) minmax(0, 720px); gap: 22px; justify-content: center; padding: 22px 24px 60px; }
.brief-col.left { position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 160px); overflow-y: auto; padding-top: 22px; margin-top: -22px; }
.brief-col.right .steps-head { margin-top: 0; }
.brief-how { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 12.5px; color: var(--dim); }
.brief-how b { color: var(--text); }
.brief-how ol { margin: 6px 0 8px; padding-left: 18px; line-height: 1.6; }
.brief-how > span { font-size: 12px; }
.full-prompt { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.full-prompt summary { cursor: pointer; font-size: 12px; color: #8ec5ff; }
.full-prompt .body-text { margin-top: 8px; font-size: 12.5px; color: #c6d1e2; white-space: pre-wrap; }
.inline-calc { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: #0b111a; }
.inline-calc summary { cursor: pointer; padding: 7px 10px; font-size: 12px; color: #8ec5ff; }
.inline-calc > div { padding: 0 10px 10px; }
.verify-cta { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 14px; border: 1px dashed #34507a; border-radius: 11px; background: #0e1623; }
.verify-cta > div { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.verify-cta span { font-size: 12.5px; color: var(--dim); }
.design-stage.view-map .brief-view { display: none; }
.design-stage.view-draw .brief-view,
.design-stage.view-draw .design-stage-main,
.design-stage.view-draw .study-pane,
.design-stage.view-draw .study-reopen,
.design-stage.view-compare .brief-view,
.design-stage.view-compare .study-pane,
.design-stage.view-compare .study-reopen { display: none !important; }
.design-stage.view-draw .board-stage,
.design-stage.view-compare .board-stage { display: flex; }
.design-stage.view-compare .design-stage-main { order: 1; flex: 1 1 0; min-width: 0; border-right: 1px solid var(--line); }
.design-stage.view-compare .board-stage { order: 2; flex: 1 1 0; min-width: 0; }
.design-stage.view-compare .board-notes { width: 180px; }
.answer-row { margin-bottom: 10px; }
.answer-row.empty em { font-size: 12px; color: var(--dim-2); }
.answer-h { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 650; margin-bottom: 4px; }
.answer-h span { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); font-family: var(--mono); font-size: 10px; color: var(--dim); }
.answer-row pre { margin: 0; white-space: pre-wrap; font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: #c9d5e6; padding: 8px 10px; border-radius: 7px; background: #0b111a; border: 1px solid var(--line-soft); }
.answer-score { display: flex; gap: 10px; align-items: center; margin: 0 0 12px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.answer-score p { margin: 0; font-size: 12px; color: var(--dim); }
.answer-score .score-ring { flex: 0 0 46px; height: 46px; padding-top: 9px; }
.answer-score .score-ring b { font-size: 17px; }
@media (max-width: 1180px) {
  .brief-grid { grid-template-columns: minmax(0, 760px); }
  .brief-col.left { position: static; max-height: none; overflow: visible; padding-top: 0; margin-top: 0; }
}
.ask-examples li { padding-left: 34px; }

/* map view: the canvas must shrink so the side panel stays on screen */
.design-stage-main, #arch-modal.inline, #arch-modal.inline .arch-modal { min-width: 0; }
#arch-modal.inline .arch-head { flex-wrap: wrap; row-gap: 6px; }
.arch-head .btn { white-space: nowrap; }

/* ============================================================
   Declutter pass
   ============================================================ */
/* "More" menu for secondary tools */
.more-menu { position: relative; }
.more-list {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 210px;
  padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.more-menu.open .more-list { display: flex; flex-direction: column; }
.more-list button { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--text); text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.more-list button:hover { background: var(--panel-2); }

/* collapsible question list */
body.sidebar-hidden .app { grid-template-columns: 0 0 minmax(0, 1fr); }
body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
body.sidebar-hidden .sidebar, body.sidebar-hidden #resize-sidebar { display: none; }
#btn-sidebar.on { color: var(--dim-2); }

/* one-line legend that never pushes the canvas down */
.arch-legend { flex-wrap: nowrap; overflow-x: auto; gap: 10px; padding: 6px 14px; scrollbar-width: none; }
.arch-legend::-webkit-scrollbar { display: none; }
.arch-legend-item, .arch-edge-key { white-space: nowrap; font-size: 9px; }
#arch-modal.inline .arch-head { flex-wrap: nowrap; gap: 6px; }
#arch-modal.inline .arch-head-copy { flex: 1 1 auto; min-width: 120px; }
#arch-modal.inline .arch-sub { max-width: 100%; }
#arch-modal.inline .arch-head > .spacer { display: none; }
.arch-select { max-width: 150px; }

/* inspector lives in the Map side panel */
.study-inspect { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.study-inspect[hidden] { display: none; }
.study-pane .arch-side,
#arch-modal.inline .study-pane .arch-side {
  position: static; transform: none; width: auto; flex: 1; min-height: 0; overflow-y: auto;
  border: 0; box-shadow: none; background: transparent; visibility: visible;
}
.study-pane .arch-tabs { position: sticky; top: 0; background: var(--panel); padding: 8px 12px; }
.study-pane .arch-tabs button { flex: 0 0 auto; }
.study-pane .arch-side-close { display: none !important; }
.study-body[hidden] { display: none; }
.study-top { gap: 6px; }

/* brief: timer sits with the steps, cheat sheet is tucked away */
.steps-timer { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.brief-numbers { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 12px; }
.brief-numbers summary { cursor: pointer; padding: 10px 0; font-size: 12.5px; color: var(--dim); }
.brief-numbers[open] { padding-bottom: 10px; }
.brief-numbers .study-h:first-of-type { margin-top: 2px; }
.stage-prompts { font-size: 11.5px; }


/* coding page with both AI panels open: give the editor room by tucking the question list away */
@media (max-width: 1799px) {
  body.chat-open.ai-hint-open:not(.mode-design) .sidebar,
  body.chat-open.ai-hint-open:not(.mode-design) #resize-sidebar { display: none; }
  body.chat-open.ai-hint-open:not(.mode-design) .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
}
.chat-toggle kbd { background: transparent; }

/* Brief: the answer column gets most of the screen */
.brief-grid { grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); justify-content: stretch; gap: 28px; padding: 22px 32px 60px; max-width: 1680px; margin: 0 auto; }
.brief-col.left .ask-card { padding: 14px 15px; }
.brief-col.left .ask-main { font-size: 14px; }
.brief-col.right { min-width: 0; }
.brief-col.right .stage-head { padding: 13px 16px; }
.brief-col.right .stage-title { font-size: 15px; }
.brief-col.right .stage-body { padding: 2px 16px 16px; }
.brief-col.right .stage-goal { font-size: 14px; }
.brief-col.right .stage-prompts { font-size: 13px; columns: 2; column-gap: 28px; }
.brief-col.right .stage-answer { font-size: 14px; line-height: 1.7; min-height: 200px; padding: 14px 16px; }
.brief-col.right .tip { font-size: 13.5px; }
.brief-col.right .eval-copy, .brief-col.right .eval-list, .brief-col.right .rubric-row p { font-size: 13.5px; }
@media (max-width: 1180px) {
  .brief-grid { grid-template-columns: minmax(0, 1fr); padding: 18px 20px 60px; }
  .brief-col.right .stage-prompts { columns: 1; }
}

/* pin each region to its column so hiding the sidebar never shifts the others */
.app > .sidebar { grid-column: 1; grid-row: 1; }
.app > #resize-sidebar { grid-column: 2; grid-row: 1; }
.app > .main { grid-column: 3; grid-row: 1; }
.app > #resize-chat { grid-column: 4; grid-row: 1; }
.app > .chat-pane { grid-column: 5; grid-row: 1; }
@media (max-width: 980px) {
  .app > .main { grid-column: 1; }
  body.sidebar-hidden .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 1fr; }
}
body.sidebar-drawer .sidebar {
  display: flex !important;
  position: fixed; top: 52px; left: 0; bottom: 0; z-index: 60;
  width: min(var(--sidebar-w, 320px), 86vw);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 32px rgba(0, 0, 0, .45);
}

/* Brief: Task column can be hidden for more writing room */
.brief-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: -4px; }
.brief-col-head b { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim-2); }
.brief-grid.task-hidden { grid-template-columns: minmax(0, 1480px); justify-content: center; }
.steps-head .btn { align-self: center; }



/* per-component risk: what goes wrong without it, and if it breaks */
.risk { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.risk-row { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.risk-row > span { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 3px; }
.risk-row p { margin: 0; font-size: 12.5px; line-height: 1.55; color: #c9d5e6; }
.risk-row p + p { margin-top: 5px; }
.risk-row.without { border-left: 3px solid var(--cb-mid); }
.risk-row.without > span { color: var(--cb-mid); }
.risk-row.breaks { border-left: 3px solid #ff7b7b; }
.risk-row.breaks > span { color: #ff8a8a; }
.risk-hits { font-size: 11.5px !important; color: var(--dim) !important; }
.risk-protect b { color: #7ee0c2; }
.risk.compact { margin-top: 8px; gap: 5px; }
.risk.compact .risk-row { padding: 6px 8px; }
.risk.compact .risk-row p { font-size: 12px; }
.path-row-title { cursor: pointer; }
.path-row-title:hover { fill: #ffffff; text-decoration: underline; }

/* readable component type, on its own line */
.arch-node-badge { font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .14em; fill: var(--node-color); opacity: 1; }
.arch-node-label { font-size: 13.5px; }
.arch-node-sub { font-size: 10.5px; fill: #8796ad; }

/* a component glows when traffic arrives */
.arch-node.pulse .arch-node-box { animation: node-arrive .6s ease-out; }
@keyframes node-arrive {
  0% { stroke-width: 1.3; filter: none; }
  25% { stroke-width: 3; stroke-opacity: 1; filter: drop-shadow(0 0 7px var(--node-color)); }
  100% { stroke-width: 1.3; filter: none; }
}
.arch-node.selected.pulse .arch-node-box, .arch-node.hot.pulse .arch-node-box { animation: node-arrive .6s ease-out; }
@media (prefers-reduced-motion: reduce) { .arch-node.pulse .arch-node-box { animation: none; } }
/* while the map sits idle the packets fade out and the highlight pulses stop, so the page does no work */
#arch-modal .arch-packet { transition: opacity .35s ease; }
#arch-modal.motion-off .arch-packet { opacity: 0; }
#arch-modal.motion-off .arch-node.hot .arch-node-box,
#arch-modal.motion-off .arch-node.pulse .arch-node-box,
#arch-modal.motion-off .arch-edge-group.flowing .arch-packet .packet-halo { animation: none; }

.study-pane { --study-w: 380px; }

/* ============================================================
   Buttons: one consistent size and feel across the app
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 5px 13px; border-radius: 8px;
  font-size: 13px; font-weight: 550; line-height: 1.2;
  background: #151c28; border: 1px solid #2a3446; color: #dfe7f3;
  transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.btn:hover:not(:disabled) { background: #1b2433; border-color: #3a4760; color: #fff; }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover:not(:disabled) { background: #161e2b; border-color: #2a3446; color: var(--text); }
.btn.primary { background: linear-gradient(180deg, #74b0ff, #5596f5); border-color: #5c9cf8; color: #04102a; font-weight: 650; box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 4px 14px rgba(70, 140, 255, .22); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #84baff, #619ff7); color: #04102a; filter: none; }
.btn.run { background: linear-gradient(180deg, #4ae0c9, #2dd4bf); border-color: #2dd4bf; color: #04221c; font-weight: 650; box-shadow: 0 1px 0 rgba(255,255,255,.28) inset, 0 4px 14px rgba(45, 212, 191, .22); }
.btn.run:hover:not(:disabled) { background: linear-gradient(180deg, #62ead4, #3ddec8); color: #04221c; filter: none; }
.btn.tiny { min-height: 26px; padding: 3px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.icon-btn { min-height: 28px; width: 30px; padding: 0; }
.topbar { gap: 8px; }
.topbar .btn { min-height: 34px; }

/* ============================================================
   Canvas: slim header, floating toolbar, overlay legend
   ============================================================ */
#arch-modal.inline .arch-head { padding: 12px 18px 10px; border-bottom: 1px solid var(--line-soft); background: var(--panel); }
.arch-head h3 { font-size: 17px; font-weight: 650; }
#arch-modal.inline .arch-sub { font-size: 12.5px; white-space: normal; }

.arch-toolbar {
  position: absolute; top: 12px; right: 12px; z-index: 4;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
  max-width: calc(100% - 24px);
}
.tb-group {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid #2a3446; border-radius: 10px;
  background: rgba(14, 20, 30, .88); backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.tb-group button {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent; color: #9fb0c8;
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.tb-group button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tb-group button:hover { background: #1b2433; color: #fff; }
.tb-group button.on { background: #233a5e; color: #e4eeff; box-shadow: inset 0 0 0 1px #34568a; }
.tb-group.zoom button { width: 28px; padding: 0; justify-content: center; font-size: 15px; }
.tb-group .arch-zoom-label { min-width: 42px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.tb-group .tb-icon { width: 30px; padding: 0; justify-content: center; font-size: 14px; }
#arch-expand.on { background: #233a5e; color: #e4eeff; }

#arch-modal .arch-canvas .arch-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 4;
  display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: min(620px, calc(100% - 24px));
  padding: 8px 11px; border: 1px solid #2a3446; border-radius: 10px;
  background: rgba(14, 20, 30, .88); backdrop-filter: blur(8px);
  overflow: visible;
}
#arch-modal .arch-canvas .arch-legend .arch-legend-item,
#arch-modal .arch-canvas .arch-legend .arch-edge-key { font-size: 9.5px; color: #9fb0c8; }

/* ============================================================
   Components: tinted card, icon chip, depth
   ============================================================ */
.arch-node { filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .45)); }
.arch-node .arch-node-box {
  fill: color-mix(in srgb, var(--node-color) 9%, #0d131c);
  stroke: color-mix(in srgb, var(--node-color) 55%, #2a3446);
  stroke-opacity: 1; stroke-width: 1.2;
}
.arch-node .arch-node-cap { stroke: color-mix(in srgb, var(--node-color) 60%, #2a3446); }
.arch-node:hover .arch-node-box { fill: color-mix(in srgb, var(--node-color) 15%, #111925); stroke: var(--node-color); }
.arch-node .icon-chip { fill: color-mix(in srgb, var(--node-color) 20%, #0d131c); stroke: color-mix(in srgb, var(--node-color) 45%, transparent); stroke-width: 1; }
.arch-node .icon-glyph { fill: none; stroke: var(--node-color); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.arch-node .arch-node-badge { font-size: 8.5px; letter-spacing: .14em; opacity: .9; }
.arch-node .arch-node-label { font-family: var(--sans); font-size: 13.5px; font-weight: 650; fill: #eef3fb; }
.arch-node .arch-node-sub { font-family: var(--mono); font-size: 10px; fill: #8a99b0; }
.arch-node.selected .arch-node-box { stroke: #f2f6fc; stroke-width: 2; }
.arch-node.hot .arch-node-box { fill: color-mix(in srgb, var(--node-color) 16%, #111925); stroke: var(--node-color); }
.arch-node.warn .arch-node-box { fill: #2a2413; stroke: #f2c75e; }
.arch-node.dim { opacity: .18; filter: none; }

/* Inspect tab: a dot when the canvas selection changed */
.study-tab.has-new { position: relative; color: var(--text); }
.study-tab.has-new::after { content: ""; position: absolute; top: 4px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); }

/* design view switch: match the new buttons */
.design-views { border-radius: 11px; }
.design-views button { border-radius: 8px; padding: 5px 14px; }
/* keep the diagram clear of the floating toolbar and legend */
#arch-modal .arch-canvas #arch-svg { box-sizing: border-box; padding: 54px 10px 70px; }

/* plain-English terms: collapsed strip at the top of the Map side panel */
.terms-strip { flex: 0 0 auto; border-bottom: 1px solid var(--line); background: #0f1622; max-height: 46%; overflow-y: auto; }
.terms-strip[hidden] { display: none; }
.terms-strip summary { display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 600; color: #cfe0ff; }
.terms-strip summary::-webkit-details-marker { display: none; }
.terms-strip summary::before { content: "▸"; font-size: 10px; color: var(--dim-2); transition: transform .12s; }
.terms-strip[open] summary::before { transform: rotate(90deg); }
.terms-strip summary i { font-style: normal; font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; }
.terms-list { margin: 0; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 5px; }
.term-row { padding: 7px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line-soft); }
.term-row.has-nodes { cursor: pointer; }
.term-row.has-nodes:hover { border-color: #34507a; }
.term-row dt { font-size: 12.5px; font-weight: 650; color: var(--text); }
.term-row dd { margin: 2px 0 0; font-size: 12px; line-height: 1.5; color: #b9c7da; }

/* difficulty labels */
.diff-tag { margin-left: 8px; padding: 1px 7px; border-radius: 99px; font-size: 9.5px; letter-spacing: .08em; border: 1px solid; }
.diff-easy { color: var(--cb-junior); border-color: #1f4a45; background: #0d2422; }
.diff-medium { color: var(--cb-mid); border-color: #4a4021; background: #211d0f; }
.diff-hard { color: #ff9a7a; border-color: #4a2b21; background: #241411; }
.group-h.diff-h { border: 0; background: none; }
.group-h.diff-h.diff-easy { color: var(--cb-junior); }
.group-h.diff-h.diff-medium { color: var(--cb-mid); }
.group-h.diff-h.diff-hard { color: #ff9a7a; }
.design-item .lvl.diff-easy, .design-item .lvl.diff-medium, .design-item .lvl.diff-hard { min-width: 22px; text-align: center; }

/* ============================================================
   Scrollbars: one slim, quiet style everywhere
   The thumb sits inside a transparent border so it reads as a
   6px pill with breathing room, and brightens on hover / drag.
   ============================================================ */
:root {
  --sb-size: 10px;
  --sb-thumb: #263041;
  --sb-thumb-hover: #3a475e;
  --sb-thumb-active: #50638a;
}
::-webkit-scrollbar { width: var(--sb-size); height: var(--sb-size); }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--sb-thumb);
  border: 2px solid transparent;
  border-radius: 99px;
  background-clip: padding-box;
  min-height: 36px;
  min-width: 36px;
}
:hover::-webkit-scrollbar-thumb { background-color: #2e3a4f; }
::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
::-webkit-scrollbar-thumb:active { background-color: var(--sb-thumb-active); }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

/* narrow columns get a narrower bar */
.list::-webkit-scrollbar,
.chat-log::-webkit-scrollbar,
.console-out::-webkit-scrollbar,
.terms-strip::-webkit-scrollbar,
.arch-side::-webkit-scrollbar,
.more-list::-webkit-scrollbar { width: 8px; }

/* browsers without ::-webkit-scrollbar (Firefox) use the standard properties */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
  *:hover { scrollbar-color: var(--sb-thumb-hover) transparent; }
}

/* the code editor and its line gutter scroll together; keep the gutter bar hidden */

/* read path vs write path labels */
.rw-tag { font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .1em; }
.rw-tag.rw-write { fill: #f6b86b; }
.rw-tag.rw-read { fill: #7fd6c4; }
.rw-tag.rw-bg { fill: #a9b1c7; }
.rw-pill { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 99px; font-size: 9px; letter-spacing: .1em; border: 1px solid; }
.rw-pill.rw-write { color: #f6b86b; border-color: #5a4220; background: #241a0e; }
.rw-pill.rw-read { color: #7fd6c4; border-color: #1f4a45; background: #0d2422; }
.rw-pill.rw-bg { color: #a9b1c7; border-color: #343a4c; background: #171a23; }
.arch-based { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--border, #262a36); }
.arch-based p { margin: 4px 0 6px; font-size: 13px; line-height: 1.5; color: var(--text, #e6e8ef); }
.arch-based ul { margin: 0; padding-left: 16px; font-size: 12.5px; line-height: 1.7; }
.arch-based a { color: #8fb4ff; text-decoration: none; }
.arch-based a:hover { text-decoration: underline; }

/* ============================================================
   Canvas text: large, high-contrast, always on top
   ============================================================ */
#arch-svg text { text-rendering: geometricPrecision; }
#arch-svg .arch-node .arch-node-label { font-family: var(--sans); font-size: 14px; font-weight: 650; fill: #f4f7fc; }
#arch-svg .arch-node .arch-node-sub { font-family: var(--sans); font-size: 11.5px; font-weight: 500; fill: #b4c1d4; }
#arch-svg .arch-node .arch-node-badge { font-size: 9.5px; letter-spacing: .1em; opacity: 1; }
#arch-svg .arch-layer { font-size: 12px; font-weight: 700; letter-spacing: .14em; opacity: 1; }

/* connection labels sit in their own top layer with a dark outline */
#arch-svg .edge-labels { pointer-events: auto; }
#arch-svg .edge-label-wrap { cursor: pointer; transition: opacity .14s ease; }
#arch-svg .edge-label-wrap .arch-edge-label {
  font-family: var(--sans); font-size: 11.5px; font-weight: 600;
  paint-order: stroke; stroke: #070b12; stroke-width: 5px; stroke-linejoin: round;
}
#arch-svg .edge-label-wrap.sync .arch-edge-label { fill: #b9d9ff; }
#arch-svg .edge-label-wrap.async .arch-edge-label { fill: #f6d68c; }
#arch-svg .edge-label-wrap.return .arch-edge-label { fill: #a8f2de; }
#arch-svg .edge-label-wrap.dim { opacity: .12; }
#arch-svg .edge-label-wrap.hot .arch-edge-label,
#arch-svg .edge-label-wrap.flowing .arch-edge-label,
#arch-svg .edge-label-wrap.peek .arch-edge-label { fill: #ffffff; }
/* labels that could not find a free spot appear when their connection is hovered or highlighted */
#arch-svg .edge-label-wrap.crowded .arch-edge-label { opacity: 0; }
#arch-svg .edge-label-wrap.crowded.hot .arch-edge-label,
#arch-svg .edge-label-wrap.crowded.flowing .arch-edge-label,
#arch-svg .edge-label-wrap.crowded.peek .arch-edge-label { opacity: 1; }

/* hop numbers in the User actions view */
#arch-svg .hop-badge circle { fill: #0b111a; stroke: #63a4ff; stroke-width: 1.6; }
#arch-svg .hop-badge text { font-family: var(--sans); font-size: 11.5px; font-weight: 800; fill: #e6efff; }
#arch-svg .edge-label-wrap.async .hop-badge circle { stroke: #e3b24f; }
#arch-svg .edge-label-wrap.return .hop-badge circle { stroke: #7ee0c2; }
#arch-svg .path-row-title { font-size: 14px; font-weight: 700; fill: #e4eeff; }
#arch-svg .rw-tag { font-size: 10.5px; }

/* the pan hint */
.arch-more {
  position: absolute; right: 14px; bottom: 14px; z-index: 4; display: none;
  padding: 6px 11px; border-radius: 99px; border: 1px solid #2a3446;
  background: rgba(14, 20, 30, .9); color: #c3d2e8; font-size: 12px; font-weight: 600; pointer-events: none;
}
.arch-more.on { display: block; }

/* Brief: the Task column grows on large screens */
.brief-grid { grid-template-columns: clamp(320px, 30vw, 560px) minmax(0, 1fr); max-width: 1920px; }
@media (max-width: 1180px) { .brief-grid { grid-template-columns: minmax(0, 1fr); } }

/* ============================================================
   No overlap at any width: panels dock side by side, toolbars never wrap
   ============================================================ */
/* the chat is always its own column; it only floats over the page on phone-sized screens */
@media (max-width: 1100px) {
  body.chat-open .app { grid-template-columns: minmax(0, var(--sidebar-w, 320px)) 7px minmax(0, 1fr) 7px var(--chat-w, 380px); }
  body.chat-open #resize-chat { display: block; }
  .chat-pane { position: static; width: auto; box-shadow: none; z-index: auto; }
  body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
}
@media (max-width: 980px) {
  .app, body.sidebar-hidden .app { grid-template-columns: 0 0 minmax(0, 1fr); }
  body.chat-open .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
  .app > .main { grid-column: 3; }
  .workspace > .resizer { display: none; }
  #resize-results { display: block; }
}
@media (max-width: 640px) {
  body.chat-open .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr); }
  body.chat-open #resize-chat { display: none; }
  body.chat-open .chat-pane { position: fixed; inset: 52px 0 0 0; z-index: 60; }
}

/* question + editor stack when the middle column is too narrow for both */
.app > .main { container: main / inline-size; }
@media (min-width: 1280px) {
@container main (max-width: 1040px) {
  .workspace.ai-open {
    grid-template-columns: minmax(0, 1fr) 7px min(var(--ai-w, 360px), 40%) !important;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }
  .workspace.ai-open > .pane.left { grid-column: 1; grid-row: 1; border-bottom: 1px solid var(--line); }
  .workspace.ai-open > #resize-panes { display: none; }
  .workspace.ai-open > .pane.right { grid-column: 1; grid-row: 2; }
  .workspace.ai-open > #resize-ai { grid-column: 2; grid-row: 1 / 3; }
  .workspace.ai-open > .ai-pane { grid-column: 3; grid-row: 1 / 3; min-width: 0; }
}
}
@container main (max-width: 720px) {
  .workspace, .workspace.ai-open { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .workspace > .resizer, .workspace > .ai-pane { display: none !important; }
  .workspace > .pane.left { border-bottom: 1px solid var(--line); }
}

/* top bars: one line, the title shrinks first, then low-priority labels drop away */
.topbar, .global-nav, .chat-head { flex-wrap: nowrap; min-width: 0; }
.topbar > *, .global-nav > * { flex-shrink: 0; }
.topbar > .spacer, .global-nav > .spacer { flex: 1 1 0; min-width: 0; }
.topbar > .page-title { flex: 0 1 auto; min-width: 60px; overflow: hidden; }
.topbar .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn, .global-nav .btn, .page-nav button, .design-views button, .chat-head .btn { white-space: nowrap; }
.chat-head-copy { flex: 1 1 auto; overflow: hidden; }
.chat-head .btn { flex-shrink: 0; }
.chat-ctx { max-width: 100%; }
@container main (max-width: 900px) {
  .topbar kbd { display: none; }
  .design-views button span, .design-views-arrow { display: none; }
}
@container main (max-width: 760px) {
  .topbar #btn-notes { display: none; }
  .topbar .sig { display: none; }
}
@container main (max-width: 560px) {
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar > .page-title { display: none; }
  .topbar .btn { padding: 6px 9px; }
}
@media (max-width: 1180px) {
  .global-nav kbd { display: none; }
}
@media (max-width: 860px) {
  #btn-help { display: none; }
}

/* canvas toolbar: Show, zoom, Fit / full screen, and ⚙ settings on one row.
   On a narrow canvas only zoom and ⚙ stay; everything else is in the settings sheet. */
.arch-toolbar { flex-wrap: nowrap; }
.arch-canvas { container: canvas / inline-size; }
.tb-gear {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 36px; height: 36px; padding: 0; border: 1px solid #2a3446; border-radius: 10px;
  background: rgba(14, 20, 30, .9); backdrop-filter: blur(8px); color: #c9d6ea;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.tb-gear svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tb-gear:hover, .tb-gear.on { background: #233a5e; border-color: #34568a; color: #fff; }
/* the legend leaves room for the "Drag to see more" hint in the other corner */
#arch-modal .arch-canvas .arch-legend { max-width: min(620px, calc(100% - 210px)); }
@container canvas (max-width: 639px) {
  .arch-toolbar .tb-wide, .tb-group .arch-zoom-label { display: none; }
  .arch-toolbar { top: 8px; right: 8px; gap: 8px; }
  .tb-group.zoom { padding: 3px; }
  .tb-group.zoom button { width: 42px; height: 42px; font-size: 21px; }
  .tb-gear { width: 50px; height: 50px; border-radius: 12px; }
  .tb-gear svg { width: 24px; height: 24px; }
  #arch-modal .arch-canvas #arch-svg { padding: 4px; }
  .arch-more.on { display: none; }
  /* the legend waits until it is turned on in ⚙ settings */
  #arch-modal .arch-canvas .arch-legend { display: none; left: 8px; right: 8px; bottom: 8px; max-width: none; max-height: 42%; overflow: auto; }
}
#arch-modal .arch-canvas.legend-on .arch-legend { display: flex; }
#arch-modal .arch-canvas.legend-off .arch-legend { display: none; }

/* settings: a drop-down under ⚙ on a computer, a bottom sheet on a phone */
.tb-scrim { position: fixed; inset: 0; z-index: 129; background: transparent; }
.tb-scrim[hidden], .tb-menu-panel[hidden] { display: none; }
.tb-menu-panel {
  position: fixed; z-index: 130; width: 330px; max-width: calc(100vw - 16px);
  display: flex; flex-direction: column; gap: 14px; padding: 12px 14px 16px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid #2a3446; border-radius: 14px; background: #0f1622;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
}
.tb-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tb-menu-head b { font-size: 15px; }
.tb-menu-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); color: var(--dim); font-size: 13px; }
.tb-menu-close:hover { color: var(--text); }
.tb-sec { display: flex; flex-direction: column; gap: 7px; }
.tb-sec-h { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim-2); }
.tb-seg { display: flex; gap: 3px; padding: 3px; border: 1px solid #2a3446; border-radius: 11px; background: #0b111a; }
.tb-seg button {
  flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent;
  color: #a9b8cf; font-size: 13px; font-weight: 550; line-height: 1.2; text-align: center;
}
.tb-seg button svg { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tb-seg button:hover { color: #fff; background: #172131; }
.tb-seg button.on { background: #233a5e; color: #eef4ff; box-shadow: inset 0 0 0 1px #34568a; }
.tb-note { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--dim); }
.tb-menu-panel .tb-narrow { display: none; }
.tb-menu-panel.narrow .tb-narrow { display: flex; }
@media (max-width: 760px), (max-height: 520px) {
  .tb-scrim { background: rgba(4, 7, 12, .55); }
  .tb-menu-panel {
    top: auto !important; right: 0 !important; left: 0; bottom: 0; width: 100%; max-width: none;
    max-height: 85vh !important; max-height: 85dvh !important;
    gap: 16px; padding: 6px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; border-bottom: 0;
    animation: sheet-up .2s cubic-bezier(.2, .8, .2, 1);
  }
  .tb-menu-panel::before { content: ""; align-self: center; flex: 0 0 auto; width: 44px; height: 5px; border-radius: 99px; background: #3a4760; margin: 4px 0 -4px; }
  .tb-seg button { min-height: 48px; font-size: 14.5px; }
  .tb-menu-close { width: 44px; height: 44px; font-size: 15px; }
  .tb-note { font-size: 13.5px; }
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }

/* with the chat open on a laptop screen, the question list tucks behind ☰ so the work area keeps its room */
@media (max-width: 1279px) {
  body.chat-open .sidebar, body.chat-open #resize-sidebar { display: none; }
  body.chat-open .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
}
@media (max-width: 980px) {
  body.chat-open .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
}
@media (max-width: 640px) {
  body.chat-open .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr); }
}

/* ============================================================
   AWS page: canvas on the left, guide panel on the right
   ============================================================ */
.aws-stage {
  display: none;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #080d14;
}
body.mode-aws .workspace { display: none; }
body.mode-aws .aws-stage { display: flex; }
body.mode-aws #btn-run,
body.mode-aws #btn-run-2,
body.mode-aws .topbar #btn-notes,
body.mode-aws .topbar #btn-hint,
body.mode-aws .topbar #btn-graph { display: none; }
body.mode-aws .side-code { display: none; }
.side-aws { display: none; flex: 1; min-height: 0; flex-direction: column; }
body.mode-aws .side-aws { display: flex; }

.aws-canvas { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; }
.aws-canvas > #arch-modal { flex: 1; min-height: 0; }
.aws-stage > #resize-aws { flex: 0 0 7px; width: 7px; margin-right: -4px; }
.study-pane.aws-pane { --study-w: var(--aws-w, 460px); }
.aws-stage.pane-collapsed .aws-pane,
.aws-stage.pane-collapsed #resize-aws { display: none; }
.aws-stage.pane-collapsed #aws-reopen { display: block; }
.aws-body { padding: 14px 16px 48px; }
.aws-note { margin: -2px 0 8px; font-size: 12px; color: var(--dim); line-height: 1.5; }
.aws-tab-n { font-style: normal; margin-left: 6px; font-family: var(--mono); font-size: 10px; color: var(--green); }

/* sidebar */
.group-h.aws-group { color: #ffb37a; }
.group-h.aws-group-genai { color: #ff9ac2; }
.group-h.aws-group-start { color: var(--cb-senior); }
.aws-item .lvl.aws-lvl, .aws-svc-hit .lvl.aws-lvl { min-width: 22px; text-align: center; color: var(--dim-2); }
.aws-svc-hit { cursor: pointer; }
.aws-svc-hit .t small { margin-left: 4px; font-size: 10.5px; color: var(--dim-2); }
.aws-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--cat, #7ab8ff); justify-self: center; flex: 0 0 auto; }

/* service chips and inline service links */
.svc-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid color-mix(in srgb, var(--cat) 45%, #2a3446);
  background: color-mix(in srgb, var(--cat) 12%, #0e141d);
  color: color-mix(in srgb, var(--cat) 70%, #f2f6fc);
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.svc-chip::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--cat); }
.svc-chip:hover { background: color-mix(in srgb, var(--cat) 22%, #111925); color: #fff; }
/* the unabbreviated name sits inside the pill, quieter than the acronym */
.svc-expand { font-weight: 400; opacity: .72; margin-left: 4px; }
.svc-link {
  border: 0; background: none; padding: 0; font: inherit; color: inherit;
  text-decoration: underline; text-decoration-color: #ffb37a; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer;
}
.svc-link:hover { color: #ffd7b8; }
.aws-chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* Guide: hero */
.aws-hero { padding: 14px; border: 1px solid #4a3622; border-radius: 12px; background: linear-gradient(160deg, #1d1610, #0f141d 60%); }
.aws-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #ffb37a; margin-bottom: 6px; }
.aws-question { margin: 0 0 8px; font-size: 16px; font-weight: 650; line-height: 1.4; color: var(--text); }
.aws-summary { margin: 0 0 12px; font-size: 13px; line-height: 1.65; color: #cdd7e6; }
.aws-hero-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* Guide: decision steps */
.aws-decide { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: aws-step; }
.aws-decide li { position: relative; padding: 10px 12px 10px 38px; border: 1px solid var(--line); border-radius: 9px; background: #0f151e; counter-increment: aws-step; }
.aws-decide li::before {
  content: counter(aws-step); position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; background: #1d2633; font-family: var(--mono); font-size: 10px; color: #cfe0ff;
}
.aws-if { font-size: 13px; line-height: 1.5; color: var(--text); font-weight: 550; }
.aws-if i { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--dim-2); letter-spacing: .1em; text-transform: uppercase; margin-right: 6px; }
.aws-then { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 6px; }
.aws-then > i { font-style: normal; color: #ffb37a; margin-right: 2px; }
.aws-decide p { margin: 6px 0 0; font-size: 12px; line-height: 1.55; color: var(--dim); }

/* Guide: comparison table */
.aws-wide { margin-left: auto; font-size: 11px; letter-spacing: 0; text-transform: none; font-family: var(--sans); }
.aws-compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #0d131c; }
.aws-compare { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 11.5px; line-height: 1.45; }
.aws-compare th, .aws-compare td { padding: 7px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.aws-compare thead th { position: sticky; top: 0; background: #121a26; border-bottom: 1px solid var(--line); }
.aws-compare tbody th { position: sticky; left: 0; z-index: 1; background: #101722; color: var(--dim-2); font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; min-width: 92px; }
.aws-compare td { color: #cdd7e6; }
.aws-compare tbody tr:last-child th, .aws-compare tbody tr:last-child td { border-bottom: 0; }
.aws-col-label { font-size: 11.5px; font-weight: 650; color: var(--text); }
.aws-compare-wrap.wide .aws-compare { font-size: 13px; min-width: 760px; }
.aws-compare-wrap.wide .aws-compare th, .aws-compare-wrap.wide .aws-compare td { padding: 10px 12px; }
#plan-modal .modal:has(.aws-compare-wrap.wide) { width: min(1180px, 96vw); }

/* Guide: worked examples */
.aws-example { padding: 11px 12px; border: 1px solid var(--line); border-left: 3px solid #ffb37a; border-radius: 9px; background: #0f151e; margin-bottom: 7px; }
.aws-ex-q { font-size: 13px; font-weight: 600; line-height: 1.45; color: var(--text); }
.aws-ex-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 7px 0 2px; }
.aws-ex-pick > span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--green); margin-right: 2px; }
.aws-ex-why { margin: 6px 0 0; font-size: 12.5px; line-height: 1.55; color: #cdd7e6; }
.aws-ex-not { margin: 5px 0 0; font-size: 12px; line-height: 1.5; color: var(--dim); }
.aws-ex-not b { color: #ff9a8a; font-weight: 600; }

/* Guide: user actions to walk on the canvas */
.aws-flows { display: flex; flex-direction: column; gap: 5px; }
.aws-flow {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: baseline; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #0f151e; color: var(--text);
}
.aws-flow:hover { border-color: #34507a; background: #111a27; }
.aws-flow .rw-pill { grid-row: 1 / 3; align-self: start; margin-top: 2px; }
.aws-flow b { font-size: 12.5px; }
.aws-flow span:last-child { grid-column: 2; font-size: 11.5px; color: var(--dim); line-height: 1.45; }

/* Guide: service index on the overview lesson */
.aws-index { display: flex; flex-direction: column; gap: 8px; }
.aws-index-cat { padding: 9px 11px; border: 1px solid var(--line-soft); border-left: 3px solid var(--cat); border-radius: 8px; background: #0e141d; }
.aws-index-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.aws-index-h b { font-size: 12.5px; color: color-mix(in srgb, var(--cat) 70%, #f2f6fc); }
.aws-index-h span { font-size: 11px; color: var(--dim-2); }

/* service card */
.aws-card { margin-top: 8px; border: 1px solid color-mix(in srgb, var(--cat) 35%, #2a3446); border-radius: 10px; background: #0e141d; overflow: hidden; }
.aws-card-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: color-mix(in srgb, var(--cat) 10%, #111925); border-bottom: 1px solid var(--line-soft); }
.aws-card-head b { font-size: 13.5px; flex: 1; min-width: 0; }
.aws-cat { font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .12em; color: var(--cat); }
.aws-ai-tag { font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .1em; padding: 1px 6px; border-radius: 99px; color: #ffb1d0; border: 1px solid #5a2b40; background: #26121b; }
.aws-plain { margin: 10px 12px 6px; font-size: 13px; line-height: 1.6; color: #dbe3ef; }
.aws-analogy { margin: 0 12px 8px; padding: 7px 10px; border-radius: 7px; background: #141b26; font-size: 12px; line-height: 1.5; color: #c3cfdf; }
.aws-analogy span { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim-2); margin-bottom: 2px; }
.aws-row { padding: 7px 12px; border-top: 1px solid var(--line-soft); }
.aws-row > span { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim-2); margin-bottom: 3px; }
.aws-row p { margin: 0; font-size: 12.5px; line-height: 1.55; color: #c9d5e6; }
.aws-row ul { margin: 0; padding-left: 16px; font-size: 12.5px; line-height: 1.55; color: #c9d5e6; }
.aws-row li + li { margin-top: 2px; }
.aws-row.good > span { color: var(--green); }
.aws-row.bad > span { color: #ff9a8a; }
.aws-row.ai > span { color: #ff9ac2; }
.aws-alt { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; white-space: nowrap; }
.aws-alt i { font-style: normal; color: var(--dim-2); }
.aws-tip { margin: 0; padding: 8px 12px; border-top: 1px solid var(--line-soft); background: #17150d; font-size: 12px; line-height: 1.5; color: #e9e1c6; }
.aws-tip b { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--cb-mid); margin-bottom: 2px; }
.aws-card-foot { padding: 7px 12px; border-top: 1px solid var(--line-soft); font-size: 11.5px; }
.aws-card-foot a { color: #8fb4ff; text-decoration: none; }
.aws-card-foot a:hover { text-decoration: underline; }
.aws-lesson-links { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.aws-card.compact .aws-plain { font-size: 12.5px; }
.arch-panel .aws-card { margin-top: 4px; }

/* Services tab */
.aws-svc { border: 1px solid var(--line); border-radius: 10px; background: #0f151e; margin-bottom: 7px; overflow: hidden; }
.aws-svc summary { display: flex; align-items: center; gap: 8px; padding: 9px 11px; cursor: pointer; list-style: none; }
.aws-svc summary::-webkit-details-marker { display: none; }
.aws-svc summary b { font-size: 13.5px; }
.aws-svc-cat { flex: 1; font-size: 11px; color: var(--dim-2); }
.aws-svc[open] summary { border-bottom: 1px solid var(--line-soft); background: #121a26; }
.aws-svc > .aws-card { margin: 0; border: 0; border-radius: 0; }
.aws-svc > .aws-card .aws-card-head { display: none; }

/* Quiz tab */
.aws-quiz-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.aws-quiz-head b { font-size: 14px; flex: 1; }
.aws-quiz-head span { font-family: var(--mono); font-size: 11px; color: var(--dim-2); }
.aws-quiz-head + .quiz-progress { margin-bottom: 12px; }
.aws-quiz-done { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; margin-bottom: 10px; border: 1px solid #1f4a45; border-radius: 9px; background: #0d2422; font-size: 12.5px; color: #c9f1e6; }
.aws-quiz-done span { flex: 1; min-width: 160px; }
.aws-q { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #0f151e; margin-bottom: 8px; }
.aws-q.right { border-color: #1f4a45; }
.aws-q.wrong { border-color: #4a2b21; }
.aws-q-n { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim-2); }
.aws-q-text { margin: 5px 0 9px; font-size: 13.5px; font-weight: 600; line-height: 1.5; }
.aws-q-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.aws-opt { text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #0b111a; font-size: 12.5px; line-height: 1.4; color: #d4deec; }
.aws-opt:hover:not(:disabled) { border-color: #34507a; background: #111a27; color: #fff; }
.aws-opt:disabled { cursor: default; }
.aws-opt.correct { border-color: #2a7a6c; background: #0d2422; color: #c9f7ea; }
.aws-opt.picked { border-color: #7a3a2a; background: #241411; color: #ffd0c4; }
.aws-opt.muted { opacity: .5; }
.aws-q-why { margin-top: 9px; font-size: 12.5px; line-height: 1.55; color: #c9d5e6; }
.aws-q.right .aws-q-why b { color: var(--green); }
.aws-q.wrong .aws-q-why b { color: #ff9a8a; }
@container aws (max-width: 380px) { .aws-q-opts { grid-template-columns: 1fr; } }
.aws-pane { container: aws / inline-size; }

/* popover for services that are not on the current canvas */
.aws-pop {
  position: fixed; z-index: 120; display: none; width: 360px; max-height: min(560px, 80vh); overflow-y: auto;
  border: 1px solid #4a3622; border-radius: 12px; background: #0f1724; box-shadow: 0 18px 50px rgba(0, 0, 0, .55); padding: 8px;
}
.aws-pop.on { display: block; }
.aws-pop .aws-card { margin-top: 0; }
.aws-pop-close { position: absolute; top: 14px; right: 14px; z-index: 1; }
.aws-pop .aws-card-head { padding-right: 44px; }
.aws-pop-note { padding: 6px 4px 0; font-size: 11px; color: var(--dim-2); }

/* ============================================================
   Phones and tablets
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* the app is exactly the visible screen, never hidden under a mobile browser's toolbar */
.app { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
#arch-modal.expanded .arch-modal { height: 100vh; height: 100dvh; }
.nav-short { display: none; }
.sheet-grab { display: none; }

/* finger-sized controls on any touch screen or small window */
@media (max-width: 760px), (max-height: 520px), (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn.tiny { min-height: 36px; padding: 6px 12px; font-size: 12.5px; }
  .icon-btn { min-width: 40px; }
  .tab, .study-tab, .arch-tabs button { min-height: 42px; }
  .chip { min-height: 34px; padding: 5px 11px; }
  .item { min-height: 44px; }
  .page-nav button { min-height: 38px; }
  .design-views button { min-height: 36px; }
  .hop, .conn-list li, .aws-opt, .aws-flow, .aws-decide li, .stage-head, .followup, .term-row, .more-list button { min-height: 44px; }
  .arch-tag, .chat-chip { min-height: 34px; display: inline-flex; align-items: center; }
  .svc-chip { min-height: 30px; }
  .chat-msg-actions { opacity: 1; }
  .chat-mini { min-height: 30px; padding: 4px 10px; }
  .qrow .mini, .add-btn { width: 32px; height: 32px; font-size: 14px; }
  .item { grid-template-columns: 16px minmax(0, 1fr) auto auto 32px; }
  .tb-group button { min-height: 38px; }
  .tb-group.zoom button { min-width: 38px; }
  .tb-gear { min-width: 44px; min-height: 44px; }
}
.more-list .more-phone { display: none; }

@media (max-width: 760px), (max-height: 520px) {
  /* top bars */
  .global-nav { gap: 6px; padding: 0 8px; }
  #btn-sidebar { width: 44px; min-height: 44px; font-size: 19px; }
  .page-nav { padding: 2px; }
  .page-nav button { padding: 0 11px; font-size: 13px; }
  .global-nav kbd, .topbar kbd { display: none; }
  #btn-chat { padding: 0 12px; }
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar .btn { padding: 0 10px; }
  .design-views button { justify-content: center; padding: 4px 12px; }
  .design-views button span, .design-views-arrow { display: none; }
  /* Submit and Run both live in the editor bar on every width */
  /* More opens as a sheet at the bottom of the screen */
  .more-list {
    position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom));
    min-width: 0; padding: 8px; border-radius: 16px; box-shadow: 0 -10px 50px rgba(0, 0, 0, .6);
  }
  .more-list button { font-size: 15px; padding: 10px 14px; }

  /* the question list slides over a dimmed page */
  body.sidebar-drawer::before { content: ""; position: fixed; inset: 52px 0 0 0; z-index: 59; background: rgba(4, 7, 12, .55); }
  body.sidebar-drawer .sidebar { width: min(360px, 88vw); }
  .search { min-height: 44px; font-size: 16px; }

  /* coding page: 16px text so iOS does not zoom into the editor */
  .doc { padding: 16px 16px 40px; }
  .code-host { --ed-font: 16px; }
  .editor-bar { min-height: 52px; padding: 6px 10px; }
  .editor-bar kbd { display: none; }
  .test-dock:not(.collapsed) { max-height: 55%; }

  /* Ask AI fills the screen */
  body.chat-open .app, body.sidebar-hidden.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr); }
  body.chat-open #resize-chat { display: none; }
  body.chat-open .chat-pane { position: fixed; inset: 52px 0 0 0; z-index: 60; width: auto; box-shadow: none; }
  .chat-ctx { max-width: 58vw; }
  .chat-head .btn { min-width: 44px; }
  .chat-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .chat-form textarea { font-size: 16px; }

  /* dialogs and pop-ups slide up from the bottom */
  .modal-back { padding: 0; align-items: flex-end; }
  .modal, .graph-modal, #plan-modal .modal:has(.aws-compare-wrap.wide) {
    width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 18px 18px 0 0; border-bottom: 0;
  }
  .graph-modal { height: 92vh; height: 92dvh; }
  .modal-b { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .aws-pop, .concept-pop {
    left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%;
    max-height: 72vh; max-height: 72dvh; overflow-y: auto; border-radius: 18px 18px 0 0;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .more-list { min-width: 230px; }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); text-align: center; }
  body.has-demo-banner .toast { bottom: calc(52px + env(safe-area-inset-bottom)); }

  /* Brief */
  .brief-grid { padding: 14px 12px 60px; gap: 16px; }
  .stage-answer, .brief-col.right .stage-answer { font-size: 16px; }

  /* canvas header: just the title */
  #arch-modal.inline .arch-head { padding: 6px 12px; }
  #arch-modal.inline .arch-head h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #arch-modal.inline .arch-sub { display: none; }

  /* learning panels: readable text */
  .study-top { padding: 4px 8px; }
  .study-tabs, .arch-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .study-tabs::-webkit-scrollbar, .arch-tabs::-webkit-scrollbar { display: none; }
  .study-tab, .arch-tabs button { padding: 8px 12px; font-size: 13.5px; }
  .arch-panel, .aws-body, .study-body { overflow-wrap: anywhere; }
  .arch-panel { padding: 12px 14px calc(32px + env(safe-area-inset-bottom)); }
  .study-body, .aws-body { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
  .arch-panel h4, .concept-head b, .aws-card-head b { font-size: 17px; }
  .arch-panel-body, .arch-panel-sub, .concept-row p, .concept-row ul, .arch-list li, .read-steps li,
  .aws-plain, .aws-summary, .aws-row p, .aws-row ul, .aws-ex-why, .aws-decide p, .aws-if,
  .learn-body > p, .risk-row p, .hop-detail, .term-row dd {
    font-size: 15px; line-height: 1.55;
  }
  .aws-question { font-size: 17px; }
  .aws-opt { font-size: 14.5px; padding: 10px 12px; }
  .aws-q-opts { grid-template-columns: 1fr; }
  .arch-stats { flex-wrap: wrap; }
  .arch-stats > div { flex: 1 1 30%; min-width: 84px; }
  .aws-alt, .svc-chip { white-space: normal; }
}
@media (max-width: 430px) {
  .nav-long { display: none; }
  .nav-short { display: inline; }
}
@media (max-width: 480px) {
  .topbar #btn-reset { display: none; }
  .more-list .more-phone { display: flex; }
}
@media (max-width: 380px) {
  .study-tab { padding: 8px 9px; }
}
@media (max-width: 350px) {
  .global-nav { gap: 4px; padding: 0 6px; }
  .page-nav button { padding: 0 8px; }
  .topbar .btn { padding: 0 8px; }
}

/* held upright: canvas on top, side panel as a bottom sheet (tabs only, half, or nearly full) */
@media (max-width: 1024px) and (orientation: portrait) {
  .design-stage.view-map, .design-stage.view-compare, body.mode-aws .aws-stage { flex-direction: column; }
  .design-stage.view-compare .design-stage-main,
  .design-stage.view-compare .board-stage { flex: 1 1 50%; width: 100%; min-height: 0; border-right: 0; }
  .design-stage.view-compare .board-stage { border-top: 1px solid var(--line); }
  .design-stage.view-map .design-stage-main, .aws-canvas { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 0; }
  .design-stage.view-map .study-pane, .study-pane.aws-pane {
    flex: 0 0 auto; width: 100%; max-width: none; height: 50%; min-height: 0;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    box-shadow: 0 -14px 32px rgba(0, 0, 0, .4); transition: height .2s cubic-bezier(.2, .8, .2, 1);
  }
  .sheet-dragging .study-pane { transition: none; }
  .design-stage.view-map.sheet-full .study-pane, .aws-stage.sheet-full .aws-pane { height: calc(100% - 64px); }
  body .design-stage.view-map.study-collapsed .study-pane, body .aws-stage.pane-collapsed .aws-pane { display: flex; height: auto; }
  .design-stage.study-collapsed .study-pane > :not(.sheet-grab):not(.study-top),
  .aws-stage.pane-collapsed .aws-pane > :not(.sheet-grab):not(.study-top) { display: none !important; }
  .design-stage.study-collapsed .study-reopen, .aws-stage.pane-collapsed #aws-reopen, .aws-stage > #resize-aws { display: none !important; }
  .sheet-grab {
    display: flex; flex: 0 0 auto; align-items: center; justify-content: center;
    width: 100%; height: 26px; padding: 0; border: 0; background: transparent; cursor: grab; touch-action: none;
  }
  .sheet-grab i { width: 44px; height: 5px; border-radius: 99px; background: #3a4760; }
  .sheet-grab:active i { background: var(--accent); }
  /* the whole sheet scrolls as one page under a pinned grab bar and tab bar */
  .design-stage.view-map .study-pane, .study-pane.aws-pane { overflow-y: auto; overscroll-behavior: contain; }
  .study-pane > .sheet-grab { position: sticky; top: 0; z-index: 4; background: var(--panel); }
  .study-pane > .study-top { position: sticky; top: 26px; z-index: 4; background: var(--panel); border-bottom: 1px solid var(--line); }
  .study-pane > .study-inspect, .study-pane > .study-body, .study-pane > .terms-strip { flex: none; overflow: visible; max-height: none; }
  .study-pane .arch-side, #arch-modal.inline .study-pane .arch-side { flex: none; overflow: visible; }
  .study-pane .arch-tabs { position: static; }
  #study-collapse, #aws-collapse { font-size: 0; width: 44px; }
  #study-collapse::after, #aws-collapse::after { content: "▾"; font-size: 18px; line-height: 1; }
  .study-collapsed #study-collapse::after, .pane-collapsed #aws-collapse::after { content: "▴"; }
}

/* phone on its side: slim bars, canvas and panel side by side */
@media (max-height: 520px) and (orientation: landscape) {
  .global-nav { height: 46px; }
  .app { height: calc(100vh - 46px); height: calc(100dvh - 46px); }
  body.sidebar-drawer .sidebar, body.chat-open .chat-pane { top: 46px; }
  body.sidebar-drawer::before { top: 46px; }
  .topbar { height: 46px; }
  #arch-modal.inline .arch-head { display: none; }
  .workspace, .workspace.ai-open { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) !important; }
  .workspace > .pane.left { border-bottom: 0; border-right: 1px solid var(--line); }
  .design-stage.view-map .study-pane { --study-w: min(46vw, 400px); }
  .study-tab, .arch-tabs button { min-height: 38px; }
}

/* ---------------- Recent GS questions (clock badge) ---------------- */
.badge-pair { display: inline-flex; align-items: center; gap: 4px; justify-self: end; }
.clock-ico { display: block; flex: none; }
.title-clock {
  display: inline-flex;
  vertical-align: -1px;
  margin-right: 5px;
  color: var(--green);
}
.doc h2 .title-clock { margin: 0 0 0 8px; vertical-align: 1px; }
.doc h2 .title-clock .clock-ico { width: 14px; height: 14px; }
.doc h2 .last-asked {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: #8b98ad;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  vertical-align: 2px;
}


/* ---------------- GS system design: Recent + Last asked ---------------- */
.topbar .title {
  display: flex;
  align-items: baseline;
  min-width: 0;
  overflow: hidden;
}
.topbar .title .title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
  /* the question name keeps its room; "Last asked" gives way first */
  min-width: min(14ch, 100%);
}
.topbar .title .title-clock {
  flex: none;
  margin-left: 8px;
  margin-right: 0;
}
.topbar .title .last-asked {
  flex: 0 999 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 10px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: #8b98ad;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.design-item .badge-pair { gap: 5px; }
.design-item .lvl.role-ai,
.design-item .lvl.role-swe {
  font-weight: 600;
  min-width: 0;
  padding: 1px 5px;
}
.design-item .lvl.role-ai { color: var(--cb-senior); border-color: #2b4470; background: #121c2c; }
.design-item .lvl.role-swe { color: #8fb3f0; border-color: #2b4470; background: #121c2c; }
.ask-kicker .tag,
.ask-kicker .diff-tag,
.ask-kicker .title-clock,
.ask-kicker .last-asked {
  letter-spacing: 0;
  text-transform: none;
  font-family: inherit;
}
.ask-kicker .tag { margin-left: 8px; vertical-align: 1px; }
.ask-kicker .title-clock { margin-left: 8px; vertical-align: -1px; }
.ask-kicker .last-asked {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 400;
  color: #8b98ad;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ask-card .gs-evidence { margin-top: 12px; }
.tag-role { font-weight: 600; }
.tag-role-ai { color: var(--cb-senior); border-color: #2b4470; background: #121c2c; }
.tag-role-swe { color: #8fb3f0; border-color: #2b4470; background: #121c2c; }


/* ---------------- Building Blocks + Design Canvas ---------------- */
body.mode-design.mode-families .page-title,
body.mode-design.mode-board .page-title { display: flex; }
body.mode-families .design-views,
body.mode-board .design-views,
body.mode-families .brief-view,
body.mode-board .brief-view,
body.mode-families .design-stage-main,
body.mode-board .design-stage-main,
body.mode-families .study-pane,
body.mode-board .study-pane,
body.mode-families .study-reopen,
body.mode-board .study-reopen,
body.mode-families .design-scrim,
body.mode-board .design-scrim,
body.mode-families .design-brief,
body.mode-board .design-brief { display: none !important; }

.families-stage, .board-stage {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
}
body.mode-families .families-stage { display: flex; overflow: auto; }
body.mode-board .board-stage { display: flex; }

.fam-page { max-width: 920px; margin: 0 auto; padding: 22px 28px 48px; }
.fam-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--cb-senior); margin-bottom: 6px; }
.fam-head h1 { font-size: 22px; margin: 0 0 8px; letter-spacing: -.02em; }
.fam-head p { margin: 0 0 18px; color: var(--dim); font-size: 13.5px; line-height: 1.65; }
.fam-flow { border: 1px solid var(--line); border-radius: 12px; background: #0f151e; padding: 12px 14px 14px; margin-bottom: 16px; }
.fam-flow-edge { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fam-flow-cap { font-size: 11.5px; color: var(--dim-2); }
.fam-flow-spine { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.fam-pill {
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: 99px;
  border: 1px solid #2b4470; background: #121c2c;
  color: #cfe0ff; font-size: 12px; font-weight: 600;
}
.fam-pill-edge { border-color: #432b52; background: #1c1226; color: #e4c9ff; }
.fam-acc { border: 1px solid var(--line); border-radius: 10px; background: #0f151e; margin-bottom: 7px; overflow: hidden; }
.fam-acc summary { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.fam-acc summary::-webkit-details-marker { display: none; }
.fam-acc summary::before { content: "▸"; font-size: 10px; color: var(--dim-2); flex: none; }
.fam-acc[open] summary::before { content: "▾"; }
.fam-acc[open] summary { border-bottom: 1px solid var(--line-soft); background: #121a26; }
.fam-name { font-weight: 650; font-size: 13.5px; flex: none; }
.fam-purpose { color: var(--dim); font-size: 12.5px; line-height: 1.45; }
.fam-body { padding: 12px 14px 14px; }
.fam-does { margin: 0 0 12px; font-size: 13.5px; line-height: 1.6; color: #d4deec; }
.fam-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px 12px; margin-bottom: 10px; }
.fam-k { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim-2); padding-top: 3px; }
.fam-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fam-chip { font-size: 12px; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--line); background: #0b111a; color: #cdd7e6; }
.fam-aws { margin: 0; padding: 0; list-style: none; }
.fam-aws li { font-size: 13px; line-height: 1.5; color: #d4deec; padding: 3px 0; }
.fam-aws b { color: #e7edf7; }
.fam-tip { margin-top: 8px; padding: 8px 12px; border-top: 1px solid var(--line-soft); background: #17150d; font-size: 12.5px; line-height: 1.55; color: #e9e1c6; }
.fam-tip b { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--cb-mid); margin-bottom: 2px; }
.fam-note { margin-top: 8px; padding: 8px 12px; border: 1px solid #4a4021; border-radius: 8px; background: #211d0f; font-size: 12px; line-height: 1.5; color: #e9e1c6; }

.board-palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.board-pal { border: 1px solid var(--line); background: #0f151e; color: var(--text); border-radius: 99px; padding: 4px 10px 4px 8px; font-size: 12px; font-weight: 600; }
.board-pal::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 99px; background: var(--c); margin-right: 6px; vertical-align: 0; }
.board-pal:hover { border-color: var(--c, var(--accent)); }
.board-pal-sp { flex: 1; }
.board-work { flex: 1; min-height: 0; display: flex; }
.board-scroll { flex: 1; min-width: 0; overflow: auto; background: #080d14; background-image: radial-gradient(#1c2533 1px, transparent 1px); background-size: 20px 20px; }
#board-svg { display: block; min-width: 2200px; min-height: 1400px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
.board-scroll { position: relative; overscroll-behavior: contain; }
#board-svg.panning { cursor: grabbing; }
#board-svg.linking, #board-svg.linking .board-node { cursor: crosshair; }
#board-svg.dragging, #board-svg.dragging .board-node { cursor: grabbing; }
#board-svg text { user-select: none; -webkit-user-select: none; }
.board-node { cursor: grab; }
.board-node:hover .board-box { filter: brightness(1.18); }
.board-node.target .board-box { stroke: #ff7a1a; stroke-width: 2.6; }
.board-port { cursor: crosshair; transition: r .08s; }
.board-node:hover .board-port, #board-svg.linking .board-port { r: 8.5; }
.board-port:hover { fill: #ff7a1a; }
.board-edge-g { cursor: pointer; }
.board-edge-g:hover .board-edge { stroke-width: 3; }
.board-rename {
  position: absolute; z-index: 3; height: 24px; padding: 2px 6px;
  border: 1px solid #ff7a1a; border-radius: 6px; background: #0b111a;
  color: #e7edf7; font: 600 13px/1.2 inherit; outline: none;
}
.board-notes { width: 260px; flex: none; border-left: 1px solid var(--line); background: var(--panel); padding: 12px; overflow: auto; }
.board-notes-empty { font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.board-lab { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--dim-2); margin-bottom: 10px; }
.board-lab input, .board-lab textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #0b111a;
  color: var(--text); padding: 7px 8px; font: inherit;
}
.board-lab textarea { resize: vertical; min-height: 140px; }
@media (max-width: 700px) {
  .fam-row { grid-template-columns: 1fr; }
  .board-notes { width: 200px; }
}


/* ---------------- UI polish (2026-11-15) ---------------- */

/* Library filter group labels (inside "More filters") */
.lib-filters-k { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim-2); }

/* Collapsible System Design groups */
.group-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: none;
  border: 0;
  border-radius: 5px;
  text-align: left;
  cursor: pointer;
}
.group-toggle:hover { filter: brightness(1.2); }
.group-toggle .group-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-toggle .cnt { flex: none; }
.group-chev {
  width: 5px;
  height: 5px;
  flex: none;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
  opacity: .8;
}
.group-toggle[aria-expanded="true"] .group-chev { transform: rotate(45deg); }

/* Keyboard focus on sidebar rows and group headers: one crisp hairline, inside the row */
.item:focus-visible, .qrow:focus-visible, .group-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* Complexity reads as a quiet note line, not a boxed shouting tag */
.tag.tag-cx {
  flex-basis: 100%;
  text-transform: none;
  letter-spacing: 0;
  border: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim-2);
}

/* ============================================================
   Say It page: speak an explanation, get feedback
   ============================================================ */
.say-stage { display: none; flex: 1; min-height: 0; min-width: 0; overflow: hidden; background: #080d14; }
body.mode-say .say-stage { display: flex; }
body.mode-say .app { grid-template-columns: 0 0 minmax(0, 1fr); }
body.mode-say.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
body.mode-say .sidebar, body.mode-say #resize-sidebar,
body.mode-say .topbar, body.mode-say .workspace,
body.mode-say .design-stage, body.mode-say .aws-stage { display: none; }
body.mode-say #btn-sidebar { display: none; }
body:not(.mode-design) #btn-speak-top { display: none; }
body.mode-aws #btn-speak, body.mode-aws #btn-speak-top { display: none; }
@media (max-width: 980px) {
  body.mode-say .app, body.mode-say.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr); }
  body.mode-say.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 380px); }
}
@media (max-width: 640px) { body.mode-say.chat-open .app { grid-template-columns: 0 0 minmax(0, 1fr); } }

.say-wrap { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.say-head { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.say-title { display: flex; flex-direction: column; line-height: 1.25; }
.say-title b { font-size: 17px; letter-spacing: .2px; }
.say-title span { font-size: 12px; color: var(--dim-2); }
.say-tabs { display: flex; gap: 4px; background: #0b1220; padding: 3px; border: 1px solid var(--line-soft); border-radius: 10px; }
.say-tabs button { border: 0; background: transparent; color: var(--dim); padding: 6px 14px; border-radius: 7px; font-weight: 600; font-size: 13px; }
.say-tabs button:hover { color: var(--text); }
.say-tabs button.on { background: var(--accent-dim); color: #cfe0ff; box-shadow: inset 0 0 0 1px #2c4d7e; }
.say-streak { font-size: 12px; color: var(--dim-2); border: 1px solid var(--line-soft); padding: 3px 10px; border-radius: 99px; }
.say-streak.on { color: #9ff0d8; border-color: #1e5a52; background: var(--green-dim); }
.say-view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.say-view > * { flex: 1; min-height: 0; }

/* drill view */
.say-drill { display: grid; grid-template-columns: 310px minmax(0, 1fr); }
.say-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.say-search { margin: 10px; padding: 7px 10px; background: #0b1220; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.say-search.wide { margin: 0; flex: 1; max-width: 520px; }
.say-search:focus { border-color: var(--accent); outline: none; }
.say-list-body { overflow-y: auto; padding: 0 6px 20px; flex: 1; }
.say-gh { margin: 12px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim-2); display: flex; gap: 6px; }
.say-gh span { color: var(--dim-2); opacity: .7; }
.say-gh.sep { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line-soft); color: #7ab8ff; }
.say-li { display: flex; align-items: flex-start; gap: 8px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 6px 8px; color: var(--dim); font-size: 13px; line-height: 1.4; }
.say-li:hover { background: var(--panel-2); color: var(--text); }
.say-li.on { background: var(--accent-dim); border-color: #2c4d7e; color: #e7f0ff; }
.say-li span { flex: 1; }
.say-li b { font-size: 11px; color: #9ff0d8; background: var(--green-dim); border-radius: 99px; padding: 0 7px; }
.say-dot { flex: 0 0 15px; height: 15px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--line); font-style: normal; font-size: 10px; line-height: 12px; text-align: center; color: #06122b; }
.say-dot.done { background: var(--green); border-color: var(--green); }
.say-card { overflow-y: auto; padding: 18px 26px 60px; }
.say-card > * { max-width: 980px; margin-left: auto; margin-right: auto; }
.say-card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.say-kicker { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: #7ab8ff; font-weight: 700; }
.say-prompt { margin: 4px auto 12px; font-size: 21px; line-height: 1.35; }
.say-skeleton { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 12px; margin-bottom: 10px; }
.say-skeleton > b { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim-2); }
.say-skeleton div { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 4px; }
.say-skeleton span { background: var(--accent-dim); color: #cfe0ff; border-radius: 6px; padding: 1px 8px; font-size: 12.5px; }
.say-skeleton i { color: var(--dim-2); font-style: normal; }
.say-topics { font-size: 12.5px; color: var(--dim); margin-bottom: 10px; }
.say-topics span { display: inline-block; margin: 2px 4px 0 0; padding: 0 8px; border: 1px solid var(--line); border-radius: 99px; }
.say-rec { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.say-rec-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.say-mic { display: inline-flex; align-items: center; gap: 9px; border: 1px solid #2c4d7e; background: linear-gradient(180deg, #1f3a63, #1a2f50); color: #e7f0ff; border-radius: 99px; padding: 8px 18px 8px 12px; font-weight: 650; min-width: 130px; }
.say-mic:hover:not(:disabled) { filter: brightness(1.12); }
.say-mic:disabled { opacity: .55; cursor: wait; }
.say-mic i { width: 14px; height: 14px; border-radius: 50%; background: #ff6b6b; box-shadow: 0 0 0 3px rgba(255,107,107,.2); }
.say-mic.rec { background: #3a1f1a; border-color: #8a3d2f; }
.say-mic.rec i { border-radius: 3px; animation: say-pulse 1.1s ease-in-out infinite; }
@keyframes say-pulse { 50% { box-shadow: 0 0 0 6px rgba(255,107,107,.05); } }
.say-timer { font: 600 18px var(--mono); color: var(--text); min-width: 78px; }
.say-timer.over { color: var(--amber); }
.say-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--dim-2); }
.say-field select, .say-select { background: #0b1220; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 12.5px; max-width: 250px; }
.say-status { min-height: 20px; margin-top: 8px; font-size: 13px; color: var(--dim); }
.say-status[data-tone="bad"] { color: var(--red); }
.say-status[data-tone="ok"] { color: #9ff0d8; }
.say-progress { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.say-progress > div { flex: 1; height: 7px; background: #0b1220; border-radius: 99px; overflow: hidden; border: 1px solid var(--line-soft); }
.say-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--green)); transition: width .15s; }
.say-progress span { font-size: 12px; color: var(--dim); min-width: 190px; text-align: right; }
.say-note { margin: 8px 0 0; font-size: 12px; color: var(--dim-2); line-height: 1.5; }
.say-label { display: block; margin: 4px 0 4px; font-size: 12.5px; font-weight: 600; color: var(--dim); }
.say-label span { font-weight: 400; color: var(--dim-2); }
.say-transcript { width: 100%; background: #0b1220; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); line-height: 1.55; resize: vertical; font-size: 14px; }
.say-transcript:focus { border-color: var(--accent); outline: none; }
.say-actions-row { display: flex; gap: 8px; margin: 10px auto; flex-wrap: wrap; align-items: center; }
.say-peek { background: #0f1b2c; border: 1px solid #25456f; border-radius: 10px; padding: 4px 14px 10px; margin-bottom: 12px; }
.say-peek h5, .say-side h5, .say-ex-col h5 { margin: 8px 0 2px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: #7ab8ff; }
.say-peek p { margin: 4px 0; line-height: 1.65; }

/* feedback */
.say-feedback { margin-top: 18px; padding-top: 6px; border-top: 1px dashed var(--line); }
.say-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 10px auto; }
.say-tile { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; border-left: 3px solid var(--line); }
.say-tile b { font-size: 24px; line-height: 1.15; }
.say-tile span { font-size: 11.5px; color: var(--dim-2); }
.say-tile.ok { border-left-color: var(--green); }
.say-tile.ok b { color: #9ff0d8; }
.say-tile.warn { border-left-color: var(--amber); }
.say-tile.warn b { color: var(--amber); }
.say-tile.bad { border-left-color: var(--red); }
.say-tile.bad b { color: var(--red); }
.say-tile.dim b { color: var(--dim-2); }
.say-delta { margin: 4px 0 8px; font-size: 12.5px; color: var(--dim); }
.say-fb { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; padding: 4px 14px 12px; margin-bottom: 10px; }
.say-fb h4 { margin: 10px 0 6px; font-size: 13px; letter-spacing: .3px; }
.say-fb h4.say-sub { margin-top: 14px; }
.say-fb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.say-fb-grid > .say-fb { margin-bottom: 0; }
.say-side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .say-side, .say-ex { grid-template-columns: 1fr; } .say-drill { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; } }
.say-side p, .say-marked { margin: 2px 0 4px; line-height: 1.7; font-size: 13.5px; }
.say-legend { color: var(--dim-2); font-size: 11px; }
.say-legend mark { margin-right: 6px; }
mark.say-hl-filler { background: rgba(242,199,94,.22); color: #ffe7a6; border-radius: 4px; padding: 0 2px; }
mark.say-hl-vague { background: rgba(255,138,112,.2); color: #ffc2b4; border-radius: 4px; padding: 0 2px; text-decoration: underline wavy rgba(255,138,112,.6); text-underline-offset: 3px; }
mark.say-term { border-radius: 4px; padding: 0 2px; }
mark.say-term.hit { background: rgba(45,212,191,.18); color: #9ff0d8; }
mark.say-term.miss { background: rgba(255,138,112,.2); color: #ffc2b4; }
.say-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.say-chip { border: 1px solid var(--line); border-radius: 99px; padding: 1px 10px; font-size: 12.5px; background: #0b1220; color: var(--dim); }
.say-chip.warn { color: var(--amber); border-color: #5b4a1f; }
.say-chip.ok { color: #9ff0d8; border-color: #1e5a52; background: var(--green-dim); }
.say-chip.bad { color: #ffc2b4; border-color: #6a3328; background: var(--red-dim); }
button.say-chip.pick { cursor: pointer; }
button.say-chip.pick:hover { color: var(--text); border-color: #3a527a; }
button.say-chip.pick.on { background: var(--accent-dim); color: #cfe0ff; border-color: #2c4d7e; }
.say-tip { margin: 6px 0 2px; font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.say-tip.ok { color: #9ff0d8; }
.say-runons { margin: 4px 0; padding-left: 18px; font-size: 12.5px; color: var(--dim); }
.say-check { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.say-check li { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; }
.say-check li i { flex: 0 0 18px; height: 18px; border-radius: 50%; text-align: center; line-height: 18px; font-style: normal; font-size: 11px; font-weight: 800; }
.say-check li.ok i { background: var(--green); color: #06122b; }
.say-check li.miss i { background: var(--red-dim); color: var(--red); border: 1px solid #6a3328; }
.say-check li span { display: block; color: var(--dim-2); font-size: 12px; }
.say-vague { border-left: 3px solid #6a3328; padding: 2px 0 2px 10px; margin: 8px 0; }
.say-said { font-style: italic; color: #ffc2b4; }
.say-say-instead { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; margin: 3px 0; }
.say-say-instead > span { font-size: 11.5px; color: var(--dim-2); text-transform: uppercase; letter-spacing: .5px; }
.say-say-instead em { font-style: normal; background: var(--green-dim); color: #bff7e8; border-radius: 6px; padding: 0 8px; }
.say-why { font-size: 12.5px; color: var(--dim-2); }
.say-empty { color: var(--dim-2); padding: 16px; font-size: 13px; }

/* phrase bank */
.say-bank { overflow-y: auto; padding: 14px 24px 60px; }
.say-bank > * { max-width: 1040px; margin-left: auto; margin-right: auto; }
.say-bank-top { display: flex; gap: 12px; align-items: center; }
.say-count { font-size: 12px; color: var(--dim-2); white-space: nowrap; }
.say-chips.moment { margin: 10px auto 4px; }
.say-kind { margin: 22px auto 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: #7ab8ff; border-bottom: 1px solid var(--line-soft); padding-bottom: 4px; }
.say-moment h4 { margin: 16px 0 8px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.say-moment h4 span { font-size: 11px; font-weight: 600; color: var(--dim-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.say-moment h4 .btn { margin-left: auto; }
.say-phrase { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1.3fr); gap: 4px 10px; align-items: start; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 14px; margin-bottom: 7px; }
.say-plain, .say-polished { font-size: 14px; line-height: 1.5; }
.say-plain span, .say-polished span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim-2); }
.say-plain { color: #ffc2b4; }
.say-polished { color: #bff7e8; font-weight: 600; position: relative; padding-right: 54px; }
.say-arrow { color: var(--dim-2); align-self: center; text-align: center; }
.say-copy { position: absolute; right: 0; top: 0; border: 1px solid var(--line); background: #0b1220; color: var(--dim); border-radius: 6px; font-size: 11px; padding: 1px 8px; }
.say-copy:hover { color: var(--text); border-color: #3a527a; }
.say-example { grid-column: 1 / -1; margin: 2px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.say-example b { color: var(--dim-2); font-weight: 600; }
@media (max-width: 760px) { .say-phrase { grid-template-columns: 1fr; } .say-arrow { display: none; } }

/* guide */
.say-guide { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
@media (max-width: 860px) { .say-guide { grid-template-columns: 1fr; } .say-toc { display: none; } }
.say-toc { overflow-y: auto; padding: 14px 10px 30px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
.say-toc-h { margin: 14px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #7ab8ff; font-weight: 700; }
.say-toc-h:first-child { margin-top: 2px; }
.say-toc a { color: var(--dim); text-decoration: none; font-size: 13px; padding: 4px 8px; border-radius: 6px; line-height: 1.35; }
.say-toc a:hover { background: var(--panel-2); color: var(--text); }
.say-guide-body { overflow-y: auto; padding: 8px 30px 80px; scroll-behavior: smooth; }
.say-guide-body > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.say-part { margin: 34px auto 6px; font-size: 24px; background: linear-gradient(90deg, #7ab8ff, #2dd4bf); -webkit-background-clip: text; background-clip: text; color: transparent; }
.say-intro { margin: 0 auto 12px; color: var(--dim); line-height: 1.7; }
.say-g { margin: 22px auto; padding: 16px 20px 18px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 14px; scroll-margin-top: 8px; }
.say-g h3 { margin: 4px 0 4px; font-size: 18px; }
.say-g ul { margin: 6px 0 8px; padding-left: 20px; line-height: 1.7; }
.say-g li { margin: 3px 0; }
.say-lead { margin: 2px 0 8px; color: var(--dim); line-height: 1.65; }
.say-tag { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: #7ab8ff; background: var(--accent-dim); border-radius: 99px; padding: 1px 9px; }
.say-tag.sm { margin-right: 8px; font-size: 9.5px; vertical-align: 1px; }
.say-ba { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
@media (max-width: 760px) { .say-ba { grid-template-columns: 1fr; } }
.say-ba > div { padding: 9px 12px; border-radius: 10px; line-height: 1.6; font-size: 13.5px; }
.say-ba span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.say-ba .bad { background: var(--red-dim); border: 1px solid #6a3328; color: #ffd2c7; }
.say-ba .bad span { color: var(--red); }
.say-ba .good { background: var(--green-dim); border: 1px solid #1e5a52; color: #c8f8ec; }
.say-ba .good span { color: var(--green); }
.say-frame { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.say-frame div { background: #0b1220; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.say-frame b { display: block; color: #7ab8ff; font-size: 12.5px; }
.say-frame span { font-size: 13px; color: var(--dim); }
.say-swaps { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.say-swaps th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--dim-2); padding: 4px 8px; border-bottom: 1px solid var(--line); }
.say-swaps td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.say-swaps td:first-child { color: #ffc2b4; }
.say-swaps td:nth-child(2) { color: #bff7e8; font-weight: 600; }
.say-swaps td em { color: var(--dim); }
.say-trans { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.say-trans > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.say-trans b { flex: 0 0 150px; font-size: 12.5px; color: #7ab8ff; }
.say-trans span { background: #0b1220; border: 1px solid var(--line); border-radius: 99px; padding: 1px 11px; font-size: 12.5px; color: var(--text); }
.say-daily { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 10px 0; }
.say-daily > div { background: #0b1220; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px 10px; }
.say-daily h5 { margin: 4px 0; font-size: 14px; display: flex; justify-content: space-between; }
.say-daily h5 span { font-size: 11px; color: var(--green); font-weight: 600; }
.say-daily p { margin: 2px 0 6px; font-size: 13px; color: var(--dim); line-height: 1.55; }
.say-daily small { color: var(--dim-2); }
.say-link { margin-top: 4px; }
.say-ex { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.say-ex-col { border-radius: 12px; padding: 4px 14px 12px; font-size: 13.5px; line-height: 1.65; }
.say-ex-col.weak { background: var(--red-dim); border: 1px solid #6a3328; }
.say-ex-col.weak h5 { color: var(--red); }
.say-ex-col.clear { background: var(--green-dim); border: 1px solid #1e5a52; }
.say-ex-col.clear h5 { color: var(--green); }
.say-ex-col p { margin: 6px 0; }
.say-ex-col ul { font-size: 12.5px; color: #ffd2c7; margin: 6px 0 0; padding-left: 18px; }
.say-ex-stats { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 4px; }
.say-ex-stats span { font-size: 11px; background: rgba(0,0,0,.25); border-radius: 99px; padding: 0 9px; color: var(--dim); }

/* history */
.say-hist { overflow-y: auto; padding: 16px 24px 60px; }
.say-hist > * { max-width: 980px; margin-left: auto; margin-right: auto; }
.say-strip { display: flex; align-items: center; gap: 4px; margin: 6px auto 12px; }
.say-strip span { font-size: 12px; color: var(--dim-2); margin-right: 8px; }
.say-day { width: 18px; height: 18px; border-radius: 4px; background: #0b1220; border: 1px solid var(--line-soft); display: inline-block; }
.say-day.on { background: #1b5f57; border-color: #1e7f73; }
.say-day.hot { background: var(--green); border-color: var(--green); }
.say-hist-top { display: flex; align-items: center; gap: 10px; margin: 6px auto 10px; }
.say-att { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; margin-bottom: 6px; }
.say-att-head { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 12px; }
.say-att-head:hover { background: var(--panel-2); border-radius: 10px; }
.say-att-score { flex: 0 0 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; background: #0b1220; border: 1px solid var(--line); }
.say-att-score.ok { color: #9ff0d8; border-color: #1e5a52; }
.say-att-score.warn { color: var(--amber); border-color: #5b4a1f; }
.say-att-score.bad { color: var(--red); border-color: #6a3328; }
.say-att-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.say-att-main b { font-size: 13.5px; font-weight: 600; }
.say-att-main small { color: var(--dim-2); font-size: 12px; }
.say-att-head i { color: var(--dim-2); font-style: normal; }
.say-att-body { padding: 0 14px 12px 62px; }
.say-att-body p { margin: 0 0 8px; color: var(--dim); font-size: 13px; line-height: 1.65; }

/* ============================================================
   Prep pack: pinned reference cards + quick sheets
   ============================================================ */
body.mode-design.mode-cards .page-title { display: flex; }
body.mode-cards .design-views,
body.mode-cards .brief-view,
body.mode-cards .design-stage-main,
body.mode-cards .study-pane,
body.mode-cards .study-reopen,
body.mode-cards .design-scrim,
body.mode-cards .design-brief { display: none !important; }
.cards-stage { display: none; flex: 1; min-height: 0; min-width: 0; flex-direction: column; background: #080d14; }
body.mode-cards .cards-stage { display: flex; }
.group-h.random-group { color: var(--green); }
.group-h.pinned-group { color: #9ec5ff; }

.prep-tabs { display: flex; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.prep-tab { border: 1px solid var(--line); background: #0b1220; color: var(--dim); border-radius: 99px; padding: 3px 12px; font-size: 12.5px; font-weight: 600; }
.prep-tab:hover { color: var(--text); border-color: #3a527a; }
.prep-tab.on { background: var(--accent-dim); color: #cfe0ff; border-color: #2c4d7e; }
.prep-scroll { flex: 1; overflow-y: auto; padding: 14px 22px 40px; }
.prep-card { max-width: 1180px; margin: 0 auto; }
.prep-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 8px; }
.prep-head > div:first-child { flex: 1; }
.prep-head-actions { display: flex; gap: 6px; }
.prep-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--cb-senior); }
.prep-head h1 { margin: 2px 0 0; font-size: 20px; letter-spacing: -.01em; }
.prep-say { display: flex; gap: 10px; align-items: baseline; background: #0f1b2c; border: 1px solid #25456f; border-left: 3px solid var(--accent); border-radius: 8px; padding: 6px 12px; margin: 6px 0 10px; }
.prep-say span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: #7ab8ff; white-space: nowrap; }
.prep-say p { margin: 0; font-size: 13.5px; color: #dce8fa; line-height: 1.5; }
.prep-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0 10px; }
.prep-table th, .prep-table td { text-align: left; vertical-align: top; padding: 4px 9px; border-bottom: 1px solid var(--line-soft); line-height: 1.4; }
.prep-table thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--dim-2); border-bottom: 1px solid var(--line); background: #0f151e; }
.prep-table tbody th { color: #cfe0ff; font-weight: 650; white-space: nowrap; width: 1%; }
.prep-table tbody tr:hover { background: #0f151e; }
.prep-table td { color: var(--dim); }
.prep-prompts tbody th { white-space: normal; width: 190px; }
.prep-link { border: 0; background: transparent; color: #9ec5ff; font-weight: 650; font-size: 12.5px; padding: 0; text-align: left; text-decoration: underline; text-decoration-color: #2c4d7e; text-underline-offset: 3px; }
.prep-link:hover { color: #fff; }
.prep-flow { display: flex; gap: 4px; list-style: none; padding: 0; margin: 6px 0 10px; flex-wrap: wrap; }
.prep-flow li { position: relative; flex: 1 1 120px; background: #121c2c; border: 1px solid #2b4470; border-radius: 8px; padding: 5px 10px; display: flex; flex-direction: column; min-width: 110px; }
.prep-flow li:not(:last-child)::after { content: "›"; position: absolute; right: -9px; top: 50%; transform: translateY(-50%); color: var(--dim-2); z-index: 1; font-size: 15px; }
.prep-flow b { font-size: 12.5px; color: #cfe0ff; }
.prep-flow span { font-size: 11px; color: var(--dim-2); line-height: 1.35; }
.prep-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .prep-cols { grid-template-columns: 1fr; } }
.prep-col { min-width: 0; }
.prep-blk { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 2px 12px 8px; margin: 6px 0 10px; }
.prep-blk h4 { margin: 8px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #7ab8ff; }
.prep-list { margin: 2px 0; padding-left: 18px; font-size: 12.5px; color: var(--dim); line-height: 1.5; }
.prep-list li { margin: 2px 0; }
.prep-code { margin: 4px 0 2px; padding: 8px 10px; background: #0b1220; border: 1px solid var(--line); border-radius: 8px; font: 11.5px/1.5 var(--mono); color: #cfe0ff; overflow-x: auto; white-space: pre; }
.prep-check { list-style: none; margin: 2px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.prep-chk { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--dim); line-height: 1.45; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.prep-chk:hover { background: #0f151e; }
.prep-chk i { flex: 0 0 14px; height: 14px; margin-top: 2px; border: 1.5px solid #3a527a; border-radius: 4px; }
.prep-chk.on { color: #9ff0d8; }
.prep-chk.on i { background: var(--green); border-color: var(--green); box-shadow: inset 0 0 0 2px #06122b; }
.prep-frame { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 6px 0 12px; }
@media (max-width: 1000px) { .prep-frame { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.prep-frame li { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 7px 10px; display: flex; flex-direction: column; gap: 1px; position: relative; padding-left: 34px; }
.prep-frame li i { position: absolute; left: 9px; top: 8px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-dim); color: #cfe0ff; font-style: normal; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.prep-frame b { font-size: 12.5px; }
.prep-frame span { font-size: 11.5px; color: var(--dim-2); line-height: 1.35; }

/* quick sheet inside the question brief */
.prep-sheet { margin: 12px 0; background: var(--panel); border: 1px solid #25456f; border-radius: 12px; padding: 0 14px 12px; }
.prep-sheet > summary { cursor: pointer; padding: 9px 0; list-style: none; display: flex; gap: 10px; align-items: baseline; }
.prep-sheet > summary::-webkit-details-marker { display: none; }
.prep-sheet > summary::before { content: "▸"; font-size: 10px; color: var(--dim-2); }
.prep-sheet[open] > summary::before { content: "▾"; }
.prep-sheet > summary b { color: #cfe0ff; font-size: 13.5px; }
.prep-sheet > summary span { font-size: 11.5px; color: var(--dim-2); }
.prep-sheet h5 { margin: 12px 0 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: #7ab8ff; }
.prep-sheet h5 small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--dim-2); margin-left: 6px; }
.prep-steps { margin: 2px 0; padding-left: 20px; font-size: 12.5px; color: var(--dim); line-height: 1.5; }
.prep-steps li { margin: 3px 0; }
.prep-steps b { color: #dce8fa; }
.prep-kp { margin: 2px 0 8px; padding-left: 18px; font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.prep-kp b { color: #9ff0d8; margin-right: 4px; }
.prep-ascii { margin: 2px 0; padding: 8px 10px; background: #0b1220; border: 1px solid var(--line); border-radius: 8px; font: 11px/1.5 var(--mono); color: #cfe0ff; overflow-x: auto; white-space: pre; }
.prep-hint { font-size: 11.5px; color: var(--dim-2); margin-top: 3px; }
.prep-follow { display: flex; flex-wrap: wrap; gap: 5px; }
.prep-pill { border: 1px solid var(--line); background: #0b1220; color: var(--dim); border-radius: 99px; padding: 2px 11px; font-size: 12px; text-align: left; }
.prep-pill:hover { color: var(--text); border-color: #3a527a; }
.prep-sayit { margin: 2px 0 8px; padding: 7px 12px; border-left: 3px solid var(--green); background: var(--green-dim); color: #c8f8ec; border-radius: 0 8px 8px 0; font-size: 13px; line-height: 1.55; }

/* Say It: Coding | System design, then General | AI */
.say-seg-wrap { padding: 10px 10px 0; display: flex; flex-direction: column; gap: 6px; }
.say-seg { display: flex; gap: 2px; padding: 3px; background: #0b1220; border: 1px solid var(--line); border-radius: 10px; }
.say-seg.sub { padding: 2px; border-radius: 8px; background: transparent; border-color: var(--line-soft); }
.say-seg-b { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--dim); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.say-seg-b b { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 8px; background: rgba(122,184,255,.1); color: var(--dim-2); }
.say-seg-b:hover { color: var(--text); }
.say-seg-b.on { background: #1d4ed8; color: #fff; }
.say-seg-b.on b { background: rgba(255,255,255,.2); color: #fff; }
.say-seg.sub .say-seg-b { font-size: 12px; padding: 5px 8px; }
.say-seg.sub .say-seg-b.on { background: rgba(59,130,246,.22); color: #9cc9ff; box-shadow: inset 0 0 0 1px rgba(122,184,255,.45); }
.say-seg.sub .say-seg-b.on b { background: rgba(122,184,255,.2); color: #9cc9ff; }

/* ---------------- settings (AI provider + key) ---------------- */
.settings-modal { width: min(560px, 100%); }
.settings-body { display: grid; gap: 14px; }
.settings-lead { margin: 0; color: var(--dim); font-size: 13px; line-height: 1.55; }
.settings-field { display: grid; gap: 6px; }
.settings-field[hidden] { display: none; }
.settings-k { font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--dim-2); }
.settings-help { font-size: 12px; color: var(--dim-2); line-height: 1.5; }
.settings-help code { font-family: var(--mono); font-size: 11.5px; color: var(--dim); }
.settings-body select.custom-input, .settings-body input.custom-input { width: 100%; min-height: 32px; font-size: 13px; }
.settings-body select.custom-input { background: var(--panel-2); color: var(--text); }
.settings-key-row { display: flex; gap: 8px; align-items: stretch; }
.settings-key-row input { flex: 1; font-family: var(--mono); }
.settings-key-row .btn { min-width: 64px; }
.settings-privacy {
  border: 1px solid #1f4a45;
  background: var(--green-dim);
  color: #c9f3ec;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
}
.settings-privacy b { color: var(--green); }
.settings-status { min-height: 18px; font-size: 12.5px; color: var(--dim); }
.settings-status.good { color: var(--green); }
.settings-status.bad { color: var(--red); }
.settings-modal .modal-f .spacer { flex: 1; }

.ai-notice {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: none;
  gap: 10px;
  align-items: flex-start;
  max-width: 420px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--dim);
}
.ai-notice.on { display: flex; }
.ai-notice-t { display: grid; gap: 2px; flex: 1; }
.ai-notice-t b { color: var(--text); font-size: 13px; }
.ai-notice-a { display: flex; gap: 6px; flex-shrink: 0; }

/* ---- Company questions: filter chips + question-view block ---- */
.group-h.co-group { color: #2dd4bf; }
.callout.co-evidence {
  border-style: solid;
  border-color: #2b4470;
  background: #101828;
  color: #b8c8e2;
}
.co-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.co-head b { color: #cfe0ff; }
.co-badge {
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; border: 1px solid #5b6b85; color: #a9b6cc;
}
.co-badge.ok { border-color: #2dd4bf; color: #2dd4bf; background: rgba(45, 212, 191, .08); }
.co-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.co-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; border: 1px dashed #3b4f72; color: #b8c8e2; background: #0d1524;
}
.co-tag i { font-style: normal; font-size: 10.5px; color: #7f8fa8; }
.co-tag.ok { border: 1px solid #63a4ff; color: #cfe0ff; background: rgba(99, 164, 255, .1); }
.co-tag.ok i { color: #2dd4bf; }
.co-note { margin-top: 7px; font-size: 12px; color: #8fa3c2; }

/* Round 2: report dates (list badge + Asked-at source labels) */
.item .rep-date { flex: none; font-size: 10px; line-height: 1; padding: 2px 5px; border-radius: 4px; margin-left: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .rep-date.fh { color: #04201c; background: #2dd4bf; font-weight: 600; }
.item .rep-date.ls { color: #8fb6e8; border: 1px solid rgba(99, 164, 255, .35); background: transparent; }
#recent-chips .chip.sort { border-style: dashed; }
.srcs .src-when { display: inline-block; min-width: 118px; margin-right: 6px; font-size: 10.5px; font-variant-numeric: tabular-nums; color: #7f8fa8; }
.srcs .src-when.reported { color: #2dd4bf; font-weight: 600; }
.srcs .src-when.listed { color: #63a4ff; }
.srcs .src-when.snapshot { color: #9aa7bb; }
.srcs .src-when.unknown { color: #6b778a; font-style: italic; }

/* ================================================================
   Library / Queue sidebar (2026-11-21 spec)
   One panel at a time, compact filters, company dropdown, queue reorder.
   Every colour is an existing token or a literal style.css already uses.
   ================================================================ */

/* ---------- 0. Minimal scroll fix (safe to ship on its own) ---------- */
/* Root cause: .side-tools (style.css:115) is a flex item of .side-code (1818) and keeps
   min-height:auto, so it cannot shrink below its 595px content. .sidebar (80) clips it. */
.side-code > .side-tools,
.side-panel > .side-tools {
  flex: 0 1 auto;          /* allowed to shrink */
  min-height: 0;           /* the actual fix: drop the min-height:auto floor */
  max-height: 55%;         /* the list always keeps at least 45% of the column */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.side-code > #q-list,
.side-panel > #q-list { flex: 1 1 0; min-height: 96px; }

/* ---------- 1. Tabs (mirrors .page-nav, style.css:1790-1815) ---------- */
.side-tabs {
  display: flex; gap: 2px; padding: 3px;
  margin: 10px 12px 2px;
  border: 1px solid var(--line); border-radius: 8px; background: #0b111a;
  flex: 0 0 auto;
}
.side-tab {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 30px; padding: 0 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--dim); font-size: 12px; font-weight: 550; line-height: 1;
  transition: background .12s ease, color .12s ease;
}
.side-tab:hover { color: var(--text); background: var(--panel-2); }
.side-tab[aria-selected="true"] { color: #dbe8ff; background: var(--accent-dim); box-shadow: inset 0 0 0 1px #2b4470; }
.side-tab:focus-visible { outline: 2px solid #8ec5ff; outline-offset: -2px; }
.tab-count {
  font-family: var(--mono); font-size: 10px; line-height: 16px; min-width: 18px; padding: 0 5px;
  border-radius: 99px; text-align: center; color: #9fc0ff; background: var(--accent-dim);
}
.side-tab[aria-selected="true"] .tab-count { background: #0b111a; }
.tab-count.pulse { animation: tab-count-pulse .32s cubic-bezier(.2, .8, .2, 1); }
@keyframes tab-count-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 164, 255, 0); }
  40% { transform: scale(1.22); box-shadow: 0 0 0 3px rgba(99, 164, 255, .28); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 164, 255, 0); }
}

/* ---------- 2. Panels: one at a time, full height ---------- */
.side-panel { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.side-panel[hidden] { display: none; }
/* The stacked queue goes: no fixed height, no splitter. */
#panel-queue .queue-list { flex: 1 1 0; height: auto; max-height: none; min-height: 0; border-bottom: 0; }

/* ---------- 3. Library tools ---------- */
#panel-library .side-tools { padding: 8px 12px 6px; gap: 6px; }
.filter-row { display: flex; align-items: center; gap: 6px; }
/* Company takes the slack; its label ellipsizes ("Amazon, Meta +2") so the row never wraps, down to the 240px sidebar clamp. */
.co-trigger { flex: 1 1 auto; min-width: 0; justify-content: space-between; border-color: var(--line); }
.co-trigger .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more-trigger { flex: 0 0 auto; border-color: var(--line); }
.co-trigger, .more-trigger { gap: 5px; }
.co-trigger .chev, .more-trigger .chev { font-size: 9px; color: var(--dim-2); transition: transform .15s ease; }
.co-trigger[aria-expanded="true"] .chev, .more-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }
.co-trigger.on, .more-trigger.on { border-color: var(--accent); color: #cfe0ff; background: var(--accent-dim); }
.more-trigger .n { font-family: var(--mono); font-size: 10px; color: #9fc0ff; }

/* Company popover (combobox + listbox). It is a child of #panel-library, NOT of the
   scrolling .side-tools (or it would be clipped). JS sets --co-pop-top on open to
   trigger.offsetTop + trigger.offsetHeight + 4 (relative to the panel). */
.co-pop {
  position: absolute; z-index: 30; left: 12px; right: 12px; top: var(--co-pop-top, 72px);
  display: flex; flex-direction: column; max-height: min(360px, 60vh);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.co-pop[hidden] { display: none; }
.co-pop .search { margin: 8px 8px 4px; width: auto; }
.co-opts { overflow-y: auto; min-height: 0; padding: 0 4px 6px; overscroll-behavior: contain; }
.co-cat { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim-2); padding: 8px 8px 3px; }
.co-opt {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 6px; font-size: 12.5px; color: var(--dim); cursor: pointer;
}
.co-opt .box { width: 12px; height: 12px; border: 1px solid var(--dim-2); border-radius: 3px; display: grid; place-items: center; font-size: 9px; color: #06122b; }
.co-opt[aria-selected="true"] { color: var(--text); }
.co-opt[aria-selected="true"] .box { background: var(--accent); border-color: var(--accent); }
.co-opt[aria-selected="true"] .box::after { content: "✓"; }
.co-opt.active, .co-opt:hover { background: var(--panel-2); }
.co-opt .n { font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); }
.co-opt mark { background: none; color: var(--accent); }
.co-pop-foot { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line-soft); }

/* "More filters" groups: one row each, "+N more" expands in place. */
.more-filters { display: grid; gap: 8px; padding: 2px 0 4px; }
.more-filters[hidden] { display: none; }
.more-filters .lib-filters-k { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim-2); }
.chips.collapsed > .chip:nth-child(n+6):not(.on):not(.more) { display: none; }
.chip.more { border-style: dashed; color: var(--dim-2); }

/* Active-filter summary */
/* Pinned: a direct child of #panel-library, between .side-tools and .result-line,
   so it never scrolls away with the filters. */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 0 0 auto; padding: 0 12px 6px; }
.active-filters[hidden] { display: none; }
.af-chip { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; }
.af-chip .x { border: 0; background: none; color: #9fc0ff; font-size: 12px; line-height: 1; padding: 0 2px; border-radius: 4px; }
.af-chip .x:hover { color: var(--text); }
.af-clear { margin-left: auto; }

.result-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 12px 4px; font-size: 11px; color: var(--dim-2);
  border-top: 1px solid var(--line-soft); flex: 0 0 auto;
}
.result-line b { color: var(--dim); font-weight: 600; }
.sort-toggle { font-size: 11px; color: var(--dim); background: none; border: 0; padding: 2px 4px; border-radius: 4px; }
.sort-toggle[aria-pressed="true"] { color: var(--accent); }

/* ---------- 4. Rows: company tags (strict company mode only) ----------
/* .co-tag and .co-tags already exist at style.css:3911 for the Asked-at callout, so the row uses .row-co* */
.item.has-co { grid-template-rows: auto auto; row-gap: 3px; }
.item.has-co > .row-cos { grid-column: 2 / 5; grid-row: 2; }
.row-cos { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 168px; overflow: hidden; }
.row-co {
  font-family: var(--mono); font-size: 10px; line-height: 15px; padding: 0 5px; border-radius: 4px;
  max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto;
  color: var(--dim); background: var(--panel-2); border: 1px solid var(--line-soft);
}
.row-co.sel { color: #cfe0ff; background: var(--accent-dim); border-color: #2b4470; }
.row-co-more { font-family: var(--mono); font-size: 10px; color: var(--dim-2); flex: none; }

/* ---------- 5. Add-to-queue feedback ---------- */
.add-btn.queued { color: var(--accent); border-color: transparent; cursor: pointer; }
.add-btn.queued:hover { color: var(--red); }
.item.just-queued { background: var(--accent-dim); transition: background .6s ease; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- 6. Queue panel ---------- */
#panel-queue .queue-head { border-top: 0; }
.qrow { grid-template-columns: 12px 18px 18px minmax(0, 1fr) auto auto; }
.qrow .grip { color: var(--dim-2); cursor: grab; font-size: 11px; letter-spacing: -2px; opacity: 0; transition: opacity .12s ease; user-select: none; }
.qrow:hover .grip, .qrow:focus-within .grip, .qrow:focus-visible .grip { opacity: 1; }
.qrow .mini.up, .qrow .mini.down { visibility: hidden; }
.qrow:hover .mini, .qrow:focus-within .mini, .qrow:focus-visible .mini, .qrow.grabbed .mini { visibility: visible; }
.qrow .mini.down[disabled], .qrow .mini.up[disabled] { opacity: .35; }
.qrow.dragging { opacity: .55; }
.qrow.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.qrow.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.qrow.grabbed { outline: 1px dashed var(--accent); outline-offset: -1px; background: var(--accent-dim); }

.side-empty { display: grid; justify-items: center; gap: 10px; padding: 36px 20px; text-align: center; color: var(--dim-2); font-size: 12.5px; }
.side-empty b { color: var(--dim); font-size: 13px; font-weight: 600; }

.skel { height: 36px; margin: 0 8px 2px; border-radius: 7px; background: var(--panel-2); opacity: .6; }

/* ---------- 7. Narrow / touch ---------- */
@media (max-width: 760px), (pointer: coarse) {
  .side-tab { min-height: 40px; font-size: 13px; }
  .co-opt { min-height: 44px; }
  .qrow .grip { opacity: 1; }
  .qrow .mini.up, .qrow .mini.down { visibility: visible; }
  .af-chip .x { min-width: 28px; min-height: 28px; }
}
@media (max-width: 760px) {
  .co-pop { max-height: 70dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .tab-count.pulse { animation: none; }
  .item.just-queued { transition: none; }
  .side-tab, .co-trigger .chev, .more-trigger .chev, .qrow .grip { transition: none; }
}

/* ---------- 8. Build additions (same tokens) ---------- */
.side-panel > .side-tools { padding: 8px 12px 6px; gap: 6px; }
.co-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 4px 0 6px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); font-size: 12px; color: var(--dim); }
.co-suggest .co-apply { border: 0; background: none; color: #cfe0ff; font-size: 12px; font-weight: 600; padding: 0; text-align: left; }
.co-suggest .co-apply:hover { color: var(--accent); }
.co-suggest .co-dismiss { border: 0; background: none; color: var(--dim-2); font-size: 11px; padding: 0; font-style: italic; }
.co-suggest .co-dismiss:hover { color: var(--text); }
.side-empty .empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toast .toast-act { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 12.5px; padding: 0; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* =====================================================================
   Usability pass (2026-11-21). Same tokens, no new colors.
   ===================================================================== */

/* #1 First-run tip strip (replaces the auto-opening help modal) */
.tip-strip {
  height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--dim);
  overflow: hidden;
}
.tip-strip[hidden] { display: none; }
.tip-body { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tip-step { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.tip-step b { color: var(--text); font-weight: 600; }
.tip-n {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-dim); color: #cfe0ff !important; font-size: 11px; font-family: var(--mono); flex: none;
}
.tip-step.done { color: var(--dim-2); text-decoration: line-through; text-decoration-color: var(--line); }
.tip-step.done .tip-n { background: var(--green-dim); color: var(--green) !important; }
.tip-step kbd { margin: 0 1px; }
.tip-sep { color: var(--dim-2); }
.tip-more { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-style: italic; }
.tip-more:hover { text-decoration: underline; }
.tip-x { border: 0; background: none; color: var(--dim-2); font-size: 14px; padding: 4px 6px; border-radius: 5px; flex: none; }
.tip-x:hover { color: var(--text); background: var(--panel); }
body.has-tip .app { height: calc(100vh - 90px); height: calc(100dvh - 90px); }
@media (max-height: 520px) and (orientation: landscape) {
  body.has-tip .app { height: calc(100vh - 84px); height: calc(100dvh - 84px); }
  body.has-tip.sidebar-drawer .sidebar, body.has-tip.chat-open .chat-pane { top: 84px; }
}

/* How it works: Guide | Shortcuts tabs; shortcuts are never below the fold */
.help-tabs { padding: 0; margin: -4px 0 14px; }
.sc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.sc-group .section-h { margin-top: 10px; }
.sc-table td:first-child { white-space: nowrap; width: 1%; padding-right: 14px; }
.sc-table td:last-child { text-align: left; font-family: var(--sans); white-space: normal; color: #c9d5e6; }
.sc-table kbd { margin-left: 0; }
@media (max-width: 760px) { .sc-grid { grid-template-columns: 1fr; } }

/* #2 / #7 one primary "Run tests"; the editor-bar Run proxy and status are gone (the dock says it) */
#btn-run-2 { display: none !important; }
.editor-bar #status { display: none; }
#btn-speak, #btn-speak-top { white-space: nowrap; }

/* #6 fewer top-bar controls: Notes is the Notes tab; Reset lives in More */
#btn-notes, #btn-reset { display: none !important; }
body.mode-cards #btn-reset-more { display: none; }
.src-more { margin-top: 6px; }
.src-more > summary { cursor: pointer; color: var(--dim); font-size: 12px; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.src-more > summary::-webkit-details-marker { display: none; }
.src-more > summary::after { content: "▸"; font-size: 10px; transition: transform .12s ease; }
.src-more[open] > summary::after { transform: rotate(90deg); }
.src-more > summary:hover { color: var(--text); }
@media (max-width: 640px) {
  .src-more > summary, .link-btn { min-height: 44px; padding: 0 8px; margin: 0 -8px; display: inline-flex; align-items: center; }
  .page-nav button { min-width: 44px; }
  .myq-row .custom-input { min-height: 44px; }
  .myq-x { width: 44px; height: 44px; }
  .m-views button { min-height: 44px; }
}

.src-more .srcs a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* #3 queued Library rows show their queue position; hover/focus shows × to remove */
#q-list .item { grid-template-columns: 18px minmax(0, 1fr) auto auto 28px; }
.add-btn.queued { width: auto; min-width: 22px; padding: 0 3px; font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); position: relative; }
.add-btn.queued:hover, .add-btn.queued:focus-visible { color: transparent; border-color: #4a2630; }
.add-btn.queued:hover::after, .add-btn.queued:focus-visible::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-family: var(--sans); font-size: 13px; }

/* #4 starter queue line */
.queue-starter { display: grid; gap: 4px; margin: 0 12px 6px; padding: 7px 9px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--panel-2); font-size: 12px; color: var(--dim-2); line-height: 1.45; }
.queue-starter[hidden] { display: none; }
.queue-starter b { color: var(--dim); font-weight: 600; }
.queue-starter-acts { display: flex; gap: 14px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.link-btn.dim { color: var(--dim); font-weight: 500; }
.queue-title.sentence { text-transform: none; letter-spacing: 0; font-size: 12px; }

/* #5 / #10 the grip is always visible; ↑/↓ stay on hover/focus; footer hint names them */
.qrow .grip { opacity: 1; color: var(--dim-2); }
.qrow:hover .grip, .qrow:focus-within .grip { color: var(--dim); }
.queue-foot { flex: 0 0 auto; padding: 5px 12px 6px; border-top: 1px solid var(--line-soft); font-size: 11px; line-height: 1.4; color: var(--dim-2); }
.queue-foot[hidden] { display: none; }

/* #9 filter triggers look like buttons; Company shows its count */
.co-trigger, .more-trigger { border-color: var(--line) !important; }
.co-trigger .co-n { color: var(--dim-2); font-family: var(--mono); font-size: 10.5px; }
.side-empty i { color: var(--dim); }

/* #8 AI off: one calm empty state in the pane */
.ai-off { margin-top: 14px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--dim); font-size: 13px; line-height: 1.55; }
.ai-off b { color: var(--text); }
.ai-off-act { margin-top: 10px; }

/* Ask AI: Copy always visible (dim), like the queue grip */
.chat-msg-actions { opacity: .7; }
.chat-msg:hover .chat-msg-actions { opacity: 1; }

/* Type and spacing floors (existing tokens) */
.chip { font-size: 12px; padding: 4px 10px; }
.group-h, .more-filters .lib-filters-k { color: var(--dim); }
.item:focus-visible .t { white-space: normal; }
.doc .body-text { max-width: 68ch; }

/* #11 Say It: Record is the primary until a transcript exists; settings fold away */
.say-mic.secondary { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.say-settings { margin-top: 10px; }
.say-settings > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim); }
.say-settings > summary::-webkit-details-marker { display: none; }
.say-settings > summary::after { content: "▾"; font-size: 10px; color: var(--dim-2); }
.say-settings[open] > summary::after { content: "▴"; }
.say-settings > summary:hover { color: var(--text); }
.say-settings-sum { color: var(--dim-2); font-size: 12px; }
.say-settings-row { margin-top: 8px; }
.say-subchips { padding: 0 2px; }
.say-subchips .chip .n { font-family: var(--mono); font-size: 10.5px; color: var(--dim-2); }
.say-subchips .chip.on .n { color: #cfe0ff; }

/* =====================================================================
   Mobile pass (2026-11-21): phones 375-430px and tablets.
   Desktop (>= 1280px, fine pointer) is unchanged except the theme button.
   ===================================================================== */

/* theme toggle (js/theme.js) */
.theme-btn { font-size: 16px; line-height: 1; padding: 0; width: 34px; justify-content: center; }
.theme-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.theme-seg .btn { flex: 1 1 0; justify-content: center; min-width: 92px; }
.theme-seg .btn.on { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }
.theme-btn { position: relative; }
.theme-btn .theme-ic { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: 0; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; transition: opacity 150ms cubic-bezier(.2, .8, .2, 1); }
html[data-theme=light] .theme-btn .theme-ic-sun,
html[data-theme=dark] .theme-btn .theme-ic-moon { opacity: 1; }

/* demo banner (js/demo-mode.js): a 40px slim strip at every width, below modals. */
#demo-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 6px; align-items: center; height: 40px;
  padding: 0 4px 0 14px; padding-bottom: env(safe-area-inset-bottom);
  background: #1e293b; color: #f8fafc; border: 0; border-top: 1px solid #f59e0b;
  font: 13px/1.4 system-ui, -apple-system, Segoe UI, sans-serif;
}
#demo-banner .db-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#demo-banner b { color: #fbbf24; }
#demo-banner a { color: #93c5fd; }
#demo-banner button { background: none; border: 0; color: #cbd5e1; font-size: 16px; cursor: pointer; flex: none; width: 44px; height: 40px; }
body.modal-open #demo-banner,
body:has(.modal-back.on) #demo-banner { display: none; }
body.has-demo-banner .app { height: calc(100vh - 92px); height: calc(100dvh - 92px); }
body.has-demo-banner.has-tip .app { height: calc(100vh - 130px); height: calc(100dvh - 130px); }
body.has-demo-banner.sidebar-drawer .sidebar, body.has-demo-banner.chat-open .chat-pane { bottom: 40px; }
body.has-demo-banner .toast { bottom: calc(52px + env(safe-area-inset-bottom)); }

/* phone pane switcher: hidden unless the phone block below turns it on */
.m-views { display: none; }

/* touch screens: finger-sized targets, no zoom-on-focus, no keyboard hints */
@media (max-width: 760px), (pointer: coarse) {
  .btn, .btn.tiny, .topbar .btn, .global-nav .btn { min-height: 44px; }
  .sort-toggle, .say-seg-b, .say-li { min-height: 44px; }
  .item .add-btn, .qrow .add-btn { width: 40px; min-width: 40px; }
  .icon-btn, .theme-btn { min-width: 44px; }
  .tab, .side-tab, .study-tab, .arch-tabs button, .say-tabs button, .lt-codetab { min-height: 44px; }
  .chip { min-height: 40px; }
  #demo-banner a { display: inline-block; padding: 10px 0; }
  .page-nav button, .design-views button { min-height: 44px; }
  .qrow .mini, .add-btn { width: 40px; height: 40px; }
  .item { grid-template-columns: 16px minmax(0, 1fr) auto auto 40px; }
  .tip-x { min-width: 44px; min-height: 38px; }
  .ln-crumb { min-height: 40px; padding: 8px 2px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select,
  .search, .custom-input, .lt-code-input, .say-list-q { font-size: 16px !important; }
  .code-host { --ed-font: 16px; }
  kbd, .queue-foot, #btn-shortcuts, .tip-desk { display: none !important; }
}
.tip-touch { display: none; }
.tip-desk { display: contents; }
@media (max-width: 760px), (pointer: coarse) { .tip-touch { display: inline; } }

/* phones */
@media (max-width: 760px) {
  .chip { min-height: 44px; }
  /* bigger touch targets make the filters taller, so they scroll sooner and the list keeps its room */
  .side-code > .side-tools, .side-panel > .side-tools { max-height: 40%; }
  /* top nav: page tabs scroll sideways, Ask AI is just its icon */
  .global-nav { gap: 4px; padding: 0 6px; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
  .global-nav > .spacer { display: none; }
  .page-nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; flex-wrap: nowrap; }
  .page-nav::-webkit-scrollbar { display: none; }
  .page-nav button { flex: 0 0 auto; padding: 0 10px; }
  #btn-chat { padding: 0; width: 44px; min-width: 44px; justify-content: center; }
  #btn-chat .chat-lbl { display: none; }
  #btn-settings { width: 44px; }

  /* first-run tip: one step at a time, no overlap */
  .tip-strip { height: 44px; padding: 0 0 0 12px; gap: 4px; }
  .tip-body { gap: 8px; }
  .tip-body .tip-step.done, .tip-body .tip-sep, .tip-body .tip-more { display: none; }
  .tip-body .tip-step:not(.done) ~ .tip-step { display: none; }
  .tip-body .tip-step { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tip-body .tip-n { margin-right: 6px; vertical-align: 1px; }
  .tip-x { width: 44px; height: 44px; }
  body.has-tip .app { height: calc(100vh - 96px); height: calc(100dvh - 96px); }
  body.has-demo-banner.has-tip .app { height: calc(100vh - 136px); height: calc(100dvh - 136px); }

  /* coding page: List | Question | Code, one pane at a time */
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)) .m-views {
    display: flex; flex: 1 1 auto; min-width: 0; gap: 3px; padding: 2px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2);
  }
  .m-views button {
    flex: 1 1 0; min-width: 0; min-height: 42px; padding: 0 4px; border: 0; border-radius: 8px; background: transparent;
    color: var(--dim); font-size: 14px; font-weight: 600; white-space: nowrap;
  }
  /* coding top bar on a phone: [List | Question | Code] [⋯] [✓]; AI hint moves into ⋯ */
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)) .topbar > .spacer,
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)) .topbar #btn-hint { display: none; }
  .more-list .more-phone { display: flex; }
  #btn-more, #btn-done { font-size: 0; width: 44px; min-width: 44px; padding: 0 !important; justify-content: center; }
  #btn-more::before { content: "⋯"; font-size: 22px; line-height: 1; }
  #btn-done::before { content: "✓"; font-size: 18px; line-height: 1; }
  .topbar { height: 54px; }
  /* design views scroll sideways instead of pushing the page wider */
  .design-views { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .design-views::-webkit-scrollbar { display: none; }
  .design-views button { flex: 0 0 auto; }
  .m-views button.on { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)) .workspace, body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)) .workspace.ai-open { grid-template-rows: minmax(0, 1fr) !important; }
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)):not([data-mview=code]) .workspace > .pane.right { display: none; }
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn))[data-mview=code] .workspace > .pane.left { display: none; }
  body:not(:is(.mode-design, .mode-aws, .mode-say, .mode-learn)) .workspace > .pane.left { border-bottom: 0; }
  .editor-bar { gap: 6px; flex-wrap: nowrap; }
  .editor-bar #btn-speak { display: none; }
  .test-dock:not(.collapsed) { max-height: 50%; }

  /* Say It */
  .say-head { padding: 8px 12px; gap: 8px; }
  .say-tabs { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .say-tabs::-webkit-scrollbar { display: none; }
  .say-tabs button { flex: 1 0 auto; }
  .say-title span { display: none; }

  /* Learn */
  .ln-tracks { grid-template-columns: minmax(0, 1fr); }
  .ln-page, .ln-page.wide { padding: 12px 12px 56px; }
  .lt-code { font-size: 13px; }
  .lt-cfields { grid-template-columns: minmax(0, 1fr); }
  .ln-rail { scrollbar-width: none; }
  .ln-rail-step { flex: 0 0 auto; max-width: 70vw; white-space: nowrap; min-height: 44px; }
  .ln-rail-step.apply { margin-top: 0; border-top: 0; border-radius: 8px; padding-top: 6px; }
}

/* ============================================================
   Consistency pass (ui-polish, Nov 2026): same look, fewer rough edges.
   Only existing tokens; transitions use the app's 120-200 ms ease-out.
   ============================================================ */

/* states: one quiet, consistent transition for every control that changes colour */
:where(.btn, .chip, .page-nav button, .side-tab, .tab, .study-tab, .arch-tabs button, .say-seg-b, .say-tabs button,
  .m-views button, .design-views button, .theme-seg .btn, .item, .qrow, .more-list button, .ln-crumb) {
  transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out, box-shadow .15s ease-out;
}
:where(.btn, .chip, .say-seg-b, .side-tab, .m-views button):disabled { cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
  :where(.btn, .chip, .page-nav button, .side-tab, .tab, .study-tab, .arch-tabs button, .say-seg-b, .say-tabs button,
    .m-views button, .design-views button, .theme-seg .btn, .item, .qrow, .more-list button, .ln-crumb) { transition: none; }
}

/* one "Last asked" per question: the header under the title keeps it, the top bar drops the copy */
.topbar .title .last-asked { display: none; }

/* one Mark done: after a passing run the dock's button is the action, so the top-bar twin steps aside
   (both stay the same control; on phones the dock can be off-screen, so both stay there) */
@media (min-width: 761px) {
  body:has(#btn-complete) .topbar #btn-done { display: none; }
}

/* sources: "date unknown" reads like its dated siblings (same mono column, AA dim ink, no italics) */
.srcs .src-when.unknown { color: var(--dim-2); font-style: normal; }

/* Say It: the Coding | System design switch uses the app's selected-tab look and the shared count badge */
.say-seg { background: var(--bg); }
.say-seg-b.on { background: var(--accent-dim); color: #dbe8ff; box-shadow: inset 0 0 0 1px #2b4470; }
.say-seg-b b { font-family: var(--mono); font-weight: 600; background: var(--accent-dim); color: #9fc0ff; }
.say-seg-b.on b { background: var(--bg); color: #9fc0ff; }
.say-seg.sub .say-seg-b.on { background: var(--accent-dim); color: #cfe0ff; box-shadow: inset 0 0 0 1px var(--accent); }
.say-seg.sub .say-seg-b.on b { background: var(--bg); color: #9fc0ff; }
.say-gh span { opacity: 1; }
.say-streak { line-height: 1.5; white-space: nowrap; }

/* Settings: Theme is its own group, the AI provider block starts below a hairline */
.settings-field:has(> .theme-seg) { padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }

/* toasts on narrow screens use the whole width instead of half of it */
.toast { width: max-content; max-width: min(560px, calc(100vw - 24px)); }

/* phones held upright: try to fit every page tab; if they cannot, scroll sideways
   so Learn stays reachable (overflow:hidden used to clip it). */
@media (max-width: 430px) {
  .global-nav { height: auto; min-height: 46px; align-items: center; flex-wrap: wrap; }
  /* the tab bar can be two rows tall here: fixed panels start under the real chrome (js/mobile.js) */
  body.sidebar-drawer .sidebar, body.has-tip.sidebar-drawer .sidebar,
  body.chat-open .chat-pane, body.has-tip.chat-open .chat-pane { top: var(--chrome-top, 52px); }
  body.sidebar-drawer::before { top: var(--chrome-top, 52px); }
  body .app, body.has-tip .app, body.has-demo-banner .app, body.has-demo-banner.has-tip .app {
    height: calc(100vh - var(--chrome-top, 52px) - var(--banner-h, 0px)); height: calc(100dvh - var(--chrome-top, 52px) - var(--banner-h, 0px)); }
  .page-nav { flex: 1 1 160px; overflow: visible; gap: 1px; flex-wrap: wrap; }
  .page-nav button { flex: 1 1 auto; min-width: 44px; padding: 0 5px; font-size: 12.5px; }
}

/* phones on their side: slim bars, so the editor and canvas keep their height */
@media (max-height: 520px) and (orientation: landscape) {
  .global-nav .btn, .topbar .btn, .editor-bar .btn, .editor-bar .btn.tiny,
  .page-nav button, .design-views button, .m-views button { min-height: 36px; }
  .design-views { padding: 2px; align-self: center; }
  .editor-bar { min-height: 44px; padding: 4px 10px; }
  .test-dock:not(.collapsed) { max-height: 34%; }
  .tip-strip { height: 36px; }
  body.has-tip .app { height: calc(100vh - 82px); height: calc(100dvh - 82px); }
}

/* ---------- My questions (js/my-questions-ui.js): Add / Edit form, badges, callout ---------- */
.add-q-btn {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-dim); border: 1px solid transparent; border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.add-q-btn:hover { border-color: var(--accent); }
.add-q-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 760px), (pointer: coarse) { .add-q-btn { min-height: 44px; padding: 0 14px; font-size: 12.5px; } }
.src-badge {
  display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 4px; margin-right: 4px; line-height: 1.5; vertical-align: middle;
}
.src-badge.mine { color: var(--accent); background: var(--accent-dim); }
.src-badge.community { color: var(--green); background: var(--green-dim); }
.group-h.my-group, .group-h.cm-group { color: var(--dim); }
.myq-modal { width: min(720px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.myq-modal .modal-b { flex: 1 1 auto; min-height: 0; }
.myq-modal .modal-h { gap: 6px; flex-wrap: wrap; }
.myq-body textarea.custom-input { width: 100%; font-size: 12.5px; }
.myq-two { display: grid; grid-template-columns: 160px 1fr; gap: 12px; }
.myq-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.myq-row .custom-input { flex: 1 1 0; min-width: 0; min-height: 32px; }
.myq-ex-row { flex-wrap: wrap; }
.myq-ex-row .custom-input:not(.myq-wide) { flex-basis: calc(50% - 22px); }
.myq-ex-row .myq-wide { flex: 1 1 100%; order: 3; }
.myq-x { flex: 0 0 auto; min-width: 28px; font-size: 15px; line-height: 1; color: var(--dim-2); }
.myq-x:hover { color: var(--red); }
.myq-add { justify-self: start; }
.myq-opt { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--dim-2); margin-left: 4px; }
.myq-k-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.myq-k-row .settings-k { margin-right: auto; }
.myq-tabs { display: inline-flex; gap: 8px; }
.myq-tabs [aria-selected="true"] { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.myq-preview { border: 1px solid var(--line); border-radius: 7px; padding: 8px 12px; min-height: 120px; background: var(--panel-2); }
.myq-preview[hidden] { display: none; }
.myq-field-err { color: var(--bad, var(--red)); font-size: 12px; margin-top: 4px; line-height: 1.35; }
.custom-input[aria-invalid=true] { border-color: var(--bad, var(--red)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad, var(--red)) 18%, transparent); }
.myq-errors:empty, .myq-results:empty { display: none; }
.myq-errors ul { margin: 4px 0 0 18px; padding: 0; }
.myq-results { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); font-size: 12.5px; }
.myq-res-h { font-weight: 650; margin-bottom: 6px; color: var(--dim); }
.myq-res-h.good { color: var(--green); }
.myq-res-h.bad { color: var(--red); }
.myq-res { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.myq-res li { overflow-wrap: anywhere; color: var(--dim); }
.myq-res li.pass > span { color: var(--green); }
.myq-res li.fail > span { color: var(--red); }
.myq-res code, .myq-ex code { font-family: var(--mono); font-size: 12px; color: var(--text); }
.myq-err { color: var(--red); }
.myq-fatal { white-space: pre-wrap; color: var(--red); font-family: var(--mono); font-size: 12px; margin: 0 0 6px; }
.myq-steps { margin: 4px 0 8px 18px; padding: 0; }
.mono { font-family: var(--mono); }
.myq-ex { border-left: 2px solid var(--line); padding: 4px 0 4px 10px; margin: 10px 0; display: grid; gap: 2px; }
.myq-k { display: inline-block; min-width: 52px; font-size: 11px; font-weight: 650; color: var(--dim-2); text-transform: uppercase; letter-spacing: .03em; }
.myq-why { color: var(--dim); font-size: 13px; }
.myq-callout { display: grid; gap: 8px; margin-top: 12px; }
.myq-callout a { color: var(--accent); }
.myq-actions { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.myq-more { position: relative; flex: none; }
.myq-more > summary { list-style: none; cursor: pointer; min-width: 36px; justify-content: center; }
.myq-more > summary::-webkit-details-marker { display: none; }
.myq-more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 8; display: grid; gap: 2px; min-width: 132px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.myq-more-menu .btn { justify-content: flex-start; width: 100%; }
.myq-danger { color: var(--red); }
@media (max-width: 520px) {
  .myq-modal { max-height: 100dvh; border-radius: 0; }
  .myq-two { grid-template-columns: 1fr; }
  .myq-ex-row .custom-input:not(.myq-wide) { flex-basis: 100%; }
  .myq-modal .modal-f { flex-wrap: wrap; }
}
.myq-modal [hidden], #myq-submit [hidden] { display: none !important; }
.myq-body input.custom-input:not(.mono), .myq-body select.custom-input, #myq-f-desc, #myq-sub-author { font-family: var(--sans); font-size: 13.5px; }
:is(.myq-md, .myq-preview) { white-space: normal; }
:is(.myq-md, .myq-preview) p { margin: 0 0 10px; }
:is(.myq-md, .myq-preview) ul, :is(.myq-md, .myq-preview) ol { margin: 0 0 10px 20px; padding: 0; }
:is(.myq-md, .myq-preview) pre { white-space: pre; overflow-x: auto; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 7px; padding: 8px 10px; margin: 0 0 10px; }
:is(.myq-md, .myq-preview) code { font-family: var(--mono); font-size: .92em; background: var(--panel-2); border-radius: 4px; padding: 1px 4px; }
:is(.myq-md, .myq-preview) pre code { background: none; padding: 0; }
:is(.myq-md, .myq-preview) a { color: var(--accent); }

/* Settings: a real gear (not the tiny ⚙ glyph) in the full text colour, a 44×44 tap target
   everywhere, and a visible "Settings" label when the top bar has room. */
#btn-settings.settings-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; height: 44px; padding: 0 10px; flex: 0 0 auto;
  color: var(--text); font-size: 13px; font-weight: 550; line-height: 1;
}
#btn-settings .settings-ic { width: 20px; height: 20px; flex: 0 0 auto; display: block; transition: transform 250ms ease; }
#btn-settings:hover .settings-ic { transform: rotate(45deg); }
#btn-settings:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#btn-settings .settings-lbl { display: none; white-space: nowrap; }
@media (min-width: 1180px) { #btn-settings .settings-lbl { display: inline; } }
@media (max-width: 430px) { #btn-settings.settings-btn { width: 44px; padding: 0; } }
@media (prefers-reduced-motion: reduce) { #btn-settings .settings-ic { transition: none; } }
/* the 44px Settings target is 14px wider than the old glyph; tighten the bar where it was already full */
@media (min-width: 981px) and (max-width: 1100px) { .global-nav { gap: 10px; } }

/* Say it: ask before downloading the speech model */
.say-consent { width: min(560px, 100%); }
.say-consent .modal-b { display: grid; gap: 12px; }
.say-consent .settings-lead { margin: 0; }
.say-consent-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 14px; margin: 0; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--panel-2); font-size: 13px; line-height: 1.5; }
.say-consent-facts dt { color: var(--dim-2); font-weight: 600; }
.say-consent-facts dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.say-consent-facts small { color: var(--dim); }
.say-consent-facts code { font-size: 12px; }
.say-consent-note { margin: 0; font-size: 12.5px; color: var(--dim); }
.say-consent-status { margin: 0; font-size: 13px; color: var(--text); min-height: 1em; }
.say-consent-status:empty { display: none; }
.say-consent .say-progress span { min-width: 0; }
.say-consent .modal-f .btn { min-height: 40px; }
.settings-speech .settings-key-row { align-items: center; }
.settings-speech .settings-help { flex: 1; }
@media (max-width: 430px) {
  .say-consent-facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .say-consent-facts dd { margin-bottom: 8px; }
  .say-consent .modal-f { flex-wrap: wrap; }
  .say-consent .modal-f .btn { flex: 1 1 auto; min-height: 44px; }
}
.say-progress[hidden] { display: none; }
