/* Diamond ELD Messenger — Telegram-inspired styling.
   Single stylesheet, inlined on demand. No build, no preprocessor.
   Dark theme only. (Light palette removed 2026-05-29 — it was never wired up
   by any JS and rendered broken if reached; see audit M finding.) */

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  /* Exact Telegram Web (k-version) dark palette. */
  --bg:              #0e1621;          /* deepest, layout root */
  --bg-elevated:     #17212b;          /* sidebar / headers */
  --bg-hover:        #202b36;          /* row hover */
  --bg-active:       #2b5278;          /* active chat row */
  --bg-chat:         #0e1621;          /* chat area bg */
  --bg-chat-pattern: #0e1621;
  --bg-input:        #242f3d;          /* input fields */
  --border:          #0e1621;          /* near-invisible between panels */
  --border-strong:   #243341;
  --text:            #ffffff;
  --text-secondary:  #aab2bd;
  --text-tertiary:   #8a9bb0;          /* lightened 2026-05-29: #708499 was 4.23:1
                                          on --bg-elevated (fails WCAG AA 4.5:1 for
                                          the metadata text it labels). #8a9bb0 = 5.7:1. */
  --accent:          #8774e1;          /* Telegram k-web purple-blue accent (newer) */
  --accent-hover:    #9683f0;
  --accent-soft:     rgba(135, 116, 225, 0.18);
  --bubble-out:      #2b5278;          /* outgoing — Telegram blue */
  --bubble-in:       #182533;          /* incoming — slightly elevated dark */
  --bubble-in-hover: #1d2c3a;
  --success:         #4dcd5e;
  --danger:          #e53935;
  --warning:         #f0ad4e;
  --online:          #4dcd5e;
  --shadow-sm:       0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg:       0 12px 40px rgba(0,0,0,0.45);
  --radius-sm:       6px;
  --radius:          10px;
  --radius-lg:       14px;
  --bubble-radius:   16px;
  --bubble-tail:     8px;
  --t-fast:          0.12s ease;
  --t:               0.18s ease;
  --font: 'Inter', 'Noto Sans Georgian', -apple-system, "Segoe UI", system-ui,
          "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", Roboto, Arial, sans-serif;
  --font-feat:       'cv11', 'ss03', 'ss04', 'cv02';
}

/* (Light theme palette removed 2026-05-29 — dead + broken; app is dark-only.) */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: var(--font-feat);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body { overflow: hidden; }

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ── SVG icons ──────────────────────────────────────────────────────── */
.icon { display: inline-block; flex-shrink: 0; vertical-align: middle; stroke: currentColor; }
.icon + span, span + .icon { margin-left: 6px; }
.icon-caret { opacity: 0.5; margin-left: 2px; }
.icon-btn, .btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0; border: 0; background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover, .btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active, .btn-icon:active { transform: scale(0.95); }
.composer-icon { color: var(--text-tertiary); }
.composer-icon:hover { color: var(--accent); background: var(--accent-soft); }

/* Scrollbars — subtle. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); background-clip: padding-box; }

/* Focus ring — modern, subtle */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible, .btn:focus-visible { outline-offset: 1px; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 0;
}

/* ── Login page ──────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.35);
}
.login-logo {
  width: 80px; height: 80px; margin: 0 auto 18px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  color: #fff;
}
.login-card h1 {
  margin: 0 0 6px; text-align: center; font-size: 18px; font-weight: 600;
}
.login-card .subtitle {
  margin: 0 0 26px; text-align: center; color: var(--text-secondary); font-size: 12px;
}
.login-card label {
  display: block; margin-bottom: 14px;
}
.login-card label .label-text {
  display: block; font-size: 11px; color: var(--text-secondary);
  margin-bottom: 4px;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button.primary {
  width: 100%; margin-top: 8px;
  padding: 11px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  transition: background 0.12s;
}
.login-card button.primary:hover { background: var(--accent-hover); }
.login-card button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-box {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(229, 57, 53, 0.12);
  border: 1px solid rgba(229, 57, 53, 0.35);
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
}

/* ── Main 3-column layout ────────────────────────────────────────────── */
.app {
  display: grid;
  /* 376 = 320px chat list (Telegram-width) + 56px folder rail */
  grid-template-columns: 376px 1fr 340px;
  height: 100vh;
}
/* Slim version strip at the top of the LEFT panel only (owner placement
   2026-06-14). Lives inside the app-nav flex column, so it spans just the
   sidebar, not the whole window. */
.app-version-bar {
  flex: 0 0 auto;
  height: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.app-nav {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
  position: relative;   /* anchor for the absolute corner mute toggle */
}
.app-main {
  background: var(--bg-chat);
  display: flex; flex-direction: column;
  min-height: 0;
  min-width: 0;       /* allow grid track to shrink — without this, a wide
                         message bubble pushes the right panel off-screen */
  overflow: hidden;   /* belt-and-suspenders against horizontal blowout */
}
.app-aside {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.app-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  position: relative;   /* anchor for the centered version pill */
}
.app-header h1 { margin: 0; font-size: 13px; font-weight: 600; }
.pill {
  background: var(--bg);
  color: var(--text-secondary);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
}
.header-actions { margin-left: auto; display: flex; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: rgba(239,79,79,0.32); }
.btn.danger:hover { background: rgba(239,79,79,0.12); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.btn-icon { padding: 0; width: 34px; height: 34px; border-radius: var(--radius-sm); }

/* Tabs inside the left panel */
.tabs {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
}
.tab-btn.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.tab-btn .pill {
  margin-left: 4px;
  background: var(--danger); color: #fff;
  padding: 0 6px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
}

/* Chat list */
.chat-search {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
/* Icon now lives inside .search-field so it tracks the input regardless of the
   private-toggle button on its left (which appears/hides per tab). */
.search-field { position: relative; flex: 1; min-width: 0; display: flex; }
.chat-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); display: flex; pointer-events: none;
}
/* Private-DM toggle button (left of the search field). */
.private-toggle { flex-shrink: 0; position: relative; }
.private-toggle.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.private-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px;
  border-radius: 999px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg-elevated);
}
.chat-search input {
  flex: 1; min-width: 0;
  padding: 9px 14px 9px 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  font-size: 12px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.chat-search input:focus { border-color: var(--accent); background: var(--bg-elevated); }
.chat-search input::placeholder { color: var(--text-tertiary); }
.chat-search button {
  flex-shrink: 0;
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ── Chat folders (Telegram-style left rail) ───────────────────────── */
.chats-area { display: flex; flex: 1; min-height: 0; }
.folder-rail {
  width: 72px; flex: 0 0 72px;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 0 44px;   /* bottom space reserved for the corner mute toggle */
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg); border-right: 1px solid var(--border);
}
.folder-rail::-webkit-scrollbar { width: 0; }
.rail-item {
  width: 66px; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: 0; border-radius: 10px;
  padding: 5px 2px; cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--t-fast);
}
.rail-item:hover { background: var(--bg-hover); }
.rail-item.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.rail-item.active .rail-label { color: var(--text); }
.rail-chip {
  position: relative;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 20px; line-height: 1;
  color: #94a3b8;            /* default (no-color) folder tint */
}
.rail-folder-svg { display: block; pointer-events: none; }
.rail-emoji { pointer-events: none; }
.rail-label {
  max-width: 64px; font-size: 10px; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-secondary);
}
/* "AI" printed on the folder body itself, centered, legible on any color */
.rail-ai-on-icon {
  position: absolute; left: 50%; top: 57%; transform: translate(-50%, -50%);
  font-size: 9px; font-weight: 800; letter-spacing: .02em; color: #fff;
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, .6); pointer-events: none;
}
.rail-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px;
  border-radius: 999px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.rail-add .rail-chip { font-size: 22px; border-style: dashed; border: 1px dashed var(--border); background: transparent; }

/* Folder manager: color dot in the list + swatch palette in the editor */
.folder-color-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--border); }
.folder-swatch-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.modal .folder-swatch {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; flex: 0 0 auto;
}
.modal .folder-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
.modal .folder-swatch-none {
  background: var(--bg-hover);
  background-image: linear-gradient(45deg, transparent 44%, var(--danger) 44%, var(--danger) 56%, transparent 56%);
}

/* folder manager + picker modal */
.folder-ai-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.folder-inline-check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; cursor: pointer; }
.folder-inline-check input { width: auto; margin: 0; flex: 0 0 auto; }
/* Scoped under .modal so it beats `.modal label{display:block}` +
   `.modal input{width:100%}` (which stack the checkbox above its label). */
.modal .folder-inline-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; cursor: pointer; }
.modal .folder-inline-check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.folder-list { max-height: 320px; overflow-y: auto; margin-bottom: 10px; }
.folder-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.folder-row-emoji { font-size: 18px; }
.folder-row-title { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.folder-row-actions { display: flex; gap: 2px; }
.folder-kind-pill { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--bg-hover); color: var(--text-secondary); }
.folder-kind-pill.ai { background: var(--accent-soft); color: var(--accent-hover); }
.folder-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin: 12px 0 4px; }
.folder-emoji-row { display: flex; gap: 10px; align-items: flex-end; }
.folder-chat-picker { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; }
/* Scoped under .modal so they beat the generic `.modal label`/`.modal input`
   rules (which would otherwise stack the row vertically + stretch the box). */
.modal .folder-pick-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 0; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.modal .folder-pick-row:last-child { border-bottom: none; }
.modal .folder-pick-row:hover { background: var(--bg-hover); }
.modal .folder-pick-row input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.modal .folder-pick-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  transition: background var(--t-fast);
  /* Virtualization via CSS — browser skips paint/layout for off-screen rows
     while keeping them in DOM (so search/filter still work without JS).
     contain-intrinsic-size hints the unrendered height so scrollbar stays
     accurate. Chrome 85+, Edge 85+, Safari 18+. Without this, full DOM
     paint for 1000+ chats causes scroll lag. */
  content-visibility: auto;
  contain-intrinsic-size: 0 62px;
  contain: layout style paint;
}
.chat-list-item:hover { background: var(--bg-hover); }
.chat-list-item.active {
  background: var(--bg-active);
  color: #fff;
}
.chat-list-item.active .chat-meta,
.chat-list-item.active .chat-preview { color: rgba(255,255,255,0.82); }
.chat-list-item.active .chat-avatar { box-shadow: 0 0 0 2px rgba(255,255,255,0.15); }
.chat-avatar {
  width: 46px; height: 46px; flex-shrink: 0;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600;
  font-size: 14px;
  position: relative; overflow: hidden;
}
/* Real Telegram chat photo overlaying the initials circle. On <img> error the
   element removes itself (JS) and the initials show through. */
