/* шрифтове — на самия хъб (Inter и JetBrains Mono, лиценз OFL) */
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(inter-cyrillic-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(inter-latin-wght-normal.woff2) format('woff2-variations'); 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-display: swap; font-weight: 100 900; src: url(jetbrains-mono-cyrillic-wght-normal.woff2) format('woff2-variations'); 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-display: swap; font-weight: 100 900; src: url(jetbrains-mono-latin-wght-normal.woff2) format('woff2-variations'); 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: #0f0f12;
  --panel: #141417;
  --card: #18181b;
  --card-border: #2c2c31;
  --text: #e6e6e9;
  --muted: #8b8b93;
  --faint: #5d5d66;
  --accent: #d4940f;
  --accent-hover: #e6a31a;
  --accent-text: #1a1204;
  --mine-bg: #2a2110;
  --mine-border: #8a6512;
  --online: #3fb950;
  --busy: #d4940f;
  --danger: #e5534b;
  --code-bg: #0b0b0d;
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --grid: rgba(255, 255, 255, .028);
  /* сянка за „повдигнати“ елементи (3D ефект) */
  --lift: 0 6px 18px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .04);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--bg);
  /* фина мрежа като в стария чат */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font);
  font-feature-settings: 'cv11', 'ss01';
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.btn-accent {
  background: var(--accent); color: var(--accent-text); border: 0;
  border-radius: 8px; padding: 9px 18px; font-weight: 600;
}
.btn-accent:hover { background: var(--accent-hover); }
.btn-accent:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 9px 14px; font-weight: 600;
}
.btn-ghost:hover { border-color: var(--faint); }

/* ---------- Вход ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-box {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; padding: 28px;
}
.login-box h1 { margin: 0 0 8px; color: var(--accent); font-size: 26px; }
.login-box input, .composer textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 10px 12px; font: inherit; outline: none;
}
.login-box input:focus, .composer textarea:focus { border-color: var(--accent); }
.login-error { color: var(--danger); min-height: 1.5em; font-size: 14px; }

/* ---------- Подредба: бутони за стаите отгоре ---------- */
.app { height: 100%; display: flex; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  /* над съобщенията: те минават под лентата и се виждат замъглени */
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  background: rgba(15, 15, 18, .35);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 0 2px 6px; margin-bottom: -6px; }
/* има още стаи вдясно (или вляво) — ръбът избледнява */
.tabs.more-right { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
.tabs.more-left { -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px); mask-image: linear-gradient(90deg, transparent, #000 40px); }
.tabs.more-left.more-right { -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  box-shadow: var(--lift);
  /* еднакви бутони: една ширина и височина, съдържанието — в средата.
     Когато не се побират, всички се свиват еднакво (до 88px), после лентата се превърта. */
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 0 1 124px; min-width: 88px;
  height: 40px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 8px;
  font-weight: 600; white-space: nowrap;
}
.tab .name { overflow: hidden; text-overflow: ellipsis; }
.dev { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.tab .dev { margin-left: -2px; }
/* тесен бутон (много машини / малък прозорец) — без иконка, за да се вижда името */
#tabs .tab { container-type: inline-size; }
@container (max-width: 112px) { .tab .dev { display: none; } }
.tab:focus { outline: none; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab:hover { border-color: var(--faint); }
/* състоянието на машината е в цвета на бутона (приглушено) */
.tab.offline { color: var(--faint); }
.tab.room { background: rgba(88, 140, 230, .12); border-color: rgba(88, 140, 230, .38); }   /* общата стая — синкава */
.tab.online { background: rgba(63, 185, 80, .10); border-color: rgba(63, 185, 80, .32); }
.tab.busy { background: rgba(212, 148, 15, .13); border-color: rgba(212, 148, 15, .42); animation: busy 2.4s ease-in-out infinite; }
@keyframes busy { 50% { background: rgba(212, 148, 15, .04); } }
/* избраната стая — по-ярка рамка и кехлибарена черта отдолу */
.tab.active { color: var(--text); border-color: var(--accent); box-shadow: var(--lift), inset 0 -3px 0 var(--accent); }
.tab.active.offline { color: var(--muted); }
.badge {
  background: var(--accent); color: var(--accent-text); border-radius: 10px;
  font-size: 12px; font-weight: 700; padding: 0 7px; min-width: 20px; text-align: center;
}
.conn { font-size: 13px; color: var(--muted); white-space: nowrap; animation: pulse 1.6s ease-in-out infinite; }
.conn:empty { display: none; }
/* тънка анимирана лента най-горе, докато чатът се свързва (появява се след половин секунда) */
.connbar {
  position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 20; overflow: hidden;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.connbar.on { opacity: 1; transition-delay: .5s; }
.connbar::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 35%; left: -35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: connbar 1.3s ease-in-out infinite;
}
@keyframes connbar { to { left: 100%; } }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Съобщения ---------- */
.messages-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: calc(var(--top, 60px) + 12px) 18px 16px; display: flex; flex-direction: column; gap: 8px; position: relative; }

/* линия над първото непрочетено съобщение */
.new-sep { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; color: var(--accent-hover); font-size: 12px; font-weight: 600; }
.new-sep::before, .new-sep::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--mine-border)); }
.new-sep::after { background: linear-gradient(90deg, var(--mine-border), transparent); }

