/* OneMetric Code — приложение на телефоне. Вид — по макету макет/index.html: те же цвета, шрифты Onest и
   JetBrains Mono, точки статусов, пузыри, «Ход работы», карточки вопросов. Тема — по системе.
   CSP запрещает встроенные стили: всё оформление — здесь. */

@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/onest-v11-var-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/onest-v11-var-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/onest-v11-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/onest-v11-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/jetbrains-mono-var-cyrillic-ext.62213be8.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/jetbrains-mono-var-cyrillic.e17cfd15.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/jetbrains-mono-var-latin.83c005d4.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --ink: #15181e;
  --muted: #5b6371;
  --line: #dadfe6;
  --soft: #f3f5f8;
  --accent: #2b59d9;
  --accent-ink: #ffffff;
  --run: #0f8a9d;
  --ok: #1e8e4f;
  --wait: #b26a00;
  --stop: #c4322f;
  --code-bg: #f6f7f9;
  --add: #e6f4ea;
  --del: #fdecea;
  --font-body: "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #171a20;
    --ink: #e8eaef;
    --muted: #9aa3b1;
    --line: #2b303a;
    --soft: #1f232b;
    --accent: #7d9cff;
    --accent-ink: #0d0f13;
    --run: #3cb8ca;
    --ok: #4cc27f;
    --wait: #e3a43c;
    --stop: #f26b67;
    --code-bg: #12151a;
    --add: #15301f;
    --del: #3a1a1a;
    color-scheme: dark;
  }
}
html.kb-open { --safe-bottom: 0px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
[hidden] { display: none !important; }
a { color: var(--accent); }
code, .mono, pre { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 26px; height: 26px; }

/* --- каркас: приложение во весь видимый экран, клавиатура iPhone его поджимает (см. app.js) --- */
#app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--app-top, 0px);
  height: var(--app-h, 100%);
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}
@media (min-width: 761px) { #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.scroll-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.boot { margin: auto; color: var(--muted); padding: 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }

.appbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 8px) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-height: 56px;
}
.appbar .titles { flex: 1; min-width: 0; display: grid; }
.appbar .title { font-weight: 650; font-size: 17px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabbar {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(var(--safe-bottom) + 6px);
  background: var(--surface);
}
.tab { display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted); background: none; border: 0; padding: 4px 0; text-decoration: none; }
.tab .icon { width: 22px; height: 22px; }
.tab.active { color: var(--accent); font-weight: 600; }

.netbar { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-top) + 4px); z-index: 30; font-size: 12px; background: var(--wait); color: #fff; border-radius: 999px; padding: 3px 12px; }

