/* TeamPulse — one stylesheet for web, desktop (installed PWA) and mobile. */

:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-active: #e9edf5;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --warning: #b45309;
  --mention-bg: #fef3c7;
  --mention-text: #92400e;
  --mention-me-bg: #fde68a;
  --highlight: #fffbeb;
  --side-bg: #1e1b4b;
  --side-text: #c7d2fe;
  --side-strong: #ffffff;
  --side-muted: #a5b4fc;
  --side-hover: rgba(255, 255, 255, 0.08);
  --side-active: #4f46e5;
  --side-border: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.1), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.2);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Noto Sans Malayalam', 'Nirmala UI', 'Kartika', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --side-w: 268px;
  --panel-w: 400px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --read: #0284c7; /* read receipts: read by everyone */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --read: #38bdf8;
    --bg: #12141c;
    --bg-soft: #171a24;
    --bg-hover: #1d2130;
    --bg-active: #242a3c;
    --border: #262b3a;
    --border-strong: #353c50;
    --text: #e6e8ef;
    --text-2: #c3c8d6;
    --text-3: #959cb0;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.16);
    --accent-text: #a5b4fc;
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --success: #4ade80;
    --warning: #fbbf24;
    --mention-bg: rgba(251, 191, 36, 0.16);
    --mention-text: #fcd34d;
    --mention-me-bg: rgba(251, 191, 36, 0.3);
    --highlight: rgba(251, 191, 36, 0.08);
    --side-bg: #0b0d14;
    --side-text: #b4bbd0;
    --side-muted: #8a93ad;
    --side-active: #4f46e5;
    --side-border: rgba(255, 255, 255, 0.07);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --read: #38bdf8;
  --bg: #12141c;
  --bg-soft: #171a24;
  --bg-hover: #1d2130;
  --bg-active: #242a3c;
  --border: #262b3a;
  --border-strong: #353c50;
  --text: #e6e8ef;
  --text-2: #c3c8d6;
  --text-3: #959cb0;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-text: #a5b4fc;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --success: #4ade80;
  --warning: #fbbf24;
  --mention-bg: rgba(251, 191, 36, 0.16);
  --mention-text: #fcd34d;
  --mention-me-bg: rgba(251, 191, 36, 0.3);
  --highlight: rgba(251, 191, 36, 0.08);
  --side-bg: #0b0d14;
  --side-text: #b4bbd0;
  --side-muted: #8a93ad;
  --side-active: #4f46e5;
  --side-border: rgba(255, 255, 255, 0.07);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.47 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent); }
img, video { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.i { flex: none; display: block; }
.muted { color: var(--text-3); }
.xs { font-size: 12px; }
.pad { padding: 16px; }
.dim { opacity: 0.6; }
kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-2);
}
code { font-family: var(--mono); }

.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--side-bg); z-index: 100; }
.splash img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.92); opacity: 0.7; } }

#conn-banner {
  position: fixed; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 90;
  background: #111827; color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  border: 1px solid transparent; transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 42px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: var(--bg); border-color: var(--border-strong); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn:disabled { opacity: 0.55; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-accent) transparent var(--on-accent) transparent; animation: spin 0.8s linear infinite;
}
.btn.ghost.loading::after { border-color: var(--text-3) transparent var(--text-3) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.danger-text { color: var(--danger) !important; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius);
  color: var(--text-3); transition: background 0.15s, color 0.15s; flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--radius-sm); }
.icon-btn.live { color: #fff; background: var(--success); }
.icon-btn.on-dark { color: #e5e7eb; }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.round-btn {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.16); color: #fff; transition: background 0.15s, transform 0.1s;
}
.round-btn:hover { background: rgba(255, 255, 255, 0.26); }
.round-btn:active { transform: scale(0.95); }
.round-btn.off { background: #dc2626; }
.round-btn.danger { background: #dc2626; }
.round-btn.ok { background: #16a34a; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 14px; color: var(--text-2); }
.hint { color: var(--text-3); font-size: 12.5px; }
.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input.sm { height: 34px; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); }
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-prefix span { padding-left: 12px; color: var(--text-3); font-weight: 600; }
.input-prefix .input { border: 0; box-shadow: none; padding-left: 4px; }
.form-error { margin: 0; color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: var(--radius); font-size: 14px; }

.switch-row { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch-row.disabled { opacity: 0.6; cursor: not-allowed; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-row > span:last-child { display: flex; flex-direction: column; }
.switch-row small { color: var(--text-3); font-size: 13px; }
.switch {
  flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background 0.15s; margin-top: 1px;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.15s; box-shadow: var(--shadow-sm);
}
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Auth ---------- */
.auth {
  position: fixed; inset: 0; overflow: auto; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% 0%, #312e81 0%, transparent 60%), linear-gradient(160deg, #1e1b4b, #0f172a);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg); border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 24px; line-height: 1.2; margin: 18px 0 6px; }
.auth-card > .muted { margin: 0 0 22px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.auth-switch { text-align: center; margin: 18px 0 0; color: var(--text-3); font-size: 14px; }
.auth-forgot { margin-top: 8px; font-size: 13px; }

/* ---------- Avatars & badges ---------- */
.avatar {
  --size: 36px;
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: calc(var(--size) * 0.22);
  background: var(--c); color: #fff; font-weight: 700; font-size: calc(var(--size) * 0.4); line-height: 1;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar .presence { position: absolute; right: -3px; bottom: -3px; }
.presence {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: transparent; border: 2px solid var(--text-3); box-shadow: 0 0 0 2px var(--bg);
}
.presence.on { background: #22c55e; border-color: #22c55e; }
.sidebar .presence { box-shadow: 0 0 0 2px var(--side-bg); border-color: var(--side-muted); }
.sidebar .presence.on { border-color: #22c55e; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.more-count { font-size: 12px; color: var(--text-3); margin-left: 6px; }
.badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px;
  font-size: 11px; font-weight: 700; background: var(--bg-active); color: var(--text-2);
}
.badge.ai { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.badge.count { background: #e11d48; color: #fff; border-radius: 999px; min-width: 20px; justify-content: center; }
.badge.count.soft { background: rgba(255, 255, 255, 0.2); color: var(--side-strong); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; flex: none; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: live 1.6s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

/* ---------- Shell ---------- */
.shell {
  height: 100dvh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
  padding-top: var(--safe-t);
}
.shell.has-panel { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--panel-w); }
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--bg); }

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0; background: var(--side-bg); color: var(--side-text);
}
.side-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 6px 12px; }
.ws-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--radius);
  color: var(--side-strong); font-weight: 800; font-size: 16px; text-align: left;
}
.ws-btn:hover { background: var(--side-hover); }
.ws-logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: 15px;
}
.ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-icon { color: var(--side-text); }
.side-icon:hover { background: var(--side-hover); color: var(--side-strong); }
.side-search {
  display: flex; align-items: center; gap: 8px; margin: 4px 12px 8px; height: 34px; padding: 0 10px;
  border-radius: var(--radius); background: rgba(255, 255, 255, 0.08); color: var(--side-muted); font-size: 14px;
  border: 1px solid var(--side-border); transition: background 0.15s;
}
.side-search:hover { background: rgba(255, 255, 255, 0.13); }
.side-search span { flex: 1; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-search kbd { background: transparent; border-color: var(--side-border); color: var(--side-muted); }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; overscroll-behavior: contain; }
.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
.side-nav { padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--side-border); }
.side-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 32px; padding: 4px 10px; border-radius: var(--radius-sm);
  color: var(--side-text); text-decoration: none; font-size: 15px; text-align: left; transition: background 0.12s, color 0.12s;
}
.side-item:hover { background: var(--side-hover); color: var(--side-strong); }
.side-item.active { background: var(--side-active); color: #fff; }
.side-item.unread { color: var(--side-strong); font-weight: 700; }
.side-item.muted { opacity: 0.6; }
.side-item.ghost { color: var(--side-muted); }
.side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-status { font-size: 13px; }
.ch-icon { opacity: 0.85; }
.group-count {
  width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, 0.16); font-size: 11px; font-weight: 700;
}
.live-pill { display: grid; place-items: center; width: 22px; height: 18px; border-radius: 9px; background: #16a34a; color: #fff; }
.side-section { margin-top: 10px; }
.side-section-head { display: flex; align-items: center; justify-content: space-between; padding-right: 2px; }
.section-toggle {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--radius-sm);
  color: var(--side-muted); font-size: 13.5px; font-weight: 600;
}
.section-toggle:hover { color: var(--side-strong); background: var(--side-hover); }
.section-toggle .rot { transform: rotate(-90deg); }
.side-add { color: var(--side-muted); }
.side-add:hover { background: var(--side-hover); color: var(--side-strong); }
.side-banner {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; margin: 10px 0 4px; padding: 10px 12px; border-radius: var(--radius);
  background: rgba(99, 102, 241, 0.22); color: var(--side-strong); text-align: left; border: 1px solid rgba(165, 180, 252, 0.25);
}
.side-banner span { display: flex; flex-direction: column; font-size: 13.5px; }
.side-banner small { color: var(--side-text); font-size: 12.5px; }
.side-banner:hover { background: rgba(99, 102, 241, 0.32); }
.side-foot { display: flex; align-items: center; gap: 4px; padding: 8px 10px calc(8px + var(--safe-b)); border-top: 1px solid var(--side-border); }
.me-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--radius); text-align: left; }
.me-btn:hover { background: var(--side-hover); }
.me-meta { display: flex; flex-direction: column; min-width: 0; }
.me-meta b { color: var(--side-strong); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-meta small { color: var(--side-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Channel header ---------- */
.ch-head {
  display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.back-btn { display: none; }
.ch-title { flex: 1; min-width: 0; }
.ch-name {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 6px; margin-left: -6px; border-radius: var(--radius-sm);
  font-weight: 800; font-size: 17px; color: var(--text);
}
.ch-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-name:hover { background: var(--bg-hover); }
.star-on { color: #f59e0b; fill: #f59e0b; }
.ch-topic { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ch-topic.add { display: block; text-align: left; }
.ch-topic.add:hover { color: var(--accent); }
.ch-tools { display: flex; align-items: center; gap: 4px; }
.members-btn {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 6px; border-radius: var(--radius);
  border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2);
}
.members-btn:hover { background: var(--bg-hover); }
.catchup { color: var(--accent-text); border-color: var(--border); }

.meeting-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 14px;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.04)); border-bottom: 1px solid var(--border);
}
.meeting-banner > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Messages ---------- */
.ch-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-padding-bottom: 16px; }
.ch-messages { padding: 8px 0 12px; }
.intro { padding: 28px 20px 16px; }
.intro h2 { margin: 10px 0 4px; font-size: 24px; }
.intro p { margin: 0; max-width: 60ch; }
.intro-icon { width: 60px; height: 60px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.intro-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.load-older { height: 40px; display: grid; place-items: center; color: var(--text-3); font-size: 13px; }

.day-divider { position: relative; z-index: 1; display: flex; justify-content: center; margin: 12px 0 4px; pointer-events: none; }
.day-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--border); z-index: -1; }
.day-divider span {
  pointer-events: auto; font-size: 12.5px; font-weight: 700; padding: 3px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-2);
}
.unread-divider { display: flex; align-items: center; margin: 6px 16px; color: #e11d48; font-size: 12px; font-weight: 700; }
.unread-divider::before { content: ''; flex: 1; border-top: 1px solid #e11d48; }
.unread-divider span { padding-left: 8px; }

.msg { position: relative; display: flex; gap: 10px; padding: 6px 16px 6px 16px; transition: background 0.1s; }
.msg.compact { padding-top: 1px; padding-bottom: 1px; }
.msg:hover, .msg:focus-within { background: var(--bg-soft); }
.msg.pinned { background: var(--highlight); }
.msg.highlight { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 40% { background: var(--mention-me-bg); } 100% { background: transparent; } }
.msg-gutter { width: 38px; flex: none; display: flex; justify-content: center; }
.avatar-btn { border-radius: 9px; height: fit-content; }
.hover-time { visibility: hidden; font-size: 11px; color: var(--text-3); padding-top: 4px; white-space: nowrap; }
.msg:hover .hover-time { visibility: visible; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; line-height: 1.3; margin-bottom: 1px; }
.msg-author { font-weight: 800; font-size: 15px; color: var(--text); }
.msg-author:hover { text-decoration: underline; }
.msg-head time { font-size: 12px; color: var(--text-3); }
.status-emoji { font-size: 13px; }
.pinned-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--warning); font-weight: 600; }
.msg-text { color: var(--text); overflow-wrap: anywhere; }
.msg-text.deleted { color: var(--text-3); font-style: italic; }
.msg-tr { max-width: 640px; margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--bg-soft); }
.msg-tr-text { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-tr-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--text-2); }
.msg-tr-text + .msg-tr-foot { margin-top: 6px; }
.msg-tr-foot .link-btn { font-size: 12px; }
.msg-tr-lang { max-width: 130px; height: 26px; padding: 0 4px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
@media (pointer: coarse) { .msg-tr-lang { height: 36px; } .msg-tr-foot .link-btn { padding: 8px 4px; } }
.msg-text.jumbo { font-size: 34px; line-height: 1.25; }
.edited { color: var(--text-3); font-size: 12px; }
.from-bot .msg-text { color: var(--text); }
.result-context { position: absolute; top: 6px; left: 64px; right: 16px; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); }