.chat-avatar .avatar-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: inherit;
  background: inherit;
}
.chat-body { flex: 1; min-width: 0; }
.chat-top { display: flex; align-items: baseline; gap: 6px; }
.chat-title {
  font-weight: 500; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.chat-meta { font-size: 10px; color: var(--text-tertiary); flex-shrink: 0; }
.chat-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chat-preview {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px; font-weight: 600;
  min-width: 20px; text-align: center;
}
.badge.red { background: var(--danger); }

/* Chat view */
.chat-main-header {
  padding: 4px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  min-height: 0;
  /* The header has no JS kebab menu, so a long title + ~8 action buttons can
     overflow. The title (.chat-main-title) is flex:1 min-width:0 and ellipsizes;
     overflow:hidden here clips any residual button row instead of forcing the
     whole layout to scroll horizontally. Buttons keep their intrinsic size and
     stay flush-right. */
  overflow: hidden;
}
.chat-main-header .chat-avatar { width: 26px; height: 26px; font-size: 10px; flex-shrink: 0; }
.chat-main-header .btn { flex-shrink: 0; }
/* Clickable name+avatar region → opens the centered Chat-info modal. Sized to
   its content (avatar + name) — the hover/click area ends right after the name;
   margin-right:auto eats the free space so the action buttons stay flush-right. */
.chat-header-id {
  flex: 0 1 auto; min-width: 0; margin-right: auto;
  max-width: 55%;            /* cap: long names truncate; short names still hug */
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; border-radius: 8px; padding: 2px 4px;
}
.chat-header-id:hover { background: var(--bg-hover, rgba(255,255,255,0.04)); }
/* The title fills the (content- or cap-sized) region and truncates INSIDE it, so
   the button box hugs the visible text instead of reserving the full name width
   (a percentage max-width on .t only clipped visually → trailing gap). */
.chat-header-id .chat-main-title { flex: 1 1 auto; min-width: 0; }
.chat-header-id .chat-main-title .t { flex: 0 1 auto; min-width: 0; max-width: none; }
.chat-header-id .chat-main-title .s { flex-shrink: 0; }
/* One thin line: title + status side by side (owner 2026-06-03). */
.chat-main-title {
  flex: 1; min-width: 0;
  display: flex; align-items: baseline; gap: 8px;
  overflow: hidden;
}
.chat-main-title .t,
.chat-main-title .s {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-main-title .t { font-weight: 600; font-size: 13px; flex-shrink: 0; max-width: 60%; }
.chat-main-title .s { font-size: 11px; color: var(--text-secondary); }
/* Typing indicator no longer needs its own line — keep it inline, tiny. */
.chat-main-title .chat-typing { font-size: 11px; color: var(--text-secondary); }

.chat-main-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-main-wrap.drag-over::after {
  content: 'Drop to attach';
  position: absolute;
  inset: 0;
  background: rgba(51, 144, 236, 0.15);
  border: 2px dashed var(--accent);
  border-radius: 12px;
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
}
.jump-to-bottom {
  position: absolute;
  right: 18px;
  bottom: 88px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.1s, background 0.12s;
}
.jump-to-bottom:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.jump-to-bottom.visible { display: flex; }
.jump-to-bottom .jump-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

.msg-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px 24px 8px;
  display: flex; flex-direction: column;
  background: var(--bg-chat);
  position: relative; /* anchor for DnD overlay */
}
.msg-row { display: flex; margin-bottom: 4px; }
.msg-row.in  { justify-content: flex-start; }
.msg-row.out { justify-content: flex-end; }
.msg-bubble {
  background: var(--bubble-in);
  color: var(--text);
  padding: 7px 12px 6px;
  border-radius: 12px;
  max-width: 70%;
  min-width: 0;
  overflow-wrap: anywhere;  /* break absurdly long URLs / tokens */
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.msg-row.out .msg-bubble { background: var(--bubble-out); }
.msg-sender {
  font-size: 11px; font-weight: 600; color: var(--accent);
  margin-bottom: 2px;
}
.msg-time {
  display: inline-block; margin-left: 8px;
  color: var(--text-tertiary); font-size: 10px;
  vertical-align: bottom; float: right;
}
.msg-tick {
  display: inline-block; margin-left: 2px;
  font-size: 11px; line-height: 1;
  vertical-align: -1px;
  color: var(--text-tertiary);
}
.msg-tick.read { color: var(--accent); }
.msg-tick.failed { color: #ef4444; opacity: 1; font-weight: 700; }
.msg-media {
  margin: 2px 0 5px;
  border-radius: 10px; overflow: hidden;
  position: relative;          /* anchor for the download button */
  width: fit-content;          /* hug the image so the ⬇ sits on ITS corner */
  max-width: 100%;
}
/* Download-from-bubble button (owner 2026-06-08) — top-right over photos/videos,
   fades in on hover of the media. */
.msg-media .media-dl {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border-radius: 50%;
  opacity: 0; transition: opacity 0.12s, background 0.12s;
  cursor: pointer; z-index: 2;
}
.msg-media:hover .media-dl { opacity: 1; }
.msg-media .media-dl:hover { background: rgba(0, 0, 0, 0.75); }
/* Touch / no-hover devices: always show it. */
@media (hover: none) { .msg-media .media-dl { opacity: 0.85; } }
.msg-media img, .msg-media video {
  display: block;
  max-width: 260px; max-height: 320px;
  width: auto; height: auto;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.12s;
  /* Tell the browser to downsample aggressively so the paint is cheap. */
  image-rendering: auto;
}
.msg-media img:hover, .msg-media video:hover { filter: brightness(1.08); }
/* Emoji-only messages render large, Telegram-style (owner 2026-06-08). */
.msg-emoji-big {
  font-size: 40px;
  line-height: 1.15;
  display: inline-block;
}

/* Lightbox (full-screen media viewer) */
.lightbox-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox-content {
  max-width: 96vw; max-height: 96vh;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.lightbox-media {
  max-width: 96vw; max-height: 92vh;
  border-radius: 6px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 20px; font-weight: 400;
  cursor: pointer; transition: background 0.15s;
  z-index: 2;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }

/* Simple Telegram-style viewer top-right tools (download + close) */
.lightbox-tools {
  position: absolute; top: 16px; right: 20px;
  display: flex; gap: 8px; z-index: 3;
}
.lightbox-tool {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 18px; line-height: 1; text-decoration: none;
  cursor: pointer; transition: background 0.15s;
}
.lightbox-tool:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-audio { background: var(--bg-elevated); padding: 24px; border-radius: 12px; }
.lightbox-audio audio { min-width: 320px; }

/* ‹ › gallery navigation — flip between the photos/videos of a chat */
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.1); color: #fff;
  font-size: 30px; line-height: 1; cursor: pointer; user-select: none;
  transition: background 0.15s; z-index: 3;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-nav-prev { left: 20px; }
.lightbox-nav-next { right: 20px; }
@media (max-width: 600px) {
  .lightbox-nav { width: 40px; height: 40px; font-size: 24px; }
  .lightbox-nav-prev { left: 8px; }
  .lightbox-nav-next { right: 8px; }
}

/* ── Photo editor (photo-editor.js) ─────────────────────────────────── */
.pe-backdrop {
  position: fixed; inset: 0; z-index: 240;
  background: rgba(0, 0, 0, 0.94);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.pe-panel {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 96vw; max-height: 96vh;
}
.pe-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.pe-tools, .pe-xform, .pe-swatches { display: flex; align-items: center; gap: 6px; }
.pe-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.pe-tool {
  min-width: 36px; height: 36px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-size: 17px; line-height: 1; cursor: pointer; transition: all 0.12s;
}
.pe-tool:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.pe-tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pe-swatch {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.25); transition: transform 0.1s;
}
.pe-swatch:hover { transform: scale(1.12); }
.pe-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.pe-color-input {
  width: 30px; height: 30px; padding: 0; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); cursor: pointer;
}
.pe-size { width: 96px; accent-color: var(--accent); }
.pe-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.pe-canvas {
  max-width: 96vw; max-height: 74vh;
  border-radius: 6px; box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
  touch-action: none;
}
.pe-base { position: relative; }
.pe-overlay { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.pe-stage[data-tool="text"] .pe-overlay { cursor: text; }
.pe-stage[data-tool="crop"] .pe-overlay { cursor: crosshair; }
.pe-overlay { cursor: crosshair; }
.pe-footer { display: flex; align-items: center; gap: 10px; }
.pe-spacer { flex: 1; }
.pe-cropbar { display: flex; gap: 8px; }
.pe-text-input {
  position: fixed; z-index: 250; transform: translateY(-50%);
  min-width: 120px; padding: 4px 8px;
  background: rgba(0, 0, 0, 0.55); border: 1px dashed rgba(255, 255, 255, 0.7);
  border-radius: 6px; font: 600 18px Inter, system-ui, sans-serif;
  outline: none;
}

/* Inline tool bar inside the photo lightbox */
.lb-toolbar {
  position: absolute; left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  backdrop-filter: blur(12px);
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  z-index: 3;
  cursor: default;
}
.lb-toolbar .lb-btn {
  background: transparent; border: 0;
  color: #fff; font-size: 14px;
  padding: 6px 10px; border-radius: 6px;
  cursor: pointer; transition: background 0.12s;
  white-space: nowrap;
}
.lb-toolbar .lb-btn:hover { background: rgba(255,255,255,0.12); }
.lb-toolbar .lb-btn.primary {
  background: #3390ec; color: #fff;
  padding: 6px 14px; font-weight: 500;
}
.lb-toolbar .lb-btn.primary:hover { background: #4ba3ee; }
.lb-toolbar .lb-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.lb-toolbar .lb-div {
  width: 1px; height: 22px; margin: 0 4px;
  background: rgba(255,255,255,0.15);
}
.lb-toolbar .lb-slider {
  display: flex; align-items: center; gap: 4px;
  color: #fff; font-size: 13px; padding: 0 4px;
}
.lb-toolbar .lb-slider input[type="range"] {
  width: 80px; accent-color: #3390ec;
}
.lightbox-media {
  transition: transform 0.2s, filter 0.15s;
}

/* Canvas-based photo editor (base image + annotation overlay) */
.lb-canvas-wrap {
  position: relative;
  max-width: 92vw; max-height: 82vh;
  transition: transform 0.2s;
  transform-origin: center center;
  display: inline-block;
  line-height: 0;
}
.lb-canvas-base,
.lb-canvas-overlay {
  display: block;
  max-width: 92vw; max-height: 82vh;
  width: auto; height: auto;
  border-radius: 6px;
}
.lb-canvas-base { box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6); }
.lb-canvas-overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  touch-action: none;
}

/* Annotation toolbar state: selected tool, color swatches, width buttons */
.lb-toolbar .tool-btn.selected {
  background: rgba(51, 144, 236, 0.35);
  outline: 1px solid #3390ec;
}
.lb-toolbar .lb-colors {
  display: inline-flex; gap: 3px; align-items: center;
  margin: 0 4px;
}
.lb-toolbar .lb-colors button {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer; padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.lb-toolbar .lb-colors button:hover { transform: scale(1.15); }
.lb-toolbar .lb-colors button.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}
.lb-toolbar .lb-widths {
  display: inline-flex; gap: 2px; align-items: center;
  margin: 0 4px;
}
.lb-toolbar .lb-widths button {
  width: 28px; height: 28px; border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.lb-toolbar .lb-widths button span {
  display: block; border-radius: 50%; background: #fff;
}
.lb-toolbar .lb-widths button:hover { background: rgba(255, 255, 255, 0.08); }
.lb-toolbar .lb-widths button.selected {
  background: rgba(51, 144, 236, 0.3);
  border-color: #3390ec;
}

/* Document image preview (inside doc viewer) */
.doc-viewer .doc-imgbox {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #222; overflow: auto; padding: 16px;
}
.doc-viewer .doc-imgbox img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}

/* Document bubble: filename link + direct-download icon side by side */
.doc-row {
  display: inline-flex; align-items: stretch; gap: 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
}
.doc-row .doc-link {
  background: transparent; border: 0;
  padding: 8px 10px;
  font-size: 12px; color: var(--text);
  cursor: pointer; text-align: left;
  flex: 1;
}
.doc-row .doc-link:hover { background: rgba(255, 255, 255, 0.06); }
.doc-row .doc-dl {
  display: flex; align-items: center; justify-content: center;
  padding: 0 10px;
  background: transparent; border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  cursor: pointer; font-size: 14px;
  text-decoration: none;
}
.doc-row .doc-dl:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* Document viewer */
.doc-viewer {
  width: 90vw; height: 90vh;
  max-width: 1200px;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}
.doc-viewer .doc-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.doc-viewer .doc-name {
  flex: 1; font-weight: 500; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.doc-viewer .doc-frame {
  flex: 1; border: 0; width: 100%;
  background: #fff;
}
.doc-viewer .doc-text {
  flex: 1; margin: 0; padding: 16px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  overflow: auto; white-space: pre-wrap; word-wrap: break-word;
}
.doc-viewer .doc-fallback {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 40px;
  color: var(--text-secondary);
}
.doc-viewer .doc-fallback .doc-icon { font-size: 58px; margin-bottom: 16px; }
.doc-viewer .doc-fallback h3 { margin: 0 0 8px; color: var(--text); }
.doc-viewer .doc-fallback p { max-width: 360px; line-height: 1.5; font-size: 12px; }
.doc-viewer .doc-fallback code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
}

.msg-media audio { display: block; max-width: 300px; margin: 6px 0; }
/* Telegram-style voice player: round play/pause + waveform + time */
.voice-player { display: flex; align-items: center; gap: 10px; width: 240px; max-width: 100%; padding: 2px 0; }
.voice-player audio { display: none; }
.voice-play {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.voice-play:hover { filter: brightness(1.08); }
.voice-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.voice-wave { height: 26px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.voice-bar { flex: 1 1 0; min-width: 2px; max-width: 3px; background: var(--text-tertiary); border-radius: 2px; opacity: 0.45; }
.voice-bar.played { background: var(--accent); opacity: 1; }
.voice-time { font-size: 11px; color: var(--text-tertiary); line-height: 1; }
.msg-media .doc-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  font-size: 12px;
}

.composer {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}
.composer .composer-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.composer textarea {
  flex: 1;
  min-height: 22px; max-height: 180px;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 13px; line-height: 1.4;
  resize: none;
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer button.icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
}
.composer button.icon:hover { background: var(--bg-hover); color: var(--text); }
.composer button.send {
  background: var(--accent); color: #fff;
  border: 0; border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px; font-weight: 600;
}
.composer button.send:hover { background: var(--accent-hover); }

.empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 13px;
  padding: 24px; text-align: center;
}

/* ── Skeleton / shimmer loaders ─────────────────────────────────────────
   Lightweight placeholders the JS may render while chat list / messages load
   (replaces the bare "Loading messages…" text). Pure CSS; harmless if unused. */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: '';
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 50%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}
/* Chat-list placeholder row: avatar circle + two text lines */
.skeleton-chat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
}
.skeleton-chat-row .sk-avatar {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0;
}
.skeleton-chat-row .sk-lines { flex: 1; min-width: 0; }
.skeleton-chat-row .sk-line {
  height: 10px; border-radius: 4px; margin-bottom: 8px;
}
.skeleton-chat-row .sk-line.short { width: 45%; }
.skeleton-chat-row .sk-line.long  { width: 80%; margin-bottom: 0; }
/* Message-area placeholder bubbles */
.skeleton-msgs {
  flex: 1; display: flex; flex-direction: column; gap: 10px;
  padding: 16px 24px;
}
.skeleton-msgs .sk-bubble {
  height: 34px; border-radius: var(--bubble-radius);
  max-width: 60%;
}
.skeleton-msgs .sk-bubble.in  { align-self: flex-start; width: 48%; }
.skeleton-msgs .sk-bubble.out { align-self: flex-end;  width: 38%; }