/* плаващ бутон „към последните“ */
.to-bottom {
  position: absolute; left: calc(50% - 20px); bottom: 10px; z-index: 6; width: 40px; height: 40px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; color: var(--text);
  background: var(--card); border: 1px solid var(--card-border); box-shadow: var(--lift);
  animation: rise .2s ease-out;
}
.to-bottom:hover { border-color: var(--faint); }
.to-bottom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.to-bottom .count { position: absolute; }
.to-bottom .count:not(:empty) {
  top: -7px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}
.day-sep { text-align: center; font-size: 12px; color: var(--faint); margin: 10px 0 4px; }
.msg {
  position: relative;
  box-shadow: var(--lift);
  max-width: min(820px, 85%); align-self: flex-start;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 10px 14px;
}
.msg.mine { align-self: flex-end; background: var(--mine-bg); border-color: var(--mine-border); }
.msg-head { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.msg-head b { color: var(--text); margin-right: 6px; }
.msg-head .dev { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; color: var(--muted); }
.msg-head .to { margin-left: 8px; display: inline-flex; align-items: center; gap: 4px; }
.ico { width: 14px; height: 14px; vertical-align: -2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.msg-head .to svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.msg-body { overflow-wrap: anywhere; }
.msg-body p { margin: 0 0 6px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body h1, .msg-body h2, .msg-body h3 { font-size: 16px; margin: 8px 0 4px; }
.msg-body h4, .msg-body h5, .msg-body h6 { font-size: 14.5px; margin: 6px 0 2px; color: var(--muted); }
.msg-body hr { border: 0; height: 1px; background: var(--card-border); margin: 10px 0; }
/* таблици */
.table-wrap { overflow-x: auto; margin: 6px 0; border: 1px solid var(--card-border); border-radius: 8px; }
.msg-body table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.msg-body th, .msg-body td { padding: 6px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--card-border); }
.msg-body th { background: rgba(255, 255, 255, .035); font-weight: 600; white-space: nowrap; }
.msg-body tr:last-child td { border-bottom: 0; }
.msg-body tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .015); }
.msg-body td + td, .msg-body th + th { border-left: 1px solid var(--card-border); }
.msg-body ul, .msg-body ol { margin: 4px 0 6px; padding-left: 22px; }
.msg-body blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--faint); color: var(--muted); }
.msg-body code { font-family: var(--mono); background: var(--code-bg); border: 1px solid var(--card-border); border-radius: 5px; padding: 0 4px; font-size: 13.5px; }
.msg-body pre {
  background: var(--code-bg); border: 1px solid var(--card-border); border-radius: 8px;
  padding: 0; margin: 6px 0; overflow: hidden;
}
.msg-body pre code { display: block; padding: 10px 12px; overflow-x: auto; }
.code-head {
  display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 4px 12px;
  border-bottom: 1px solid var(--card-border); font: 11px var(--mono); color: var(--faint);
}
.msg-body pre code { background: none; border: 0; white-space: pre; font-size: 13px; line-height: 1.5; }
.msg-body code { font-variant-ligatures: none; }
.msg-body pre code.hljs { background: none; }
.msg-body pre .copy {
  display: grid; place-items: center; width: 26px; height: 24px; padding: 0; color: var(--muted);
  background: var(--card); border: 1px solid var(--card-border); border-radius: 6px;
}
.msg-body pre .copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.msg-body pre .copy:hover { color: var(--text); }
.msg-body a { color: var(--accent-hover); }
.mention { color: var(--accent-hover); font-weight: 600; }

