:root {
  --bg: #e3e8f0; --surface: #e8ecf3; --raised: #edf1f7; --ink: #0c1a33; --ink-2: #33415c; --muted: #6a7691; --faint: #93a0b8;
  --accent: #0193a5; --accent-ink: #ffffff; --accent-soft: #d3eef2; --navy: #051932; --ground-dark: #051932;
  --good: #11865f; --good-soft: #d7efe6; --warn: #a56a00; --warn-soft: #f6e8c9; --bad: #d22f47; --bad-soft: #f8dbe0; --run: #2b5fd9; --run-soft: #dbe5fb;
  --hi: #ffffff; --lo: #c5ccda; --line: #d2d9e6; --code-bg: #dfe5ef;
  --r: 18px; --r-sm: 12px;
  --sh: 9px 9px 20px var(--lo), -9px -9px 20px var(--hi);
  --sh-sm: 5px 5px 11px var(--lo), -5px -5px 11px var(--hi);
  --sh-in: inset 4px 4px 9px var(--lo), inset -4px -4px 9px var(--hi);
  --font: "Plus Jakarta Sans", "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #0f1626; --surface: #131c2f; --raised: #172138; --ink: #e6ecf8; --ink-2: #b8c4dc; --muted: #8190ad; --faint: #5d6c8a;
  --accent: #29b7c9; --accent-soft: #123a45; --good: #3ccf9a; --good-soft: #12362b; --warn: #e5b04a; --warn-soft: #3a2f12; --bad: #ff6b82; --bad-soft: #3e1a22; --run: #6e9bff; --run-soft: #1a2a52;
  --hi: #1b2640; --lo: #0a101d; --line: #22304d; --code-bg: #0e1626; --ground-dark: #0a101d;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; width: 100%; max-width: 100vw; overflow-x: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; box-sizing: border-box; }
#app, main { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }

/* ---------- login ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 34px; border-radius: 26px; background: var(--surface); box-shadow: var(--sh); }
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.btn-google-login { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 13px 20px; font-size: 15px; font-weight: 600; border-radius: 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 4px 4px 10px var(--lo), -3px -3px 8px var(--hi); cursor: pointer; transition: all .15s ease-in-out; }
.btn-google-login:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 6px 6px 14px var(--lo), -4px -4px 10px var(--hi); }
.btn-google-login:active { transform: none; box-shadow: var(--sh-in); }
.btn-google-login .g-icon { display: flex; align-items: center; justify-content: center; }
.login-card .err { margin-top: 14px; font-size: 13px; line-height: 1.4; color: var(--bad, #dc2626); text-align: center; }


/* ---------- controls ---------- */
.btn { border: 0; cursor: pointer; padding: 9px 16px; border-radius: 14px; background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13px; box-shadow: var(--sh-sm); display: inline-flex; align-items: center; gap: 7px; transition: transform .12s, box-shadow .12s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); color: var(--ink); }
.btn:active { box-shadow: var(--sh-in); transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #0a6f80); color: var(--accent-ink); box-shadow: 6px 6px 14px var(--lo), -4px -4px 10px var(--hi), 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:active { box-shadow: inset 3px 3px 8px rgba(0,0,0,.25); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 11px; }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.stop-btn { color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.stop-btn:hover { background: var(--bad-soft); color: var(--bad); }
.btn.stop-btn.is-active-stop { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); animation: pulseStop 1.8s infinite; }
@keyframes pulseStop {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 40%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--bad) 20%, transparent); }
}
.btn.clear-btn { color: var(--muted); }
.btn.clear-btn:hover { color: var(--ink); background: var(--surface); }
.btn.auto-pickup-btn { font-family: var(--mono); font-size: 11px; font-weight: 700; border-radius: 99px; padding: 4px 10px; }
.btn.auto-pickup-btn.on { color: var(--good); background: var(--good-soft); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
.btn.auto-pickup-btn.hold { color: var(--warn); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], select, textarea { width: 100%; border: 0; border-radius: 12px; padding: 10px 13px; background: var(--surface); box-shadow: var(--sh-in); outline: none; }
input:focus, select:focus, textarea:focus { box-shadow: var(--sh-in), 0 0 0 2px var(--accent); }
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 12px; line-height: 1.55; }
label.f { display: block; margin: 0 0 14px; }
label.f > span { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px 2px; }
label.f small { display: block; color: var(--faint); margin: 5px 2px 0; font-size: 11.5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--surface); box-shadow: var(--sh-sm); color: var(--muted); font-family: var(--mono); }
.chip.good { color: var(--good); background: var(--good-soft); box-shadow: none; }
.chip.bad { color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.chip.run { color: var(--run); background: var(--run-soft); box-shadow: none; }
.chip.warn { color: var(--warn); background: var(--warn-soft); box-shadow: none; }
.chip.accent { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.run { background: var(--run); animation: pulse 1s infinite; } .dot.good { background: var(--good); } .dot.bad { background: var(--bad); }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh); padding: 22px; min-width: 0; max-width: 100%; overflow-wrap: break-word; word-break: break-word; box-sizing: border-box; }
.card + .card { margin-top: 22px; }
.card h2, .card h3 { margin: 0; letter-spacing: -.01em; }
.eyebrow { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
pre.code, .code { font-family: var(--mono); font-size: 12px; background: var(--code-bg); border-radius: 12px; box-shadow: var(--sh-in); padding: 14px 16px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 440px; }
.empty { text-align: center; padding: 38px 18px; color: var(--muted); }
.err { color: var(--bad); font-size: 12.5px; margin-top: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 100; max-width: 90vw; font-size: 13px; }
.toast.bad { background: var(--bad); }

/* ---------- header ---------- */
header.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); transition: box-shadow .2s ease; }
.top-in { max-width: 1280px; margin: 0 auto; padding: 14px 22px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; transition: padding .2s ease, gap .2s ease; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--sh-sm); color: var(--accent); transition: width .2s ease, height .2s ease, border-radius .2s ease; }
.brand b { font-size: 20px; letter-spacing: -.02em; transition: font-size .2s ease; }
.brand .ver { font-family: var(--mono); font-size: 10px; margin-left: 8px; padding: 2px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.brand small { display: block; color: var(--muted); font-size: 11.5px; margin-top: -2px; }
.mobile-tools-toggle { display: none; }
nav.tabs { display: flex; gap: 4px; padding: 5px; border-radius: 16px; background: var(--surface); box-shadow: var(--sh-in); margin: 0 auto; }
nav.tabs button { border: 0; background: transparent; padding: 8px 15px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); display: flex; gap: 7px; align-items: center; white-space: nowrap; flex-shrink: 0; }
nav.tabs button:hover { color: var(--ink); }
nav.tabs button.on { background: var(--raised); color: var(--accent); box-shadow: var(--sh-sm); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.user-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 12px; background: var(--surface); box-shadow: var(--sh-in); font-size: 11.5px; font-family: var(--mono); }
.user-email { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.role-tag { padding: 2px 7px; border-radius: 8px; font-weight: 700; text-transform: uppercase; font-size: 9.5px; }
.role-tag.operator { background: var(--good-soft); color: var(--good); }
.role-tag.run-only { background: var(--accent-soft); color: var(--accent); }
.role-tag.read-only { background: var(--code-bg); color: var(--muted); }

/* M4 : OPENROUTER routing toggle in title bar */
.routing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--sh-in);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
}
.routing-toggle.mode-m4 { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.routing-toggle.mode-or { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.routing-toggle .rt-opt {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.routing-toggle .rt-opt:hover:not(:disabled) { color: var(--ink); }
.routing-toggle .rt-opt.on[data-routing="m4"] {
  background: var(--good-soft);
  color: var(--good);
  box-shadow: var(--sh-sm);
}
.routing-toggle .rt-opt.on[data-routing="openrouter"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: var(--sh-sm);
}
.routing-toggle .rt-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  opacity: .5;
}
.routing-toggle .rt-opt.on[data-routing="m4"] .rt-dot {
  background: var(--good);
  opacity: 1;
  box-shadow: 0 0 6px var(--good);
}
.routing-toggle .rt-opt.on[data-routing="openrouter"] .rt-dot {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 6px var(--accent);
}
.routing-toggle .rt-sep {
  color: var(--faint);
  font-weight: 700;
  padding: 0 1px;
  cursor: pointer;
  user-select: none;
}
.routing-toggle.readonly .rt-opt, .routing-toggle.readonly .rt-sep { cursor: default; }

/* Header shrunk state when harness is active */
header.top.shrunk .top-in { padding: 7px 18px; gap: 12px; }
header.top.shrunk .logo { width: 32px; height: 32px; border-radius: 10px; }
header.top.shrunk .brand b { font-size: 16.5px; }
header.top.shrunk .brand small, header.top.shrunk .brand .ver { display: none; }
header.top.shrunk nav.tabs { padding: 3px; border-radius: 13px; }
header.top.shrunk nav.tabs button { padding: 6px 12px; font-size: 12px; border-radius: 10px; }
header.top.shrunk .tools .btn { padding: 6px 11px; font-size: 12px; border-radius: 10px; }
header.top.shrunk .routing-toggle { padding: 2px; border-radius: 11px; }
header.top.shrunk .routing-toggle .rt-opt { padding: 4px 8px; font-size: 10.5px; border-radius: 8px; }

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 20px 22px 80px; min-width: 0; box-sizing: border-box; }

/* ---------- prominent centered active session ---------- */
.active-session-card {
  position: relative;
  text-align: center;
  padding: 26px 28px;
  border-radius: 24px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  background: linear-gradient(180deg, var(--raised) 0%, var(--surface) 100%);
  box-shadow: var(--sh), 0 12px 32px color-mix(in srgb, var(--accent) 12%, transparent);
}
.active-session-card.is-live {
  border-color: var(--run);
  box-shadow: var(--sh), 0 0 0 2px color-mix(in srgb, var(--run) 35%, transparent), 0 14px 36px color-mix(in srgb, var(--run) 18%, transparent);
}
.session-hero { display: flex; flex-direction: column; align-items: center; max-width: 820px; margin: 0 auto; }
.session-badges { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.session-eyebrow { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 700; }
.session-headline { margin: 10px 0 12px; font-size: 22px; font-weight: 800; line-height: 1.3; letter-spacing: -.02em; color: var(--ink); max-width: 760px; min-width: 0; word-break: break-word; overflow-wrap: break-word; }
.session-progress { width: 100%; max-width: 580px; margin: 2px auto 6px; }
.session-prog-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.session-prog-track { width: 100%; height: 8px; border-radius: 99px; background: var(--code-bg); box-shadow: var(--sh-in); overflow: hidden; }
.session-prog-bar { height: 100%; border-radius: 99px; background: var(--accent); transition: width .35s ease; }
.session-prog-bar.good { background: var(--good); }
.session-prog-bar.run { background: linear-gradient(90deg, var(--run), var(--accent)); animation: pulse 1.4s infinite; }
.session-prog-bar.bad { background: var(--bad); }
.session-prog-bar.warn { background: var(--warn); }

.active-session-card .run-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  max-width: 820px;
  margin: 16px auto 0;
}
.active-session-card .stat { align-items: center; text-align: center; min-width: 0; padding: 10px 12px; }
.active-session-card .stat b { font-size: 16px; }

.session-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 680px;
  margin: 18px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.session-controls .run-select { width: 100%; max-width: 520px; text-align: center; font-weight: 600; }
.session-controls .runbar-actions { display: flex; justify-content: center; gap: 10px; width: 100%; margin-left: 0; }

/* Floating centered sticky HUD bar when scrolling stages */
.session-sticky-bar {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translate(-50%, -18px);
  opacity: 0;
  pointer-events: none;
  z-index: 28;
  width: min(740px, calc(100vw - 20px));
  padding: 8px 14px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--raised) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity .2s ease, transform .2s ease;
}
.session-sticky-bar.is-live { border-color: var(--run); }
.session-sticky-bar.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.session-sticky-bar .sticky-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.session-sticky-bar .sticky-hl { font-weight: 700; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }

/* ---------- flow ---------- */
.harness-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.harness-head.compact { padding: 13px 18px; border-radius: 16px; box-shadow: var(--sh-sm); }
.harness-head.compact h1 { font-size: 15px; }
.harness-head.compact p { font-size: 11.5px; }
.harness-head .harness-info { min-width: 220px; }
.harness-head h1 { margin: 0; font-size: 18px; letter-spacing: -.015em; }
.harness-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.runbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.runbar h2 { font-size: 20px; display: flex; gap: 10px; align-items: center; margin: 0; }
.stat { display: flex; flex-direction: column; padding: 8px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--sh-in); min-width: 92px; }
.stat b { font-size: 15px; font-family: var(--mono); } .stat span { font-size: 10px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.stages { margin-top: 18px; display: flex; flex-direction: column; gap: 18px; position: relative; }
.stage { background: var(--surface); border-radius: 20px; box-shadow: var(--sh); transition: box-shadow .2s; position: relative; }
.stage::before { content: ""; position: absolute; left: 31px; top: 100%; width: 2px; height: 18px; background: linear-gradient(var(--faint), transparent); opacity: .5; }
.stage:last-child::before { display: none; }
.stage.run { box-shadow: var(--sh), 0 0 0 2px var(--run); }
.stage.bad { box-shadow: var(--sh), 0 0 0 2px var(--bad); }
.stage-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer; flex-wrap: wrap; }
.stage-head .stage-info { min-width: 180px; }
.stage-ic { width: 42px; height: 42px; border-radius: 14px; background: var(--surface); box-shadow: var(--sh-sm); display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 12px; color: var(--accent); flex: none; }
.stage.run .stage-ic { color: var(--run); } .stage.good .stage-ic { color: var(--good); } .stage.bad .stage-ic { color: var(--bad); }
.stage-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.stage-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 1px; }
.stage-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stage-body { display: none; padding: 4px 20px 20px; }
.stage.open .stage-body { display: block; }
.nodes { display: flex; flex-direction: column; gap: 8px; }
.node { border-radius: 14px; background: var(--raised); box-shadow: var(--sh-sm); }
.node-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; flex-wrap: wrap; }
.node-head .nm { font-weight: 600; font-size: 13px; word-break: break-word; }
.node-head .ty { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.node-body { display: none; padding: 4px 14px 14px; }
.node.open .node-body { display: block; }
.node.edited .nm::after { content: " ● edited"; color: var(--warn); font-size: 10.5px; font-weight: 700; }
.node.skipped { opacity: .5; }
.toolrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.toollog { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 6px 0; }
.sizebar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 10px 0 6px; }
.banner { padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.good { background: var(--good-soft); color: var(--good); }

/* ---------- agent context injection ---------- */
.injection-panel {
  margin-top: 14px;
  padding: 18px 20px;
  border-radius: 18px;
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--sh-sm), 0 8px 24px color-mix(in srgb, var(--accent) 10%, transparent);
  animation: slideDown .18s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.injection-panel h4 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 7px;
}
.injection-dropzone {
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  background: var(--raised);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.injection-dropzone:hover, .injection-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.doc-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--raised);
  box-shadow: var(--sh-sm);
  font-size: 12px;
}
.doc-pill-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.doc-pill-meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.doc-pill-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.inj-banner {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-left: 3.5px solid var(--accent);
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}

