:root {
  --bg: #17181b;
  --side: #1d1e22;
  --panel: #232529;
  --raised: #2b2d33;
  --hover: #31343a;
  --border: #35373e;
  --text: #e9e9eb;
  --muted: #9b9da4;
  --faint: #6d7078;
  --accent: #ff8a1f;
  --accent-ink: #1b1206;
  --accent-soft: rgba(255, 138, 31, 0.13);
  --ok: #5cc27a;
  --warn: #f2b84b;
  --bad: #ef6461;
  --radius: 10px;
  --c-claude: #d97757;
  --c-codex: #6fb59f;
  --c-gemini: #e9b949;
  --c-openrouter: #b18cff;
  --c-deepseek: #5b7cff;
  --c-kimi: #e8e8ea;
  --c-glm: #3ec1d3;
  --c-mock: #8a8f98;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--raised); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--raised); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 6px 8px; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
select { cursor: pointer; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.hint { font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--raised); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.p-claude { color: var(--c-claude); border-color: color-mix(in srgb, var(--c-claude) 40%, transparent); }
.badge.p-codex { color: var(--c-codex); border-color: color-mix(in srgb, var(--c-codex) 40%, transparent); }
.badge.p-gemini { color: var(--c-gemini); border-color: color-mix(in srgb, var(--c-gemini) 40%, transparent); }
.badge.p-deepseek { color: var(--c-deepseek); border-color: color-mix(in srgb, var(--c-deepseek) 40%, transparent); }
.badge.p-kimi { color: var(--c-kimi); }
.badge.p-glm { color: var(--c-glm); border-color: color-mix(in srgb, var(--c-glm) 40%, transparent); }
.badge.p-openrouter { color: var(--c-openrouter); border-color: color-mix(in srgb, var(--c-openrouter) 40%, transparent); }
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--bad); }
.badge.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; display: inline-block; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; height: 100dvh; }
.sidebar { background: var(--side); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; font-weight: 700; font-size: 16px; }
.brand img { width: 28px; height: 28px; }
.nav { padding: 4px 8px; }
.nav a, .plist a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover, .plist a:hover { background: var(--raised); }
.nav a.active, .plist a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.plist { padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.plist a .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist a .count { font-size: 12px; color: var(--faint); }
.plist a.archived { opacity: .5; }
.side-foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; gap: 6px; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: none; }
.page { padding: 24px 28px 40px; overflow-y: auto; flex: 1; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; }