/* Tasks / right aside */
.aside-header {
  /* uses .app-header base; just ensures pill+title get nice gap */
  gap: 8px;
}
.aside-header .pill {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.aside-section {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}
.aside-section h2 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  color: var(--text-secondary); font-weight: 600; letter-spacing: 0.04em;
}
.task-item {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}
.task-item.closed {
  opacity: 0.6;
}
.task-meta {
  font-size: 10px; color: var(--text-secondary);
  margin-top: 4px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.task-actions { margin-top: 8px; display: flex; gap: 6px; }

/* Schedule page */
.schedule-wrap {
  max-width: 960px; margin: 0 auto; padding: 24px; min-height: 100vh;
  overflow-y: auto;
}
.schedule-wrap h1 {
  font-size: 20px; font-weight: 600; margin: 0 0 4px;
}
.schedule-wrap .sub { color: var(--text-secondary); margin-bottom: 24px; font-size: 12px; }
.schedule-days { display: flex; flex-direction: column; gap: 8px; }
.schedule-day {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.08s;
}
.schedule-day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.15);
}
.schedule-day .date-col {
  min-width: 72px; text-align: center; flex-shrink: 0;
}
.schedule-day .dow {
  font-size: 10px; text-transform: uppercase; color: var(--text-secondary);
  font-weight: 600;
}
.schedule-day .dow.weekend { color: var(--danger); }
.schedule-day .dnum {
  font-size: 23px; font-weight: 600; line-height: 1;
}
.schedule-day .dmon { font-size: 10px; color: var(--text-secondary); }
.schedule-day .today-chip {
  display: inline-block; margin-top: 4px;
  background: var(--accent); color: #fff;
  padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
}
.schedule-day .shift-block {
  flex: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border-left: 4px solid transparent;
}
.schedule-day .shift-block.empty {
  border: 1px dashed var(--border);
  color: var(--text-tertiary);
  padding: 10px 14px;
}
.schedule-day .shift-emoji { font-size: 20px; }
.schedule-day .shift-meta .l { font-weight: 600; font-size: 13px; }
.schedule-day .shift-meta .r {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--text-secondary);
}

/* Shift picker grid (modal) */
.shift-picker {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (min-width: 560px) {
  .shift-picker { grid-template-columns: repeat(4, 1fr); }
}
.shift-card {
  padding: 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: left; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  color: var(--text);
}
.shift-card:hover { border-color: var(--text-secondary); }
.shift-card.active {
  background: rgba(51, 144, 236, 0.1);
}
.shift-card .top {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.shift-card .emoji { font-size: 20px; }
.shift-card .label { font-size: 13px; font-weight: 600; }
.shift-card .range {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--text-secondary);
}

/* Modal / backdrop */
.backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg-elevated);
  border-radius: 16px;
  padding: 24px;
  max-width: 460px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.modal label { display: block; margin-bottom: 12px; }
.modal label .label-text {
  display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: 4px;
}
.modal input, .modal textarea, .modal select {
  width: 100%; padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); font-size: 13px; outline: none;
}
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); }
.modal textarea { resize: vertical; min-height: 60px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

/* Incoming swap requests banner */
.alert-box {
  background: rgba(240, 173, 78, 0.08);
  border: 2px solid rgba(240, 173, 78, 0.4);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.alert-box h2 {
  margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--warning);
}
.swap-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.swap-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px; font-weight: 500;
}

/* Team grid */
.team-grid-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  margin-top: 16px;
}
.team-grid {
  border-collapse: separate; border-spacing: 0; width: 100%;
}
.team-grid th, .team-grid td {
  padding: 8px; border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.team-grid th {
  background: var(--bg-elevated);
  font-weight: 600; color: var(--text-secondary); text-align: center;
  position: sticky; top: 0; z-index: 2;
}
.team-grid .op-col {
  position: sticky; left: 0; background: var(--bg-elevated);
  text-align: left;
  min-width: 180px;
}
.team-grid .op-name { font-weight: 500; font-size: 12px; }
.team-grid .op-sub { color: var(--text-secondary); font-size: 10px; }
.team-grid .cell {
  width: 58px; text-align: center; padding: 0;
  border-left: 1px solid var(--border);
}
.team-grid .cell button {
  width: 100%; padding: 10px 0; border: 0;
  background: transparent; color: var(--text-tertiary);
  font-size: 11px; font-weight: 600;
}
.team-grid .cell button.filled {
  color: #fff;
}
.team-grid .cell button:hover { filter: brightness(1.15); }

/* User-menu button in app-header + dropdown */
.user-menu-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.1s, border-color 0.1s;
}
.user-menu-btn:hover { background: var(--bg-hover); }
.user-menu-btn .user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.user-menu-btn .user-name {
  max-width: 130px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 12px;
}
.user-menu-pop {
  position: fixed; z-index: 500;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: pop-in 0.14s ease;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.user-menu-pop button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent; border: 0;
  color: var(--text); text-align: left;
  border-radius: 6px;
  cursor: pointer; font-size: 12px;
}
.user-menu-pop button:hover { background: var(--bg-hover); }
.user-menu-pop button.danger { color: var(--danger); }