/* ---------- tables ---------- */
.tablewrap { overflow: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; max-height: 70vh; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; position: sticky; top: 0; background: var(--surface); z-index: 1; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; word-break: break-word; overflow-wrap: break-word; }
tr.click { cursor: pointer; } tr.click:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
td.num { text-align: right; font-family: var(--mono); white-space: nowrap; word-break: normal; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { padding: 18px 20px; border-radius: 18px; background: var(--surface); box-shadow: var(--sh); }
.kpi span { display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kpi b { display: block; font-size: 28px; letter-spacing: -.02em; font-family: var(--mono); margin: 4px 0 2px; } .kpi small { color: var(--faint); font-size: 11.5px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; align-items: center; }
.filters input[type=text] { width: 300px; max-width: 100%; } .filters select { width: auto; min-width: 150px; }

/* ---------- reader ---------- */
.reader-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; width: 100%; max-width: 100%; }
.reader-grid > *, .found-grid > * { min-width: 0; max-width: 100%; }
.reader-session-card { border: 1.5px solid color-mix(in srgb, var(--accent) 42%, var(--line)); background: linear-gradient(180deg, var(--raised) 0%, var(--surface) 100%); }
.file-dl-btn { width: 100%; min-width: 0; overflow: hidden; }
.file-dl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.scores { display: grid; gap: 8px; }
.scorebar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 34px; gap: 8px; align-items: center; font-size: 12px; }
.scorebar i { height: 8px; border-radius: 99px; background: var(--code-bg); box-shadow: var(--sh-in); display: block; overflow: hidden; } .scorebar i::after { content: ""; display: block; height: 100%; width: var(--w); background: var(--accent); border-radius: 99px; }
iframe.article { width: 100%; max-width: 100%; height: 78vh; border: 0; border-radius: 14px; background: #fff; box-shadow: var(--sh-in); display: block; }
img.hero, .hero-img, .article img { max-width: 100%; height: auto; border-radius: 12px; margin: 0 auto 20px; display: block; }
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; max-width: 100%; }
.subtabs button { border: 0; padding: 7px 14px; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; }
.subtabs button.on { background: var(--raised); color: var(--accent); box-shadow: var(--sh-sm); }

