/* Brain Desk — общий стиль: главный экран, сеанс, окна программы для Windows. Светлая и тёмная тема. */
:root {
  --bg: #f4f6f5; --card: #fff; --text: #1a1d1c; --muted: #66706c; --line: #dfe4e2;
  --accent: #c8233b; --accent-strong: #a8182f; --accent-bg: #fde9ec; --on-accent: #fff;
  --ok: #0f6e56; --ok-bg: #e0f4ec; --warn: #8a5a0b; --warn-bg: #fbefd9; --err: #a32d2d; --err-bg: #fcebeb;
  --shadow: 0 1px 2px rgba(16, 24, 22, .05), 0 6px 20px rgba(16, 24, 22, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111514; --card: #1a1f1e; --text: #e8ecea; --muted: #9ba49f; --line: #2c3331;
    --accent: #ff6b7f; --accent-strong: #ff94a2; --accent-bg: #3b1820; --on-accent: #2b0710;
    --ok: #5dcaa5; --ok-bg: #12302a; --warn: #efa43a; --warn-bg: #33250d; --err: #f09595; --err-bg: #3a1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ---------- кнопки и поля ---------- */
button { cursor: pointer; }
.primary, .ghost, .danger, .plain {
  border-radius: 10px; padding: 10px 16px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-strong); }
.primary:disabled { opacity: .55; cursor: default; }
.ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.ghost:hover { border-color: var(--accent); }
.danger { background: var(--err); color: #fff; }
.plain { background: none; color: var(--accent); padding: 8px 10px; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
input[type=text], input[type=password], input:not([type]), input[inputmode], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
label.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
label.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.muted { color: var(--muted); }
.err { color: var(--err); background: var(--err-bg); border-radius: 10px; padding: 9px 12px; margin: 10px 0 0; font-size: 14px; }
.okmsg { color: var(--ok); background: var(--ok-bg); border-radius: 10px; padding: 9px 12px; margin: 10px 0 0; font-size: 14px; }
.svgi { width: 18px; height: 18px; flex: none; }

/* ---------- главный экран ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 18px 10px; }
.brand { display: flex; align-items: center; gap: 12px; max-width: 760px; margin: 0 auto; }
.logo { width: 42px; height: 42px; border-radius: 12px; flex: none; }
.brand .grow { flex: 1; min-width: 0; }
.brand h1 { font-size: 20px; font-weight: 650; margin: 0; line-height: 1.2; letter-spacing: -.2px; }
.status { margin: 0; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.online .dot { background: #1fb57f; box-shadow: 0 0 0 3px rgba(31, 181, 127, .18); }
.status.connecting .dot { background: #e0a526; }
.status.offline .dot { background: #d24a4a; }
main { padding: 6px 18px 28px; max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.label { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.idrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bigid { font-size: 34px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; line-height: 1.15; user-select: all; }
.card p { margin: 10px 0 0; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.on { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
button.chip { cursor: pointer; }
.connect { display: flex; gap: 10px; }
.connect input { font-size: 20px; letter-spacing: 1px; font-variant-numeric: tabular-nums; font-weight: 600; }
details { margin-top: 12px; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '›'; display: inline-block; margin-right: 6px; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
details input { margin-top: 10px; }
h3.group { font-size: 13px; font-weight: 600; color: var(--muted); margin: 22px 2px 10px; text-transform: uppercase; letter-spacing: .5px; }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.item:hover { border-color: var(--accent); }
.ava { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 15px; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item .x { border: 0; background: none; color: var(--muted); font-size: 20px; width: 34px; height: 34px; border-radius: 8px; }
.item .x:hover { background: var(--bg); color: var(--err); }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }
.apps { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- окна-диалоги ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 16, 15, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 4px 18px 8px; overflow: auto; max-height: calc(100vh - 170px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
fieldset { border: 0; padding: 0; margin: 14px 0 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.field { margin: 10px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.sub { padding-left: 28px; }
.fp { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; background: var(--bg); padding: 2px 6px; border-radius: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } .connect { flex-direction: column; } .bigid { font-size: 30px; } }

/* ---------- сеанс ---------- */
body.session { overflow: hidden; background: #0d1110; height: 100vh; height: 100dvh; overscroll-behavior: none; touch-action: none; }
#stage { position: fixed; inset: 0; overflow: hidden; outline: none; touch-action: none; user-select: none; -webkit-user-select: none; background: #0d1110; }
#view { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#screen { width: 100%; height: 100%; display: block; image-rendering: auto; background: #000; }
#cursor { position: absolute; width: 22px; height: 22px; margin: 0; pointer-events: none; transform-origin: 0 0; }
#cursor svg { width: 22px; height: 22px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }

.bar {
  position: fixed; z-index: 20; left: 50%; top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px;
  background: rgba(24, 30, 29, .92); color: #eef2f1; border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; padding: 5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35); max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none;
  transition: transform .2s, opacity .2s; backdrop-filter: blur(8px);
}
.bar::-webkit-scrollbar { display: none; }
.bar.hide { transform: translate(-50%, -140%); opacity: 0; }
.bar .title { padding: 0 10px 0 6px; font-size: 13px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.bar .title small { display: block; color: #9fb0ab; font-size: 11px; line-height: 1.2; }
.bar button { border: 0; background: none; color: inherit; width: 40px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; position: relative; }
.bar button:hover, .bar button.on { background: rgba(255, 255, 255, .12); }
.bar button.red { color: #ff8a8a; }
.bar button svg { width: 20px; height: 20px; }
.bar .sep { width: 1px; height: 24px; background: rgba(255, 255, 255, .14); margin: 0 3px; flex: none; }
.bar-handle { position: fixed; z-index: 19; left: 50%; top: 0; transform: translateX(-50%); width: 64px; height: 18px; border-radius: 0 0 10px 10px; background: rgba(24, 30, 29, .7); border: 0; color: #cfd8d6; font-size: 12px; padding: 0; }

.menu {
  position: fixed; z-index: 30; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); min-width: 220px; max-height: calc(100vh - 80px); overflow: auto;
}
.menu button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; border: 0; background: none; padding: 9px 10px; border-radius: 8px; font-size: 14px; }
.menu button:hover { background: var(--bg); }
.menu button.sel::after { content: '✓'; margin-left: auto; color: var(--accent); font-weight: 700; }
.menu .mh { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .4px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(9, 13, 12, .82); padding: 16px; }
.overlay .box { background: var(--card); color: var(--text); border-radius: 16px; padding: 22px; width: min(420px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.overlay h2 { margin: 6px 0 6px; font-size: 18px; }
.overlay p { margin: 6px 0; color: var(--muted); font-size: 14px; }
.overlay .actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.overlay form { margin-top: 14px; display: grid; gap: 10px; text-align: left; }
.spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--accent-bg); border-top-color: var(--accent); margin: 4px auto 8px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bigicon { font-size: 34px; line-height: 1; }

.panel {
  position: fixed; z-index: 25; right: 10px; top: 62px; width: min(360px, calc(100vw - 20px)); max-height: calc(100% - 80px); display: flex; flex-direction: column;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.panel .ph { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 6px; font-weight: 600; }
.panel .ph button { border: 0; background: none; font-size: 20px; color: var(--muted); }
.panel .pb { padding: 6px 14px 14px; overflow: auto; }
.chatlog { display: flex; flex-direction: column; gap: 6px; min-height: 120px; max-height: 300px; overflow: auto; padding: 4px 0 10px; }
.msg { max-width: 85%; padding: 7px 10px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.chatform { display: flex; gap: 8px; }
.filerow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.filerow:first-child { border-top: 0; }
.filerow .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.prog i { display: block; height: 100%; background: var(--accent); width: 0; }

.keys {
  position: fixed; z-index: 22; left: 0; right: 0; bottom: 0; display: flex; gap: 4px; overflow-x: auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(24, 30, 29, .96); scrollbar-width: none;
}
.keys::-webkit-scrollbar { display: none; }
.keys button { flex: none; min-width: 44px; height: 38px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .1); color: #eef2f1; font-size: 13px; font-weight: 600; padding: 0 10px; }
.keys button.on { background: var(--accent); color: var(--on-accent); }
#kbd { position: fixed; left: 0; bottom: 0; width: 100%; height: 40px; opacity: 0; pointer-events: none; font-size: 16px; border: 0; z-index: -1; resize: none; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(24, 30, 29, .95); color: #eef2f1; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .35); }
.stats { position: fixed; z-index: 21; left: 10px; bottom: 10px; background: rgba(0, 0, 0, .6); color: #d8e3e0; font: 12px/1.45 ui-monospace, Consolas, monospace; padding: 8px 10px; border-radius: 10px; pointer-events: none; white-space: pre; }

/* ---------- окна программы для Windows: «Принять?» и индикатор ---------- */
body.prompt { padding: 0; height: 100vh; display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; }
.prompt-head { display: flex; gap: 12px; align-items: center; padding: 16px 18px 6px; -webkit-app-region: drag; }
.prompt-head h1 { margin: 0; font-size: 16px; }
.prompt-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.prompt-body { padding: 4px 18px; flex: 1; }
.who { display: flex; gap: 12px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 6px 0 8px; }
.who b { display: block; font-size: 16px; }
.who span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prompt-foot { display: flex; gap: 10px; padding: 10px 18px 16px; }
.prompt-foot button { flex: 1; }
.countdown { font-size: 12.5px; color: var(--muted); text-align: center; padding-bottom: 6px; }

body.indicator { background: transparent; margin: 0; overflow: hidden; -webkit-user-select: none; user-select: none; }
.ind {
  margin: 6px; background: #13201e; color: #eef4f2; border-radius: 12px; border: 1px solid rgba(255, 107, 127, .45);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35); overflow: hidden;
}
.ind-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; -webkit-app-region: drag; }
.ind-row .rec { width: 10px; height: 10px; border-radius: 50%; background: #ff5a5a; box-shadow: 0 0 0 4px rgba(255, 90, 90, .2); flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 90, 90, .05); } }
.ind-row .txt { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ind-row .txt b { font-weight: 650; }
.ind-row button { -webkit-app-region: no-drag; border: 0; border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; background: rgba(255, 255, 255, .1); color: inherit; }
.ind-row button:hover { background: rgba(255, 255, 255, .18); }
.ind-row button.stop { background: #c43c3c; color: #fff; }
.ind-row button.stop:hover { background: #d84a4a; }
.ind-more { border-top: 1px solid rgba(255, 255, 255, .1); padding: 8px 10px 10px; font-size: 13px; }
.ind-more .chatlog { max-height: 150px; min-height: 60px; }
.ind-more .msg.them { background: rgba(255, 255, 255, .1); }
.ind-more input { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #eef4f2; padding: 7px 10px; }
.ind-more label.check { padding: 2px 0; font-size: 13px; }
.ind-sess { padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.ind-sess:last-child { border-bottom: 0; }
.bar button[data-badge]::after { content: attr(data-badge); position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #ff5a5a; color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
@media (max-width: 640px) {
  .bar { top: 6px; padding: 4px; gap: 2px; }
  .bar .title, .bar .sep { display: none; }
  .bar button { width: 38px; height: 36px; }
}
body.prompt { overflow: hidden; }
.ind button.stop { border: 0; border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; background: #c43c3c; color: #fff; }
.ind button.stop:hover { background: #d84a4a; }