/* Sidebar list item: pin icon + trailing star */
.chat-list-item {
  position: relative;
}
.chat-list-item.pinned::after {
  content: '📌';
  position: absolute;
  right: 10px; bottom: 8px;
  font-size: 10px;
  opacity: 0.7;
}
.chat-list-item.muted .mute-marker {
  position: absolute;
  right: 30px; bottom: 8px;
  width: 14px; height: 14px;
  color: var(--text-tertiary);
  opacity: 0.85;
  pointer-events: none;
  display: inline-flex;
}
.chat-list-item.muted:not(.pinned) .mute-marker {
  right: 10px;
}
.chat-list-item.muted .mute-marker .icon { width: 14px; height: 14px; }
.list-item-menu-btn {
  position: absolute;
  right: 8px; bottom: 8px;
  width: 22px; height: 22px;
  padding: 0; border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  opacity: 0;
  border-radius: 50%;
  cursor: pointer;
}
.chat-list-item:hover .list-item-menu-btn { opacity: 0.7; }
.chat-list-item .list-item-menu-btn:hover { opacity: 1; background: rgba(0,0,0,0.2); }

/* Day separator between messages with different calendar dates */
.day-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 4px;
}
.day-sep span {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
/* Sender name above bubble (only on first message of a cluster) */
.msg-row .msg-sender-head {
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  margin: 0 0 2px 4px;
}
/* Operator attribution head on our own (right-aligned) messages. */
.msg-row.out .msg-op-head {
  text-align: right;
  margin: 0 4px 2px 0;
  opacity: 0.92;
}
/* Group incoming messages: avatar gutter on the left */
.msg-row.in.has-avatar { padding-left: 0; }
.msg-row .msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 600;
  margin-right: 6px;
  flex-shrink: 0;
  align-self: flex-end;
}
.msg-row.in.cluster-sibling { margin-left: 34px; }

/* Per-chat search bar at the top of msg-scroll */
.chat-search-bar {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-search-bar input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text);
  outline: none;
}
.chat-search-bar .match-count {
  font-size: 10px;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: right;
}
.msg-bubble.search-hit { outline: 2px solid var(--accent); }