.md .md-p + .md-p, .md .md-p + ul, .md ul + .md-p, .md .md-p + ol, .md ol + .md-p, .md .md-h + .md-p { margin-top: 6px; }
.md ul, .md ol { margin: 4px 0; padding-left: 22px; }
.md li { margin: 2px 0; }
.md .md-h { font-weight: 800; margin: 12px 0 4px; line-height: 1.3; }
.md .md-h:first-child { margin-top: 2px; }
.md .md-h1 { font-size: 18px; }
.md .md-h2 { font-size: 16px; }
.md .md-h3 { font-size: 15px; }
.md blockquote { margin: 4px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md .md-code { font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--bg-active); color: #e11d48; }
:root[data-theme='dark'] .md .md-code { color: #fda4af; }
.md .md-pre {
  margin: 6px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--border);
  overflow-x: auto; font-size: 13px; line-height: 1.5;
}
.md a { overflow-wrap: anywhere; }
.md-tasks { list-style: none; padding-left: 2px !important; }
.md-tasks li { display: flex; gap: 8px; align-items: flex-start; }
.md-tasks .box {
  flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 4px; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; font-size: 11px; color: #fff;
}
.md-tasks .done .box { background: var(--success); border-color: var(--success); }
.md-tasks .done > span:last-child { text-decoration: line-through; color: var(--text-3); }
.mention {
  display: inline; padding: 0 3px; border-radius: 4px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-text);
}
button.mention:hover { text-decoration: underline; }
.mention.me, .mention.all { background: var(--mention-bg); color: var(--mention-text); }

/* Hover action bar */
.msg-actions {
  position: absolute; top: -14px; right: 16px; z-index: 3; display: none; align-items: center; gap: 2px; padding: 2px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.act { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--text-3); }
.act:hover { background: var(--bg-hover); color: var(--text); }
.act.emoji { font-size: 17px; }
.act.on { color: var(--accent); }
@media (hover: none) { .msg-actions { display: none !important; } }

/* Attachments */
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.att-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 220px)); gap: 6px; }
.att-images.single { grid-template-columns: minmax(0, 360px); }
.att-img { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--bg-soft); max-height: 320px; }
.att-img img { display: block; width: 100%; height: 100%; max-height: 320px; object-fit: cover; }
.att-images.single .att-img img { object-fit: contain; }
.att-video video, .recording-card video { display: block; width: 100%; max-width: 560px; border-radius: var(--radius); background: #000; aspect-ratio: 16 / 9; }
.att-caption { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); text-decoration: none; margin-top: 4px; }
.att-audio audio { width: min(100%, 360px); }
.vn {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 340px; margin-top: 4px; padding: 6px 10px 6px 6px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
}
.vn-play { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; transition: background 0.15s; }
.vn-play:hover { background: var(--accent-hover); }
.vn-play svg { fill: currentColor; }
.vn-track { flex: 1; min-width: 0; display: flex; align-items: center; gap: 1px; height: 30px; cursor: pointer; border-radius: 4px; }
.vn-track i { flex: 1 1 0; min-width: 1px; height: var(--h); border-radius: 1px; background: var(--text-3); opacity: 0.5; }
.vn-track i.done { background: var(--accent); opacity: 1; }
.vn-time { flex: none; min-width: 34px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }
.vn-speed { flex: none; min-width: 30px; height: 22px; padding: 0 5px; font-size: 11.5px; font-weight: 700; color: var(--text-2); background: var(--bg-active); border-radius: 11px; transition: background 0.15s; }
.vn-speed:hover { color: var(--text); }
.vn-mark { flex: none; display: grid; place-items: center; width: 15px; height: 15px; color: var(--text-3); }
.vn-mark.heard { color: var(--read); }
.vn-mark.new svg { display: none; }
.vn-mark.new::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.vc { width: min(100%, 360px); margin-top: 4px; }
.vc.tall { width: min(100%, 230px); }
.vc video { display: block; width: 100%; aspect-ratio: var(--ar, 16 / 9); border-radius: var(--radius); background: #000; }
.vc-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.vc-foot .vn-time { min-width: 0; }
.vc-save { display: grid; place-items: center; width: 24px; height: 24px; margin-left: auto; border-radius: 6px; color: var(--text-3); }
.vc-save:hover { color: var(--text); background: var(--bg-soft); }
.vc-view { display: grid; place-items: center; width: 100%; max-height: 60dvh; aspect-ratio: 16 / 9; margin: 0 auto; overflow: hidden; border-radius: var(--radius); background: #000; }
.vc-view video { width: 100%; height: 100%; object-fit: contain; }
.vc-view video[hidden] { display: none; }
.vc-live { transform: scaleX(-1); }
.vc-live.plain { transform: none; }
.vc-bar { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 40px; margin-top: 14px; }
.vc-status { color: var(--text-3); }
.vc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }
@media (pointer: coarse) { .vc-save { width: 36px; height: 36px; } }
@media (pointer: coarse) { .vn-play { width: 40px; height: 40px; } .vn-speed { height: 28px; min-width: 38px; } }
.att-file {
  display: flex; align-items: center; gap: 10px; width: min(100%, 380px); padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); text-decoration: none; transition: background 0.15s;
}
.att-file:hover { background: var(--bg-hover); }
.att-file-icon { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.att-file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file-size { font-size: 12px; color: var(--text-3); }
.att-file-dl { color: var(--text-3); }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-soft); font-size: 13px; transition: border-color 0.15s, background 0.15s;
}
.reaction b { font-weight: 600; font-size: 12px; color: var(--text-2); }
.reaction:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction.mine b { color: var(--accent-text); }
.reaction.add { color: var(--text-3); opacity: 0; }
.msg:hover .reaction.add, .reaction.add:focus-visible { opacity: 1; }
@media (hover: none) { .reaction.add { opacity: 1; } }

.thread-summary {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 4px 8px 4px 4px; border-radius: var(--radius);
  font-size: 13px; color: var(--accent); border: 1px solid transparent;
}
.thread-summary:hover { background: var(--bg); border-color: var(--border); }
.thread-summary .avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg-soft); }

/* Cards */
.card { margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); max-width: 640px; }
.meeting-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.meeting-card.live { border-color: rgba(34, 197, 94, 0.5); background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), transparent); }
.card-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.meeting-card.live .card-icon { background: #16a34a; color: #fff; }
.card-main { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 4px; }
.card-title { font-weight: 700; }
.card-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-card, .recording-card { padding: 12px 14px; }
.ai-card { border-color: rgba(99, 102, 241, 0.35); background: linear-gradient(180deg, var(--accent-soft), var(--bg) 120px); }
.ai-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 14px; color: var(--accent-text); flex-wrap: wrap; }
.ai-card-head .muted { color: var(--text-3); }
.ai-card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ai-card details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.ai-card details[open] summary { margin-bottom: 8px; }

/* System messages */
.msg.system { padding-top: 2px; padding-bottom: 2px; color: var(--text-3); font-size: 14px; }
.msg.system .msg-gutter { align-items: center; }
.sys-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.sys-text { color: var(--text-2); }
.sys-text b { color: var(--text); }
.sys-text .md-p { display: inline; }
.msg.system time { font-size: 12px; color: var(--text-3); }

