/* 熔爐 Fuse：A 版面（三欄指揮台）。配色是「爐火」深色系，色票集中在 :root */
:root {
  color-scheme: dark;
  --bg: #17120f; --panel: #201914; --panel2: #2a211b; --panel3: #33281f; --line: #3d3129;
  --text: #f1e7dc; --dim: #b4a395; --faint: #75675d;
  --fire: #ff8a2a; --fire2: #ffc266; --ok: #6cc28a; --warn: #f0c04a; --bad: #e0675a;
  --claude: #d9895b; --codex: #8fb3ff; --agy: #7fd0c0;
  --user-bubble: #3a2a1f; --card: #2b1d12;
  --mono: Consolas, "Cascadia Mono", monospace;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow: hidden;
       font: 14px/1.55 "Microsoft JhengHei UI", "Noto Sans TC", system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
.hidden { display: none !important; }

#app { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; height: 100vh; }
#app.no-panel { grid-template-columns: 250px minmax(0, 1fr) 0; }
#app.no-panel #panel { display: none; }

/* ---------- 共用小元件 ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.running { background: var(--fire); box-shadow: 0 0 6px var(--fire); animation: glow 1.6s ease-in-out infinite; }
.dot.waiting { background: var(--warn); animation: glow 1s ease-in-out infinite; }
.dot.stuck { background: var(--warn); }
.dot.error { background: var(--bad); }
.dot.idle { background: var(--faint); }
@keyframes glow { 50% { opacity: .45; } }
.badge { font-size: 10.5px; padding: 0 7px; border-radius: 999px; border: 1px solid currentColor; flex: none; white-space: nowrap; line-height: 17px; }
.p-claude { color: var(--claude); } .p-codex { color: var(--codex); } .p-agy { color: var(--agy); }
.tag { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 3px 11px; }
.btn:hover { border-color: var(--dim); }
.btn.pri { border-color: var(--fire); color: var(--fire2); }
.btn.danger { border-color: var(--bad); color: #ffb3a8; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--dim); padding: 1px 6px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.icon-btn:hover { color: var(--text); border-color: var(--line); }
.ico-wrap { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 1; }
.ico { display: block; flex: none; }
.ico-fire { color: var(--fire); }
.newchat, .stopbtn, .clipbtn, .card .ct, .m-wrap .wtitle, .m-wrap .wreply, .resolved, .proj-head .name, .msg-acts button, .chip { display: inline-flex; align-items: center; gap: 5px; }
.newchat { display: flex; }
.proj-head .name { display: flex; gap: 4px; }
.card .ct { display: flex; gap: 6px; }
.resolved { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- 左欄：專案與串 ---------- */
#side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: bold; letter-spacing: .04em; }
.brand img { width: 22px; height: 22px; }
.brand .sp { flex: 1; }
.newchat { width: 100%; text-align: left; padding: 6px 10px; border-radius: 8px; color: var(--fire2); }
.newchat:hover { border-color: var(--fire); }
.search { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; outline: none; }
.search:focus { border-color: var(--fire); }
#tree { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.proj { margin-top: 10px; }
.proj-head { display: flex; align-items: center; gap: 4px; padding: 2px 4px; color: var(--faint); font-size: 11.5px; letter-spacing: .06em; }
.proj-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.proj-head .icon-btn { opacity: 0; }
.proj-head:hover .icon-btn { opacity: 1; }
.thread { display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 8px; color: var(--dim); cursor: pointer; min-width: 0; }
.thread:hover { background: var(--panel2); }
.thread.cur { background: var(--panel3); color: var(--text); }
.thread .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread.child { margin-left: 16px; }
.thread.child::before { content: "└"; color: var(--faint); margin-right: -3px; }
.empty-hint { color: var(--faint); padding: 8px; font-size: 12px; }
.result { padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.result:hover { background: var(--panel2); }
.result .rt { color: var(--dim); font-size: 11.5px; }
.result .snip { color: var(--text); font-size: 12.5px; }
.result mark { background: transparent; color: var(--fire2); }
.side-foot { border-top: 1px solid var(--line); padding: 8px 12px; display: flex; gap: 6px; align-items: center; color: var(--faint); font-size: 11.5px; }
.side-foot .sp { flex: 1; }

/* ---------- 中欄：主對話 ---------- */
#chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chathead { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); min-height: 46px; }
.chathead .title { font-weight: bold; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.chathead .meta { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; display: flex; gap: 10px; align-items: center; }
#msgs { flex: 1; overflow-y: auto; padding: 16px max(22px, calc((100% - 860px) / 2)) 24px; display: flex; flex-direction: column; gap: 10px; }
.welcome { margin: auto; text-align: center; color: var(--dim); max-width: 420px; }
.welcome h2 { color: var(--text); margin: 8px 0; }
.welcome img { width: 72px; height: 72px; opacity: .9; }

.m-user { align-self: flex-end; max-width: 75%; background: var(--user-bubble); padding: 8px 12px; border: 1px solid #4a3627; border-radius: 12px 12px 3px 12px; white-space: pre-wrap; word-break: break-word; }
.m-user .ut { display: block; font-size: 10.5px; color: var(--fire2); margin-bottom: 2px; }
.m-user.pending { opacity: .7; }
.m-asst { max-width: 100%; word-break: break-word; }
/* 訊息旁的動作（滑過去才出現）：編輯、回到這裡、重生、分叉 */
.m-user, .m-asst { position: relative; }
.msg-acts { position: absolute; top: -13px; right: 6px; display: none; gap: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 1px 3px; box-shadow: 0 3px 10px #0007; z-index: 2; }
.m-asst .msg-acts { right: auto; left: 0; }
.m-user:hover .msg-acts, .m-asst:hover .msg-acts { display: flex; }
.msg-acts button { background: transparent; border: 0; color: var(--dim); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.msg-acts button:hover { color: var(--fire2); background: var(--panel3); }
.m-asst.streaming .msg-acts { display: none; }
.m-asst.streaming::after { content: "▍"; color: var(--fire); animation: glow 1s infinite; }
.m-asst details.think { color: var(--faint); font-size: 12px; margin-bottom: 4px; }
.m-asst details.think summary { cursor: pointer; }
.m-asst details.think div { white-space: pre-wrap; border-left: 2px solid var(--line); padding-left: 8px; margin-top: 4px; }

.m-tool { border: 1px solid var(--line); background: #1d1612; border-radius: 7px; font-size: 12.5px; max-width: 100%; }
.m-tool.child { margin-left: 22px; border-left: 2px solid var(--panel3); }
.m-tool > .row { display: flex; gap: 8px; align-items: center; padding: 4px 10px; cursor: pointer; color: var(--dim); min-width: 0; }
.m-tool .tn { color: var(--text); font-family: var(--mono); flex: none; }
.m-tool .ts { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.m-tool .st { flex: none; }
.m-tool .st.done { color: var(--ok); } .m-tool .st.error { color: var(--bad); } .m-tool .st.running { color: var(--fire); }
.m-tool .body { display: none; border-top: 1px solid var(--line); padding: 8px 10px; }
.m-tool.open .body { display: block; }
.m-tool pre { margin: 0 0 6px; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12px; max-height: 320px; overflow: auto; color: #cdbfb2; }
.m-tool .lbl { color: var(--faint); font-size: 11px; margin: 4px 0 2px; }

.card { border: 1px solid var(--line); border-left: 3px solid var(--fire); background: var(--card); border-radius: var(--radius); padding: 10px 12px; max-width: 100%; }
.card .ct { color: var(--fire2); font-weight: bold; margin-bottom: 6px; }
.card .cs { font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; background: #0006; border-radius: 6px; padding: 6px 8px; max-height: 220px; overflow: auto; }
.card .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.card .q { margin-top: 8px; }
.card .q .qh { color: var(--text); margin-bottom: 4px; }
.card .opt { text-align: left; }
.card .opt small { display: block; color: var(--faint); font-size: 11px; }
.card .opt.sel { border-color: var(--fire); background: #ff8a2a22; }
.card .other { display: flex; gap: 6px; margin-top: 6px; }
.card .other input, .card textarea.reason { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; }
.card .plan { background: #0004; border-radius: 8px; padding: 8px 12px; max-height: 420px; overflow: auto; }
.resolved { color: var(--faint); font-size: 12px; padding-left: 4px; }
.resolved b { color: var(--dim); font-weight: normal; }

.m-sys { align-self: center; font-size: 12px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; max-width: 90%; text-align: center; }
.m-sys.warn { color: var(--warn); border-color: #f0c04a55; }
.m-sys.error { color: #ffb3a8; border-color: #e0675a77; border-radius: 10px; white-space: pre-wrap; text-align: left; }
.m-end-box { align-self: stretch; display: flex; flex-direction: column; gap: 6px; }
.m-end { align-self: stretch; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 11px; flex-wrap: nowrap; }
.m-end::before, .m-end::after { content: ""; flex: 1; min-width: 12px; border-top: 1px dashed var(--line); }
.m-end.err { color: var(--bad); }
.m-end.has-usage { cursor: pointer; }
.m-end.has-usage:hover { color: var(--dim); }
.m-end-in { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 6px; font-family: var(--mono); font-size: 11px; }
.m-end-chev { transition: transform .15s; opacity: .7; }
.m-end-box.open .m-end-chev { transform: rotate(180deg); opacity: 1; }
.tchip { padding: 0 6px; border-radius: 999px; font-size: 10.5px; border: 1px solid var(--line); background: var(--panel); }
.tchip.hit-ok { color: var(--ok); border-color: #6cc28a55; background: #6cc28a14; }
.tchip.hit-mid { color: var(--fire2); border-color: #ff8a2a44; background: #ff8a2a12; }
.tchip.hit-low { color: var(--warn); border-color: #f0c04a55; background: #f0c04a14; }
.tnum { color: var(--dim); }
.m-end-detail { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; flex-direction: column; gap: 8px; }
.m-end-box.open .m-end-detail { display: flex; }
.tbar-wrap { display: flex; flex-direction: column; gap: 4px; }
.tbar { height: 6px; background: var(--panel3); border-radius: 3px; overflow: hidden; display: flex; width: 100%; }
.tbar-hit { display: block; height: 100%; background: var(--ok); }
.tbar-write { display: block; height: 100%; background: var(--codex); }
.tbar-miss { display: block; height: 100%; background: var(--fire); }
.tbar-leg { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; font-family: var(--mono); color: var(--dim); }
.leg-hit { color: var(--ok); } .leg-write { color: var(--codex); } .leg-miss { color: var(--fire2); }
.tgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 6px 10px; }
.tgrid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
.tcell { background: var(--panel2); border: 1px solid #ffffff08; border-radius: 6px; padding: 5px 8px; display: flex; flex-direction: column; gap: 1px; }
.tcell .tl { font-size: 10.5px; color: var(--faint); }
.tcell .tv { font-family: var(--mono); font-size: 12.5px; color: var(--text); font-weight: 600; }
.tcell.c-hit .tv { color: var(--ok); }
.tcell.c-miss .tv { color: var(--fire2); }
.tcell.c-write .tv { color: var(--codex); }
.ctx-pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.ctx-pill:hover { border-color: var(--fire); color: var(--text); }
.ctx-pill.warn { color: var(--warn); border-color: #f0c04a55; }
.ctx-pill.hi { color: var(--bad); border-color: #e0675a66; }
.m-wrap { border: 1px solid var(--line); border-left: 3px solid var(--fire); background: var(--card); border-radius: var(--radius); padding: 11px 14px; max-width: 100%; display: flex; flex-direction: column; gap: 8px; }
.m-wrap.sending { opacity: .65; pointer-events: none; }
.m-wrap .wh { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.m-wrap .wh .sp { flex: 1; }
.m-wrap .wtitle { font-size: 12px; font-weight: bold; color: var(--fire2); letter-spacing: .04em; }
.m-wrap .wmode { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid #ff8a2a66; background: #ff8a2a1a; color: var(--fire2); }
.m-wrap .wtog { font-size: 11.5px; color: var(--dim); padding: 1px 7px; }
.m-wrap .wrecap { font-size: 13px; color: var(--dim); background: #00000028; border: 1px solid #ffffff0d; border-radius: 7px; padding: 7px 10px; }
.m-wrap .wrecap.collapsed { max-height: 3.3em; overflow: hidden; mask-image: linear-gradient(to bottom, #000 55%, transparent); -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent); }
.m-wrap .wq { color: var(--text); font-weight: 600; font-size: 14.5px; line-height: 1.5; }
.m-wrap .w-list { display: flex; flex-direction: column; gap: 6px; }
.m-wrap .w-row { display: flex; flex-wrap: wrap; gap: 6px; }
.m-wrap .wopt { display: flex; align-items: flex-start; gap: 10px; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; transition: border-color .12s, background .12s; width: 100%; }
.m-wrap .w-row .wopt { width: auto; flex: 0 1 auto; align-items: center; padding: 6px 10px; }
.m-wrap .wopt:hover { border-color: var(--fire); background: var(--panel3); }
.m-wrap .wopt.rec { border-color: #ff8a2a55; }
.m-wrap .wopt.sel { border-color: var(--fire); background: #ff8a2a1f; }
.m-wrap .wopt.ro { cursor: default; opacity: .78; }
.m-wrap .wopt.ro:hover { border-color: var(--line); background: var(--panel2); }
.m-wrap .widx { flex: none; min-width: 20px; height: 20px; border-radius: 5px; background: #00000038; border: 1px solid var(--line); color: var(--dim); font-family: var(--mono); font-size: 11.5px; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.m-wrap .wopt:hover .widx, .m-wrap .wopt.sel .widx { border-color: var(--fire); color: var(--fire2); background: #ff8a2a24; }
.m-wrap .wmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-wrap .wt { color: var(--text); font-weight: 500; line-height: 1.45; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.m-wrap .wd { color: var(--dim); font-size: 12.5px; line-height: 1.45; }
.m-wrap .wrec { font-size: 10px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--fire); color: var(--fire2); background: #ff8a2a1c; line-height: 16px; }
.m-wrap .wedit { flex: none; opacity: 0; font-size: 12px; padding: 2px 6px; align-self: center; }
.m-wrap .wopt:hover .wedit, .m-wrap .wopt:focus-within .wedit, .m-wrap .wopt.ro .wedit { opacity: .85; }
.m-wrap .wedit:hover { opacity: 1 !important; color: var(--fire2); border-color: var(--fire); }
.m-wrap .wother { display: flex; gap: 8px; align-items: center; margin-top: 2px; padding-top: 8px; border-top: 1px dashed var(--line); }
.m-wrap .wother .sp { flex: 1; }
.m-wrap .wother-in { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; font-size: 13px; outline: none; }
.m-wrap .wother-in:focus { border-color: var(--fire); }
.m-wrap .wother-in::placeholder { color: var(--faint); }
.m-wrap .wsend { flex: none; padding: 5px 12px; font-size: 13px; }
.m-wrap.done { border-left-color: var(--line); background: var(--panel); padding: 7px 12px; gap: 0; }
.m-wrap.done .wtitle { color: var(--dim); font-weight: normal; }
.m-wrap.done .wreply { color: var(--ok); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m-wrap.done .wdetail { display: none; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); flex-direction: column; gap: 8px; }
.m-wrap.done.expanded .wdetail { display: flex; }
.m-file { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.m-file img { max-width: 360px; max-height: 280px; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.m-file .fp { font-family: var(--mono); font-size: 12px; color: var(--dim); }

/* Markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; line-height: 1.3; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: 14.5px; } .md h4 { font-size: 13.5px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code { font-family: var(--mono); background: var(--panel2); border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
.md pre { background: #0f0b09; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; margin: 0 0 8px; position: relative; }
.md pre code { background: none; padding: 0; white-space: pre; }
.md pre .copy { position: absolute; top: 4px; right: 4px; opacity: 0; }
.md pre:hover .copy { opacity: 1; }
.md blockquote { margin: 0 0 8px; padding: 4px 12px; border-left: 3px solid var(--fire); background: var(--panel); border-radius: 0 8px 8px 0; color: var(--text); }
.md table { border-collapse: collapse; margin: 0 0 8px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--panel2); }
.md a { color: var(--fire2); text-decoration: none; border-bottom: 1px dotted var(--fire2); cursor: pointer; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* 輸入區 */
.composer { border-top: 1px solid var(--line); padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 7px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--dim); font-size: 12px; outline: none; max-width: 210px; }
.chip:hover { border-color: var(--dim); }
select.chip { appearance: none; padding-right: 8px; }
.chip.prov-claude { color: var(--claude); } .chip.prov-agy { color: var(--agy); } .chip.prov-codex { color: var(--codex); }
.chips .sp { flex: 1; }
.chips .hint { color: var(--faint); font-size: 11px; }
.inputrow { display: flex; gap: 8px; align-items: flex-end; }
#input { flex: 1; resize: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; outline: none; min-height: 42px; max-height: 240px; line-height: 1.5; }
#input:focus { border-color: var(--fire); }
.clipbtn { background: transparent; border: 1px solid var(--line); border-radius: var(--radius); height: 42px; width: 38px; color: var(--dim); font-size: 16px; }
.clipbtn:hover { border-color: var(--dim); color: var(--text); }
.composer.drop { outline: 2px dashed var(--fire); outline-offset: -4px; background: var(--panel2); }
.attachrow, .uatt { display: flex; gap: 6px; flex-wrap: wrap; }
.uatt { margin-top: 6px; }
.att { display: inline-flex; align-items: center; gap: 5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 4px 2px 6px; max-width: 240px; font-size: 12px; color: var(--dim); cursor: default; }
.uatt .att { cursor: pointer; }
.att img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.att .an { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .ax { background: transparent; border: 0; color: var(--faint); padding: 0 3px; font-size: 14px; }
.att .ax:hover { color: var(--bad); }
.uimg { max-width: 220px; max-height: 160px; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; object-fit: contain; background: var(--panel); }
.sendbtn, .stopbtn { border-radius: var(--radius); padding: 0 16px; height: 42px; border: 1px solid var(--line); }
.sendbtn { background: linear-gradient(180deg, #ff9a3c, #e8701a); color: #1b0f06; border: 0; font-weight: bold; }
.stopbtn { background: #3a1a16; border-color: var(--bad); color: #ffb3a8; }

/* ---------- 右欄：派工、額度、清單 ---------- */
#panel { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ptabs { display: flex; gap: 4px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.ptabs button { background: transparent; border: 0; padding: 3px 10px; border-radius: 6px; color: var(--dim); }
.ptabs button.on { background: var(--panel2); color: var(--text); }
.ptabs .cnt { color: var(--fire2); font-size: 11px; margin-left: 2px; }
#pbody { flex: 1; overflow-y: auto; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.sect { font-size: 11px; color: var(--faint); letter-spacing: .08em; margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.job { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; border-left: 3px solid var(--faint); }
.job:hover { border-color: var(--dim); }
.job.stuck, .job.waiting { border-color: #5a4a2a; border-left-color: var(--warn); }
.job.error { border-color: #5a2f2a; border-left-color: var(--bad); }
.job .row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.job b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: normal; color: var(--text); }
.job .time { margin-left: auto; color: var(--faint); font-size: 11px; white-space: nowrap; }
.job .last { color: var(--dim); font-size: 12px; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job .acts { display: flex; gap: 4px; }
.job .acts button { font-size: 11px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--dim); }
.job .acts button:hover { color: var(--text); border-color: var(--dim); }
.qhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qbtn { font-size: 11.5px; padding: 2px 9px; display: inline-flex; align-items: center; gap: 5px; color: var(--dim); }
.qbtn:hover { color: var(--fire2); border-color: var(--fire); }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }
.quota { display: flex; flex-direction: column; gap: 6px; }
.qcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; }
.qcard.hi { border-color: #e0675a66; }
.qcard .qtop { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.qcard .qname { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcard .qrem { font-family: var(--mono); font-size: 12.5px; font-weight: bold; flex: none; }
.qcard .qrem.ok { color: var(--ok); }
.qcard .qrem.warn { color: var(--warn); }
.qcard .qrem.hi { color: var(--bad); }
.qcard .qsub { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--faint); font-family: var(--mono); }
.qmeta { font-size: 11px; color: var(--faint); padding: 0 2px; line-height: 1.45; }
.bar { height: 6px; background: var(--panel3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar i.warn { background: var(--fire); }
.bar i.hi { background: var(--bad); }
.check { margin: 0; padding: 0; list-style: none; }
.check li { color: var(--dim); margin: 4px 0; padding-left: 20px; position: relative; }
.check li::before { content: "○"; position: absolute; left: 2px; color: var(--faint); }
.check li.completed { color: var(--faint); text-decoration: line-through; }
.check li.completed::before { content: "✓"; color: var(--ok); text-decoration: none; }
.check li.in_progress { color: var(--fire2); }
.check li.in_progress::before { content: "◉"; color: var(--fire); }

/* ---------- 對話框、提示 ---------- */
.modal-back { position: fixed; inset: 0; background: #0009; display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; width: min(460px, 92vw); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px #000a; }
.modal h3 { margin: 0 0 4px; font-size: 15px; }
.modal label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 12px; }
.modal input, .modal select, .modal textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; outline: none; }
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--fire); }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal .note { color: var(--faint); font-size: 11.5px; }
/* Claude 帳號清單 */
.acct-list { display: flex; flex-direction: column; gap: 6px; }
.acct { display: flex; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--faint); border-radius: 8px; padding: 7px 10px; }
.acct.on { border-left-color: var(--claude); }
.acct-main { flex: 1; min-width: 0; }
.acct-name { display: flex; gap: 6px; align-items: center; color: var(--text); }
.acct-sub { color: var(--faint); font-size: 11.5px; overflow-wrap: anywhere; }
.acct-sub.bad { color: var(--warn); }
.acct-acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.acct-acts .btn { padding: 1px 9px; font-size: 12px; }
.steps { margin: 0; padding-left: 20px; color: var(--dim); font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; }
.steps .btn { padding: 1px 10px; font-size: 12px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 60; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 12px; max-width: 360px; box-shadow: 0 4px 16px #0008; animation: rise .2s ease-out; }
.toast.warn { border-color: var(--warn); } .toast.error { border-color: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.lightbox { position: fixed; inset: 0; background: #000d; display: grid; place-items: center; z-index: 70; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 94vh; }

@media (max-width: 980px) {
  #app { grid-template-columns: 210px minmax(0, 1fr) 0; }
  #panel { display: none; }
}

/* ---------- 手機（iPhone 遠端）：單欄，左右欄改成抽屜 ---------- */
.mbar, #scrim { display: none; }
.remote-qr { align-self: center; background: #fff; padding: 8px; border-radius: 10px; width: 220px; height: 220px; }
.remote-qr svg { width: 100%; height: 100%; display: block; }
.remote-url { font-family: var(--mono); font-size: 11.5px; color: var(--dim); overflow-wrap: anywhere; user-select: all; }
.pairing { margin: auto; max-width: 320px; text-align: center; color: var(--dim); padding: 24px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.pairing img { width: 56px; height: 56px; }
@media (max-width: 760px) {
  body { font-size: 15px; }
  #app { grid-template-columns: minmax(0, 1fr); height: 100dvh; padding-top: env(safe-area-inset-top); }
  #app.no-panel { grid-template-columns: minmax(0, 1fr); }
  #side, #panel, #app.no-panel #panel { display: flex; position: fixed; top: 0; bottom: 0; z-index: 40; width: min(86vw, 340px);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); transition: transform .22s ease-out; }
  #side { left: 0; transform: translateX(-102%); }
  #panel { right: 0; transform: translateX(102%); }
  body.side-open #side, body.panel-open #panel { transform: none; box-shadow: 0 0 30px #000c; }
  body.side-open #scrim, body.panel-open #scrim { display: block; position: fixed; inset: 0; background: #0009; z-index: 35; }
  #btn-toggle-panel { display: none; }
  .mbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
  .mbar img { width: 20px; height: 20px; }
  .mbar .mtitle { font-weight: bold; letter-spacing: .04em; }
  .mbar .mconn { flex: 1; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mbar .icon-btn { padding: 6px; }
  .chathead { padding: 7px 12px; min-height: 40px; flex-wrap: wrap; row-gap: 4px; }
  .chathead .meta { margin-left: 0; flex-wrap: wrap; white-space: normal; }
  #msgs { padding: 12px 10px 18px; }
  .composer { padding: 7px 8px calc(9px + env(safe-area-inset-bottom)); }
  /* iOS 字小於 16px 會自動放大畫面 */
  #input, .search, .modal input, .modal select, .modal textarea, .m-wrap input { font-size: 16px; }
  /* 觸控沒有 hover：訊息按鈕、程式碼複製鈕直接顯示 */
  .m-user .msg-acts, .m-asst .msg-acts { display: flex; position: static; box-shadow: none; margin-top: 4px; width: fit-content; }
  .m-asst.streaming .msg-acts { display: none; }
  .md pre .copy, .proj-head .icon-btn, .m-wrap .wedit { opacity: .85; }
  #toasts { left: 10px; right: 10px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .modal { width: 94vw; max-height: 88dvh; overflow-y: auto; }
}
