/* Raptor: chat-style layout in a modern blue, matching the logo's navy (#010f23). */
:root {
  --brand-navy: #010f23;
  --radius: 12px;
  --accent: #1a6dff;
  --accent-strong: #0c56d8;
  --accent-fill: #1a6dff; /* filled buttons and badges: white text stays readable */
  --accent-soft: #e2ecff;
  --bg: #e8eef8;
  --panel: #ffffff;
  --panel-2: #f1f5fb;
  --line: #dfe6f1;
  --text: #0a1628;
  --muted: #5c6c84;
  --bubble-in: #ffffff;
  --bubble-out: #d8e7ff;
  --wallpaper: #edf2fa;
  --file-bg: rgb(10 40 90 / 6%);
  --track: rgb(10 40 90 / 12%);
  --danger: #d6304f;
  --attention: #1a6dff;
  --online: #22c55e;
  --tick-read: #1a8cff;
  --notice-bg: #fff6d8;
  --notice-fg: #574500;
  --toast-bg: #0b1d3a;
  --shadow: 0 1px 2px rgb(10 30 70 / 10%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #3d9bff;
    --accent-strong: #66b2ff;
    --accent-fill: #1f6fe6;
    --accent-soft: #0e2a52;
    --bg: #010a18;
    --panel: #061428;
    --panel-2: #0b1d36;
    --line: #142a47;
    --text: #e5eefc;
    --muted: #8a9cb8;
    --bubble-in: #0b1d36;
    --bubble-out: #0b3d80;
    --wallpaper: #020c1c;
    --file-bg: rgb(140 190 255 / 8%);
    --track: rgb(140 190 255 / 16%);
    --danger: #ff5f7a;
    --attention: #5aaeff;
    --online: #34d399;
    --tick-read: #66c2ff;
    --notice-bg: #2a2410;
    --notice-fg: #f3e2a0;
    --toast-bg: #0e2547;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --accent: #3d9bff;
  --accent-strong: #66b2ff;
  --accent-fill: #1f6fe6;
  --accent-soft: #0e2a52;
  --bg: #010a18;
  --panel: #061428;
  --panel-2: #0b1d36;
  --line: #142a47;
  --text: #e5eefc;
  --muted: #8a9cb8;
  --bubble-in: #0b1d36;
  --bubble-out: #0b3d80;
  --wallpaper: #020c1c;
  --file-bg: rgb(140 190 255 / 8%);
  --track: rgb(140 190 255 / 16%);
  --danger: #ff5f7a;
  --attention: #5aaeff;
  --online: #34d399;
  --tick-read: #66c2ff;
  --notice-bg: #2a2410;
  --notice-fg: #f3e2a0;
  --toast-bg: #0e2547;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* Space taken by the phone's status bar and gesture bar. The page draws edge to edge
   (viewport-fit=cover); the Android app also passes the sizes in as --safe-area-inset-*. */
:root {
  --inset-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --inset-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
}
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "HarmonyOS Sans", "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.04em; }
.error-text { color: var(--danger); min-height: 1.2em; margin: 4px 0; font-size: 14px; }
.bad { color: var(--danger); }
.attention { color: var(--attention); font-weight: 600; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 16px; font-weight: 500;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; }
.or-line { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.chat-head { position: relative; }
.select-bar { position: absolute; inset: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel-2); z-index: 2; }
.select-bar strong { flex: 1; font-size: 16px; }
.select-bar .btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.select-bar .btn.danger:disabled { opacity: 0.45; }
.select-bar .btn svg { margin-right: 2px; }
.messages.selecting .msg { cursor: pointer; user-select: none; }
.messages.selecting .msg * { pointer-events: none; }
.bubble { position: relative; }
.msg-select { position: absolute; top: 8px; right: 8px; z-index: 1; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: var(--panel); opacity: 0; cursor: pointer; transition: opacity 0.12s; }
@media (hover: hover) { .msg:hover .msg-select { opacity: 0.9; } }
.messages.selecting .msg-select { opacity: 1; }
.msg.selected .msg-select { display: none; }
.msg.selected .bubble { outline: 3px solid var(--accent); outline-offset: 2px; position: relative; }
.msg.selected .bubble::after { content: '✓'; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 13px/22px sans-serif; text-align: center; }
.stack-buttons { display: grid; gap: 8px; margin-top: 12px; }
.stack-buttons .btn.wide { margin-top: 0; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.device-card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.device-card:last-child { border-bottom: 0; padding-bottom: 4px; }
.device-card-head { display: flex; align-items: center; gap: 12px; }
.device-card-info { min-width: 0; flex: 1; display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; row-gap: 2px; }
.device-card-info strong { font-size: 16px; overflow-wrap: anywhere; }
.device-card-info small { flex-basis: 100%; color: var(--muted); }
.device-card-info .code { letter-spacing: 0.04em; }
.this-chip { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent-strong); }
.device-card-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; padding-left: 56px; }
.device-card-actions .btn { padding: 6px 4px; white-space: nowrap; }
.avatar.device svg { width: 56%; height: 56%; }
.avatar.photo { overflow: visible; background: var(--panel-2); }
.avatar.photo img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.emoji { font-size: 1.45em; line-height: 1; }
.profile-row { display: flex; align-items: center; gap: 14px; margin: 6px 0 8px; }
.profile-row .avatar { width: 64px; height: 64px; font-size: 20px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-actions .btn svg { width: 16px; height: 16px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 4px 0 8px; }
.emoji-pick { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-size: 22px; cursor: pointer; }
.emoji-pick:hover { border-color: var(--accent); }
.status-chip.st-removed { background: var(--track); color: var(--muted); }
.chat-item.removed .name, .chat-item.removed .preview { color: var(--muted); }
.chat-item.removed .avatar, .chat-head.removed .avatar { filter: grayscale(1); opacity: 0.55; }
.chat-head.removed .chat-title strong { color: var(--muted); }
.removed-text { color: var(--danger); }
.mine-chip { flex: none; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent-strong); }
.forgot-link { display: block; margin: -2px 0 0 auto; font-size: 13px; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; font-weight: 600; }
.google-slot { display: flex; justify-content: center; min-height: 44px; }
.handoff-code { margin: 8px 0 14px; font: 700 34px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.12em; text-align: center; }
.notice-text { padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); line-height: 1.5; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: none; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.code-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; letter-spacing: 0.12em; text-align: center; }