/* ---------- foundation ---------- */
.found-grid { display: grid; grid-template-columns: 290px 320px minmax(0, 1fr); gap: 20px; align-items: start; width: 100%; max-width: 100%; }
.found-grid.pack { grid-template-columns: 290px minmax(0, 1fr); }
.pack-info { margin-bottom: 14px; }
.list { display: flex; flex-direction: column; gap: 6px; max-height: 66vh; overflow: auto; padding: 4px; margin: -4px; }
.li { padding: 10px 12px; border-radius: 12px; cursor: pointer; font-size: 12.5px; background: transparent; border: 0; text-align: left; color: var(--ink-2); }
.li:hover { background: var(--raised); } .li.on { background: var(--raised); box-shadow: var(--sh-sm); color: var(--accent); font-weight: 600; }
.li small { display: block; color: var(--faint); font-family: var(--mono); font-size: 10.5px; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(5, 12, 28, .45); z-index: 50; backdrop-filter: blur(3px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); max-width: 100vw; background: var(--bg); z-index: 60; box-shadow: -20px 0 50px rgba(0,0,0,.28); display: flex; flex-direction: column; animation: slide .22s ease; overflow: hidden; box-sizing: border-box; }
.drawer.wide { width: min(980px, 100vw); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-h { padding: 20px 24px 14px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.drawer-h h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; word-break: break-word; }
.drawer-b { padding: 22px 24px 40px; overflow-y: auto; overflow-x: hidden; flex: 1; min-width: 0; max-width: 100%; -webkit-overflow-scrolling: touch; box-sizing: border-box; }
.drawer-f { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.swatch { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--surface); box-shadow: var(--sh-sm); font-size: 12px; }
.swatch input[type=color] { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 8px; }
.hr { height: 1px; background: var(--line); margin: 20px 0; border: 0; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); box-shadow: var(--sh-in); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--raised); color: var(--accent); box-shadow: var(--sh-sm); }