.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-files img {
  max-width: 240px; max-height: 180px; border-radius: 8px; border: 1px solid var(--card-border);
  cursor: zoom-in; display: block;
}
/* файл като карта: иконка по вида, име, тип и размер */
.file-card {
  display: flex; gap: 10px; align-items: center; min-width: 220px; max-width: 320px; padding: 8px 12px 8px 8px; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--card-border); color: var(--text); text-decoration: none;
}
.file-card:hover { border-color: var(--faint); }
.ficon { width: 34px; height: 34px; flex-shrink: 0; padding: 5px; border-radius: 7px; background: var(--card); border: 1px solid var(--card-border);
  fill: none; stroke: var(--accent-hover); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.fname { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmeta small { color: var(--muted); font-size: 12px; }
.fdl { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.file-card:hover .fdl { stroke: var(--text); }

/* действия при посочване на съобщение */
.tools {
  position: absolute; top: -13px; right: 10px; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 2px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 8px; box-shadow: var(--lift);
  opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s; pointer-events: none;
}
.msg:hover .tools { opacity: 1; transform: none; pointer-events: auto; }
.tools button { display: grid; place-items: center; width: 26px; height: 24px; padding: 0; background: none; border: 0; border-radius: 6px; color: var(--muted); }
.tools button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.tools svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tools-time { font-size: 11.5px; color: var(--muted); padding: 0 6px 0 4px; }

.line { font-size: 13.5px; color: var(--muted); padding: 2px 4px; cursor: pointer; overflow-wrap: anywhere; }
.line:hover { color: var(--text); }
.line .full { margin: 6px 0 4px 12px; color: var(--text); cursor: auto; }
.system { align-self: flex-start; font-size: 13px; color: var(--faint); padding: 2px 4px; }

.perm { border-color: var(--busy); }
.perm pre { white-space: pre-wrap; max-height: 220px; overflow-y: auto; }
.perm-actions { display: flex; gap: 8px; margin-top: 8px; }
.perm-actions .deny { background: var(--card); border: 1px solid var(--danger); color: var(--danger); }
.perm-state { margin-top: 6px; font-size: 13px; font-weight: 600; }
.perm-state.allow { color: var(--online); }
.perm-state.deny { color: var(--danger); }

.typing { font-size: 13px; color: var(--busy); padding: 0 4px; }
.typing div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing b { font-weight: 600; margin-right: 4px; }

/* ---------- Писане ---------- */
.icon-btn { width: 44px; height: 42px; padding: 0; display: grid; place-items: center; flex-shrink: 0; }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.composer { padding: 10px 18px 14px; position: relative; }
.composer textarea, .icon-btn, .att { box-shadow: var(--lift); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 200px; line-height: 1.45; overflow-y: hidden; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; }
.attachments:not(:empty) { margin-bottom: 10px; }
.att {
  position: relative; width: 96px; background: var(--card); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 6px; font-size: 12px; color: var(--muted); text-align: center;
}
.att img { width: 100%; height: 64px; object-fit: cover; border-radius: 5px; display: block; margin-bottom: 4px; }
.att .ext { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); }
.att .ext .ficon { width: 36px; height: 36px; }
.att .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .remove {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--card-border); font-size: 13px; line-height: 1; padding: 0;
}
.mention-box {
  position: absolute; bottom: 100%; left: 90px; min-width: 180px; background: var(--card);
  border: 1px solid var(--card-border); border-radius: 8px; padding: 4px; margin-bottom: 4px; z-index: 5;
}
.mention-box div { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.mention-box div.sel { background: var(--accent); color: var(--accent-text); }
.drop-zone {
  position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 14px;
  background: rgba(15, 15, 18, .85); display: grid; place-items: center; font-size: 20px; color: var(--accent); z-index: 10;
}

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); display: grid; place-items: center; z-index: 50; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; border-radius: 6px; }