/* Emoji picker popover */
.emoji-pop {
  position: fixed;
  z-index: 500;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.emoji-pop button {
  background: transparent; border: 0;
  font-size: 20px;
  padding: 3px;
  cursor: pointer;
  border-radius: 6px;
}
.emoji-pop button:hover { background: var(--bg-hover); }

/* Tombstone bubble, edited mark, reply-quote block inside a bubble */
.msg-bubble.deleted {
  background: transparent !important;
  border: 1px dashed var(--border);
  box-shadow: none;
  color: var(--text-secondary);
}
.msg-bubble .edited-mark {
  font-size: 10px;
  margin-left: 6px;
}
/* Driver edited their message — show the final version under the original. */
.msg-driver-edit {
  margin-top: 5px;
  padding: 4px 8px;
  border-left: 3px solid var(--accent, #f59e0b);
  background: rgba(245, 158, 11, 0.12);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.msg-driver-edit-label {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
}
.msg-driver-edit-text { font-size: inherit; white-space: pre-wrap; word-break: break-word; }
.msg-bubble .reply-quote {
  border-left: 3px solid var(--accent);
  background: rgba(51, 144, 236, 0.08);
  padding: 4px 8px;
  margin: 2px 0 6px;
  border-radius: 0 6px 6px 0;
}
.msg-bubble .reply-quote-label {
  font-size: 10px; color: var(--accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.msg-bubble .reply-quote-text {
  font-size: 11px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 260px;
}

/* Right-click context menu on messages + Reply bar inside composer */
/* ── Telegram-style message context menu ─────────────────────────────────
   A floating rounded reaction capsule ABOVE a separate menu box. The wrap is
   the positioned/clamped element; both children are independent "glass" pills
   with their own translucent background, blur and soft shadow. */
:root {
  --ctx-glass:  rgba(28, 38, 48, 0.92);   /* elevated glass surface */
  --ctx-edge:   rgba(255, 255, 255, 0.07); /* hairline top edge */
  --ctx-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.ctx-menu-wrap {
  position: fixed; z-index: 500;
  display: flex; flex-direction: row;     /* menu left, reaction rail right */
  align-items: flex-start;
  gap: 8px;
  transform-origin: top left;
  animation: ctxPop 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes ctxPop {
  from { opacity: 0; transform: scale(0.9) translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* Menu box */
.ctx-menu {
  min-width: 208px;
  background: var(--ctx-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--ctx-edge);
  border-radius: 14px;
  box-shadow: var(--ctx-shadow);
  padding: 6px;
  font-size: 13.5px;
  overflow: hidden;
}
.ctx-menu button {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; width: 100%;
  padding: 9px 14px;
  background: transparent; border: 0;
  color: var(--text); text-align: left;
  border-radius: 9px; cursor: pointer;
  font-size: 13.5px; line-height: 1.2;
  transition: background 0.12s;
}
.ctx-menu button:hover { background: var(--bg-hover); }
.ctx-menu button:active { background: var(--bg-active); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu .ctx-label { flex: 1 1 auto; }
.ctx-menu .ctx-icon {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.ctx-menu button.danger .ctx-icon { color: var(--danger); }
.ctx-menu button:hover .ctx-icon { color: var(--text); }
.ctx-menu button.danger:hover .ctx-icon { color: var(--danger); }
.ctx-menu .ctx-sep {
  height: 1px; background: var(--ctx-edge);
  margin: 5px 8px;
}

/* Reaction rail — a VERTICAL emoji column to the right of the menu. Its height
   is set inline (JS) to match the menu's height; the column scrolls vertically
   when there are more reactions than fit. */
.ctx-react-bar {
  display: flex; flex-direction: column;
  box-sizing: border-box;
  padding: 4px;
  background: var(--ctx-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--ctx-edge);
  border-radius: 24px;
  box-shadow: var(--ctx-shadow);
}
.ctx-react-scroll {
  display: flex; flex-direction: column; gap: 1px;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;                     /* Firefox: hide scrollbar */
  overscroll-behavior: contain;
}
.ctx-react-scroll::-webkit-scrollbar { display: none; } /* WebKit */
.ctx-react-bar button.ctx-react {
  flex: 0 0 auto;
  width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer;
  font-size: 23px; line-height: 1;
  border-radius: 50%;
  transition: transform 0.12s ease, background 0.12s ease;
  animation: reactIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
.ctx-react-bar button.ctx-react:hover {
  background: var(--bg-hover);
  transform: scale(1.22);
}
.ctx-react-bar button.ctx-react:active { transform: scale(1.05); }
@keyframes reactIn {
  from { opacity: 0; transform: scale(0.3) translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ctx-menu-wrap, .ctx-react-bar button.ctx-react, .hover-react-bar { animation: none; }
}

/* Hover-to-react capsule (Telegram-style): floats beside a message after a ~1s
   hover. VERTICAL glass rail with scroll (owner picked this look, Screenshot_32)
   reusing the .ctx-react emoji buttons. Height is capped → scrolls if it has
   more reactions than fit. */
.hover-react-bar {
  position: fixed; z-index: 480;
  display: flex; flex-direction: column;
  padding: 4px;
  background: var(--ctx-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--ctx-edge);
  border-radius: 24px;
  box-shadow: var(--ctx-shadow);
  animation: ctxPop 0.13s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.hover-react-bar .ctx-react-scroll {
  flex-direction: column;
  max-height: 280px;              /* ~7 emoji tall, then scroll */
  overflow-y: auto; overflow-x: hidden;
}
.hover-react-bar button.ctx-react {
  width: 38px; height: 38px; font-size: 22px;
  /* The transparent-bg rule above is scoped to .ctx-react-bar, so without this
     the hover capsule's buttons fell back to the browser's default grey button
     background (owner Screenshot_35). Make them transparent like the rail. */
  background: transparent; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: transform 0.12s ease, background 0.12s ease;
}
.hover-react-bar button.ctx-react:hover { background: var(--bg-hover); transform: scale(1.22); }

/* Clickable reply quote → jump to original, + the flash on arrival */
.msg-bubble .reply-quote.clickable { cursor: pointer; }
.msg-bubble .reply-quote.clickable:hover { background: rgba(51, 144, 236, 0.16); }
@keyframes msgFlash {
  0%   { background: rgba(51, 144, 236, 0.35); }
  100% { background: transparent; }
}
.msg-row.msg-flash .msg-bubble { animation: msgFlash 1.6s ease-out; }

/* Telegram pinned-message banner at the top of the chat */
.chat-pinned-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  cursor: pointer; min-height: 42px;
}
.chat-pinned-bar:hover { background: var(--bg-hover); }
.chat-pinned-bar .pinned-icon { color: var(--accent); font-size: 14px; flex-shrink: 0; }
.chat-pinned-bar .pinned-body { min-width: 0; flex: 1; }
/* Vertical segment indicator (one bar per pinned message, current highlighted) */
.chat-pinned-bar .pinned-segs {
  display: flex; flex-direction: column; gap: 2px;
  width: 3px; flex-shrink: 0; height: 28px;
}
.chat-pinned-bar .pinned-seg {
  flex: 1; min-height: 3px;
  background: rgba(255, 255, 255, 0.22); border-radius: 2px;
}
.chat-pinned-bar .pinned-seg.active { background: var(--accent); }
.chat-pinned-bar .pinned-unpin {
  flex-shrink: 0; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--text-secondary); cursor: pointer; font-size: 13px; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.chat-pinned-bar .pinned-unpin:hover { background: var(--bg-hover); color: var(--danger); }

/* ── Inline sticky notes (real yellow-paper look, in the timeline) ── */
.sticky-note-row { display: flex; justify-content: center; padding: 12px 14px; }
.sticky-note {
  position: relative;
  max-width: 300px; min-width: 130px;
  background: linear-gradient(165deg, #fff7ad 0%, #ffe879 100%);
  color: #4a3f1a;
  padding: 15px 16px 11px;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.22), 4px 7px 16px rgba(0,0,0,0.4);
  font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive, sans-serif;
}
.sticky-note.tilt-l { transform: rotate(-1.8deg); }
.sticky-note.tilt-r { transform: rotate(1.6deg); }
.sticky-note::before {           /* translucent "tape" strip at the top */
  content: ''; position: absolute; top: -7px; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 62px; height: 15px;
  background: rgba(255,255,255,0.42);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.sticky-note::after {            /* folded bottom-right corner */
  content: ''; position: absolute; right: 0; bottom: 0;
  border-width: 0 0 14px 14px; border-style: solid;
  border-color: transparent transparent rgba(0,0,0,0.13) transparent;
}
.sticky-note-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.45; }
.sticky-note-meta { margin-top: 8px; font-size: 10px; color: #8a7a33; }
.sticky-note-del {
  position: absolute; top: 3px; right: 5px;
  width: 18px; height: 18px; border: 0; background: transparent;
  color: #8a7a33; cursor: pointer; font-size: 12px; line-height: 1;
  opacity: 0; transition: opacity 0.12s;
}
.sticky-note:hover .sticky-note-del { opacity: 1; }
.sticky-note-del:hover { color: var(--danger); }

/* Yellow mini-composer above the message input */
.note-composer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin: 0 8px 6px;
  background: #fff3a8; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.note-composer.hidden { display: none; }
.note-composer-icon { font-size: 16px; flex-shrink: 0; }
/* Strong selector so the global dark textarea style doesn't win — a near-white
   paper field with dark ink, readable on the yellow bar. */
.note-composer textarea.note-input {
  flex: 1; resize: none; min-height: 34px; max-height: 120px;
  background: #fffdf2; color: #2a2410;
  border: 1px solid #d8c98a; border-radius: 6px;
  padding: 7px 10px; font-size: 13px; line-height: 1.4;
}
.note-composer textarea.note-input:focus { outline: none; border-color: #b89b3a; background: #fff; }
.note-composer textarea.note-input::placeholder { color: #9a8a45; opacity: 1; }
/* Buttons on the yellow bar: clear light "Cancel" + keep the purple "Add note". */
.note-composer > .btn {
  background: #fff; color: #4a3f1a; border: 1px solid #d8c98a; flex-shrink: 0;
}
.note-composer > .btn:hover { border-color: var(--accent); color: var(--accent); }
.note-composer > .btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.note-composer > .btn.primary:hover { background: var(--accent-hover); color: #fff; }
/* Operator-only PINNED notes pinned at the top of the chat (classic yellow). */
.pinned-note-bar {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.pinned-note-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 10px;
  background: #fff3a8; color: #2a2410;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  font-size: 12px; line-height: 1.35;
}
.pinned-note-ico { flex-shrink: 0; }
.pinned-note-body { flex: 1; white-space: pre-wrap; word-break: break-word; }
.pinned-note-del {
  flex-shrink: 0; border: 0; background: transparent; cursor: pointer;
  color: #6b5d1a; font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 4px;
}
.pinned-note-del:hover { background: rgba(0,0,0,0.12); }
.chat-pinned-bar .pinned-label { font-size: 11px; color: var(--accent); font-weight: 600; }
.chat-pinned-bar .pinned-text {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: rgba(51, 144, 236, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  margin-bottom: 6px;
}
.reply-bar .reply-body { flex: 1; min-width: 0; }
.reply-bar .reply-body .reply-label { font-size: 10px; color: var(--accent); font-weight: 600; }
.reply-bar .reply-body .reply-text {
  font-size: 12px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reply-bar .reply-close {
  background: transparent; border: 0; color: var(--text-secondary);
  cursor: pointer; font-size: 14px; padding: 4px 8px;
}
.reply-bar .reply-close:hover { color: var(--text); }

/* Forward modal — list of chats and contacts to pick as target */
.fwd-search {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  box-sizing: border-box;
}
.fwd-search:focus { outline: none; border-color: var(--accent); }
.fwd-list {
  max-height: 360px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}
.fwd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.08s;
}
.fwd-item:hover { background: var(--bg-hover); }
.fwd-item .fwd-title { flex: 1; font-size: 12px; }
.fwd-item .fwd-kind {
  font-size: 10px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Update centre (updates.js) ─────────────────────────────────────── */
.app-version-chip {
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  opacity: 0.85;
  white-space: nowrap;
  pointer-events: none;
}
/* Restart button — always present (manual restart); neon-yellow tint, and it
   pulses when an update is available / a restart is needed. */
.btn-restart { color: #facc15; }
.btn-restart.update-glow {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.6);
  background: rgba(250, 204, 21, 0.12);
  animation: upd-pulse 1.6s ease-in-out infinite;
}
@keyframes upd-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.0); }
  50%      { box-shadow: 0 0 10px 2px rgba(250, 204, 21, 0.55); }
}
.upd-backdrop {
  position: fixed; inset: 0; z-index: 260;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.upd-card {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5);
}
.upd-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.upd-spark { font-size: 30px; line-height: 1; }
.upd-title { font-size: 18px; font-weight: 700; }
.upd-ver { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.upd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upd-list li { display: flex; gap: 9px; font-size: 13.5px; line-height: 1.4; }
.upd-bullet { color: var(--accent); flex: 0 0 auto; }
.upd-empty { font-size: 13px; color: var(--text-secondary); }
.upd-note { margin-top: 14px; font-size: 12px; color: var(--text-secondary); }
.upd-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.upd-restart-btn { background: #facc15; border-color: #facc15; color: #1a1a1a; }
.upd-restart-btn:hover { background: #eab308; border-color: #eab308; }

/* Utility */
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--text-secondary); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.row { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }

/* ════════════════════════════════════════════════════════════════════════
   TELEGRAM WEB OVERRIDES — full visual port of Telegram Web (k-variant)
   Applied after the base sheet so it overrides where styles overlap.
   2026-05-16
   ════════════════════════════════════════════════════════════════════════ */

/* Border between columns nearly invisible (Telegram trick) */
.app-nav, .app-aside { border-color: rgba(255,255,255,0.04); }

/* Headers — sit flat, subtle bottom divider */
.app-header, .chat-main-header, .aside-header {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  background: var(--bg-elevated);
}

/* Chat list rows — Telegram Web exact */
.chat-list-item {
  padding: 9px 12px;
  gap: 12px;
  border-bottom: 0;
  position: relative;
}
.chat-list-item:hover { background: var(--bg-hover); }
.chat-list-item.active { background: var(--bg-active); }
.chat-list-item.active .chat-title,
.chat-list-item.active .chat-meta,
.chat-list-item.active .chat-preview { color: #fff !important; opacity: 0.95; }
.chat-list-item.active .badge { background: rgba(255,255,255,0.22); color: #fff; }
.chat-list-item.active .chat-avatar { box-shadow: none; }
.chat-avatar {
  width: 54px; height: 54px;
  font-size: 16px; font-weight: 500;
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  position: relative;
}
/* Online dot — JS toggles .online class on .chat-avatar */
.chat-avatar.online::after {
  content: '';
  position: absolute;
  right: 0; bottom: 1px;
  width: 12px; height: 12px;
  background: var(--online);
  border: 2.5px solid var(--bg-elevated);
  border-radius: 50%;
}
.chat-list-item.active .chat-avatar.online::after { border-color: var(--bg-active); }
.chat-title { font-size: 14px; font-weight: 500; }
.chat-meta { font-size: 11px; }
.chat-preview { font-size: 13.5px; line-height: 1.3; }
.chat-bottom { margin-top: 3px; }

/* Telegram bubbles with proper tail */
.msg-row { margin-bottom: 2px; }
.msg-row + .msg-row.same-author { margin-top: -2px; }
.msg-bubble {
  padding: 6px 9px 8px 11px;
  border-radius: var(--bubble-radius);
  font-size: 14.5px; line-height: 1.32;
  box-shadow: none;
  position: relative;
  max-width: min(560px, 70%);
}
/* Tail on last bubble of an author run */
.msg-row.in.tail .msg-bubble {
  border-bottom-left-radius: var(--bubble-tail);
}
.msg-row.out.tail .msg-bubble {
  border-bottom-right-radius: var(--bubble-tail);
}
.msg-row.in:not(.tail) .msg-bubble,
.msg-row.out:not(.tail) .msg-bubble { /* mid-run bubbles share corners */ }

/* Time/status overlay inside bubble (Telegram style) */
.msg-time {
  float: right;
  margin: 4px 0 -2px 8px;
  font-size: 11.5px;
  /* bumped 2026-05-29: 0.5 alpha was 3.93:1 on the in-bubble bg (fails AA). */
  color: rgba(255,255,255,0.6);
  line-height: 1;
  user-select: none;
}
.msg-row.out .msg-time { color: rgba(255,255,255,0.7); }
.msg-tick { color: inherit; opacity: 0.9; font-size: 12px; vertical-align: -1px; }
.msg-tick.read { color: #4fc3f7; opacity: 1; }
.msg-sender { font-size: 12px; font-weight: 600; margin-bottom: 1px; }

/* Day separator — centered floating pill */
.day-sep {
  align-self: center;
  margin: 10px auto;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255,255,255,0.85);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Composer — Telegram precise */
.composer {
  padding: 8px 16px 12px;
  background: var(--bg-elevated);
  border-top: 1px solid rgba(255,255,255,0.04);
  gap: 6px;
}
.composer textarea {
  background: var(--bg-input);
  border: 0;
  border-radius: 14px;
  padding: 11px 50px 11px 14px;
  font-size: 14.5px;
  color: var(--text);
  resize: none;
  min-height: 42px;
  flex: 1;
}
.composer textarea::placeholder { color: var(--text-tertiary); }
.composer textarea:focus { outline: 0; background: #2a3947; }
.composer .composer-icon { color: var(--text-tertiary); }
.composer .composer-icon:hover { color: var(--accent); background: transparent; }
/* Round send button on the right */
.composer .send-btn, .composer .btn.primary {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: transform var(--t-fast), background var(--t-fast);
}
.composer .send-btn:hover, .composer .btn.primary:hover {
  background: var(--accent-hover); transform: scale(1.05);
}
.composer .send-btn:active, .composer .btn.primary:active { transform: scale(0.95); }

/* Tabs — Telegram-ish minimal */
.tab-btn { padding: 14px 10px; font-size: 13px; }
.tab-btn.active::after { left: 18px; right: 18px; height: 3px; }

/* Selected chat in light bubble area: subtle Telegram pattern (very faint dots) */
.msg-scroll {
  padding: 16px 18px 8px;
  background:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,0.012) 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, rgba(255,255,255,0.012) 1px, transparent 1px),
    var(--bg-chat);
  background-size: 80px 80px, 80px 80px;
}

/* Sender name color hash — used by JS when adding .author-N */
.author-1 { color: #ff8e6e; } .author-2 { color: #ffd266; }
.author-3 { color: #5ad88c; } .author-4 { color: #5cc7e2; }
.author-5 { color: #b18cff; } .author-6 { color: #ff8eb0; }
.author-7 { color: #4bd99c; } .author-8 { color: #ffb56b; }

/* Pill in aside header — soft accent */
.aside-header .pill {
  padding: 1px 9px; font-size: 11px;
}

/* App version label at bottom of sidebar */
.app-version {
  /* Now only holds the PWA "Install app" button (name/version/changelog
     removed per owner). Hidden until the install button is actually shown,
     so the sidebar bottom stays clean. */
  display: none;
  padding: 6px 14px;
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.04);
  user-select: none;
}
.app-version:has(.install-btn:not(.hidden)) { display: flex; }
.app-version .v-link { color: inherit; text-decoration: underline dotted; cursor: pointer; }

/* (Light-theme overrides removed 2026-05-29 along with the light palette.) */

/* Install-app button in sidebar footer */
.install-btn {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  margin-right: 8px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.install-btn:hover { background: var(--accent-hover); }
.app-version:has(.install-btn:not(.hidden)) { align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }

/* ── Bottom-left global "mute all sounds" toggle ─────────────────────── */
/* Mute toggle now lives in the header actions row next to Notes + Mark-all-read
   (owner 2026-06-05). Sized to match .btn.btn-icon (34×34). Tooltip carries the
   on/off meaning; muted state shows a red bell-off sign. */
.mute-all-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.mute-all-btn:hover { background: rgba(255,255,255,0.04); color: var(--text-primary, #fff); }
.mute-all-btn .mute-all-ico { display: inline-flex; }
.mute-all-btn .mute-all-txt { display: none; }   /* icon-only corner sign */
/* Muted state — the "sign": red bell-off + tinted square so operators can see
   at a glance that all sounds are off. */
.mute-all-btn.muted {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(229, 57, 53, 0.12);
}
.mute-all-btn.muted:hover { background: rgba(229, 57, 53, 0.20); color: var(--danger); }

/* ── Optimistic / pending outgoing-message UI ───────────────────────── */
.msg-bubble.pending { opacity: 0.85; }
.msg-bubble.pending .msg-time { color: rgba(255,255,255,0.55); }
.pending-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.45));
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 6px 8px; gap: 6px;
  border-radius: 8px;
  pointer-events: none;
}
.pending-label { color: #fff; font-size: 10px; font-weight: 500; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.pending-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pending-clock { display: inline-block; }

.msg-bubble.failed {
  background: rgba(229, 57, 53, 0.16) !important;
  border: 1px solid rgba(229, 57, 53, 0.5);
}
.msg-failed-bar {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--danger);
  display: flex; align-items: center; flex-wrap: wrap;
}
.msg-failed-bar button { margin-left: auto; }

/* ── Floating "Report a problem" button + modal ─────────────────────── */
#report-fab {
  position: fixed;
  right: 18px; bottom: 18px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--warning);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 800;
  transition: transform 0.15s, background 0.12s, color 0.12s;
}
#report-fab:hover { transform: translateY(-2px); background: var(--warning); color: var(--bg); }
#report-fab:active { transform: scale(0.95); }

/* (Removed: .report-backdrop / .report-modal / .report-title / .report-head /
    .report-close / .report-sub / .report-toggle / .report-stats / .report-actions
    were for the original two-step modal — replaced by the in-place success
    card in 1.0.0-beta.8. CSS audit 1.0.0-beta.10.) */

/* ── Report toast + note banner ───────────────────────────────────── */
#report-fab.sending { animation: pulse-warn 1s ease-in-out infinite; }
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 4px 24px rgba(240, 173, 78, 0.7); }
}

.report-toast {
  position: fixed;
  right: 18px; bottom: 76px;
  z-index: 1100;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 12px; font-weight: 500;
  max-width: 340px;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.report-toast.show { opacity: 1; transform: none; }
.report-toast.ok { border-left: 3px solid var(--success); }
.report-toast.bad { border-left: 3px solid var(--danger); color: var(--danger); }

.report-note {
  position: fixed;
  right: 18px; bottom: 76px;
  z-index: 1090;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 320px;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.report-note.show { opacity: 1; transform: none; }
.report-note-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-bottom: 4px;
}
.report-note-ok { color: var(--success); }
.report-note-sub {
  font-size: 11px; color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.35;
}
.report-note-close { cursor: pointer; color: var(--text-tertiary); font-size: 13px; padding: 0 4px; }
.report-note-close:hover { color: var(--text); }
.report-note textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 12px;
  resize: vertical;
}
.report-note textarea:focus { border-color: var(--accent); outline: 0; }
.report-note-send {
  margin-top: 8px;
  width: 100%;
  padding: 6px 10px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.report-note-send:hover { background: var(--accent-hover); }

/* ── Internal notes panel ───────────────────────────────────────────── */
.notes-panel-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: stretch; justify-content: flex-end;
}
.notes-panel {
  width: 100%; max-width: 420px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-strong);
  display: flex; flex-direction: column;
  animation: slide-in 0.18s ease;
}
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0.4; }
  to   { transform: none; opacity: 1; }
}
.notes-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.notes-panel-title { font-size: 13px; font-weight: 600; }
.notes-panel-close {
  background: transparent; border: 0; color: var(--text-secondary);
  font-size: 14px; padding: 4px 8px; cursor: pointer;
}
.notes-panel-close:hover { color: var(--text); }
.notes-panel-list { flex: 1; overflow-y: auto; padding: 10px 14px; }
.note-item {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.note-item.pinned { border-left: 3px solid var(--warning); }
.note-body { font-size: 12px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.note-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; color: var(--text-tertiary);
  margin-top: 6px;
}
.note-meta button.note-del {
  margin-left: auto; background: transparent; border: 0;
  color: var(--text-tertiary); cursor: pointer; font-size: 12px;
}
.note-meta button.note-del:hover { color: var(--danger); }
.notes-panel-input {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.notes-panel-input textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 12px;
  resize: vertical;
}
.notes-panel-input textarea:focus { border-color: var(--accent); outline: 0; }

/* Author color hash for group-chat sender names */
.author-1 { color: #ff8e6e; }
.author-2 { color: #ffd266; }
.author-3 { color: #5ad88c; }
.author-4 { color: #5cc7e2; }
.author-5 { color: #b18cff; }
.author-6 { color: #ff8eb0; }
.author-7 { color: #4bd99c; }
.author-8 { color: #ffb56b; }

/* ── Quickjump (Ctrl+K) ─────────────────────────────────────────── */
.qj-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  backdrop-filter: blur(2px);
}
.qj-box {
  width: 540px; max-width: 90vw; max-height: 70vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.qj-input {
  width: 100%; padding: 14px 18px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.qj-input:focus { outline: 0; }
.qj-input::placeholder { color: var(--text-tertiary); }
.qj-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 4px 0;
}
.qj-empty { padding: 18px; text-align: center; color: var(--text-tertiary); font-size: 12px; }
.qj-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: pointer;
}
.qj-row.active { background: var(--bg-active); color: #fff; }
.qj-row.active .qj-sub { color: rgba(255,255,255,0.82); }
.qj-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.qj-body { flex: 1; min-width: 0; }
.qj-title {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qj-sub { font-size: 10px; color: var(--text-tertiary); margin-top: 1px; }
.qj-hint {
  padding: 6px 14px;
  font-size: 10px; color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── Chat snooze indicator (status open/waiting/resolved removed 2026-06-04) ── */
.chat-list-item.snoozed { opacity: 0.5; }
.chat-list-item.snoozed .chat-title::after {
  content: ' 💤'; font-size: 10px;
}

/* ── Profile panel (chat info) ──────────────────────────────────── */
.profile-panel-body { padding: 12px 14px; overflow-y: auto; }
.profile-hero {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.profile-hero-meta { flex: 1; min-width: 0; }
.profile-hero-title {
  font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-hero-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* Telegram-style centered group profile (owner 2026-06-07) */
.profile-hero.centered {
  flex-direction: column; align-items: center; text-align: center;
  gap: 8px; padding: 8px 0 16px;
}
.profile-hero.centered .profile-avatar { width: 84px; height: 84px; font-size: 28px; position: relative; overflow: hidden; }
.profile-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.profile-hero.centered .profile-hero-title { font-size: 18px; white-space: normal; }
.profile-actions-row { display: flex; gap: 8px; margin-bottom: 14px; }
.profile-action {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-secondary); cursor: pointer;
  font-size: 11px; transition: background var(--t-fast), color var(--t-fast);
}
.profile-action:hover { background: var(--bg-hover); color: var(--text); }
.profile-action.active { color: var(--accent); }
.profile-action .pa-ico { font-size: 18px; line-height: 1; }
/* Members list */
.profile-members { margin-bottom: 16px; }
.profile-members-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; letter-spacing: .04em; color: var(--text-secondary);
  text-transform: uppercase; padding: 4px 2px 6px;
}
.profile-members-add {
  width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-size: 18px; line-height: 1;
}
.profile-members-add:hover { background: var(--accent); color: #fff; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.member-av {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.member-main { flex: 1; min-width: 0; }
.member-name { font-size: 13px; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-bot { font-size: 9px; background: var(--bg-hover); color: var(--text-secondary); padding: 0 5px; border-radius: 6px; text-transform: uppercase; }
.member-status { font-size: 11px; color: var(--text-tertiary); }
.member-status.online { color: var(--accent); }
.member-role { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--bg-hover); color: var(--text-secondary); }
.member-role.owner { background: var(--accent-soft); color: var(--accent); }
/* "More" popover */
.profile-more-menu {
  position: fixed; z-index: 320; min-width: 200px;
  background: var(--bg-elevated, var(--bg)); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px; box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
.profile-more-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; background: none; border: 0; border-radius: 7px;
  color: var(--text); font-size: 13px; text-align: left; cursor: pointer;
}
.profile-more-item:hover { background: var(--bg-hover); }
.profile-more-item.danger { color: var(--danger); }
.profile-more-item .pm-ico { width: 18px; text-align: center; }

/* Group settings editor */
.ge-head { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.ge-photo {
  width: 72px; height: 72px; border-radius: 50%; flex: 0 0 auto; cursor: pointer;
  position: relative; overflow: hidden; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
}
.ge-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ge-photo-cam {
  position: relative; z-index: 1; font-size: 22px;
  background: rgba(0,0,0,0.35); width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.ge-rows { margin: 10px 0 4px; border-top: 1px solid var(--border); }
.ge-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 4px; background: none; border: 0; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 13px; text-align: left; cursor: pointer;
}
.ge-row:hover { background: var(--bg-hover); }
.ge-row-ico { width: 20px; text-align: center; }
.ge-row-label { flex: 1; }
.ge-row-val { color: var(--accent); font-size: 12px; }
.ge-row-arrow { color: var(--text-tertiary); font-size: 16px; }
.perm-list { max-height: 360px; overflow-y: auto; margin: 4px 0 10px; }
/* Clickable member row (Members & admins → tap to open rights) */
.tg-member-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 6px; background: none; border: 0; border-bottom: 1px solid var(--border);
  color: var(--text); text-align: left; cursor: pointer; font-size: 13px;
}
.tg-member-row:hover { background: var(--bg-hover); }
.tg-member-row.static { cursor: default; }
.tg-member-row.static:hover { background: none; }
.tg-member-row .member-av { width: 34px; height: 34px; }
.profile-stats {
  margin-bottom: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.profile-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.profile-stat-row:last-child { border-bottom: 0; }
.profile-stat-label { color: var(--text-tertiary); }
.profile-stat-value {
  color: var(--text); font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 60%;
}
.profile-section-head {
  font-size: 10px; text-transform: uppercase; color: var(--text-tertiary);
  letter-spacing: 0.05em; margin-bottom: 8px;
}
.profile-media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.profile-media-tile {
  aspect-ratio: 1; background-size: cover; background-position: center;
  background-color: var(--bg);
  border-radius: 6px; cursor: pointer;
  position: relative;
  transition: transform var(--t-fast);
}
.profile-media-tile:hover { transform: scale(1.04); }
.profile-media-badge {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0,0,0,0.65); color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
}

/* ── Media tabs (Photos / Video / Files) in the chat-info modal ──── */
/* Link-preview card (self-generated, Telegram-style) under a message bubble */
.link-preview {
  display: block; margin-top: 6px; max-width: 320px;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.05);
  border-radius: 6px; overflow: hidden;
  text-decoration: none; color: inherit; cursor: pointer;
}
.link-preview:hover { background: rgba(255,255,255,0.09); }
.link-preview .lp-img {
  width: 100%; max-height: 180px; object-fit: cover; display: block;
}
.link-preview-body { padding: 6px 10px; }
.lp-site { font-size: 11px; color: var(--accent); font-weight: 600; }
.lp-title { font-size: 13px; font-weight: 600; margin-top: 2px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Clickable links inside message bubbles */
.msg-link {
  color: #6ab7ff; text-decoration: underline;
  text-underline-offset: 2px; word-break: break-word;
}
.msg-link:hover { color: #8fcaff; }
.msg-row.mine .msg-link { color: #cfe8ff; }

.profile-media-tabs {
  display: flex; gap: 4px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.profile-media-tab {
  flex: 1; background: transparent; border: 0;
  color: var(--text-secondary);
  padding: 8px 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; position: relative; transition: color 0.12s;
}
.profile-media-tab:hover { color: var(--text); }
.profile-media-tab.active { color: var(--accent); }
.profile-media-tab.active::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
}
.profile-members-toggle {
  width: 100%; margin-top: 4px; padding: 8px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--accent); font-size: 12px; font-weight: 600;
  border-radius: 8px; transition: background var(--t-fast);
}
.profile-members-toggle:hover { background: var(--bg); }

.profile-media-body { min-height: 60px; }
/* video tiles show the generated frame thumbnail (dark fallback behind it) with
   a play glyph overlaid in the centre */
.profile-media-tile.is-video { background-color: #1c1f24; }
.profile-media-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #fff; font-size: 18px; opacity: 0.95;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8); pointer-events: none;
}

/* File list (documents tab) */
.profile-file-list { display: flex; flex-direction: column; gap: 2px; }
.profile-file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: 8px; cursor: pointer;
  transition: background var(--t-fast);
}
.profile-file-row:hover { background: var(--bg); }
.profile-file-icon {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-radius: 8px; font-size: 16px;
  overflow: hidden;
}
.profile-file-icon.has-thumb { background: #1c1f24; }
.profile-file-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-file-main { min-width: 0; flex: 1; }
.profile-file-name {
  font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-file-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Centered Chat-info modal (2 pages, owner 2026-06-04) ──────── */
.profile-modal { position: relative; max-width: 420px; }
.profile-modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: 0; cursor: pointer;
  color: var(--text-tertiary); font-size: 16px; line-height: 1;
  padding: 4px; border-radius: 6px;
}
.profile-modal-close:hover { color: var(--text); background: var(--bg-hover, rgba(255,255,255,0.06)); }
/* Admin actions — inline list at the TOP of the Chat-info menu; separated from
   the stats below by a margin + divider. */
.profile-manage-list {
  display: flex; flex-direction: column; gap: 8px;
  margin: 14px 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.profile-manage-item {
  width: 100%; text-align: left;
  padding: 12px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
  color: var(--text); font-size: 13px;
}
.profile-manage-item:hover { border-color: var(--accent); background: var(--bg-hover, rgba(255,255,255,0.04)); }
.profile-manage-item.danger { color: #ef5350; }
.profile-manage-item.danger:hover { border-color: #ef5350; }

/* ── Inline message edit ──────────────────────────────────────── */
.msg-bubble.editing { padding: 8px; }
.msg-edit-ta {
  width: 100%; min-width: 240px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-family: inherit; font-size: 13px;
  resize: vertical;
}
.msg-edit-ta:focus { outline: 0; border-color: var(--accent); }
.msg-edit-bar { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.msg-edit-hint { color: var(--text-tertiary); font-size: 10px; margin-left: auto; }

/* ── Pinned message indicator ──────────────────────────────────── */
.msg-row.pinned-msg .msg-bubble::before {
  content: '📌'; position: absolute; top: -8px; left: -8px;
  font-size: 13px; opacity: 0.9;
}

/* ── Chat tag pills ─────────────────────────────────────────────── */
.chat-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.chat-tag-pill {
  background: rgba(91, 141, 239, 0.15);
  color: var(--accent);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
}
.chat-list-item.active .chat-tag-pill {
  background: rgba(255,255,255,0.18); color: #fff;
}
.chat-ai-tags {
  display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap;
}
.chat-ai-tag-pill {
  background: rgba(168, 85, 247, 0.14);
  color: #c4a7f7;
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.chat-list-item.active .chat-ai-tag-pill {
  background: rgba(255,255,255,0.18); color: #fff;
}

/* ── Message reactions pills (under bubble) ─────────────────────── */
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.msg-reaction-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  background: rgba(91, 141, 239, 0.12);
  border: 1px solid rgba(91, 141, 239, 0.25);
  border-radius: 10px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast);
}
.msg-reaction-pill:hover { background: rgba(91, 141, 239, 0.22); }
.msg-reaction-pill.chosen {
  background: rgba(91, 141, 239, 0.4);
  border-color: var(--accent);
}
.msg-reaction-emoji { font-size: 13px; line-height: 1; }
.msg-reaction-count { font-variant-numeric: tabular-nums; font-weight: 500; }
.msg-row.out .msg-reactions { justify-content: flex-end; }

/* ── Voice recording inline UI ──────────────────────────────────── */
.voice-rec-box {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; background: rgba(255, 75, 75, 0.10);
  border: 1px solid rgba(255, 75, 75, 0.35); border-radius: 8px;
}
.voice-rec-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ff4b4b;
  animation: voicePulse 1s ease-in-out infinite;
}
@keyframes voicePulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}
.voice-rec-timer {
  font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--text);
}

/* ── Typing indicator in chat header ────────────────────────────── */
.chat-typing {
  font-size: 10px; color: var(--accent);
  font-style: italic;
  margin-top: 1px;
  height: 14px;
  transition: opacity var(--t-fast);
}
.chat-typing:empty { height: 0; }

/* ── Bulk select ───────────────────────────────────────────────── */
.msg-row.selected .msg-bubble {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.msg-row.selected::before {
  content: '☑';
  position: absolute;
  left: -22px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 14px;
}
.msg-row { position: relative; }
.bulk-action-bar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  display: flex; gap: 8px; align-items: center;
  z-index: 100;
}
.bulk-count { font-weight: 600; font-size: 12px; margin-right: 8px; }

/* ── Task driver_category badge ────────────────────────────────── */
.task-category-pill {
  display: inline-block;
  background: rgba(91, 141, 239, 0.18);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 8px;
  margin-left: 6px;
  letter-spacing: 0.02em;
}
.task-category-pending {
  display: inline-block;
  font-size: 10px;
  margin-left: 6px;
  opacity: 0.7;
}
/* AI-guessed category — same shape as driver-picked but cooler palette so
   you can tell at a glance whether a human confirmed it or a model guessed. */
.task-category-pill.ai {
  background: rgba(168, 85, 247, 0.18);
  color: #c4a7f7;
}
/* AI urgency pills. Only HIGH and CRITICAL render — low/medium stay clean. */
.task-urgency-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  margin-left: 6px;
  letter-spacing: 0.04em;
}
.task-urgency-pill.high {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}
.task-urgency-pill.critical {
  background: rgba(220, 38, 38, 0.20);
  color: #fca5a5;
  animation: pulseCritical 1.4s infinite ease-in-out;
}
@keyframes pulseCritical {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ── AI summary card at top of chat (Feature 2) ──────────────────── */
.ai-summary-card {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.10), rgba(91, 141, 239, 0.08));
  border: 1px solid rgba(168, 85, 247, 0.30);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 14px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}
.ai-summary-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c4a7f7;
  font-weight: 700;
  margin-bottom: 4px;
}
.ai-summary-icon { font-size: 12px; }
.ai-summary-cached {
  background: rgba(168, 85, 247, 0.18);
  color: #c4a7f7;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ai-summary-body {
  color: var(--text);
  white-space: pre-line;
}

/* (AI reply-suggestion composer styles removed — feature deleted 2026-06-03.) */
/* (AI photo-tag pill styles removed 2026-06-07 — photo tagging deleted.) */

/* AI summary refresh button */
.ai-summary-refresh {
  background: none;
  border: none;
  color: #c4a7f7;
  cursor: pointer;
  font-size: 12px;
  margin-left: auto;
  padding: 0 4px;
  opacity: 0.7;
  transition: opacity 0.12s, transform 0.3s;
}
.ai-summary-refresh:hover { opacity: 1; transform: rotate(120deg); }

/* AI feedback thumbs on task card */
.task-ai-feedback {
  display: inline-flex;
  gap: 2px;
  margin-left: 6px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.task-item:hover .task-ai-feedback { opacity: 1; }
.task-ai-fb {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1;
}
.task-ai-fb:hover { background: rgba(168, 85, 247, 0.18); }
.task-ai-fb.voted { opacity: 0.4; cursor: default; }

/* ── Tasks panel scroll (right aside body) ─────────────────────── */
.tasks-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 14px;
}
.tasks-scroll .task-item:last-child { margin-bottom: 0; }

/* ── Closed-tasks slide-out (toggled by 📁 in tasks header) ──────── */
.aside-header .archive-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  /* Override the fixed 34×34 square from .btn.btn-icon — this button holds an
     icon + a count pill, so it must size to its content. */
  width: auto;
  height: auto;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.aside-header .archive-toggle.active {
  background: var(--accent-soft);
  color: var(--accent);
}
#closed-tasks-panel {
  position: fixed;
  top: 0; bottom: 0;
  right: 340px;             /* sits to the LEFT of the .app-aside (340px wide) */
  width: 340px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 12px rgba(0,0,0,0.25);
}
.closed-panel-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; min-height: 56px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.closed-panel-scroll {
  flex: 1; overflow-y: auto;
  padding: 14px;
}
.closed-panel-scroll .task-item:last-child { margin-bottom: 0; }

/* ── Task age timer + escalated red marker ──────────────────────── */
.task-age {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-secondary);
}
.task-age.escalated {
  color: var(--danger);
  font-weight: 700;
}
.task-escalated-badge {
  color: var(--danger);
  font-weight: 700;
  letter-spacing: 0.04em;
  animation: pulseRed 1.5s ease-in-out infinite;
}
@keyframes pulseRed {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
/* Missed tasks no longer redden the whole row (owner directive 2026-05-28):
   only the 🔴 NEEDS ATTENTION badge + the red age timer remain. The .escalated
   class stays on the row purely as a marker for the missed-banner scroll-to. */

/* ── Task-gated chat curtain ────────────────────────────────────── */
.chat-curtain {
  position: absolute; inset: 0;
  background: rgba(15, 20, 25, 0.78);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 30;
  /* sits inside .chat-main-wrap which is position:relative */
}
.chat-curtain-card {
  max-width: 420px;
  padding: 28px 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.chat-curtain-title {
  font-size: 14px; font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.chat-curtain-sub {
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.45;
}
.chat-curtain-actions {
  display: flex; gap: 8px; justify-content: center;
}
.chat-curtain-actions .btn.disabled,
.chat-curtain-actions .btn[disabled] {
  opacity: 0.45; cursor: not-allowed;
}
/* Sidebar section header — e.g. "⚡ Active tasks" pinned above the chat list. */
.chat-section-header {
  padding: 9px 14px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-secondary);
  background: var(--bg);
}
.chat-section-header.dim { opacity: 0.55; font-weight: 600; }
/* (AI driver-rating avatar ring styles removed 2026-06-07 — feature deleted.) */
/* Telegram service/system message — centered grey notice in the timeline. */
.service-msg-row { display: flex; justify-content: center; margin: 6px 0; }
.service-msg {
  font-size: 11px; color: var(--text-secondary);
  background: rgba(0,0,0,0.20);
  padding: 3px 12px; border-radius: 10px;
  max-width: 80%; text-align: center; line-height: 1.35;
}
/* Chat-header ⋮ overflow menu (secondary actions). */
.hdr-menu-wrap { position: relative; display: inline-flex; }
.hdr-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; min-width: 180px; z-index: 50; padding: 4px;
}
.hdr-menu.hidden { display: none; }
.hdr-menu-item {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; color: var(--text);
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  text-align: left; font-size: 13px; white-space: nowrap;
}
.hdr-menu-item:hover { background: var(--bg-hover); }
.hdr-menu-item.danger { color: var(--danger); }
/* Read-only overlay over the composer (write gated). The read-only note and an
   optional action button (e.g. "Start working") sit side by side at the bottom. */
.composer-lock {
  position: absolute; inset: 0;
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 0 14px;
  font-size: 11px; color: var(--text-secondary);
  cursor: not-allowed; z-index: 5;
}
.composer-lock-text { line-height: 1.3; }
.composer-lock .btn { cursor: pointer; flex-shrink: 0; }
/* Undo the round 44×44 send-button styling that ".composer .btn.primary"
   forces on any primary button inside the composer — the gate button must look
   exactly like the rectangular "Take" button in the Tasks panel (plain .btn.primary). */
.composer-lock .btn.primary {
  width: auto; height: auto;
  border-radius: var(--radius);
  padding: 7px 13px;
  font-size: 11px; font-weight: 500;
  border: 1px solid var(--accent);
}
/* Session bar at top of chat-main-wrap when operator has an active task */
.task-session-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  background: rgba(91, 198, 132, 0.10);
  border-bottom: 1px solid rgba(91, 198, 132, 0.35);
  font-size: 11px;
}
.task-session-timer {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  color: var(--accent);
}
.task-session-timer.expiring {
  color: var(--danger);
  animation: pulseRed 1s ease-in-out infinite;
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE LAYOUT (2026-05-29, audit M1)
   Desktop (>900px) is unchanged: the fixed 3-column grid above still applies.
   Below that we progressively collapse so the app is usable on tablets/phones
   (the PWA invites phone install). No JS is involved, so the chat column and
   its composer must stay reachable purely via CSS reflow.
   ════════════════════════════════════════════════════════════════════════ */

/* ≤900px — tablet: drop the 340px tasks rail (3rd column).
   .app-aside is the tasks rail (#tasks). Grid becomes 320px + 1fr. */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 376px 1fr;
  }
  .app-aside {
    display: none;
  }
  /* The closed-tasks slide-out anchored to the (now-hidden) 340px rail would
     float in empty space — pin it to the right edge instead. */
  #closed-tasks-panel {
    right: 0;
  }
}

/* ≤600px — phone: single column. Stack the chat list above the chat view and
   let each scroll internally. .app switches from grid to a vertical flex so the
   chat column keeps its own flex layout (header / scroll / composer) and the
   composer stays pinned at the bottom of the chat pane — never pushed off-screen.
   The sidebar is capped to ~40% height with its own scroll; no horizontal
   overflow because nothing keeps a fixed pixel width. */
@media (max-width: 600px) {
  .app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;        /* avoid the mobile URL-bar gap eating the composer */
  }
  .app-nav {
    flex: 0 0 42vh;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--border-strong);
  }
  .app-main {
    flex: 1 1 auto;
    min-height: 0;
  }
  /* Header buttons in app-header / chat-main-header wrap rather than clip on
     the narrowest screens, so the user menu and key actions stay tappable. */
  .header-actions { gap: 4px; }
  .chat-main-header { gap: 8px; padding: 10px 12px; }
  .msg-scroll { padding: 12px 12px 8px; }
  .composer { padding: 8px 10px 10px; }
  .msg-bubble { max-width: 85%; }
}

/* ── Shared-contact card (message_type='contact') ─────────────────────── */
.msg-bubble.contact-card { min-width: 256px; max-width: 320px; padding: 10px 12px; }
.contact-card-main { display: flex; gap: 11px; align-items: center; }
.contact-card-info { min-width: 0; flex: 1; }
.contact-card-name {
  font-weight: 600; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-card-phone {
  font-size: 13px; color: var(--text-dim, var(--muted)); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-card-actions {
  display: flex; gap: 6px; margin-top: 9px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.contact-card-btn {
  flex: 1; background: transparent; border: none; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap;
  padding: 7px 6px; border-radius: 7px; transition: background var(--t-fast);
}
.contact-card-btn:hover { background: var(--accent-soft); }

/* ── Contact profile panel (Telegram-style, centered) ────────────────── */
.contact-profile { max-width: 380px; }
.cp-head { text-align: center; padding: 8px 0 2px; }
.cp-head .chat-avatar { margin: 0 auto 12px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); }
.cp-name { font-size: 19px; font-weight: 700; color: var(--text); line-height: 1.2; }
.cp-status { font-size: 12.5px; color: var(--text-dim, var(--muted)); margin-top: 3px; min-height: 16px; }
.contact-profile .contact-profile-actions { display: flex; gap: 8px; margin: 16px 0 10px; }
.cp-action {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: var(--bg-input, rgba(255, 255, 255, 0.04)); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 4px; cursor: pointer;
  color: var(--accent); font-size: 11px; font-weight: 600; white-space: nowrap;
  transition: background var(--t-fast), transform var(--t-fast);
}
.cp-action:hover { background: var(--accent-soft); transform: translateY(-1px); }
.cp-action .cp-ico { font-size: 19px; line-height: 1; }
.contact-profile-info { margin-top: 6px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cp-row { padding: 10px 12px; }
.cp-row + .cp-row { border-top: 1px solid var(--border); }
.cp-val { font-size: 14px; color: var(--text); word-break: break-word; }
.cp-label { font-size: 11px; color: var(--text-dim, var(--muted)); margin-top: 2px; }
.cp-notes-wrap { margin-top: 12px; }
.cp-notes {
  width: 100%; resize: vertical; min-height: 44px; font: inherit;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 8px 10px;
}

/* ── Program feedback survey (feedback.js) ──────────────────────────────── */
.fb-modal { max-width: 380px; }
.fb-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 10px 0;
}
.fb-row-label { font-size: 14px; color: var(--text); }
.fb-stars { display: inline-flex; gap: 4px; }
.fb-star {
  font-size: 26px; line-height: 1; cursor: pointer; user-select: none;
  color: var(--border-strong); transition: color .08s, transform .08s;
}
.fb-star:hover { transform: scale(1.12); }
.fb-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.fb-star.on { color: #f5c518; }
.fb-comment {
  width: 100%; resize: vertical; min-height: 40px; margin-top: 4px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
  font: inherit;
}

/* ── @-mention picker (composer.js wireMentions) ────────────────────────── */
.mention-pop {
  position: fixed; z-index: 200; min-width: 220px; max-width: 320px;
  max-height: 256px; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.45); padding: 4px;
}
.mention-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer; line-height: 1.2;
}
.mention-item.active, .mention-item:hover { background: var(--accent-soft); }
.mention-name { color: var(--text); font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.mention-uname { color: var(--text-tertiary); font-size: 12px; }
