:root {
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1b222c;
  --panel-3: #232c38;
  --border: #28323f;
  --text: #e7edf3;
  --muted: #93a1b1;
  --faint: #6b7887;
  --accent: #4c8dff;
  --accent-2: #3b78e0;
  --danger: #ff6b6b;
  --ok: #4ec98a;
  --radius: 10px;
  --sidebar-w: 288px;
  --content-max: 900px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
a { color: var(--accent); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px calc(24px + var(--safe-b)); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 26px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; min-height: 46px; padding: 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--accent); }
button.primary {
  width: 100%; min-height: 46px; padding: 12px 14px; background: var(--accent); border: 0; border-radius: 10px;
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
button.primary:hover { background: var(--accent-2); }
button.primary:disabled { opacity: .6; cursor: default; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- app shell (mobile-first) ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* sidebar: off-canvas drawer by default (mobile) */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  width: 68vw; max-width: 270px;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
  transform: translateX(-105%); transition: transform .2s ease;
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
}
.sidebar.open { transform: translateX(0); }
.workflow-sidebar-mode .sidebar-actions,
.workflow-sidebar-mode .sidebar-search,
.workflow-sidebar-mode .session-list,
.workflow-sidebar-mode .list-note { display: none; }
.workflow-sidebar-panel { padding: 14px 12px 10px; overflow-y: auto; flex: 1; min-height: 0; }
.workflow-sidebar-panel[hidden] { display: none; }
.wf-side-title { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; margin-bottom: 10px; }
.wf-side-new { width: 100%; min-height: 40px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.wf-side-new:hover { background: var(--accent-2); }
.wf-side-search { width: 100%; min-height: 38px; margin: 10px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); font-size: 14px; }
.wf-side-search:focus { outline: none; border-color: var(--accent); }
.wf-filter-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.wf-filter-shortcut { min-height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.wf-filter-shortcut:hover, .wf-filter-shortcut.active { background: var(--panel-3); color: var(--text); border-color: var(--accent); }
.wf-filter-shortcut strong { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: rgba(255,255,255,.08); font-size: 11px; text-align: center; }
.wf-side-filters { display: grid; gap: 3px; }
.wf-side-filter { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; font-size: 13px; }
.wf-side-filter:hover, .wf-side-filter.active { background: var(--panel-3); color: var(--text); }
.wf-side-filter strong { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 11px; text-align: center; }
.wf-side-filter:nth-child(2) strong { color: #ffd479; }
.wf-side-filter:nth-child(3) strong { color: var(--danger); }

.sidebar-top { padding: 12px 12px 10px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; }
.navtab {
  flex: 1; min-height: 40px; border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px;
}
.navtab.active { background: var(--panel-3); color: var(--text); border-color: transparent; }
.sidebar-actions { padding: 10px 12px; display: flex; gap: 8px; }
.btn-new {
  flex: 1; min-height: 42px; border: 0; border-radius: 9px; background: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer;
}
.btn-new:hover { background: var(--accent-2); }
.sidebar-search { padding: 0 12px 8px; }
.search-row { display: flex; gap: 6px; align-items: stretch; }
.search-row input { flex: 1; min-width: 0; }
.search-row .iconbtn { flex: 0 0 auto; min-height: 42px; width: 42px; }
.sidebar-search input {
  width: 100%; min-height: 42px; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 16px;
}
.scope-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-top: 8px; padding: 2px; border-radius: 8px; background: var(--panel-2); }
.scope-tabs button { min-height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.scope-tabs button.active { background: var(--panel-3); color: var(--text); }
.classifier-note { padding: 0 12px 7px; color: var(--faint); font-size: 11px; }
.session-list { list-style: none; margin: 0; padding: 2px 8px 10px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.session-group { padding: 7px 9px 3px; color: var(--faint); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.session-list li {
  padding: 5px 8px; border-radius: 7px; cursor: pointer; margin-bottom: 1px; min-height: 42px;
}
.session-list li:hover { background: var(--panel-2); }
.session-list li.active { background: var(--panel-3); }
.session-list li.active .row1 { color: var(--text); }
.row1 { display: flex; align-items: center; gap: 7px; min-height: 32px; }
.row1 .title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; color: var(--text); }
.row1 .row-time { flex: 0 0 auto; color: var(--faint); font-size: 10px; }
.row1 .row-action { min-width: 30px; min-height: 30px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--faint); cursor: pointer; }
.row1 .row-action:hover { color: var(--text); background: var(--panel-3); }
.row1 .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: transparent; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
/* One colour language on both surfaces: the header light IS the open session's
   row light (yellow = running/background work, green = finished and unviewed,
   red = needs attention, no light = viewed). */
.row1 .dot.running, .status .dot.running { background: #f4c45e; box-shadow: 0 0 0 3px rgba(244,196,94,.16); animation: pulse 1.2s infinite; }
.row1 .dot.delegated-running, .status .dot.delegated-running { background: #f4c45e; box-shadow: 0 0 0 3px rgba(244,196,94,.16), 0 0 0 5px rgba(244,196,94,.08); animation: pulse 1.6s infinite; }
.row1 .dot.awaiting-handoff, .status .dot.awaiting-handoff { background: #f4c45e; box-shadow: 0 0 0 2px rgba(244,196,94,.14); }
.row1 .dot.attention-required, .status .dot.attention-required { background: var(--danger); box-shadow: 0 0 0 3px rgba(244,100,100,.16); }
.row1 .dot.finished-unchecked, .status .dot.finished-unchecked { background: var(--ok); box-shadow: 0 0 0 3px rgba(78,201,138,.18); }
.row1 .dot.checked, .status .dot.checked { background: transparent; }
.status .dot.bad { background: var(--danger); animation: none; }
.status .dot.bad, .status .dot.attention-required { box-shadow: 0 0 0 3px rgba(244,100,100,.16); }
.list-note { padding: 12px; color: var(--muted); font-size: 12px; text-align: center; }

.runtime-controls {
  flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto auto;
  align-items: end; gap: 4px; padding: 4px 6px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.runtime-controls label { min-width: 0; color: var(--muted); font-size: 6px; }
.runtime-controls label span { display: block; margin: 0 0 2px 2px; }
.runtime-controls select, .runtime-controls button {
  width: 100%; min-width: 0; height: 20px; padding: 0 5px; border: 1px solid var(--border);
  border-radius: 5px; background: var(--panel-2); color: var(--text); font-size: 7px;
}
.runtime-controls button { width: auto; cursor: pointer; }
.control-status { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.control-status:empty { display: none; }
.runtime-controls select:disabled, .runtime-controls button:disabled { opacity: .5; cursor: default; }
.context-pct { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; padding-bottom: 5px; }
.context-pct.warn { color: #f4c45e; }
.context-pct.danger { color: var(--danger); }
.task-tree-status { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 3px 2px 0; }
.task-tree-status[hidden] { display: none; }
.task-tree-status > div { min-width: 0; }
.task-tree-status strong, .task-tree-status small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-tree-status strong { color: var(--text); font-size: 11px; font-weight: 600; }
.task-tree-status small { margin-top: 1px; color: var(--muted); font-size: 10px; }

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

/* header */
.header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-top: calc(10px + var(--safe-t));
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.header .hamburger {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); font-size: 20px;
  border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex: 0 0 44px;
}
.header .htitle { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Thumb-reachable drawer toggle: pinned to the left edge, vertically centred.
   The header hamburger stays; this is an extra shortcut where the sidebar is
   off-canvas (mobile). */
.edge-toggle {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 40;
  width: 26px; height: 64px; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--muted); font-size: 14px;
  border: 1px solid var(--border); border-right: 0; border-radius: 10px 0 0 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.edge-toggle[hidden] { display: none; }
.edge-toggle:active { color: var(--text); background: var(--panel-3); }
.header .grow { flex: 1; min-width: 0; }
.status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.reconnecting .txt { color: #f4c45e; }
.live-run-strip { flex: 0 0 auto; min-height: 32px; display: flex; align-items: center; gap: 12px; padding: 5px 14px; border-bottom: 1px solid var(--border); background: var(--panel); }
.live-run-strip[hidden] { display: none; }
.run-counters { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.live-sync-status { flex: 0 0 auto; color: #f4c45e; font-size: 11px; }
@keyframes pulse { 50% { opacity: .35; } }
.iconbtn {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 16px;
  border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:hover { background: var(--panel-2); color: var(--text); }
.iconbtn.active { color: #f4c45e; background: var(--panel-2); }
#hideBtn.active { color: var(--danger); }

.history-tools {
  min-height: 38px; padding: 5px 12px; border-bottom: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px;
}
.history-tools .grow { flex: 1; }
.history-tools button, .history-tools select {
  min-height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); color: var(--text); padding: 3px 9px; cursor: pointer;
}
.history-tools button:disabled { opacity: .55; cursor: default; }

/* messages */
.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 2px; padding: 14px 12px 20px;
  scroll-behavior: auto;
}
.msgs-inner { width: 100%; max-width: var(--content-max); margin: 0 auto; display: flex; flex-direction: column; gap: 2px; }
.spacer { width: 100%; flex: 0 0 auto; }
.loadearlier { display: flex; justify-content: center; padding: 8px 0 14px; }
.loadearlier button {
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 16px; font-size: 12px; cursor: pointer; min-height: 36px;
}
.skeleton { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.skeleton .sk { height: 44px; border-radius: 10px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
.skeleton .sk.w60 { width: 60%; } .skeleton .sk.w40 { width: 40%; }
.skeleton .load-status { color: var(--muted); font-size: 13px; padding: 3px 0; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.msg { padding: 10px 2px; }
.msgs-inner > .msg + .msg { margin-top: 4px; }
.msg .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg .who { font-size: 12px; font-weight: 600; color: var(--muted); }
.msg .acts { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 20px; }
.msg .elapsed { font-size: 11px; color: var(--muted); }
.code-footer { justify-content: flex-end; border-top: 1px solid var(--border); border-bottom: 0; }
.msg .acts button {
  min-height: 30px; padding: 3px 10px; font-size: 12px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
}
.msg .acts button:hover { color: var(--text); }
.msg .acts button.resend { color: #ffd0d0; border-color: rgba(255,107,107,.45); }
.msg.user { border-left: 3px solid var(--accent); padding-left: 12px; background: rgba(76,141,255,.06); border-radius: 0 8px 8px 0; }
.msg.user .who { color: #a9c6ff; }
.msg.assistant .who { color: #9fb0c3; }
.msg.error .body { color: var(--danger); }

.body {
  word-wrap: break-word; overflow-wrap: anywhere; max-width: 1120px;
  font-size: 15.5px; line-height: 1.72; color: var(--text);
}
.collapsed-user { white-space: pre-wrap; overflow-wrap: anywhere; }
.collapsed-user .collapsed-ellipsis { color: var(--muted); margin-right: 2px; }
.msg-toggle {
  display: inline-flex; align-items: center; margin-top: 8px; min-height: 30px;
  padding: 3px 10px; font-size: 12px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
}
.msg-toggle:hover { color: var(--text); }
.message-attachment-summary { margin-top: 7px; color: var(--muted); font-size: 12px; }
.message-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.message-image {
  display: block; width: 84px; height: 84px; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: var(--panel-2);
}
.message-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.message-image:hover { border-color: var(--accent); }
.message-image.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-3); color: var(--muted); font-size: 22px;
}
.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 14px; text-wrap: pretty; }
.body h1, .body h2, .body h3, .body h4, .body h5, .body h6 {
  margin: 22px 0 10px; line-height: 1.35; letter-spacing: -0.01em;
}
.body h1 { font-size: 23px; }
.body h2 { font-size: 19.5px; padding-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,.08); }
.body h3 { font-size: 17.5px; }
.body h4, .body h5, .body h6 { font-size: 16px; color: var(--muted); }
.body ul, .body ol { margin: 0 0 14px; padding-left: 26px; }
.body li { margin: 5px 0; text-wrap: pretty; }
.body li > ul, .body li > ol { margin: 6px 0 0; }
.body blockquote {
  margin: 0 0 14px; padding: 10px 16px; border-left: 3px solid var(--border);
  border-radius: 0 8px 8px 0; background: rgba(255,255,255,.03); color: var(--muted);
}
.body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em; background: rgba(255,255,255,.07); color: #e9d9b8;
  padding: 1px 5px; border-radius: 4px; border: 1px solid rgba(255,255,255,.06);
}
.body hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.body a { color: #7fb0ff; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.tablewrap { overflow-x: auto; margin: 0 0 14px; }
.body table { border-collapse: collapse; font-size: 13.5px; line-height: 1.5; min-width: 100%; }
.body th, .body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.body th { background: var(--panel-3); }
.codeblock { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #0b0e13; }
.codebar { display: flex; align-items: center; justify-content: space-between; padding: 5px 10px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.codebar .lang { font-size: 11px; color: var(--faint); }
.codebar .copy { min-height: 30px; padding: 3px 10px; font-size: 12px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.codeblock pre code { background: none; border: 0; padding: 0; color: var(--text); font-size: 13px; line-height: 1.62; }
.streaming .body::after { content: "▋"; color: var(--accent); animation: blink 1s steps(2) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

.jump {
  position: sticky; bottom: 8px; align-self: center; margin-top: -40px;
  background: var(--panel-3); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 12px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.4); display: none;
}
.jump.show { display: block; }

/* composer */
.composer {
  flex: 0 0 auto; border-top: 1px solid var(--border); background: var(--panel);
  padding: 10px 12px calc(10px + var(--safe-b));
}
.composer-inner { max-width: var(--content-max); margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer .attach {
  width: 46px; height: 46px; flex: 0 0 46px; padding: 0; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 26px;
  line-height: 1; cursor: pointer;
}
.attachment-tray {
  max-width: var(--content-max); margin: 0 auto 8px; display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 6px 2px; -webkit-overflow-scrolling: touch;
}
.attachment-tray[hidden] { display: none; }
.attachment-preview { position: relative; flex: 0 0 72px; width: 72px; height: 72px; }
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; overflow: hidden; font-size: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; display: block; }
.attachment-preview .attachment-status {
  position: absolute; left: 4px; right: 4px; bottom: 4px; padding: 2px 3px;
  border-radius: 4px; background: rgba(0,0,0,.72); color: #fff; font-size: 9px; text-align: center;
}
.attachment-preview button {
  position: absolute; top: -6px; right: -6px; width: 25px; height: 25px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: var(--panel-3); color: var(--text);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; height: 46px; min-height: 46px; max-height: 46px; padding: 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text); font: inherit; font-size: 16px; line-height: 1.45;
  overflow-y: auto;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer .send, .composer .stop {
  min-height: 46px; padding: 0 18px; border: 0; border-radius: 10px; color: #fff; font-weight: 600; cursor: pointer; flex: 0 0 auto;
}
.composer .send { background: var(--accent); }
.composer .send:hover { background: var(--accent-2); }
.composer .stop { background: var(--danger); }
.composer button:disabled { opacity: .5; cursor: default; }
.composer-meta { max-width: var(--content-max); margin: 6px auto 0; display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); min-height: 14px; }
.composer-meta .warn { color: var(--danger); }

/* workflow */
.placeholder { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.placeholder h2 { color: var(--text); margin: 0 0 6px; }

.workflow { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px calc(20px + var(--safe-b)); }
.wf-screen { max-width: var(--content-max); margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.wf-head { display: flex; align-items: center; gap: 10px; }
.wf-title { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-head-actions { display: flex; gap: 6px; }
.wf-btn {
  min-height: 38px; padding: 0 12px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.wf-btn:hover { background: var(--panel-3); }
.wf-btn:disabled { opacity: .5; cursor: default; }
.wf-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.wf-btn-primary:hover { background: var(--accent-2); }
.wf-btn-danger { color: var(--danger); }
.wf-btn-mini { min-height: 30px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.wf-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; line-height: 1.6; }

.wf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wf-row { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wf-row-main { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 10px 12px; cursor: pointer; }
.wf-row-main:hover { background: var(--panel-2); }
.wf-row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wf-row-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-row-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 11px; color: var(--faint); }
.wf-row-badge { margin-top: 6px; display: inline-block; font-size: 11px; color: #ffcf6b; border: 1px solid #6b5324; background: #33280f; border-radius: 999px; padding: 1px 9px; }
.wf-row-progress { margin-top: 8px; color: var(--muted); font-size: 12px; }

.wf-chip { font-size: 10px; letter-spacing: .3px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.wf-chip-running { color: #ffd479; border-color: #6b5324; background: #33280f; }
.wf-chip-waiting_approval { color: #9fc6ff; border-color: #2b4a79; background: #16243a; }
.wf-chip-completed { color: var(--ok); border-color: #2c5b45; background: #13301f; }
.wf-chip-failed { color: var(--danger); border-color: #6b2c2c; background: #331515; }
.wf-chip-cancelled { color: var(--faint); }

.wf-form { display: flex; flex-direction: column; gap: 10px; }
.wf-mode-question { margin: 2px 0 0; font-size: 16px; font-weight: 600; }
.wf-create-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wf-create-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; min-height: 120px; padding: 14px; color: var(--text); text-align: left; white-space: normal; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.wf-create-mode:hover { border-color: var(--accent); background: var(--panel-2); }
.wf-create-mode-recommended { border-color: var(--accent); }
.wf-mode-recommendation { color: var(--accent); font-size: 11px; font-weight: 600; }
.wf-mode-title { font-size: 15px; overflow-wrap: anywhere; }
.wf-mode-description { color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.wf-owner-defined-preview { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.wf-owner-milestone-preview { display: flex; flex-direction: column; gap: 8px; margin: 0; padding-left: 24px; }
.wf-owner-milestone-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.wf-owner-milestone-item > strong { display: block; margin-bottom: 4px; overflow-wrap: anywhere; }
.wf-planning-provenance { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.wf-import { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 12px; border-bottom: 1px solid var(--border); }
.wf-import-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wf-import-input { min-height: 180px; }
.wf-import .wf-btn { align-self: flex-start; }
.wf-field { display: flex; flex-direction: column; gap: 5px; }
.wf-field-label { font-size: 11px; color: var(--muted); }
.wf-input {
  width: 100%; min-height: 40px; padding: 9px 10px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; font: inherit; font-size: 14px;
}
textarea.wf-input { resize: vertical; min-height: 62px; line-height: 1.5; }
.wf-input:focus { outline: none; border-color: var(--accent); }
.wf-section-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.wf-steps { display: flex; flex-direction: column; gap: 8px; }
.wf-step-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.wf-step-top { display: flex; align-items: center; }
.wf-step-index { flex: 1; font-size: 12px; color: var(--muted); }
.wf-step-tools { display: flex; gap: 6px; }
.wf-note { font-size: 12px; color: var(--faint); }
.wf-guide-dialog { width: min(720px, calc(100vw - 28px)); max-height: min(760px, calc(100dvh - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); }
.wf-guide-dialog::backdrop { background: rgba(0,0,0,.7); }
.wf-guide-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.wf-guide-heading { display: flex; align-items: center; gap: 8px; }
.wf-guide-heading h3 { flex: 1; margin: 0; font-size: 16px; }
.wf-guide-content { max-height: min(560px, 62dvh); overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #090c10; color: var(--text); font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }

.wf-statusbar { display: flex; flex-direction: column; gap: 6px; }
.wf-detail-summary { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--muted); font-size: 12px; }
.wf-owner-timing { display: grid; gap: 5px; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.wf-timing-line { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; min-width: 0; font-size: 12px; }
.wf-timing-label { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.wf-timing-value { color: var(--text); font-variant-numeric: tabular-nums; white-space: normal; text-align: right; overflow-wrap: anywhere; }
.wf-row-elapsed { font-variant-numeric: tabular-nums; }
.wf-tl-duration { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.wf-attempt-timing { background: rgba(255,255,255,.015); }
.wf-planning-summary { display: grid; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.wf-endgame-prepare, .wf-spec-validation { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.wf-spec-ready { color: var(--ok); font-weight: 700; }
.wf-spec-blocked, .wf-spec-error { color: var(--danger); overflow-wrap: anywhere; }
.wf-advanced { border-top: 1px solid var(--border); padding-top: 10px; }
.wf-advanced > summary { color: var(--muted); cursor: pointer; }
.wf-planning-milestones { display: grid; gap: 6px; }
.wf-planning-milestone { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.wf-planning-milestone > summary { cursor: pointer; font-weight: 700; }
.wf-owner-decision-gate { display: grid; gap: 8px; padding: 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.wf-owner-summary { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border-strong, var(--border)); border-radius: var(--radius); background: var(--panel); }
.wf-owner-milestone { margin: 0; color: var(--text); font-size: 16px; }
.wf-owner-attempt-line { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.wf-owner-next-label, .wf-owner-label { color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.wf-owner-next { color: var(--text); font-weight: 700; }
.wf-canonical-settlement-summary { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: #83d18b; }
.wf-owner-text, .wf-owner-muted, .wf-owner-ref { color: var(--muted); font-size: 12px; line-height: 1.5; word-break: break-word; }
.wf-owner-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.wf-owner-interruption { border-left: 3px solid #d69e2e; padding-left: 9px; color: #f0c36b; font-size: 12px; }
.wf-owner-longtext { margin-top: 4px; }
.wf-owner-longtext summary, .wf-advanced-events summary { color: var(--muted); cursor: pointer; font-size: 12px; }
.wf-owner-longtext[open] .wf-owner-text { margin-top: 6px; white-space: pre-wrap; }
.wf-owner-list { margin: 5px 0 0 16px; padding: 0; color: var(--muted); font-size: 12px; }
.wf-attempt-card { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,.02); }
.wf-ai-config { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.wf-ai-config > summary { cursor: pointer; font-weight: 700; }
.wf-ai-role { display: grid; grid-template-columns: minmax(90px, .5fr) 1fr 1fr; gap: 10px; align-items: end; margin-top: 12px; }
.wf-ai-role .wf-field { margin: 0; }
.wf-route-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-top: 6px; }
.wf-route-line small { flex-basis: 100%; }
.wf-closure-summary { margin: 12px 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.02); }
.wf-closure-line { margin-top: 6px; color: var(--muted); font-size: 13px; }
.wf-qa-item { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.wf-qa-finding { margin-top: 6px; color: var(--muted); font-size: 12px; }
.wf-attempt-summary { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; list-style: none; }
.wf-attempt-summary::-webkit-details-marker { display: none; }
.wf-attempt-state { color: var(--muted); font-size: 12px; }
.wf-attempt-number { font-weight: 700; }
.wf-attempt-duration { color: var(--faint); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.wf-attempt-reason { flex: 1 1 120px; min-width: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-attempt-reason-passed { color: #83d18b; }
.wf-attempt-reason-failed { color: #f28b82; }
.wf-attempt-reason-interrupted { color: #f0c36b; }
.wf-attempt-reason-running { color: #ffd479; }
.wf-attempt-fixline { flex-basis: 100%; color: var(--faint); font-size: 11px; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-attempt-secondary { color: var(--faint); font-size: 11px; padding: 0 10px 6px; }
.wf-attempt-summary { flex-wrap: wrap; }
.wf-trace-section { display: grid; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.wf-evidence-addendum-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px 0; }
.wf-evidence-addendum-form textarea:nth-of-type(1), .wf-evidence-addendum-form textarea:nth-of-type(2) { grid-column: 1 / -1; }
.wf-evidence-addendum-form button { justify-self: start; }
.wf-evidence-addendum-row { padding: 7px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.wf-canonical-review { padding-left: 0; padding-right: 0; }
.wf-trace-section h4 { margin: 0; color: var(--faint); font-size: 10px; letter-spacing: .06em; }
.wf-review-verdict { font-weight: 700; font-size: 13px; }
.wf-review-pass { color: #83d18b; }
.wf-review-fail { color: #f28b82; }
.wf-review-interrupted { color: #f0c36b; }
.wf-trace-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wf-trace-actions h4 { flex-basis: 100%; }
.wf-advanced-events { margin-top: 18px; }
.wf-advanced-events > summary { padding: 10px 0; }
.wf-raw-prompt { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.wf-raw-prompt summary { padding: 10px 12px; color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; }
.wf-raw-prompt-content { max-height: 360px; overflow: auto; margin: 0; padding: 0 12px 12px; color: var(--muted); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.wf-goal { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.wf-goal { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.wf-goal-full { font-size: 13px; color: var(--muted); white-space: pre-wrap; margin-top: 8px; }
.wf-project-brief { margin-top: 8px; }
.wf-project-brief summary { color: var(--muted); cursor: pointer; font-size: 12px; }

/* Owner Action Required card (needs_human) — summary first, action first. */
.wf-owner-action { margin-top: 10px; border: 1px solid #d69e2e; border-left-width: 4px; border-radius: var(--radius); background: rgba(214, 158, 46, .06); padding: 12px; }
.wf-owner-action-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wf-owner-action-badge { color: #f0c36b; font-size: 13px; font-weight: 700; letter-spacing: .03em; }
.wf-owner-action-milestone { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; font-size: 14px; }
.wf-owner-action-milestone-title { color: var(--text); font-weight: 600; }
.wf-owner-action-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.wf-owner-action-label { margin-top: 10px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.wf-owner-action-text { margin-top: 3px; color: var(--text); font-size: 13px; line-height: 1.55; word-break: break-word; }
.wf-owner-action .wf-btn { margin-top: 12px; width: 100%; }
.wf-owner-attempt-strip { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.wf-owner-attempt-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; font-size: 12px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.02); }
.wf-owner-attempt-row-reason { flex: 1 1 140px; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-owner-attempt-row-time { color: var(--faint); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.wf-owner-action .wf-owner-longtext { margin-top: 6px; }
.wf-owner-resolution-type { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; min-width: 0; }
.wf-owner-resolution-option { display: flex; width: 100%; min-width: 0; box-sizing: border-box; gap: 8px; align-items: flex-start; color: var(--text); font-size: 13px; line-height: 1.45; white-space: normal; }
.wf-owner-resolution-option input[type='radio'] { accent-color: #f0c36b; flex: 0 0 16px; width: 16px; height: 16px; margin: 1px 0 0; }
.wf-owner-resolution-option span { display: block; flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.wf-evi-manifest-status { margin-top: 8px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.wf-evi-manifest-preview { min-width: 0; margin-top: 8px; }
.wf-evi-manifest-source { min-width: 0; padding: 8px 0; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.45; }
.wf-evi-manifest-id { display: block; color: var(--text); overflow-wrap: anywhere; }
.wf-evi-manifest-path, .wf-evi-manifest-hash { margin-top: 3px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; word-break: break-word; }
.wf-evi-manifest-bytes { margin-top: 3px; color: var(--muted); }
.wf-evi-manifest-approval { display: flex; width: 100%; min-width: 0; box-sizing: border-box; gap: 8px; align-items: flex-start; margin-top: 10px; color: var(--text); font-size: 13px; line-height: 1.45; }
.wf-evi-manifest-approval input[type='checkbox'] { flex: 0 0 16px; width: 16px; height: 16px; margin: 1px 0 0; }
.wf-evi-manifest-approval span { min-width: 0; overflow-wrap: anywhere; }
.wf-owner-evidence-label { margin-top: 9px; color: var(--faint); font-size: 10px; font-weight: 700; }
.wf-owner-evidence-copy { margin-top: 3px; color: var(--text); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.wf-owner-evidence-system { margin-top: 8px; color: var(--text); font-size: 12px; }
.wf-owner-evidence-actions { margin: 3px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.45; }
.wf-owner-evidence-summary { display: flex; flex-wrap: wrap; gap: 4px 8px; min-width: 0; margin-top: 9px; color: var(--text); font-size: 12px; line-height: 1.45; }
.wf-owner-evidence-summary span { min-width: 0; overflow-wrap: anywhere; }
.wf-owner-evidence-fail { color: var(--danger) !important; }
.wf-owner-evidence-review-list { min-width: 0; margin-top: 8px; }
.wf-owner-evidence-row { min-width: 0; padding: 7px 0; border-top: 1px solid var(--border); }
.wf-owner-evidence-name { display: block; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.wf-owner-evidence-summary-zh { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.wf-owner-evidence-status { margin-top: 2px; color: var(--ok); font-size: 11px; }
.wf-owner-evidence-status.is-limited, .wf-owner-evidence-limitation { color: var(--muted); font-size: 11px; }
.wf-owner-evidence-limitation { margin-top: 2px; overflow-wrap: anywhere; }
.wf-owner-evidence-advanced, .wf-owner-evidence-limitations { margin-top: 5px; color: var(--muted); font-size: 11px; }
.wf-owner-evidence-advanced > summary, .wf-owner-evidence-limitations > summary { cursor: pointer; color: var(--faint); }
.wf-owner-evidence-path, .wf-owner-evidence-hash { margin-top: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; word-break: break-word; }
.wf-owner-evidence-bytes { margin-top: 3px; }
.wf-owner-evidence-raw-evaluator, .wf-owner-evidence-raw-source { min-width: 0; margin-top: 6px; }
.wf-owner-evidence-raw-evaluator > summary, .wf-owner-evidence-raw-source > summary { cursor: pointer; color: var(--faint); overflow-wrap: anywhere; }
.wf-owner-evidence-raw { max-height: min(42dvh, 440px); overflow: auto; margin: 6px 0 0; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); color: var(--muted); font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.wf-owner-evidence-raw-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.wf-owner-evidence-limitations ul { margin: 4px 0 0; padding-left: 18px; overflow-wrap: anywhere; }
.wf-owner-evidence-approve { margin-top: 8px !important; }
.wf-owner-resolved { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-top: 8px; color: var(--ok); font-size: 13px; }
.wf-owner-action-details { margin-top: 10px; }
.wf-owner-action-details > summary { color: var(--muted); cursor: pointer; font-size: 12px; }
.wf-owner-action .wf-btn { margin-top: 10px; width: 100%; }
.wf-qualified-decision { border-radius: 8px; border-color: #c58b32; }
.wf-owner-decision-question { margin: 4px 0 8px; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.wf-owner-options { display: grid; gap: 8px; margin-top: 10px; }
.wf-owner-option { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; min-width: 0; }
.wf-owner-option input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.wf-owner-option-body { min-width: 0; overflow-wrap: anywhere; }
.wf-owner-option-heading { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; line-height: 1.4; }
.wf-owner-option-impact { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.wf-owner-option-deltas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.wf-owner-recommended { color: var(--ok); font-size: 11px; font-weight: 700; }
.wf-owner-decision-recommendation, .wf-owner-default { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.wf-intervention-status, .wf-interruption-metrics { margin-top: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow-wrap: anywhere; }
.wf-intervention-status { border-left: 4px solid var(--accent); }
.wf-interruption-count { display: block; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.wf-human-task { border-radius: 8px; border-left: 4px solid var(--accent); }
.wf-human-task-owner { border-left-color: #c58b32; }
.wf-human-task-choice { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.wf-team-task-queue { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.wf-team-task-queue > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.wf-team-task-item { padding: 9px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .wf-evidence-addendum-form { grid-template-columns: minmax(0, 1fr); }
  .wf-evidence-addendum-form textarea:nth-of-type(1), .wf-evidence-addendum-form textarea:nth-of-type(2) { grid-column: auto; }
  .wf-owner-option { padding: 9px; gap: 8px; }
  .wf-owner-option-deltas { grid-template-columns: minmax(0, 1fr); }
  .wf-interruption-metrics, .wf-intervention-status { padding: 10px; }
}
.wf-run-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wf-run-id { font-size: 11px; color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.wf-timeline { display: flex; flex-direction: column; gap: 8px; }
.wf-tl-row { background: var(--panel); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 10px 12px; }
.wf-tl-running { border-left-color: #ffd479; }
.wf-tl-waiting_approval { border-left-color: #4c8dff; }
.wf-tl-completed { border-left-color: var(--ok); }
.wf-tl-failed { border-left-color: var(--danger); }
.wf-tl-cancelled { border-left-color: var(--faint); }
.wf-tl-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wf-tl-index { width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; background: var(--panel-3); color: var(--muted); font-size: 11px; display: grid; place-items: center; }
.wf-tl-title { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-tl-mode { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .3px; }
.wf-tl-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 5px; font-size: 11px; color: var(--faint); }
.wf-tl-error { color: var(--danger); word-break: break-word; }
.wf-tl-actions { display: flex; gap: 8px; margin-top: 8px; }
.wf-step-details > summary { list-style: none; }
.wf-step-details > summary::-webkit-details-marker { display: none; }
.wf-step-details[open] > summary { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.wf-step-copy { display: grid; gap: 5px; padding-top: 10px; }
.wf-copy-label { color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.wf-copy-text { color: var(--muted); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

.wf-events { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.wf-event-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); max-height: 260px; overflow-y: auto; }
.wf-event { display: flex; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 12px; align-items: baseline; }
.wf-event:last-child { border-bottom: 0; }
.wf-event-time { color: var(--faint); white-space: nowrap; font-size: 11px; }
.wf-event-type { color: var(--accent); white-space: nowrap; font-size: 11px; }
.wf-event-msg { color: var(--muted); min-width: 0; word-break: break-word; }

/* ---------- rescue ---------- */
.gateway-degraded {
  flex: 0 0 auto; min-height: 42px; padding: 6px 12px; border-bottom: 1px solid #6b5324;
  background: #33280f; color: #ffd479; display: flex; align-items: center; justify-content: center; gap: 12px;
}
.gateway-degraded button { min-height: 32px; border: 1px solid #8b6a28; border-radius: 7px; background: transparent; color: #ffd479; padding: 0 10px; cursor: pointer; }
.rescue-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 12px calc(24px + var(--safe-b)); }
.rescue-inner { width: 100%; max-width: 780px; margin: 0 auto; }
.rescue-heading { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.rescue-heading > div { flex: 1; min-width: 0; }
.rescue-heading h1 { margin: 0; font-size: 18px; }
.rescue-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.rescue-status { margin: 0; }
.rescue-status > div { display: grid; grid-template-columns: minmax(130px, 1fr) auto; gap: 16px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.rescue-status dt { color: var(--muted); }
.rescue-status dd { margin: 0; font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.rescue-status dd.ready, .rescue-status dd.online { color: var(--ok); }
.rescue-status dd.down, .rescue-status dd.unavailable { color: var(--danger); }
.rescue-status dd.running { color: #ffd479; }
.rescue-actions { display: flex; flex-direction: column; gap: 9px; padding: 16px 0; }
.rescue-actions label { color: var(--muted); font-size: 12px; }
.rescue-actions textarea { width: 100%; min-height: 96px; resize: vertical; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 16px; line-height: 1.45; }
.rescue-actions textarea:focus { outline: none; border-color: var(--accent); }
.rescue-actions button, .rescue-dialog-actions button { min-height: 44px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); padding: 0 14px; cursor: pointer; font-weight: 600; }
.rescue-actions > #rescueCheck { align-self: flex-start; }
.rescue-action-row { display: flex; gap: 8px; }
.rescue-action-row button { flex: 1; }
.rescue-actions .rescue-auto { background: #5b341e; border-color: #8f5433; color: #ffe0cc; }
.rescue-actions .rescue-restart { background: #4a2525; border-color: #9a4f4f; color: #ffdede; }
.rescue-actions button:disabled { opacity: .5; cursor: default; }
.rescue-note { margin: 0; color: var(--faint); font-size: 11px; }
.rescue-run-state { padding: 9px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.rescue-console { min-height: 220px; max-height: 46vh; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #090c10; color: #d8e0e8; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal-view { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px; padding-bottom: calc(12px + var(--safe-b)); }
.terminal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.terminal-heading h1 { margin: 0; font-size: 18px; }
.terminal-heading p { display: flex; align-items: center; gap: 7px; margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.terminal-heading .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.terminal-heading .dot.connected { background: var(--ok); }
.terminal-actions { display: flex; gap: 7px; }
.terminal-actions button { min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.terminal-actions button:disabled { opacity: .5; cursor: default; }
.terminal-actions .danger { border-color: #733b3b; color: #ffdede; }
.terminal-paste-dialog { width: min(92vw, 500px); max-height: min(70dvh, 440px); margin: auto; }
.terminal-paste-dialog textarea { width: 100%; min-height: 120px; max-height: 35dvh; resize: vertical; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); color: var(--text); font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.terminal-paste-dialog textarea:focus { outline: none; border-color: var(--accent); }
.terminal-screen { flex: 1; min-height: 0; width: 100%; padding: 8px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: #0c1117; }
.terminal-screen .xterm { height: 100%; }
.terminal-screen .xterm-viewport { overscroll-behavior: contain; }
.rescue-stepup { width: min(92vw, 390px); max-height: 76dvh; margin: 12dvh auto auto; border: 1px solid var(--border); border-radius: 8px; padding: 0; background: var(--panel); color: var(--text); }
.rescue-stepup::backdrop { background: rgba(0,0,0,.72); }
.rescue-stepup form { padding: 20px; }
.rescue-stepup h2 { margin: 0 0 6px; font-size: 17px; }
.rescue-stepup p { margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.rescue-stepup label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.rescue-stepup input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); font-size: 16px; }
.rescue-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.rescue-dialog-actions .primary { background: var(--accent); border-color: transparent; }
.rescue-dialog-actions .danger { background: #7b3030; border-color: #a74a4a; color: #fff0f0; }
.step-up-content, .security-content { padding: 20px; }
.step-up-content h2, .security-content h2 { margin: 0 0 6px; font-size: 17px; }
.step-up-content > p, .security-content > p { margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.step-up-content > button { width: 100%; min-height: 44px; margin-top: 8px; border-radius: 8px; cursor: pointer; }
.step-up-content > button.primary, .security-content > button.primary { border: 0; background: var(--accent); color: #fff; font-weight: 600; }
.step-up-content > .step-up-fallback { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.step-up-content #stepUpPasswordForm { display: grid; gap: 8px; margin-top: 12px; padding: 0; }
.step-up-content #stepUpPasswordForm label, .security-content label { color: var(--muted); font-size: 12px; }
.step-up-content #stepUpPasswordForm input, .security-content > input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); font-size: 16px; }
.step-up-content #stepUpPasswordForm .primary { min-height: 42px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.passkey-list { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); }
.passkey-row > div { display: grid; min-width: 0; gap: 2px; }
.passkey-row strong { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.passkey-row small { color: var(--muted); font-size: 11px; }
.passkey-row button, .passkey-empty { color: var(--muted); font-size: 12px; }
.passkey-row button { flex: 0 0 auto; min-height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: transparent; cursor: pointer; }
.passkey-row button:disabled, .security-content > button:disabled { opacity: .55; cursor: default; }
.passkey-empty { padding: 10px; border: 1px dashed var(--border); border-radius: 7px; }
.security-content > label { display: block; margin-bottom: 5px; }
.security-content > input { margin-bottom: 10px; }
.security-content > button.primary { width: 100%; min-height: 42px; border-radius: 8px; cursor: pointer; }
.step-up-content, .security-content { padding: 20px; }
.step-up-content h2, .security-content h2 { margin: 0 0 6px; font-size: 17px; }
.step-up-content > p, .security-content > p { margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.step-up-content > button { width: 100%; min-height: 44px; margin-top: 8px; border-radius: 8px; cursor: pointer; }
.step-up-content > button.primary, .security-content > button.primary { border: 0; background: var(--accent); color: #fff; font-weight: 600; }
.step-up-content > .step-up-fallback { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.step-up-content #stepUpPasswordForm { display: grid; gap: 8px; margin-top: 12px; padding: 0; }
.step-up-content #stepUpPasswordForm label, .security-content label { color: var(--muted); font-size: 12px; }
.step-up-content #stepUpPasswordForm input, .security-content > input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); font-size: 16px; }
.step-up-content #stepUpPasswordForm .primary { min-height: 42px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.passkey-list { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel-2); }
.passkey-row > div { display: grid; min-width: 0; gap: 2px; }
.passkey-row strong { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.passkey-row small { color: var(--muted); font-size: 11px; }
.passkey-row button, .passkey-empty { color: var(--muted); font-size: 12px; }
.passkey-row button { flex: 0 0 auto; min-height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: transparent; cursor: pointer; }
.passkey-row button:disabled, .security-content > button:disabled { opacity: .55; cursor: default; }
.passkey-empty { padding: 10px; border: 1px dashed var(--border); border-radius: 7px; }
.security-content > label { display: block; margin-bottom: 5px; }
.security-content > input { margin-bottom: 10px; }
.security-content > button.primary { width: 100%; min-height: 42px; border-radius: 8px; cursor: pointer; }

@media (min-width: 769px) {
  .workflow { padding: 18px 24px 24px; }
}

/* account */
.account { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 10px 12px calc(10px + var(--safe-b)); display: grid; gap: 8px; }
.account-header { display: flex; align-items: center; gap: 8px; }
.account .notify-toggle { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; cursor: pointer; }
.account .notify-toggle input { accent-color: var(--accent); }
.account .who { flex: 1; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account button { min-height: 36px; padding: 0 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; }
.notification-summary { width: 100%; min-width: 0; display: flex; align-items: center; gap: 9px; text-align: left; }
.notification-summary:hover { border-color: var(--accent); }
.notification-icon { font-size: 15px; line-height: 1; }
.notification-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.notification-copy strong, .notification-copy small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-copy strong { font-size: 13px; font-weight: 600; color: var(--text); }
.notification-copy small, .notification-test-result { color: var(--muted); font-size: 11px; }
.notification-chevron { color: var(--faint); font-size: 21px; line-height: 1; }
.notification-settings { display: grid; gap: 8px; padding: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
.notification-settings-title { font-size: 12px; font-weight: 600; color: var(--text); }
.notification-setting-row { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.notification-setting-row strong { color: var(--ok); font-weight: 600; }
.notification-test { width: 100%; background: var(--accent); border-color: transparent; color: #fff; }
.notification-test:disabled { opacity: .55; cursor: default; }
.notification-clear { width: 100%; background: transparent !important; color: var(--muted) !important; }
.notification-recent { display: grid; gap: 5px; border-top: 1px solid var(--border); padding-top: 8px; }
.notification-recent ul { display: grid; gap: 6px; list-style: none; padding: 0; margin: 0; }
.notification-recent li { display: grid; gap: 1px; min-width: 0; }
.notification-recent li strong, .notification-recent li small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-recent li strong { color: var(--text); font-size: 11px; }
.notification-recent li small { color: var(--muted); font-size: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  background: var(--panel-3); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 9px;
  font-size: 13px; z-index: 50; opacity: 0; transition: opacity .2s ease; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 768px) {
  .terminal-heading { align-items: stretch; flex-direction: column; }
  .terminal-actions { width: 100%; }
  .terminal-actions button { flex: 1; min-width: 0; padding: 0 7px; }
  .sidebar-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .wf-create-modes { grid-template-columns: 1fr; }
  .wf-create-mode { min-height: 96px; }
  .wf-tl-head { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; grid-template-areas: "index title status" "index mode duration"; gap: 3px 8px; align-items: center; }
  .wf-tl-index { grid-area: index; align-self: start; }
  .wf-tl-title { grid-area: title; min-width: 0; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .wf-tl-mode { grid-area: mode; }
  .wf-tl-head .wf-chip { grid-area: status; justify-self: end; }
  .wf-tl-duration { grid-area: duration; justify-self: end; }
  .navtab { font-size: 11px; padding: 0 3px; gap: 3px; }
  .messages { padding-right: 32px; }
  .runtime-controls .control-status { display: none; }
  .header { gap: 4px; }
  .header .status .txt { display: none; }
  .header .iconbtn { width: 38px; height: 40px; }
  .history-tools { min-height: 36px; }
}

/* ---------- desktop ---------- */
@media (min-width: 769px) {
  .msgs-inner, .composer-inner, .attachment-tray, .composer-meta { max-width: 1440px; }
  .overlay { display: none; }
  .sidebar {
    position: static; transform: none; width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    max-width: none; padding-top: 0; padding-bottom: 0;
  }
  .header { padding-top: 10px; }
  .header .hamburger { display: none; }
  .edge-toggle { display: none; }
  .history-tools { padding-left: 24px; padding-right: 24px; }
  .messages { padding: 18px 24px 24px; }
  .rescue-view { padding: 20px 24px 28px; }
  .composer { padding: 12px 24px calc(12px + 0px); }
  .msg .acts { opacity: 1; }
  .msg:hover .acts, .msg:focus-within .acts { opacity: 1; }
}

/* ---------- WebChat light theme (scoped to the Chat view) ---------- */
body {
  color-scheme: light;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --panel-3: #e9ebef;
  --border: #d9dee5;
  --text: #1f2328;
  --muted: #5c6673;
  --faint: #6b7480;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --danger: #b42318;
  --ok: #067647;
  background: var(--bg);
  color: var(--text);
}
body .app { background: var(--bg); color: var(--text); }
body .overlay { background: rgba(15,23,42,.24); }
body .sidebar {
  background: #fbfbfa; border-right-color: var(--border);
  box-shadow: 1px 0 0 rgba(15,23,42,.03);
}
body .navtab { background: #f7f7f5; color: var(--muted); border-color: var(--border); }
body .navtab.active { background: #e8eefb; color: #1d4ed8; border-color: transparent; }
body .scope-tabs { background: var(--panel-2); }
body .scope-tabs button.active { background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
body .session-list li:hover { background: #f0f2f5; }
body .session-list li.active { background: #e8eefb; }
body .header,
body .live-run-strip,
body .runtime-controls,
body .composer { background: var(--panel); }
body .history-tools { background: #f7f7f5; }
body .history-tools button,
body .history-tools select { background: var(--panel-2); color: var(--text); }
body .msg.user { background: #f2f6ff; border-left-color: #2563eb; }
body .msg.user .who { color: #1d4ed8; }
body .msg.assistant .who { color: #5c6673; }
body .msg .acts button { background: var(--panel-2); color: var(--muted); border-color: var(--border); }
body .msg .acts button:hover { color: var(--text); }
body .msg .acts button.resend { color: #b42318; border-color: rgba(180,35,24,.35); }
body .body h2 { border-bottom-color: rgba(15,23,42,.08); }
body .body blockquote {
  background: #f6f7f9; color: #4b5563; border-left-color: #cbd5e1;
}
body .body code {
  background: #f1f3f5; color: #24292f; border-color: #e1e5ea;
}
body .body a { color: #1d4ed8; }
body .body th { background: #f1f3f5; }
body .codeblock { background: #f6f8fa; border-color: var(--border); }
body .codebar { background: #eef1f4; }
body .codebar .copy { background: #fff; color: var(--muted); }
body .codeblock pre code { color: #24292f; }
body .jump { background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.14); }
body .composer textarea,
body .composer .attach {
  background: var(--panel-2); color: var(--text); border-color: var(--border);
}
body .composer textarea::placeholder { color: var(--faint); }
body .attachment-preview button { background: #fff; color: var(--text); border-color: var(--border); }
body .toast { box-shadow: 0 6px 20px rgba(15,23,42,.14); }
body .skeleton .sk { background: linear-gradient(90deg,#eceff3,#f6f7f9,#eceff3); }
body .gateway-degraded {
  background: #fff8e6; border-bottom-color: #e6c78a; color: #7a4b00;
}
body .gateway-degraded button { border-color: #d9b56a; color: #7a4b00; }
body .status.reconnecting .txt,
body .live-sync-status,
body .iconbtn.active,
body .context-pct.warn { color: #9a6700; }
body .row1 .dot.running,
body .status .dot.running,
body .row1 .dot.delegated-running,
body .status .dot.delegated-running,
body .row1 .dot.awaiting-handoff,
body .status .dot.awaiting-handoff {
  background: #b7791f; box-shadow: 0 0 0 3px rgba(183,121,31,.16);
}
body .row1 .dot.attention-required,
body .status .dot.attention-required {
  background: var(--danger); box-shadow: 0 0 0 3px rgba(180,35,24,.14);
}
body .row1 .dot.finished-unchecked,
body .status .dot.finished-unchecked {
  background: var(--ok); box-shadow: 0 0 0 3px rgba(6,118,71,.14);
}
body .status .dot.bad { background: var(--danger); }
body .message-image { background: var(--panel-2); border-color: var(--border); }
body .message-image.placeholder { background: var(--panel-3); color: var(--muted); }
body .notification-settings { background: var(--panel-2); }
body .security-content,
body .step-up-content { background: var(--panel); color: var(--text); }
body .security-content input,
body .step-up-content input { background: var(--panel-2); color: var(--text); }
body ::selection { background: rgba(37,99,235,.18); color: inherit; }

/* ---------- Global light surfaces beyond Chat ---------- */
body .wf-row-badge { color:#8a5a00; border-color:#e6c78a; background:#fff4d6; }
body .wf-chip-running { color:#8a5a00; border-color:#e6c78a; background:#fff4d6; }
body .wf-chip-waiting_approval { color:#1d4ed8; border-color:#bfdbfe; background:#eff6ff; }
body .wf-chip-completed { color:#067647; border-color:#a7e3c3; background:#ecfdf3; }
body .wf-chip-failed { color:#b42318; border-color:#f3b5b0; background:#fef3f2; }
body .wf-guide-content { background:#f6f8fa; color:#24292f; }
body .wf-raw-prompt-content { color:#5c6673; }
body .wf-attempt-timing,
body .wf-attempt-card,
body .wf-closure-summary,
body .wf-owner-attempt-row { background:#f7f8fa; }
body .wf-owner-action { border-color:#e0b25a; background:#fff8e8; }
body .wf-owner-action-badge,
body .wf-owner-interruption { color:#8a5a00; }
body .wf-qualified-decision { border-color:#d8a23e; }
body .wf-attempt-reason-passed,
body .wf-review-pass { color:#067647; }
body .wf-attempt-reason-failed,
body .wf-review-fail { color:#b42318; }
body .wf-attempt-reason-interrupted,
body .wf-review-interrupted { color:#8a5a00; }
body .wf-attempt-reason-running { color:#9a6700; }
body .wf-tl-running { border-left-color:#b7791f; }
body .wf-tl-waiting_approval { border-left-color:#2563eb; }
body .wf-owner-resolution-option input[type='radio'] { accent-color:var(--accent); }
body .wf-owner-option.is-selected,
body .wf-owner-option:has(input:checked) {
  border-color:var(--accent);
  background:#eef4ff;
  box-shadow:0 0 0 1px var(--accent);
}
body .wf-owner-resolution-option.is-selected,
body .wf-owner-resolution-option:has(input:checked) {
  background:#eef4ff;
  box-shadow:0 0 0 1px var(--accent);
  border-radius:6px;
}
body .wf-owner-option.is-selected .wf-owner-option-heading strong { color:#1d4ed8; }
body .wf-owner-selected { color:#1d4ed8; font-size:11px; font-weight:700; }
body .wf-owner-selection-note { margin-top:10px; padding:8px 10px; border-radius:8px; border:1px dashed var(--border); background:var(--panel-2); color:var(--muted); font-size:12px; font-weight:600; }
body .wf-owner-selection-note.is-chosen { border:1px solid #bfdbfe; border-style:solid; background:#eff6ff; color:#1d4ed8; }
body .wf-owner-option:focus-within,
body .wf-owner-resolution-option:focus-within { outline:2px solid var(--accent); outline-offset:2px; }
body .wf-human-task-owner { border-left-color:#d8a23e; }
body .wf-side-filter:nth-child(2) strong { color:#9a6700; }
body .wf-filter-shortcut strong { background:#e9ebef; }
body .rescue-console { background:#f6f8fa; color:#24292f; }
body .rescue-actions .rescue-auto { background:#fff4d6; border-color:#e6c78a; color:#7a4b00; }
body .rescue-actions .rescue-restart { background:#fef3f2; border-color:#f3b5b0; color:#b42318; }
body .rescue-status dd.running { color:#9a6700; }
body .terminal-actions .danger { border-color:#f3b5b0; color:#b42318; }
body .terminal-screen { background:#fbfbfa; border-color:var(--border); }
body .wf-guide-dialog::backdrop,
body .rescue-stepup::backdrop { background:rgba(15,23,42,.28); }