/* ---------- Телефон ---------- */
@media (max-width: 760px) {
  .topbar, .messages, .composer { padding-left: 16px; padding-right: 16px; }
  .tab { flex-basis: 104px; min-width: 92px; height: 36px; padding: 0 8px; }
  .menu-btn { flex-basis: 36px; width: 36px; }
  .msg { max-width: 92%; }
  .msg-files img { max-width: 100%; }
  .mention-box { left: 16px; }
}

/* ---------- Групиране на поредни съобщения ---------- */
.msg.cont { margin-top: -4px; }
.msg-foot { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.msg-foot svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Анимации ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.new, .line.new, .system.new { animation: rise .28s ease-out; }
.dots span { display: inline-block; animation: blink 1.4s infinite both; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .msg.new, .line.new, .system.new, .dots span, .tab.busy, .conn, .connbar::after, .to-bottom { animation: none; } }

/* ---------- Кратко известие (копирано/поставено) ---------- */
.toast {
  position: fixed; z-index: 60; max-width: 260px; padding: 5px 10px; border-radius: 7px; font-size: 13px;
  background: var(--card); border: 1px solid var(--card-border); color: var(--text); box-shadow: var(--lift); pointer-events: none;
}

/* ---------- Дълги съобщения — показва се само началото ---------- */
.msg.collapsed .msg-body {
  max-height: 9.5em; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
.msg .more {
  display: grid; place-items: center; margin: 4px auto 0; width: 34px; height: 22px; padding: 0;
  color: var(--accent-hover); background: none; border: 1px solid var(--mine-border); border-radius: 6px;
}
.msg .more svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.msg .more.open svg { transform: rotate(180deg); }
.msg .more:hover { background: rgba(212, 148, 15, .1); }

/* ---------- Меню с настройки ---------- */
.menu-wrap { position: relative; flex-shrink: 0; }
.menu-btn { flex: 0 0 40px; width: 40px; min-width: 0; padding: 0; }
.menu-btn svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 90px); overflow-y: auto; padding: 6px 14px 12px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; box-shadow: var(--lift);
}
.menu section { padding: 10px 0; border-bottom: 1px solid var(--card-border); }
.menu section:last-child { border-bottom: 0; }
.menu h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.menu label { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; font-size: 14px; }
.menu input[type=radio], .menu input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.menu .hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.menu .row { display: flex; gap: 8px; }
.menu .row input {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 8px 10px; font: inherit; outline: none;
}
.menu .row input:focus { border-color: var(--accent); }
.menu .row .btn-accent { padding: 8px 14px; }
.seg { display: flex; margin-top: 8px; border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; background: none; border: 0; padding: 6px 4px; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--card-border); }
.seg button.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
#machine-result:not(:empty) { margin-top: 10px; font-size: 13px; }
#machine-result .warn { color: var(--busy); margin-bottom: 6px; }

/* размер на текста */
body[data-size=compact] .app { zoom: .9; }
body[data-size=large] .app { zoom: 1.12; }
#machine-result pre code { white-space: pre-wrap; word-break: break-all; }