/* ---------- title screens: sign-in, setup, server (Raptor palette, same in light and dark) ---------- */
.center-screen {
  /* Prussian Blue #000022, Deep Navy #001242, Ocean Blue #0094C6, Baltic Blue #005E7C, Ink Black #040F16 */
  --prussian: #000022; --deep-navy: #001242; --ocean: #0094c6; --baltic: #005e7c; --ink: #040f16;
  --panel: rgb(4 15 22 / 78%); --panel-2: var(--prussian); --line: #12364d;
  --text: #e8f3fa; --muted: #93b4c6; --accent: var(--ocean); --accent-strong: #36b3e0;
  --accent-fill: #007ba7; /* Ocean Blue, deepened so white text keeps 4.5:1 contrast */
  --accent-soft: #002c44; --danger: #ff8193; --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; color: var(--text);
  padding: calc(24px + var(--inset-top)) 16px calc(24px + var(--inset-bottom)); box-sizing: border-box;
  background:
    radial-gradient(90% 60% at 50% -10%, rgb(0 148 198 / 28%), transparent 60%),
    radial-gradient(70% 50% at 100% 100%, rgb(0 94 124 / 30%), transparent 70%),
    linear-gradient(180deg, var(--deep-navy) 0%, var(--prussian) 100%);
}
.brand-logo { display: block; width: 100%; height: auto; }
.card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px 24px; box-shadow: 0 24px 60px rgb(0 0 0 / 45%); backdrop-filter: blur(14px);
}
.center-screen .brand-logo { width: min(300px, 82%); margin: 4px auto 0; }
.center-screen input, .center-screen select { background: var(--prussian); border-color: var(--line); color: var(--text); }
.center-screen input::placeholder { color: #5f8196; }
.center-screen .btn { background: transparent; border-color: var(--line); color: var(--text); }
.center-screen .btn.primary { background: var(--ocean); border-color: var(--ocean); color: #fff; font-weight: 700; font-size: 16px; letter-spacing: 0.01em; padding: 12px 16px; box-shadow: 0 2px 8px rgb(0 148 198 / 30%); }
.center-screen .btn.primary:hover { background: #00a6dc; border-color: #00a6dc; filter: none; }
.center-screen .btn.primary:active { background: #0083b0; }
.center-screen .btn.link { color: var(--accent); border: 0; }
.center-screen .error-text { color: var(--danger); }
.brand { text-align: center; }
.brand h1 { margin: 14px 0 4px; font-size: 24px; letter-spacing: 0.01em; }
.brand p { color: var(--muted); margin: 14px 0 18px; }
.tabs { display: flex; background: var(--panel-2); border-radius: 999px; padding: 4px; margin-bottom: 4px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 999px; font-weight: 500; color: var(--muted); }
.segmented { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
/* Title screens: a crisp two-way switch and a solid, sharp primary button. */
.center-screen .tabs { background: rgb(255 255 255 / 6%); border: 1px solid rgb(255 255 255 / 12%); padding: 3px; margin-bottom: 8px; }
.center-screen .tabs button { padding: 10px 8px; font-size: 15px; font-weight: 600; color: #b9d0de; cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.center-screen .tabs button:hover { color: #fff; }
.center-screen .tabs button[aria-selected="true"] { background: #fff; color: var(--deep-navy); box-shadow: 0 1px 3px rgb(0 0 0 / 35%); }
.center-screen .tabs button:focus-visible, .center-screen .btn:focus-visible { outline: 2px solid var(--ocean); outline-offset: 2px; }
.divider { display: flex; align-items: center; gap: 8px; margin: 20px 0 8px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.device-pick, .device-list { list-style: none; margin: 0; padding: 0; }
.device-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: none; padding: 10px 8px; border-radius: 8px;
}
button.device-row:hover { background: var(--panel-2); }
.device-row span:not(.avatar) { display: flex; flex-direction: column; min-width: 0; }
.device-row small { color: var(--muted); }
.device-row.static { border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.device-list .device-row > span:nth-child(2) { flex: 1; }
.row-actions { display: flex !important; flex-direction: row !important; gap: 6px; flex-wrap: wrap; }

/* ---------- main layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(300px, 30%) 1fr; height: 100vh; height: 100dvh;
  box-sizing: border-box; padding-top: var(--inset-top); padding-bottom: var(--inset-bottom);
  max-width: 1600px; margin: 0 auto; background: var(--panel); overflow: hidden;
}
/* Wide browser windows: a framed app in the middle of the page. The apps fill their window. */
@media (min-width: 1440px) {
  html:not([data-platform]) .layout { height: calc(100dvh - 38px); margin: 19px auto; box-shadow: 0 6px 18px rgb(0 0 0 / 10%); }
}
html[data-platform] .layout { max-width: none; }
/* Only the chat list and the conversation scroll, never the page around them. */
html:has(.layout), html:has(.layout) body { overflow: hidden; }

.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; min-height: 0; }
.side-head, .chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; background: var(--panel-2); min-height: 60px;
}
.me { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; min-width: 0; flex: 1; text-align: left; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); }
.head-actions { display: flex; gap: 2px; }
.conn-banner { display: none; background: #ffd279; color: #3b2b00; padding: 8px 16px; font-size: 13px; }
.conn-banner.show { display: block; }
.conn-banner .btn.link { color: inherit; text-decoration: underline; }
.search { display: flex; align-items: center; gap: 8px; margin: 8px 12px; padding: 0 12px; background: var(--panel-2); border-radius: 8px; color: var(--muted); }
.search input { border: 0; background: none; margin: 0; padding: 8px 0; }
.search input:focus { outline: none; }

.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left;
  padding: 0 0 0 14px; height: 72px;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--panel-2); }
.chat-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px;
  height: 100%; border-bottom: 1px solid var(--line); padding-right: 14px; }
.chat-item .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chat-item .name { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-item .time { color: var(--muted); font-size: 12px; flex: none; }
.preview { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 3px; min-width: 0; }
.preview > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--accent-fill); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px; display: grid; place-items: center; flex: none; }
.trust-ic { color: var(--accent); display: inline-flex; }
.pin-ic { color: var(--muted); display: inline-flex; flex: none; }
.pin-ic svg { width: 16px; height: 16px; transform: rotate(45deg); }
.icon-btn.pinned { color: var(--accent); }
.list-empty { padding: 32px 24px; text-align: center; color: var(--muted); }

.avatar {
  position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 16px;
}
.side-head .avatar, .chat-head .avatar { width: 40px; height: 40px; font-size: 14px; }
.online-dot { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--online); border: 2px solid var(--panel); }

/* ---------- chat pane ---------- */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wallpaper); }
.chat-empty { margin: auto; max-width: 460px; text-align: center; padding: 24px; color: var(--muted); }
.chat-empty .brand-logo {
  width: min(380px, 90%); margin: 0 auto; padding: 28px 34px; border-radius: 20px; box-sizing: border-box;
  background: linear-gradient(180deg, #001242, #000022); box-shadow: 0 12px 40px rgb(0 0 34 / 30%);
}
.chat-empty h2 { color: var(--text); font-weight: 300; font-size: 30px; margin: 12px 0; }
.my-code { margin: 24px auto; padding: 14px 20px; border-radius: 12px; background: var(--panel); display: inline-flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.my-code strong { color: var(--text); font-size: 26px; }

.chat-head .back { display: none; }
.chat-title { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; display: flex; flex-direction: column; }
.chat-title strong { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-text { color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.trusted { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.notice { display: none; padding: 10px 16px; background: var(--notice-bg); color: var(--notice-fg); font-size: 13.5px; border-bottom: 1px solid var(--line); }
.notice.show { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.messages { flex: 1; overflow-y: auto; padding: 16px 6% 12px; display: flex; flex-direction: column; gap: 4px; }
.system-note { align-self: center; margin: 12px; padding: 6px 12px; border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 13px; box-shadow: var(--shadow); text-align: center; display: flex; align-items: center; gap: 6px; }
.system-note svg { width: 16px; height: 16px; }
.day-sep { align-self: center; margin: 10px 0 6px; }
.day-sep span { background: var(--panel); color: var(--muted); padding: 5px 12px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow); }

.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.bubble {
  position: relative; max-width: min(380px, 78%); min-width: 240px; padding: 6px 8px 4px; border-radius: var(--radius);
  background: var(--bubble-in); box-shadow: var(--shadow);
}
.msg.in .bubble { border-top-left-radius: 2px; }
.msg.out .bubble { background: var(--bubble-out); border-top-right-radius: 2px; }
.thumb img { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.file { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; background: var(--file-bg); }
.file-icon { color: var(--accent); display: grid; }
.msg.out .file-icon { color: var(--accent-strong); }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-meta strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta small { color: var(--muted); font-size: 12px; }
.status { font-size: 13.5px; margin: 6px 2px 0; }
.progress { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; margin: 4px 0; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.15s; }
.progress-text { font-size: 12.5px; color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.tick { display: inline-flex; color: var(--muted); }
.tick.done { color: var(--tick-read); }
.tick.bad { color: var(--danger); }

.composer { padding: 8px 12px; background: var(--panel-2); }
.composer-bar { display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 4px; }
.composer-bar .attach { flex: none; width: 42px; height: 42px; border-radius: 50%; color: var(--muted); }
.composer-hint { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 10px 4px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font: inherit; }
.send-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent-fill); color: #fff; cursor: pointer; transition: opacity 0.15s, transform 0.1s; }
.send-btn:disabled { background: var(--track); color: var(--muted); cursor: default; }
.send-btn:not(:disabled):active { transform: scale(0.94); }
.staging { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 2px; background: var(--panel-2); border-top: 1px solid var(--line); }
.staging[hidden] { display: none; }
.staged { position: relative; flex: none; width: 116px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.staged img, .staged video, .staged-icon { display: grid; place-items: center; width: 100%; height: 76px; object-fit: cover; background: var(--file-bg); color: var(--accent); }
.staged img.page { object-position: top; background: #fff; }
.staged-icon svg { width: 34px; height: 34px; }
.staged-text { display: grid; padding: 6px 8px 8px; font-size: 12px; }
.staged-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.staged-text small { color: var(--muted); }
.staged-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; display: grid; place-items: center; background: rgb(0 0 0 / 55%); color: #fff; cursor: pointer; }
.staged-remove svg { width: 14px; height: 14px; }
.drop-overlay { display: none; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); border: 3px dashed var(--accent); place-items: center; z-index: 5; }
.drop-overlay div { background: var(--panel); padding: 16px 24px; border-radius: 12px; font-weight: 500; box-shadow: var(--shadow); }
.drop-overlay.show { display: grid; }

/* ---------- dialogs, menu, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 45%); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: 0 12px 40px rgb(0 0 0 / 25%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 4px 20px; }
.modal h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 0 20px 20px; }
.info { text-align: center; }
.info .avatar { width: 88px; height: 88px; font-size: 30px; margin: 8px auto; }
.info .code.big { font-size: 22px; margin: 4px 0; }
.info form { text-align: left; }
.menu { position: fixed; z-index: 30; width: 220px; background: var(--panel); border-radius: 10px; padding: 6px 0; box-shadow: 0 8px 24px rgb(0 0 0 / 22%); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 18px; }
.menu button:hover { background: var(--panel-2); }
.menu button.danger { color: var(--danger); }
.composer.blocked-bar { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 14px; }
.menu-note { padding: 8px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 4px 0; font-size: 13px; }
.menu-note small { color: var(--muted); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--toast-bg); color: #fff; padding: 10px 18px; border-radius: 8px; max-width: calc(100vw - 32px);
  transition: opacity 0.2s, transform 0.2s; z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- phones: one pane at a time ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .layout .chat { display: none; }
  .layout.chat-open .sidebar { display: none; }
  .layout.chat-open .chat { display: flex; }
  .chat-head { padding-left: 4px; }
  .chat-head .back { display: inline-grid; }
  .messages { padding: 12px 10px; }
  .bubble { min-width: 0; max-width: 88%; }
  .pill { display: none; }
  .composer-hint .muted { display: none; }
}

/* ---------- settings, banners ---------- */
.folder-banner { display: none; background: var(--accent-soft); padding: 8px 16px; font-size: 13px; align-items: center; gap: 10px; flex-wrap: wrap; }
.folder-banner.show { display: flex; }
.setting { border-top: 1px solid var(--line); padding: 12px 0; }
.setting:first-child { border-top: 0; }
.setting h3 { margin: 0 0 4px; font-size: 15px; }
.setting-value { margin: 6px 0; font-weight: 500; word-break: break-all; }
.setting .btn { margin: 4px 6px 0 0; }
.saved-to { color: var(--muted); font-size: 12.5px; }

/* ---------- device status: on Wi-Fi / online / offline ---------- */
.online-dot.wifi { background: var(--accent-fill); }
.status-chip {
  display: inline-flex; align-items: center; gap: 3px; flex: none; margin-left: auto; margin-right: 8px;
  padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
}
.status-chip svg { width: 12px; height: 12px; }
.status-chip.st-wifi { background: var(--accent-soft); color: var(--accent); }
.status-chip.st-online { background: color-mix(in srgb, var(--online) 16%, transparent); color: color-mix(in srgb, var(--online) 75%, var(--text)); }
.status-chip.st-offline { background: var(--panel-2); color: var(--muted); }
.chat-item .row .name { min-width: 0; }
.filters { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.filter {
  display: inline-flex; align-items: center; gap: 5px; flex: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 13px;
}
.filter svg { width: 13px; height: 13px; }
.filter .count { font-size: 11.5px; opacity: 0.8; }
.filter.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

/* ---------- search results ---------- */
.list-section { padding: 12px 16px 4px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.file-result { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 0 0 0 18px; height: 64px; }
.file-result:hover { background: var(--panel-2); }
.file-result .file-icon { color: var(--accent); }
.msg.flash .bubble { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
@media (prefers-reduced-motion: reduce) { .msg.flash .bubble { animation: none; outline: 3px solid var(--accent); } }

/* ---------- file previews ---------- */
.thumb { position: relative; margin-bottom: 6px; border-radius: 8px; overflow: hidden; }
.thumb[role="button"] { cursor: zoom-in; }
.thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb.loading { min-height: 120px; background: var(--file-bg); }
.thumb img, .thumb video { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: 8px; margin: 0; }
.thumb .pdf-page { max-height: 230px; object-fit: cover; object-position: top; background: #fff; border: 1px solid var(--line); }
.thumb .office-thumb { object-fit: contain; background: #fff; border: 1px solid var(--line); }
.thumb audio { width: 100%; }
.thumb-caption {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: rgb(1 15 35 / 72%); color: #fff;
}
.play-badge {
  position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; background: rgb(1 15 35 / 60%);
}
.play-badge::after { content: ""; position: absolute; left: 21px; top: 15px; border: 11px solid transparent; border-left: 17px solid #fff; }
.text-snippet {
  margin: 0; padding: 10px 12px; max-height: 190px; overflow: hidden; border-radius: 8px; background: var(--file-bg);
  font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.doc-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 34px; border-radius: 8px; background: #fff; color: #1b2433;
  border: 1px solid var(--line); font-size: 12.5px; overflow: hidden;
}
.doc-card strong { font-size: 15px; line-height: 1.25; color: #0a1628; }
.doc-card span { color: #4a5568; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card.doc-slide { aspect-ratio: 16 / 9; justify-content: center; text-align: center; padding: 16px; background: linear-gradient(160deg, #ffffff, #eaf1ff); }
.doc-card.doc-slide strong { font-size: 18px; }
.doc-card.large { padding: 24px; font-size: 14px; }
.doc-card.large span { white-space: normal; }

.modal.wide { max-width: min(960px, 100%); }
.preview-body { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 120px; }
.preview-body .pdf-full-page { max-width: 100%; height: auto !important; box-shadow: 0 2px 10px rgb(1 15 35 / 25%); background: #fff; }
.preview-body .image-full, .preview-body .video-full, .preview-body .office-full { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.zoom-stage { display: grid; place-items: center; overflow: hidden; touch-action: none; border-radius: 8px; height: min(70vh, 70dvh); cursor: zoom-in; user-select: none; }
.zoom-stage.zoomed { cursor: grab; }
.zoom-stage .image-full { max-height: 100%; transform-origin: center; will-change: transform; }
.zoom-hint { text-align: center; margin: 6px 0 0; }
.modal header { position: sticky; top: 0; z-index: 1; background: var(--panel); }
.preview-body .text-full {
  align-self: stretch; margin: 0; padding: 14px; border-radius: 8px; background: var(--file-bg); max-height: 70vh; overflow: auto;
  font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.preview-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.device-card .avatar { width: 44px; height: 44px; font-size: 15px; flex: none; }