/* ---- Google Sheet row picker ---- */
.modal { position: fixed; z-index: 90; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(1080px, calc(100vw - 28px)); max-height: calc(100vh - 28px); display: flex; flex-direction: column; background: var(--bg); border-radius: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.4); overflow: hidden; animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.modal-h { display: flex; align-items: center; gap: 14px; padding: 20px 24px 14px; }
.modal-h .logo { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--accent); background: var(--surface); box-shadow: var(--sh-sm); flex: none; }
.modal-link { padding: 4px 24px 12px; }
.modal-link .row { gap: 10px; flex-wrap: nowrap; } .modal-link .btn { flex: none; white-space: nowrap; }
.picker-filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.picker-filters input[type=text] { flex: 1 1 260px; min-width: 200px; } .picker-filters select { width: auto; flex: 0 1 190px; }
.modal-b { overflow: auto; padding: 16px 24px; flex: 1; min-height: 200px; -webkit-overflow-scrolling: touch; }
.modal-f { display: flex; justify-content: flex-end; padding: 12px 24px 18px; }
.picker-list { display: grid; gap: 14px; }
.pick-card { display: flex; gap: 16px; align-items: flex-start; padding: 16px 18px; border-radius: 18px; background: var(--raised); box-shadow: var(--sh-sm); }
.pick-main { flex: 1; min-width: 0; } .pick-card .btn { flex: none; }
.pick-h { font-weight: 800; font-size: 16px; margin: 9px 0 6px; letter-spacing: -.01em; }
.modal-link .mono { word-break: break-all; }

