/* WeftNative workbench — iOS light. One scale, one accent, status by meaning. */
:root {
  color-scheme: light;
  --bg: #f2f3f5;
  --surface: #ffffff;
  --sunken: #f7f8fa;
  --fg: #1d1d1f;
  --muted: #5f6368;
  --faint: #8e9197;
  --line: #e3e5e9;
  --line-strong: #cfd3da;
  --accent: #0a66d8;
  --accent-hover: #0858bb;
  --accent-soft: #e9f2fd;
  --green: #17803d;
  --green-soft: #e8f5ec;
  --amber: #a85b00;
  --amber-soft: #fdf2e3;
  --red: #c22f38;
  --red-soft: #fdecec;
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(.16,1,.3,1);
  --sidebar: 236px;
  --inspector: 400px;
  font: 14px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei UI","Microsoft YaHei",sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: "Cascadia Mono", Consolas, "SFMono-Regular", monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }

/* Controls */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background-color 120ms, border-color 120ms, color 120ms, transform 120ms;
}
button:hover { background: var(--sunken); border-color: #b9bec7; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.quiet, .text-button { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 6px; min-height: 32px; }
.text-button:hover, button.quiet:hover { background: var(--accent-soft); border-color: transparent; }
.icon-button { width: 36px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.icon-button:hover { background: #e8eaee; color: var(--fg); border-color: transparent; }
.danger-button { color: var(--red); border-color: #efc4c7; }
.danger-button:hover { background: var(--red-soft); border-color: #e7a9ad; }
input, textarea, select {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 14px;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #0a66d826; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--fg); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.form-feedback { color: var(--red); font-size: 13px; }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.form-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
pre { margin: 0; padding: 12px 14px; max-height: 360px; overflow: auto; border-radius: var(--radius-sm); background: #f5f6f8; border: 1px solid var(--line); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; color: #2d3340; }
kbd { white-space: nowrap; font-size: 11px; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--sunken); }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }

/* Status chips */
.status { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef0f3; color: var(--muted); }
.status .icon { width: 14px; height: 14px; }
.status.ready { background: var(--accent-soft); color: var(--accent); }
.status.running, .status.queued { background: var(--green-soft); color: var(--green); }
.status.blocked, .status.failed { background: var(--red-soft); color: var(--red); }
.status.followup, .status.interrupted, .status.created { background: var(--amber-soft); color: var(--amber); }
.status.completed { background: var(--green-soft); color: var(--green); }
.available { color: var(--green); }
.unavailable { color: var(--red); }

/* Login */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: 16px; padding: 32px; border: 1px solid var(--line); display: grid; gap: 16px; }
.login-card .brand { font-size: 20px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.login-card .brand span { font-size: 13px; font-weight: 400; color: var(--muted); }
.login-card h1 { font-size: 22px; }
.login-intro, .login-footnote { color: var(--muted); font-size: 13px; }
#login-form, #token-login-form { display: grid; gap: 12px; }
.login-alternative summary { color: var(--accent); font-size: 13px; }
.login-alternative .disclosure-body { display: grid; gap: 10px; padding-top: 10px; }
.login-options-status { background: var(--amber-soft); color: var(--amber); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }

/* Shell */
.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0,1fr); min-height: 100dvh; }
.project-sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; border-right: 1px solid var(--line); background: #f7f8fa; }
.project-sidebar .brand { justify-content: flex-start; gap: 8px; border: 0; background: transparent; font-size: 17px; font-weight: 700; padding: 6px 8px; margin-bottom: 10px; }
.brand-mark { width: 26px; height: 26px; fill: none; stroke-width: 4; stroke-linecap: round; }
.sidebar-link { width: 100%; justify-content: flex-start; gap: 10px; border: 0; background: transparent; color: var(--fg); font-weight: 500; padding: 7px 10px; min-height: 36px; text-align: left; }
.sidebar-link span:not(.nav-count) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-link:hover { background: #eaecf0; }
.sidebar-link.selected { background: var(--surface); box-shadow: 0 0 0 1px var(--line); color: var(--accent); font-weight: 600; }
.nav-count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-section-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 4px 10px; font-size: 12px; font-weight: 600; color: var(--faint); }
.sidebar-section-title .icon-button { width: 28px; min-height: 28px; }
.project-list { display: grid; gap: 2px; align-content: start; overflow-y: auto; min-height: 0; flex: 1; }
.project-nav-group { display: grid; gap: 2px; }
.project-subnav { justify-content: flex-start; gap: 8px; border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 4px 10px 4px 38px; min-height: 30px; }
.project-subnav:hover { background: #eaecf0; color: var(--fg); }
.project-subnav.selected { color: var(--accent); font-weight: 600; }
.sidebar-empty { color: var(--faint); font-size: 13px; padding: 4px 10px; }
.sidebar-bottom { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.workspace-menu summary { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); font-weight: 500; }
.workspace-menu summary:hover { background: #eaecf0; }
.menu-panel { display: grid; gap: 1px; padding: 4px 0 4px 28px; }
.menu-panel button, .menu-panel a { justify-content: flex-start; border: 0; background: transparent; min-height: 32px; padding: 4px 10px; font-size: 13px; font-weight: 400; color: var(--fg); border-radius: 6px; text-align: left; }
.menu-panel button:hover, .menu-panel a:hover { background: #eaecf0; text-decoration: none; }
.connection-control { display: flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.connection::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 7px; vertical-align: 1px; }
.connection[data-state="offline"]::before { background: var(--red); }
.connection[data-state="connecting"]::before { background: var(--faint); }
.sidebar-backdrop { display: none; }
.mobile-only { display: none; }

.workspace-main { min-width: 0; padding: 20px 32px 0; outline: none; }
.app-toolbar { display: flex; align-items: center; gap: 16px; min-height: 44px; margin-bottom: 20px; }
.toolbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.toolbar-title h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-button { border: 0; background: transparent; color: var(--accent); padding: 6px 8px 6px 2px; font-weight: 500; }
.back-button:hover { background: var(--accent-soft); }
.back-button span { max-width: 40ch; overflow: hidden; text-overflow: ellipsis; }
.workspace-tools { display: flex; align-items: center; gap: 8px; }
.search-field { display: flex; align-items: center; gap: 8px; width: 260px; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--faint); font-weight: 400; }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px #0a66d826; }
.search-field input { border: 0; box-shadow: none !important; padding: 0; min-height: 0; height: 100%; background: transparent; }
.loading-state { padding: 80px 0; text-align: center; color: var(--muted); }
.loading-state h2 { font-size: 16px; font-weight: 500; }
.refresh-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--amber-soft); color: var(--amber); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.navigation-status { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--fg); color: #fff; font-size: 12px; padding: 6px 12px; border-radius: 99px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 24px; align-items: start; max-width: 1180px; }
body[data-view="task"] .workspace-grid { grid-template-columns: minmax(0,1fr) var(--inspector); max-width: 1440px; }
.primary-column { min-width: 0; display: flex; flex-direction: column; min-height: calc(100dvh - 84px); }
.home-panel, .task-panel { flex: 1; padding-bottom: 24px; }

/* Home */
.home-panel { display: grid; gap: 28px; align-content: start; }
.work-group { display: grid; gap: 10px; }
.group-heading { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.group-heading h2 { font-size: 16px; font-weight: 700; }
.group-count { font-size: 13px; color: var(--muted); font-weight: 500; }
.group-empty { color: var(--muted); font-size: 13px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.work-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: border-color 120ms, box-shadow 120ms; }
.work-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px #1d1d1f0d; }
.work-card.accept { border-top: 3px solid var(--accent); }
.work-card.decide { border-top: 3px solid var(--amber); }
.card-main { flex: 1; width: 100%; justify-content: stretch; display: grid; justify-items: start; align-content: start; gap: 6px; text-align: left; white-space: normal; border: 0; border-radius: 0; background: transparent; padding: 14px 16px 10px; font-weight: 400; }
.card-main:hover { background: transparent; }
.card-kicker { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.accept .card-kicker { color: var(--accent); }
.decide .card-kicker { color: var(--amber); }
.card-title { font-size: 15px; font-weight: 650; line-height: 1.45; }
.card-reason { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 12px; color: var(--faint); }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 14px; }
.card-actions button { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.row-list { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row-list > .group-empty { border: 0; border-radius: 0; }
.work-row { justify-content: stretch; display: grid; grid-template-columns: 20px minmax(0,1fr) 150px 80px; align-items: center; gap: 14px; width: 100%; text-align: left; white-space: normal; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 12px 16px; font-weight: 400; min-height: 60px; }
.work-row:last-child { border-bottom: 0; }
.work-row:hover { background: var(--sunken); }
.row-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); justify-self: center; }
.row-dot.running { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); animation: breathe 2.4s ease-in-out infinite; }
.row-dot.paused { background: transparent; border: 2px solid var(--faint); }
.row-dot.done { width: 20px; height: 20px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-main strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-progress { display: grid; gap: 4px; }
.row-progress small { font-size: 12px; color: var(--muted); }
.progress { display: block; height: 4px; border-radius: 2px; background: #e6e8ec; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); border-radius: 2px; }
.row-time { font-size: 12px; color: var(--faint); text-align: right; white-space: nowrap; }
.work-row.done { grid-template-columns: 20px minmax(0,1fr) auto; }
.done-group > summary { padding: 4px 0; }
.done-group > summary .chevron { color: var(--muted); transition: transform 160ms var(--ease); }
.done-group[open] > summary .chevron { transform: rotate(180deg); }
.done-group > .row-list { margin-top: 10px; }
.empty-state { color: var(--muted); text-align: center; padding: 28px 16px; display: grid; gap: 8px; justify-items: center; }
.empty-state.compact { padding: 14px; }
.welcome { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 24px; }
.welcome h2 { font-size: 18px; color: var(--fg); }

/* Task */
.task-heading { display: grid; gap: 12px; padding-bottom: 16px; }
.task-project { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.task-project span + span::before { content: "·"; margin-right: 10px; }
.task-title-row { display: flex; align-items: flex-start; gap: 12px; }
.task-title-row h2 { font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; overflow-wrap: anywhere; outline: none; }
.task-title-row .status { margin-top: 4px; }
.task-banner { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); background: #eef0f3; font-size: 13px; color: var(--muted); }
.task-banner strong { color: var(--fg); font-size: 14px; }
.task-banner span { white-space: pre-wrap; overflow-wrap: anywhere; }
.task-banner.accept { background: var(--accent-soft); }
.task-banner.accept strong { color: var(--accent); }
.task-banner.danger { background: var(--red-soft); }
.task-banner.danger strong { color: var(--red); }
.task-banner.running { background: var(--green-soft); }
.task-banner.running strong { color: var(--green); }
.task-banner.done { background: var(--green-soft); }
.task-banner.done strong { color: var(--green); }
.task-heading-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-button { display: none; }
.action-feedback { font-size: 13px; color: var(--muted); }
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: #e6e8ec; gap: 2px; }
.segmented button { min-height: 30px; padding: 3px 12px; border: 0; background: transparent; font-size: 13px; color: var(--muted); border-radius: 7px; }
.segmented button:hover { background: #dcdfe4; }
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px #0000001a; }

.timeline-list { position: relative; display: grid; gap: 0; }
.tl-item { position: relative; display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 14px; padding-bottom: 18px; }
.tl-item::before { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: 0; width: 1px; background: var(--line-strong); }
.tl-item:last-child::before { display: none; }
.tl-mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eceef1; color: var(--muted); font-size: 12px; font-weight: 700; border: 1px solid var(--line); }
.tl-item.done .tl-mark { background: var(--green-soft); color: var(--green); border-color: #cfe8d7; }
.tl-item.running .tl-mark { background: var(--surface); border: 2px solid var(--green); }
.tl-item.failed .tl-mark { background: var(--red-soft); color: var(--red); border-color: #f2c9cc; }
.tl-item.info .tl-mark { background: var(--accent-soft); color: var(--accent); border-color: #cfe1f8; }
.tl-item.accept .tl-mark { background: var(--accent); color: #fff; border-color: var(--accent); }
.tl-item.pending .tl-mark { background: var(--surface); color: var(--faint); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--green); animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; } }
.tl-body { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.tl-item.pending .tl-body { background: transparent; border-style: dashed; }
.tl-item.running .tl-body { border-color: #b8dcc4; box-shadow: 0 0 0 3px var(--green-soft); }
.tl-item.failed .tl-body { border-color: #efc4c7; }
.tl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tl-head strong { font-size: 14px; font-weight: 650; }
.tl-meta { font-size: 12px; color: var(--faint); white-space: nowrap; }
.tl-text { font-size: 13.5px; color: #3a3f47; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-text.muted { color: var(--muted); }
.goal-text { color: var(--fg); }
.tl-body h4 { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.tl-body ul { display: grid; gap: 4px; font-size: 13px; color: #3a3f47; }
.tl-body ul li { padding-left: 14px; position: relative; overflow-wrap: anywhere; }
.tl-body ul li::before { content: ""; position: absolute; left: 3px; top: .65em; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.tl-body ul.issues li { color: var(--red); }
.followups time { color: var(--faint); font-size: 12px; margin-right: 8px; }
.tl-agent { display: flex; }
.agent-chip { min-height: 28px; padding: 2px 10px 2px 3px; gap: 6px; border-radius: 99px; border-color: var(--line); background: var(--sunken); font-size: 12.5px; font-weight: 600; }
.agent-chip small { font-weight: 400; color: var(--muted); }
.agent-chip .app-icon { border-radius: 50%; padding: 3px; }
.flow-link { justify-self: start; font-size: 13px; }
.step-details > summary { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--accent); font-weight: 500; }
.step-details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 140ms; }
.step-details[open] > summary::before { transform: rotate(45deg); }
.step-details .disclosure-body { display: grid; gap: 8px; padding-top: 8px; }
.command-output { background: #1f2329; color: #e6e8eb; border: 0; }
.accept-card { display: grid; gap: 10px; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; padding-left: 0 !important; }
.checklist li::before { display: none; }
.checklist .icon { color: var(--green); margin-top: 3px; }
.verify-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--green); font-weight: 600; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip { min-height: 30px; padding: 3px 10px; font-size: 12.5px; gap: 6px; }
.accept-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.accept-actions small { color: var(--muted); font-size: 12px; }

/* Records */
.records-panel { display: grid; gap: 16px; }
.records-panel .section-heading { display: flex; justify-content: space-between; align-items: center; }
.records-panel h2 { font-size: 16px; }
.section-intro { color: var(--muted); font-size: 13px; }
.record-section { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.record-section h3 { font-size: 14px; margin-bottom: 4px; }
.record-section details { border-top: 1px solid var(--line); }
.record-section details > summary { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 13px; }
.record-section .disclosure-body { padding-bottom: 10px; }
.disclosure-meta { color: var(--faint); font-size: 12px; white-space: nowrap; }
.event-list { display: grid; }
.event-row { padding: 9px 0; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.event-row > div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.event-row time { color: var(--faint); font-size: 12px; }
.event-row > p { font-size: 13px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.event-operation { font-size: 12px; color: var(--faint); }
.scene img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 6px 0; }
.scene p { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; }

/* Assistant command panel */
.command-panel { position: sticky; bottom: 0; z-index: 10; padding: 12px 0 16px; background: linear-gradient(to bottom, #f2f3f500, var(--bg) 14px); display: grid; gap: 8px; }
#assistant-form { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; padding: 8px 8px 8px 14px; box-shadow: 0 2px 12px #1d1d1f0f; }
#assistant-form:focus-within { border-color: var(--accent); }
#assistant-input { border: 0; box-shadow: none !important; padding: 6px 0; min-height: 34px; max-height: 180px; resize: none; field-sizing: content; }
.command-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.command-buttons { display: flex; gap: 4px; }
.scope-trigger { min-height: 28px; padding: 2px 8px; font-size: 12px; color: var(--muted); border-color: var(--line); background: var(--sunken); font-weight: 500; }
.send-button { width: 36px; padding: 0; border-radius: 10px; }
.assistant-mode { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--accent); font-weight: 600; }
.assistant-receipt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.receipt-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.receipt-fact { color: var(--muted); margin-top: 4px; }
.receipt-excerpt { color: var(--muted); margin-top: 4px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.picker { position: relative; }
.picker-menu { position: absolute; z-index: 40; left: 0; top: calc(100% + 6px); min-width: 220px; max-width: 320px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 8px 30px #1d1d1f1f; display: grid; }
.picker-menu.upward { top: auto; bottom: calc(100% + 6px); }
.picker-menu button { justify-content: space-between; border: 0; background: transparent; font-weight: 400; min-height: 34px; text-align: left; white-space: normal; }
.picker-menu button:hover, .picker-menu button:focus { background: var(--sunken); }
.picker-menu button[aria-selected="true"] { color: var(--accent); font-weight: 600; }

/* Inspector */
.inspector { position: sticky; top: 20px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.inspector-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.inspector-bar h2 { font-size: 15px; flex: 1; outline: none; }
.inspector-content { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 18px; display: grid; gap: 18px; align-content: start; }
.inspector-section { display: grid; gap: 10px; }
.inspector-section > h3 { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.inspector-section p { font-size: 13px; color: var(--muted); }
.artifact-tabs, .member-tabs { display: flex; gap: 2px; overflow-x: auto; }
.artifact-tabs button { min-height: 30px; padding: 3px 10px; font-size: 12.5px; border: 0; background: transparent; color: var(--muted); border-radius: 7px; }
.artifact-tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.artifact-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--sunken); }
.artifact-frame { display: block; width: 100%; height: 360px; border: 0; background: #fff; }
.file-preview-code { border: 0; border-radius: 0; max-height: 360px; }
.markdown-preview { padding: 12px 14px; font-size: 13px; display: grid; gap: 8px; max-height: 360px; overflow: auto; background: #fff; }
.markdown-preview h3 { font-size: 14px; }
.markdown-preview ul { list-style: disc; padding-left: 18px; }
.preview-empty { display: grid; justify-items: center; gap: 6px; padding: 28px 12px; color: var(--muted); text-align: center; font-size: 13px; }
.preview-empty .icon { color: var(--faint); }
.preview-caption { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--faint); }
.preview-caption a { display: inline-flex; align-items: center; gap: 4px; }
.delivery-members { display: grid; gap: 6px; }
.delivery-member { justify-content: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border-color: var(--line); text-align: left; font-weight: 400; min-height: 52px; white-space: normal; }
.delivery-member > span:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.delivery-member strong { font-size: 13.5px; }
.delivery-member small { font-size: 12px; color: var(--muted); }
.member-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.member-state.active { color: var(--green); font-weight: 600; }
.member-state .icon { color: var(--green); }
.app-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 5px; color: var(--muted); }
.app-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.app-icon > svg { width: 100%; height: 100%; }
.member-heading { display: flex; gap: 12px; align-items: center; }
.member-heading h2 { font-size: 17px; }
.member-heading p { font-size: 13px; color: var(--muted); }
.member-tabs { padding: 2px; background: #e6e8ec; border-radius: 9px; }
.member-tabs button { flex: 1; min-height: 32px; border: 0; background: transparent; font-size: 13px; color: var(--muted); }
.member-tabs button[aria-selected="true"] { background: #fff; color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px #0000001a; }
.member-detail-body { display: grid; gap: 10px; }
.member-conversation { display: grid; gap: 10px; }
.member-message { display: grid; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.member-message-author { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.member-message-author time { margin-left: auto; color: var(--faint); font-size: 12px; }
.member-message-author .app-icon { width: 24px !important; height: 24px !important; padding: 3px; }
.member-message-body { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; color: #3a3f47; }
.member-source-details summary, .member-scene summary { font-size: 12px; color: var(--accent); }
.member-scene img { width: 100%; border-radius: var(--radius-sm); }
.member-detail-body details:not(.member-source-details) { border-top: 1px solid var(--line); }
.member-detail-body details > summary { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; font-size: 13px; }
.problem-block { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; display: grid; gap: 8px; }
.inspector-kicker { font-size: 12px; color: var(--muted); font-weight: 600; }
.inspector-description { font-size: 13px; color: var(--muted); }
.inspector-form { display: grid; gap: 12px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; }
.danger-zone small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.current-fact { font-size: 13px; color: var(--muted); }

/* Project settings and flow canvas */
.project-settings { display: grid; gap: 20px; max-width: 1440px; padding-bottom: 32px; }
.settings-heading { display: flex; justify-content: space-between; gap: 16px; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 600; }
.settings-heading h2 { font-size: 22px; }
.project-path { font: 12px "Cascadia Mono", Consolas, monospace; color: var(--faint); overflow-wrap: anywhere; margin-top: 2px; }
.flow-layout { display: grid; grid-template-columns: minmax(0,1fr) 360px; gap: 20px; align-items: start; }
.flow-board { display: grid; gap: 10px; min-width: 0; }
.flow-board-heading h3 { font-size: 16px; }
.flow-board-heading p { font-size: 13px; color: var(--muted); }
.flow-editor { position: sticky; top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; max-height: calc(100dvh - 40px); overflow-y: auto; }
.flow-editor:empty { display: none; }
.flow-editor h2 { font-size: 16px; }
.flow-editor .inspector-section { border-top: 1px solid var(--line); padding-top: 12px; gap: 6px; }
.flow-editor .inspector-section h3 { font-size: 13px; color: var(--fg); }
.flow-editor small { font-size: 12px; color: var(--muted); }
.canvas-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.canvas-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.canvas-toolbar:empty { display: none; }
.canvas-command-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.canvas-command-group button { min-height: 32px; font-size: 13px; padding: 4px 10px; }
.canvas-command-group .icon { width: 15px; height: 15px; }
.flow-mode-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.segmented.small button { min-height: 28px; font-size: 12.5px; }
.canvas-explanation { color: var(--muted); font-size: 12.5px; padding: 8px 14px 10px; }
.canvas-alert { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 12px 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--amber-soft); color: var(--amber); font-size: 12.5px; }
.canvas-alert button { min-height: 30px; font-size: 12px; flex: none; }
.graph-viewport { height: 520px; overflow: auto; position: relative; overscroll-behavior: contain; background-color: #fafbfc; background-image: radial-gradient(#dde2ea .8px, transparent .8px); background-size: 18px 18px; border-top: 1px solid var(--line); outline: none; }
.graph-space { min-width: 0; position: relative; margin: 0 auto; }
.graph-world { position: relative; transform-origin: top left; }
.graph-edges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; color: #8fa6c4; }
.graph-edge { fill: none; stroke: #a3b4cb; stroke-width: 1.8; }
.graph-edge.sequence { stroke: #6f7fc0; stroke-dasharray: 6 5; }
.graph-edge.preview { stroke: var(--accent); stroke-dasharray: 5 5; }
.graph-edge.context { stroke: #c4cedb; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16px; cursor: pointer; }
.edge-dot { fill: #a3b4cb; }
.graph-edges .selected .graph-edge { stroke: var(--accent); stroke-width: 2.6; }
.graph-edges .selected .edge-dot { fill: var(--accent); }
.graph-owner { position: absolute; width: 132px; height: 62px; display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--fg); font-size: 14px; }
.graph-node-wrap { position: absolute; width: 240px; height: 110px; }
.graph-node { display: flex; align-items: center; justify-content: flex-start; width: 240px; height: 110px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 14px; gap: 12px; text-align: left; background: #fff; white-space: normal; font-weight: 400; }
.graph-node:hover { background: #fff; border-color: #8db5e8; }
.graph-node.fixed { background: var(--sunken); }
.graph-node[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px #0a66d826; }
.graph-node[data-node-drag] { cursor: grab; touch-action: none; }
.graph-node[data-node-drag]:active { cursor: grabbing; transform: none; }
.graph-node .app-icon { width: 42px; height: 42px; border-radius: 10px; }
.graph-node-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.graph-node-copy strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.graph-node-copy small { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.draft-node-label { font-size: 11px; color: var(--faint); }
.graph-port { position: absolute; width: 22px; height: 22px; min-height: 22px; padding: 5px; border: 0; left: calc(50% - 11px); bottom: -11px; background: transparent; touch-action: none; border-radius: 50%; }
.graph-port span, .graph-port-marker { display: block; width: 10px; height: 10px; background: #8db5e8; border: 2px solid #fafbfc; border-radius: 50%; }
.graph-port:hover { background: var(--accent-soft); }
.graph-port-marker.input { position: absolute; top: -5px; left: calc(50% - 5px); }
.graph-hint { position: absolute; color: var(--muted); text-align: center; }
.graph-hint strong { color: var(--fg); font-size: 16px; font-weight: 600; }
.graph-hint p { font-size: 13px; margin-top: 6px; }
.canvas-empty { text-align: center; color: var(--muted); padding: 60px 20px; display: grid; justify-items: center; gap: 8px; }
.canvas-empty h3 { font-size: 16px; color: var(--fg); }
.canvas-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px; min-height: 44px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.canvas-footer > div { display: flex; align-items: center; gap: 4px; flex: none; }
.canvas-footer button { width: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; }
.canvas-footer button:hover { background: var(--sunken); }
.edge-kind-label { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 12px; margin-right: 6px; }
.edge-kind-label select { min-height: 30px; padding: 2px 8px; font-size: 12px; width: auto; }
.zoom-label { width: 38px; text-align: center; font-variant-numeric: tabular-nums; }
.flow-name-field input { font-weight: 400; }

/* Secondary pages */
.secondary-page { max-width: 760px; display: grid; gap: 16px; padding-bottom: 40px; }
.secondary-page > h1 { font-size: 22px; }
.page-intro, .settings-intro { color: var(--muted); font-size: 13.5px; }
.settings-back { justify-self: start; }
#task-form, .settings-form { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.settings-form h2 { font-size: 15px; }
#settings > h2 { font-size: 15px; margin-top: 8px; }
.resource-row, .rule-row, .connection-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; }
.resource-row h3, .rule-row h3 { font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.resource-row h3 small { font-size: 12px; font-weight: 600; }
.resource-row p, .rule-row p, .connection-row > p { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.resource-row small, .rule-row small, .connection-row small { color: var(--faint); font-size: 12px; }
.resource-row > button, .rule-row > button { justify-self: start; margin-top: 6px; min-height: 30px; font-size: 13px; }
.connection-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.connection-heading h3 { font-size: 14px; margin-right: auto; }
.connection-heading span { font-size: 12px; color: var(--muted); }
.connection-operations { display: grid; gap: 4px; font-size: 13px; }
.connection-operations li { display: flex; justify-content: space-between; gap: 8px; }
.connection-addresses { display: grid; gap: 10px; }
.connection-addresses h2, .connection-list-heading { font-size: 15px; }
.endpoint-row { font-weight: 500; }
.endpoint-field { display: flex; gap: 6px; }
.endpoint-field input { font: 12px "Cascadia Mono", Consolas, monospace; }
.token-result { background: var(--green-soft); border-radius: var(--radius); padding: 14px; display: grid; gap: 8px; }
.token-result code { overflow-wrap: anywhere; user-select: all; font-size: 12.5px; }
.connection-help summary { color: var(--accent); font-size: 13px; }
.studio-heading { font-size: 15px; margin-top: 8px; }
.studio-form .member-heading p { font-size: 13px; }
.quota-line { color: var(--fg) !important; font-size: 13px; font-weight: 500; }
.quota-line.unavailable { color: var(--red) !important; }
.company-tree { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.company-tree .owner, .global-position { display: flex; gap: 12px; align-items: center; }
.company-branches { display: grid; gap: 10px; padding-left: 26px; border-left: 2px solid var(--line); margin-left: 18px; }
.company-tree p { font-size: 13px; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent); flex: none; }
.owner-avatar { background: var(--fg); color: #fff; }

/* Dialogs and notice */
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); box-shadow: 0 20px 60px #0000002e; color: var(--fg); }
dialog::backdrop { background: #1d1d1f59; }
.wide-dialog { width: min(820px, calc(100vw - 32px)); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dialog-heading h2 { font-size: 17px; }
dialog p { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
#project-form { display: grid; gap: 12px; }
.path-field { display: flex; gap: 6px; }
.folder-list { display: grid; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.folder-list button { justify-content: flex-start; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; font-weight: 400; text-align: left; white-space: normal; }
.folder-list button:last-child { border-bottom: 0; }
.conversation-dialog { width: min(680px, calc(100vw - 32px)); }
.assistant-messages { display: grid; gap: 4px; max-height: 60dvh; overflow-y: auto; }
.chat { padding: 10px 12px; border-radius: 12px; background: var(--sunken); font-size: 13.5px; max-width: 88%; }
.chat.user { justify-self: end; background: var(--accent-soft); }
.chat.chat-error { background: var(--red-soft); }
.byline { display: flex; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.byline time { font-weight: 400; color: var(--faint); }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.version-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.version-row p, .version-row small { font-size: 12px; color: var(--muted); margin: 0; }
.merge-choice { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin: 0 0 10px; display: grid; gap: 8px; }
.merge-choice label { font-weight: 400; }
.notice { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: min(560px, calc(100vw - 32px)); background: var(--fg); color: #fff; border-radius: 12px; padding: 10px 10px 10px 16px; font-size: 13.5px; box-shadow: 0 10px 30px #0000003d; }
.notice[data-tone="error"] { background: var(--red); }
.notice button { color: #fff; border-color: #ffffff4d; background: transparent; min-height: 30px; }

/* Narrower desktops: the inspector becomes a sheet opened on demand */
@media (max-width: 1240px) {
  body[data-view="task"] .workspace-grid { grid-template-columns: minmax(0,1fr); }
  .inspector { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); max-height: none; border-radius: 0; z-index: 50; transform: translateX(105%); transition: transform 220ms var(--ease); box-shadow: -12px 0 40px #0000001f; }
  body.inspector-open .inspector { transform: none; }
  .inspector .mobile-only { display: inline-flex; }
  .sheet-button { display: inline-flex; }
  .flow-layout { grid-template-columns: minmax(0,1fr); }
  .flow-editor { position: static; max-height: none; }
}

/* Phones */
@media (max-width: 860px) {
  :root { font-size: 15px; }
  .app-shell { grid-template-columns: minmax(0,1fr); }
  .mobile-only { display: inline-flex; }
  .project-sidebar { position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-105%); transition: transform 220ms var(--ease); background: #f7f8fa; }
  body.sidebar-open .project-sidebar { transform: none; box-shadow: 12px 0 40px #00000026; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 65; border: 0; border-radius: 0; background: #1d1d1f59; }
  .workspace-main { padding: 10px 14px 0; }
  .app-toolbar { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .toolbar-title h1 { font-size: 20px; }
  .workspace-tools { width: 100%; order: 3; }
  .search-field { flex: 1; width: auto; }
  .search-field kbd { display: none; }
  .workspace-tools .primary span, #open-project-settings span { display: none; }
  .workspace-tools button { width: 40px; padding: 0; }
  .card-list { grid-template-columns: minmax(0,1fr); }
  .work-row { grid-template-columns: 14px minmax(0,1fr) auto; gap: 10px; padding: 12px; }
  .work-row .row-progress { display: none; }
  .row-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .task-title-row { flex-direction: column; gap: 6px; }
  .task-title-row h2 { font-size: 19px; }
  .task-title-row .status { margin-top: 0; }
  .task-heading-bottom { flex-direction: column; align-items: stretch; }
  .task-actions button { flex: 1; }
  .view-switch { width: 100%; }
  .view-switch button { flex: 1; }
  .tl-item { grid-template-columns: 24px minmax(0,1fr); gap: 10px; }
  .tl-mark { width: 24px; height: 24px; }
  .tl-item::before { left: 11.5px; top: 26px; }
  .tl-head { flex-direction: column; gap: 2px; }
  .tl-body { padding: 11px 12px; }
  .agent-chip small { display: none; }
  .command-panel { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #assistant-input { font-size: 16px; }
  .inspector { width: 100vw; }
  .inspector-bar { min-height: 56px; }
  .member-tabs button { min-height: 44px; }
  .graph-viewport { height: 420px; }
  .canvas-command-group button { min-height: 36px; }
  .form-two { grid-template-columns: 1fr; }
  .notice { bottom: 96px; }
  input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
