/* Цвета берутся из темы Telegram (переменные --tg-theme-*), запасные — тёмная тема. */
:root {
  --bg: var(--tg-theme-bg-color, #111318);
  --bg2: var(--tg-theme-secondary-bg-color, #1b1e25);
  --section: var(--tg-theme-section-bg-color, var(--bg2));
  --text: var(--tg-theme-text-color, #ececef);
  --hint: var(--tg-theme-hint-color, #8d919b);
  --link: var(--tg-theme-link-color, #6ab3f3);
  --btn: var(--tg-theme-button-color, #3e88f7);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --danger: var(--tg-theme-destructive-text-color, #ec5b5b);
  --line: color-mix(in srgb, var(--text) 9%, transparent);
  --soft: color-mix(in srgb, var(--text) 5%, transparent);
  --claude: #d97757;
  --claude-soft: color-mix(in srgb, #d97757 16%, transparent);
  --ok: #3ccf91;
  --r: 18px;
  --safe-b: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  --top-inset: calc(var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.dim, .hint { color: var(--hint); }
.hint { font-size: 13px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: var(--top-inset); }

/* ---------- шапка ---------- */
#top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px 9px; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 3; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 21px; color: #fff; background: linear-gradient(140deg, #e48a69, #c4603f); box-shadow: 0 4px 14px -6px #d97757; transition: transform .3s; }
.logo.busy { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.titles { min-width: 0; }
.title { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.sub { display: block; max-width: 52vw; font-size: 12.5px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.chip { font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.icon-btn { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--soft); }
.icon-btn:active, .chip:active { transform: scale(.95); }

/* ---------- экраны ---------- */
main { flex: 1; position: relative; min-height: 0; }
.view { position: absolute; inset: 0; display: none; flex-direction: column; }
.view.active { display: flex; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } }
.pad { overflow-y: auto; padding: 14px 14px 30px; height: 100%; -webkit-overflow-scrolling: touch; }

/* ---------- лента чата ---------- */
.feed { flex: 1; overflow-y: auto; padding: 14px 12px 10px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.msg { max-width: 88%; word-wrap: break-word; overflow-wrap: anywhere; animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.msg.user { align-self: flex-end; background: var(--btn); color: var(--btn-text); padding: 9px 13px; border-radius: var(--r) var(--r) 6px var(--r); white-space: pre-wrap; }
.msg.user .files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.msg.user .files span { font-size: 12.5px; padding: 3px 8px; border-radius: 8px; background: color-mix(in srgb, var(--btn-text) 18%, transparent); }
.msg.user.from-tg::before { content: "из чата"; display: block; font-size: 11px; opacity: .7; margin-bottom: 2px; }
.msg.bot { align-self: flex-start; max-width: 96%; padding: 2px 2px; }
.msg.bot.bubble { background: var(--bg2); padding: 10px 13px; border-radius: var(--r) var(--r) var(--r) 6px; }
.msg.sys { align-self: center; font-size: 12.5px; color: var(--hint); background: var(--soft); padding: 5px 12px; border-radius: 999px; }
.msg.err { color: var(--danger); }

/* markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .6em; }
.md h1, .md h2, .md h3, .md h4 { margin: .9em 0 .4em; line-height: 1.25; font-size: 1.06em; }
.md h1 { font-size: 1.22em; } .md h2 { font-size: 1.13em; }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.3em; } .md li { margin: .15em 0; }
.md a { color: var(--link); text-decoration: none; word-break: break-all; }
.md code { font: 13px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.md pre { position: relative; margin: .5em 0 .7em; background: color-mix(in srgb, var(--text) 6%, var(--bg)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.md pre code { display: block; padding: 11px 12px; overflow-x: auto; background: none; white-space: pre; font-size: 12.5px; }
.md pre .lang { position: absolute; top: 0; left: 0; font-size: 10.5px; color: var(--hint); padding: 3px 9px; }
.md pre .lang + code { padding-top: 21px; }
.md pre .copy { position: absolute; top: 4px; right: 4px; font-size: 11.5px; padding: 3px 8px; border-radius: 7px; background: var(--bg2); color: var(--hint); }
.md blockquote { margin: .4em 0 .7em; padding: 2px 0 2px 11px; border-left: 3px solid var(--claude); color: color-mix(in srgb, var(--text) 82%, var(--hint)); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: .9em 0; }
.md .tbl { overflow-x: auto; margin: .4em 0 .7em; }
.md table { border-collapse: collapse; font-size: 13.5px; min-width: 60%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; text-align: left; vertical-align: top; }
.md th { color: var(--hint); font-weight: 600; font-size: 12.5px; }

/* шаги */
.steps { align-self: stretch; border-radius: 14px; background: var(--soft); overflow: hidden; animation: pop .2s ease; }
.steps > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--hint); cursor: pointer; }
.steps > summary::-webkit-details-marker { display: none; }
.steps > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.8px solid var(--hint); border-bottom: 1.8px solid var(--hint); transform: rotate(45deg); transition: transform .2s; }
.steps[open] > summary::after { transform: rotate(-135deg); }
.step { display: flex; gap: 9px; padding: 6px 12px; font-size: 13px; border-top: 1px solid var(--line); }
.step .ic { width: 20px; flex: none; text-align: center; }
.step .bd { min-width: 0; flex: 1; }
.step .nm { font-weight: 600; margin-right: 5px; }
.step .ar { color: var(--hint); word-break: break-word; }
.step .dt { display: none; margin-top: 4px; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; color: var(--hint); background: var(--soft); border-radius: 8px; padding: 6px 8px; }
.step.open .dt { display: block; }
.step.sub { padding-left: 30px; }
.step .st { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; }
.step .st.run { border: 2px solid var(--claude-soft); border-top-color: var(--claude); animation: spin .8s linear infinite; }
.step .st.ok { background: var(--ok); mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4 8.5l2.5 2.5L12 5.5" stroke="black" stroke-width="2.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>') center/100% no-repeat; }
.step .st.bad { background: var(--danger); mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M5 5l6 6M11 5l-6 6" stroke="black" stroke-width="2.2" fill="none" stroke-linecap="round"/></svg>') center/100% no-repeat; }

/* карточка текущей работы */
.work { align-self: stretch; border-radius: 16px; background: var(--bg2); border: 1px solid var(--claude-soft); overflow: hidden; animation: pop .2s ease; }
.work-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.work-head .spark { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--claude); font-size: 15px; animation: spin 2.4s linear infinite; }
.work-head .wt { flex: 1; font-weight: 600; font-size: 14px; }
.work-head .wt small { display: block; font-weight: 400; color: var(--hint); font-size: 12px; }
.work-head .stop { font-size: 13px; font-weight: 600; color: var(--danger); padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--danger) 13%, transparent); }
.work .thought { padding: 0 12px 10px; font-size: 13.5px; color: color-mix(in srgb, var(--text) 80%, var(--hint)); font-style: italic; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.work .wsteps { max-height: 230px; overflow-y: auto; }
.work .shimmer { height: 2px; background: linear-gradient(90deg, transparent, var(--claude), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: sh 1.4s linear infinite; }
@keyframes sh { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* файл от Claude */
.filecard { align-self: flex-start; width: min(320px, 92%); background: var(--bg2); border-radius: 16px; overflow: hidden; animation: pop .2s ease; }
.filecard img { display: block; width: 100%; max-height: 300px; object-fit: cover; background: var(--soft); }
.filecard .fc-body { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.filecard .fc-ic { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; background: var(--claude-soft); font-size: 18px; }
.filecard .fc-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.filecard .fc-act { display: flex; border-top: 1px solid var(--line); }
.filecard .fc-act button { flex: 1; padding: 9px 4px; font-size: 13px; font-weight: 600; color: var(--link); }
.filecard .fc-act button + button { border-left: 1px solid var(--line); }

/* пустой чат */
.empty { margin: auto; text-align: center; padding: 20px 12px 40px; max-width: 360px; }
.empty-logo { font-size: 42px; width: 72px; height: 72px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 24px; color: #fff; background: linear-gradient(140deg, #e48a69, #c4603f); box-shadow: 0 14px 34px -14px #d97757; }
.empty-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.empty-hint { color: var(--hint); font-size: 14px; }
.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 18px; }
.suggest button { font-size: 13.5px; padding: 8px 13px; border-radius: 999px; background: var(--bg2); }

.to-bottom { position: absolute; right: 14px; bottom: 86px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--bg2); box-shadow: 0 4px 16px -6px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 2; }
.to-bottom.show { opacity: 1; pointer-events: auto; }

/* ---------- поле ввода ---------- */
#composer { padding: 6px 10px 8px; border-top: 1px solid var(--line); background: var(--bg); }
.compose-row, .rec-row { display: flex; align-items: flex-end; gap: 8px; }
#input { flex: 1; resize: none; max-height: 160px; min-height: 42px; padding: 10px 14px; border-radius: 21px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; outline: none; line-height: 1.4; }
#input:focus { border-color: color-mix(in srgb, var(--btn) 55%, transparent); }
#input::placeholder { color: var(--hint); }
.round { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; transition: transform .12s, background .2s; }
.round:active { transform: scale(.9); }
.round.ghost { color: var(--hint); background: var(--soft); }
.round.primary { background: var(--btn); color: var(--btn-text); }
.round.danger { color: var(--danger); }
#sendBtn svg { display: none; }
#sendBtn[data-mode="mic"] .i-mic, #sendBtn[data-mode="send"] .i-send, #sendBtn[data-mode="stop"] .i-stop { display: block; }
#sendBtn[data-mode="stop"] { background: var(--danger); }
.attach-row { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; }
.att { position: relative; flex: none; display: flex; align-items: center; gap: 7px; max-width: 200px; padding: 6px 28px 6px 8px; border-radius: 12px; background: var(--bg2); font-size: 12.5px; overflow: hidden; }
.att img { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; }
.att .an { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .ax { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-size: 12px; }
.att .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--btn); transition: width .2s; }
.att.err { color: var(--danger); }
.queue-bar { display: flex; flex-direction: column; gap: 4px; padding: 2px 2px 8px; }
.queue-bar div { font-size: 12.5px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-bar div::before { content: "⏳ в очереди: "; }

.rec-body { flex: 1; height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 14px; border-radius: 21px; background: var(--bg2); font-variant-numeric: tabular-nums; font-size: 14px; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
#recWave { flex: 1; min-width: 0; height: 32px; }
.rec-body.busy { color: var(--hint); }

/* ---------- нижние вкладки ---------- */
#tabs { display: flex; border-top: 1px solid var(--line); background: var(--bg); padding-bottom: var(--safe-b); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; font-size: 11px; color: var(--hint); }
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--btn); }
body.kb #tabs { display: none; }

/* ---------- общее: карточки, списки, кнопки ---------- */
.card { background: var(--section); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.h2 { font-size: 19px; font-weight: 700; }
.h3 { font-size: 15px; font-weight: 650; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 14px; background: var(--btn); color: var(--btn-text); font-weight: 600; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn.ghost { background: var(--soft); color: var(--text); }
.btn.wide { width: 100%; margin: 4px 0 14px; }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.btn:active { transform: scale(.98); opacity: .9; }
.link { color: var(--link); font-size: 13px; text-transform: none; letter-spacing: 0; }
.group-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 16px 4px 7px; }
.group-title:first-child { margin-top: 2px; }
.list { background: var(--section); border-radius: 16px; overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 14px; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item:active { background: var(--soft); }
.item .ii { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--soft); }
.item .ii.dir { background: color-mix(in srgb, var(--btn) 16%, transparent); }
.item .it { flex: 1; min-width: 0; }
.item .t1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.item .t2 { font-size: 12px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .chev { color: var(--hint); width: 18px; height: 18px; }
.item.current .t1 { font-weight: 650; color: var(--btn); }
.item .badge { font-size: 11px; font-weight: 700; color: var(--btn); }
.list .more { padding: 10px; text-align: center; color: var(--hint); font-size: 13px; }

.places { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; margin: 0 -14px 0; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.places::-webkit-scrollbar { display: none; }
.places button { flex: none; font-size: 13px; padding: 7px 12px; border-radius: 999px; background: var(--section); white-space: nowrap; }
.places button.on { background: var(--btn); color: var(--btn-text); }
.places.small { margin: 10px 0 6px; padding: 0 0 6px; flex-wrap: wrap; overflow: visible; }
.places.small button { background: var(--soft); }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 13px; margin: 2px 2px 10px; color: var(--hint); }
.crumbs button { padding: 3px 5px; border-radius: 6px; color: var(--link); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.files-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.files-actions .btn { flex: 1; }

.seg-list { background: var(--section); border-radius: 16px; overflow: hidden; }
.seg-list button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px 14px; text-align: left; }
.seg-list button + button { border-top: 1px solid var(--line); }
.seg-list button.on::after { content: "✓"; color: var(--btn); font-weight: 700; }
.seg-list small { color: var(--hint); margin-left: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 0 auto; padding: 9px 10px; border-radius: 12px; background: var(--section); font-size: 13.5px; }
.seg button.on { background: var(--btn); color: var(--btn-text); font-weight: 600; }
.cwd-now { font: 13.5px/1.4 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; margin-bottom: 3px; }
.toggles { padding: 4px 14px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle b { display: block; font-weight: 500; font-size: 14.5px; }
.toggle small { display: block; color: var(--hint); font-size: 12px; }
.toggle input { display: none; }
.toggle i { flex: none; position: relative; width: 46px; height: 28px; border-radius: 14px; background: color-mix(in srgb, var(--hint) 40%, transparent); transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle input:checked + i { background: var(--btn); }
.toggle input:checked + i::after { transform: translateX(18px); }
.about { text-align: center; color: var(--hint); font-size: 12px; margin: 14px 10px; }

/* ПК */
.pc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.meter { background: var(--section); border-radius: 16px; padding: 12px 14px; }
.meter .ml { font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; }
.meter .mv { font-size: 24px; font-weight: 700; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.meter .mv small { font-size: 13px; font-weight: 500; color: var(--hint); margin-left: 3px; }
.bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--btn); transition: width .5s; }
.bar.hot > i { background: var(--danger); }
.bar.warm > i { background: #f0a43a; }
.drow { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; }
.drow + .drow { border-top: 1px solid var(--line); }
.drow .bar { flex: 1; }
.drow .dn { width: 26px; font-weight: 700; }
.drow .df { color: var(--hint); font-size: 12px; white-space: nowrap; }
.prow { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.prow + .prow { border-top: 1px solid var(--line); }
.prow span:last-child { color: var(--hint); font-variant-numeric: tabular-nums; }
.shot-box { margin-top: 10px; }
.shot-box img { width: 100%; border-radius: 10px; display: block; }
.shot-box .row-between { margin-top: 8px; }

/* шторка */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86%; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 14px calc(16px + var(--safe-b)); animation: up .24s cubic-bezier(.2,.9,.3,1); }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet .sh-title { font-weight: 650; font-size: 16px; word-break: break-all; }
.sheet .sh-sub { color: var(--hint); font-size: 12.5px; margin: 2px 0 12px; word-break: break-all; }
.sheet .sh-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .sh-actions .btn { padding: 12px 8px; font-size: 14px; }
.sheet .preview { margin: 0 0 12px; border-radius: 12px; overflow: hidden; background: var(--bg2); }
.sheet .preview img, .sheet .preview video { display: block; width: 100%; max-height: 50vh; object-fit: contain; background: #000; }
.sheet .preview pre { margin: 0; padding: 10px 12px; max-height: 45vh; overflow: auto; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 30; max-width: 88%; padding: 9px 15px; border-radius: 14px; background: color-mix(in srgb, var(--text) 88%, var(--bg)); color: var(--bg); font-size: 13.5px; box-shadow: 0 8px 24px -10px rgba(0,0,0,.5); animation: pop .2s ease; text-align: center; }
.gate { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--soft); border-top-color: var(--btn); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.loading { padding: 20px; text-align: center; color: var(--hint); }

/* ---------- удалённый доступ ---------- */
.rd-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.rd-card:active { opacity: .85; }
.rd-ic { width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, #4f8ff7, #2f6bd8); }
.rd-tx { flex: 1; min-width: 0; }
.rd-card .chev { color: var(--hint); width: 18px; height: 18px; }
.rd { position: fixed; inset: 0; z-index: 25; background: #000; color: #fff; display: flex; flex-direction: column; padding-top: var(--top-inset); }
.rd-top { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(20,22,28,.92); z-index: 2; }
.rd-btn { min-width: 38px; height: 38px; padding: 0 9px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.1); color: #fff; font-size: 13px; font-weight: 700; }
.rd-btn.on { background: #3e88f7; }
.rd-btn svg { width: 20px; height: 20px; }
.rd-stat { flex: 1; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; min-width: 0; white-space: nowrap; overflow: hidden; }
.rd-dot { width: 8px; height: 8px; border-radius: 50%; background: #f0a43a; flex: none; }
.rd-dot.ok { background: #3ccf91; } .rd-dot.bad { background: #ec5b5b; }
.rd-tools { display: flex; gap: 6px; }
.rd-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.rd-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: none; image-rendering: auto; }
.rd-ripple { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 2px solid #3e88f7; background: rgba(62,136,247,.25); pointer-events: none; opacity: 0; }
.rd-ripple.go { animation: ripple .45s ease-out; }
.rd-ripple.right { border-color: #f0a43a; background: rgba(240,164,58,.25); }
@keyframes ripple { from { opacity: 1; transform: scale(.4); } to { opacity: 0; transform: scale(1.6); } }
.rd-keys { background: rgba(20,22,28,.96); padding: 8px 8px calc(8px + var(--safe-b)); }
.rd-keys input { width: 100%; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: #fff; padding: 0 12px; font: inherit; outline: none; margin-bottom: 7px; }
.rd-keyrow { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.rd-keyrow::-webkit-scrollbar { display: none; }
.rd-keyrow button { flex: none; height: 36px; padding: 0 12px; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.rd-keyrow button.mod.on { background: #3e88f7; }
.rd-keyrow button:active { background: rgba(255,255,255,.25); }
.rd-hint { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); max-width: 92%; padding: 8px 14px; border-radius: 12px; background: rgba(20,22,28,.85); font-size: 12.5px; color: rgba(255,255,255,.85); text-align: center; pointer-events: none; transition: opacity .6s; }
.rd-hint.gone { opacity: 0; }