/* ---------- responsive & mobile ---------- */
@media (max-width: 980px) {
  .reader-grid, .found-grid, .found-grid.pack { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .reader-side { display: contents; }
  .reader-session-card { order: 1; text-align: center; margin-top: 0 !important; }
  .reader-session-card .session-eyebrow { justify-content: center; }
  .reader-session-chips { justify-content: center; }
  .reader-hold-card { order: 2; margin-top: 0 !important; }
  .reader-body-card { order: 3; margin-top: 0 !important; }
  .reader-audit-card { order: 4; margin-top: 0 !important; }
  .reader-files-card { order: 5; margin-top: 0 !important; }
  nav.tabs { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav.tabs::-webkit-scrollbar { display: none; }
  .tools { margin-left: auto; }
  .list { max-height: 30vh; }
  .session-sticky-bar { top: 96px; }
}

@media (max-width: 640px) {
  /* Compact sticky header that shrinks when harness is active */
  .top-in { padding: 6px 10px; gap: 5px; }
  .brand { gap: 8px; }
  .logo { width: 30px; height: 30px; border-radius: 9px; }
  .brand b { font-size: 16px; }
  .brand .ver { font-size: 9px; padding: 2px 5px; margin-left: 5px; }
  .brand small { display: none; }
  .mobile-tools-toggle { display: inline-flex; margin-left: auto; padding: 5px 9px; border-radius: 10px; gap: 5px; }
  .tools { order: 2; gap: 6px; width: 100%; justify-content: flex-start; padding-top: 4px; padding-bottom: 2px; }
  .tools .btn { padding: 7px 10px; border-radius: 11px; }
  .tools .btn span.lbl { display: none; }
  .user-badge { margin-left: auto; padding: 4px 8px; font-size: 11px; }
  .user-badge .role-tag { display: none; }
  .user-email { max-width: 115px; }
  header.top:not(.tools-open) .tools { display: none; }
  header.top.shrunk .top-in { padding: 5px 8px; gap: 4px; }
  header.top.shrunk .logo { width: 26px; height: 26px; border-radius: 8px; }
  header.top.shrunk .brand b { font-size: 15px; }
  nav.tabs { padding: 3px; gap: 2px; border-radius: 12px; justify-content: space-between; }
  nav.tabs button { padding: 6px 5px; font-size: 10.5px; gap: 3px; border-radius: 9px; flex: 1 0 auto; justify-content: center; letter-spacing: -.01em; }
  nav.tabs button svg { width: 12px; height: 12px; flex-shrink: 0; }

  /* Layout & cards */
  main { padding: 12px 10px 70px; }
  .card { padding: 14px; border-radius: 16px; }
  .card + .card { margin-top: 14px; }
  .login-card { padding: 24px 20px; border-radius: 22px; }

  /* Prevent iOS Safari zoom on input focus */
  input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], select, textarea { font-size: 16px; }

  /* Prominent centered Active Session card on mobile */
  .active-session-card { padding: 18px 14px; border-radius: 20px; }
  .session-headline { font-size: 17.5px; margin: 8px 0 10px; line-height: 1.32; }
  .session-prog-meta { font-size: 11px; }
  .active-session-card .run-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
  .active-session-card .stat { padding: 8px 6px; border-radius: 12px; }
  .active-session-card .stat b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .active-session-card .stat span { font-size: 9.5px; }
  .session-controls { margin-top: 14px; padding-top: 12px; gap: 8px; }
  .session-controls .run-select { width: 100%; font-size: 13.5px; padding: 9px 11px; }
  .session-controls .runbar-actions { width: 100%; gap: 7px; }
  .session-controls .runbar-actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; padding: 9px 10px; }

  /* Floating centered sticky session bar */
  .session-sticky-bar { top: 76px; padding: 7px 11px; gap: 6px; }
  .session-sticky-bar .sticky-meta { display: none; }
  .session-sticky-bar .sticky-hl { max-width: 165px; font-size: 12px; }

  /* Compact Harness header below active session */
  .harness-head { gap: 8px; align-items: center; margin-top: 14px; }
  .harness-head .harness-info { flex: 1 1 100%; min-width: 0; order: 2; }
  .harness-head h1 { font-size: 15px; line-height: 1.3; }
  .harness-head.compact p { display: none; }
  .harness-head .btn { order: 3; flex: 1 1 calc(50% - 6px); justify-content: center; }

  /* Banners */
  .banner { padding: 12px 14px; gap: 8px; }
  .banner .btn.right { width: 100%; justify-content: center; margin-left: 0; margin-top: 4px; }

  /* Stages & nodes: full-width stage titles and clean chip row below */
  .stages { gap: 14px; margin-top: 14px; }
  .stage::before { left: 25px; height: 14px; }
  .stage-head { padding: 13px 14px; gap: 8px 10px; align-items: flex-start; }
  .stage-ic { width: 36px; height: 36px; border-radius: 11px; font-size: 11px; }
  .stage-head .stage-info { flex: 1 1 calc(100% - 50px); min-width: 0; }
  .stage-title { font-size: 14.5px; line-height: 1.3; }
  .stage-sub { font-size: 10.5px; word-break: break-word; margin-top: 2px; }
  .stage-meta { width: 100%; padding-left: 46px; gap: 6px; }
  .stage-meta > span:last-child { margin-left: auto; }
  .stage-body { padding: 4px 12px 14px; }
  .node-head { padding: 10px 12px; gap: 5px 8px; }
  .node-head .ty { width: 100%; padding-left: 16px; word-break: break-all; }
  .node-head .node-chips { width: 100%; padding-left: 16px; margin-left: 0; gap: 5px; }
  .node-body { padding: 4px 12px 12px; }
  .injection-panel { padding: 14px 12px; border-radius: 14px; margin-top: 10px; }
  .doc-pill { flex-wrap: wrap; gap: 6px; }
  .doc-pill-name { max-width: 100%; width: 100%; }
  .doc-pill-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }

  /* Reader, Library KPIs & Filters */
  .reader-select { width: 100% !important; margin-left: 0; }
  .subtabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 4px; margin-bottom: 12px; width: 100%; }
  .subtabs::-webkit-scrollbar { display: none; }
  .scorebar { grid-template-columns: 105px minmax(0, 1fr) 28px; font-size: 11.5px; }
  iframe.article { height: 70vh; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  .kpi { padding: 13px 14px; border-radius: 14px; min-width: 0; }
  .kpi b { font-size: 20px; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .filters input[type=text] { width: 100%; flex: 1 1 100%; }
  .filters select { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .found-search input[type=text] { flex: 1 1 100%; }
  .found-search .btn { width: 100%; justify-content: center; }

  /* Drawers & Sheet Picker Modal */
  .drawer, .drawer.wide { width: 100vw; max-width: 100vw; }
  .drawer-h { padding: 14px 16px 12px; }
  .drawer-b { padding: 16px 16px 32px; }
  .drawer-f { padding: 12px 16px; }
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 20px; }
  .modal-h, .modal-link, .picker-filters, .modal-b, .modal-f { padding-left: 14px; padding-right: 14px; }
  .modal-link .row { flex-wrap: wrap; }
  .modal-link .row input[type=url] { flex: 1 1 100%; }
  .modal-link .row .btn { flex: 1 1 calc(50% - 6px); justify-content: center; }
  .picker-filters input[type=text] { flex: 1 1 100%; min-width: 0; }
  .picker-filters select { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .pick-card { flex-direction: column; gap: 10px; padding: 14px; }
  .pick-card .btn { width: 100%; justify-content: center; }

  /* Brief Drawer Reference Images Panel Mobile */
  .ref-lightbox-modal { width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px); }
  .ref-lightbox-img { max-height: 300px; }
  .brief-ref-thumb { width: 68px; }
  .brief-ref-thumb-img { width: 66px; height: 66px; }
  .brief-ref-thumb-label { width: 66px; font-size: 10.5px; }
}

/* Brief Drawer Reference Images Panel */
.brief-ref-panel {
  padding: 14px 16px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 10px 0 16px;
  transition: opacity .18s ease;
}
.brief-ref-panel.dimmed {
  opacity: 0.45;
}
.brief-ref-panel.dimmed .brief-ref-dropzone {
  pointer-events: none;
}
.brief-ref-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  margin: 10px 0;
}
.brief-ref-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 74px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  text-align: center;
}
.brief-ref-thumb:hover .brief-ref-thumb-img {
  border-color: var(--accent);
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
}
.brief-ref-thumb-img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
  background: #051932;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.brief-ref-thumb-label {
  font-size: 11px;
  width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.25;
}
.brief-ref-dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s, background .15s;
  cursor: pointer;
  margin-top: 10px;
}
.brief-ref-dropzone.dragover {
  border-color: var(--accent);
  background: var(--raised);
}
.ref-lightbox-modal {
  width: min(640px, calc(100vw - 28px)) !important;
  max-height: calc(100vh - 40px);
}
.ref-lightbox-img-wrap {
  background: #051932;
  text-align: center;
  padding: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}