/* ---------- overview ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pcard { display: block; background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--pc, var(--accent)); border-radius: var(--radius); padding: 14px 16px; color: var(--text); text-decoration: none !important; transition: background .12s, transform .12s; }
.pcard:hover { background: var(--raised); }
.pcard .t { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.pcard .d { color: var(--muted); font-size: 13px; margin: 4px 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.pcard .m { display: flex; gap: 6px; flex-wrap: wrap; }
.provgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 26px; }
.prov { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.prov .n { font-weight: 600; }
.prov .h { font-size: 12px; color: var(--muted); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 0 0 10px; }

/* ---------- project ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 28px; background: var(--bg); flex: none; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.phead { padding: 18px 28px 12px; display: flex; align-items: center; gap: 12px; flex: none; }
.phead .dot { width: 14px; height: 14px; }
.phead .desc { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* chats */
.chatwrap { display: grid; grid-template-columns: 260px 1fr; flex: 1; min-height: 0; }
.threads { border-right: 1px solid var(--border); overflow-y: auto; padding: 10px; }
.threads a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.threads a:hover { background: var(--raised); }
.threads a.active { background: var(--accent-soft); }
.threads a .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.threads a .tm { font-size: 12px; color: var(--faint); display: flex; gap: 6px; align-items: center; }
.convo { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.msgs { flex: 1; overflow-y: auto; padding: 22px 28px 10px; }
.msgs-inner { max-width: 860px; margin: 0 auto; }
.msg { margin-bottom: 22px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--raised); border: 1px solid var(--border); padding: 10px 14px; border-radius: 14px 14px 4px 14px; max-width: 80%; white-space: pre-wrap; word-wrap: break-word; }
.msg.event { color: var(--muted); font-size: 13px; text-align: center; }
.msg.event.err { color: var(--bad); text-align: left; background: color-mix(in srgb, var(--bad) 10%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); padding: 8px 12px; border-radius: 8px; white-space: pre-wrap; }
.ahead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.steps { margin: 6px 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); font-size: 13px; }
.steps summary { padding: 6px 10px; cursor: pointer; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
.steps summary::-webkit-details-marker { display: none; }
.steps summary::before { content: '▸'; transition: transform .15s; }
.steps[open] summary::before { transform: rotate(90deg); }
.steps ol { margin: 0; padding: 4px 12px 10px 30px; }
.steps li { margin: 3px 0; color: var(--muted); }
.steps li b { color: var(--text); font-weight: 600; }
.steps li code { font-size: 12px; word-break: break-all; }
.steps li.status { color: var(--warn); list-style: '⚠ '; }
.steps li.fail b { color: var(--bad); }
.md { word-wrap: break-word; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5, .md h6 { margin: 16px 0 8px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li.check { list-style: none; margin-left: -18px; }
.md code { background: var(--raised); padding: 1px 5px; border-radius: 5px; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md pre { position: relative; background: #121316; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0 0 12px; }
.md pre code { background: none; padding: 0; font-size: 13px; }
.md pre .copy { position: absolute; top: 6px; right: 6px; font-size: 12px; background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; cursor: pointer; color: var(--muted); opacity: 0; transition: opacity .15s; }
.md pre:hover .copy { opacity: 1; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md .tablewrap { overflow-x: auto; margin-bottom: 12px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--panel); }
.md-task { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.composer { border-top: 1px solid var(--border); padding: 12px 28px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); flex: none; }
.composer-inner { max-width: 860px; margin: 0 auto; }
.composer .box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.composer .box:focus-within { border-color: var(--accent); }
.composer textarea { border: 0; background: transparent; min-height: 44px; max-height: 40vh; resize: none; padding: 6px 8px; }
.composer .controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.composer select { width: auto; max-width: 230px; padding: 5px 8px; font-size: 13px; background: var(--raised); }
.voice-start { color: var(--accent); }
.voice-call { width: min(460px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 22px; border: 1px solid var(--border); border-radius: 22px; color: var(--text); background: var(--panel); box-shadow: 0 24px 80px #0008; }
.voice-call::backdrop { background: #101114d4; }
.voice-call { position: fixed; inset: 0; z-index: 80; height: fit-content; margin: auto; }
.voice-call.compact { inset: auto max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) auto; margin: 0; width: min(390px, calc(100vw - 24px)); border-radius: 14px; padding: 10px 12px; }
.voice-call.compact .voice-indicator, .voice-call.compact .voice-transcript, .voice-call.compact .voice-options, .voice-call.compact .voice-label { display: none; }
.voice-call.compact h2 { font-size: 15px; }
.voice-call.compact .voice-status { min-height: 0; text-align: left; margin: 6px 0; font-size: 12px; }
.voice-call header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.voice-call header > div { min-width: 0; text-align: left; }
.call-recap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.call-recap h2 { margin: 0 0 8px; }
.call-recap-grid ul { padding-left: 18px; margin: 0; }
.call-recap #recapRefresh { margin-top: 12px; }
@media (max-width: 560px) { .call-recap-grid { grid-template-columns: minmax(0, 1fr); } }
.voice-call header { text-align: center; }
.voice-label { font-size: 12px; color: var(--muted); }
.voice-call h2 { margin: 3px 0 0; font-size: 23px; overflow-wrap: anywhere; }
.voice-indicator { display: flex; justify-content: center; align-items: center; gap: 5px; width: 82px; height: 82px; margin: 15px auto 8px; background: radial-gradient(circle at 35% 20%, var(--accent-soft), var(--bg)); border-radius: 50%; border: 1px solid var(--border); }
.voice-indicator span { background: var(--accent); width: 4px; height: 16px; border-radius: 6px; opacity: .7; }
.voice-indicator span:nth-child(2n) { height: 24px; }
.voice-indicator span:nth-child(3) { height: 33px; }
.voice-call:is([data-stage=listening],[data-stage=speaking]) .voice-indicator span { animation: voice-level 1.05s ease-in-out infinite alternate; animation-delay: calc(-.13s * var(--beat, 1)); }
.voice-indicator span:nth-child(2) { --beat: 3; }
.voice-indicator span:nth-child(3) { --beat: 4; }
.voice-indicator span:nth-child(4) { --beat: 2; }
@keyframes voice-level { from { transform: scaleY(.47); opacity: .62; } to { transform: scaleY(1.05); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .voice-call .voice-indicator span { animation: none !important; } }
.voice-status { min-height: 2.8em; margin: 0 0 7px; color: var(--muted); text-align: center; }
.voice-transcript { max-height: min(27dvh, 190px); overflow: auto; overscroll-behavior: contain; }
.voice-transcript:empty { display: none; }
.voice-transcript p { margin: 0 0 7px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 8px; }
.voice-transcript strong { display: block; font-size: 12px; color: var(--accent); }
.voice-options { margin: 8px 0; font-size: 13px; }
.voice-options > summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.voice-options > div { padding: 10px 0 4px; }
.voice-options .hint { margin-bottom: 0; }
.voice-call footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.voice-call footer [hidden] { display: none; }
@media (max-width: 480px) { .voice-call { padding: 15px; } .composer .voice-start { padding-inline: 8px; } }
.route-note { font-size: 12px; color: var(--faint); margin-top: 6px; min-height: 16px; }

/* tasks */
.task-add, .task-tools { display: grid; align-items: end; gap: 12px; margin-bottom: 14px; }
.task-add { grid-template-columns: minmax(0, 1fr) auto auto auto; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.task-tools { grid-template-columns: minmax(0, 1fr) minmax(120px, 160px) auto; }
.task-tools .hint { align-self: end; padding-bottom: 8px; white-space: nowrap; }
.tasklist .task { padding: 10px 12px; }
.tasklist .task:hover { border-color: var(--faint); }
.tasklist .task[hidden] { display: none; }
.task .task-project { margin: 2px 6px; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; display: inline-block; text-decoration: none; }
.task .task-due { width: auto; min-width: 0; color: var(--muted); color-scheme: dark; }
.task.overdue .task-due { color: var(--bad); border-color: var(--bad); }
@media (max-width: 600px) {
  .task-add, .task-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-add > :first-child { grid-column: 1 / -1; }
  .task-add .btn { justify-content: center; grid-column: 1 / -1; }
  .tasklist .task[data-id] { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .tasklist .task[hidden] { display: none; }
  .task .title { grid-column: 2 / -1; }
  .task .task-due { grid-column: 1 / 3; width: 100%; }
  .task [data-act="del"] { grid-row: 3; grid-column: 3; justify-self: end; }
  .task [data-act="prio"] { grid-row: 2; grid-column: 3; }
}
.addrow { display: flex; gap: 8px; margin-bottom: 16px; }
.tasklist { display: flex; flex-direction: column; gap: 6px; }
.task { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.task .title { flex: 1; min-width: 0; }
.task .title input { background: transparent; border-color: transparent; padding: 4px 6px; }
.task .title input:focus { border-color: var(--accent); background: var(--bg); }
.task.done .title input { text-decoration: line-through; color: var(--faint); }
.st { border: 1px solid var(--border); border-radius: 99px; font-size: 12px; padding: 3px 10px; cursor: pointer; background: var(--raised); min-width: 62px; text-align: center; }
.st.todo { color: var(--muted); }
.st.doing { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); }
.st.done { color: var(--ok); }
.prio { width: auto !important; font-size: 12px; padding: 3px 6px !important; }
.prio.high { color: var(--bad); }

/* files */
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.flist { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.frow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.frow:last-child { border-bottom: 0; }
.frow:hover { background: var(--panel); }
.frow .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .fs { color: var(--faint); font-size: 12px; }
.viewer { margin-top: 14px; }
.jump-trigger { display: flex; justify-content: space-between; align-items: center; margin: 0 12px 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--muted); cursor: pointer; }
.jump-trigger kbd { font: 11px system-ui; border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }
.jump-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--panel); box-shadow: 0 18px 70px #0008; }
.jump-dialog::backdrop { background: #101114b8; }
.review-diff { width: min(1120px, calc(100vw - 24px)); height: min(760px, calc(100dvh - 24px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--panel); }
.review-diff::backdrop { background: #101114cc; }
.review-diff[open] { display: flex; flex-direction: column; }
.review-diff header { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.review-diff h2 { margin: 0; }
.file-review-body { display: grid; grid-template-columns: minmax(190px, 26%) minmax(0, 1fr); min-height: 0; flex: 1; }
.review-file-list { padding: 12px; overflow: auto; border-right: 1px solid var(--border); }
.review-file-buttons { display: grid; gap: 4px; margin-bottom: 12px; }
.review-file-count { margin: 0 0 7px; }
.review-file-select { display: none; }
.review-file-buttons button { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.review-file-buttons [aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
.review-diff .diff { margin: 0; padding: 14px; max-height: none; overflow: auto; }
@media (max-width: 650px) {
  .file-review-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .review-file-buttons, .review-file-count { display: none; }
  .review-file-select { display: block; }
  .review-file-list { max-height: 40dvh; border-right: 0; border-bottom: 1px solid var(--border); }
}
.jump-bar, .file-tools, .activity-tools { display: flex; align-items: center; gap: 10px; }
.jump-bar { padding: 14px; border-bottom: 1px solid var(--border); }
.jump-results { max-height: 48vh; overflow-y: auto; padding: 6px; }
.jump-results a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; color: var(--text); border-radius: 7px; }
.jump-results small, .run-info small, .run-row time { color: var(--muted); font-size: 12px; }
.jump-results a:hover, .jump-results a:focus-visible { background: var(--accent-soft); }
.activity-tools, .file-tools { margin-bottom: 14px; }
.activity-tools label { width: min(240px, 55%); min-width: 0; }
.file-tools select { width: auto; max-width: 45%; }
.file-tools input { min-width: 0; }
.flist button.frow { width: 100%; text-align: left; background: var(--panel); border: 0; border-bottom: 1px solid var(--border); color: var(--text); }
.flist button.frow:hover { background: var(--raised); }
.run-list { overflow: hidden; border-radius: 12px; }
.run-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(64px, auto); align-items: center; gap: 14px; padding: 12px 16px; background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.run-row + .run-row { border-top: 0; }
.run-row:hover { background: var(--raised); text-decoration: none; }
.run-info { display: grid; gap: 3px; min-width: 0; }
.run-info strong, .run-info small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.run-row time { text-align: right; }
.run-state { font-size: 12px; border-radius: 99px; padding: 2px 9px; background: var(--raised); }
.run-state[data-state=running] { color: var(--accent); background: var(--accent-soft); }
.run-state[data-state=error] { color: var(--bad); }
.run-state[data-state=done] { color: var(--ok); }
.run-state[data-state=awaiting], .run-state[data-state=interrupted] { color: var(--warn); }
.run-state[data-state=queued], .run-state[data-state=finalizing] { color: var(--warn); }
.jump-context { display: block; max-width: 100%; margin-top: 3px; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.jump-results > .jump-context { padding: 5px 12px; }
.overview-pulse { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.overview-pulse h2 { margin: 0; font-size: 16px; }
.overview-pulse .row > a { font-size: 12px; }
.pulse-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); color: var(--text); }
.pulse-row:first-of-type { margin-top: 10px; }
.pulse-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.pulse-row small { display: block; color: var(--muted); }
.pulse-row time { color: var(--muted); white-space: nowrap; font-size: 12px; }
.pulse-row .run-state { white-space: nowrap; }
.run-panels { display: grid; grid-template-columns: minmax(0, 2fr) minmax(190px, 1fr); gap: 20px; margin-top: 20px; }
.run-output > section + section { margin-top: 18px; }
.run-events { padding: 14px; align-self: start; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.run-panel-controls { display: none; }
@media (max-width: 680px) {
  .overview-pulse, .run-panels { grid-template-columns: minmax(0, 1fr); }
  .run-panel-controls { display: flex; gap: 6px; margin-top: 16px; }
  .run-panel-controls [aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
  .run-panels[data-panel=output] .run-events, .run-panels[data-panel=timeline] .run-output { display: none; }
}
.run-detail > section { margin-top: 24px; }
.run-detail h2 { margin: 0 0 10px; }
.run-detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin: 0 0 16px; }
.run-detail dt { color: var(--muted); font-size: 12px; }
.run-detail dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.run-error { padding: 10px 12px; border-left: 3px solid var(--bad); background: var(--panel); overflow-wrap: anywhere; }
.run-prompt { white-space: pre-wrap; overflow-wrap: anywhere; }
.run-timeline { margin: 0; padding: 0 0 0 22px; color: var(--muted); overflow-wrap: anywhere; }
.run-timeline li { padding: 4px 0; }
.policy-form { display: grid; gap: 12px; max-width: 520px; }
.policy-form p, .policy-form .field { margin: 0; }
.policy-form .btn { justify-self: start; }
[data-more][hidden] { display: none; }
@media (max-width: 540px) {
  .run-row { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; padding: 10px; }
  .run-info { grid-row: span 2; }
  .run-row time { grid-column: 2; }
  .run-state { justify-self: end; }
}
.viewer pre { background: #121316; border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 60vh; font-size: 13px; }
.viewer img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }

/* usage */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tscroll { overflow-x: auto; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.bars .col { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; border-radius: 3px 3px 0 0; overflow: hidden; }
.bars .col span { display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* settings */
.settings { max-width: 900px; }
.settings section { margin-bottom: 30px; }
.settings section > h2 { margin-bottom: 4px; }
.settings section > .hint { margin-bottom: 14px; }
.rule { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.rule .full { grid-column: 1 / -1; }
.rule .act { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
.cmd { background: #121316; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: 13px ui-monospace, Menlo, Consolas, monospace; overflow-x: auto; white-space: pre; margin: 6px 0; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: 100%; max-width: 520px; max-height: 90dvh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button.on { border-color: var(--text); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: 90vw; }
#toast.bad { border-color: var(--bad); }

/* login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login img { width: 48px; height: 48px; display: block; margin-bottom: 14px; }
.login h1 { margin-bottom: 4px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

/* ---------- mobile ---------- */
.only-mobile { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 82vw; max-width: 300px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex: none; padding-top: calc(8px + env(safe-area-inset-top)); }
  .topbar .ttl { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page { padding: 16px 14px 30px; }
  .phead { display: none; }
  .tabs { padding: 0 8px; }
  .chatwrap { grid-template-columns: 1fr; }
  .chatwrap.has-thread .threads { display: none; }
  .chatwrap:not(.has-thread) .convo { display: none; }
  .threads { border-right: 0; }
  .msgs { padding: 14px 12px 8px; }
  .msg.user .bubble { max-width: 92%; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer .controls { flex-wrap: nowrap; }
  .composer select { flex: 1 1 0; min-width: 0; max-width: none; }
  .composer .spacer { display: none; }
  .only-mobile { display: inline-flex; }
  .rule { grid-template-columns: 1fr; }
  .md pre .copy { opacity: 1; }
}

/* master */
.master-ask { margin-bottom: 26px; border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: linear-gradient(180deg, var(--accent-soft), var(--panel) 70%); }
.master-ask svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.master-ask .hint { margin-left: 6px; }
.overview-master.master-ask { padding: clamp(16px, 3vw, 26px); margin-bottom: 14px; border-radius: 16px; background: radial-gradient(ellipse at top left, var(--accent-soft), transparent 68%), var(--panel); }
.overview-master-label { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 650; margin-bottom: 12px; }
.overview-master .row { flex-wrap: nowrap; }
.overview-master input { min-width: 0; }
.overview-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 32px; }
.overview-stats > * { display: flex; flex-direction: column; padding: 12px clamp(8px, 2vw, 18px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--muted); font-size: 13px; }
.overview-stats strong { color: var(--text); font-size: clamp(20px, 3vw, 28px); line-height: 1.15; font-variant-numeric: tabular-nums; }
.overview-stats a:hover { border-color: var(--accent); text-decoration: none; }
.overview-projects { display: grid; grid-template-columns: 1fr minmax(130px, 225px) auto; align-items: center; gap: 10px; margin-bottom: 12px; }
.overview-projects h2 { margin: 0; }
.overview-card.pcard { display: flex; flex-direction: column; gap: 10px; border-left-width: 1px; min-height: 112px; }
.overview-card.pcard:hover, .overview-card.pcard:focus-visible { border-color: var(--pc, var(--accent)); }
.overview-card .t > :nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.overview-card .project-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; color: var(--pc, var(--accent)); background: color-mix(in srgb, currentColor 13%, var(--panel)); border-radius: 9px; }
.project-mark svg { width: 17px; height: 17px; }
.overview-card .d { margin: 0; min-height: 0; }
.overview-card .m { margin-top: auto; column-gap: 12px; color: var(--muted); font-size: 12px; }
.overview-models { margin-top: 24px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.overview-models summary { cursor: pointer; font-weight: 600; }
.overview-models .provgrid { margin: 12px 0 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.thread-search { margin-bottom: 8px; }
.threads a[hidden] { display: none; }
.thread-empty:not([hidden]) { padding: 8px; }
@media (max-width: 540px) {
  .overview-projects { grid-template-columns: minmax(0, 1fr) auto; }
  .overview-projects h2 { grid-column: 1 / -1; }
  .overview-stats { gap: 6px; }
}
.children { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.child { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--panel); color: var(--text); font-size: 13px; text-decoration: none !important; }
.child:hover { background: var(--raised); }
.child .hint { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.nav-master { color: var(--accent) !important; font-weight: 600; }
.phead svg { width: 20px; height: 20px; }
@media (max-width: 860px) { .master-ask .hint { display: none; } }

/* attachments, schedules */
.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.attachments:empty { display: none; }
.attachments .chip { display: inline-flex; align-items: center; gap: 6px; background: var(--raised); border: 1px solid var(--border); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 13px; margin-top: 4px; }
.attachments .chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; }
.daychip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 13px; cursor: pointer; }
.daychip:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.daychip input { display: none; }
.job { flex-wrap: wrap; }
@media (max-width: 860px) {
  .job .grow { flex: 1 1 calc(100% - 40px); }
  .job { row-gap: 8px; }
}

/* memory */
.memory { max-width: 900px; }
.memview { padding: 18px 22px; }
.memview h3 { font-size: 18px; margin-top: 4px; }
.memview h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 18px 0 6px; }
.memedit { width: 100%; min-height: 60vh; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.memold { background: #121316; border: 1px solid var(--border); border-radius: 8px; padding: 12px; max-height: 50vh; overflow: auto; font-size: 12px; white-space: pre-wrap; }

/* browser */
.browser { max-width: 1100px; }
.bbar { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.bbar input { flex: 1; min-width: 160px; }
.bstatus { margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bscreen { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #0f1012; margin-bottom: 8px; min-height: 200px; }
.bscreen img { display: block; width: 100%; height: auto; cursor: pointer; }

/* changes, diff */
.changes { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.modal.wide { max-width: 1000px; }
pre.diff { background: #121316; border: 1px solid var(--border); border-radius: 8px; padding: 12px; max-height: 70dvh; overflow: auto; font-size: 12px; line-height: 1.45; }
pre.diff .add { color: #7fd48f; } pre.diff .del { color: #ef8a87; }
