:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --ink: #1d1b18;
  --muted: #8a8580;
  --line: #ece9e4;
  --accent: #d97757;
  --green: #3a9d52;
  --user-bub: #efe9e2;
  --subtle: #f3f0eb;
  --subtle-2: #f1eee9;
  --code-bg: #efece7;
  --pre-bg: #f3f0eb;
  --pre-line: #e7e3dd;
  --shadow: rgba(40,30,20,.16);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --app-h: 100dvh;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #101214;
  --card: #191c20;
  --ink: #f2f0ea;
  --muted: #a0a6ad;
  --line: #2b3036;
  --accent: #ee8b66;
  --green: #58c777;
  --user-bub: #263241;
  --subtle: #20242a;
  --subtle-2: #242932;
  --code-bg: #272c33;
  --pre-bg: #15181c;
  --pre-line: #303640;
  --shadow: rgba(0,0,0,.38);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%; overflow-x: hidden;
}
body { position: fixed; inset: 0; overflow: hidden; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: #c0392b; font-size: 14px; min-height: 18px; }
.notice { color: #8a8f98; font-size: 12.5px; font-style: italic; margin: 2px 0; }
.blocked { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 11px 13px; margin: 6px 0; }
.blocked .blockedMsg { font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.blocked .takeover { margin-top: 9px; padding: 8px 16px; font-size: 14px; font-weight: 600; background: var(--accent); color: #fff; border-radius: 11px; }

.screen { height: var(--app-h); display: flex; flex-direction: column; }
.center { align-items: center; justify-content: center; gap: 14px; padding: 0 28px; text-align: center; }

button { font: inherit; cursor: pointer; border: none; background: none; color: var(--ink); }
input, textarea { font: inherit; }

/* login */
.logo { width: 88px; height: 88px; border-radius: 21px; box-shadow: 0 6px 20px rgba(180,120,90,.25); }
h1 { margin: 0; font-size: 26px; font-weight: 700; }
#tokenInput { width: 100%; max-width: 340px; padding: 14px 16px; font-size: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); outline: none; }
.primary { width: 100%; max-width: 340px; padding: 14px; font-size: 16px; font-weight: 600; background: var(--accent); color: #fff; border-radius: 14px; }

/* top bar */
.bar {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  padding-top: calc(8px + var(--safe-t)); border-bottom: 1px solid var(--line);
  background: var(--bg); flex: none;
}
.bar strong { font-size: 17px; font-weight: 700; }
.ctitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62vw; font-size: 16px; }
.ghost { padding: 6px 10px; font-size: 19px; border-radius: 10px; color: var(--ink); }

/* sessions list */
/* sessions header + compose */
.sbar .apptitle { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.ver { font-size: 11px; color: var(--muted); margin-left: 7px; align-self: flex-end; padding-bottom: 4px; }
.compose { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 10px rgba(200,110,80,.4); flex: none; }
.compose svg { width: 22px; height: 22px; }

/* status filter tabs */
.tabs { display: flex; gap: 8px; padding: 12px 14px 6px; overflow-x: auto; flex: none; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 550; color: var(--ink); }
.tab.on { background: #2a2722; color: #fff; border-color: #2a2722; }
.tab .tcount { font-size: 12px; opacity: .6; font-weight: 600; }
.tab.on .tcount { opacity: .7; }
.subtabs { padding-top: 0; padding-bottom: 8px; }
.subtabs .tab { padding: 6px 12px; font-size: 13px; font-weight: 500; background: transparent; }
.subtabs .tab.on { background: #efe9df; color: #2a2722; border-color: #d8cfc0; }
.pipeCard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 10px 14px; overflow: hidden; }
.pipeHead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.pipeTitle { font-weight: 650; font-size: 15px; }
.pipeMeta { font-size: 12px; color: var(--muted); }
.pipeEmpty { padding: 0 14px 14px; color: var(--muted); font-size: 13px; }
.pipeRow { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--line); }
.pipeRowMain { flex: 1; min-width: 0; }
.pipeRowTitle { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipeRowSub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.pipeFlag { flex: none; font-size: 11px; font-weight: 600; color: #7a6a4a; background: #f0e9dc; border-radius: 10px; padding: 2px 8px; }
.hdot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #9aa0a6; }
.hdot.ok { background: #2ea043; } .hdot.warn { background: #d4a017; } .hdot.fail { background: #e5484d; }
.pipeRow.tap { cursor: pointer; }
.pipeRow.tap:active { background: #efe9df; }
.pipeRow.tap .pipeRowMain::after { content: '›'; float: right; color: #c3b9a8; font-size: 18px; line-height: 1; margin-left: 8px; }
.pipeDoc { padding: 4px 16px 24px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.pipeDoc h1, .pipeDoc h2, .pipeDoc h3 { font-size: 16px; margin: 14px 0 6px; }
.pipeDoc pre { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-x: auto; font-size: 12px; }
.pipeDoc code { background: var(--card); padding: 1px 4px; border-radius: 4px; }

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 14px 40px; }
.grouphd { font-size: 13px; color: var(--muted); font-weight: 500; margin: 16px 4px 8px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; font-size: 14px; }

.sCard { background: var(--card); border-radius: 18px; padding: 14px 15px; margin-bottom: 11px; box-shadow: 0 1px 3px rgba(40,30,20,.05), 0 6px 18px rgba(40,30,20,.04); }
.sCard:active { transform: scale(.992); }
.sCard .srow { display: flex; align-items: center; gap: 12px; }
.savatar { width: 42px; height: 42px; border-radius: 12px; background: var(--subtle-2); display: grid; place-items: center; flex: none; }
.savatar.idle, .savatar.archived { border: 1.5px dashed #cfc8bf; background: transparent; }
.sCard .conn.archived { color: var(--muted); }
.savatar .sdot { width: 11px; height: 11px; border-radius: 50%; }
.savatar.live .sdot { background: var(--green); }
.savatar.active .sdot { background: #e0a23c; }
.savatar.needs_input .sdot { background: var(--accent); }
.savatar.working { position: relative; }
.savatar.working .sdot { display: none; }
.savatar.working::after { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid #e4ddd2; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sCard .hd { flex: 1; min-width: 0; }
.sCard .nmrow { display: flex; align-items: baseline; gap: 8px; }
.sCard .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sCard .time { font-size: 12.5px; color: var(--muted); flex: none; }
.sCard .sl { display: flex; align-items: center; margin-top: 3px; font-size: 12.5px; color: var(--muted); overflow: hidden; }
.sCard .conn { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.sCard .conn svg { width: 14px; height: 14px; }
.sCard .conn.live, .sCard .conn.working { color: var(--green); }
.sCard .conn.active { color: #b07d1e; }
.sCard .conn.needs_input { color: var(--accent); font-weight: 600; }
.sCard .cwd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sCard .preview { margin-top: 11px; background: var(--subtle); border-radius: 11px; padding: 11px 13px; font-size: 14px; line-height: 1.4; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* messages */
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 100%; min-width: 0; overflow: hidden; flex: 0 0 auto; }
.msg .body { overflow-wrap: anywhere; }
.toolchip { max-width: 100%; box-sizing: border-box; }
.toolchip .tdot, .toolchip .tn, .toolchip .tgo { flex: none; }
.toolchip .ti { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg .body pre, .bashout { max-width: 100%; }
.msg.user { align-self: flex-end; max-width: 84%; background: var(--user-bub); border-radius: 16px 16px 5px 16px; padding: 10px 13px; }
.msg.user .body { font-size: 15.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .umgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.msg.user .umgs img { width: 130px; max-width: 58vw; max-height: 200px; object-fit: cover; border-radius: 11px; display: block; }
.qchip .qthumbs { display: flex; gap: 5px; flex: none; }
.qchip .qthumbs img { width: 32px; height: 32px; border-radius: 7px; object-fit: cover; }
/* scroll-to-latest */
.tobottom { position: absolute; right: 14px; bottom: 100%; margin-bottom: 10px; width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); box-shadow: 0 4px 14px var(--shadow); display: grid; place-items: center; color: var(--ink); z-index: 6; }
.tobottom svg { width: 20px; height: 20px; }
.msg.assistant .body {
  font-family: Georgia, "Times New Roman", ui-serif, serif; font-size: 17px; line-height: 1.55; color: var(--ink);
  word-wrap: break-word;
}
.msg.assistant .body p { margin: 0 0 10px; }
.msg.assistant .body h1,.msg.assistant .body h2,.msg.assistant .body h3 { font-family: -apple-system, "Inter", system-ui, sans-serif; line-height: 1.3; margin: 14px 0 8px; }
.msg.assistant .body h1 { font-size: 20px; } .msg.assistant .body h2 { font-size: 18px; } .msg.assistant .body h3 { font-size: 16px; }
.msg .body ul, .msg .body ol { margin: 0 0 10px; padding-left: 22px; }
.msg .body li { margin: 0 0 4px; }
.msg .body code { font-family: ui-monospace, Menlo, monospace; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
.msg .body pre { background: var(--pre-bg); border: 1px solid var(--pre-line); border-radius: 10px; padding: 11px 13px; overflow-x: auto; margin: 0 0 10px; }
.msg .body pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.msg .body a { color: var(--accent); }
.thinking { color: var(--muted); font-style: italic; font-size: 14px; margin-bottom: 6px; white-space: pre-wrap; }
.toolchip { display: inline-flex; align-items: center; gap: 6px; background: var(--subtle-2); border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px; font-size: 12.5px; color: var(--muted); margin: 2px 0; font-family: -apple-system, "Inter", system-ui, sans-serif; }
.toolchip .tn { font-weight: 600; color: var(--ink); }
.bashout { background: #14110e; color: #d8d2c8; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.45; padding: 11px 13px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; overflow-x: auto; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* composer */
.composer { flex: none; border-top: 1px solid var(--line); background: var(--bg); padding: 8px 10px calc(8px + var(--safe-b)); position: relative; }
.queueArea { display: flex; flex-direction: column; gap: 6px; padding: 2px 2px 8px; }
.qchip { display: flex; align-items: center; gap: 8px; background: var(--subtle-2); border: 1px solid var(--line); border-radius: 13px; padding: 9px 12px; }
.qchip .qt { flex: 1; min-width: 0; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qchip .qmode { font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; flex: none; }
.qchip .qx { color: var(--muted); padding: 2px 4px; flex: none; }
.qchip.running { opacity: .6; }
.attachRow { display: flex; gap: 8px; padding: 4px 2px 8px; overflow-x: auto; }
.attachRow .thumb { position: relative; flex: none; }
.attachRow img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.attachRow .x { position: absolute; top: -6px; right: -6px; background: #1a1a1a; color: #fff; width: 19px; height: 19px; border-radius: 50%; font-size: 12px; display: grid; place-items: center; }
.inputWrap { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 8px 10px 6px; }
#input { width: 100%; border: none; outline: none; resize: none; background: none; font-size: 16px; line-height: 1.4; max-height: 38vh; padding: 2px 4px; color: var(--ink); }
.toolsRow { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
	.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--subtle-2); border-radius: 16px; padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--ink); }
	.chip svg { width: 15px; height: 15px; }
	.chip.small { padding: 5px 10px; font-size: 12px; }
	.chip.bash { background: #14110e; color: #e9c08a; }
	.chip.agent { padding-inline: 11px; }
	#agentDot { width: 8px; height: 8px; border-radius: 50%; background: #8d7b68; }
	.chip.agent.codex #agentDot { background: #1f6feb; }
	.chip.agent.codex { background: #e7f0fb; color: #1f4f9c; }
	.agentTag { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; border-radius: 8px; padding: 1px 6px; background: #efe9df; color: #7a6a4a; }
	.agentTag.codex { background: #e7f0fb; color: #1f6feb; }
	.agentTag.fork { background: #edf7ef; color: #2f7d4d; }
	.iconbtn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--subtle-2); color: var(--ink); flex: none; }
.iconbtn svg { width: 21px; height: 21px; }
.iconbtn.ghost { background: none; color: var(--ink); }
.iconbtn.send { background: var(--accent); color: #fff; }
.iconbtn.send svg { width: 20px; height: 20px; }
.iconbtn.send:disabled { opacity: .35; }
.iconbtn.send.stop { background: #1d1b18; }
.stopbtn { background: #1d1b18; color: #fff; }
.stopbtn svg { width: 17px; height: 17px; }
.iconbtn:active { filter: brightness(.93); }

/* recorder */
.recorder { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 7px 10px; margin-top: 8px; }
.recdot { width: 10px; height: 10px; border-radius: 50%; background: #e0392b; flex: none; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.recText { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recTime { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); min-width: 38px; text-align: right; }

/* suggestion popover (@ and /) */
.suggest { position: absolute; left: 8px; right: 8px; bottom: 100%; margin-bottom: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 34px var(--shadow); max-height: min(46vh, calc(var(--app-h) - 180px)); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; z-index: 8; padding: 5px; }
.suggest .si { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 11px; cursor: pointer; }
.suggest .si:active { background: #f3f0eb; }
.suggest .si .ic { width: 22px; text-align: center; color: var(--accent); font-size: 15px; }
.suggest .si .ic svg { width: 18px; height: 18px; }
.suggest .si .t { flex: 1; min-width: 0; }
.suggest .si .nm { font-size: 15px; font-weight: 500; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #2f6fdb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .si .ds { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.suggest .si.file .nm { font-family: inherit; color: var(--ink); font-weight: 450; }

/* sheets */
.sheet { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h); max-height: var(--app-h); overflow: hidden; background: rgba(0,0,0,.35); z-index: 30; display: flex; align-items: flex-end; }
.sheetInner { width: 100%; background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 0 calc(10px + var(--safe-b)); max-height: calc(var(--app-h) - 12px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.sheetInner h3 { text-align: center; font-size: 15px; margin: 12px 0; color: var(--muted); font-weight: 600; }
.sheetRow { display: flex; align-items: center; gap: 14px; padding: 15px 22px; font-size: 16px; }
.sheetRow .ic { font-size: 20px; width: 26px; text-align: center; }
.sheetRow.sel { color: var(--accent); font-weight: 600; }
.sheetRow + .sheetRow { border-top: 1px solid var(--line); }
.sheetInput { width: calc(100% - 44px); margin: 6px 22px 12px; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); outline: none; }

/* in-flight loading indicator */
.loading { display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; }
.loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .35; animation: bounce 1.2s infinite; }
.loading span:nth-child(2) { animation-delay: .2s; } .loading span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.stoppedTag { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 4px; }

/* file explorer */
.explorer { position: fixed; inset: 0; z-index: 25; background: var(--bg); display: flex; flex-direction: column; }
.reader { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; padding-top: calc(var(--safe-t)); }
.readerBar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.readerBar strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#readerBody { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0; padding: 0; font-size: 13px; line-height: 1.55; }
#readerBody.astext { white-space: pre-wrap; word-break: break-word; padding: 14px; font-family: ui-monospace, Menlo, monospace; }
#readerBody pre.hl { margin: 0; }
#readerBody pre.hl code { display: block; padding: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
#readerBody .mdview { padding: 16px 16px 44px; font-family: -apple-system, "Inter", system-ui, sans-serif; font-size: 15px; line-height: 1.6; color: var(--ink); }
#readerBody .mdview h1, #readerBody .mdview h2, #readerBody .mdview h3 { line-height: 1.3; margin: 18px 0 8px; }
#readerBody .mdview h1 { font-size: 22px; } #readerBody .mdview h2 { font-size: 19px; } #readerBody .mdview h3 { font-size: 16px; }
#readerBody .mdview p { margin: 0 0 11px; }
#readerBody .mdview ul, #readerBody .mdview ol { margin: 0 0 11px; padding-left: 22px; }
#readerBody .mdview li { margin: 0 0 4px; }
#readerBody .mdview code { font-family: ui-monospace, Menlo, monospace; background: #efece7; padding: 1px 5px; border-radius: 5px; font-size: .88em; }
#readerBody .mdview pre { background: #f3f0eb; border: 1px solid #e7e3dd; border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
#readerBody .mdview pre code { background: none; padding: 0; }
#readerBody .mdview a { color: var(--accent); }
.htmlbar { display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.htmltab { padding: 6px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: #4a463f; }
.htmltab.on { background: #2a2722; color: #fff; border-color: #2a2722; }
.htmlframe { width: 100%; height: calc(var(--app-h) - 160px); border: 0; background: #fff; display: block; }
.detailimg { max-height: 50vh; width: auto; margin: 0 18px 12px; }
.mediaimg { max-width: 100%; height: auto; border-radius: 10px; display: block; }
.mediael { width: 100%; margin-top: 6px; }

/* clickable tool chips + detail sheet */
.toolchip.clickable { cursor: pointer; min-width: 0; }
.toolchip .ti { color: #7c766c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolchip .tgo { margin-left: auto; color: var(--muted); font-weight: 700; padding-left: 6px; }
.codeblk { background: #14110e; color: #e3ddd2; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.45; padding: 12px 13px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0 18px 12px; }
.codeblk.out { background: #f3f0eb; color: #2f2b26; }
.diff { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.5; margin: 0 18px 12px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.diff .del { background: #fbe9e7; color: #b3261e; padding: 1px 10px; white-space: pre-wrap; word-break: break-word; }
.diff .add { background: #e7f3ea; color: #1e7a36; padding: 1px 10px; white-space: pre-wrap; word-break: break-word; }
.openfile { display: flex; align-items: center; gap: 8px; margin: 6px 18px 12px; padding: 12px 14px; background: #f1eee9; border-radius: 11px; font-size: 14px; font-weight: 600; color: var(--accent); width: calc(100% - 36px); }
.openfile svg { width: 18px; height: 18px; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.row .ic { width: 22px; display: grid; place-items: center; color: var(--muted); }
.row .ic svg { width: 19px; height: 19px; }
.row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.row .at { color: var(--accent); padding: 6px; }

.toast { position: fixed; bottom: calc(96px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: #1a1a1a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 90; max-width: 86%; text-align: center; }

/* image lightbox / gallery */
.lightbox { position: fixed; inset: 0; z-index: 80; background: #000; }
.lbTrack { display: flex; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.lbTrack::-webkit-scrollbar { display: none; }
.lbTrack.nozoom { scroll-snap-type: none; overflow: hidden; }
.lbSlide { flex: 0 0 100%; width: 100vw; height: 100%; scroll-snap-align: center; display: grid; place-items: center; overflow: hidden; }
.lbSlide img { max-width: 100vw; max-height: 100dvh; object-fit: contain; user-select: none; -webkit-user-drag: none; will-change: transform; transition: transform .15s ease; }
.lbSlide img.panning { transition: none; }
.lbClose { position: fixed; top: calc(10px + var(--safe-t)); right: 14px; width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; z-index: 2; }
.lbClose svg { width: 20px; height: 20px; }
.lbCount { position: fixed; top: calc(16px + var(--safe-t)); left: 50%; transform: translateX(-50%); color: #fff; font-size: 14px; font-weight: 600; z-index: 2; text-shadow: 0 1px 5px rgba(0,0,0,.6); }
.msg .umgs img, .msg.user .umgs img { cursor: zoom-in; }
.pipeFlag.dec-filed { color: #1a7f37; background: #e6f4ea; }
.pipeFlag.dec-distilled { color: #7a6a4a; background: #f0e9dc; }
.pipeFlag.dec-skip { color: #8a8278; background: #efeae1; }
.linearBar { flex: none; background: #fff7f3; border-bottom: 1px solid #f0d9cf; padding: 10px 14px; }
.lbTop { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lbId { font-weight: 700; color: var(--accent); text-decoration: none; }
.lbTitle { flex-basis: 100%; font-size: 13px; color: #56514a; margin-top: 2px; }
.lbState { font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 8px; background: #efe9df; color: #7a6a4a; text-transform: capitalize; }
.lbState.completed, .lbState.merged { background: #e6f4ea; color: #1a7f37; }
.lbState.open, .lbState.started { background: #e7f0fb; color: #1f6feb; }
.lbPr { font-size: 12px; margin-top: 4px; } .lbPr.muted { color: var(--muted); }
.lbLoad { font-size: 13px; color: var(--muted); }
.lbActions { display: flex; gap: 8px; margin-top: 8px; }
.lbBtn { font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.lbBtn.merge { background: #1a7f37; color: #fff; border-color: #1a7f37; }
.lbBtn.done { background: #2a2722; color: #fff; border-color: #2a2722; }

html[data-theme="dark"] .tab.on,
html[data-theme="dark"] .htmltab.on { background: #edf0f3; color: #111316; border-color: #edf0f3; }
html[data-theme="dark"] .subtabs .tab.on,
html[data-theme="dark"] .pipeRow.tap:active,
html[data-theme="dark"] .suggest .si:active { background: var(--subtle-2); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .sCard { box-shadow: none; border: 1px solid var(--line); }
html[data-theme="dark"] .pipeFlag,
html[data-theme="dark"] .pipeFlag.dec-distilled,
html[data-theme="dark"] .pipeFlag.dec-skip,
html[data-theme="dark"] .agentTag { background: #322a21; color: #e4c28c; }
html[data-theme="dark"] .agentTag.codex,
html[data-theme="dark"] .chip.agent.codex,
html[data-theme="dark"] .lbState.open,
html[data-theme="dark"] .lbState.started { background: #18304c; color: #8dbdff; }
html[data-theme="dark"] .agentTag.fork,
html[data-theme="dark"] .pipeFlag.dec-filed,
html[data-theme="dark"] .lbState.completed,
html[data-theme="dark"] .lbState.merged { background: #17351f; color: #82d993; }
html[data-theme="dark"] .savatar.idle,
html[data-theme="dark"] .savatar.archived { border-color: #49515b; }
html[data-theme="dark"] .savatar.working::after { border-color: #3a414b; border-top-color: var(--accent); }
html[data-theme="dark"] .suggest .si .nm { color: #8dbdff; }
html[data-theme="dark"] .htmltab { color: var(--ink); }
html[data-theme="dark"] .htmlframe { background: #fff; }
html[data-theme="dark"] #readerBody .mdview code,
html[data-theme="dark"] .codeblk.out,
html[data-theme="dark"] .openfile { background: var(--code-bg); color: var(--ink); }
html[data-theme="dark"] #readerBody .mdview pre { background: var(--pre-bg); border-color: var(--pre-line); }
html[data-theme="dark"] .diff .del { background: #431f1f; color: #ffb1aa; }
html[data-theme="dark"] .diff .add { background: #17351f; color: #93e0a1; }
html[data-theme="dark"] .linearBar { background: #241d1a; border-bottom-color: #3b302b; }
html[data-theme="dark"] .lbTitle { color: var(--muted); }
html[data-theme="dark"] .lbState { background: var(--subtle-2); color: var(--muted); }
.lbBtn:disabled { opacity: .5; }