/* ---------- Участници и профили ---------- */
.menu-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 0; background: none; border: 0;
  font: inherit; font-size: 14px; font-weight: 600; text-align: left;
}
.menu-link:hover { color: var(--accent-hover); }
.menu-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; }
.modal-box {
  width: min(760px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 8px 18px 18px;
  background: var(--panel); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: var(--lift);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; background: var(--panel); padding: 10px 0; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 18px; }
.icon-close { background: none; border: 0; padding: 4px; color: var(--muted); }
.icon-close:hover { color: var(--text); }
.icon-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; display: block; }
.profile { background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--lift); }
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.device-pick {
  background: var(--bg); color: var(--muted); border: 1px solid var(--card-border); border-radius: 7px;
  padding: 3px 6px; font: inherit; font-size: 12.5px; outline: none; max-width: 240px;
}
.device-pick:focus { border-color: var(--accent); }
.profile-status { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { padding: 3px 12px; border-radius: 7px; font-weight: 700; border: 1px solid var(--card-border); }
.chip.online { background: rgba(63, 185, 80, .10); border-color: rgba(63, 185, 80, .32); }
.chip.busy { background: rgba(212, 148, 15, .13); border-color: rgba(212, 148, 15, .42); }
.chip.offline { color: var(--faint); }
.btn-ghost.small { padding: 4px 10px; font-size: 13px; }
.hw { border-collapse: collapse; font-size: 13px; margin-bottom: 10px; width: 100%; }
.hw td { padding: 3px 0; vertical-align: top; }
.hw td:first-child { color: var(--muted); width: 120px; padding-right: 12px; }
.profile-desc { border-top: 1px solid var(--card-border); padding-top: 10px; font-size: 14px; }
.profile-edit {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px; font: 13.5px/1.5 var(--mono); resize: vertical;
}
.profile-actions { display: flex; gap: 8px; margin-top: 8px; }
.profile .hint { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* ---------- Подсказки (вместо стандартните на Windows) ---------- */
.tip {
  position: fixed; z-index: 70; max-width: 300px; padding: 5px 9px; border-radius: 7px; pointer-events: none;
  background: #26262b; border: 1px solid #3a3a41; color: var(--text); font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5); visibility: hidden; opacity: 0; transition: opacity .12s;
}
.tip.on { visibility: visible; opacity: 1; }

/* ---------- Клавиши (в менюто) ---------- */
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 13px; color: var(--muted); }
.keys > span:nth-child(odd) { white-space: nowrap; color: var(--text); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; text-align: center;
  font: 600 11.5px var(--mono); color: var(--text); background: var(--bg);
  border: 1px solid var(--card-border); border-bottom-width: 2px;
}

/* ---------- Тънък тъмен скролбар ---------- */
* { scrollbar-width: thin; scrollbar-color: #34343a transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #34343a; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #4a4a52; }

/* ---------- Търсене в историята ---------- */
.search-modal { align-items: start; padding-top: 8vh; }
.search-modal .modal-box { padding: 0; width: min(720px, 100%); display: flex; flex-direction: column; max-height: 80vh; overflow: hidden; }
.search-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--card-border); }
.search-row > svg { width: 20px; height: 20px; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
#search-btn svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
#search-input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 16px; }
.search-results { overflow-y: auto; padding: 8px; }
.search-results:empty { display: none; }
.search-row:has(+ .search-results:empty) { border-bottom: 0; }
.search-results .hint { color: var(--faint); font-size: 13px; padding: 10px 8px; }
.hit {
  display: block; width: 100%; text-align: left; padding: 9px 12px; margin-bottom: 4px;
  background: none; border: 1px solid transparent; border-radius: 9px;
}
.hit:hover, .hit:focus-visible { background: var(--card); border-color: var(--card-border); outline: none; }
.hit-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.hit-head b { color: var(--text); }
.hit-head .dev { width: 13px; height: 13px; }
.hit-time { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.hit-text { font-size: 14px; color: var(--text); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hit-text mark { background: rgba(212, 148, 15, .28); color: var(--text); border-radius: 3px; padding: 0 2px; }
.hit-files { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* намереното съобщение — оцветява се за момент */
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 2px var(--accent), var(--lift); } 100% { box-shadow: var(--lift); } }
.msg.flash { animation: flash 2.2s ease-out; }
.line.flash { animation: flash 2.2s ease-out; border-radius: 6px; }

/* ---------- База знания ---------- */
#kb-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kb-box { width: min(820px, 100%); }
#kb-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }
.kb-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.kb-tools input, .kb-form input {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 8px 10px; font: inherit; outline: none;
}
.kb-tools input:focus, .kb-form input:focus, .kb-form textarea:focus { border-color: var(--accent); }
.btn-accent.small { padding: 6px 12px; font-size: 13px; }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { border-color: var(--danger); }
.kb-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 9px; box-shadow: var(--lift);
}
.kb-item:hover { border-color: var(--faint); }
.kb-item-title { font-weight: 600; }
.kb-item-meta { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.tag {
  display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 11.5px; line-height: 19px; font-weight: 500;
  color: var(--muted); background: rgba(255, 255, 255, .05); border: 1px solid var(--card-border);
}
.kb-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.kb-actions { margin-left: auto; display: flex; gap: 6px; }
.kb-back { margin-bottom: 10px; }
.kb-bar .kb-back { margin-bottom: 0; }
.kb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--faint); margin-bottom: 12px; }
.kb-meta span:last-child { margin-left: 2px; }
.kb-text { background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; padding: 14px 16px; box-shadow: var(--lift); }
.kb-form { display: flex; flex-direction: column; gap: 8px; }
.kb-form textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--card-border); border-radius: 8px;
  padding: 10px; font: 13.5px/1.5 var(--mono); resize: vertical; outline: none;
}
.kb-box .hint { color: var(--faint); font-size: 13px; padding: 6px 2px; }
.hits-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); padding: 8px 12px 4px; }
.kb-hit .dev { color: var(--accent-hover); }