.ref-lightbox-img {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 4px;
  display: inline-block;
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Follow active agent */
.btn.on { box-shadow: var(--sh-sm), 0 0 0 2px var(--run); color: var(--run); }
.node.running > .node-head { box-shadow: 0 0 0 2px var(--run); border-radius: 12px; }

/* Anti-spillover helpers */
.brief-preview-card { min-width: 0; max-width: 100%; word-break: break-word; overflow-wrap: break-word; }
.brief-preview-headline { font-weight: 700; margin: 4px 0 6px; word-break: break-word; overflow-wrap: break-word; min-width: 0; }
.brief-preview-grid { font-size: 12px; display: grid; gap: 3px; min-width: 0; word-break: break-word; overflow-wrap: break-word; }
.brief-preview-item { min-width: 0; word-break: break-word; overflow-wrap: break-word; }
.matrix-headline { max-width: 650px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; min-width: 0; }

/* Background Tint Slider in Matrix Settings & Styling */
.tint-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--sh-in);
  margin-top: 10px;
}
.tint-slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.tint-range-input {
  flex: 1;
  height: 14px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 99px;
  background: linear-gradient(to right, 
    #ff6b6b 0%, 
    #feca57 16.6%, 
    #1dd1a1 33.3%, 
    #48dbfb 50%, 
    #54a0ff 66.6%, 
    #5f27cd 83.3%, 
    #ff6b6b 100%
  ) !important;
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15) !important;
  padding: 0 !important;
}
.tint-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.1s;
}
.tint-range-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.tint-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tint-chip {
  border: 0;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tint-chip:hover {
  transform: translateY(-1px);
  color: var(--ink);
}
.tint-chip:active {
  box-shadow: var(--sh-in);
  transform: none;
}
.tint-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 1px rgba(0,0,0,0.4);
}

