:root {
  /* «терминал-дашборд»: бумажный фон, тонкие рамки, моноширинные метки */
  --bg: #f6f4ef; --panel: #fffdf9; --side: #efece5; --line: #e2ddd2; --plate: #e3f1ee;
  --tx: #1f2328; --tx2: #6b6b63; --ok: #15803d; --err: #dc2626; --warn: #c2410c; --acc: #0f766e;
  --okbg: #ecf7ef; --errbg: #fdeeee; --warnbg: #fdf3e7;
  --r: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--tx); font-size: 14px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; color: var(--tx); background: none; border: 0; cursor: pointer; }
header {
  height: 48px; flex: none; display: flex; align-items: center; gap: 16px;
  padding: 0 16px 0 8px; border-bottom: 1px solid var(--line); background: var(--panel);
}
header a { color: var(--tx2); text-decoration: none; font-size: 13px; margin-left: auto; }
header a:hover { color: var(--tx); }
.hbtn { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: var(--r); color: var(--tx2); font-size: 13px; }
.hbtn:hover, .hbtn.on { background: var(--plate); color: var(--tx); }
@font-face { font-family: codicon; src: url("/a/vendor/codicon.ttf") format("truetype"); font-display: block; }
.ci { font: normal normal normal 16px/1 codicon; display: inline-block; width: 16px; text-align: center; flex: none;
  color: var(--tx2); -webkit-font-smoothing: antialiased; user-select: none; }
.ci.mut { color: var(--tx2); }
.ibtn .ci { color: inherit; }
.ibtn.big .ci { font-size: 18px; width: 18px; }
.fi { width: 16px; height: 16px; flex: none; }
.chev { width: 14px; font-size: 14px; flex: none; }
.tool .tic { font-size: 14px; width: 14px; vertical-align: -2px; margin-right: 4px; }
.tool .fi { width: 14px; height: 14px; vertical-align: -2px; margin: 0 4px; }
.tool .rmark { font-size: 14px; margin-left: 6px; vertical-align: -2px; }
.tool.ok .rmark { color: var(--ok); } .tool.err .rmark { color: var(--err); }
.ptitle .ci { vertical-align: -2px; }
.pbtn .ci { color: var(--tx); vertical-align: -3px; }
.pbtn.send { padding: 0 12px; }
.tab .ci, .tab .fi { margin-right: -2px; }
.tab.on .ci { color: var(--tx); }
header a { display: inline-flex; align-items: center; gap: 4px; }
.chead > .ci { font-size: 16px; }
.ibtn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; border-radius: var(--r); color: var(--tx2); }
.ibtn:hover { background: var(--plate); color: var(--tx); }
#app { flex: 1; display: flex; min-height: 0; position: relative; }