/* бутонът „Изпрати“ — малко по-тъмен от останалите кехлибарени */
#send-btn { background: #b07a0c; }
#send-btn:hover { background: #c4890e; }

/* Wake-on-LAN в профила */
.wol-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: 13px; color: var(--muted); margin: -2px 0 10px; }
.wol-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wol-row input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.wol-mac {
  width: 160px; background: var(--bg); color: var(--text); border: 1px solid var(--card-border); border-radius: 7px;
  padding: 3px 8px; font: 12.5px var(--mono); outline: none;
}
.wol-mac:focus { border-color: var(--accent); }
.wol-ip { font: 12.5px var(--mono); color: var(--faint); }

/* ---------- Двуфакторен вход ---------- */
.totp-box { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.totp-box .hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.totp-state { color: var(--muted); }
.totp-state.on { color: var(--online); font-weight: 600; }
.totp-box > .btn-accent, .totp-box > .btn-ghost { align-self: flex-start; padding: 7px 14px; }
.totp-qr svg { width: 180px; height: 180px; background: #fff; border-radius: 8px; display: block; }
.totp-secret { font: 12px var(--mono); word-break: break-all; }
.totp-backup { margin: 0; background: var(--code-bg); border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; }
.totp-backup code { display: block; padding: 8px 12px; font: 13px/1.6 var(--mono); }
.totp-backup .copy {
  display: grid; place-items: center; width: 26px; height: 24px; padding: 0; color: var(--muted);
  background: var(--card); border: 1px solid var(--card-border); border-radius: 6px;
}
.totp-backup .copy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ■ — спиране на машина (в реда „мисли…“) */
.typing div { display: flex; align-items: center; gap: 6px; }
.typing .act { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stop-btn {
  display: grid; place-items: center; flex-shrink: 0; width: 20px; height: 20px; padding: 0; border-radius: 5px;
  background: rgba(229, 83, 75, .12); border: 1px solid rgba(229, 83, 75, .45); color: var(--danger);
}
.stop-btn:hover { background: rgba(229, 83, 75, .25); }
.stop-btn:disabled { opacity: .4; }
.stop-btn svg { width: 10px; height: 10px; fill: currentColor; }