/* User-requested chip & action enhancements */
.chip { font-size: 10px !important; padding: 2px 7px !important; letter-spacing: -0.01em; }
.chip.drip { color: #d97706 !important; background: #fef3c7 !important; border: 1px solid #fde68a !important; }
.chip.good { color: #047857 !important; background: #d1fae5 !important; }
:root[data-theme="dark"] .chip.drip { color: #f59e0b !important; background: #3b2505 !important; border-color: #78350f !important; }
:root[data-theme="dark"] .chip.good { color: #34d399 !important; background: #064e3b !important; }

.btn.btn-link-blue {
  background: #2563eb !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35) !important;
  padding: 5px 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 9px !important;
}
.btn.btn-link-blue:hover {
  background: #1d4ed8 !important;
  transform: translateY(-1px) !important;
}
.btn.btn-link-blue svg {
  stroke: #ffffff !important;
}

/* ---------- Superadmin Mode Toggle ---------- */
.btn.super-mode-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  padding: 4px 12px;
  transition: all .2s ease;
}
.btn.super-mode-btn.dev {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn.super-mode-btn.safe {
  background: color-mix(in srgb, var(--good) 15%, transparent);
  color: var(--good);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
}

/* ---------- 5-Phase Executive Stepper ---------- */
.card.executive-stepper {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 20px 22px;
}
.exec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.exec-header h2 {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.phase-card {
  background: var(--raised);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--sh-sm);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .2s ease, transform .15s ease;
}
.phase-card.run {
  border-color: color-mix(in srgb, var(--run) 50%, transparent);
  background: color-mix(in srgb, var(--run) 6%, var(--raised));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--run) 25%, transparent);
}
.phase-card.good {
  border-color: color-mix(in srgb, var(--good) 30%, transparent);
}
.phase-card.bad {
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 6%, var(--raised));
}
.phase-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.phase-num {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}
.phase-card.run .phase-num {
  background: var(--run);
  color: #fff;
}
.phase-card.good .phase-num {
  background: var(--good);
  color: #fff;
}
.phase-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.phase-desc {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
}
.phase-bar {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
  margin-top: 4px;
}
.phase-bar-in {
  height: 100%;
  border-radius: 99px;
  background: var(--muted);
  transition: width .3s ease;
}
.phase-card.run .phase-bar-in {
  background: var(--run);
  animation: pulseBar 1.5s infinite;
}
.phase-card.good .phase-bar-in {
  background: var(--good);
  width: 100% !important;
}
@keyframes pulseBar {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}
.phase-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- writefuse.cloud Editorial Landing & Onboarding ---------- */
.wf-landing { min-height: 100vh; background: #FEF9F4; color: #1E1A15; padding: 36px 24px 72px; }
.wf-shell { max-width: 1120px; margin: 0 auto; }
.wf-nav { display: flex; align-items: center; justify-content: space-between; padding-bottom: 24px; border-bottom: 1px solid #E8E4DF; margin-bottom: 40px; flex-wrap: wrap; gap: 12px; }
.wf-wordmark { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; color: #110C08; display: flex; align-items: center; gap: 8px; }
.wf-wordmark .dot-accent { color: #0193A5; }
.wf-nav-meta { font-family: var(--mono); font-size: 12px; color: #4C4741; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.wf-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: start; }
@media (max-width: 900px) { .wf-grid { grid-template-columns: 1fr; gap: 28px; } }
.wf-eyebrow { font-size: 13.5px; color: #4C4741; margin: 0 0 14px; }
.wf-h1 { font-size: clamp(34px, 5vw, 52px); font-weight: 400; line-height: 1.1; letter-spacing: -0.025em; margin: 0 0 22px; color: #1E1A15; }
.wf-lead { font-family: Georgia, Cambria, "Times New Roman", serif; font-size: 19px; line-height: 1.68; color: #1E1A15; max-width: 58ch; margin: 0 0 18px; }
.wf-sub { font-size: 16.5px; line-height: 1.65; color: #4C4741; max-width: 58ch; margin: 0 0 32px; }
.si-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #D4D0CB; border-radius: 10px; background: #FFFFFF; padding: 14px 18px; max-width: 540px; flex-wrap: wrap; }
.si-label { font-size: 14px; font-weight: 600; color: #1E1A15; }
.si-icons { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.si-link { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: #4C4741; font-size: 11.5px; font-weight: 500; cursor: pointer; background: none; border: 0; padding: 4px 6px; border-radius: 6px; }
.si-link:hover { color: #051932; background: #F5F1EC; }
.wf-rail { border-left: 1px solid #AAA39D; padding-left: 24px; color: #4C4741; font-size: 14px; line-height: 1.55; }
.wf-rail-bar { width: 44px; height: 2px; background: #0193A5; margin-bottom: 12px; }
.wf-rail h3 { margin: 0 0 8px; font-size: 15px; font-weight: 700; color: #1E1A15; }
.wf-rail-card { background: #F5F1EC; border: 1px solid #E8E4DF; border-radius: 10px; padding: 16px; margin-top: 16px; }
.wf-wiz { margin-top: 32px; background: #FFFFFF; border: 1px solid #D4D0CB; border-radius: 12px; padding: 26px; box-shadow: 0 6px 24px rgba(17,12,8,0.05); }
.wf-plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 10px 0 18px; }
@media (max-width: 640px) { .wf-plan-grid { grid-template-columns: 1fr; } }
.wf-plan-card { border: 2px solid #D4D0CB; border-radius: 10px; padding: 16px; cursor: pointer; text-align: left; background: #FEF9F4; transition: border-color .15s, background .15s; }
.wf-plan-card.active { border-color: #0193A5; background: #E7F6F8; }
.wf-plan-card h4 { margin: 0 0 4px; font-size: 15px; color: #051932; }
.wf-plan-card .price { font-size: 22px; font-weight: 700; color: #051932; }
.wf-plan-card small { color: #4C4741; display: block; margin-top: 4px; }
.wf-brief-blocks { display: grid; gap: 10px; margin-top: 12px; }
.wf-block-box { background: var(--raised); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 8px; font-size: 12.5px; }