/* файлы — панель слева, открывается кнопкой «Файлы» */
#files {
  width: 300px; flex: none; display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line);
}
.bar { height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); }
.ttl { font-size: 12px; color: var(--tx2); text-transform: uppercase; letter-spacing: .04em; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree { flex: 1; overflow: auto; padding: 4px 0; }
.tree ul { padding-left: 12px; }
.tree .row { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 8px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.tree .row:hover, .tree .row.on { background: var(--plate); }
.tree .row .ic { color: var(--tx2); }
.tree .msg { padding: 4px 12px; font-size: 13px; color: var(--tx2); }
.tree .msg.err { color: var(--err); }
.lnk { color: var(--tx); text-decoration: underline; padding: 0 4px; }

/* две панели */
.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#paneL { flex: none; width: 50%; min-width: 240px; }
#splitV { width: 4px; flex: none; cursor: col-resize; background: var(--line); }
#splitV:hover { background: var(--plate); }
.tabs { height: 40px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 4px 0 12px; border-radius: var(--r); color: var(--tx2); font-size: 13px; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--tx); }
.tab.on { background: var(--plate); color: var(--tx); }
.tab .x { width: 20px; height: 20px; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; }
.tab .x:hover { background: var(--line); }
.tab .x .ic { width: 12px; height: 12px; }
.tab .dirty { color: var(--warn); }
.body { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.body > .tw { position: absolute; inset: 4px 0 0 8px; }
.body > textarea {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; outline: 0;
  background: var(--bg); color: var(--tx); font: 13px/1.5 var(--mono); padding: 12px 16px; tab-size: 4;
  white-space: pre; overflow: auto;
}
.empty { color: var(--tx2); padding: 16px; margin: 0; }
.empty.err { color: var(--err); }
.status { height: 24px; flex: none; display: flex; align-items: center; padding: 0 16px; font-size: 12px; color: var(--tx2); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.status.ok { color: var(--ok); } .status.err { color: var(--err); }


#mob { display: none; }
@media (max-width: 800px) {
  #splitV { display: none; }
  #paneL { width: auto; flex: 1; }
  body[data-p="L"] #paneR, body[data-p="R"] #paneL, body[data-p="F"] .pane { display: none; }
  body[data-p="F"] #files { display: flex !important; position: static; width: 100%; border-right: 0; }
  body:not([data-p="F"]) #files { display: none !important; }
  #ftoggle { display: none; }
  #mob { display: flex; flex: none; gap: 8px; padding: 8px; border-top: 1px solid var(--line); background: var(--panel); }
  #mob button { flex: 1; min-height: 44px; border-radius: var(--r); color: var(--tx2); font-size: 16px; }
  body[data-p="F"] #mob [data-p="F"], body[data-p="L"] #mob [data-p="L"], body[data-p="R"] #mob [data-p="R"] { background: var(--plate); color: var(--tx); }
  .tree .row { min-height: 44px; font-size: 16px; }
  .ibtn, .tab .x { min-width: 44px; min-height: 44px; }
  .tab { height: 36px; font-size: 14px; }
  .tabs { height: 52px; }
  .menu button { min-height: 44px; font-size: 16px; }
}

/* чат */
.body > .chat { position: absolute; inset: 0; display: flex; flex-direction: column; }
.chead { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chead select { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--tx); font: inherit; font-size: 13px; padding: 0 8px; }
.cstate { font-size: 12px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cstate.warn { color: var(--warn); } .cstate.err { color: var(--err); }
.clog { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; max-width: 100%; }
.msg.user { align-self: flex-end; max-width: 85%; background: var(--plate); padding: 8px 12px; border-radius: var(--r); }
.msg.ai pre, .perm pre { background: var(--side); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; overflow-x: auto; font: 12px/1.5 var(--mono); white-space: pre; margin: 4px 0; }
.msg.ai code { font: 12px var(--mono); background: var(--side); padding: 0 4px; border-radius: var(--r); }
.tool { font-size: 12px; color: var(--tx2); }
.tool .thead { cursor: pointer; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool .thead b { color: var(--tx); font-weight: 600; margin-right: 8px; }
.tool.err .thead b { color: var(--err); }
.tool .tres { margin-top: 4px; white-space: pre-wrap; font: 12px/1.5 var(--mono); background: var(--side); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; max-height: 300px; overflow: auto; }
.note { font-size: 12px; color: var(--tx2); }
.note.err { color: var(--err); }
.perm { border: 1px solid var(--warn); border-radius: var(--r); padding: 12px; background: var(--panel); }
.perm.closed { border-color: var(--line); opacity: .7; }
.ptitle { font-weight: 600; margin-bottom: 4px; }
.prow { display: flex; gap: 8px; margin-top: 8px; }
.cin { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--panel); }
.cbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cbar select { height: 28px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--tx2); font: inherit; font-size: 12px; padding: 0 4px; max-width: 170px; }
.cbar .grow { flex: 1; }
.mono { font-family: var(--mono); font-weight: 600; }
.catt { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 8px; border-radius: 999px; background: var(--side); border: 1px solid var(--line); font-size: 12px; color: var(--tx2); max-width: 260px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--tx2); }
.chip button .ic { width: 10px; height: 10px; }
.menu { position: fixed; z-index: 10; min-width: 220px; max-height: 320px; overflow-y: auto; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; }
.menu button { text-align: left; padding: 8px 12px; border-radius: var(--r); font: 13px var(--mono); }
.menu button:hover { background: var(--plate); }
.menu .msg { padding: 8px 12px; font-size: 12px; color: var(--tx2); }
.cin textarea { resize: none; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; font: inherit; color: var(--tx); background: var(--bg); outline: 0; }
.cin textarea:focus { border-color: var(--tx2); }
.pbtn { height: 32px; padding: 0 16px; border-radius: var(--r); background: var(--plate); color: var(--tx); font-size: 13px; font-weight: 600; border: 1px solid var(--line); }
.pbtn:disabled { opacity: .5; cursor: default; }
@media (max-width: 800px) {
  .pbtn, .chead select, .chead .hbtn { min-height: 44px; font-size: 16px; }
  .cin textarea { font-size: 16px; }
}
.msg.ya { border-left: 3px solid var(--warn); padding-left: 12px; }
.eng { display: block; font-size: 12px; font-weight: 600; color: var(--warn); margin-bottom: 4px; }
.perm.stan { border-color: var(--tx2); }
.ppurp { color: var(--tx2); margin-bottom: 4px; }
.pres { font-size: 12px; color: var(--tx2); margin-top: 8px; }
.pres.ok { color: var(--ok); } .pres.err { color: var(--err); }
.msg.ai table { border-collapse: collapse; margin: 4px 0; font-size: 13px; white-space: normal; }
.msg.ai th, .msg.ai td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.msg.ai th { background: var(--side); font-weight: 600; }
.ibtn.on { background: var(--plate); color: var(--tx); }
.cmic.rec .ci { color: var(--err); }
.cmic.rec { background: var(--plate); }
.tab .busy { color: var(--acc); }
.cvoice { font-size: 12px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cvoice.err { color: var(--err); }

/* ---------- стиль «терминал-дашборд» ---------- */
header { gap: 12px; }
.htitle { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.hpill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font: 600 12px var(--mono); color: var(--tx); white-space: nowrap; }
.hpill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tx2); flex: none; }
.hpill.ok .dot { background: var(--ok); } .hpill.run .dot { background: var(--acc); animation: pulse 1.2s infinite; }
.hpill.warn .dot { background: var(--warn); } .hpill.warn { color: var(--warn); border-color: var(--warn); background: var(--warnbg); }
.hpill.err .dot { background: var(--err); } .hpill.err { color: var(--err); border-color: var(--err); background: var(--errbg); }
.hpill .hsep, #hclock { color: var(--tx2); font-weight: 400; }
.hver { font: 600 11px var(--mono); color: var(--acc); border: 1px solid var(--acc); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .3; } }
@media (max-width: 800px) { .hver, .hpill .hsep, #hclock { display: none; } }

/* подписи разделов */
.ttl, .lbl { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--tx2); }
.lbl { flex: none; }