/* Skeletons & empty states */
.skel { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--bg-hover), var(--bg-active), var(--bg-hover)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-msg { display: flex; gap: 10px; padding: 10px 16px; }
.skel.av { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.skel.l1 { height: 12px; width: 40%; }
.skel.l2 { height: 12px; width: 75%; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 40px 20px; color: var(--text-2); }
.empty-state p { margin: 0; max-width: 40ch; }
.empty-state.full { flex: 1; }
.empty-state .i { color: var(--text-3); }

.new-pill {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 4;
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.typing-line { height: 20px; padding: 0 20px; font-size: 12.5px; color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- Composer ---------- */
.ch-composer, .panel-composer { padding: 0 16px calc(14px + var(--safe-b)); }
.panel-composer { padding-top: 8px; border-top: 1px solid var(--border); }
.composer { position: relative; }
.composer-box {
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within { border-color: var(--text-3); box-shadow: var(--shadow-sm); }
.composer-input {
  display: block; width: 100%; min-height: 44px; max-height: 40vh; padding: 12px 14px 4px; border: 0; outline: 0; resize: none;
  background: transparent; line-height: 1.45; font-size: 15px;
}
.composer-bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px 6px; }
.composer-bar .icon-btn { width: 32px; height: 32px; }
.composer-hint { flex: 1; font-size: 11.5px; color: var(--text-3); padding: 0 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer-hint kbd { font-size: 10px; padding: 0 4px; }
.send-btn {
  width: 36px; height: 32px; border-radius: var(--radius); display: grid; place-items: center;
  background: var(--accent); color: #fff; transition: background 0.15s, opacity 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { background: var(--bg-active); color: var(--text-3); }
.send-btn.busy { animation: pulse 1s infinite; }
.send-btn.voice { background: var(--bg-active); color: var(--text-2); }
.send-btn.voice:hover:not(:disabled) { background: var(--accent); color: #fff; }
.composer-box.recording > :not(.vn-bar) { display: none; }
.vn-bar { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 8px; }
.vn-bar .vn { flex: 1; max-width: none; margin: 0; padding: 0; background: none; border: 0; }
.vn-rec { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.vn-clock { flex: none; min-width: 36px; font-variant-numeric: tabular-nums; font-weight: 600; }
.vn-status { flex: 1; color: var(--text-3); }
.vn-bar [data-vn-act='stop'] svg { fill: currentColor; }
.vn-live { flex: 1; min-width: 0; width: 100%; height: 30px; color: var(--text-3); }
.composer-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 10px 0; }
.file-chip {
  position: relative; display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 6px 6px 6px 8px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft);
}
.file-chip.error { border-color: var(--danger); }
.file-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.file-chip-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; background: var(--accent-soft); color: var(--accent); flex: none; }
.file-chip-meta { min-width: 0; display: flex; flex-direction: column; }
.file-chip-name { font-size: 13px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-chip-sub { font-size: 11.5px; color: var(--text-3); }
.file-progress { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p) * 100%); background: var(--accent); transition: width 0.2s; }
.ac-pop {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20; max-height: 280px; overflow-y: auto; padding: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.ac-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--radius-sm); text-align: left; }
.ac-item.active, .ac-item:hover { background: var(--accent); color: #fff; }
.ac-item.active .muted, .ac-item.active .ac-desc { color: rgba(255, 255, 255, 0.8); }
.ac-desc { margin-left: auto; color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 12px; }
.ac-at { width: 22px; text-align: center; font-weight: 800; }
.join-bar { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-soft); }
.join-bar p { margin: 0; display: flex; align-items: center; gap: 6px; }
.drop-overlay {
  position: absolute; inset: 8px; z-index: 30; display: grid; place-items: center; text-align: center;
  border: 2px dashed var(--accent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--accent); pointer-events: none;
}
.msg-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.msg-edit-bar { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.msg-edit-bar .muted { margin-right: auto; }

/* ---------- Right panel ---------- */
.panel-head { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border); }
.panel-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.panel-title h2 { margin: 0; font-size: 17px; }
.panel-sub { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.panel .back-btn { display: none; }
.thread-root .msg { padding-top: 14px; }
.thread-count { display: flex; align-items: center; gap: 10px; padding: 4px 16px; font-size: 13px; color: var(--text-3); }
.thread-count::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.results .msg { padding-top: 26px; border-bottom: 1px solid var(--border); cursor: pointer; }
.panel-loading { padding-top: 8px; }
.search-form { display: flex; align-items: center; gap: 8px; margin: 12px 16px; padding-left: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text-3); }
.search-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-form .input { border: 0; box-shadow: none !important; padding-left: 0; }
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { padding: 10px 8px; font-size: 14px; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.rows { display: flex; flex-direction: column; padding: 4px 8px; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px; border-radius: var(--radius); text-align: left; color: var(--text); }
button.row:hover, .file-row:hover { background: var(--bg-hover); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
/* Workspace settings on a phone: a member's admin buttons go on their own line under the name. */
@media (max-width: 640px) {
  .settings-block .row { flex-wrap: wrap; }
  .settings-block .row .row-main { flex-basis: calc(100% - 40px); }
  .settings-block .row .row-actions { flex-basis: 100%; padding-left: 40px; justify-content: flex-start; }
}
.row-main b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-thumb { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail-block { margin: 12px 16px; padding: 4px 0; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.detail-block.toggles, .detail-block.danger-zone { padding: 4px; }
.detail-block.danger-zone { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 0; }
.detail-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.detail-row:last-child { border-bottom: 0; }
.detail-label { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 4px; }
.profile { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 16px; gap: 4px; }
.profile h3 { margin: 12px 0 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.profile p { margin: 0; }
.presence-line { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; }
.status-line { color: var(--text-2); }
.profile-actions { display: flex; gap: 8px; margin: 14px 0 6px; }
.profile .detail-block { align-self: stretch; text-align: left; }
.ai-summary { padding: 16px; }
.ai-meta { display: flex; align-items: center; gap: 6px; color: var(--accent-text); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.ai-loading { padding: 32px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--accent); }
.ai-loading .skel { width: 100%; }
.ai-loading .i { animation: pulse 1.2s infinite; }
.transcript { padding: 8px 16px; }
.tr-line { padding: 8px 0; border-bottom: 1px solid var(--border); }
.tr-who { font-weight: 700; font-size: 13.5px; }
.tr-time { color: var(--text-3); font-size: 12px; margin-left: 8px; }
.tr-line p { margin: 2px 0 0; }

/* ---------- Modals, popovers, sheets ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(15, 23, 42, 0.55); animation: fade 0.15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop 0.18s ease-out;
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 22px; }
.modal-head h2 { margin: 0; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 8px 22px 22px; overflow-y: auto; }
.modal-text { margin: 0 0 4px; color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.modal-actions .actions-start { margin-right: auto; }
.lightbox { display: grid; place-items: center; background: #000; border-radius: var(--radius); }
.lightbox img { max-height: 70dvh; object-fit: contain; }

.pop-layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.popover {
  position: fixed; pointer-events: auto; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); padding: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); animation: pop 0.12s ease-out;
}
.sheet-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, 0.45); display: flex; align-items: flex-end; animation: fade 0.15s; }
.sheet {
  width: 100%; max-height: 80dvh; overflow-y: auto; padding: 8px 8px calc(12px + var(--safe-b));
  background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); animation: up 0.2s ease-out;
}
.sheet::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 4px; margin: 2px auto 10px; background: var(--border-strong); }
@keyframes up { from { transform: translateY(100%); } }
.menu { display: flex; flex-direction: column; }
.menu-header { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-header small { color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border-radius: var(--radius-sm); text-align: left; font-size: 14px; }
.sheet .menu-item { min-height: 46px; font-size: 15px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent); color: #fff; outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
.menu-item kbd { margin-left: auto; }
.menu-divider { height: 1px; margin: 4px 6px; background: var(--border); }
.sheet-reactions { display: flex; justify-content: space-around; padding: 4px 4px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.emoji-pop { width: 340px; }
.emoji-picker { display: flex; flex-direction: column; gap: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 260px; overflow-y: auto; }
.sheet .emoji-grid { max-height: 50dvh; }
.emoji-btn { height: 38px; border-radius: var(--radius-sm); font-size: 22px; line-height: 1; display: grid; place-items: center; }
.emoji-btn.lg { width: 46px; height: 46px; font-size: 26px; border-radius: 50%; background: var(--bg-soft); }
.emoji-btn:hover { background: var(--bg-hover); }
.react-row { display: flex; gap: 2px; }

.toasts { position: fixed; z-index: 80; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: var(--radius-lg);
  background: #111827; color: #f9fafb; box-shadow: var(--shadow-lg); font-size: 14px; animation: pop 0.18s ease-out;
}
.toast.error { background: #7f1d1d; }
.toast.success { background: #14532d; }
.toast.out { opacity: 0; transform: translateY(6px); transition: 0.18s; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action { color: #a5b4fc; font-weight: 700; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.toast-action:hover { background: rgba(255, 255, 255, 0.1); }
.toast .icon-btn { color: #d1d5db; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* People picker, chips, settings */
.picker { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.picker-box { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-bottom: 1px solid var(--border); }
.picker-chips { display: contents; }
.picker-input { flex: 1; min-width: 140px; height: 30px; border: 0; outline: 0; background: transparent; padding: 0 6px; }
.picker-list { max-height: 240px; overflow-y: auto; padding: 4px; }
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: var(--radius-sm); text-align: left; }
.picker-item:hover { background: var(--bg-hover); }
.picker-item.on { background: var(--accent-soft); }
.picker-item .check { color: var(--accent); width: 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 4px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.chip-x { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; }
.chip-x:hover { background: rgba(0, 0, 0, 0.08); }
.browse-bar { display: flex; gap: 8px; margin-bottom: 8px; }
.browse-row { border-bottom: 1px solid var(--border); border-radius: 0; }
.browse-list { padding: 0; max-height: 55dvh; overflow-y: auto; }
.ok { color: var(--success); font-weight: 600; }
.avatar-edit { display: flex; align-items: center; gap: 16px; }
.file-btn { cursor: pointer; }
.status-input { display: flex; gap: 8px; }
.emoji-pick { width: 40px; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 20px; flex: none; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.preset { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; }
.preset:hover { background: var(--bg-hover); }
.pw-details { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.pw-details summary { cursor: pointer; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
.settings-block { padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings-block:last-child { border-bottom: 0; }
.settings-block h3 { margin: 0 0 6px; font-size: 15px; }
.settings-block p { margin: 0 0 10px; }
.settings-block .rows { padding: 0; max-height: 300px; overflow-y: auto; }
.settings-switch { margin: 14px 0 10px; }
.settings-switch small { display: block; color: var(--text-3); font-size: 13px; }
/* Join requests */
.jr-list .rows { padding: 4px 0 0; }
.jr-row { flex-wrap: wrap; }
.jr-row .row-main { flex: 1; min-width: 180px; }
.jr-actions { display: flex; gap: 6px; margin-left: auto; }
.auth-wait { width: 52px; height: 52px; display: grid; place-items: center; margin: 22px 0 6px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.copy-row { display: flex; gap: 8px; }
.call-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 0; }
.call-card h3 { margin: 14px 0 0; font-size: 20px; }
.call-who { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13px; color: var(--text-2); }
.call-actions { display: flex; gap: 36px; margin-top: 24px; }
.call-actions .round-btn { width: 60px; height: 60px; }

/* ---------- Meetings ---------- */
.meeting { position: fixed; inset: 0; z-index: 50; background: #0b0d14; color: #e5e7eb; }
.meeting .muted { color: #9ca3af; }
.pj {
  height: 100%; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 32px; align-items: center;
  max-width: 1100px; margin: 0 auto; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
}
.pj-preview { position: relative; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; background: #1c2030; display: grid; place-items: center; }
.pj-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: 0; }
.pj-preview.video-on video { opacity: 1; }
.pj-preview.plain video { transform: none; }
.pj-preview.video-on .pj-avatar { opacity: 0; }
.pj-toggles { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; }
.pj-status { position: absolute; top: 12px; left: 16px; margin: 0; font-size: 13px; }
.pj-side h2 { margin: 0 0 4px; font-size: 26px; color: #fff; }
.pj-side > .muted { margin: 0 0 16px; }
.pj-people { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 14px; }
.pj-people .avatar-stack .avatar { box-shadow: 0 0 0 2px #0b0d14; }
.meeting .switch-row small { color: #9ca3af; }
.pj-warn { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius); background: rgba(245, 158, 11, 0.14); color: #fcd34d; font-size: 14px; }
.pj-actions { display: flex; gap: 10px; margin-top: 24px; }
.pj-actions .btn { height: 44px; padding: 0 22px; }
.meeting .btn.ghost { background: transparent; color: #e5e7eb; border-color: #374151; }
.meeting .btn.ghost:hover { background: #1f2937; }

.mt-shell { height: 100%; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.mt-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.mt-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mt-info b { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-sub { font-size: 12.5px; color: #9ca3af; }
.rec-badge { padding: 3px 10px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 12px; font-weight: 700; animation: pulse 1.6s infinite; }
.cc-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: rgba(99, 102, 241, 0.25); color: #c7d2fe; font-size: 12px; font-weight: 600; }
.cc-badge.off { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
button.cc-badge:hover { background: rgba(99, 102, 241, 0.4); color: #fff; }
.pj-lang { margin-top: 14px; }
.meeting select.input { background: #1f2433; color: #e5e7eb; border-color: #374151; }
.meeting .label { color: #d1d5db; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: start; }
.translator-error, .translator-actions { grid-column: 1 / -1; }
.translator-actions { display: flex; flex-wrap: wrap; gap: 8px; }
[data-translator] > .form-error { margin: 10px 0; }
@media (max-width: 640px) { .lang-grid { grid-template-columns: 1fr; } }
.mt-body { flex: 1; min-height: 0; display: flex; position: relative; }
.mt-stage {
  flex: 1; min-width: 0; min-height: 0; display: grid; gap: 10px; padding: 4px 14px 10px;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr);
}
.mt-stage[data-count='2']:not(.spotlight) { align-content: center; grid-auto-rows: auto; }
.mt-stage[data-count='2']:not(.spotlight) .tile { aspect-ratio: 16 / 9; }
/* Spotlight: the featured tile fills the stage height; the others stack on the right (--side of them, as many as fit). */
.mt-stage.spotlight { grid-template-columns: minmax(0, 1fr) 220px; grid-template-rows: repeat(var(--side, 1), 124px) minmax(0, 1fr); grid-auto-rows: 124px; }
.mt-stage.spotlight .tile.featured { grid-column: 1; grid-row: 1 / -1; }
.mt-stage.spotlight .tile:not(.featured) { grid-column: 2; }
.tile {
  position: relative; min-height: 0; border-radius: 14px; overflow: hidden; background: #1c2030; display: grid; place-items: center;
  outline: 3px solid transparent; outline-offset: -3px; transition: outline-color 0.15s; cursor: pointer;
}
.tile.speaking { outline-color: #22c55e; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.tile.video-on video { opacity: 1; }
.tile.screen video { object-fit: contain; background: #000; }
.tile.mirror video { transform: scaleX(-1); }
.tile.video-on .tile-avatar { visibility: hidden; }
.tile-avatar .avatar { --size: clamp(48px, 18vmin, 96px) !important; }
.tile-label {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 5px; max-width: calc(100% - 16px);
  padding: 3px 9px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 13px;
}
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mic { color: #f87171; display: flex; }
.tile-hand { position: absolute; top: 8px; left: 8px; font-size: 22px; display: none; background: rgba(0, 0, 0, 0.5); border-radius: 8px; padding: 2px 6px; }
.tile.hand .tile-hand { display: block; }
.tile-conn { position: absolute; top: 8px; right: 8px; font-size: 12px; color: #fcd34d; }
.tile-conn:not(:empty) { background: rgba(0, 0, 0, 0.6); padding: 2px 8px; border-radius: 6px; }
.tile.offstage { display: none; }
.more-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #e5e7eb; font-size: 15px; border: 1px dashed #374151; }
.more-tile:hover { background: #232838; }
.more-tile .avatar-stack .avatar { box-shadow: 0 0 0 2px #1c2030; }
.more-tile .muted { font-size: 12.5px; }
.mt-people { width: 300px; flex: none; margin: 4px 14px 10px 0; border-radius: 14px; background: #161a26; display: flex; flex-direction: column; min-height: 0; }
.mt-people-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px 14px; color: #fff; }
.mt-people-list { overflow-y: auto; padding: 0 6px 8px; }
.mt-person { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 14px; }
.mt-person.speaking { background: rgba(34, 197, 94, 0.14); }
.mt-person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e5e7eb; }
.mt-person-name small { color: #9ca3af; }
.mt-person-name small.warn { color: #fcd34d; }
.mt-person-mic { color: #9ca3af; display: flex; }
.mt-person-mic.off { color: #f87171; }
.mt-people-head b { flex: 1; }
.mt-people-head .mt-invite { margin-right: 4px; }
.mt-people-sub { padding: 12px 8px 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #9ca3af; }
.mt-person.invited .avatar { opacity: 0.6; }
.mt-person-name small.ringing { color: #86efac; }
@media (max-width: 480px) { .mt-top .mt-invite span { display: none; } }
.mt-net { padding: 3px 10px; border-radius: 999px; background: rgba(245, 158, 11, 0.2); color: #fcd34d; font-size: 12px; font-weight: 600; }
.mt-audio-btn { background: #f59e0b; color: #111827; }
.ctrl { position: relative; }
.ctrl-badge { position: absolute; top: 4px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #374151; color: #fff; font-size: 11px; font-style: normal; line-height: 18px; }
.mt-captions { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(820px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 2; }
.cap { align-self: center; max-width: 100%; padding: 6px 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 16px; line-height: 1.35; }
.cap.interim { color: #d1d5db; }
.mt-float { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.float-emoji { position: absolute; bottom: 90px; display: flex; flex-direction: column; align-items: center; animation: floatUp 3.2s ease-out forwards; }
.float-emoji span { font-size: 40px; }
.float-emoji small { font-size: 11px; background: rgba(0, 0, 0, 0.6); padding: 1px 6px; border-radius: 6px; }
@keyframes floatUp { to { transform: translateY(-55vh); opacity: 0; } }
.mt-controls { display: flex; justify-content: center; gap: 8px; padding: 10px 12px calc(14px + var(--safe-b)); flex-wrap: wrap; }
.ctrl {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; height: 58px; padding: 0 8px;
  border-radius: 12px; background: #1f2433; color: #e5e7eb; font-size: 11.5px; font-weight: 600; transition: background 0.15s;
}
.ctrl:hover:not(:disabled) { background: #2a3044; }
.ctrl.on { background: #4f46e5; color: #fff; }
.ctrl.off { background: #3b1d22; color: #fca5a5; }
.ctrl.danger { background: #dc2626; color: #fff; }
.ctrl.danger:hover { background: #b91c1c; }
.ctrl:disabled { opacity: 0.5; }
.react-pop { background: #1f2433; border-color: #2a3044; }
.react-pop .emoji-btn:hover { background: #2a3044; }

.mt-mini { display: none; }
.meeting.min { inset: 66px 16px auto auto; width: 300px; height: auto; border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.meeting.min .mt-shell { display: block; height: 0; overflow: hidden; padding: 0; }
.meeting.min .mt-mini { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
.mt-mini-info { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.mt-mini-title { flex: 1; min-width: 0; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-mini-ctrls { display: flex; gap: 6px; }
.mt-mini-ctrls .ctrl { flex: 1; height: 40px; min-width: 0; }

/* ---------- Mobile tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; padding-bottom: var(--safe-b);
  background: var(--bg); border-top: 1px solid var(--border);
}
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.tab-btn.active { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  :root { --side-w: 240px; --panel-w: 360px; }
  .catchup span { display: none; }
}
@media (max-width: 960px) and (min-width: 769px) {
  .shell.has-panel { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .shell.has-panel .panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 90vw); z-index: 15; box-shadow: var(--shadow-lg); }
  .members-btn { display: none; }
}
@media (max-width: 768px) {
  body { font-size: 16px; }
  .shell, .shell.has-panel { grid-template-columns: 1fr; }
  .shell[data-view='list'] .main, .shell[data-view='list'] .panel { display: none; }
  .shell[data-view='channel'] .sidebar, .shell[data-view='channel'] .panel { display: none; }
  .shell[data-view='panel'] .sidebar, .shell[data-view='panel'] .main { display: none; }
  .shell[data-view='list'] .sidebar { padding-bottom: calc(58px + var(--safe-b)); }
  .shell[data-view='panel'] .panel { border-left: 0; }
  .tabbar:not([hidden]) ~ * .panel-body { padding-bottom: 64px; }
  .side-foot { display: none; }
  .side-search kbd, .members-btn { display: none; }
  .back-btn, .panel .back-btn { display: inline-grid; margin-left: -8px; }
  .panel .close-btn { display: none; }
  .ch-head { padding-left: 8px; min-height: 54px; }
  .ch-name { font-size: 16px; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .ch-composer, .panel-composer { padding-left: 10px; padding-right: 10px; }
  .composer-hint { visibility: hidden; display: block; }
  .side-item { min-height: 40px; font-size: 16px; }
  .icon-btn { width: 40px; height: 40px; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-width: none !important; border-radius: 16px 16px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); animation: up 0.2s ease-out; }
  .pj { grid-template-columns: 1fr; gap: 18px; align-content: start; overflow-y: auto; }
  .pj-side h2 { font-size: 22px; }
  .mt-people { position: absolute; inset: 0 8px 8px; width: auto; margin: 0; z-index: 4; }
  .mt-stage.spotlight { grid-template-columns: 1fr; grid-auto-rows: 96px; grid-template-rows: minmax(0, 1fr); }
  .mt-stage.spotlight .tile.featured { grid-column: 1; grid-row: 1; }
  .mt-stage.spotlight .tile:not(.featured) { grid-column: auto; display: none; }
  .ctrl { min-width: 52px; height: 52px; font-size: 0; gap: 0; }
  .mt-captions { bottom: 150px; }
  .meeting.min { inset: calc(6px + var(--safe-t)) 8px auto 8px; width: auto; }
  .meeting.min .mt-mini { flex-direction: row; align-items: center; }
  .meeting.min .mt-mini-ctrls { flex: none; }
  .meeting.min .mt-mini-ctrls .ctrl { width: 44px; flex: none; }
  .att-images { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .att-images.single { grid-template-columns: minmax(0, 1fr); }
  .new-pill { bottom: 110px; }
  .result-context { left: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Guests ---------- */
.mt-invite { background: #1f2433; color: #e5e7eb; border-color: #374151; }
.mt-invite:hover { background: #2a3044; }
.mt-lobby { margin: 0 14px 6px; padding: 6px; border-radius: 12px; background: #1f2433; border: 1px solid #f59e0b55; display: flex; flex-direction: column; gap: 4px; }
.lobby-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px; color: #e5e7eb; font-size: 14px; }
.lobby-row.all { justify-content: flex-end; }
.lobby-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-card { text-align: left; }
.guest-kicker { margin: 18px 0 0; color: var(--text-3); font-size: 14px; }
.guest-card h1 { margin-top: 4px; }
.guest-card .muted { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.guest-fine { text-align: center; justify-content: center; }
.guest-actions { display: flex; gap: 8px; margin-top: 12px; }
.wait-spinner { width: 36px; height: 36px; margin: 18px 0 12px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.guest-links-title { margin: 22px 0 6px; font-size: 15px; }
.guest-links { padding: 0; }
.guest-link { flex-wrap: wrap; border-bottom: 1px solid var(--border); border-radius: 0; }
.guest-link.fresh { background: var(--accent-soft); }
.guest-link .row-main small { white-space: normal; overflow-wrap: anywhere; }
.guest-link-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.guest-lobby-toggle { align-self: end; padding-bottom: 6px; }

/* ---------- Calendar ---------- */
.cal { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-head {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; min-height: 58px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
}
.cal-h { display: flex; align-items: center; gap: 8px; margin: 0 6px 0 0; font-size: 17px; font-weight: 800; }
.cal-h .i { color: var(--accent); }
.cal-nav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.cal-nav .icon-btn { color: var(--text-2); }
.cal-range { min-width: 0; margin-left: 6px; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-tools { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cal-who { width: auto; max-width: 190px; padding-right: 8px; }
.cal-new { height: 34px; }
.seg { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--bg-hover); }
.seg-btn { height: 28px; padding: 0 10px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: background 0.15s, color 0.15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.cal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; transition: opacity 0.15s; }
.cal-body.loading { opacity: 0.7; }

/* Week / day grid */
.cal-week { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-week-head { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--border); padding-right: 8px; }
.cal-dayhead { display: flex; flex-direction: column; align-items: center; padding: 6px 0 8px; color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; border-radius: var(--radius-sm); }
.cal-dayhead:hover { background: var(--bg-hover); }
.cal-dayhead b { font-size: 20px; line-height: 1.3; color: var(--text); font-weight: 700; text-transform: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.cal-dayhead.today { color: var(--accent); }
.cal-dayhead.today b { background: var(--accent); color: var(--on-accent); }
.cal-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.cal-grid { position: relative; display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); }
.cal-hours { position: relative; }
.cal-hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--text-3); white-space: nowrap; }
.cal-col {
  position: relative; border-left: 1px solid var(--border); cursor: cell;
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 100% 48px;
}
.cal-col.today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.cal-now { position: absolute; left: -1px; right: 0; height: 2px; background: #e11d48; z-index: 3; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e11d48; }
.cal-ev {
  position: absolute; z-index: 2; display: flex; flex-direction: column; gap: 1px; overflow: hidden; padding: 3px 6px; text-align: left;
  border-radius: 6px; border-left: 3px solid var(--ec); font-size: 12px; line-height: 1.3; color: var(--text); cursor: pointer;
  background: color-mix(in srgb, var(--ec) 16%, var(--bg)); box-shadow: 0 0 0 1px var(--bg);
  transition: filter 0.15s, box-shadow 0.15s;
}
.cal-ev:hover { filter: brightness(0.97); box-shadow: 0 0 0 1px var(--bg), var(--shadow); z-index: 4; }
.cal-ev b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.cal-ev span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.cal-ev.short { flex-direction: row; align-items: center; gap: 6px; padding-top: 1px; padding-bottom: 1px; }
.cal-ev.short span { white-space: nowrap; }
.cal-ev.live { border-left-color: #16a34a; background: color-mix(in srgb, #16a34a 16%, var(--bg)); }
.cal-ev.past, .cal-pill.past, .cal-row.past { opacity: 0.6; }
.cal-ev.busy, .cal-pill.busy {
  background: repeating-linear-gradient(135deg, var(--bg-hover) 0 6px, var(--bg-soft) 6px 12px); border-left-color: var(--border-strong); color: var(--text-2);
}

/* Month grid */
.cal-month { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.cal-month-head span { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; }
.cal-month-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(92px, 1fr)); overflow-y: auto; }
.cal-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 4px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.other { background: var(--bg-soft); }
.cal-cell.other .cal-date { color: var(--text-3); }
.cal-date { align-self: flex-start; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 13px; font-size: 13px; font-weight: 700; }
.cal-date:hover { background: var(--bg-hover); }
.cal-cell.today .cal-date { background: var(--accent); color: var(--on-accent); }
.cal-pill {
  display: flex; align-items: center; min-width: 0; height: 22px; padding: 0 6px; border-radius: 5px; font-size: 12px; text-align: left;
  border-left: 3px solid var(--ec); background: color-mix(in srgb, var(--ec) 14%, var(--bg)); color: var(--text);
}
.cal-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-pill:hover { filter: brightness(0.96); }
.cal-more { align-self: flex-start; padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--text-3); border-radius: 4px; }
.cal-more:hover { color: var(--accent); background: var(--bg-hover); }

/* List */
.cal-list { flex: 1; overflow-y: auto; padding: 4px 0 24px; overscroll-behavior: contain; }
.cal-group { padding: 0 16px; }
.cal-group-head { position: sticky; top: 0; z-index: 1; margin: 0; padding: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--text-2); background: var(--bg); }
.cal-group-head.today { color: var(--accent); }
.cal-row {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--border); margin-bottom: 6px; background: var(--bg); transition: background 0.15s, border-color 0.15s;
}
.cal-row:hover { background: var(--bg-hover); }
.cal-row-time { display: flex; flex-direction: column; width: 72px; flex: none; }
.cal-row-time b { font-size: 14px; white-space: nowrap; }
.cal-row-time small { font-size: 12px; color: var(--text-3); }
.cal-row-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--ec); flex: none; }
.cal-row.busy .cal-row-bar { background: repeating-linear-gradient(180deg, var(--border-strong) 0 4px, transparent 4px 8px); }
.cal-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cal-row-main b { display: flex; align-items: center; gap: 6px; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-row-main small { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Invitation card in the conversation */
.event-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; border-left: 4px solid var(--ec); }
.event-card.cancelled .card-title { text-decoration: line-through; color: var(--text-3); }
.event-card.cancelled .card-title .badge { text-decoration: none; }
.event-card.over { opacity: 0.75; }
.cal-badge {
  width: 46px; height: 50px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 10px;
  background: color-mix(in srgb, var(--ec) 14%, var(--bg)); color: var(--ec); line-height: 1.1;
}
.cal-badge small { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.cal-badge b { font-size: 20px; color: var(--text); }
.event-card .card-sub .avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg); }

/* Meeting details */
.ev-detail { display: flex; flex-direction: column; gap: 14px; }
.ev-line { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.ev-line > .i { color: var(--text-3); margin-top: 2px; }
.ev-line small { color: var(--text-3); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.ev-line a { font-weight: 600; }
.ev-people { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.ev-person { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.ev-person small { color: var(--text-3); }
.ev-guests { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.ev-guests li { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.ev-agenda { white-space: pre-wrap; font-size: 14px; color: var(--text-2); }
.ev-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.ev-cancelled { margin: 0; display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.ev-organizer { margin: -4px 0 0; }

/* Schedule dialog */
.sched { gap: 14px; }
.sched-when { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.sched-repeat { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.sched-end { margin: -6px 0 0; }
.sched-people-head { display: flex; align-items: center; justify-content: space-between; }
.sched-people { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; padding: 2px; }
.sched-person {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px 0 6px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); font-size: 14px; transition: background 0.15s, border-color 0.15s;
}
.sched-person input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sched-person.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.sched-person:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.sched-person:has(input:disabled) { cursor: default; }
.sched-person small { color: var(--text-3); }
.sched-switches { display: flex; flex-direction: column; gap: 12px; }
.guest-emails .picker-box { border-bottom: 0; }
.guest-emails .chip { padding: 0 4px 0 8px; }
.sub-steps { margin: 14px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.sub-warn { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); color: var(--warning); background: color-mix(in srgb, #f59e0b 14%, transparent); }
.guest-when { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-weight: 600; color: var(--text); }
.guest-when .i { color: var(--accent); }

@media (max-width: 768px) {
  .shell[data-view='calendar'] .sidebar, .shell[data-view='calendar'] .panel { display: none; }
  .shell[data-view='calendar'] .main { padding-bottom: calc(58px + var(--safe-b)); }
  .cal-head { padding: 8px 10px; gap: 8px; }
  .cal-h { flex: 1; }
  .cal-new { order: 2; width: 40px; padding: 0; }
  .cal-new span { display: none; }
  .cal-nav { order: 3; flex-basis: 100%; }
  .cal-tools { order: 4; flex-basis: 100%; }
  .cal-tools .seg { flex: none; }
  .cal-who { flex: 1; max-width: none; min-width: 0; }
  .cal-week-head, .cal-grid { grid-template-columns: 48px repeat(var(--days), minmax(0, 1fr)); }
  .cal-month-grid { grid-template-rows: repeat(6, minmax(64px, 1fr)); }
  .cal-cell { padding: 2px; cursor: pointer; }
  .cal-pill { height: 6px; padding: 0; border-left: 0; border-radius: 3px; background: var(--ec); }
  .cal-pill.busy { background: var(--border-strong); }
  .cal-pill span { display: none; }
  .cal-more { font-size: 11px; padding: 0 2px; }
  .cal-date { font-size: 12px; min-width: 24px; height: 24px; }
  .cal-group { padding: 0 10px; }
  .cal-row { gap: 10px; padding: 10px 8px; }
  .cal-row-time { width: 70px; }
  .cal-row-people { display: none; }
  .sched-when { grid-template-columns: 1fr 1fr; }
  .sched-when .field:first-child { grid-column: 1 / -1; }
  .sched-repeat { grid-template-columns: 1fr; }
  .ev-actions .btn { flex: 1 1 auto; }
}

/* ---------- Tasks ---------- */
.tasks { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tasks-head {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; min-height: 58px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
}
.tasks-back { color: var(--text-2); margin-left: -6px; }
.tasks-h { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 800; }
.tasks-h > .i { color: var(--accent); }
.tasks-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-key, .proj-badge {
  display: inline-flex; align-items: center; flex: none; height: 22px; padding: 0 7px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
}
.tasks-tools { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tasks-tools .seg-btn { display: inline-flex; align-items: center; gap: 5px; }
.tasks-search { width: 180px; }
.tasks-who { width: auto; max-width: 170px; padding-right: 8px; }
.tasks-new { height: 34px; }
.tasks-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; transition: opacity 0.15s; }
.tasks-body.loading { opacity: 0.7; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--sc); }
.s-todo { --sc: #94a3b8; }
.s-in_progress { --sc: #2563eb; }
.s-in_review { --sc: #d97706; }
.s-done { --sc: #16a34a; }
.status-pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--sc-text); background: color-mix(in srgb, var(--sc) 14%, transparent);
}
/* Status text: the status color pulled toward the text color, so it stays readable in light and dark themes. */
.s-todo, .s-in_progress, .s-in_review, .s-done { --sc-text: color-mix(in srgb, var(--sc) 65%, var(--text)); }
.ttype { width: 18px; height: 18px; border-radius: 4px; display: inline-grid; place-items: center; flex: none; color: #fff; }
.t-task { background: #2563eb; }
.t-bug { background: #dc2626; }
.t-story { background: #16a34a; }
.t-epic { background: #7c3aed; }
.prio { display: inline-flex; flex: none; }
.p-urgent { color: #dc2626; }
.p-high { color: #ea580c; }
.p-medium { color: #ca8a04; }
.p-low { color: #64748b; }
.tkey { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.tkey.done { text-decoration: line-through; }
.due { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.due.late { color: var(--danger); font-weight: 600; }
.tk-who { display: inline-flex; flex: none; }
.tk-who.none { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%; border: 1.5px dashed var(--border-strong); color: var(--text-3); }
.issue-ref {
  display: inline-flex; align-items: center; padding: 0 5px; border-radius: 4px; background: var(--accent-soft);
  color: var(--accent-text); font-weight: 600; font-size: 0.92em; text-decoration: none;
}
.issue-ref:hover { text-decoration: underline; }

/* Board */
.board { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; padding: 14px 16px; overflow-x: auto; align-items: start; }
.board-col { display: flex; flex-direction: column; max-height: 100%; min-height: 0; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 8px 6px 4px 12px; font-size: 13px; }
.col-head b { font-weight: 700; }
.col-count { margin-right: auto; color: var(--text-3); font-weight: 600; }
.col-head .icon-btn { color: var(--text-2); }
.col-cards { display: flex; flex-direction: column; gap: 8px; min-height: 64px; padding: 4px 8px 10px; overflow-y: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); transition: background 0.15s; }
.col-cards.over { background: var(--accent-soft); }
.col-empty { margin: 4px 0; padding: 14px 0; border: 1.5px dashed var(--border); border-radius: var(--radius); text-align: center; font-size: 13px; color: var(--text-3); }
.tcard {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.tcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tcard.dragging { opacity: 0.4; }
.tcard-title { font-size: 14px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.tcard-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.tlabel { padding: 1px 7px; border-radius: 999px; background: var(--bg-hover); color: var(--text-2); font-size: 11px; font-weight: 600; }
.tcard-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.tcard-foot .tk-who { margin-left: auto; }
.tmeta { display: inline-flex; align-items: center; gap: 3px; }
.drop-mark { height: 3px; margin: -2px 2px; border-radius: 2px; background: var(--accent); }

/* List */
.tlist { padding: 4px 16px 24px; }
.tl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 118px 104px 180px 96px 84px; gap: 12px; align-items: center;
  padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 14px; text-decoration: none;
}
a.tl-row:hover { background: var(--bg-hover); text-decoration: none; }
.tl-head { position: sticky; top: 0; z-index: 1; background: var(--bg); font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.tl-issue { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tl-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-prio, .tl-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tl-who > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-updated { font-size: 13px; }

/* Home */
.tasks-home { display: grid; gap: 28px; width: 100%; max-width: 1100px; padding: 20px 24px 40px; }
.th-sec h2 { margin: 0 0 10px; font-size: 16px; font-weight: 800; }
.th-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.th-empty { margin: 4px 0; }
.mywork { display: flex; flex-direction: column; }
.mw-group { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.mw-group:first-child { margin-top: 0; }
.mw-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.mw-row:hover { background: var(--bg-hover); text-decoration: none; }
.mw-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.mw-done summary { margin-top: 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.proj-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--bg); color: var(--text); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.proj-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.proj-card.archived { opacity: 0.7; }
.proj-name { font-size: 15px; }
.proj-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--text-2); }
.proj-stats { margin-top: auto; padding-top: 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }

/* Issue page */
.modal.issue-modal { max-width: 980px; }
.it-head { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text-2); }
.issue { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; }
.issue-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.issue-title {
  width: calc(100% + 16px); margin: -4px -8px 0; padding: 4px 8px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text); font: inherit; font-size: 22px; font-weight: 700; line-height: 1.3; resize: none; overflow: hidden;
}
.issue-title:hover { border-color: var(--border); }
.issue-title:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.issue-parent { display: flex; align-items: center; gap: 6px; margin: -10px 0 0; font-size: 13px; color: var(--text-2); }
.is-sec h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.is-sec h3 .muted { font-weight: 600; text-transform: none; letter-spacing: 0; }
.issue-desc { margin-bottom: 6px; font-size: 14px; line-height: 1.55; }
.desc-empty { width: 100%; padding: 12px; border: 1.5px dashed var(--border); border-radius: var(--radius); text-align: left; font-size: 14px; color: var(--text-3); transition: border-color 0.15s, color 0.15s; }
.desc-empty:hover { border-color: var(--border-strong); color: var(--text-2); }
.desc-input { min-height: 150px; }
.is-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.subs { display: flex; flex-direction: column; margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.sub-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; color: var(--text); font-size: 14px; text-decoration: none; }
.sub-row + .sub-row { border-top: 1px solid var(--border); }
.sub-row:hover { background: var(--bg-hover); text-decoration: none; }
.sub-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-title.done { color: var(--text-3); text-decoration: line-through; }
.sub-add { display: flex; gap: 8px; }
.sub-add .input { flex: 1; min-width: 0; }
.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; min-width: 0; font-size: 14px; }
.comment-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; font-size: 13px; }
.danger-link { margin-left: auto; color: var(--text-3); font-size: 12px; font-weight: 500; }
.danger-link:hover { color: var(--danger); }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.comment-form .ic-files { display: flex; flex-wrap: wrap; gap: 8px; }
.ic-bar { display: flex; align-items: center; gap: 8px; }
.ic-hint { flex: 1; font-size: 12.5px; color: var(--text-3); }
@media (hover: none) { .ic-hint { visibility: hidden; } }
.comment-form.over .ic-input { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.is-history summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.history { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.history li { display: flex; justify-content: space-between; gap: 12px; }
.history li .muted { flex: none; }
.issue-side { display: flex; flex-direction: column; gap: 12px; align-self: start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-soft); }
.issue-side .field { gap: 4px; }
.issue-side .link-btn { align-self: flex-start; font-size: 12px; }
.status-select { font-weight: 700; color: var(--sc-text); }
.is-sec .link-btn { display: inline-flex; align-items: center; gap: 4px; }
.input.late { border-color: var(--danger); color: var(--danger); }
.is-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 4px 0 0; font-size: 13px; }
.is-meta dt { color: var(--text-3); }
.is-meta dd { display: flex; align-items: center; gap: 6px; min-width: 0; margin: 0; }
.is-source { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.is-buttons { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.danger-text { color: var(--danger); }
.issue-form .if-row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.issue-form .if-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.if-another { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; font-size: 13px; color: var(--text-2); }
.if-source { display: flex; align-items: center; gap: 6px; }
.key-input { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

@media (max-width: 768px) {
  .shell[data-view='tasks'] .sidebar, .shell[data-view='tasks'] .panel { display: none; }
  .shell[data-view='tasks'] .main { padding-bottom: calc(58px + var(--safe-b)); }
  .tasks-head { padding: 8px 12px; }
  .tasks-new { order: 2; width: 40px; padding: 0; }
  .tasks-new span, .tasks-tools .seg-btn span { display: none; }
  .tasks-tools { order: 3; flex-basis: 100%; }
  .tasks-search { flex: 1; width: auto; min-width: 0; }
  .tasks-who { max-width: 130px; }
  .board { grid-template-columns: repeat(4, 82vw); padding: 12px; scroll-snap-type: x mandatory; }
  .board-col { scroll-snap-align: center; }
  .tlist { padding: 0 8px 16px; }
  .tl-head { display: none; }
  .tl-row { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 8px; }
  .tl-row > :nth-child(n + 3) { display: none; }
  .tasks-home { padding: 16px 12px 32px; gap: 22px; }
  .mw-row { padding: 10px 6px; }
  .mw-meta .status-pill { display: none; }
  /* Phones: the fields go right under the title, two per row; description, sub-tasks and comments follow. */
  .issue { display: flex; flex-direction: column; gap: 16px; }
  .issue-main { display: contents; }
  .issue-main > * { order: 2; }
  .issue-main > .issue-title, .issue-main > .issue-parent { order: 0; }
  .issue-side { order: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .issue-side .is-meta, .issue-side .is-source, .issue-side .is-buttons { grid-column: 1 / -1; }
  .issue-title { font-size: 19px; }
  .issue-form .if-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Second Brain ---------- */
.brain { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.brain-head { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; min-height: 58px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--border); }
.brain-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; font-weight: 800; white-space: nowrap; }
.brain-h .i { color: var(--accent); }
.brain-tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.brain-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--radius);
  color: var(--text-2); font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background 0.15s, color 0.15s;
}
.brain-tab:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.brain-tab.on { background: var(--accent-soft); color: var(--accent-text); }
.brain-add { height: 34px; }
.brain-history { display: none; }
.brain-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.brain-loading { padding: 24px; }

/* Ask */
.ask { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.ask-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 12px 10px; border-right: 1px solid var(--border); background: var(--bg-soft); }
.ask-new { justify-content: flex-start; }
.ask-chats { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.ask-chat { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.ask-chat:hover { background: var(--bg-hover); text-decoration: none; }
.ask-chat.on { background: var(--bg-active); }
.ask-chat-title { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.ask-chat small { font-size: 12px; color: var(--text-3); }
.ask-none { padding: 8px 10px; font-size: 13px; }
.ask-sheet { display: flex; flex-direction: column; gap: 8px; max-height: 70dvh; padding: 8px; }
.ask-main { display: flex; flex-direction: column; min-height: 0; }
.ask-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ask-thread { display: flex; flex-direction: column; gap: 22px; max-width: 780px; margin: 0 auto; padding: 24px 20px 12px; }
.ask-intro { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8vh 12px 12px; text-align: center; }
.ask-logo, .a-logo { display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.ask-logo { width: 60px; height: 60px; border-radius: 18px; box-shadow: var(--shadow); }
.ask-intro h2 { margin: 6px 0 0; font-size: 24px; letter-spacing: -0.01em; }
.ask-intro p { max-width: 54ch; margin: 0; line-height: 1.55; }
.ask-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 560px; margin-top: 14px; }
.ask-example {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg);
  color: var(--text); font-size: 14px; text-align: left; transition: border-color 0.15s, background 0.15s;
}
.ask-example:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.ask-empty { max-width: 54ch; margin: 10px 0 0; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--bg-soft); color: var(--text-2); }
.q-row { display: flex; justify-content: flex-end; }
.q-bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--bg-hover); font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.a-card { margin-top: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); }
.a-card.conf-none, .a-card.failed { background: var(--bg-soft); }
.a-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.a-logo { width: 24px; height: 24px; border-radius: 7px; }
.conf { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.c-high { background: color-mix(in srgb, var(--success) 14%, transparent); color: color-mix(in srgb, var(--success) 70%, var(--text)); }
.c-medium { background: color-mix(in srgb, #d97706 16%, transparent); color: color-mix(in srgb, #d97706 70%, var(--text)); }
.c-low { background: color-mix(in srgb, var(--danger) 14%, transparent); color: color-mix(in srgb, var(--danger) 72%, var(--text)); }
.c-none { background: var(--bg-hover); color: var(--text-2); }
.a-scope { margin-left: auto; font-size: 12px; color: var(--text-3); }
.a-body { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.a-status { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 14px; color: var(--text-2); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: brain-dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes brain-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.caret { display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: text-bottom; background: var(--accent); animation: brain-blink 1s steps(2) infinite; }
@keyframes brain-blink { 50% { opacity: 0; } }
.cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin: 0 1px; padding: 0 4px;
  border-radius: 5px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; line-height: 1; vertical-align: super;
}
.cite:hover { background: var(--accent); color: var(--on-accent); }
.a-hint { margin: 8px 0 0; font-size: 13px; color: var(--text-3); }
.a-sources { display: grid; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.a-sources-h { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.src { display: flex; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--bg-soft); transition: box-shadow 0.3s; }
.src.flash { box-shadow: 0 0 0 2px var(--accent); }
.src-n { display: grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; }
.src-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.src-main small { color: var(--text-3); }
.src-main p { margin: 2px 0 0; color: var(--text-2); font-style: italic; overflow-wrap: anywhere; }
.ask-composer { padding: 10px 20px 14px; border-top: 1px solid var(--border); background: var(--bg); }
.ask-box {
  display: flex; align-items: flex-end; gap: 8px; max-width: 780px; margin: 0 auto; padding: 8px 8px 8px 14px;
  border: 1px solid var(--border-strong); border-radius: 16px; background: var(--bg); box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.15s;
}
.ask-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-input { flex: 1; max-height: 200px; padding: 6px 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; line-height: 1.5; resize: none; }
.ask-send { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: var(--on-accent); transition: background 0.15s; }
.ask-send:hover { background: var(--accent-hover); }
.ask-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ask-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; max-width: 780px; margin: 8px auto 0; font-size: 12px; }
.ask-scope { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); }
.ask-scope select { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; }

/* Library */
.lib { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 1100px; padding: 16px 20px 32px; }
.lib-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-tools .input { width: auto; max-width: 100%; }
.lib-search { width: 260px; }
.lib-folders { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--text-2); font-size: 13px; font-weight: 600; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip-btn span { color: var(--text-3); font-weight: 500; }
.chip-btn:hover { border-color: var(--border-strong); color: var(--text); }
.chip-btn.on { border-color: var(--text); background: var(--text); color: var(--bg); }
.chip-btn.on span { color: inherit; opacity: 0.7; }
.lib-list { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.lib-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 110px 140px 120px 84px; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg); color: var(--text); text-align: left; }
.lib-row + .lib-row { border-top: 1px solid var(--border); }
.lib-row:hover { background: var(--bg-soft); }
.lib-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--bg-hover); color: var(--text-2); }
.lib-icon.k-pdf { background: #fee2e2; color: #b91c1c; }
.lib-icon.k-word { background: #dbeafe; color: #1d4ed8; }
.lib-icon.k-excel { background: #dcfce7; color: #15803d; }
.lib-icon.k-powerpoint { background: #ffedd5; color: #c2410c; }
.lib-icon.k-image { background: #f3e8ff; color: #7e22ce; }
.lib-icon.k-email { background: #e0f2fe; color: #0369a1; }
.lib-icon.k-web { background: #e0e7ff; color: #4338ca; }
.lib-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-main b, .lib-main small, .lib-space { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-main b { font-size: 14px; }
.lib-main small { font-size: 12.5px; color: var(--text-3); }
.lib-folder { justify-self: start; padding: 2px 8px; border-radius: 6px; background: var(--bg-hover); color: var(--text-2); font-size: 12px; font-weight: 600; }
.lib-space { font-size: 13px; color: var(--text-2); }
.lib-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.lib-status.s-ready { color: var(--success); }
.lib-status.s-failed { color: var(--danger); }
.spin { width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.lib-date { font-size: 12.5px; text-align: right; }
.lib-none { padding: 12px 0; }

/* Document details */
.doc-head { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text-2); }
.doc-title { font-size: 19px; font-weight: 700; }
.doc-title-ro { margin: 0; font-size: 20px; }
.doc-meta { margin: 6px 0 12px; font-size: 13px; overflow-wrap: anywhere; }
.doc-warn { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius); background: color-mix(in srgb, #d97706 14%, transparent); color: color-mix(in srgb, #d97706 70%, var(--text)); font-size: 13px; }
.doc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; }
.doc-main h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.doc-summary { margin: 0 0 18px; line-height: 1.6; }
.doc-decisions { margin: 0 0 8px; padding-left: 20px; line-height: 1.55; }
.doc-decisions li + li { margin-top: 4px; }
.doc-side { display: flex; flex-direction: column; gap: 12px; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* Add knowledge */
.add-seg { align-self: flex-start; }
.add-seg .seg-btn { display: inline-flex; align-items: center; gap: 6px; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg); color: var(--text-2); text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop small { color: var(--text-3); }
.add-files { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.add-files li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius); background: var(--bg-soft); font-size: 13px; }
.add-files li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-files li small { color: var(--text-3); }

/* Spaces and roles */
.spaces { display: flex; flex-direction: column; gap: 28px; width: 100%; max-width: 1000px; padding: 16px 20px 32px; }
.sp-sec h2 { margin: 0 0 4px; font-size: 17px; }
.sp-sec > p { margin: 0 0 12px; line-height: 1.55; }
.sp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.sp-head p { margin: 0; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sp-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.sp-card p { margin: 0; font-size: 13px; }
.sp-card-top { display: flex; align-items: center; justify-content: space-between; }
.sp-kind { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.sp-stats { margin-top: auto; font-size: 12.5px; color: var(--text-3); }
.sp-people { padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.role-select { width: auto; }
.role-fixed { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.sp-access { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; }
.radio-row, .check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.sp-pick { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }

/* Dashboard */
.dash { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 1150px; padding: 16px 20px 32px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.stat-value { font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; }
.stat small { font-size: 12.5px; }
.stat.warn .stat-value { color: color-mix(in srgb, #d97706 80%, var(--text)); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.panel-card { min-width: 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.panel-card.wide { grid-column: 1 / -1; }
.panel-card h3 { margin: 0 0 10px; font-size: 14px; }
.card-sub { margin: -4px 0 10px; font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bar-col { display: flex; flex: 1; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bar { width: 100%; max-width: 26px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--accent); }
.bar-col small { font-size: 10.5px; color: var(--text-3); }
.topics { display: flex; flex-wrap: wrap; gap: 6px; }
.topic { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: calc(13px * var(--w)); font-weight: 600; }
.topic small { font-size: 11px; opacity: 0.7; }
.gaps { display: flex; flex-direction: column; }
.gap { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 0; }
.gap + .gap { border-top: 1px solid var(--border); }
.gap-q { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.gap-meta { font-size: 12.5px; white-space: nowrap; }
.topdocs { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 20px; }
.topdocs li small { display: block; }
.link-row { color: var(--text); font-weight: 600; text-align: left; }
.link-row:hover { color: var(--accent); text-decoration: underline; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 90px minmax(0, 1fr) 32px; align-items: center; gap: 10px; font-size: 13px; }
.hbar-track { height: 8px; overflow: hidden; border-radius: 4px; background: var(--bg-hover); }
.hbar-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.hbar b { text-align: right; }

@media (max-width: 768px) {
  .shell[data-view='brain'] .sidebar, .shell[data-view='brain'] .panel { display: none; }
  .shell[data-view='brain'] .main { padding-bottom: calc(58px + var(--safe-b)); }
  .brain-head { padding: 8px 12px; }
  .brain-h { flex: 1; }
  .brain-history { display: inline-grid; order: 2; }
  .brain-add { order: 3; width: 40px; padding: 0; }
  .brain-add span { display: none; }
  .brain-tabs { order: 4; flex-basis: 100%; }
  .ask { grid-template-columns: 1fr; }
  .ask-side { display: none; }
  .ask-thread { padding: 16px 12px 8px; }
  .ask-composer { padding: 8px 10px 10px; }
  .ask-examples { grid-template-columns: 1fr; }
  .q-bubble { max-width: 90%; }
  .lib { padding: 12px; }
  .lib-search { flex: 1; width: auto; min-width: 0; }
  .lib-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .lib-folder, .lib-space, .lib-date { display: none; }
  .doc-grid { grid-template-columns: 1fr; }
  .spaces, .dash { padding: 12px; }
  .sp-head { flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .gap { grid-template-columns: minmax(0, 1fr) auto; }
  .gap-meta { grid-column: 1; grid-row: 2; white-space: normal; }
}

/* ---------- Activity reports ---------- */
.reports { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rp-select { width: auto; max-width: 200px; padding-right: 8px; }
.rp-wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 16px; }
.rp-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 20px; text-align: center; }
.rp-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-soft); color: var(--text-2); font-size: 13.5px; }
.rp-note .i { flex: none; margin-top: 2px; color: var(--accent); }
.rp-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.rp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rp-table th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-soft); }
.rp-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rp-table tbody tr { cursor: pointer; transition: background 0.15s; }
.rp-table tbody tr:hover, .rp-table tbody tr:focus-visible { background: var(--bg-hover); outline: none; }
.rp-table tbody tr:last-child td { border-bottom: 0; }
.rp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rp-table td.zero { color: var(--text-3); }
.rp-table td.warn { color: var(--danger); font-weight: 700; }
.rp-person { display: flex; align-items: center; gap: 10px; }
.rp-person b { display: block; font-weight: 600; }
.rp-person small { display: block; color: var(--text-3); font-size: 12px; }
.rp-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.rp-card { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.rp-card-h { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.rp-card b { font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.rp-card small { color: var(--text-3); font-size: 12.5px; }
.rp-card.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: color-mix(in srgb, var(--warning) 7%, transparent); }
.rp-card.warn b { color: var(--warning); }
.rp-sec { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.rp-sec h2 { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 15px; font-weight: 700; }
.rp-sec h3 { margin: 12px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.rp-sec h2 + h3 { margin-top: 0; }
.rp-sec > .muted:last-child { margin-bottom: 0; }
.rp-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.rp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rp-list li { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; }
.rp-list a { color: var(--text); text-decoration: none; }
.rp-list a:hover { color: var(--accent-text); text-decoration: underline; }
.rp-list small { color: var(--text-3); font-size: 12.5px; }
.rp-item { flex-direction: column; align-items: flex-start !important; }
.rp-item.done > span { color: var(--text-3); text-decoration: line-through; }
.rp-task small.late { color: var(--danger); font-weight: 600; }
.rp-count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.rp-meter { flex-basis: 100%; height: 4px; border-radius: 2px; background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 0 / var(--w) 100%, var(--bg-soft); }
.rp-bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.rp-day { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.rp-bar { width: 100%; max-width: 36px; height: max(3px, var(--h)); border-radius: 4px 4px 2px 2px; background: var(--accent); }
.rp-bar.zero { height: 3px; background: var(--border); }
.rp-day small { height: 14px; font-size: 11px; color: var(--text-3); white-space: nowrap; }
.rp-ai { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.rp-ai h2 .i { color: var(--accent); }
.rp-review { font-size: 14.5px; line-height: 1.55; }
.rp-review h2 { font-size: 15px; margin: 16px 0 6px; }
.rp-review-meta { margin-bottom: 6px; }
.rp-review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.rp-writing { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--text-2); }
.rp-spin { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.rp-earlier { margin-top: 12px; font-size: 13.5px; }
.rp-earlier summary { cursor: pointer; color: var(--text-2); }
.rp-earlier .rp-list { margin-top: 8px; }
@media (max-width: 900px) {
  .rp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-cols { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .shell[data-view='reports'] .sidebar, .shell[data-view='reports'] .panel { display: none; }
  .shell[data-view='reports'] .main { padding-bottom: calc(58px + var(--safe-b)); }
}
@media (max-width: 640px) {
  .rp-wrap { padding: 12px 12px 24px; }
  .rp-card b { font-size: 24px; }
}

/* ---------- Performance review PDF (print layout; only shown while printing) ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 15mm 16mm 16mm; }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; color: #14123a; background: #fff; font: 10.5pt/1.5 var(--font); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-head { padding-bottom: 10pt; border-bottom: 2pt solid #4f46e5; }
  .pr-brand { display: flex; align-items: center; gap: 8pt; font-size: 10pt; font-weight: 600; color: #525675; }
  .pr-brand img { border-radius: 6pt; }
  .pr-brand em { margin-left: auto; font-style: normal; font-size: 8pt; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #b91c1c; }
  .pr-head h1 { margin: 12pt 0 2pt; font-size: 22pt; line-height: 1.15; color: #1e1b4b; }
  .pr-who { margin: 0; font-size: 12.5pt; }
  .pr-meta { margin: 2pt 0 0; font-size: 9.5pt; color: #525675; }
  .pr-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8pt; margin: 12pt 0 4pt; }
  .pr-stat { padding: 8pt 10pt; border-radius: 6pt; background: #f4f3fb; break-inside: avoid; }
  .pr-stat small { display: block; font-size: 8pt; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #525675; }
  .pr-stat b { display: block; font-size: 17pt; line-height: 1.25; color: #1e1b4b; }
  .pr-stat span { font-size: 8.5pt; color: #525675; }
  .pr-review { font-size: 10.5pt; }
  .pr-review h1, .pr-review h2, .pr-review h3 { margin: 14pt 0 4pt; font-size: 12.5pt; font-weight: 700; color: #1e1b4b; break-after: avoid; }
  .pr-review ul, .pr-review ol, .pr-facts ul { margin: 2pt 0 6pt; padding-left: 16pt; }
  .pr-review li, .pr-facts li { margin: 2pt 0; break-inside: avoid; }
  .pr-review a, .pr-review button { color: inherit; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; }
  .pr-facts { margin-top: 14pt; padding-top: 10pt; border-top: 1pt solid #e5e4f0; break-before: page; }
  .pr-facts h2 { margin: 0 0 4pt; font-size: 14pt; color: #1e1b4b; }
  .pr-facts h3 { margin: 10pt 0 2pt; font-size: 9pt; letter-spacing: 0.06em; text-transform: uppercase; color: #4f46e5; break-after: avoid; }
  .pr-facts p { margin: 2pt 0; }
  .pr-dim { color: #6b6e8a; }
  .pr-late { font-size: 8pt; font-weight: 700; text-transform: uppercase; color: #b91c1c; }
  .pr-foot { margin-top: 14pt; padding-top: 8pt; border-top: 1pt solid #e5e4f0; font-size: 8.5pt; color: #6b6e8a; }
}

/* ---------- Sounds window ---------- */
.snd-block { padding: 6px 0 4px; }
.snd-row { display: flex; align-items: flex-end; gap: 8px; }
.snd-row .field { flex: 1; min-width: 0; margin: 0; }
.snd-row .btn { flex: none; height: 40px; }
.snd-block .muted.xs { margin: 6px 0 0; }
.snd-volume { margin-top: 10px; }
.snd-volume input[type='range'] { width: 100%; accent-color: var(--accent); }
.snd-switch { margin: 14px 0 6px; }
.snd-note { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-soft); color: var(--text-2); font-size: 13px; }
.snd-note .i { flex: none; margin-top: 2px; color: var(--accent); }

/* "Open in the TeamPulse app" bar in phone browsers */
.open-app {
  position: fixed; left: 12px; right: 12px; bottom: calc(72px + var(--safe-b, 0px)); z-index: 60;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  border-radius: var(--radius-lg); background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}
.open-app img { flex: none; border-radius: 7px; }
.open-app span { flex: 1; min-width: 0; }
.open-app .btn { flex: none; }

/* ---------- Meeting background picker ---------- */
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 12px; }
.bg-tile { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 2px solid transparent; border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.bg-tile:hover { background: var(--bg-hover); }
.bg-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bg-tile.on { border-color: var(--accent); background: var(--accent-soft); }
.bg-swatch { display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; object-fit: cover; background: var(--bg-soft); color: var(--text-2); }
.bg-swatch.blur { background: radial-gradient(circle at 50% 40%, #cbd5e1 0 18%, transparent 19%), linear-gradient(135deg, #94a3b8, #475569); filter: blur(1.5px); }
.bg-swatch.blur.strong { filter: blur(4px); }
.bg-swatch.upload { border: 1px dashed var(--border-strong); }
.bg-status { min-height: 18px; margin: 10px 0 0; }
.pj-toggles [data-m='bg'][hidden] { display: none; }
.bg-preview { position: relative; width: min(100%, 392px); aspect-ratio: 16 / 9; margin: 12px auto 0; border-radius: var(--radius); overflow: hidden; background: #1c2030; }
.bg-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.bg-preview video.plain { transform: none; }
.bg-preview[hidden] { display: none; }

/* ---------- Read receipts ---------- */
.msg.own { padding-right: 46px; }
.receipt-slot { position: absolute; right: 14px; bottom: 5px; }
.receipt { display: grid; place-items: center; width: 26px; height: 24px; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-3); cursor: pointer; transition: background 0.15s, color 0.15s; }
.receipt:hover { background: var(--bg-hover); color: var(--text-2); }
.receipt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.receipt.all, .receipt.all:hover { color: var(--read); }
@media (pointer: coarse) { .receipt { width: 32px; height: 30px; } .receipt-slot { right: 8px; bottom: 2px; } }

.mi-preview { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-soft); }
.mi-preview p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mi-head { display: flex; align-items: center; gap: 6px; margin: 18px 0 6px; font-size: 14px; }
.mi-head .muted { font-weight: 500; }
.mi-head.read svg { color: var(--read); }
.mi-head svg { color: var(--text-3); }
.mi-list { list-style: none; margin: 0; padding: 0; max-height: 36vh; overflow-y: auto; }
.mi-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.mi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-time { flex: none; font-size: 12px; }
.mi-empty { margin: 0; font-size: 13px; }