/* --- общие элементы макета --- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.on { color: var(--ok); }
.pill.off { color: var(--wait); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; background: var(--muted); opacity: .5; }
.dot.run { background: var(--run); opacity: 1; animation: pulse 1.8s ease-out infinite; }
.dot.wait { background: var(--wait); opacity: 1; }
.dot.queue { background: transparent; border: 2px solid var(--wait); opacity: 1; }
.dot.ok, .dot.on { background: var(--ok); opacity: 1; }
.dot.err { background: var(--stop); opacity: 1; }
.dot.idle { background: var(--muted); opacity: .45; }
.dot.view { background: var(--muted); opacity: .6; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--run) 55%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
@media (prefers-reduced-motion: reduce) { .dot.run { animation: none; } }

.btn { font-weight: 600; font-size: 14px; border-radius: 12px; padding: 10px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 45%, var(--line)); }
.btn.stop { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 45%, var(--line)); padding: 6px 12px; font-size: 13px; min-height: 34px; }
.btn.wide { width: 100%; }
.btn.small { padding: 6px 10px; font-size: 13px; min-height: 32px; border-radius: 10px; }
.linkbtn { font-size: 13px; color: var(--accent); background: none; border: 0; padding: 0; text-align: left; }
.round { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 0; }
.round.ghost { border-color: transparent; background: transparent; color: var(--ink); }
.round.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.round.rec { background: var(--stop); color: #fff; border-color: var(--stop); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.tag.from-phone { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.tag.warn { color: var(--wait); background: color-mix(in srgb, var(--wait) 12%, var(--surface)); }
.tag.studio { color: var(--muted); }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.error-text { color: var(--stop); font-size: 13px; margin: 0; }
.field { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.field:focus { outline: none; border-color: var(--accent); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--run) 25%, transparent); border-top-color: var(--run); display: inline-block; flex: none; animation: spin .8s linear infinite; }
.spin.big { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* --- вход --- */
.login { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: calc(var(--safe-top) + 32px) 20px calc(var(--safe-bottom) + 24px); background: var(--bg); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 18px; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; justify-self: center; }
.login h1 { margin: 0; text-align: center; font-size: 24px; font-weight: 700; }
.login p { margin: 0; }
.login .lede { text-align: center; color: var(--muted); }
.login form { display: grid; gap: 10px; }
.code-big { font-family: var(--font-mono); font-size: 40px; font-weight: 600; letter-spacing: .08em; text-align: center; font-variant-numeric: tabular-nums; padding: 8px 0; }
.steps-list-plain { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.note { font-size: 13px; color: var(--muted); background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.note.warn { color: var(--wait); background: color-mix(in srgb, var(--wait) 9%, var(--surface)); }
.center { text-align: center; justify-self: center; }

/* --- список бесед --- */
.list-body { display: grid; gap: 12px; padding: 12px 12px 20px; align-content: start; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; background: var(--soft); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; font-size: 16px; color: var(--ink); }
.search input:focus { outline: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); display: inline-flex; gap: 6px; align-items: center; }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip select { border: 0; background: transparent; font-size: 12px; padding: 0; max-width: 46vw; }
.group { display: grid; gap: 0; }
.group-name { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); padding: 6px 4px 4px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.row { display: grid; grid-template-columns: 14px 1fr auto; gap: 3px 8px; padding: 10px 6px; align-items: start; background: none; border: 0; border-radius: 12px; text-align: left; width: 100%; color: inherit; }
.row + .row { border-top: 1px solid var(--line); border-radius: 0; }
.row:active { background: var(--soft); }
.row .dot { margin-top: 6px; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .what { grid-column: 2 / 4; color: var(--muted); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .where { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 4px; }
.row.wait-row .what { color: var(--wait); font-weight: 500; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; display: grid; gap: 12px; justify-items: center; }

/* --- беседа --- */
.chat-scroll { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 12px; }
.chat-scroll.has-chip { padding-bottom: 56px; }
.feed { display: flex; flex-direction: column; gap: 12px; }
.feed-top { display: flex; justify-content: center; min-height: 0; }
.feed-empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 14px; }
.msg { display: grid; gap: 4px; max-width: 90%; min-width: 0; }
.msg.me { justify-self: end; align-self: flex-end; }
.msg.ai { align-self: flex-start; max-width: 100%; }
.msg .who { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg.me .who { justify-content: flex-end; }
.bubble { padding: 10px 12px; border-radius: 16px; min-width: 0; overflow-wrap: anywhere; }
.bubble .text { white-space: pre-wrap; }
.msg.me .bubble { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); border-bottom-right-radius: 6px; }
.msg.ai .bubble { background: var(--soft); border-bottom-left-radius: 6px; }
.msg.pending .bubble { opacity: .6; }
.msg.pending.accepted .bubble { opacity: .85; }
.msg.pending.failed .bubble { opacity: 1; border: 1px solid color-mix(in srgb, var(--stop) 50%, var(--line)); }
.msg.queued .bubble { opacity: .7; border: 1px dashed var(--line); }
.msg .state { font-size: 11px; color: var(--muted); display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.msg .state.err { color: var(--stop); }
.msg .state .linkbtn { font-size: 12px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumb { width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; padding: 0; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-files { display: grid; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--muted); }

.steps { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; gap: 4px; min-width: 0; }
.steps-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.steps .more { justify-self: start; margin-top: 2px; }
.step { display: grid; min-width: 0; }
.step.folded { display: none; }
.step-line { display: grid; grid-template-columns: 16px 16px 1fr; gap: 8px; align-items: start; font-size: 13px; background: none; border: 0; padding: 4px 0; text-align: left; color: inherit; width: 100%; min-width: 0; }
.step-line .icon { width: 15px; height: 15px; margin-top: 2px; }
.step-line .st-ok { color: var(--ok); }
.step-line .st-error { color: var(--stop); }
.step-line .st-unknown { color: var(--muted); }
.step-line .spin { width: 14px; height: 14px; margin-top: 2px; }
.step-ico { color: var(--muted); }
.step-title { min-width: 0; overflow-wrap: anywhere; }
.step-title small { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.step.st-error .step-title { color: var(--stop); }
.step-detail { display: grid; gap: 6px; padding: 4px 0 8px 24px; min-width: 0; }
.step-detail .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
pre.code { margin: 0; font-size: 12px; line-height: 1.45; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow: auto; max-height: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.code.del { background: var(--del); }
pre.code.add { background: var(--add); }
pre.code.tall { max-height: none; }

.file { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; color: inherit; width: 100%; min-width: 0; }
.file .icon { color: var(--accent); }
.file div { display: grid; min-width: 0; }
.file b { font-size: 13px; overflow-wrap: anywhere; }
.file span { font-size: 12px; color: var(--muted); }

.agent-card { display: grid; grid-template-columns: 14px 1fr auto 16px; gap: 4px 8px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; color: inherit; width: 100%; min-width: 0; }
.agent-card .dot { margin-top: 6px; }
.agent-card .agent-main { display: grid; min-width: 0; }
.agent-card b { font-size: 14px; overflow-wrap: anywhere; }
.agent-card small { font-size: 12px; color: var(--muted); }
.agent-card .agent-result { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; margin-top: 2px; }
.agent-card .agent-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.agent-card .icon { color: var(--muted); margin-top: 2px; }
.wf-card { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; gap: 6px; }
.wf-head { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.wf-head b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.wf-head .icon { color: var(--accent); }
.wf-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.wf-progress { font-size: 12px; color: var(--muted); }
.wf-agent { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; padding: 6px 2px; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; color: inherit; width: 100%; font-size: 13px; }
.wf-agent small { color: var(--muted); }
.done-note { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ok); padding: 0 2px; }
.done-note.err { color: var(--stop); }
.fold { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.fold summary { cursor: pointer; color: var(--muted); font-size: 12px; list-style: none; display: flex; gap: 6px; align-items: center; }
.fold summary::-webkit-details-marker { display: none; }
.fold[open] summary { margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.new-pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--accent); box-shadow: 0 4px 14px rgba(0,0,0,.12); }

/* вопросы и разрешения */
.prompts-box { display: grid; gap: 10px; }
.ask { border: 1.5px solid var(--wait); border-radius: 14px; padding: 12px; display: grid; gap: 8px; background: color-mix(in srgb, var(--wait) 7%, var(--surface)); min-width: 0; }
.ask-head { display: flex; gap: 8px; align-items: center; font-weight: 650; color: var(--wait); }
.ask .cmd { font-family: var(--font-mono); font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.ask p { margin: 0; font-size: 13px; }
.ask .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ask .q { display: grid; gap: 6px; }
.ask .q + .q { border-top: 1px solid var(--line); padding-top: 8px; }
.ask .q-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ask .q-text { font-weight: 600; font-size: 14px; }
.ask .opts { display: grid; gap: 6px; }
.opt { display: grid; gap: 2px; text-align: left; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: inherit; }
.opt small { color: var(--muted); font-size: 12px; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.ask textarea { width: 100%; min-height: 40px; resize: vertical; border-radius: 10px; border: 1px solid var(--line); padding: 8px 10px; background: var(--surface); font-size: 16px; }

/* --- низ беседы: поле ввода, вложения, голос --- */
.chat-bottom { flex: none; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: var(--safe-bottom); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; border-radius: 20px; background: var(--soft); padding: 9px 14px; font-size: 16px; line-height: 1.4; min-height: 40px; overflow-y: auto; }
.composer textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.attach-list { display: flex; gap: 8px; padding: 8px 10px 0; overflow-x: auto; }
.attach { position: relative; flex: none; display: grid; gap: 2px; justify-items: center; width: 72px; font-size: 11px; color: var(--muted); }
.attach img, .attach .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; }
.attach span { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .rm { position: absolute; top: -4px; right: 0; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--surface); display: grid; place-items: center; padding: 0; }
.attach .rm .icon { width: 12px; height: 12px; }
.readonly-note { padding: 12px 14px; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.composer-note { padding: 6px 14px 0; font-size: 12px; color: var(--muted); }
/* длинный текст: поле до половины экрана, «Свернуть / Развернуть» над ним (высоту ставит composer.js) */
.ta-toggle { display: flex; align-items: center; gap: 4px; margin: 6px 10px -4px auto; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; }
.ta-toggle .icon { width: 14px; height: 14px; }
.icon.flip { transform: rotate(180deg); }
/* «Claude работает» — внизу ленты */
.working { display: flex; align-items: center; gap: 8px; padding: 8px 4px 4px; font-size: 13px; color: var(--muted); }
.working-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.working-time { font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
/* «Задачи · N» — работающие фоновые субагенты и конвейеры */
.tasks-chip { position: absolute; left: 10px; bottom: 10px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.task-list { display: grid; }
.task-row { grid-template-columns: 12px 1fr; align-items: start; column-gap: 10px; }
.task-row .dot { margin-top: 5px; }
.task-row:disabled { opacity: .7; }
.task-main { display: grid; gap: 1px; min-width: 0; }
.task-group { display: grid; gap: 1px; padding: 12px 8px 4px; }
.task-group small { color: var(--muted); font-size: 12px; }
.voice { padding: 12px 14px 12px; display: grid; gap: 10px; }
.voice-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.voice-head b { color: var(--ok); font-weight: 600; }
.voice-head b.rec { color: var(--stop); }
.clip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--soft); }
.clip canvas { flex: 1; height: 28px; width: 100%; min-width: 0; }
.clip span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.voice .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* --- файлы --- */
.crumbs { display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: center; font-size: 12px; color: var(--muted); padding: 10px 12px 0; }
.crumbs button { background: none; border: 0; padding: 2px 2px; color: var(--muted); font-size: 12px; }
.crumbs button:last-child { color: var(--ink); font-weight: 600; }
.files-body { display: grid; gap: 10px; padding: 10px 12px 20px; align-content: start; }
.files { display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.frow { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; padding: 10px; font-size: 14px; background: var(--surface); border: 0; text-align: left; color: inherit; width: 100%; }
.frow + .frow { border-top: 1px solid var(--line); }
.frow .icon { color: var(--muted); }
.frow.dir .icon { color: var(--accent); }
.frow .fname { overflow-wrap: anywhere; min-width: 0; }
.frow.hidden-file .fname { color: var(--muted); }
.frow .fmeta { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lock { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); }
.viewer { display: grid; gap: 10px; }
.viewer .meta { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.viewer .meta code { overflow-wrap: anywhere; }
.viewer .btns { display: flex; flex-wrap: wrap; gap: 8px; }
.viewer img.full { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: var(--soft); }
.viewer iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.viewer iframe.html-view { height: calc(var(--app-h, 100vh) - var(--safe-top) - 190px); min-height: 320px; }
/* пробная страница проверки «песочницы» (files.js) — за краем экрана */
.probe-frame { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; border: 0; }
.progress { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* --- настройки --- */
.settings-body { display: grid; gap: 16px; padding: 14px 12px 24px; align-content: start; }
.card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 10px; background: var(--surface); }
.card h2 { margin: 0; font-size: 15px; font-weight: 650; }
.dev { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; }
.dev + .dev { border-top: 1px solid var(--line); }
.dev b { font-size: 14px; overflow-wrap: anywhere; }
.dev small { grid-column: 1 / 2; font-size: 12px; color: var(--muted); }
.dev .acts { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 6px; }

/* --- markdown --- */
.md { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; min-width: 0; }
.md.plain { white-space: pre-wrap; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table, .md pre { margin: 0 0 .65em; }
.md ul, .md ol { padding-left: 1.3em; }
.md li + li { margin-top: .2em; }
.md h1, .md h2, .md h3, .md h4 { margin: .8em 0 .4em; line-height: 1.3; }
.md h1 { font-size: 18px; }
.md h2 { font-size: 16px; }
.md h3, .md h4 { font-size: 15px; }
.md code { font-size: .88em; background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 5px; padding: .08em .35em; }
.md pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 12px; line-height: 1.45; }
.md pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
.md blockquote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: .8em 0; }

/* --- шторки и всплывающие сообщения --- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.sheet-wrap { position: absolute; inset: 0; pointer-events: auto; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.backdrop { position: absolute; inset: 0; background: rgba(10, 12, 16, .45); }
.sheet { position: relative; width: 100%; max-width: 760px; max-height: calc(var(--app-h, 100vh) - var(--safe-top) - 24px); background: var(--surface); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); }
.sheet.full { height: calc(var(--app-h, 100vh) - var(--safe-top) - 12px); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-title { flex: 1; min-width: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px 16px; display: grid; gap: 10px; align-content: start; flex: 1; min-height: 0; }
.pick-row { display: grid; gap: 1px; padding: 10px 8px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; color: inherit; width: 100%; }
.pick-row b { font-size: 14px; }
.pick-row small { color: var(--muted); font-family: var(--font-mono); font-size: 11px; overflow-wrap: anywhere; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 76px); z-index: 50; display: grid; gap: 6px; justify-items: center; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; max-width: 520px; width: fit-content; display: flex; gap: 12px; align-items: center; font-size: 14px; padding: 10px 14px; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.error { background: var(--stop); color: #fff; }
.toast.warn { background: var(--wait); color: #fff; }
.toast .linkbtn { color: inherit; text-decoration: underline; font-weight: 600; font-size: 14px; }

/* --- мелочи --- */
.groups { display: grid; gap: 12px; }
.composer .round, .tab, .row, .opt, .btn { -webkit-touch-callout: none; touch-action: manipulation; }
.composer .round { user-select: none; -webkit-user-select: none; }
.note p { margin: 0; }
.note p + p { margin-top: 6px; }
img.full { max-width: 100%; height: auto; display: block; border-radius: 10px; }
.ask.sending { opacity: .7; }
.step.thinking .step-title { color: var(--muted); }
.feed-top .progress, .feed-top .empty { padding: 8px 0; }
.msg.task .bubble { background: color-mix(in srgb, var(--run) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--run) 25%, var(--line)); }
.ask pre.code { max-height: 260px; }