/* вызовы инструментов — карточки шагов */
.tool { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 6px 10px; }
.tool.open { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc) inset; }
.tool .thead { display: flex; align-items: center; gap: 6px; }
.tool .thead b { margin-right: 4px; }
.tool .tsum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tool .tnum { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex;
  align-items: center; justify-content: center; font: 600 11px var(--mono); color: var(--tx2); }
.tool.err .tnum { border-color: var(--err); color: var(--err); }
.tool .tsub { cursor: pointer; margin: 2px 0 0 26px; font: 12px var(--mono); color: var(--acc); }
.tool.err .tsub { color: var(--err); }
.badge { flex: none; font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px;
  border-radius: 4px; border: 1px solid var(--line); color: var(--tx2); background: var(--side); }
.badge.ok { color: var(--ok); border-color: #b7dfc3; background: var(--okbg); }
.badge.err { color: var(--err); border-color: #f3c0c0; background: var(--errbg); }
.badge.run { color: var(--acc); border-color: #a7d3cd; background: var(--plate); }

/* карточки разрешений и «под stan» — как блок проверки */
.perm, .perm.stan { border: 1px solid var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; background: var(--panel); }
.perm.closed { opacity: 1; box-shadow: none; }
.perm.closed.ok { border-color: var(--ok); }
.perm.closed.err { border-color: var(--err); }
.ptitle { font-size: 14px; }
.ppurp { font-size: 13px; }
.perm.closed .pres { margin-top: 10px; padding: 6px 10px; border-radius: 6px; border: 1px solid; font: 700 12px var(--mono);
  text-transform: uppercase; letter-spacing: .06em; }
.perm.closed .pres.ok { color: var(--ok); background: var(--okbg); border-color: #b7dfc3; }
.perm.closed .pres.err { color: var(--err); background: var(--errbg); border-color: #f3c0c0; }

/* итог хода — разделитель */
.note.done { display: flex; align-items: center; gap: 8px; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.note.done::before, .note.done::after { content: ''; flex: 1; border-top: 1px dashed var(--line); }

/* поле ввода и кнопки */
.pbtn { background: var(--acc); color: #fff; border-color: var(--acc); }
.pbtn .ci { color: #fff; }
.pbtn:hover:not(:disabled) { filter: brightness(1.1); }
.cin textarea { background: var(--panel); }
.cin textarea:focus { border-color: var(--acc); }
.msg.user { border: 1px solid #c3e2dc; }
.cstate, .cvoice { font-family: var(--mono); }

/* вход и устройства */
#acct { margin-left: auto; }
#acct + a { margin-left: 0; }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(31, 35, 40, .35); display: flex; align-items: flex-start; justify-content: center; padding: 48px 12px; overflow: auto; }
.ocard { width: 100%; max-width: 640px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px 16px; }
.obar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.osec { margin: 14px 0 6px; }
.orow { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 6px; }
.orow.cur { border-color: var(--acc); }
.otxt { flex: 1; min-width: 0; }
.oname { font-weight: 600; }
.osub { font: 11px var(--mono); color: var(--tx2); overflow-wrap: anywhere; }
.prow .grow { flex: 1; }
a.hbtn { text-decoration: none; }

/* страница входа */
body.authp { overflow: auto; align-items: center; padding: max(32px, env(safe-area-inset-top)) 16px 32px; }
.acard { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.acard section { display: flex; flex-direction: column; gap: 12px; }
.acard h2 { margin: 0; font-size: 18px; }
.acard p { margin: 0; line-height: 1.45; }
.acard .mut { color: var(--tx2); font-size: 13px; }
.acard .big { font: 800 56px/1 var(--mono); text-align: center; letter-spacing: .05em; color: var(--acc); }
.pbtn.big { height: 48px; font-size: 16px; width: 100%; }
.hbtn.wide { width: 100%; justify-content: center; height: 44px; border: 1px solid var(--line); }
.ainp { height: 44px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 12px; font: inherit; font-size: 16px; background: var(--bg); }
.amsg { font-size: 13px; color: var(--ok); }
.amsg.err { color: var(--err); }

/* копирование кода */
.cwrap { position: relative; }
.cwrap > pre { padding-right: 40px; }
.cpy { position: absolute; top: 8px; right: 6px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--panel); border: 1px solid var(--line); opacity: .75; }
.cpy:hover { opacity: 1; border-color: var(--acc); }
.cpy .ci { color: var(--tx2); font-size: 14px; }
.cpy.done { opacity: 1; border-color: var(--ok); } .cpy.done .ci { color: var(--ok); }

.ainp.code { font: 700 28px var(--mono); letter-spacing: .3em; text-align: center; height: 56px; }

.arem { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.arem input { width: 18px; height: 18px; accent-color: var(--acc); }

/* модель — заметно: видно, кто отвечает */
.cbar select.cmodel { font-weight: 800; color: var(--acc); border: 2px solid var(--acc); background: var(--plate); }

/* ---------- телефон / PWA (iPhone 17 Pro: 402×874 pt, Dynamic Island) ---------- */
#mtabs { display: none; }
@media (max-width: 800px) {
  html, body { height: var(--app-h, 100dvh); }
  body { padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  header { height: 44px; padding: 0 8px 0 14px; gap: 8px; }
  header .htitle { font-size: 16px; }
  #mob { display: none !important; }
  #mtabs { display: flex; flex: none; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--panel);
    overflow-x: auto; scrollbar-width: none; }
  #mtabs::-webkit-scrollbar { display: none; }
  .mtab { flex: none; position: relative; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--panel); color: var(--tx2); font-size: 15px; font-weight: 600; }
  .mtab.on { background: var(--acc); border-color: var(--acc); color: #fff; }
  .mtab.plus { width: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
  .mtab .mdot { position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; border-radius: 50%; }
  .mtab .mdot.run { background: var(--acc); animation: pulse 1.2s infinite; } .mtab.on .mdot.run { background: #fff; }
  .mtab .mdot.warn { background: var(--warn); }
  .pane > .tabs, .pane > .status { display: none !important; }
  .chead { padding: 6px 10px; } .chead .lbl { display: none; }
  .clog { padding: 12px 12px 16px; }
  .msg { font-size: 15px; }
  .msg.user { max-width: 90%; }
  .cin { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .cin textarea { min-height: 44px; max-height: 30vh; }
  .cbar { gap: 6px; }
  .cbar select.cmodel { order: -1; flex: 1 1 100%; max-width: none; height: 40px; font-size: 16px; }
  .cbar select.ceffort, .cbar select.cmode { flex: 1; max-width: none; height: 36px; font-size: 14px; }
  .cbar .cstate { flex: 1 1 100%; order: 10; }
  .body > .tw { inset: 4px 4px calc(4px + env(safe-area-inset-bottom)) 6px; }
}
