:root {
  --bg: #262624;
  --bg2: #1f1e1d;
  --panel: #30302e;
  --line: #3e3d3a;
  --text: #ece9e3;
  --muted: #9c9a94;
  --dim: #6f6d68;
  --accent: #d97757;
  --accent2: #c4653f;
  --user: #3a3936;
  --code: #1a1a19;
  --green: #7fbf7f;
  --red: #e77d7d;
  --yellow: #e0b25c;
  --blue: #7aa7e0;
  --add-bg: rgba(87, 171, 90, .16);
  --del-bg: rgba(229, 83, 75, .16);
  --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --side-w: 290px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.grow { flex: 1; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- вход ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-size: 13px; color: var(--muted); display: block; margin: 8px 0 4px; }
.login-card input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-card #code { font: 22px var(--mono); letter-spacing: 6px; text-align: center; }
button.primary { width: 100%; margin-top: 12px; padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent2); }
button.primary:disabled { opacity: .6; }
button.link { background: none; border: 0; color: var(--muted); margin-top: 6px; text-decoration: underline; }
.login-msg { min-height: 20px; font-size: 14px; color: var(--muted); }
.login-msg.bad { color: var(--red); }

/* ---------- раскладка ---------- */
#app { display: flex; height: 100%; height: 100dvh; }
#side { width: var(--side-w); flex: none; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#scrim { display: none; }
.brand { font-weight: 600; font-size: 16px; display: flex; align-items: baseline; gap: 6px; padding: 4px 4px 10px; }
.brand.big { font-size: 22px; padding: 0 0 4px; }
.brand .star { color: var(--accent); }
.brand-sub { font-weight: 400; font-size: 12px; color: var(--dim); }
.side-top { padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.side-btn { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); text-align: left; }
.side-btn:hover { border-color: var(--accent); }
.side-search { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); outline: none; font-size: 13px; }
.side-search:focus { border-color: var(--accent); }
.projects { flex: 1; overflow-y: auto; padding: 4px 6px 12px; }
.proj { margin-bottom: 2px; }
.proj-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; user-select: none; }
.proj-head:hover { background: var(--panel); color: var(--text); }
.proj-head .caret { width: 10px; font-size: 10px; transition: transform .15s; }
.proj.open .proj-head .caret { transform: rotate(90deg); }
.proj-head .pname { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-head .branch { font: 11px var(--mono); color: var(--dim); }
.proj-head .add { margin-left: auto; opacity: 0; border: 0; background: none; color: var(--muted); padding: 0 4px; }
.proj-head:hover .add { opacity: 1; }
.sess-list { display: none; padding-left: 10px; }
.proj.open .sess-list { display: block; }
.sess { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.sess:hover { background: var(--panel); }
.sess.active { background: var(--user); }
.sess .stitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .stime { font-size: 11px; color: var(--dim); flex: none; }
.sess .sdot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: transparent; }
.sess .sdot.alive { background: var(--dim); }
.sess .sdot.busy { background: var(--accent); animation: pulse 1.2s infinite; }
.sess .sdot.pending { background: var(--yellow); animation: pulse .8s infinite; }
.sess .smenu { opacity: 0; border: 0; background: none; color: var(--muted); padding: 0 2px; }
.sess:hover .smenu { opacity: 1; }
.sess-empty { font-size: 12px; color: var(--dim); padding: 4px 8px; }
.dev-link { display: flex; align-items: center; gap: 6px; margin: 4px 10px 6px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); user-select: none; }
.dev-link:hover, .dev-link.active { background: var(--panel); }
.dev-link .dname { font-weight: 600; white-space: nowrap; }
.dev-link .dhost { font: 11px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-link .add { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 0 4px; cursor: pointer; }
.dev-link .ddot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.dev-link .ddot.on { background: #3fb950; }
.dev-link .ddot.off { background: #d29922; }
.dev-root { display: flex; align-items: center; gap: 8px; padding: 3px 0; font: 13px var(--mono); cursor: pointer; }
.compact-mark { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--muted); font-size: 12px; }
.compact-mark::before, .compact-mark::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.compact-wrap { margin: 0 auto 12px; }
.compact-sum { margin: 0; font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.compact-sum summary { cursor: pointer; user-select: none; }
.compact-sum[open] { color: var(--text); }
#input.suggest::placeholder { color: var(--muted); opacity: .8; font-style: italic; }
.ctx-bar { position: relative; height: 10px; margin: 8px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.ctx-fill { height: 100%; background: #3fb950; }
.ctx-fill.warn { background: #d29922; }
.ctx-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .6; }
.ctx-input { flex: 1; min-width: 200px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text); }
button.chip.ctx-go { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctx-cats { margin: 8px 0; font-size: 12px; border-collapse: collapse; }
.ctx-cats td { padding: 2px 14px 2px 0; }
.ctx-cats td:last-child { text-align: right; font-family: var(--mono); color: var(--muted); }
.users-tbl { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.users-tbl th, .users-tbl td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users-tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.users-tbl tr.off td { color: var(--dim); }
.users-tbl td.mono { font-family: var(--mono); font-size: 12px; }
.users-tbl td.acts { white-space: nowrap; display: flex; gap: 4px; }
.setup-card { max-width: 560px; align-self: flex-start; margin-top: 4vh; }
.setup-steps { margin: 8px 0 14px; padding-left: 20px; line-height: 1.55; font-size: 14px; }
.setup-steps li { margin: 6px 0; }
.setup-sub { margin: 4px 0 2px; padding-left: 18px; list-style: disc; color: var(--muted); font-size: 13px; }
.setup-sub li { margin: 3px 0; }
.setup-cmd { display: flex; flex-direction: column; margin: 4px 0; font-size: 12px; color: var(--muted); }
.setup-cmd code, .setup-steps code { font-family: var(--mono); font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; color: var(--text); word-break: break-all; }
.setup-current { margin: 6px 0 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.setup-links { display: flex; gap: 14px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.side-foot { display: flex; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); }
.side-link { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 4px 5px; border-radius: 6px; white-space: nowrap; }
.side-link:hover { color: var(--text); background: var(--panel); }
.side-link.on { color: var(--accent); }

#top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; color: var(--muted); font-size: 16px; }
.icon-btn:hover { border-color: var(--line); color: var(--text); }
.top-titles { min-width: 0; flex: 1; }
.title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.path { font: 12px var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- лента ---------- */
.feed { flex: 1; overflow-y: auto; padding: 18px 0 24px; scroll-behavior: auto; }
.feed > * { max-width: 860px; margin-left: auto; margin-right: auto; padding-left: 20px; padding-right: 20px; }
.empty { color: var(--muted); text-align: center; margin-top: 18vh; }
.empty .star { color: var(--accent); font-size: 34px; display: block; margin-bottom: 8px; }
.msg-user { display: flex; justify-content: flex-end; margin: 14px auto; }
.msg-user .bubble { background: var(--user); border-radius: 14px; padding: 9px 14px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg-user.pending .bubble { opacity: .6; }
.msg-ai { margin: 8px auto; }
.md { word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .55em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .4em 0; }
.md li { margin: .15em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1em 0 .4em; line-height: 1.3; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.08em; }
.md code { font: .88em var(--mono); background: var(--code); padding: .1em .35em; border-radius: 4px; }
.md pre { position: relative; background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: .6em 0; }
.md pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.md table { border-collapse: collapse; margin: .6em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 10px; text-align: left; }
.md th { background: var(--panel); }
.md blockquote { border-left: 3px solid var(--line); margin: .5em 0; padding: 0 12px; color: var(--muted); }
.md a { color: var(--accent); }
.copy-btn { position: absolute; top: 6px; right: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 5px; font-size: 11px; padding: 1px 6px; opacity: 0; }
.md pre:hover .copy-btn { opacity: 1; }
.streaming { white-space: pre-wrap; }

/* карточки инструментов */
.tool { margin: 6px auto; font: 13px/1.5 var(--mono); }
.tool-head { display: flex; align-items: baseline; gap: 8px; cursor: pointer; padding: 2px 0; }
.tool-head .tdot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; transform: translateY(-1px); }
.tool.run .tdot { background: var(--accent); animation: pulse 1s infinite; }
.tool.ok .tdot { background: var(--green); }
.tool.err .tdot { background: var(--red); }
.tool.ask .tdot { background: var(--yellow); }
.tool-head .tname { font-weight: 700; color: var(--text); }
.tool-head .targ { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tool-head .tmeta { color: var(--dim); flex: none; }
.tool-head .tmeta .plus { color: var(--green); } .tool-head .tmeta .minus { color: var(--red); }
.tool-body { margin: 4px 0 6px 16px; border-left: 2px solid var(--line); padding-left: 12px; }
.tool.collapsed .tool-body { display: none; }
.tool-sum { color: var(--dim); margin-left: 16px; }
.tool-sum::before { content: "⎿  "; }
.tool pre { margin: 4px 0; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; background: var(--code); border-radius: 6px; padding: 8px 10px; }
.tool .err-text { color: var(--red); }
.tool .sub { color: var(--muted); }
.diff { background: var(--code); border-radius: 6px; padding: 6px 0; overflow-x: auto; max-height: 520px; overflow-y: auto; }
.diff div { white-space: pre; padding: 0 10px; min-height: 1.5em; }
.diff .a { background: var(--add-bg); } .diff .a::before { content: "+ "; color: var(--green); }
.diff .d { background: var(--del-bg); } .diff .d::before { content: "- "; color: var(--red); }
.diff .c::before { content: "  "; }
.diff .gap { color: var(--dim); }
.todo { list-style: none; padding: 0; margin: 2px 0; }
.todo li::before { content: "☐ "; color: var(--dim); }
.todo li.done { color: var(--dim); text-decoration: line-through; } .todo li.done::before { content: "☑ "; color: var(--green); }
.todo li.doing { color: var(--accent); } .todo li.doing::before { content: "◐ "; }

/* разрешения, вопросы, план */
.ask-card { margin: 10px auto; }
.ask-inner { border: 1px solid var(--accent); border-radius: 10px; background: var(--panel); padding: 12px 14px; }
.ask-card.done .ask-inner { border-color: var(--line); opacity: .75; }
.ask-title { font-weight: 600; margin-bottom: 6px; }
.ask-title .tname { font-family: var(--mono); color: var(--accent); }
.ask-desc { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.ask-card pre { font: 13px var(--mono); background: var(--code); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; margin: 6px 0; }
.ask-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ask-btns button { border: 1px solid var(--line); background: var(--bg2); border-radius: 7px; padding: 6px 12px; }
.ask-btns button:hover { border-color: var(--accent); }
.ask-btns button.yes { background: var(--accent); border-color: var(--accent); color: #fff; }
.ask-btns button.yes:hover { background: var(--accent2); }
.ask-btns button.no:hover { border-color: var(--red); color: var(--red); }
.ask-card textarea { width: 100%; margin-top: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; resize: vertical; min-height: 34px; }
.ask-done { color: var(--muted); font-size: 13px; margin-top: 6px; }
.q-block { margin: 8px 0 12px; }
.q-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.q-text { font-weight: 600; margin: 2px 0 6px; }
.q-opt { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; padding: 7px 10px; margin: 4px 0; }
.q-opt:hover { border-color: var(--accent); }
.q-opt.sel { border-color: var(--accent); background: rgba(217, 119, 87, .15); }
.q-opt small { display: block; color: var(--muted); }
.q-other { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-top: 4px; }

.note { margin: 8px auto; font-size: 13px; color: var(--muted); }
.note.warn { color: var(--yellow); } .note.error { color: var(--red); white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }
.turn-end { margin: 2px auto 14px; font-size: 12px; color: var(--dim); }
.working { margin: 8px auto; color: var(--accent); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.working .spin { display: inline-block; animation: spin 2.4s linear infinite; }
.working .wtime { color: var(--dim); }

/* ---------- ввод ---------- */
#composer { padding: 10px 16px 6px; max-width: 900px; width: 100%; margin: 0 auto; }
#composer textarea { width: 100%; resize: none; max-height: 40vh; min-height: 52px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; line-height: 1.45; }
#composer textarea:focus { border-color: #5b5a56; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.chip { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; color: var(--muted); }
.chip:hover { color: var(--text); border-color: #5b5a56; }
select.chip { appearance: none; background: var(--bg); padding-right: 12px; }
#modeBtn.plan { color: #8fb3ff; border-color: #4a5f8a; }
#modeBtn.acceptEdits { color: #c49be8; border-color: #6a4f86; }
#modeBtn.bypassPermissions { color: var(--red); border-color: #8a4a4a; }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 15px; }
.send:hover { background: var(--accent2); }
.send.stop { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.send.stop::before { content: "■"; }
.send.stop { font-size: 0; } .send.stop::before { font-size: 14px; }
.hint { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: 13px; max-height: 220px; overflow-y: auto; }
.hint div { padding: 4px 10px; cursor: pointer; display: flex; gap: 10px; }
.hint div.sel, .hint div:hover { background: var(--user); }
.hint b { font-family: var(--mono); font-weight: 600; color: var(--accent); min-width: 110px; }
.hint span { color: var(--muted); }
.status { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 4px 18px 8px; font: 12px var(--mono); color: var(--dim); max-width: 900px; width: 100%; margin: 0 auto; }
.status .ok { color: var(--green); } .status .bad { color: var(--red); } .status .warn { color: var(--yellow); }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #44433f; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- узкий экран (телефон) ---------- */
@media (max-width: 820px) {
  #side { position: fixed; z-index: 20; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; width: min(86vw, 320px); }
  #app.side-open #side { transform: none; }
  #app.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 10; }
  .feed > * { padding-left: 12px; padding-right: 12px; }
  #composer { padding: 8px 10px 4px; }
  #top { padding: 8px 10px; }
  .msg-user .bubble { max-width: 92%; }
  .status { padding: 2px 12px 6px; }
}
@media (min-width: 821px) {
  #app.side-hidden #side { display: none; }
}

/* ---------- этап 2: правая панель ---------- */
:root { --panel-w: 460px; }
#panel { width: var(--panel-w); flex: none; position: relative; background: var(--bg2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 300px; max-width: 75vw; }
#panelResize { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 5; }
#panelResize:hover, #panelResize.drag { background: var(--accent); opacity: .5; }
.panel-tabs { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.ptab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 6px 10px; font-size: 13.5px; }
.ptab:hover { color: var(--text); }
.ptab.on { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; }
.pbody { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ptools { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.tiny { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.fsel, .gbranch, .tinfo { font: 12px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree { flex: 1; overflow: auto; padding: 4px 0 20px; font: 13px/1.6 var(--mono); }
.ftree.dropping { outline: 2px dashed var(--accent); outline-offset: -4px; }
.frow { display: flex; align-items: center; gap: 6px; padding: 0 10px; cursor: pointer; white-space: nowrap; }
.frow:hover { background: var(--panel); }
.frow.sel { background: var(--user); }
.frow .fic { width: 12px; color: var(--dim); flex: none; text-align: center; }
.frow .fname { overflow: hidden; text-overflow: ellipsis; }
.frow.dir .fname { color: var(--blue); }
.frow.ign { opacity: .5; }
.frow .fsize { margin-left: auto; color: var(--dim); font-size: 11px; padding-left: 10px; }
.glist { flex: 1; overflow: auto; font: 13px var(--mono); }
.gfile { border-bottom: 1px solid #2c2b29; }
.ghead { display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer; }
.ghead:hover { background: var(--panel); }
.gcode { width: 18px; text-align: center; font-weight: 700; flex: none; }
.gcode.M { color: var(--yellow); } .gcode.A, .gcode.\3F { color: var(--green); } .gcode.D { color: var(--red); } .gcode.R { color: var(--blue); }
.gpath { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gbtn { opacity: 0; border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 5px; font-size: 11px; padding: 0 6px; }
.ghead:hover .gbtn { opacity: 1; }
.gbtn:hover { color: var(--red); border-color: var(--red); }
.gdiff { margin: 0 6px 8px; }
.gdiff .h { color: var(--blue); background: rgba(122, 167, 224, .08); }
.gdiff.diff .a::before, .gdiff.diff .d::before, .gdiff.diff .c::before, .gdiff.diff .h::before { content: ""; }
.gempty { padding: 14px; color: var(--dim); font-size: 13px; font-family: var(--sans); }
.gcommit { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.gcommit textarea { flex: 1; resize: vertical; min-height: 36px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 13px; }
.termbox { flex: 1; min-height: 0; padding: 4px 0 0 6px; background: #1a1a19; }
.termbox .xterm { height: 100%; }

/* вложения */
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.att { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 2px 4px 2px 8px; font-size: 12.5px; max-width: 260px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att.up { opacity: .6; }
.att button { border: 0; background: none; color: var(--muted); padding: 0 4px; }
.att button:hover { color: var(--red); }
#main.dropping #composer textarea { border-color: var(--accent); border-style: dashed; }

/* просмотр файла */
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 3vh 3vw; }
.viewer-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; width: min(1100px, 100%); height: 100%; display: flex; flex-direction: column; min-height: 0; }
.viewer-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.viewer-head b { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-head a.chip { text-decoration: none; }
.viewer-body { flex: 1; overflow: auto; }
.viewer-body pre { margin: 0; padding: 10px 14px; font: 13px/1.5 var(--mono); }
.viewer-body pre code { background: none; }
.viewer-body img { max-width: 100%; display: block; margin: 16px auto; }
.viewer-body .vnote { padding: 20px; color: var(--muted); }

@media (max-width: 1100px) {
  #panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 25; width: min(100vw, 560px); max-width: 100vw; box-shadow: -8px 0 24px rgba(0, 0, 0, .4); }
  #panelResize { display: none; }
}
@media (max-width: 820px) {
  .viewer { padding: 0; }
  .viewer-card { border-radius: 0; }
}

.tool-head .targ.flink { cursor: pointer; }
.tool-head .targ.flink:hover { color: var(--text); text-decoration: underline; }

/* ---------- этап 3: диалоги ---------- */
.dlg-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; width: min(600px, 100%); max-height: 100%; display: flex; flex-direction: column; }
.dlg-body { padding: 14px 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.dlg-body label { font-size: 13px; color: var(--muted); }
.dlg-body input[type=text], .dlg-body input[type=url] { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.dlg-body input:focus { border-color: var(--accent); }
.dlg-tabs { display: flex; gap: 6px; }
.dlg-tabs button { border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.dlg-tabs button.on { border-color: var(--accent); color: var(--text); }
.dlg-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dlg-msg { min-height: 18px; font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.dlg-msg.bad { color: var(--red); }
.dlg-msg.ok { color: var(--green); }
.dlg-act { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 9px 12px; }
.dlg-act:hover { border-color: var(--accent); }
.dlg-act small { display: block; color: var(--muted); font-size: 12px; }
.dlg-code { font: 12.5px var(--mono); background: var(--code); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; white-space: pre-wrap; word-break: break-all; position: relative; }
.dlg-kv { font: 12.5px var(--mono); color: var(--muted); }
.dlg-kv b { color: var(--text); font-weight: 500; }
.proj-head .pmenu { opacity: 0; border: 0; background: none; color: var(--muted); padding: 0 4px; }
.proj-head:hover .pmenu { opacity: 1; }
.proj-head .add { margin-left: auto; }

/* ---------- этап 4: светлая тема ---------- */
:root[data-theme="light"] {
  --bg: #faf9f6;
  --bg2: #f1eee8;
  --panel: #ffffff;
  --line: #e0dbd2;
  --text: #1f1e1c;
  --muted: #64615b;
  --dim: #98948c;
  --accent: #c2603f;
  --accent2: #a94f31;
  --user: #ebe7df;
  --code: #f5f2ec;
  --green: #2e7d32;
  --red: #c0392b;
  --yellow: #9a6400;
  --blue: #2b5fb4;
  --add-bg: rgba(46, 125, 50, .12);
  --del-bg: rgba(192, 57, 43, .10);
}
:root[data-theme="light"] .gfile { border-bottom-color: #ece8e1; }
:root[data-theme="light"] #composer textarea:focus { border-color: #b9b3a8; }
:root[data-theme="light"] .chip:hover { border-color: #b9b3a8; }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cfc9be; background-clip: padding-box; }
:root[data-theme="light"] #modeBtn.plan { color: #2b5fb4; border-color: #9fb6e0; }
:root[data-theme="light"] #modeBtn.acceptEdits { color: #7b3fb0; border-color: #c7a8e3; }
:root[data-theme="light"] .viewer { background: rgba(40, 36, 30, .35); }
:root[data-theme="light"] #app.side-open #scrim { background: rgba(40, 36, 30, .3); }
:root[data-theme="light"] .ask-inner { box-shadow: 0 1px 6px rgba(0, 0, 0, .06); }

/* справка */
.help h3 { margin: 6px 0 2px; font-size: 14px; color: var(--accent); }
.help table { border-collapse: collapse; width: 100%; font-size: 13px; }
.help td { padding: 3px 8px 3px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.help td:first-child { font-family: var(--mono); white-space: nowrap; color: var(--text); }
.help td:last-child { color: var(--muted); }
.help p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.dlg-card.wide { width: min(820px, 100%); }

/* лимиты подписки */
.status .clk { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.status .clk:hover { color: var(--text); }
.usage-h { margin: 10px 0 2px; font-size: 14px; color: var(--accent); }
.uwin { margin: 6px 0 4px; }
.uwin-top { display: flex; gap: 10px; font-size: 13.5px; align-items: baseline; }
.uwin-top span:last-child { color: var(--muted); font-size: 12.5px; }
.ubar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 5px 0 3px; }
.ubar > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.ubar > div.warn { background: var(--yellow); }
.ubar > div.bad { background: var(--red); }
.uwin-sub { font-size: 12px; color: var(--dim); }
.utable { border-collapse: collapse; width: 100%; font-size: 13px; }
.utable th { text-align: right; color: var(--dim); font-weight: 500; padding: 3px 8px; border-bottom: 1px solid var(--line); }
.utable td { text-align: right; padding: 3px 8px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.utable th:first-child, .utable td:first-child { text-align: left; font-family: var(--sans); }

.sess .sdot.bg { background: var(--blue); animation: pulse 2s infinite; }
.note.bgwait { color: var(--blue); }
