@font-face {
  font-family: 'JimmyQrg';
  src: url('/assets/ttf/jimmyqrg.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JimmyComicLatin';
  src: url('/assets/ttf/comic.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JimmyComicChinese';
  src: url('/assets/ttf/comic-chinese.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JimmyComic2';
  src: url('/assets/ttf/comic2.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'ChatCode';
  src: url('/assets/ttf/code.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Themes: JimmyQrg (default), Simple, Comic – fonts use local TTFs in /assets/ttf (plus system fallbacks) */
:root,
html[data-theme="jimmyqrg"] {
  --font-family: 'JimmyQrg', system-ui, sans-serif;
  --font-code: 'Oxygen Mono', 'ChatCode', ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  --bg-deep: #0a0612;
  --bg-main: #120c1a;
  --bg-panel: #1a1225;
  --bg-hover: #251a35;
  --border: #2d2240;
  --purple: #8b5cf6;
  --purple-dim: #6d28d9;
  --purple-bright: #a78bfa;
  --accent: #c084fc;
  --text: #e9e0f5;
  --text-dim: #a78bb8;
  --text-muted: #8b7a9e;
  --star: rgba(196, 181, 255, 0.15);
  --glow: rgba(139, 92, 246, 0.3);
  --border-width: 1px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-fast: 0.15s var(--ease);
  --transition-normal: 0.25s var(--ease);
  --transition-slow: 0.35s var(--ease);
  --chatbox-other: url('/assets/chatboxes/default/other.svg');
  --chatbox-own: url('/assets/chatboxes/default/own.svg');
}

/* Simple: formal, Roboto, light, blue & green */
html[data-theme="simple"] {
  --font-family: 'Roboto', system-ui, sans-serif;
  --font-code: 'Oxygen Mono', 'ChatCode', ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  --bg-deep: #e8f0f7;
  --bg-main: #ffffff;
  --bg-panel: #f5f9fc;
  --bg-hover: #e3eef6;
  --border: #b8d4e8;
  --purple: #1976d2;
  --purple-dim: #0d47a1;
  --purple-bright: #42a5f5;
  --accent: #2e7d32;
  --text: #1a237e;
  --text-dim: #5c6bc0;
  --text-muted: #7986cb;
  --star: rgba(25, 118, 210, 0.12);
  --glow: rgba(25, 118, 210, 0.25);
  --border-width: 1px;
  --chatbox-other: url('/assets/chatboxes/default/other.svg');
  --chatbox-own: url('/assets/chatboxes/default/own.svg');
}

html[data-theme="simple"] body.auth-page::before,
html[data-theme="simple"] body::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 248, 255, 0.9) 100%),
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--glow), transparent);
}

html[data-theme="simple"] body::after {
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 40px 70px, var(--star), transparent),
    radial-gradient(1px 1px at 90px 40px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 130px 80px, var(--star), transparent),
    radial-gradient(1px 1px at 160px 120px, var(--star), transparent);
}

/* Comic: hand-written, Nunito, light, white/black/orange, thicker lines */
html[data-theme="comic"] {
  --font-family: 'JimmyComicLatin', 'JimmyComicChinese', system-ui, sans-serif;
  --font-code: 'Oxygen Mono', 'ChatCode', ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  --bg-deep: #ffffff;
  --bg-main: #ffffff;
  --bg-panel: #fafafa;
  --bg-hover: #f5f5f5;
  --border: #2d2d2d;
  --purple: #ff8c00;
  --purple-dim: #e67e00;
  --purple-bright: #ffa726;
  --accent: #ff8c00;
  --text: #1a1a1a;
  --text-dim: #4d4d4d;
  --text-muted: #666666;
  --star: rgba(0, 0, 0, 0.06);
  --glow: rgba(255, 140, 0, 0.2);
  --border-width: 3px;
  --chatbox-other: url('/assets/chatboxes/default/other.svg');
  --chatbox-own: url('/assets/chatboxes/default/own.svg');
}

html[data-theme="comic"] body.auth-page::before,
html[data-theme="comic"] body::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.92) 100%),
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--glow), transparent);
}

html[data-theme="comic"] body::after {
  background-image:
    radial-gradient(2px 2px at 20px 30px, var(--star), transparent),
    radial-gradient(2px 2px at 40px 70px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 90px 40px, var(--star), transparent),
    radial-gradient(2px 2px at 130px 80px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 160px 120px, var(--star), transparent);
}

html[data-theme="comic"] body {
  font-weight: 600;
}

/* Simple: own message bubble */
html[data-theme="simple"] .message.own .message-body-file {
  background: #0d47a1;
  border-color: #1565c0;
}
html[data-theme="simple"] .message.own .message-body,
html[data-theme="simple"] .message.own .message-body .message-content,
html[data-theme="simple"] .message.own .message-body .message-reply-preview {
  color: #ffffff;
}
html[data-theme="simple"] .message.own .message-body .message-reply-preview {
  color: rgba(255, 255, 255, 0.85);
  border-left-color: rgba(255, 255, 255, 0.6);
}

/* Comic: own message bubble */
html[data-theme="comic"] .message.own .message-body-file {
  background: var(--purple-dim);
  border-color: var(--purple);
}
html[data-theme="comic"] .message.own .message-body,
html[data-theme="comic"] .message.own .message-body .message-content,
html[data-theme="comic"] .message.own .message-body .message-reply-preview {
  color: #ffffff;
}
html[data-theme="comic"] .message.own .message-body .message-reply-preview {
  color: rgba(255, 255, 255, 0.85);
  border-left-color: rgba(255, 255, 255, 0.6);
}

/* ── Study: plain study / notes page ──────────────────────────────────────
   Calm paper light, readable text, and no ambient decoration at all: the
   twinkling starfield, the purple glow wash and the gradient overlays are all
   removed. Message bubbles always render as the plain default (any sender's
   custom bubble skin is neutralised), and motion is effectively instant so
   nothing bounces or eases. */
html[data-theme="study"] {
  --font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-code: 'Oxygen Mono', 'ChatCode', ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  --bg-deep: #f4f5f7;
  --bg-main: #ffffff;
  --bg-panel: #ffffff;
  --bg-hover: #eef1f4;
  --border: #d7dce2;
  --purple: #2f5d8f;
  --purple-dim: #3c6ea6;
  --purple-bright: #35699f;
  --accent: #2f5d8f;
  --text: #1f2933;
  --text-dim: #52606d;
  --text-muted: #7b8794;
  --star: transparent;
  --glow: transparent;
  --border-width: 1px;
  --ease: linear;
  --transition-fast: 0.01s linear;
  --transition-normal: 0.01s linear;
  --transition-slow: 0.01s linear;
  --chatbox-other: url('/assets/chatboxes/default/other.svg');
  --chatbox-own: url('/assets/chatboxes/default/own.svg');
}

/* Flat paper background — no gradient wash, no starfield. */
html[data-theme="study"] body,
html[data-theme="study"] body.auth-page {
  background: var(--bg-deep);
}
html[data-theme="study"] body::before {
  background: var(--bg-deep) !important;
}
html[data-theme="study"] body::after {
  content: none !important;
  background-image: none !important;
  animation: none !important;
}

/* Always the plain default bubble: neutralise the SVG 9-slice bubble and every
   per-style chatbox skin (they use !important, so these must too). */
html[data-theme="study"] .message-body,
html[data-theme="study"] .message-body.message-body-svg,
html[data-theme="study"] .message-body[class*="chatbox-"] {
  border: 1px solid var(--border) !important;
  border-image: none !important;
  border-radius: 6px !important;
  background: #ffffff !important;
  box-shadow: none !important;
  padding: 0.4rem 0.8rem 0.55rem !important;
  color: var(--text) !important;
  overflow-wrap: anywhere;
}
html[data-theme="study"] .message.own .message-body,
html[data-theme="study"] .message.own .message-body.message-body-svg,
html[data-theme="study"] .message.own .message-body[class*="chatbox-"] {
  background: #e8eef5 !important;
  border-color: #c3d2e2 !important;
  color: var(--text) !important;
}
html[data-theme="study"] .message-body[class*="chatbox-"]::before,
html[data-theme="study"] .message-body[class*="chatbox-"]::after {
  content: none !important;
  background: none !important;
}
html[data-theme="study"] .message-body .message-content,
html[data-theme="study"] .message-body .message-reply-preview,
html[data-theme="study"] .message.own .message-body .message-content,
html[data-theme="study"] .message.own .message-body .message-reply-preview {
  color: var(--text) !important;
}
html[data-theme="study"] .message-body .message-reply-preview {
  border-left-color: var(--border) !important;
}

/* Hard, instant motion: nothing eases, bounces or twinkles. */
html[data-theme="study"] *,
html[data-theme="study"] *::before,
html[data-theme="study"] *::after {
  animation-duration: 0.01s !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01s !important;
  transition-delay: 0s !important;
}
/* Keep loaders actually spinning — an instant spinner reads as "frozen". */
html[data-theme="study"] .loading-spinner,
html[data-theme="study"] .inbox-loading-spinner,
html[data-theme="study"] .admin-loading-spinner {
  animation-duration: 0.9s !important;
  animation-iteration-count: infinite !important;
}

/* A few glows in the base stylesheet are hardcoded purple and so don't follow
   the theme variables — flatten them, otherwise the study page still glows. */
html[data-theme="study"] .auth-box,
html[data-theme="study"] .auth-box:hover,
html[data-theme="study"] .auth-box button[type="submit"]:hover {
  box-shadow: none !important;
  transform: none !important;
}
html[data-theme="study"] .hc-compact-btn:hover:not(.is-busy) {
  background: var(--bg-hover) !important;
}
html[data-theme="study"] [class*="glow"] {
  box-shadow: none !important;
  text-shadow: none !important;
}

/* ══ STUDY — LAYOUT PASS ═════════════════════════════════════════════════
   The app is built as a rounded, elevated, floating-bubble UI. Recolouring
   that can never read as a study page: the shape language and the reading
   structure have to change. Study pages are square-cornered, flat, dense and
   left-aligned, so this section squares off every corner, removes elevation
   (separation comes from rules, not shadows), and re-lays the conversation
   out as a document thread — full-width rows on rules — instead of
   alternating chat bubbles.
   ====================================================================== */

/* 1 · Shape: square corners, everywhere. */
html[data-theme="study"] *,
html[data-theme="study"] *::before,
html[data-theme="study"] *::after {
  border-radius: 0 !important;
}
/* Natives that genuinely look broken when perfectly square. */
html[data-theme="study"] input[type="checkbox"],
html[data-theme="study"] input[type="radio"] {
  border-radius: 2px !important;
}

/* 2 · Elevation: flat. No drop shadows, no glow, no text shadow. */
html[data-theme="study"] *,
html[data-theme="study"] *::before,
html[data-theme="study"] *::after {
  box-shadow: none !important;
  text-shadow: none !important;
}

/* 3 · The conversation is a document thread, not alternating bubbles:
      every message is a full-width row on a rule, left-aligned. */
html[data-theme="study"] .messages-wrap {
  background: #ffffff !important;
  padding: 0 1.5rem !important;
}
html[data-theme="study"] .message-row,
html[data-theme="study"] .message-row:has(.message.own) {
  grid-template-columns: 28px 1fr !important;
  border-bottom: 1px solid var(--border) !important;
  margin-bottom: 0 !important;
  padding: 0.8rem 0 !important;
}
html[data-theme="study"] .message,
html[data-theme="study"] .message.own {
  max-width: 100% !important;
  align-items: flex-start !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  padding: 0 !important;
}
html[data-theme="study"] .message-header,
html[data-theme="study"] .message.own .message-header {
  justify-content: flex-start !important;
  padding: 0 !important;
}
html[data-theme="study"] .message-inline,
html[data-theme="study"] .message.own .message-inline {
  flex-direction: row !important;
  gap: 0.6rem !important;
}
html[data-theme="study"] .message-avatar {
  width: 26px !important;
  height: 26px !important;
}
/* No bubble chrome of any kind — including every custom chatbox skin. */
html[data-theme="study"] .message-body,
html[data-theme="study"] .message.own .message-body,
html[data-theme="study"] .message-body.message-body-svg,
html[data-theme="study"] .message-body[class*="chatbox-"] {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
}
/* Authorship stays legible without a bubble: own posts get a quiet accent
   bar and a faint tint, like an annotated passage rather than a chat balloon.
   The bar uses the theme accent so it stays visible on the light page. */
html[data-theme="study"] .message.own .message-body {
  background: #eef2f6 !important;
  border-left: 3px solid var(--purple) !important;
  padding: 0.15rem 0.6rem !important;
}

/* 4 · Navigation becomes a plain sidebar column, not a floating icon rail. */
html[data-theme="study"] .left-bar,
html[data-theme="study"] .left-bar-expanded {
  background: #ffffff !important;
  border-right: 1px solid var(--border) !important;
}
html[data-theme="study"] .left-bar-item.active {
  background: #eef2f6 !important;
  color: var(--text) !important;
  border-left: 3px solid var(--purple) !important;
}

/* 5 · Chrome: headers and panels are ruled, not elevated. */
html[data-theme="study"] .chat-header {
  background: #ffffff !important;
  border-bottom: 2px solid var(--border) !important;
}
html[data-theme="study"] .composer {
  background: #ffffff !important;
  border-top: 1px solid var(--border) !important;
}
html[data-theme="study"] .composer-input-wrap,
html[data-theme="study"] .composer-input {
  background: #ffffff !important;
  border: 1px solid var(--border) !important;
}
html[data-theme="study"] .settings-page,
html[data-theme="study"] .admin-section,
html[data-theme="study"] .chat-side-panel {
  background: #ffffff !important;
  border-color: var(--border) !important;
}

/* 6 · Headings read as document section headings: ruled, not floating. */
html[data-theme="study"] .settings-section-title,
html[data-theme="study"] .admin-section-title,
html[data-theme="study"] .panel-list-title {
  border-bottom: 1px solid var(--border) !important;
  padding-bottom: 0.3rem !important;
  letter-spacing: 0 !important;
}

/* ══ STUDY — DE-GAMIFY PASS ══════════════════════════════════════════
   Repainting alone left two problems: the Venory/premium layer kept a dark
   purple gradient panel, a gold crown and a glowing purple nav icon, and it
   hardcodes white/light text for a dark background in ~26 places — on paper
   that text vanished. Everything here flattens premium to plain paper and
   forces readable ink. Targets were found with a computed-colour sweep of a
   running instance (contrast audit), not guessed from the source.
   ================================================================== */

/* ── 1 · The upgrade panel becomes a paper card: no gradient, no glow. ── */
html[data-theme="study"] .premium-modal-backdrop {
  background: rgba(15, 23, 42, 0.45) !important;
  backdrop-filter: none !important;
}
html[data-theme="study"] .premium-modal-card {
  background: #ffffff !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  color: var(--text) !important;
}
/* The headline uses gradient-clipped text (transparent fill + bright wash). */
html[data-theme="study"] .premium-head h2 {
  background: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  color: var(--text) !important;
}
/* Crown / banner icons become small neutral marks — no gold, no halo. */
html[data-theme="study"] .premium-crown,
html[data-theme="study"] .premium-banner-icon {
  color: var(--text-muted) !important;
  filter: none !important;
}
html[data-theme="study"] .premium-crown svg { width: 22px !important; height: 22px !important; }
html[data-theme="study"] .premium-account-state {
  color: var(--text-muted) !important;
  letter-spacing: 0.02em !important;
}

/* ── 2 · Ink, not the dark-theme white, on every premium text surface. ── */
html[data-theme="study"] .premium-sub,
html[data-theme="study"] .premium-loading,
html[data-theme="study"] .premium-status,
html[data-theme="study"] .premium-tier-features,
html[data-theme="study"] .premium-tier-features li,
html[data-theme="study"] .premium-tier-name,
html[data-theme="study"] .premium-tier-price,
html[data-theme="study"] .premium-settings-hint,
html[data-theme="study"] .premium-settings-features,
html[data-theme="study"] .premium-settings-features li,
html[data-theme="study"] .premium-banner-text strong,
html[data-theme="study"] .premium-banner-text span,
html[data-theme="study"] .premium-quota-text,
html[data-theme="study"] .premium-member-callout {
  color: var(--text) !important;
  opacity: 1 !important;
}
html[data-theme="study"] .premium-modal-close { color: var(--text-dim) !important; }
html[data-theme="study"] .premium-modal-close:hover { color: var(--text) !important; }

/* ── 3 · Buttons: no gradient fills, no saturated purple CTA. ── */
html[data-theme="study"] .premium-btn,
html[data-theme="study"] .premium-btn.ghost,
html[data-theme="study"] .premium-quota-cta,
html[data-theme="study"] .premium-plan-btn {
  background: #ffffff !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
html[data-theme="study"] .premium-btn.primary {
  background: var(--text) !important;
  background-image: none !important;
  border-color: var(--text) !important;
  color: #ffffff !important;
}
html[data-theme="study"] .premium-btn.primary:disabled { opacity: 0.45 !important; }
html[data-theme="study"] .premium-plan-btn.active {
  background: var(--bg-hover) !important;
  border-color: var(--text) !important;
  color: var(--text) !important;
}

/* ── 4 · Tier cards, chips and banners: plain bordered paper. ── */
html[data-theme="study"] .premium-tier,
html[data-theme="study"] .premium-tier:hover,
html[data-theme="study"] .premium-tier.selected,
html[data-theme="study"] .premium-tier.current {
  background: #ffffff !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}
html[data-theme="study"] .premium-tier.selected { border-color: var(--text) !important; }
html[data-theme="study"] .premium-tier-badge,
html[data-theme="study"] .premium-plan-chip,
html[data-theme="study"] .premium-plan-chip.tier-premium,
html[data-theme="study"] .premium-plan-chip.tier-plus {
  background: var(--bg-hover) !important;
  background-image: none !important;
  color: var(--text) !important;
}
html[data-theme="study"] .premium-plan-save { color: var(--text-dim) !important; }
html[data-theme="study"] .premium-settings-card,
html[data-theme="study"] .premium-banner,
html[data-theme="study"] .premium-banner.active,
html[data-theme="study"] .premium-member-callout {
  background: #ffffff !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
}

/* ── 5 · The glowing purple nav icon and badge dot. ── */
html[data-theme="study"] .left-bar-item.premium-left-bar.is-premium .left-bar-icon {
  filter: none !important;
  box-shadow: none !important;
}
html[data-theme="study"] .premium-badge-dot,
html[data-theme="study"] .premium-quota-fill {
  background: var(--text-muted) !important;
  background-image: none !important;
}
html[data-theme="study"] .premium-quota-track { background: var(--bg-hover) !important; }
html[data-theme="study"] .premium-quota-cta { padding: 3px 10px !important; }

/* ── 6 · Cut the strongest chat-app tells. ── */
/* Avatars say "messenger"; the sender name already identifies the speaker. */
html[data-theme="study"] .message-avatar-wrap,
html[data-theme="study"] .message-avatar,
html[data-theme="study"] .message-skeleton-avatar {
  display: none !important;
}
html[data-theme="study"] .message-row,
html[data-theme="study"] .message-row:has(.message.own) {
  grid-template-columns: 1fr !important;
}
/* Presence line ("2 online · 6 members") is status furniture, not content. */
html[data-theme="study"] .chat-header-subtitle { display: none !important; }
/* Voice / send / attachment accents: plain ink, not saturated UI colours. */
html[data-theme="study"] .panel-voice-btn,
html[data-theme="study"] .panel-voice-btn:hover {
  background: #ffffff !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
html[data-theme="study"] .panel-voice-text,
html[data-theme="study"] .panel-voice-icon { color: var(--text) !important; }
html[data-theme="study"] .panel-voice-count {
  background: var(--bg-hover) !important;
  color: var(--text) !important;
}
html[data-theme="study"] .composer-send {
  background: var(--text) !important;
  background-image: none !important;
  border: 1px solid var(--text) !important;
  color: #ffffff !important;
  box-shadow: none !important;
}
html[data-theme="study"] .composer-actions button,
html[data-theme="study"] .composer-actions .icon { color: var(--text-dim) !important; }

/* ── 7 · Remaining low-contrast text, and the rank-style role chips. ── */
/* Placeholders were the one unreadable string left: they inherit the dark
   theme's light grey and have no Study override. */
html[data-theme="study"] input::placeholder,
html[data-theme="study"] textarea::placeholder,
html[data-theme="study"] .composer-input::placeholder {
  color: var(--text-dim) !important;
  opacity: 1 !important;
}
html[data-theme="study"] .premium-account-state,
html[data-theme="study"] .premium-status,
html[data-theme="study"] .premium-settings-hint,
html[data-theme="study"] .premium-sub {
  color: var(--text-dim) !important;
}
/* Owner / Admin / Assistance chips are lavender-gold gradients — they read as
   ranks or tiers. On paper they become plain ruled labels. */
html[data-theme="study"] .user-tag,
html[data-theme="study"] .user-tag-helper,
html[data-theme="study"] .user-tag-owner,
html[data-theme="study"] .user-tag-admin {
  background: var(--bg-hover) !important;
  background-image: none !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

/* ── Theme picker (Settings → General) ── */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin: 0.4rem 0 0.2rem;
}
.theme-picker-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.8rem;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.theme-picker-item:hover { background: var(--bg-hover); }
.theme-picker-item.active { border-color: var(--purple); }
.theme-picker-swatch {
  display: block;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.theme-swatch-jimmyqrg {
  background: linear-gradient(135deg, #120c1a 0%, #2d2240 60%, #8b5cf6 100%);
}
.theme-swatch-study {
  background: linear-gradient(135deg, #ffffff 0%, #f4f5f7 55%, #d7dce2 100%);
}
.theme-picker-label { font-weight: 600; font-size: 0.95rem; }
.theme-picker-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.3; }

/* Required first-visit theme chooser (shown before the sign-in screen). */
.theme-gate-box { max-width: 520px; }
.theme-gate-desc { color: var(--text-dim); font-size: 0.9rem; margin: 0.4rem 0 1rem; line-height: 1.45; }
.theme-gate-picker { margin: 0; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

html {
  font-family: var(--font-family);
  height: 100%;
}

body {
  font-family: inherit;
  background: var(--bg-deep);
  color: var(--text);
  height: 100%;
  /* Use small viewport height on mobile so content fits in visible area and scrolls inside the app */
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  max-height: 100vh;
  max-height: 100dvh;
  max-height: 100svh;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

button,
input,
select,
textarea,
optgroup,
[role="button"] {
  font-family: var(--font-family);
}

body.auth-page {
  background: var(--bg-deep);
  overflow: hidden;
}

/* Chat normally clips its full-screen shell. On auth pages the shell itself
   scrolls so tall forms remain reachable on short screens. */
body.auth-page #app {
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

body.auth-page::before {
  /* Keep the decorative backdrop fixed while #app scrolls the auth form. */
  background:
    linear-gradient(180deg, rgba(10, 6, 18, 0.5) 0%, rgba(10, 6, 18, 0.45) 100%),
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--glow), transparent),
    url('https://jimmyqrg.pages.dev/background.png') center / cover no-repeat;
  pointer-events: none;
}

/* Overlay so text stays readable – behind all content so clicks always hit buttons */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(10, 6, 18, 0.85) 0%, rgba(10, 6, 18, 0.75) 100%),
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--glow), transparent),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(109, 40, 217, 0.12), transparent);
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 40px 70px, var(--star), transparent),
    radial-gradient(1px 1px at 90px 40px, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 130px 80px, var(--star), transparent),
    radial-gradient(1px 1px at 160px 120px, var(--star), transparent);
  background-size: 200px 200px;
  pointer-events: none;
  animation: twinkle 8s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  overflow: hidden;
}

#app button,
#app a[href],
#app input,
#app textarea,
#app select,
#app [role="button"] {
  position: relative;
  z-index: 1;
}

/* Custom file input (Choose file) */
.file-label {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: var(--border-width) dashed var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.file-label:hover {
  border-color: var(--purple);
  color: var(--text);
  background: var(--bg-hover);
}

.file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Custom select / dropdown */
select {
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a78bb8' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

select:hover {
  border-color: var(--purple-dim);
}

select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

/* Loading screen (before app hydrates) */
#app.app-loading {
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.loading-text {
  color: var(--text-dim);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

/* Auth screen – background only on login/signup */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  position: relative;
}

/* 28 transition animations (keyframes) */
@keyframes authFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes authFadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes authFadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes authSlideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes authSlideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes authScaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes authZoomIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes authRotateIn {
  from { opacity: 0; transform: rotate(-12deg) scale(0.95); }
  to { opacity: 1; transform: rotate(0) scale(1); }
}
@keyframes authBounceIn {
  from { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes authFlipInX {
  from { opacity: 0; transform: perspective(400px) rotateX(90deg); }
  to { opacity: 1; transform: perspective(400px) rotateX(0); }
}
@keyframes authFlipInY {
  from { opacity: 0; transform: perspective(400px) rotateY(-90deg); }
  to { opacity: 1; transform: perspective(400px) rotateY(0); }
}
@keyframes authRollIn {
  from { opacity: 0; transform: translateX(-100%) rotate(-120deg); }
  to { opacity: 1; transform: translateX(0) rotate(0); }
}
@keyframes authSwingIn {
  from { opacity: 0; transform: rotate(-15deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-4deg); }
  to { opacity: 1; transform: rotate(0); }
}
@keyframes authLightSpeedIn {
  from { opacity: 0; transform: translateX(100%) skewX(-25deg); }
  60% { transform: skewX(10deg); }
  80% { transform: skewX(-5deg); }
  to { opacity: 1; transform: translateX(0) skewX(0); }
}
@keyframes authPulseIn {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.02); }
}
@keyframes authShakeIn {
  from { opacity: 0; }
  20%, 60%, 100% { transform: translateX(0); opacity: 1; }
  40% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}
@keyframes authGlowIn {
  from { opacity: 0; box-shadow: 0 0 0 0 var(--glow); }
  to { opacity: 1; box-shadow: 0 0 24px var(--glow); }
}
@keyframes authBlurIn {
  from { opacity: 0; filter: blur(8px); }
  to { opacity: 1; filter: blur(0); }
}
@keyframes authExpandIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes authSlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes authSlideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes authFlipIn {
  from { opacity: 0; transform: perspective(400px) rotateY(90deg); }
  to { opacity: 1; transform: perspective(400px) rotateY(0); }
}
@keyframes authJackInTheBox {
  from { opacity: 0; transform: scale(0.1) rotate(30deg); }
  50% { transform: rotate(-10deg); }
  70% { transform: rotate(3deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes authRubberBand {
  from { transform: scale(1); }
  30% { transform: scaleX(1.25) scaleY(0.75); }
  40% { transform: scaleX(0.75) scaleY(1.25); }
  50% { transform: scaleX(1.15) scaleY(0.85); }
  65% { transform: scaleX(0.95) scaleY(1.05); }
  75% { transform: scaleX(1.05) scaleY(0.95); }
  to { transform: scale(1); }
}
@keyframes authWobbleIn {
  from { opacity: 0; transform: translateX(0) rotate(0); }
  15% { transform: translateX(-10px) rotate(-5deg); }
  30% { transform: translateX(8px) rotate(4deg); }
  45% { transform: translateX(-6px) rotate(-3deg); }
  60% { transform: translateX(4px) rotate(2deg); }
  75% { transform: translateX(-2px) rotate(-1deg); }
  to { opacity: 1; transform: translateX(0) rotate(0); }
}
@keyframes authTadaIn {
  from { transform: scale(1) rotate(0); }
  10%, 20% { transform: scale(0.9) rotate(-3deg); }
  30%, 50%, 70% { transform: scale(1.05) rotate(3deg); }
  40%, 60% { transform: scale(1.05) rotate(-3deg); }
  to { transform: scale(1) rotate(0); }
}
@keyframes authJelloIn {
  from { transform: skew(0); }
  30% { transform: skewX(12deg) skewY(12deg); }
  40% { transform: skewX(-6deg) skewY(-6deg); }
  50% { transform: skewX(4deg) skewY(4deg); }
  65% { transform: skewX(-2deg) skewY(-2deg); }
  75% { transform: skewX(1deg) skewY(1deg); }
  to { transform: skew(0); }
}
@keyframes authHeartBeatIn {
  from { opacity: 0; transform: scale(0); }
  14% { transform: scale(1.15); }
  28% { transform: scale(0.95); }
  42% { transform: scale(1.05); }
  70% { transform: scale(1); }
  to { opacity: 1; transform: scale(1); }
}

/* Apply 28 animations to auth elements (25 in markup + 3 pseudo) */
.auth-ani-1 { animation: authFadeIn 0.4s ease-out both; }
.auth-ani-2 { animation: authScaleIn 0.5s ease-out 0.05s both; position: relative; }
.auth-ani-3 { animation: authFadeInDown 0.45s ease-out 0.1s both; }
.auth-ani-4 { animation: authSlideInLeft 0.4s ease-out 0.15s both; }
.auth-ani-5 { animation: authSlideInRight 0.4s ease-out 0.18s both; }
.auth-ani-6 { animation: authSlideInRight 0.4s ease-out 0.21s both; }
.auth-ani-7 { animation: authFadeInUp 0.45s ease-out 0.2s both; }
.auth-ani-8 { animation: authBlurIn 0.35s ease-out 0.25s both; }
.auth-ani-9 { animation: authExpandIn 0.4s ease-out 0.28s both; }
.auth-ani-10 { animation: authFadeIn 0.3s ease-out 0.3s both; }
.auth-ani-11 { animation: authSlideUp 0.35s ease-out 0.32s both; }
.auth-ani-12 { animation: authFadeIn 0.3s ease-out 0.34s both; }
.auth-ani-13 { animation: authSlideUp 0.35s ease-out 0.36s both; }
.auth-ani-14 { animation: authExpandIn 0.4s ease-out 0.28s both; }
.auth-ani-15 { animation: authFadeIn 0.3s ease-out 0.3s both; }
.auth-ani-16 { animation: authSlideUp 0.35s ease-out 0.32s both; }
.auth-ani-17 { animation: authFadeIn 0.3s ease-out 0.34s both; }
.auth-ani-18 { animation: authSlideUp 0.35s ease-out 0.36s both; }
.auth-ani-19 { animation: authFadeIn 0.3s ease-out 0.38s both; }
.auth-ani-20 { animation: authSlideUp 0.35s ease-out 0.4s both; }
.auth-ani-21 { animation: authFadeIn 0.3s ease-out 0.42s both; }
.auth-ani-22 { animation: authSlideUp 0.35s ease-out 0.44s both; }
.auth-ani-23 { animation: authFadeIn 0.3s ease-out 0.46s both; }
.auth-ani-24 { animation: authSlideUp 0.35s ease-out 0.48s both; }
.auth-recaptcha-wrap {
  margin: 0.75rem 0;
  min-height: 78px;
}
.auth-verify-row {
  margin: 0.6rem 0 0.2rem;
}
.auth-verify-info {
  font-size: 0.82rem;
  color: var(--text-secondary, #8a8fa0);
  line-height: 1.4;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: rgba(124,58,237,.08);
  border-radius: 8px;
  border-left: 3px solid #7c3aed;
}
.auth-verify-info strong {
  color: var(--text-primary, #e0e0e8);
}
.auth-verify-info.auth-verify-skip {
  color: #34d399;
  border-left-color: #34d399;
  background: rgba(52, 211, 153, 0.08);
}
.auth-verify-info.auth-verify-skip strong {
  color: #6ee7b7;
}
.auth-verify-row label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--text-secondary, #8a8fa0);
}
.auth-verify-row input {
  width: 100%;
  font-size: 1.3rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border, #333);
  background: var(--bg-input, #1a1a2e);
  color: var(--text-primary, #e0e0e8);
  box-sizing: border-box;
}
.auth-resend-btn {
  display: block;
  margin-top: 0.4rem;
  background: none;
  border: none;
  color: #7c3aed;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.25rem 0;
  text-decoration: underline;
}
.auth-resend-btn:disabled {
  color: var(--text-secondary, #8a8fa0);
  cursor: default;
  text-decoration: none;
}
.auth-send-code-btn {
  width: 100%;
  padding: 0.55rem 0;
  border-radius: 8px;
  border: 1px solid #7c3aed;
  background: rgba(124,58,237,.1);
  color: #7c3aed;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  margin-top: 0.3rem;
  transition: background 0.15s;
}
.auth-send-code-btn:hover {
  background: rgba(124,58,237,.2);
}
/* Continue with Venory on the sign-in page and the Venory row in Connected apps. Colours come from the theme. */
.auth-venory-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.auth-venory-btn:hover {
  border-color: var(--accent);
  background: var(--bg-panel);
}
.auth-venory-logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex: none;
}
.auth-venory-btn[hidden] { display: none; }
/* Connected apps, in Settings → Account: one item for the app, then the button, like the other blocks. */
.connected-app-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
}
.connected-app-mark {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--bg-main);
  border: 1px solid var(--border);
}
.connected-app-mark img,
.connected-app-mark svg { width: 22px; height: 22px; display: block; }
.connected-app-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.connected-app-text strong { font-weight: 600; }
.connected-app-text span { font-size: 0.85rem; color: var(--text-dim); overflow-wrap: anywhere; }

/* Venory's mark: the coloured logo on the JimmyQrg themes, and the same mark in the text colour on study themes. */
.venory-mark-mono { display: none; color: var(--text); }
html[data-theme="study"] .venory-mark-color { display: none; }
html[data-theme="study"] .venory-mark-mono { display: block; }
.auth-ani-25 { animation: authBounceIn 0.6s ease-out 0.5s both; }
.auth-ani-26 { animation: authFadeIn 0.35s ease-out 0.55s both; }
.auth-box::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 18px;
  border: var(--border-width) solid transparent;
  pointer-events: none;
  z-index: -1;
  animation: authGlowIn 0.8s ease-out 0.6s both;
}
.auth-box::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 60%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--purple), transparent);
  border-radius: 0 0 4px 4px;
  pointer-events: none;
  z-index: -1;
  transform: translateX(-50%);
  animation: authLineIn 0.5s ease-out 0.4s both;
}
.auth-box > * {
  position: relative;
  z-index: 0;
}
@keyframes authLineIn {
  from { opacity: 0; transform: translateX(-50%) scaleX(0); }
  to { opacity: 1; transform: translateX(-50%) scaleX(1); }
}
.auth-box {
  position: relative;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.15);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* 6 hover effects */
.auth-box:hover {
  box-shadow: 0 0 56px rgba(139, 92, 246, 0.25);
  transform: translateY(-2px);
}
.auth-box input:hover {
  border-color: var(--purple-dim);
  background: var(--bg-hover);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.auth-box button[type="submit"]:hover {
  background: var(--purple-bright);
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s ease;
}
.auth-box label:hover {
  color: var(--purple-bright);
  transition: color 0.2s ease;
}
.auth-box h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--purple-bright);
}

.auth-box .auth-switch {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  text-align: center;
}

.auth-box .auth-switch-link {
  color: var(--purple-bright);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s, text-decoration 0.2s;
}

.auth-box .auth-switch-link:hover {
  color: var(--purple);
  text-decoration: underline;
}

.auth-box .auth-forgot-link {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
  text-align: right;
}

.auth-box .auth-subtitle {
  font-size: 0.92rem;
  color: var(--text-dim);
  margin: 0 0 1rem;
  line-height: 1.4;
}

.auth-box .auth-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #16a34a;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.auth-box .auth-error-block .error {
  text-align: center;
  margin-bottom: 1rem;
}

/* Auth transition: vanish / appear when switching login ↔ signup */
.auth-content-vanish {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.auth-content-appear {
  opacity: 1;
  transition: opacity 0.25s ease;
}

.auth-box label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.auth-box input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.auth-box input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

.auth-box button[type="submit"] {
  width: 100%;
  padding: 0.85rem;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s ease;
}
.auth-box button[type="submit"] .icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.auth-box .error {
  color: #f87171;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* App shell: left bar + panel column + main content */
.app-shell {
  display: flex;
  flex-direction: row;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.app-shell-inner {
  order: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  min-width: 0;
  overflow: hidden;
}

.panel-column-toggle {
  display: none;
}

.mobile-menu-glyph { display: none; }

.panel-column-overlay {
  display: none;
}

@keyframes barExpandIn {
  from { box-shadow: none; }
  to { box-shadow: 2px 0 12px rgba(0, 0, 0, 0.06); }
}
@keyframes labelFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes expandBtnPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes panelOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes panelSlideIn {
  from { transform: translateX(-12px); opacity: 0.95; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes panelSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-12px); opacity: 0.95; }
}

.left-bar {
  order: 0;
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.35s ease,
    border-color 0.3s ease,
    background 0.3s ease;
}
.left-bar-expanded {
  width: 180px;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.06);
  border-color: var(--border);
  animation: barExpandIn 0.35s ease-out;
}

.left-bar-avatar {
  padding: 0.75rem;
  flex-shrink: 0;
}

.left-bar-avatar-link {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}

.left-bar-avatar-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Icons centered in middle; expand stays at bottom */
.left-bar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0;
  transition: padding 0.28s ease, align-items 0.28s ease;
}

.left-bar-expanded .left-bar-nav {
  align-items: stretch;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.left-bar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 8px;
  width: 40px;
  justify-content: center;
  /* The expanded row stretches .left-bar-label to fill the width. Anchors
     default to start, but the Premium entry is a <button>, and buttons inherit
     the UA's text-align:center — which shifted its label ~22px right of every
     other item. Pin it so element type can't change the alignment. */
  text-align: start;
  transition: width 0.28s ease,
    justify-content 0.28s ease,
    background 0.2s ease,
    color 0.2s ease,
    transform 0.25s ease;
}

.left-bar-expanded .left-bar-item {
  width: auto;
  justify-content: flex-start;
}

.left-bar-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.left-bar-item.active {
  background: var(--bg-hover);
  color: var(--purple-bright);
}

.left-bar-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.left-bar-icon svg {
  width: 100%;
  height: 100%;
}

.left-bar-icon-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.left-bar-icon-wrap .left-bar-icon {
  width: 24px;
  height: 24px;
}

.left-bar-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  border-radius: 50%;
  min-width: 8px;
  height: 8px;
  pointer-events: none;
}

.left-bar-badge-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
}

/* Red dot with number (private chat total, inbox unread). Group chat uses .left-bar-badge-dot only (no number). */
.left-bar-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  line-height: 1;
  box-sizing: border-box;
}

.left-bar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s ease 0.08s, transform 0.3s ease 0.08s;
}

.left-bar-expanded .left-bar-label {
  opacity: 1;
  animation: labelFadeIn 0.35s ease-out both;
}
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(1) .left-bar-label { animation-delay: 0.05s; }
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(2) .left-bar-label { animation-delay: 0.08s; }
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(3) .left-bar-label { animation-delay: 0.11s; }
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(4) .left-bar-label { animation-delay: 0.14s; }
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(5) .left-bar-label { animation-delay: 0.17s; }
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(6) .left-bar-label { animation-delay: 0.2s; }
.left-bar-expanded .left-bar-nav .left-bar-item:nth-child(7) .left-bar-label { animation-delay: 0.23s; }
.left-bar-expanded .left-bar-expand .left-bar-label { animation-delay: 0.06s; }

.left-bar:not(.left-bar-expanded) .left-bar-label {
  display: none;
}

.left-bar-bottom {
  padding: 0.5rem;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  transition: justify-content 0.28s ease;
}

.left-bar-expanded .left-bar-bottom {
  justify-content: stretch;
}

.left-bar-expand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  width: 40px;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: width 0.28s ease, justify-content 0.28s ease, color 0.2s ease, transform 0.2s ease;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.left-bar-expanded .left-bar-expand {
  width: auto;
  justify-content: flex-start;
}

/* Keep horizontal navigation contents inset while the rail expands/collapses;
   explicit full-width rows avoid drifting toward the outer border. */
@media (min-aspect-ratio: 1/1) {
  .left-bar-nav { width: 100%; align-items: center; }
  .left-bar:not(.left-bar-expanded) .left-bar-item { flex: 0 0 40px; margin-inline: auto; }
  .left-bar-expanded .left-bar-nav { align-items: stretch; padding: 0.5rem 0.65rem; }
  .left-bar-expanded .left-bar-item {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding-inline: 0.65rem;
    gap: 0.65rem;
  }
  .left-bar-expanded .left-bar-label { flex: 1; min-width: 0; }
}

.left-bar-expand:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.left-bar-expand:active {
  animation: expandBtnPop 0.25s ease-out;
}

.panel-column {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.panel-list-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 1rem 1rem 0.5rem;
  margin: 0;
}

.panel-list-ul {
  list-style: none;
  padding: 0 0.5rem 1rem;
  margin: 0;
}

.panel-list-hash {
  font-family: 'JimmyComic2', var(--font-family);
}

.panel-list-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.panel-list-link:hover {
  background: var(--bg-hover);
}

.panel-list-link.active {
  background: var(--bg-hover);
  color: var(--purple-bright);
}

.panel-list-link-text {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-list-badge {
  flex-shrink: 0;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  padding: 0 5px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-list-badge-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  padding: 0;
}

/* User role tags */
.user-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.4;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.user-tag-helper {
  background: linear-gradient(135deg, rgba(99,102,241,.25), rgba(168,85,247,.25));
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,.3);
}
.user-tag-owner {
  background: linear-gradient(135deg, rgba(234,179,8,.2), rgba(245,158,11,.2));
  color: #fbbf24;
  border: 1px solid rgba(234,179,8,.3);
}
.user-tag-admin {
  background: linear-gradient(135deg, rgba(140,95,255,.22), rgba(168,85,247,.22));
  color: #c4b5fd;
  border: 1px solid rgba(140,95,255,.35);
}
.message-sender .user-tag { font-size: 0.55rem; padding: 0px 4px; margin-left: 4px; }

/* Support @Helper tip bar */
.support-helper-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(168,85,247,.10));
  border: 1px solid rgba(139,92,246,.2);
  border-radius: 8px;
  margin: 0 12px 4px;
  font-size: 0.82rem;
  color: rgba(255,255,255,.75);
}
.support-helper-tip-icon {
  flex-shrink: 0;
  display: flex;
  color: #a78bfa;
}
.support-helper-tip-text { flex: 1; }
.support-helper-tip-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  transition: color .15s, background .15s;
}
.support-helper-tip-close:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}

.panel-user-avatar-wrap {
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}
.panel-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.panel-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 0.5rem;
}

.panel-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.panel-search-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.panel-search-btn svg {
  width: 20px;
  height: 20px;
}

.panel-search-bar {
  padding: 0 1rem 0.5rem;
  display: none;
}

.panel-search-bar.open {
  display: block;
  animation: fadeIn 0.2s var(--ease) forwards;
}

.panel-search-bar input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--text);
  font-size: 0.9rem;
}

.panel-list-users .panel-list-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.panel-tabs {
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
}

.panel-tabs .panel-list-title {
  margin-bottom: 0.25rem;
}

.panel-tab {
  padding: 0.5rem 1rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
}

.panel-tab:hover {
  color: var(--text);
}

.panel-tab.active {
  color: var(--purple-bright);
}

.main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.main-content-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.main-header-link {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  transition: color var(--transition-fast);
}

.main-header-link:hover {
  color: var(--purple-bright);
}

.main-header-inbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.main-content-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main);
}

.main-content-body .chat-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.main-content-body .chat-area .messages-wrap,
.main-content-body .chat-main .messages-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.main-content-body .chat-area .composer,
.main-content-body .chat-main .composer {
  flex-shrink: 0;
}

.main-content-body .doc-panel,
.main-content-body .admin-main,
.main-content-body .settings-page,
.main-content-body .inbox-page,
.main-content-body .collections-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.main-content-body .empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  padding: 2rem;
}

/* Vertical / portrait layout: use only aspect ratio (height vs width), never pixel width.
   When height >= width (e.g. portrait phone, tall window), use vertical layout. */
@media (max-aspect-ratio: 1/1) {
  html { font-size: 14px; }

  .app-shell {
    flex-direction: column;
  }

  .app-shell-inner {
    order: 1;
    flex: 1;
    min-height: 0;
    display: flex;
  }

   .left-bar {
    order: 2;
    width: 100%;
    height: calc(48px + env(safe-area-inset-bottom, 0px));
    min-height: calc(48px + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 0.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 400;
    position: relative;
  }

  .left-bar .left-bar-expand {
    display: none;
  }

  .left-bar .left-bar-avatar {
    padding: 0.4rem;
  }

  .left-bar .left-bar-avatar-link {
    width: 30px;
    height: 30px;
  }

  .left-bar .left-bar-nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-evenly;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.5rem;
  }

  .left-bar .left-bar-item {
    width: 34px;
    padding: 0.4rem;
  }

  .left-bar .left-bar-label {
    display: none;
  }

  .left-bar .left-bar-bottom {
    flex-shrink: 0;
    padding: 0.4rem;
  }

  .left-bar-expanded {
    width: 100%;
  }

  /* Panel column: narrow strip by default, overlay when expanded */
  .panel-column {
    width: 30px;
    min-width: 30px;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    transition: width 0.2s ease, box-shadow 0.2s ease;
  }

  .panel-column-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 100%;
    flex-shrink: 0;
    background: var(--bg-panel);
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
  }

  .panel-column-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
  }

  .panel-column-toggle .left-bar-icon {
    width: 16px;
    height: 16px;
  }

  .panel-column-content {
    display: none;
    overflow-y: auto;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
  }

  .panel-column-expanded .panel-column-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
    animation: panelSlideIn 0.3s ease-out;
  }

  .panel-column-expanded {
    position: fixed;
    left: 0;
    top: 0;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    width: 240px;
    max-width: 85vw;
    z-index: 300;
    flex-direction: row;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    border-right: 1px solid var(--border);
  }

  .panel-column-expanded .panel-column-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    z-index: -1;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    animation: overlayIn 0.2s var(--ease) forwards;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
  }

  .message-sender {
    max-width: 140px;
    font-size: 0.68rem;
  }

  .message-inline {
    gap: 0.6rem;
  }

  .message-row {
    grid-template-columns: calc(40px + 0.6rem) 1fr;
  }

  .message-row:has(.message.own) {
    grid-template-columns: 1fr calc(40px + 0.6rem);
  }

  .left-bar .left-bar-icon {
    width: 20px;
    height: 20px;
  }

  .left-bar .left-bar-icon-wrap .left-bar-icon {
    width: 20px;
    height: 20px;
  }

  /* Keep the portrait navigation clear of gesture areas and easy to tap. */
  .left-bar {
    height: calc(52px + env(safe-area-inset-bottom, 0px));
    min-height: calc(52px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .left-bar .left-bar-nav {
    justify-content: space-around;
    gap: 0.15rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .left-bar .left-bar-nav::-webkit-scrollbar { display: none; }

  .left-bar .left-bar-item {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    justify-content: center;
    touch-action: manipulation;
  }

  .panel-column-expanded,
  .panel-column-expanded .panel-column-overlay {
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  }

  .chat-header {
    min-height: 50px;
    padding: 0.55rem 0.75rem;
    gap: 0.5rem;
  }

  .chat-header-menu-btn { width: 42px; height: 42px; flex-shrink: 0; }

  .messages-wrap { padding: 0.75rem 0.6rem; }

  .composer { padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)); }

  .composer-actions button,
  .composer-send {
    min-width: 40px;
    min-height: 40px;
    touch-action: manipulation;
  }
}

/* Main layout (legacy / inbox full page) */
.main-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.header h1,
.header-logo {
  font-size: 1.25rem;
  color: var(--purple-bright);
}

.header-logo {
  text-decoration: none;
  font-weight: inherit;
  transition: color var(--transition-fast);
}

.header-logo:hover {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-link {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color var(--transition-fast);
}

.header-link:hover {
  color: var(--purple-bright);
}

.header-link-inbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.header-inbox-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  background: #ef4444;
  border-radius: 999px;
  line-height: 1;
}

.header-link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0;
  font-family: inherit;
  transition: color var(--transition-fast);
}

.header-link-btn:hover {
  color: var(--purple-bright);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.25rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.header-user:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.header-user:active {
  transform: scale(0.98);
  transition: transform var(--transition-fast);
}

.header-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

/* Panels (group chat tabs) */
.panels-tabs {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}

.panels-tabs a,
.panels-tabs button {
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-block;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.panels-tabs a:hover,
.panels-tabs button:hover {
  color: var(--text);
}

.panels-tabs a.active,
.panels-tabs button.active {
  color: var(--purple-bright);
  border-bottom-color: var(--purple);
}

/* Content area */
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 220px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar h3 {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sidebar ul {
  list-style: none;
}

.sidebar li {
  border-radius: 6px;
  margin: 0 0.25rem;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.sidebar li a {
  padding: 0.5rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.sidebar li:hover {
  background: var(--bg-hover);
}

.sidebar li:hover a {
  color: var(--text);
}

.sidebar li.active a {
  background: var(--purple-dim);
  color: var(--text);
}

.sidebar li img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  min-width: 0;
  position: relative;
}

.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.chat-side-panel {
  display: none;
  width: 320px;
  max-width: min(38vw, 360px);
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
}

.chat-side-panel.open {
  display: flex;
  flex-direction: column;
  animation: panelSlideIn 0.25s var(--ease) forwards;
}

.chat-side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.chat-side-panel-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chat-side-panel-tab,
.chat-side-panel-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.chat-side-panel-tab {
  padding: 0.45rem 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.chat-side-panel-tab .icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.chat-side-panel-tab.active,
.chat-side-panel-tab:hover,
.chat-side-panel-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.chat-side-panel-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-side-panel-close .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.chat-side-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.9rem;
}

.chat-users-search {
  margin-bottom: 0.75rem;
}

.chat-users-search input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--text);
}

.chat-side-user-list {
  padding: 0;
}

.scroll-to-bottom {
  position: absolute;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s, transform 0.2s;
}
.scroll-to-bottom:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateX(-50%) scale(1.05);
}
.scroll-to-bottom .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.message-virtualize-notice {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 0.25rem;
}

.message-virtualize-show-more {
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  color: var(--text-muted);
}

.messages-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: block;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}
.chat-header-title {
  font-weight: 600;
  color: var(--text);
}
.chat-header-menu-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.chat-header-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.chat-header-menu-btn .icon {
  width: 1.25rem;
  height: 1.25rem;
}
.messages-loading-older,
.messages-load-more-hint,
.chat-search-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0.5rem 0 0.75rem;
}
.chat-search-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-search-top {
  display: block;
}
.chat-search-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-search-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.chat-search-row input {
  flex: 1;
}
.chat-search-row .chat-search-run {
  flex-shrink: 0;
  align-self: stretch;
}
.chat-search-fields input[type="search"],
.chat-search-fields input[type="date"],
.chat-search-fields select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
}
.chat-search-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.chat-search-custom-dates {
  grid-template-columns: 1fr 1fr;
}
.chat-search-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.chat-search-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-left: 0.2rem;
}
.chat-search-select {
  appearance: auto;
  cursor: pointer;
}
.chat-search-actions {
  display: flex;
  justify-content: flex-end;
}
@media (max-width: 900px) {
  .chat-search-filters {
    grid-template-columns: 1fr;
  }
  .chat-search-custom-dates {
    grid-template-columns: 1fr 1fr;
  }
}
.chat-search-results {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-search-result {
  border: var(--border-width) solid var(--border);
  background: var(--bg-panel);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.chat-search-result:hover {
  border-color: var(--purple);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.chat-search-result-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}
.chat-search-result-body {
  color: var(--text);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .chat-side-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, 360px);
    max-width: none;
    z-index: 25;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.22);
  }
}

.messages-wrap > *:last-child {
  margin-bottom: 0;
}

.message-timestamp,
.message-system {
  text-align: center;
  padding: 0.35rem 0;
  background: none;
  border: none;
  margin-bottom: 0.5rem;
}

.message-timestamp {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
}

.message-timestamp-line {
  flex: 1;
  height: 0;
  border-top: 1px solid var(--text-dim);
  opacity: 0.6;
}

.message-timestamp-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  flex-shrink: 0;
  padding: 0 0.25rem;
  opacity: 0.6;
}

.message.message-system {
  max-width: none;
  padding: 0.35rem 0;
  align-items: center;
}

.message-timestamp .message-system-text,
.message-system-text {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.message-recalled-line .message-recalled-name {
  font-style: italic;
}

.message-row {
  display: grid;
  /* Column 1 = avatar-wrap width + message gap so like-wrap aligns under body */
  grid-template-columns: calc(48px + 0.75rem) 1fr;
  grid-template-rows: auto auto;
  max-width: 100%;
  position: relative;
  gap: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.message-row .message {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-row .message-like-wrap {
  grid-column: 2;
  grid-row: 2;
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  height: 28px;
}

.message-row:hover .message-like-wrap {
  opacity: 1;
  pointer-events: auto;
}

.message-row:has(.message.own) {
  grid-template-columns: 1fr calc(48px + 0.75rem);
}

.message-row:has(.message.own) .message-like-wrap {
  grid-column: 2;
  justify-self: end;
}

.message-like-btn,
.message-reaction-picker-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}
.message-like-btn svg,
.message-reaction-picker-btn svg {
  width: 16px;
  height: 16px;
}
.message-like-btn:hover {
  color: var(--accent);
  background: var(--bg-hover);
}
.message-reaction-picker-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.message-reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.message-reaction-chip:hover {
  border-color: var(--purple);
}
.message-reaction-count {
  color: var(--text-dim);
}
.message-row-highlight .message-body {
  box-shadow: 0 0 0 2px var(--purple), 0 0 18px var(--glow);
}

.message-row-highlight .message-body-svg {
  box-shadow: none;
  filter: brightness(1.3) drop-shadow(0 0 8px var(--glow));
}

.message-like-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  min-width: 1.2em;
  line-height: 28px;
}

.message-edit-history {
  display: flex;
  align-items: center;
  gap: 0;
  height: 28px;
  color: var(--text-dim);
}

.message-edit-history-btn {
  width: 24px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}
.message-edit-history-btn svg {
  width: 14px;
  height: 14px;
}

.message-edit-history-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--bg-hover);
}

.message-edit-history-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.message-edit-history-label {
  font-size: 0.72rem;
  min-width: 2em;
  text-align: center;
  line-height: 28px;
}

.message-edit-area {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.message-edit-input {
  width: min(80vw, 600px);
  min-height: 14rem;
  padding: 1rem 1.1rem;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  line-height: 1.5;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.message-edit-input:focus {
  outline: none;
  border-color: var(--purple);
}

.message-edit-actions {
  display: flex;
  gap: 0.5rem;
}

.message-edit-save,
.message-edit-cancel {
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.message-edit-save .icon,
.message-edit-cancel .icon {
  width: 0.9em;
  height: 0.9em;
  flex-shrink: 0;
}

.message-edit-save {
  background: var(--purple);
  color: white;
}

.message-edit-save:hover {
  background: var(--purple-dim);
}

.message-edit-save[disabled] {
  background: var(--border);
  color: var(--text-dim);
  cursor: default;
  opacity: 0.7;
}

.message-edit-save[disabled]:hover {
  background: var(--border);
}

.message-edit-cancel {
  background: transparent;
  color: var(--text-dim);
}

.message-edit-cancel:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.messages-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  animation: fadeIn 0.4s var(--ease) forwards;
}

.messages-access-denied {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  margin: 1rem;
}

.deleted-user-banner {
  padding: 0.5rem 1rem;
  background: rgba(245, 158, 11, 0.15);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
}

.dm-timeout-banner {
  padding: 0.55rem 1rem;
  background: rgba(220, 80, 80, 0.12);
  border-bottom: 1px solid rgba(220, 80, 80, 0.35);
  color: #d04040;
  font-size: 0.88rem;
  text-align: center;
  font-weight: 500;
}

.pinned-message-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.pinned-message-banner:hover {
  background: var(--bg-hover);
}
.pinned-message-icon {
  display: inline-flex;
  align-items: center;
  color: var(--purple-bright);
  flex-shrink: 0;
}
.pinned-message-icon svg {
  width: 1rem;
  height: 1rem;
}
.pinned-message-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.pinned-message-sender {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--purple-bright);
}
.pinned-message-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pinned-message-unpin {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.pinned-message-unpin:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}
.pinned-message-unpin .icon {
  width: 0.85rem;
  height: 0.85rem;
}

@keyframes messageHighlight {
  0% { background: rgba(139, 92, 246, 0.25); }
  100% { background: transparent; }
}
.message-highlight {
  animation: messageHighlight 2s ease-out;
}

.message-skeleton {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}
.message-skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--bg-panel) 25%, var(--border) 50%, var(--bg-panel) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.message-skeleton-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.message-skeleton-line {
  height: 0.875rem;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-panel) 25%, var(--border) 50%, var(--bg-panel) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  width: 100%;
}
.message-skeleton-line-short {
  width: 40%;
}
.message-skeleton-line-medium {
  width: 70%;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: 85%;
  padding: 0.5rem 0;
}

.message.own {
  justify-self: end;
  align-self: flex-end;
  align-items: flex-end;
}

.message-header {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  padding: 0 0.4rem;
  margin-bottom: 0.15rem;
}

.message.own .message-header {
  justify-content: flex-end;
}

.message-inline {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: 100%;
  min-width: 0;
}

.message.own .message-inline {
  flex-direction: row-reverse;
}

.message-avatar-wrap {
  flex-shrink: 0;
  cursor: pointer;
  line-height: 0;
}

.message-sender {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-align: left;
  line-height: 1.2;
  /* Names are never italic: no style rule and no client-side override may
     land a slant on the sender label. */
  font-style: normal;
}

.message-sender-name {
  flex: 0 1 auto;
  max-width: 220px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.message.own .message-sender {
  text-align: right;
}

/* The Codex conversation view is guaranteed upright — names, message text and
   reply previews get the app's normal face even if a theme, a browser override
   or a substituted font would otherwise slant them. */
.messages-wrap[data-codex-session-view="1"] .message-sender,
.messages-wrap[data-codex-session-view="1"] .message-sender-name,
.messages-wrap[data-codex-session-view="1"] .message-content,
.messages-wrap[data-codex-session-view="1"] .message-reply-preview {
  font-style: normal;
  font-family: 'JimmyQrg', system-ui, sans-serif;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.message:hover .message-avatar {
  transform: scale(1.05);
}

.message-body {
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 12px;
  padding: 0.35rem 0.9rem 0.6rem;
  position: relative;
  min-width: 0;
  overflow-wrap: anywhere;
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal), transform var(--transition-fast);
}

.message .message-body {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.message.own .message-body {
  background: var(--purple-dim);
  border-color: var(--purple);
  box-shadow: 0 2px 12px var(--glow);
}

.message-body-svg {
  /* 9-slice scaling: corners render at fixed size, only the middle
     stretches — the bubble resizes with the text without distorting. */
  border: 14px 18px 16px 18px solid transparent;
  border-image: var(--bubble-svg) 28 fill / 14px 18px 16px 18px / 0 stretch;
  background: none;
  border-radius: 0;
  padding: 2px 4px 4px;
  overflow: hidden;
  min-width: 0;
}

.message .message-body-svg {
  box-shadow: none;
  background: none;
}

.message.own .message-body-svg {
  border-image: var(--bubble-svg) 28 fill / 14px 18px 16px 18px / 0 stretch;
  box-shadow: none;
}

.message-body-svg.message-body-tail {
  padding-bottom: 1.15rem;
  margin-bottom: 4px;
}

/* ── Star Gazer chatbox (CSS-based cosmic bubble) ── */
.message-body.chatbox-star-gazer {
  background: linear-gradient(135deg, #4C1D95 0%, #331464 100%) !important;
  border: 1.5px solid #8B5CF6 !important;
  border-radius: 12px !important;
  box-shadow:
    0 0 0 2.5px rgba(139, 92, 246, 0.20),
    0 2px 14px rgba(51, 20, 100, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  position: relative;
  overflow: hidden;
}

.message-body.chatbox-star-gazer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('/assets/chatboxes/star-gazer/other-stars.svg') center / cover no-repeat;
  pointer-events: none;
}

/* Chatbox picker in settings */
.chatbox-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.chatbox-picker-item {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

.chatbox-picker-item:hover {
  border-color: var(--purple);
}

.chatbox-picker-item.active {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

/* Earned styles: still shown to everyone, but not selectable until unlocked. */
.chatbox-picker-item.locked {
  position: relative;
  cursor: not-allowed;
  opacity: 0.65;
}

.chatbox-picker-item.locked:hover {
  border-color: var(--border);
}

.chatbox-picker-item.locked .chatbox-preview-bubble {
  filter: grayscale(1) contrast(0.85);
}

.chatbox-picker-lock {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.chatbox-picker-locked-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.chatbox-picker-preview {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.chatbox-preview-bubble {
  height: 28px;
  border: none;
  border-radius: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.chatbox-preview-own {
  align-self: flex-end;
  width: 70%;
}

.chatbox-preview-other {
  width: 85%;
}


.chatbox-picker-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: capitalize;
}

.message-time {
  display: none;
}

.message-reply-preview {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  text-align: left;
  appearance: none;
  background: transparent;
  border: none;
  border-left: 3px solid var(--purple);
  padding: 0 0.5rem;
  margin-bottom: 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}
.message-reply-preview:hover,
.message-reply-preview:focus-visible {
  color: var(--text);
  outline: none;
}
.message-reply-sender {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-reply-snippet {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-content {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
  /* Message text is never slanted unless markdown asks for it (<em>). An
     explicit normal stops a client-side font/user-style (extension, override
     stylesheet, substituted face) from inheriting italic into every bubble. */
  font-style: normal;
}

.message-content p {
  margin: 0.25em 0;
}

.message-content p:first-child {
  margin-top: 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content code {
  font-family: var(--font-code);
}
.message-content pre {
  margin: 0.35em 0;
  overflow-x: auto;
  font-family: var(--font-code);
}
.message-content pre code {
  font-family: var(--font-code);
}

/* Code block with header */
.chat-codeblock {
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  margin: 0.4em 0;
  overflow: hidden;
  position: relative;
}
.chat-codeblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: sticky;
  top: 0;
  z-index: 1;
}
.chat-codeblock-lang {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: lowercase;
  letter-spacing: 0.3px;
}
.chat-codeblock-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 3px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.chat-codeblock-copy:hover {
  color: var(--text);
  background: rgba(255,255,255,.08);
}
.chat-codeblock code {
  display: block;
  padding: 10px 12px;
  font-family: var(--font-code);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  background: transparent;
}

.message-content hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,.12);
  margin: 14px 0;
}
.message-content blockquote {
  margin: 0.5em 0;
  padding: 0.5em 0.75em 0.5em 1rem;
  border-left: 4px solid var(--purple-dim);
  background: var(--star);
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
  font-style: italic;
}
.message-content blockquote p {
  margin: 0.25em 0;
}
.message-content blockquote p:first-child { margin-top: 0; }
.message-content blockquote p:last-child { margin-bottom: 0; }

.message-content ul,
.message-content ol {
  margin: 0.25em 0;
  padding-left: 1.25em;
}

.message-content img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

.message-content video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

.message-content a {
  color: inherit;
  text-decoration: underline;
}
.message-content a:link,
.message-content a:visited,
.message-content a:hover,
.message-content a:active {
  color: inherit;
}

.message-content-plaintext {
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 0.5em;
}

.message-actions {
  display: none;
}

/* Composer */
.composer {
  padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

@media (max-width: 600px) {
  .composer {
    padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }
  .composer-row {
    gap: 0.3rem;
  }
  .composer-actions {
    padding: 0.3rem 0.3rem 0.3rem 0.15rem;
    gap: 0.1rem;
  }
  .composer-actions button {
    padding: 0.3rem;
  }
  .composer-send {
    width: 38px;
    height: 38px;
  }
}

.composer.composer-drag-over {
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 2px var(--purple);
}

.composer-no-files .composer-actions #attach-file {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.composer-pending-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.5rem;
  background: var(--bg-main);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.composer-pending-file button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color var(--transition-fast);
}

.composer-pending-file button:hover {
  color: var(--purple-bright);
}

.upload-progress {
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.5rem;
}

.upload-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.upload-progress-pct {
  font-variant-numeric: tabular-nums;
  color: var(--purple-bright);
  font-weight: 600;
}

.upload-progress-track {
  height: 6px;
  background: var(--bg-main);
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple), var(--purple-bright));
  border-radius: 999px;
  transition: width 0.15s ease;
}

.upload-progress.is-processing .upload-progress-bar {
  background-size: 200% 100%;
  animation: upload-progress-processing 1.2s linear infinite;
}

@keyframes upload-progress-processing {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .upload-progress.is-processing .upload-progress-bar { animation: none; }
}

.composer-reply {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  background: var(--bg-main);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.composer-reply .cancel-reply-link {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.composer-reply .cancel-reply-link:hover {
  color: var(--purple-bright);
}

.composer-reply-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-reply-jump {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-left: 3px solid var(--purple);
  padding-left: 0.5rem;
}
.composer-reply-jump:hover,
.composer-reply-jump:focus-visible {
  color: var(--text);
  outline: none;
}
.composer-reply-sender {
  font-weight: 600;
  color: var(--text);
  flex: 0 0 auto;
  max-width: 40%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-reply-snippet {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cancel-reply-x {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.15rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}
.cancel-reply-x .icon {
  width: 0.9rem;
  height: 0.9rem;
}
.cancel-reply-x:hover {
  color: var(--purple-bright);
  background: var(--bg-hover);
}

.composer-row {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  min-width: 0;
}

.composer-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  border: var(--border-width) solid var(--border);
  border-radius: 12px;
  background: var(--bg-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.composer-input-wrap:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 22px;
  max-height: 200px;
  padding: 0.5rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  resize: none;
  font-family: inherit;
  overflow-y: auto;
  box-sizing: border-box;
}

.composer textarea:focus {
  outline: none;
}

.composer-actions {
  display: flex;
  gap: 0.15rem;
  padding: 0.35rem 0.4rem 0.35rem 0.25rem;
  flex-shrink: 0;
  align-items: center;
  margin-left: auto;
}

/* Lucide / Figma-style icons */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  color: inherit;
}
.icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
}
/* Google Material filled icons carry fill="currentColor" on the svg root
   (stroke icons instead put fill="none" + stroke on the root). The stroke/fill
   above is inherited, so filled icons must override both or they render as
   thin outlines. */
.icon svg[fill="currentColor"],
.icon svg[fill="currentColor"] path,
.icon svg [fill="currentColor"] {
  fill: currentColor;
  stroke: none;
}
.icon.icon-sm {
  width: 1rem;
  height: 1rem;
}

.composer-actions button {
  padding: 0.35rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  transition: color var(--transition-fast), background var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composer-actions button .icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.composer-actions button:hover:not(:disabled) {
  color: var(--accent);
}
.composer-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer-command-btn {
  color: var(--text-dim);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.composer-command-btn.composer-command-btn-on {
  color: var(--purple-bright);
  background: var(--glow);
}

.composer-send {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.composer-send .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.composer-send:hover {
  background: var(--purple-bright);
  box-shadow: 0 2px 12px var(--glow);
}

.composer-send:active {
  transform: scale(0.98);
}

/* Venory helper: stop button while responding (all accounts) */
.composer-send.composer-stop {
  background: #ef4444;
}
.composer-send.composer-stop:hover {
  background: #dc2626;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.4);
}

/* Venory helper: owner control bar (model/effort + live status + tools) */
.helper-control-bar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  margin: 0 0.75rem 0.4rem;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
}
/* Owner policy: no text in the agent control bar is ever italic — this also
   blocks a slant inherited from anything outside the stylesheet. */
.helper-control-bar,
.helper-control-bar * {
  font-style: normal;
}
.hc-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hc-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.hc-select {
  background: var(--bg-main);
  color: var(--text);
  border: var(--border-width) solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.hc-session-select {
  max-width: 240px;
}
/* Custom session listbox: native <option> elements can't render SVG, so the
   active-run dot icon lives in a custom dropdown instead of a <select>. */
.hc-session-picker {
  position: relative;
  display: inline-flex;
}
.hc-session-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-main);
  color: var(--text);
  border: var(--border-width) solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
  max-width: 240px;
  font-family: inherit;
}
.hc-session-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}
.hc-session-caret {
  opacity: 0.7;
  flex-shrink: 0;
}
.hc-session-dot {
  display: inline-flex;
  width: 0.6rem;
  height: 0.6rem;
  flex-shrink: 0;
  color: var(--purple-bright, #a78bfa);
}
.hc-session-dot svg {
  width: 100%;
  height: 100%;
}
.hc-session-dot-current svg {
  animation: hc-pulse 1s ease-in-out infinite;
}
.hc-session-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  min-width: 220px;
  max-width: 320px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-panel, var(--bg-main));
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hc-session-menu[hidden] {
  display: none;
}
/* Viewport-aware positioning (toggled from JS at open time): flip above
   the trigger when there's no room below, and right-align when the menu
   would spill off the right edge of the screen. */
.hc-session-menu-flip {
  top: auto;
  bottom: calc(100% + 4px);
}
.hc-session-menu-right {
  left: auto;
  right: 0;
}
.hc-session-menu {
  max-width: min(320px, calc(100vw - 16px));
}
.hc-session-opt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 0.35rem 0.45rem;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.hc-session-opt:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.06));
}
.hc-session-opt.is-selected {
  color: var(--purple-bright, #a78bfa);
  font-weight: 600;
}
.hc-session-opt-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Owner policy: the agent control bar (Venory DM, every backend including
   Codex) must never render italic text, so the hint is upright. */
.hc-note {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.hc-note b {
  color: var(--purple-bright, #a78bfa);
  font-style: normal;
}
.hc-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.hc-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.hc-status-working { color: var(--purple-bright); }
.hc-status-working .hc-status-dot {
  background: var(--purple-bright);
  animation: hc-pulse 1s ease-in-out infinite;
}
.hc-status-done { color: #34d399; }
.hc-status-done .hc-status-dot { background: #34d399; }
.hc-status-idle { color: var(--text-muted); }
/* Content size badge + Compact button (control bar, top row) */
.hc-size-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-main);
  border: var(--border-width) solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}
.hc-compact-btn {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--purple-bright, #a78bfa);
  background: transparent;
  color: var(--purple-bright, #a78bfa);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.hc-compact-btn:hover:not(.is-busy) {
  background: rgba(139, 92, 246, 0.12);
}
.hc-compact-btn.is-busy {
  opacity: 0.6;
  cursor: default;
}
/* Venory mode switch (OpenClaw ↔ basic) — segmented control */
.hc-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem;
  background: var(--bg-main);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
}
.hc-mode-opt {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.hc-mode-opt:hover {
  color: var(--text);
}
.hc-mode-opt.is-active {
  background: var(--purple-bright);
  color: #fff;
}
.hc-bridge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: #34d399;
}
.hc-bridge-off {
  color: #f59e0b;
}
.hc-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.hc-tool {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.hc-tool-running {
  color: var(--purple-bright);
  border-color: var(--purple-dim);
  background: var(--glow);
}
.hc-tool-done { color: #34d399; }
.hc-tool-none {
  border-style: dashed;
}
@keyframes hc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Doc panels (Problem Solving, Rules) */
.doc-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-toolbar {
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.doc-toolbar .doc-edit-btn,
.doc-toolbar .doc-cancel {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.doc-toolbar .doc-edit-btn:hover,
.doc-toolbar .doc-cancel:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

.doc-toolbar .doc-save {
  padding: 0.5rem 1rem;
  background: var(--purple-dim);
  color: var(--text);
  border: var(--border-width) solid var(--purple);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.doc-toolbar .icon {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
}

.doc-toolbar .doc-save:hover {
  background: var(--purple);
  color: white;
  box-shadow: 0 2px 10px var(--glow);
}

.doc-toolbar .doc-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.doc-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: auto;
}

.doc-editor textarea {
  flex: 1;
  width: 100%;
  min-height: 100%;
  padding: 1rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.doc-editor textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

.doc-view {
  flex: 1;
  padding: 1rem;
  overflow: auto;
}

.doc-view pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-code);
}

.doc-markdown {
  line-height: 1.6;
}

.doc-markdown h1 {
  font-size: 1.5rem;
  margin: 1rem 0 0.5rem;
  color: var(--purple-bright);
}

.doc-markdown h1:first-child {
  margin-top: 0;
}

.doc-markdown h2 {
  font-size: 1.25rem;
  margin: 1rem 0 0.5rem;
  color: var(--purple-bright);
}

.doc-markdown h3 {
  font-size: 1.1rem;
  margin: 0.75rem 0 0.35rem;
  color: var(--text);
}

.doc-markdown p {
  margin: 0.5rem 0;
}

.doc-markdown ul,
.doc-markdown ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.doc-markdown li {
  margin: 0.25rem 0;
}

.doc-markdown code {
  background: var(--bg-main);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: var(--font-code);
}

.doc-markdown pre {
  background: var(--bg-main);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.75rem 0;
  overflow-x: auto;
  font-family: var(--font-code);
}

.doc-markdown pre code {
  background: none;
  padding: 0;
  font-family: var(--font-code);
}

.doc-markdown a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.doc-markdown a:hover {
  text-decoration: underline;
}

.doc-markdown hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 14px 0;
}

.doc-markdown .md-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
  font-size: 0.95em;
}

.doc-markdown .md-table th,
.doc-markdown .md-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.doc-markdown .md-table th {
  background: var(--bg-main);
  font-weight: 600;
}

.doc-markdown .md-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

.message-content .md-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0;
  font-size: 0.9em;
}

.message-content .md-table th,
.message-content .md-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}

.message-content .md-table th {
  background: var(--bg-hover);
  font-weight: 600;
}

/* Settings */
.settings-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem;
}

.settings-page h2 {
  margin-bottom: 1rem;
  color: var(--purple-bright);
}

.settings-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.settings-tabs a,
.settings-tabs button {
  padding: 0.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: inline-block;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.settings-tabs a:hover,
.settings-tabs button:hover {
  color: var(--text);
}

.settings-tabs a.active,
.settings-tabs button.active {
  color: var(--purple-bright);
  border-bottom-color: var(--purple);
}

.settings-form label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-dim);
}

.settings-form input,
.settings-form textarea {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-form textarea {
  min-height: 80px;
  resize: vertical;
}

.settings-form input:focus,
.settings-form textarea:focus,
.settings-text-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

.settings-text-input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-avatar-drop-zone {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.settings-avatar-drop-zone.settings-avatar-drag-over {
  border-color: var(--purple);
  background: var(--bg-hover);
  box-shadow: 0 0 0 2px var(--glow);
}

.settings-avatar-drop-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.settings-form .avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.settings-form button[type="submit"] {
  padding: 0.6rem 1.25rem;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.settings-form button[type="submit"] .icon {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
}

.settings-form button[type="submit"]:hover {
  background: var(--purple-bright);
  box-shadow: 0 2px 12px var(--glow);
}

.settings-form button[type="submit"]:active {
  transform: scale(0.98);
}

.settings-section-title {
  font-size: 1.1rem;
  margin: 2rem 0 1rem;
  color: var(--text);
}

.settings-form-message {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  min-height: 1.25em;
}

.settings-form-message[data-type="error"] {
  color: #f87171;
}

/* Checkboxes – unified style & lineup across all themes */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-main);
  cursor: pointer;
  position: relative;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
input[type="checkbox"]:hover {
  border-color: var(--purple-dim);
}
input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--glow);
}
input[type="checkbox"]:active {
  transform: scale(0.96);
}
input[type="checkbox"]:checked {
  background: var(--purple);
  border-color: var(--purple);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 42%;
  width: 0.35rem;
  height: 0.65rem;
  margin-left: -0.2rem;
  margin-top: -0.4rem;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  box-sizing: border-box;
}

.settings-checkbox-label,
.admin-delete-msgs-label,
.admin-timeout-locked,
.admin-perm-check {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--text);
  user-select: none;
}
.settings-checkbox-label {
  margin-bottom: 0.5rem;
}
.settings-checkbox-label span {
  line-height: 1.35;
}

/* Toggle switch override for settings checkboxes */
.settings-checkbox-label input[type="checkbox"] {
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg-main);
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.settings-checkbox-label input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--text-dim);
  border: none;
  margin: 0;
  transform: none;
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.settings-checkbox-label input[type="checkbox"]:checked {
  background: var(--purple);
  border-color: var(--purple);
}
.settings-checkbox-label input[type="checkbox"]:checked::after {
  transform: translateX(1.125rem);
  background: #fff;
  width: 0.875rem;
  height: 0.875rem;
  border: none;
  margin: 0;
  left: 2px;
  top: 2px;
}
.admin-delete-msgs-label {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.admin-timeout-locked {
  margin: 0.5rem 0;
}
.admin-perm-check {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: inline-flex;
}
.notif-triggers {
  margin: 0.75rem 0;
}
.notif-dnd {
  margin-top: 1rem;
}
.dnd-modal-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin: 1rem 0;
}
.dnd-modal-inputs label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.dnd-modal-inputs input {
  padding: 0.5rem 0.6rem;
  border: var(--border-width) solid var(--border);
  border-radius: 6px;
  background: var(--bg-main);
  color: var(--text);
  font-size: 1rem;
}

.settings-notifications {
  margin-top: 0.5rem;
}

.settings-form-message[data-type="success"] {
  color: var(--purple-bright);
}

.settings-account {
  max-width: 420px;
}

.settings-account-block {
  margin-bottom: 2rem;
}

.settings-general .settings-section-title {
  margin-top: 0;
}

.settings-form-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.settings-select {
  width: 100%;
  max-width: 240px;
  padding: 0.6rem 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 2px var(--glow);
}

.settings-account-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-primary:hover {
  background: var(--purple-bright);
  box-shadow: 0 2px 10px var(--glow);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--purple);
  background: var(--bg-hover);
}

.btn-danger {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #f87171;
  border: var(--border-width) solid #f87171;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  background: var(--bg-hover);
  color: var(--text);
  border: var(--border-width) solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.btn-primary .icon,
.btn-secondary .icon,
.btn-danger .icon,
.btn-small .icon {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
}

.btn-small:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
}

.btn-small.btn-danger {
  color: #f87171;
  border-color: #f87171;
}

.btn-small.btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.icon-btn:hover {
  border-color: var(--purple);
  color: var(--purple-bright);
  background: rgba(168, 85, 247, 0.08);
}
.icon-btn .icon {
  width: 1rem;
  height: 1rem;
}
.icon-btn-danger {
  color: var(--text-dim);
}
.icon-btn-danger:hover {
  border-color: #f87171;
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.modal-hint {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

/* Inbox */
.inbox-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem;
}

.inbox-page h2 {
  margin-bottom: 1rem;
  color: var(--purple-bright);
}

.inbox-empty,
.inbox-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 2.5rem 2rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  animation: fadeIn 0.4s var(--ease) forwards;
}
.inbox-empty-icon,
.inbox-loading-spinner {
  font-size: 2rem;
  color: var(--purple-dim);
}
.inbox-loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.inbox-item-main { flex: 1; min-width: 0; }
.inbox-item-delete {
  flex-shrink: 0;
  padding: 0.35rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.6;
  transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.inbox-item-delete:hover {
  opacity: 1;
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.inbox-item:hover {
  border-color: var(--purple);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  transform: translateX(2px);
}

.inbox-item.unread {
  border-left: 3px solid var(--purple);
}

.inbox-item .type {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.inbox-item .title {
  font-weight: 600;
  margin: 0.25rem 0;
}

.inbox-item .body {
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Context menu (dropdown list style) */
.context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0;
  min-width: 180px;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  list-style: none;
  animation: menuIn 0.2s var(--ease) forwards;
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.context-menu button:hover {
  background: var(--bg-hover);
}

.context-menu button.danger {
  color: #f87171;
}

.context-menu hr.context-menu-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
  opacity: 0.7;
}

/* Emoji picker popover */
.emoji-picker {
  position: fixed;
  z-index: 1100;
  display: grid;
  gap: 2px;
  padding: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  max-width: calc(100vw - 12px);
  width: max-content;
  max-height: min(70vh, 460px);
  overflow-y: auto;
}
.emoji-picker-cell {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.emoji-picker-cell:hover {
  background: var(--bg-hover);
  transform: scale(1.15);
}
.emoji-picker-cell:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}
@media (max-width: 480px) {
  .emoji-picker-cell {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.05rem;
  }
}

/* Modal */
/* Voice recording overlay */
.recording-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.recording-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: auto;
  animation: overlayIn 0.25s var(--ease) forwards;
}

.recording-overlay-content {
  position: relative;
  z-index: 1;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  pointer-events: auto;
  animation: modalIn 0.3s var(--ease) forwards;
}

.recording-overlay-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.recording-overlay-actions {
  display: flex;
  gap: 0.75rem;
}

.modal-overlay,
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  animation: overlayIn 0.25s var(--ease) forwards;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Notification permission modal – non-dismissible, no close button, must choose an option */
.notif-permission-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: default;
  animation: overlayIn 0.25s var(--ease) forwards;
}
.notif-permission-modal {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 2rem;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.3s var(--ease) forwards;
}
.notif-permission-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  color: var(--text);
}
.notif-permission-desc {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.notif-permission-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.notif-permission-actions .btn-primary {
  flex: 1;
  min-width: 140px;
}
.notif-permission-actions .btn-secondary {
  flex: 1;
  min-width: 100px;
}

.wordle-modal-overlay {
  cursor: default;
}
.wordle-modal {
  position: relative;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  width: 90vw;
  max-width: 520px;
  height: 85vh;
  max-height: 700px;
  animation: modalIn 0.3s var(--ease) forwards;
}
.wordle-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: var(--bg-panel);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.wordle-modal-close .icon { width: 1.15rem; height: 1.15rem; }
.wordle-modal-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.wordle-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

.modal {
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  animation: modalIn 0.3s var(--ease) forwards;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal h3,
.modal h4 {
  margin: 0.5rem 0 1rem;
  color: var(--purple-bright);
}

.modal h3:first-child,
.modal h4:first-child {
  margin-top: 0;
}

.modal input[type="text"],
.modal input[type="password"],
.modal textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.modal form label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.modal textarea {
  min-height: 60px;
  resize: vertical;
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Admin panel */
.admin-panel {
  padding: 1rem;
}

.admin-panel h3 {
  margin-bottom: 0.75rem;
  color: var(--purple-bright);
}

.admin-panel ul {
  list-style: none;
}

.admin-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-panel li button {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  margin-left: 0.5rem;
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.admin-panel li button:hover {
  color: var(--purple-bright);
}

.admin-panel .admin-send {
  padding: 0.5rem 1rem;
  background: var(--purple-dim);
  color: var(--text);
  border: var(--border-width) solid var(--purple);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.admin-panel .admin-send:hover {
  background: var(--purple);
  color: white;
  box-shadow: 0 2px 10px var(--glow);
}

.modal-actions .modal-close {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-dim);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.modal-actions .icon {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
}

.modal-actions .modal-close:hover {
  color: var(--text);
  border-color: var(--purple);
  background: var(--bg-hover);
}

/* Admin page */
.admin-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--bg-main);
}

.admin-nav {
  width: 200px;
  flex-shrink: 0;
  padding: 1rem 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
}

.admin-nav-item {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.admin-nav-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.admin-nav-item.active {
  color: var(--purple-bright);
  background: var(--bg-hover);
  border-left: 3px solid var(--purple);
  padding-left: calc(1.25rem - 3px);
}

.admin-main {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

.admin-section {
  max-width: 560px;
  margin-bottom: 2rem;
}

.admin-section-title {
  font-size: 1.2rem;
  color: var(--purple-bright);
  margin: 1.25rem 0 0.6rem;
}

.admin-section:first-child .admin-section-title,
.admin-section-title:first-child {
  margin-top: 0;
}

.admin-section-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.profile-modal { position: relative; padding: 0; min-width: 320px; display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; }
.profile-modal-close { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2; background: none; border: none; color: var(--text-dim); cursor: pointer; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; padding: 0; transition: background var(--transition-fast), color var(--transition-fast); }
.profile-modal-close .icon { width: 1.15rem; height: 1.15rem; }
.profile-modal-close:hover { color: var(--text); background: var(--bg-hover); }
.profile-modal-scroll { overflow-y: auto; padding: 1.5rem; flex: 1; min-height: 0; }
.profile-modal-header { text-align: center; margin-bottom: 1.25rem; }
.profile-modal-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 0.75rem; }
.profile-modal-name { margin: 0 0 0.25rem; font-size: 1.25rem; }
.profile-modal-username { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 0.5rem; }
.profile-modal-description { display: block; font-size: 0.9rem; margin: 0 0 0.5rem; white-space: pre-wrap; word-break: break-word; color: var(--text); line-height: 1.4; }
.profile-modal-website { font-size: 0.9rem; margin: 0; }
.profile-modal-website a { color: var(--purple-bright); transition: color var(--transition-fast); }
.profile-modal-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.admin-delete-modal h3 { margin: 0 0 0.75rem; font-size: 1.1rem; }

/* Profile view in chat area (read-only, like settings) */
.chat-area-profile-view {
  flex-direction: column;
}
.chat-area-profile-view .messages-wrap-profile-view {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}
.profile-view-loading,
.profile-view-error {
  padding: 2rem;
  text-align: center;
  color: var(--text-dim);
}
.profile-view-error { color: #f87171; }
.profile-view-header {
  margin-bottom: 1.5rem;
}
.profile-view-back {
  color: var(--purple-bright);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
}
.profile-view-back:hover {
  text-decoration: underline;
}
.profile-view-body {
  max-width: 420px;
}
.profile-view-avatar-wrap {
  margin-bottom: 1.5rem;
}
.profile-view-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.profile-view-field {
  margin-bottom: 1.25rem;
}
.profile-view-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}
.profile-view-value {
  font-size: 1rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.profile-view-value a {
  color: var(--purple-bright);
  transition: color var(--transition-fast);
}
.admin-delete-modal p { margin: 0 0 1rem; font-size: 0.9rem; color: var(--text-dim); line-height: 1.4; }
.admin-delete-modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.inbox-item-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inbox-item-report .body { white-space: pre-wrap; }
.inbox-item-report .type {
  color: var(--red, #e06c75);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.admin-recalled-ul { list-style: none; padding: 0; margin: 0; }
.admin-recalled-item { padding: 0.75rem; border: var(--border-width) solid var(--border); border-radius: 8px; margin-bottom: 0.5rem; background: var(--bg-panel); }
.admin-recalled-content { margin: 0.25rem 0 0; color: var(--text-dim); font-size: 0.9rem; }
.admin-recalled-time { font-size: 0.85rem; color: var(--text-dim); margin-left: 0.5rem; }
.admin-timeout-list { margin-top: 1rem; }
.admin-loading { display: flex; align-items: center; gap: 0.5rem; color: var(--text-dim); }
.admin-loading-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.collections-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}
.collections-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}
.collection-item {
  border-radius: 10px;
  border: var(--border-width) solid var(--border);
  background: var(--bg-panel);
  padding: 0.75rem 0.9rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
}
.collection-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.collection-sender {
  font-weight: 600;
  color: var(--text);
}
.collection-date {
  opacity: 0.85;
}
.collection-body {
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.collection-actions {
  display: flex;
  gap: 0.35rem;
  align-self: center;
}
.collection-open,
.collection-remove {
  align-self: center;
}
.collections-empty {
  margin-top: 1.5rem;
  color: var(--text-dim);
}
.admin-timeout-ul { list-style: none; padding: 0; margin: 0; }
.admin-timeout-item { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem; border: var(--border-width) solid var(--border); border-radius: 8px; margin-bottom: 0.5rem; background: var(--bg-panel); }
.admin-timeout-item .admin-timeout-release { margin-left: auto; }
.admin-timeout-meta { font-size: 0.85rem; color: var(--text-dim); }
.admin-timeout-scope {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 0.35rem;
}
.admin-timeout-scope-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.admin-section-subhint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
}
.admin-timeout-scope-badge {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.admin-timeout-scope-badge-group {
  background: rgba(140, 95, 255, 0.12);
  color: var(--purple, #8c5fff);
  border-color: rgba(140, 95, 255, 0.4);
}
.admin-timeout-scope-badge-dm {
  background: rgba(255, 160, 64, 0.12);
  color: #d98a25;
  border-color: rgba(255, 160, 64, 0.4);
}
.admin-form label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.admin-form input,
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.admin-form textarea {
  resize: vertical;
  min-height: 80px;
}

.admin-form button {
  margin-top: 0.25rem;
}

/* === Admin timeout form: searchable user picker + duration chips === */

.admin-timeout-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.admin-timeout-form .admin-form-label {
  display: block;
  margin: 0.6rem 0 0.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
}
.admin-timeout-form .admin-form-label:first-child {
  margin-top: 0;
}
.admin-timeout-form .admin-section-subhint {
  margin: 0.1rem 0 0.25rem;
}
.admin-timeout-form .admin-timeout-scope {
  margin: 0;
}
.admin-timeout-form .admin-timeout-locked {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.25rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
}
.admin-timeout-form .admin-timeout-locked input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.admin-timeout-form .admin-timeout-submit {
  align-self: flex-start;
  margin-top: 0.6rem;
}
.admin-timeout-form .admin-timeout-submit.is-loading {
  opacity: 0.7;
  cursor: progress;
}

/* User picker trigger button — shows the currently selected user (or a
 * placeholder) and opens the panel below on click. */
.admin-user-picker {
  position: relative;
  margin-bottom: 0.4rem;
}
.admin-form .admin-user-picker-trigger,
.admin-user-picker-trigger {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  margin: 0;
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.admin-user-picker-trigger:hover {
  border-color: var(--accent, #8c5fff);
}
.admin-user-picker-trigger[aria-expanded="true"] {
  border-color: var(--accent, #8c5fff);
  box-shadow: 0 0 0 3px rgba(140, 95, 255, 0.15);
}
.admin-user-picker-trigger-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-panel);
}
.admin-user-picker-trigger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-panel);
  color: var(--text-dim);
  flex-shrink: 0;
}
.admin-user-picker-trigger-icon svg {
  width: 18px;
  height: 18px;
}
.admin-user-picker-trigger-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.admin-user-picker-trigger-name {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-user-picker-trigger-handle {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-user-picker-trigger-empty {
  display: block;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.admin-user-picker-trigger-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
.admin-user-picker-trigger[aria-expanded="true"] .admin-user-picker-trigger-caret {
  transform: rotate(180deg);
}

/* The dropdown panel sits absolutely below the trigger and contains a
 * sticky search bar plus the scrollable list of candidate users. */
.admin-user-picker-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: hidden;
  background: var(--bg-panel, var(--bg-main));
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  animation: adminPickerPanelIn 0.14s ease;
}
.admin-user-picker-panel[hidden] { display: none; }
@keyframes adminPickerPanelIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.admin-user-picker-search {
  position: relative;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel, var(--bg-main));
  flex-shrink: 0;
}
.admin-user-picker-search-icon {
  position: absolute;
  top: 50%;
  left: 0.95rem;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  display: inline-flex;
}
.admin-form .admin-user-picker-search-input,
.admin-user-picker-search-input {
  width: 100%;
  padding: 0.45rem 0.6rem 0.45rem 2.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  margin: 0;
}
.admin-form .admin-user-picker-search-input:focus,
.admin-user-picker-search-input:focus {
  outline: none;
  border-color: var(--accent, #8c5fff);
  box-shadow: 0 0 0 3px rgba(140, 95, 255, 0.18);
}
.admin-user-picker-list {
  overflow-y: auto;
  padding: 0.25rem;
  flex: 1;
  scrollbar-width: thin;
}
.admin-user-picker-list::-webkit-scrollbar {
  width: 8px;
}
.admin-user-picker-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.admin-form .admin-user-picker-item,
.admin-user-picker-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
  margin: 0;
}
.admin-user-picker-item[hidden] { display: none; }
.admin-user-picker-item:hover {
  background: rgba(140, 95, 255, 0.08);
}
.admin-user-picker-item.active {
  background: rgba(140, 95, 255, 0.15);
}
.admin-user-picker-item-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-panel);
}
.admin-user-picker-item-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}
.admin-user-picker-item-name {
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-user-picker-item-handle {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-user-picker-item-check {
  display: inline-flex;
  color: var(--accent, #8c5fff);
  flex-shrink: 0;
}
.admin-user-picker-empty {
  margin: 0.6rem 0.6rem 0.4rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Duration chips: clickable preset buttons for common timeout lengths. */
.admin-duration-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
}
.admin-form .admin-duration-chip,
.admin-duration-chip {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel, var(--bg-main));
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.08s ease;
  margin: 0;
  width: auto;
}
.admin-duration-chip:hover {
  border-color: var(--accent, #8c5fff);
  color: var(--accent, #8c5fff);
}
.admin-duration-chip:active {
  transform: scale(0.97);
}
.admin-duration-chip.active {
  background: rgba(140, 95, 255, 0.15);
  border-color: var(--accent, #8c5fff);
  color: var(--accent, #8c5fff);
  font-weight: 600;
}
.admin-duration-chip-forever {
  border-style: dashed;
}
.admin-duration-chip-forever.active {
  border-style: solid;
}
.admin-duration-chip-custom {
  font-style: italic;
}
.admin-duration-custom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
}
.admin-duration-custom[hidden] { display: none; }
.admin-form .admin-duration-custom-num,
.admin-duration-custom-num {
  flex: 1 1 8rem;
  min-width: 6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  margin: 0;
}
.admin-form .admin-duration-custom-num:focus,
.admin-duration-custom-num:focus {
  outline: none;
  border-color: var(--accent, #8c5fff);
  box-shadow: 0 0 0 3px rgba(140, 95, 255, 0.18);
}
.admin-form .admin-duration-custom-unit,
.admin-duration-custom-unit {
  flex: 0 1 8rem;
  min-width: 7rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  margin: 0;
  width: auto;
}

/* Mobile-friendly tweaks for the picker so the panel doesn't overflow on
 * narrow screens. */
@media (max-width: 480px) {
  .admin-user-picker-panel { max-height: 60vh; }
  .admin-duration-chip { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
}

.admin-users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.admin-user-search {
  flex: 1 1 260px;
  min-width: 200px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
}

.admin-user-search:focus-visible {
  outline: 2px solid var(--purple, #8c5fff);
  outline-offset: 1px;
}

/* Replace the browser's native search-cancel control with our own SVG.
   WebKit/Blink draw their own glyph there (it reads as an off-brand ✕ and
   ignores the app theme), so we hide it and paint an SVG mark instead.
   Firefox has no native cancel button, so there is nothing to override. */
.admin-user-search::-webkit-search-cancel-button,
.admin-audit-search::-webkit-search-cancel-button,
.admin-user-picker-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-left: 0.25rem;
  cursor: pointer;
  opacity: 0.7;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
}
.admin-user-search::-webkit-search-cancel-button:hover,
.admin-audit-search::-webkit-search-cancel-button:hover,
.admin-user-picker-search-input::-webkit-search-cancel-button:hover {
  opacity: 1;
}

.admin-user-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0.25rem 0.6rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.admin-user-empty {
  font-size: 0.9rem;
}

.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-user-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-panel);
  border: var(--border-width) solid var(--border);
  border-radius: 12px;
  transition: border-color var(--transition-fast);
}

.admin-user-card[hidden] {
  display: none;
}

.admin-user-card:hover {
  border-color: var(--border);
}

.admin-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-user-name {
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.admin-user-handle {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-code, monospace);
}

.admin-user-email {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.15rem;
}

.admin-user-email .icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

.admin-user-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

.admin-user-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.admin-user-perms {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.admin-audit-section {
  margin-top: 1rem;
}

.admin-audit-list {
  margin-top: 0.5rem;
}

.admin-audit-ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.admin-audit-item {
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  background: var(--bg-panel);
}

.admin-audit-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-audit-time {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.admin-audit-meta {
  margin-top: 0.2rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.admin-audit-details {
  margin-top: 0.45rem;
  white-space: pre-wrap;
  word-break: break-word;
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--bg-main);
  color: var(--text);
  font-family: var(--font-code);
  font-size: 0.78rem;
}

/* ── Moderation queue ─────────────────────────────────────────── */
.mod-queue-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.mod-queue-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.2rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.mod-queue-status-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.mod-queue-status-btn:hover {
  color: var(--text);
  background: rgba(140, 95, 255, 0.08);
}
.mod-queue-status-btn.active {
  background: var(--purple, #8c5fff);
  color: #fff;
  box-shadow: 0 2px 6px rgba(140, 95, 255, 0.4);
}
.mod-queue-search {
  flex: 1 1 240px;
  min-width: 200px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
}
.mod-queue-search:focus-visible {
  outline: 2px solid var(--purple, #8c5fff);
  outline-offset: 1px;
}
.mod-queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.85rem;
}
.mod-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.9rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.mod-card:hover {
  border-color: var(--purple, #8c5fff);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.mod-card-open {
  border-color: rgba(220, 80, 80, 0.55);
  box-shadow: 0 0 0 1px rgba(220, 80, 80, 0.25);
}
.mod-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.mod-card-status {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-dim);
  white-space: nowrap;
}
.mod-card-status-open {
  color: #d04040;
  background: rgba(220, 80, 80, 0.12);
  border-color: rgba(220, 80, 80, 0.4);
}
.mod-card-status-in_review {
  color: #d98a25;
  background: rgba(255, 160, 64, 0.12);
  border-color: rgba(255, 160, 64, 0.4);
}
.mod-card-status-resolved {
  color: #2f9e6d;
  background: rgba(64, 200, 140, 0.12);
  border-color: rgba(64, 200, 140, 0.4);
}
.mod-card-status-rejected,
.mod-card-status-duplicate {
  color: var(--text-dim);
  background: var(--bg-main);
}
.mod-card-reason {
  font-weight: 600;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
}
.mod-card-time {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.mod-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.mod-card-meta strong {
  color: var(--text);
  font-weight: 600;
}
.mod-card-details {
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: var(--bg-main);
  border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0;
  font-size: 0.88rem;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.mod-card-message {
  display: block;
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: var(--bg-main);
  border-left: 3px solid var(--purple, #8c5fff);
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}
.mod-card-message-jump {
  appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  border: 1px solid transparent;
  border-left: 3px solid var(--purple, #8c5fff);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.mod-card-message-jump:hover,
.mod-card-message-jump:focus-visible {
  background: rgba(140, 95, 255, 0.08);
  border-color: rgba(140, 95, 255, 0.45);
  outline: none;
}
.mod-card-message-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre-wrap;
}
.mod-card-message-jump-hint {
  font-size: 0.78rem;
  color: var(--purple, #8c5fff);
  font-weight: 600;
  letter-spacing: 0.02em;
  align-self: flex-end;
}
.mod-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.1rem;
}
.mod-card-actions .btn-small {
  padding: 0.32rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 6px;
}
.mod-card-detail-link {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 0.55rem;
  margin-top: 0.1rem;
}
.mod-card-detail-link .btn-link {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--purple, #8c5fff);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.mod-card-detail-link .btn-link:hover,
.mod-card-detail-link .btn-link:focus-visible {
  text-decoration: underline;
  outline: none;
}
.mod-card-room {
  white-space: nowrap;
}

/* Moderation detail modal ---------------------------------------------- */
.mod-detail-modal {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 85vh;
  overflow-y: auto;
}
.mod-detail-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.mod-detail-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}
.mod-detail-section h4 {
  margin: 0.4rem 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
}

.mod-detail-section:first-child h4 {
  margin-top: 0;
}
.mod-detail-section p {
  margin: 0;
  font-size: 0.9rem;
}
.mod-detail-message {
  margin: 0.25rem 0;
  padding: 0.6rem 0.8rem;
  background: var(--bg-main);
  border-left: 3px solid var(--purple, #8c5fff);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.mod-detail-details {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mod-notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}
.mod-note {
  padding: 0.5rem 0.65rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}
.mod-note-meta {
  display: block;
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}
.mod-note-meta strong {
  color: var(--text);
}
.mod-detail-modal textarea#mod-note-input {
  width: 100%;
  resize: vertical;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.mod-detail-modal textarea#mod-note-input:focus-visible {
  outline: 2px solid var(--purple, #8c5fff);
  outline-offset: 1px;
}

/* ── Mention picker ─────────────────────────────────────────── */
.mention-autocomplete {
  position: fixed;
  display: none;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  z-index: 400;
  padding: 0.3rem;
  min-width: 240px;
  width: max-content;
  max-width: min(420px, calc(100vw - 16px));
  scrollbar-gutter: stable;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: background var(--transition-fast);
}

.mention-option:hover,
.mention-option:focus-visible {
  background: rgba(140, 95, 255, 0.12);
  outline: none;
}

.mention-option + .mention-option {
  margin-top: 0.1rem;
}

.mention-option-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.mention-option-token-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--purple, #8c5fff);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}

.mention-option-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.2;
}

.mention-option-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-autocomplete::-webkit-scrollbar {
  width: 6px;
}
.mention-autocomplete::-webkit-scrollbar-track {
  background: transparent;
}
.mention-autocomplete::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Edit history */
.edit-history {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.edit-history summary {
  cursor: pointer;
}

.edit-history .version {
  margin-top: 0.35rem;
  padding: 0.35rem;
  background: var(--bg-main);
  border-radius: 4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

/* Hidden file input */
.hidden-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* File message blocks */
.message-content-file {
  padding: 0;
}
.message-file {
  position: relative;
}
.message-file-video {
  width: 280px;
  height: 160px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: block;
  background: var(--bg-deep);
}
.message-file-video .message-file-video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.message-file-video .message-file-video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  color: #fff;
  pointer-events: none;
  transition: background 0.2s ease, transform 0.2s ease;
}
.message-file-video:hover .message-file-video-play {
  background: rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%) scale(1.08);
}
.message-file-video .message-file-download {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.message-file-video:hover .message-file-download {
  opacity: 1;
}
.message-file-video .message-file-download:hover {
  background: rgba(0, 0, 0, 0.8);
}
.message-file-image {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: block;
  position: relative;
  background: var(--bg-deep);
}
.message-file-image .message-file-image-img {
  width: 100%;
  height: auto;
  display: block;
}
.message-file-image .message-file-download {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.message-file-image:hover .message-file-download {
  opacity: 1;
}
.message-file-image .message-file-download:hover {
  background: rgba(0, 0, 0, 0.8);
}
.message-file-audio {
  position: relative;
  padding: 0.5rem 0.75rem;
  padding-right: 2.5rem;
  background: var(--bg-panel);
  border-radius: 8px;
  border: 1px solid var(--border);
  max-width: 320px;
}
.message-file-audio-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.message-file-audio-el {
  display: none;
}
.message-file-audio-progress-wrap {
  flex: 1;
  min-width: 120px;
}
.message-file-audio-progress {
  width: 100%;
  height: 6px;
  cursor: pointer;
  accent-color: var(--purple);
}
.message-file-audio-time {
  width: 100%;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.message-file-audio-download {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 4px;
  color: var(--purple-bright);
  transition: color var(--transition-fast);
}
.message-file-audio-download:hover {
  color: var(--accent);
}
.message-file-other {
  padding: 0.5rem 0.75rem;
  background: var(--bg-panel);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.message-file-other-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.message-file-other-icon {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-dim);
  transition: color var(--transition-fast);
}
.message-file-other-icon:hover {
  color: var(--purple-bright);
}
.message-file-other-download {
  padding: 4px;
  color: var(--purple-bright);
  transition: color var(--transition-fast);
}
.message-file-other-download:hover {
  color: var(--accent);
}

/* Media popup */
.media-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.media-popup {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.media-popup--video .media-popup-image-overlay {
  display: none;
}
.media-popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  z-index: 10;
}
.media-popup-close .icon { width: 1.2rem; height: 1.2rem; }
.media-popup-close {
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.media-popup-close:hover {
  background: rgba(0, 0, 0, 0.75);
  opacity: 1;
}
.media-popup-fullscreen {
  position: absolute;
  top: 0.5rem;
  right: 3.4rem;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  z-index: 10;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.media-popup-fullscreen .icon { width: 1.2rem; height: 1.2rem; }
.media-popup-fullscreen:hover {
  background: rgba(0, 0, 0, 0.75);
  opacity: 1;
}
.media-popup:fullscreen,
.media-popup:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: #000;
}
.media-popup:fullscreen .media-popup-content,
.media-popup:-webkit-full-screen .media-popup-content {
  max-width: 96vw;
  max-height: 84vh;
}
.media-popup:fullscreen .media-popup-video,
.media-popup:-webkit-full-screen .media-popup-video {
  max-width: 96vw;
  max-height: 84vh;
}
.media-popup:fullscreen .media-popup-image,
.media-popup:-webkit-full-screen .media-popup-image {
  max-width: 96vw;
  max-height: 84vh;
}
.media-popup-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.media-popup-video {
  max-width: 90vw;
  max-height: 70vh;
  background: #000;
}
.media-popup-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  will-change: transform;
}
.media-popup-status {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.35;
  max-width: min(88vw, 420px);
  text-align: center;
  pointer-events: none;
}
.media-popup-status--error {
  background: rgba(132, 17, 38, 0.86);
}
.media-popup-image-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
  cursor: pointer;
}
.media-popup-controls {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.media-popup--video .media-popup-controls {
  background: rgba(0, 0, 0, 0.7);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}
.media-popup-controls-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.media-popup-kb-hint {
  font-size: 0.72rem;
  opacity: 0.72;
  color: #fff;
  margin-left: 0.25rem;
}
.media-popup-controls .media-popup-prev,
.media-popup-controls .media-popup-next {
  padding: 0.35rem 0.6rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.media-popup--video .media-popup-controls .media-popup-prev,
.media-popup--video .media-popup-controls .media-popup-next {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.media-popup-controls .media-popup-prev:disabled,
.media-popup-controls .media-popup-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.media-popup-step,
.media-popup-step-fwd {
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.media-popup--video .media-popup-step,
.media-popup--video .media-popup-step-fwd {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.media-popup-play {
  padding: 0.35rem 0.75rem;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.media-popup-download {
  padding: 0.35rem;
  color: #fff;
}
.media-popup--video .media-popup-download {
  color: rgba(255, 255, 255, 0.9);
}
.media-popup-download:hover {
  color: var(--accent);
}
.media-popup-image-ui {
  transition: opacity 0.2s ease;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 8px;
}
.media-popup-image-ui .media-popup-prev,
.media-popup-image-ui .media-popup-next {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transition: background var(--transition-fast);
}
.media-popup-image-ui .media-popup-prev:hover,
.media-popup-image-ui .media-popup-next:hover {
  background: rgba(255, 255, 255, 0.25);
}
.media-popup-image-ui .media-popup-download {
  color: #fff;
}
@media (max-width: 860px) {
  .media-popup-kb-hint {
    display: none;
  }
}

/* Link preview popover */
.link-preview-popover {
  position: fixed;
  z-index: 1100;
  max-width: 320px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  pointer-events: auto;
  animation: fadeIn 0.2s var(--ease) forwards;
}
.link-preview-img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  display: block;
}
.link-preview-body {
  padding: 0.75rem 1rem;
}
.link-preview-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: var(--text);
  line-height: 1.3;
}
.link-preview-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(90vw, 360px);
  pointer-events: none;
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  cursor: pointer;
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast--dismissed {
  opacity: 0;
  transform: translateY(4px);
}
.toast--error {
  background: var(--bg-panel);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--text);
}
.toast--success {
  background: var(--bg-panel);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: var(--text);
}
.toast--info {
  background: var(--bg-panel);
  border: 1px solid var(--purple-dim);
  color: var(--text);
}
.toast-action {
  display: block;
  margin-top: 0.55rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--purple-dim);
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.16);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.toast-action:hover { background: rgba(139, 92, 246, 0.28); }
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* File content modal */
.file-content-modal-overlay .file-content-modal {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  padding: 2rem 1rem 1rem;
}
.file-content-modal-body {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  overflow: auto;
  font-size: 0.9rem;
  padding: 1rem;
}
.file-content-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  border-radius: 8px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.file-content-modal-close .icon { width: 1.15rem; height: 1.15rem; }
.file-content-modal-close:hover { background: var(--bg-hover); color: var(--text); }
.file-content-modal-download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  color: var(--purple-bright);
}
.file-content-modal-download .icon {
  width: 1rem;
  height: 1rem;
}

/* Language blocks in messages (markdown, html, latex, raw) – no extra box, inherit theme */
.language-block-html {
  margin: 0.5em 0;
  overflow-x: auto;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.language-block-html p,
.language-block-html div,
.language-block-html span {
  margin: 0.25em 0;
  color: inherit;
}


.language-block-latex {
  margin: 0.5em 0;
  overflow-x: auto;
  text-align: center;
  color: inherit;
  max-width: 100%;
}

.language-block-latex .katex,
.language-block-latex .katex * {
  color: inherit !important;
}

/* Allow long display-mode equations to wrap to the next line so the
   message bubble doesn't show a horizontal scrollbar. KaTeX's recommended
   wrap technique – see https://katex.org/docs/issues.html */
.language-block-latex .katex-display {
  margin: 0.25em 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.language-block-latex .katex-display > .katex {
  white-space: normal;
  max-width: 100%;
}

.language-block-latex .katex-display > .katex > .katex-html {
  white-space: normal;
  max-width: 100%;
}

.language-block-latex .katex-display > .katex > .katex-html > .base {
  margin: 0.25em 0;
}

.language-block-latex .katex {
  max-width: 100%;
}

.language-block-latex pre,
.language-block-error {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  font-size: inherit;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
  text-align: left;
}

.language-block-raw {
  margin: 0.5em 0;
  padding: 0.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9rem;
  font-family: var(--font-code);
}

.language-block-raw code {
  background: none;
  padding: 0;
  color: var(--text);
  font-family: var(--font-code);
}

/* Inbox action buttons (inherit from btn-small) */
.inbox-accept-fr,
.inbox-reject-fr {
  font-size: 0.85rem;
}

/* Modal overlay base (ensure consistent with other modals) */
.modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay .modal {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 1.5rem;
  color: var(--text);
}

/* Report context modal (admin view of nearest messages around a reported DM) */
.report-context-modal {
  max-width: 640px;
  width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}
.report-context-modal h3 {
  margin: 0;
}
.report-context-participants {
  font-size: 0.9rem;
  color: var(--text-dim);
}
.report-context-messages {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 55vh;
}
.report-context-message {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border);
}
.report-context-message-focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(140, 95, 255, 0.2);
  background: rgba(140, 95, 255, 0.08);
}
.report-context-meta {
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text-dim);
}
.report-context-meta strong {
  color: var(--text);
}
.report-context-time {
  white-space: nowrap;
}
.report-context-body {
  font-size: 0.92rem;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.report-context-muted {
  color: var(--text-dim);
  font-style: italic;
}
.report-context-attach {
  font-weight: 600;
  color: var(--purple);
}
.report-context-fileref {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.report-context-empty {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  padding: 0.3rem 0.5rem;
}
.mod-detail-actions {
  margin-top: 0.5rem;
}

/* Composer reply and pending file (ensure layout) */
.composer-reply {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.cancel-reply-link {
  background: none;
  border: none;
  color: var(--purple-bright);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
}

.cancel-reply-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.composer-pending-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.composer-pending-file span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panel list header (Chat / Inbox section title row) */
.panel-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.5rem 0.35rem;
}

.panel-list-header .panel-list-title {
  margin: 0;
}

.panel-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
}

.panel-search-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Loading state */
#app.app-loading {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Voice Chat Panel Entry ── */
.panel-voice-entry {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}
.panel-voice-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 8px;
  color: #22c55e;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.panel-voice-btn:hover {
  background: rgba(34, 197, 94, 0.2);
}
.panel-voice-btn-active {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
}
.panel-voice-icon {
  display: inline-flex;
}
.panel-voice-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}
.panel-voice-count {
  margin-left: auto;
  background: rgba(34, 197, 94, 0.25);
  border-radius: 10px;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Voice Chat Area ── */
.vc-area {
  display: flex;
  height: 100%;
  width: 100%;
  background: #111;
  overflow: hidden;
}
.vc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.vc-main-with-panel {
  flex: 1;
}
.vc-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--vc-cols, 1), 1fr);
  gap: 8px;
  padding: 12px;
  align-content: center;
  overflow-y: auto;
}
.vc-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.5);
  font-size: 1rem;
  grid-column: 1 / -1;
}
.vc-tile {
  position: relative;
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vc-tile-video-wrap {
  position: absolute;
  inset: 0;
}
.vc-tile-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vc-tile-video-wrap audio {
  display: none;
}
.vc-tile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.vc-tile-avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.1);
}
.vc-tile-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  z-index: 2;
}
.vc-tile-name {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vc-tile-mic {
  margin-left: auto;
  display: inline-flex;
  color: #fff;
}
.vc-tile-mic svg {
  width: 14px;
  height: 14px;
}
.vc-tile-mic.vc-muted {
  color: #f87171;
}

/* ── Voice Chat Toolbar ── */
.vc-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #181825;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.vc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: #e0e0e0;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 68px;
}
.vc-btn:hover {
  background: rgba(255,255,255,0.14);
}
.vc-btn-icon {
  display: inline-flex;
}
.vc-btn-icon svg {
  width: 22px;
  height: 22px;
}
.vc-btn-label {
  font-size: 0.7rem;
  font-weight: 500;
}
.vc-btn-off {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}
.vc-btn-off:hover {
  background: rgba(239, 68, 68, 0.3);
}
.vc-btn-active {
  background: rgba(139, 92, 246, 0.25);
  color: var(--purple-bright);
}
.vc-btn-active:hover {
  background: rgba(139, 92, 246, 0.35);
}
.vc-btn-leave {
  background: #dc2626;
  color: #fff;
}
.vc-btn-leave:hover {
  background: #ef4444;
}
.vc-btn-group {
  position: relative;
}

/* ── Screen share dropdown ── */
.vc-screen-menu {
  position: fixed;
  z-index: 9999;
  background: #23233a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.vc-screen-menu button {
  padding: 0.55rem 0.75rem;
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 0.85rem;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
}
.vc-screen-menu button:hover {
  background: rgba(255,255,255,0.08);
}
.vc-screen-audio-opt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  cursor: pointer;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 0.15rem;
}

/* ── Voice Chat Side Panels ── */
.vc-side-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #181825;
  border-left: 1px solid rgba(255,255,255,0.08);
}
.vc-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.vc-side-title {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}
.vc-side-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: inline-flex;
}
.vc-side-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

/* Voice chat messages */
.vc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.vc-chat-msg {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}
.vc-chat-msg:hover {
  background: rgba(255,255,255,0.04);
}
.vc-chat-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--purple-bright);
}
.vc-chat-text {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  word-break: break-word;
}
.vc-chat-empty {
  color: rgba(255,255,255,0.3);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
}
.vc-chat-composer {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.vc-chat-composer input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.vc-chat-composer input:focus {
  border-color: var(--purple-bright);
}
.vc-chat-composer input::placeholder {
  color: rgba(255,255,255,0.3);
}
.vc-chat-composer button {
  background: var(--purple-bright);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.vc-chat-composer button:hover {
  opacity: 0.85;
}
.vc-chat-composer button svg {
  width: 16px;
  height: 16px;
}

/* Voice members list */
.vc-members-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.vc-member {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
}
.vc-member:hover {
  background: rgba(255,255,255,0.04);
}
.vc-member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.vc-member-name {
  flex: 1;
  color: #e0e0e0;
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vc-member-mic {
  display: inline-flex;
  color: rgba(255,255,255,0.5);
}
.vc-member-mic svg {
  width: 16px;
  height: 16px;
}
.vc-member-mic.vc-muted {
  color: #f87171;
}

/* Responsive */
@media (max-width: 768px) {
  .vc-side-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    width: 280px;
    box-shadow: -4px 0 16px rgba(0,0,0,0.3);
  }
  .vc-toolbar {
    gap: 0.25rem;
    padding: 0.5rem;
  }
  .vc-btn {
    min-width: 52px;
    padding: 0.5rem 0.5rem;
  }
  .vc-btn-label {
    display: none;
  }
  .vc-tile-avatar img {
    width: 56px;
    height: 56px;
  }
}

/* ───────────────────────────────────────────────────────────
 *  AI moderation block modal
 * ───────────────────────────────────────────────────────────
 *  Shown when the AI content filter rejects an outgoing message.
 *  Goal: make the user feel guided, not punished — the modal is
 *  warm, mildly amber-toned, and sits at a normal modal size. It
 *  intentionally avoids red/destructive styling.
 */
.ai-mod-overlay {
  /* Sits above the rest of the chat UI (matching the other .modal-overlay
   * stack) so the user can't keep typing while the moderation result is
   * being acknowledged. */
  z-index: 10001;
}

.ai-mod-modal {
  max-width: 460px;
  padding: 1.4rem 1.5rem 1.25rem;
}

.ai-mod-modal .ai-mod-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.ai-mod-modal .ai-mod-header h3 {
  margin: 0;
  /* Override the default purple modal title for a calmer amber/gold
   * that signals "needs your attention" without screaming "danger". */
  color: #f5b945;
  font-size: 1.1rem;
}

.ai-mod-modal .ai-mod-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(245, 185, 69, 0.12);
  color: #f5b945;
  flex-shrink: 0;
}

.ai-mod-modal .ai-mod-icon svg {
  width: 22px;
  height: 22px;
}

.ai-mod-modal .ai-mod-reason {
  margin: 0 0 0.65rem;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
  /* Soft tinted card behind the AI's reason so it visually stands apart
   * from the helper text below. */
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(245, 185, 69, 0.08);
  border: 1px solid rgba(245, 185, 69, 0.22);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.ai-mod-modal .ai-mod-help {
  margin: 0 0 0.25rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.45;
}

.ai-mod-modal .modal-actions {
  margin-top: 1.1rem;
}

@media (max-width: 480px) {
  .ai-mod-modal {
    max-width: calc(100vw - 2rem);
    padding: 1.2rem 1.1rem 1rem;
  }
  .ai-mod-modal .ai-mod-header h3 {
    font-size: 1rem;
  }
  .ai-mod-modal .ai-mod-reason {
    font-size: 0.9rem;
  }
}

/* ── Disable all transitions & animations when user opts out ── */
.no-animations *,
.no-animations *::before,
.no-animations *::after {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
  animation-delay: 0s !important;
}

/* ── DM Voice Chat Overlay (1:1 private calls) ── */
.dm-voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #111;
}
.dm-voice-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}
.dm-voice-modal {
  background: var(--surface, #1a1a1a);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  padding: 2rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.dm-voice-modal-avatar img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 1rem;
  display: block;
}
.dm-voice-modal-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text, #fff);
}
.dm-voice-modal-sub {
  font-size: 0.9rem;
  color: var(--text-muted, #aaa);
  margin-bottom: 1.5rem;
}
.dm-voice-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}
.dm-voice-modal-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  color: #fff;
}
.dm-voice-modal-decline {
  background: #c0392b;
}
.dm-voice-modal-accept {
  background: #27ae60;
}

/* Private-user notice: shown when the server blocks a profile or DM
   view because the target user is is_private=1. Centered, neutral
   text — no avatar, no display name, no links. */
.private-user-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-dim, #6b7280);
  max-width: 360px;
  margin: 0 auto;
}
.private-user-notice-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text, #111827);
  margin-bottom: 0.4rem;
}
.private-user-notice-sub {
  font-size: 0.9rem;
  line-height: 1.4;
}
.dm-voice-modal-btn:hover { filter: brightness(1.1); }


/* ====================================================================
 * Slash-commands + whisper styling
 *   .fall-overlay / .fall-letter / .fall-word    -- /fall animation
 *   .grumm-flipped / .grumm-flip-back           -- /grumm page flip
 *   .emoji-picker-header / .emoji-picker-close  -- emoji X button
 *   .message-whisper / .message-body-whisper / .message-whisper-badge
 *   .whisper-modal / .whisper-recipient-* / .whisper-audience-*
 *
 * Color/background/foreground all reference the active theme tokens
 * (--bg-panel / --bg-hover / --text / --text-dim / --border / --purple
 * / --purple-dim / --purple-bright) so these elements work in both
 * dark and light themes without separate overrides.
 * ==================================================================*/

.fall-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
  overflow: hidden;
}
.fall-letter,
.fall-word {
  position: absolute;
  font-family: var(--font-family, system-ui, sans-serif);
  font-weight: 700;
  color: var(--purple, #8b5cf6);
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  white-space: nowrap;
  will-change: transform;
  animation: fall var(--dur, 8s) linear var(--delay, 0s) forwards;
}
@keyframes fall {
  from { transform: translate(0, -32px) rotate(0deg); }
  to   { transform: translate(var(--drift, 0px), 110vh) rotate(360deg); }
}

.grumm-flipped {
  transform: rotate(180deg);
  transform-origin: center center;
  transition: transform 0.4s ease-out;
}
.grumm-flip-back {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 0;
  background: var(--bg-deep, rgba(0,0,0,0.75));
  color: var(--text, #fff);
  font: 600 0.85rem var(--font-family, system-ui, sans-serif);
  cursor: pointer;
}
.grumm-flip-back:hover { background: var(--bg-hover, rgba(0,0,0,0.9)); }

/* ---- Emoji picker header + close-X ----
 * The existing .emoji-picker rule already positions the popover and lays
 * out the emoji grid. We add a single header row spanning the grid for
 * the title + X button, plus explicit focus styles so keyboard users
 * can dismiss. */
.emoji-picker-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 6px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.emoji-picker-title {
  font: 600 0.75rem var(--font-family, system-ui, sans-serif);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.emoji-picker-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.emoji-picker-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.emoji-picker-close:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

/* ---- Whisper message styling ----
 * .message-body-whisper tints the bubble; .message-whisper (outer row)
 * is a hook for any layout tweaks. The badge surfaces the recipient so
 * viewers don't confuse the bubble with a deleted or recalled message. */
.message-row-whisper { /* row-level hook */ }
.message-body-whisper {
  background: color-mix(in srgb, var(--purple) 12%, transparent);
  border-left: 3px solid var(--purple);
}
.message-whisper-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--purple);
  color: #fff;
  font: 600 0.7rem var(--font-family, system-ui, sans-serif);
  letter-spacing: 0.02em;
  vertical-align: middle;
  cursor: help;
}

/* ---- Whisper modals (recipient picker + audience choice) ----
 * The shell is the same .modal used by every other dialog in the app
 * (see the .modal rule around line 4389): theme-aware bg, border,
 * border-radius, padding, animation. Anything that diverges from the
 * standard modal is scoped under .whisper-modal. */
.whisper-modal.modal {
  max-width: 520px;
  width: 90vw;
  background: var(--bg-panel);
  color: var(--text);
  border: var(--border-width) solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
}
.whisper-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.whisper-modal .modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}
.whisper-modal-body {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}
.whisper-modal-body p { margin: 0 0 0.75rem; }
.whisper-modal-body p:last-child { margin-bottom: 0; }
.whisper-modal-body strong { color: var(--text); }
.whisper-modal-body em { color: var(--purple-bright); font-style: normal; font-weight: 600; }

/* Recipient picker: each option is a thin row with display name on
 * top and the @handle badge below. Two-column structure keeps things
 * aligned even when names vary in length. */
.whisper-recipient-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin: 0 0 12px;
  padding: 2px;
}
.whisper-recipient-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.whisper-recipient-option:hover {
  border-color: var(--purple);
  background: var(--bg-hover);
}
.whisper-recipient-option:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}
.whisper-recipient-option:active { transform: scale(0.98); }
.whisper-recipient-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.whisper-recipient-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.whisper-recipient-handle {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font-code, ui-monospace, monospace);
}

/* Audience choice: two large cards (Hidden / Placeholder) with a
 * bold title and a one-line description. */
.whisper-audience-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 0;
}
.whisper-audience-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: var(--border-width) solid var(--border);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.whisper-audience-option:hover {
  border-color: var(--purple);
  background: var(--bg-hover);
}
.whisper-audience-option:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}
.whisper-audience-option:active { transform: scale(0.98); }
.whisper-audience-option strong {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: block;
}
.whisper-audience-option .option-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
  .fall-overlay,
  .fall-letter,
  .fall-word,
  .grumm-flipped,
  .whisper-recipient-option,
  .whisper-audience-option {
    animation: none !important;
    transition: none !important;
  }
}

/* Fallback for browsers without color-mix() (older Safari, mostly). */
@supports not (background: color-mix(in srgb, red, blue)) {
  .message-body-whisper {
    background: rgba(139, 92, 246, 0.12);
    border-left: 3px solid #8b5cf6;
  }
}

/* ask_user question panel (owner's helper DM): gateway questions surfaced
   above the composer as tappable options. Global — desktop + mobile. */
.helper-question-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.25rem 0.75rem 0.5rem;
  padding: 0.5rem;
  background: var(--bg-panel, var(--bg-main));
  border: 1px solid var(--purple-bright, #a78bfa);
  border-radius: 10px;
  max-width: 640px;
}
.hq-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--purple-bright, #a78bfa);
  font-weight: 700;
}
.hq-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.hq-head {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.hq-text {
  font-size: 0.85rem;
  color: var(--text);
  white-space: pre-wrap;
}
.hq-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.hq-opt {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--bg-main);
  color: var(--text);
  border: var(--border-width) solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  max-width: 100%;
}
.hq-opt:hover:not(:disabled) {
  border-color: var(--purple-bright, #a78bfa);
}
.hq-opt.is-selected {
  border-color: var(--purple-bright, #a78bfa);
  color: var(--purple-bright, #a78bfa);
  font-weight: 600;
}
.hq-opt:disabled {
  opacity: 0.6;
  cursor: default;
}
.hq-opt-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}
.hq-sendrow {
  display: flex;
  gap: 0.4rem;
}
.hq-send {
  background: var(--purple-bright, #a78bfa);
  color: #0b0714;
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.hq-send:disabled {
  opacity: 0.5;
  cursor: default;
}
.hq-err {
  font-size: 0.72rem;
  color: #f87171;
}

/* Tab cloak picker (settings > general) */
.cloak-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
  align-items: center;
}
.cloak-icon-opt {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
  box-sizing: border-box;
  object-fit: contain;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.cloak-icon-opt:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.06);
}
.cloak-icon-opt.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.35);
}
.cloak-upload-zone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.9;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}
.cloak-upload-zone:hover {
  border-color: rgba(255, 255, 255, 0.45);
  opacity: 1;
}

/* ── Experimental chatboxes: pure-CSS rendering, ONE look for both
     sender and receiver (no own/other variants). !important is needed
     because .message.own / theme rules set background, border, shadow
     and text color on .message-body with higher specificity. ── */

/* Shared: skin text color wins, even in themes that color
   .message-content / .message-reply-preview directly. */
.message-body.chatbox-neon-blaze .message-content,
.message-body.chatbox-neon-blaze .message-reply-preview,
.message-body.chatbox-aqua-glass .message-content,
.message-body.chatbox-aqua-glass .message-reply-preview,
.message-body.chatbox-pixel-pop .message-content,
.message-body.chatbox-pixel-pop .message-reply-preview,
.message-body.chatbox-sticky-note .message-content,
.message-body.chatbox-sticky-note .message-reply-preview,
.message-body.chatbox-bubble-gum .message-content,
.message-body.chatbox-bubble-gum .message-reply-preview,
.message-body.chatbox-cake-1 .message-content,
.message-body.chatbox-cake-1 .message-reply-preview,
.message-body.chatbox-star-gazer .message-content,
.message-body.chatbox-star-gazer .message-reply-preview {
  color: inherit !important;
}

/* The reply quote's inner parts carry their own colours (.message-reply-sender
   uses var(--text), the snippet var(--text-dim)), so on light skins in a dark
   theme the quoted name painted light text onto them — white on the Sticky
   Note's yellow paper. Let the skin's colour win there as well. */
.message-body[class*="chatbox-"] .message-reply-preview .message-reply-sender,
.message-body[class*="chatbox-"] .message-reply-preview .message-reply-snippet {
  color: inherit !important;
}

/* Neon Blaze — cover art: own = pink→orange neon stroke, other =
   cyan→violet neon stroke, dark gradient fill. */
.message-body.chatbox-neon-blaze {
  background: linear-gradient(180deg, #241040 0%, #12061f 100%) !important;
  border: 1.5px solid #ff2d95 !important;
  border-radius: 10px !important;
  box-shadow: 0 0 0 3px rgba(255, 45, 149, 0.16), 0 0 16px rgba(255, 138, 0, 0.4), 0 2px 14px rgba(255, 45, 149, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
  color: #ffe4f2 !important;
}
.message:not(.own) .message-body.chatbox-neon-blaze {
  background: linear-gradient(180deg, #0b1220 0%, #060a14 100%) !important;
  border-color: #00e5ff !important;
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.14), 0 0 16px rgba(124, 58, 237, 0.45), 0 2px 14px rgba(0, 229, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
}

/* Aqua Glass — cover art: frosted translucent fill, light rim
   stroke with a wider cyan glow stroke beneath it. */
.message-body.chatbox-aqua-glass {
  background: linear-gradient(180deg, rgba(224, 242, 254, 0.28) 0%, rgba(224, 242, 254, 0.05) 38%, rgba(125, 211, 252, 0.14) 100%) !important;
  border: 1.5px solid rgba(224, 242, 254, 0.5) !important;
  border-radius: 10px !important;
  color: #e0f2fe !important;
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.18), 0 0 14px rgba(125, 211, 252, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.28) !important;
}
.message:not(.own) .message-body.chatbox-aqua-glass {
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16), 0 0 14px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.28) !important;
}

/* Pixel Pop — cover art: flat dark fill, chunky hard corners,
   no glow, no offset shadow. Own = cyan stroke, other = violet. */
.message-body.chatbox-pixel-pop {
  background: #0f172a !important;
  border: 2px solid #22d3ee !important;
  border-radius: 0 !important;
  color: #cffafe !important;
  box-shadow: none !important;
}
.message:not(.own) .message-body.chatbox-pixel-pop {
  border-color: #a78bfa !important;
}

/* Sticky Note — cover art: flat yellow paper, amber folded corner,
   thin amber outline, radius 10, no outer shadow. */
.message-body.chatbox-sticky-note {
  background: #fef08a !important;
  border: 1.5px solid #d97706 !important;
  border-radius: 10px !important;
  color: #3f2a06 !important;
  --text-dim: #8a6a1f;
  box-shadow: none !important;
}
.message-body.chatbox-sticky-note::before {
  content: '';
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 0;
  height: 0;
  border-top: 20px solid #f59e0b;
  border-left: 20px solid transparent;
  pointer-events: none;
}
.message-body.chatbox-sticky-note::after {
  content: '';
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 0;
  height: 0;
  border-top: 15px solid #fbbf24;
  border-left: 15px solid transparent;
  pointer-events: none;
}
.message-body.chatbox-sticky-note .message-content a {
  color: #92400e !important;
}
/* Cover art mirrors the fold: other messages fold the top-LEFT corner. */
.message:not(.own) .message-body.chatbox-sticky-note::before {
  left: -1.5px;
  right: auto;
  border-top: 20px solid #f59e0b;
  border-left: none;
  border-right: 20px solid transparent;
}
.message:not(.own) .message-body.chatbox-sticky-note::after {
  left: -1.5px;
  right: auto;
  border-top: 15px solid #fbbf24;
  border-left: none;
  border-right: 15px solid transparent;
}

/* Bubble Gum — cover art: pink→berry gradient blob, light rim,
   radius 10, two glossy highlights, no glow. */
.message-body.chatbox-bubble-gum {
  background: linear-gradient(180deg, #f472b6 0%, #be185d 100%) !important;
  border: 1.5px solid #f9a8d4 !important;
  border-radius: 10px !important;
  color: #fce7f3 !important;
  box-shadow: none !important;
}
.message-body.chatbox-bubble-gum::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 10px;
  width: 38%;
  height: 26%;
  background: radial-gradient(ellipse at 40% 40%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}
.message-body.chatbox-bubble-gum::after {
  content: '';
  position: absolute;
  top: 40%;
  right: 12px;
  width: 12%;
  height: 20%;
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}
/* Cover art: other messages get the indigo gum, own get the pink gum. */
.message:not(.own) .message-body.chatbox-bubble-gum {
  background: linear-gradient(180deg, #4f46e5 0%, #312e81 100%) !important;
  border-color: #818cf8 !important;
  color: #e0e7ff !important;
}

/* Anniversary Cake — first-anniversary birthday cake as a small corner
   icon. Own messages: icon at top-left; others' messages: top-right. */
.message-body.chatbox-cake-1 {
  background:
    radial-gradient(circle at 5px 5px, #ffd166 0 2px, rgba(255, 255, 255, 0) 2.6px) 12px 12px / 26px 22px repeat,
    radial-gradient(circle at 5px 5px, #7ee8c7 0 2px, rgba(255, 255, 255, 0) 2.6px) 24px 18px / 30px 26px repeat,
    radial-gradient(circle at 5px 5px, #7aa8ff 0 2px, rgba(255, 255, 255, 0) 2.6px) 18px 8px / 34px 20px repeat,
    linear-gradient(180deg, #fff9fc 0%, #ffe6f0 100%) !important;
  border: 1.5px solid #ff9ec7 !important;
  border-radius: 10px !important;
  color: #a41f5c !important;
  --text-dim: #c2557f;
  padding-top: 16px;
  box-shadow: none !important;
}
/* Mini cake: candle, frosting + drips, sponge, plate, piped "1".
   Sticker badge — half-extended above the bubble's top edge AND
   half past the side edge, so it reads as a decoration, not text. */
.message-body.chatbox-cake-1::before {
  content: '1';
  position: absolute;
  top: -12px;
  left: -10px;
  width: 20px;
  height: 24px;
  font-size: 8px;
  font-weight: 900;
  font-family: var(--font-code), monospace;
  color: #ffffff;
  text-align: center;
  line-height: 1;
  padding-top: 13px;
  text-shadow: 0 0 2px rgba(214, 51, 132, 0.9);
  background:
    linear-gradient(#ff4d94, #e63d80) 8px 2px / 4px 10px no-repeat,
    linear-gradient(#ffffff, #ffeaf3) 2px 12px / 16px 4px no-repeat,
    radial-gradient(circle at 6px 0, #ffffff 0 2px, rgba(255, 255, 255, 0) 2.6px) 2px 16px / 8px 3px repeat-x,
    linear-gradient(#ff8fc0, #ff75ae) 2px 16px / 16px 6px no-repeat,
    linear-gradient(#f4b93c, #e0a52e) 0 22px / 20px 2px no-repeat;
  pointer-events: none;
}
/* Candle flame, mirroring the icon side. */
.message-body.chatbox-cake-1::after {
  content: '';
  position: absolute;
  top: -14px;
  left: -2px;
  width: 4px;
  height: 5px;
  background: radial-gradient(circle at 50% 70%, #ffd166 0 45%, #ff7a3d 100%);
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  box-shadow: 0 0 4px rgba(255, 170, 60, 0.9);
  pointer-events: none;
}
/* Others' messages: icon at top-right instead. */
.message:not(.own) .message-body.chatbox-cake-1::before {
  left: auto;
  right: -10px;
}
.message:not(.own) .message-body.chatbox-cake-1::after {
  left: auto;
  right: -2px;
}

/* ====================================================================
 * Premium (Venory subscription) UI
 * Tiers are enforced server-side; everything here is presentation.
 * ==================================================================*/

.premium-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.premium-modal[hidden] { display: none; }
.premium-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 14, 0.72);
  backdrop-filter: blur(4px);
}
.premium-modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  background: linear-gradient(180deg, #1d1430 0%, #150f24 100%);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 18px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6);
  color: #ece9f7;
}
.premium-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.premium-modal-close:hover { color: #fff; }
.premium-modal-body { padding: 26px 24px 22px; }
.premium-loading { text-align: center; padding: 40px; color: rgba(255, 255, 255, 0.6); }

.premium-head { text-align: center; margin-bottom: 14px; }
.premium-crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f6c85f;
}
.premium-crown svg { width: 30px; height: 30px; }
.premium-head h2 {
  margin: 6px 0 4px;
  font-size: 21px;
  font-weight: 700;
  background: linear-gradient(90deg, #c4b5fd, #f0abfc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.premium-sub { margin: 0; font-size: 13px; color: rgba(255, 255, 255, 0.62); }

.premium-plans-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin: 16px 0 12px;
}
.premium-plan-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
.premium-plan-btn.active {
  background: rgba(139, 92, 246, 0.25);
  border-color: rgba(167, 139, 250, 0.7);
  color: #fff;
}
.premium-plan-save { font-size: 11px; color: #86efac; margin-left: 4px; }

.premium-tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 620px) {
  .premium-tiers { grid-template-columns: 1fr; }
}
.premium-tier {
  position: relative;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 12px;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.premium-tier:hover { border-color: rgba(167, 139, 250, 0.55); }
.premium-tier.selected {
  border-color: #a78bfa;
  background: rgba(139, 92, 246, 0.16);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35) inset;
}
.premium-tier.current { border-color: rgba(134, 239, 172, 0.5); }
.premium-tier-badge {
  position: absolute;
  top: -9px;
  right: 10px;
  background: #166534;
  color: #dcfce7;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
}
.premium-tier-name { display: block; font-weight: 650; font-size: 14.5px; }
.premium-tier-price { display: block; font-size: 13px; color: #c4b5fd; margin: 3px 0 8px; }
.premium-tier-features { margin: 0; padding-left: 16px; font-size: 12.5px; color: rgba(255, 255, 255, 0.75); }
.premium-tier-features li { margin-bottom: 3px; }

.premium-status { text-align: center; font-size: 12px; color: rgba(255, 255, 255, 0.5); margin: 12px 0 4px; }
.premium-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.premium-btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.premium-btn.primary {
  background: linear-gradient(135deg, #8b5cf6, #d946ef);
  color: #fff;
}
.premium-btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.premium-btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.8);
}
.premium-btn.small { padding: 6px 11px; font-size: 12.5px; }
.premium-checkout-mount { margin-top: 16px; }
.premium-checkout-mount.active {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 16px;
}

/* Settings card */
.premium-settings-card {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.premium-settings-top { display: flex; align-items: center; gap: 8px; }
.premium-plan-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.premium-plan-chip.tier-premium { background: rgba(139, 92, 246, 0.35); }
.premium-plan-chip.tier-plus { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.premium-settings-hint { font-size: 12px; opacity: 0.6; }
.premium-settings-features { margin: 10px 0; padding-left: 18px; font-size: 13px; }
.premium-settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Banner (profile page) */
.premium-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(217, 70, 239, 0.14));
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.premium-banner.compact { padding: 10px 12px; }
.premium-banner.active { background: rgba(134, 239, 172, 0.1); border-color: rgba(134, 239, 172, 0.35); }
.premium-banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #f6c85f;
}
.premium-banner-icon svg { width: 22px; height: 22px; }
.premium-banner.active .premium-banner-icon { color: #86efac; }
.premium-banner-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.premium-banner-text strong { font-size: 14px; }
.premium-banner-text span { font-size: 12px; opacity: 0.7; }

/* Left-bar nav entry */
.left-bar-item.premium-left-bar { background: transparent; border: 0; cursor: pointer; font-family: inherit; }
.left-bar-item.premium-left-bar.is-premium .left-bar-icon { filter: drop-shadow(0 0 6px rgba(217, 70, 239, 0.6)); }
.premium-badge-dot {
  background: linear-gradient(135deg, #8b5cf6, #d946ef) !important;
}

/* Inline quota bar above the Venory composer */
.premium-quota-bar { padding: 0 0 6px; }
.premium-quota-bar[hidden] { display: none; }
.premium-quota-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
}
.premium-quota-text { white-space: nowrap; }
.premium-quota-unlimited { color: #86efac; }
.premium-quota-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  max-width: 160px;
}
.premium-quota-fill { display: block; height: 100%; background: #a78bfa; }
.premium-quota-inner.warn .premium-quota-fill { background: #fbbf24; }
.premium-quota-inner.exhausted .premium-quota-fill { background: #f87171; }
.premium-quota-inner.exhausted .premium-quota-text { color: #fca5a5; }
.premium-quota-cta {
  border: 0;
  background: linear-gradient(135deg, #8b5cf6, #d946ef);
  color: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* Phone chat: full-width conversation, floating panel menu, and larger touch
   controls designed for thumbs instead of pointer precision. */
@media (max-width: 600px), (max-aspect-ratio: 1/1) and (max-width: 900px) {
  html,
  body,
  #app,
  .app-shell,
  .app-shell-inner {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .app-shell {
    height: 100dvh;
  }

  .app-shell-inner { overflow: hidden; }

  .panel-column {
    width: 0;
    min-width: 0;
    overflow: visible;
    z-index: 250;
  }

  .panel-column-toggle {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    top: max(12px, env(safe-area-inset-top, 0px));
    transform: none;
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--bg-panel) 88%, var(--purple));
    color: var(--text);
    box-shadow: 0 6px 22px rgba(0, 0, 0, .32);
    backdrop-filter: blur(14px);
    z-index: 500;
  }

  .panel-column-toggle .left-bar-icon { display: none; }

  .mobile-menu-glyph {
    display: flex;
    width: 21px;
    flex-direction: column;
    gap: 5px;
  }

  .mobile-menu-glyph i {
    display: block;
    width: 21px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .18s ease, width .18s ease;
  }

  .panel-column-expanded .mobile-menu-glyph i:first-child { transform: translateY(7px) rotate(45deg); }
  .panel-column-expanded .mobile-menu-glyph i:nth-child(2) { width: 0; }
  .panel-column-expanded .mobile-menu-glyph i:last-child { transform: translateY(-7px) rotate(-45deg); }

  .panel-column-expanded {
    width: 240px;
    min-width: 0;
  }

  .panel-column-expanded .panel-column-toggle {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    top: max(12px, env(safe-area-inset-top, 0px));
    right: auto;
    transform: none;
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .chat-main,
  .chat-area { min-width: 0; width: 100%; }

  .chat-header {
    min-height: 64px;
    padding: 0.45rem 0.65rem 0.45rem 70px;
  }

  .chat-header-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-header-subtitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  .chat-header-menu-btn,
  .composer-actions button,
  .composer-send {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    border-radius: 14px;
    touch-action: manipulation;
  }

  .messages-wrap { padding: 0.6rem 0.45rem; }

  .message-row,
  .message-row:has(.message.own) {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 0.35rem;
  }

  .message-row:has(.message.own) { grid-template-columns: minmax(0, 1fr) 30px; }

  .message-avatar { width: 28px; height: 28px; }

  .composer {
    padding: 0.4rem 0.45rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }

  .composer textarea { max-height: 112px; padding: 0.45rem 0.65rem; }

  .composer-row { gap: 0.45rem; }
  .composer-actions { gap: 0.25rem; padding: 0.2rem; }
  .composer-input-wrap { min-height: 48px; border-radius: 16px; }

  .left-bar {
    flex: 0 0 calc(68px + env(safe-area-inset-bottom, 0px));
    height: calc(68px + env(safe-area-inset-bottom, 0px));
    min-height: calc(68px + env(safe-area-inset-bottom, 0px));
    padding-left: max(0.4rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.4rem, env(safe-area-inset-right, 0px));
    background: color-mix(in srgb, var(--bg-panel) 94%, var(--purple));
    box-shadow: 0 -5px 18px rgba(0, 0, 0, .18);
  }

  .left-bar .left-bar-nav { justify-content: space-evenly; gap: 0; }

  .left-bar .left-bar-item {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 15px;
    padding: 0.55rem;
    touch-action: manipulation;
  }

  .left-bar .left-bar-avatar-link { width: 40px; height: 40px; }
  .left-bar .left-bar-avatar { padding: 0.35rem; }

  /* Expansion is a desktop affordance. In portrait, preserve the bottom-tab
     geometry even if the saved desktop preference says the rail was open. */
  .left-bar-expanded { width: 100%; }
  .left-bar-expanded .left-bar-nav { align-items: center; padding: 0 0.5rem; }
  .left-bar-expanded .left-bar-item {
    flex: 0 0 48px;
    width: 48px;
    min-width: 48px;
    justify-content: center;
    padding: 0.55rem;
  }
  .left-bar-expanded .left-bar-label { display: none; }

  .panel-list-link,
  .panel-user-item,
  .panel-column-expanded button,
  .panel-column-expanded [role="button"] {
    min-height: 48px;
  }
}

/* Give the message field the entire first row on phones. The placeholder stays
   readable while the thumb-sized tools remain grouped below it. */
@media (max-width: 480px) {
  .composer-row {
    display: grid;
    grid-template-columns: repeat(3, 48px) minmax(0, 1fr) 48px;
    gap: 0.25rem;
    align-items: center;
  }

  .composer-input-wrap {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    min-height: 40px;
    align-items: center;
  }
  .composer textarea {
    height: 22px;
    min-height: 22px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 16px;
    line-height: 22px;
  }
  .composer-actions { display: contents; }
  .composer-actions #composer-mic { grid-column: 1; grid-row: 2; }
  .composer-actions #attach-file { grid-column: 2; grid-row: 2; }
  .composer-actions #composer-emoji { grid-column: 3; grid-row: 2; }
  .composer-row > .composer-send { grid-column: 5; grid-row: 2; justify-self: end; }
}

.left-bar-nav > .mobile-nav-more-toggle { display: none; }

/* A <button> keeps its browser-default fill unless reset; make the More tab
   use the same transparent base as the navigation links beside it. */
.left-bar .mobile-nav-more-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}

/* Phone navigation prioritizes four named destinations. Secondary pages sit
   in More so the primary bar never depends on horizontal scrolling. */
@media (max-width: 600px), (max-aspect-ratio: 1/1) and (max-width: 900px) {
  .left-bar {
    overflow: visible;
    align-items: stretch;
  }

  .left-bar-avatar,
  .left-bar-bottom,
  .left-bar-nav > .mobile-desktop-nav {
    display: none !important;
  }

  .left-bar .left-bar-nav {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    align-items: stretch;
    justify-content: space-evenly;
    gap: 0.25rem;
    overflow: visible;
    padding: 0 0.25rem;
  }

  .left-bar .left-bar-nav > .mobile-primary-nav,
  .left-bar .left-bar-nav > .mobile-nav-more-toggle {
    flex: 1 1 0;
    width: auto;
    min-width: 56px;
    max-width: 96px;
    height: 60px;
    min-height: 60px;
    padding: 0.3rem 0.15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    border-radius: 15px;
  }

  .left-bar:not(.left-bar-expanded) .left-bar-label {
    display: block;
    max-width: 100%;
    opacity: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transform: none;
    animation: none;
    font-size: 0.64rem;
    line-height: 1.15;
    text-align: center;
  }

  .left-bar .left-bar-icon,
  .left-bar .left-bar-icon-wrap .left-bar-icon {
    width: 21px;
    height: 21px;
  }

  .left-bar .mobile-nav-more-menu {
    position: absolute;
    inset: auto 0.6rem calc(100% + 0.55rem);
    z-index: 650;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    max-height: min(62dvh, 420px);
    overflow: auto;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: color-mix(in srgb, var(--bg-panel) 92%, var(--purple));
    box-shadow: 0 12px 36px rgba(0, 0, 0, .4);
    backdrop-filter: blur(18px);
  }

  .left-bar .mobile-nav-more-menu:not([hidden]) { display: grid; }

  .mobile-nav-more-link {
    min-width: 0;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--bg-main);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    text-decoration: none;
    touch-action: manipulation;
  }

  .mobile-nav-more-link .left-bar-icon { flex: 0 0 21px; }
  .mobile-nav-more-link:hover,
  .mobile-nav-more-link:focus-visible { background: var(--bg-hover); outline: 2px solid var(--purple); }

  .left-bar.mobile-more-open { z-index: 600; }
}

/* Premium modal adapts its hierarchy to the account's current membership. */
.premium-modal-content.tier-view-free .premium-head-free {
  padding: 12px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.premium-account-state {
  display: block;
  margin-top: 6px;
  color: #c4b5fd;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.14em;
}
.premium-head-premium .premium-crown { color: #c4b5fd; }
.premium-head-plus .premium-crown { color: #f6c85f; filter: drop-shadow(0 0 10px rgba(246, 200, 95, 0.35)); }
.premium-modal-content.tier-view-premium .premium-head h2 {
  background-image: linear-gradient(90deg, #c4b5fd, #a78bfa);
}
.premium-modal-content.tier-view-plus .premium-head h2 {
  background-image: linear-gradient(90deg, #f6c85f, #f0abfc);
}
.premium-member-callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 18px 0 8px;
  padding: 16px;
  border: 1px solid rgba(246, 200, 95, 0.36);
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.18), rgba(246, 200, 95, 0.1));
  text-align: center;
}
.premium-member-callout strong { color: #f8e6a0; font-size: 15px; }
.premium-member-callout span { color: rgba(255, 255, 255, 0.72); font-size: 12px; }
.premium-tiers-for-premium .premium-tier[data-tier="plus"] {
  border-color: rgba(217, 70, 239, 0.48);
  background: rgba(139, 92, 246, 0.09);
}
.premium-tiers-for-plus .premium-tier.current {
  border-color: rgba(246, 200, 95, 0.7);
  background: linear-gradient(150deg, rgba(139, 92, 246, 0.18), rgba(246, 200, 95, 0.08));
}
.premium-settings-card.tier-view-free { border-color: rgba(167, 139, 250, 0.42); }
.premium-settings-card.tier-view-premium { background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05)); }
.premium-settings-card.tier-view-plus { background: linear-gradient(135deg, rgba(139, 92, 246, 0.17), rgba(246, 200, 95, 0.09)); border-color: rgba(246, 200, 95, 0.4); }
.premium-settings-card.tier-view-plus .premium-plan-chip { background: linear-gradient(135deg, #8b5cf6, #d946ef 60%, #d7a843); }
@media (max-width: 620px) {
  .premium-modal-body { padding: 22px 16px 18px; }
  .premium-member-callout { margin-top: 12px; }
  .premium-modal-content.tier-view-plus .premium-plans-toggle { margin-top: 12px; }
}

/* Venory has separate casual-chat and support personalities in DMs. */
.venory-persona-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
}
.venory-persona-caption {
  padding: 0 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 650;
}
.venory-persona-switch button {
  min-height: 32px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
.venory-persona-switch button.is-active {
  background: var(--purple-bright, #8b5cf6);
  color: #fff;
}
.chat-header:has(.venory-persona-switch) .chat-header-title { flex: 1 1 auto; min-width: 0; }
@media (max-width: 600px), (max-aspect-ratio: 1/1) and (max-width: 900px) {
  .venory-persona-caption { display: none; }
  .venory-persona-switch { gap: 1px; }
  .venory-persona-switch button { min-height: 36px; padding: 0 9px; }
}

/* Theme variants shared with jimmyqrg.pages.dev. All chat surfaces use the
   same design tokens so dialogs, messages, settings, and the app chrome move
   together instead of recolouring only the conversation pane. */
html[data-theme="study"][data-theme-variant="study"] {
  --bg-deep:#f1f0e7; --bg-main:#f8f7f1; --bg-panel:#e5e8de; --bg-hover:#dbe2d5; --border:#cbd2c5;
  --purple:#496c55; --purple-dim:#35563f; --purple-bright:#50785d; --accent:#8b694f;
  --text:#2c3930; --text-dim:#5e6d62; --text-muted:#748076; --star:rgba(64,91,68,.04); --glow:rgba(70,105,79,.08);
  --font-family:Georgia,"Palatino Linotype",serif; --border-width:1px;
}
html[data-theme="study"][data-theme-variant="study-library"] {
  --bg-deep:#eee5d8; --bg-main:#f9f2e7; --bg-panel:#e8ddcd; --bg-hover:#ded0bc; --border:#d3c2ab;
  --purple:#754451; --purple-dim:#5c3540; --purple-bright:#864c59; --accent:#a06a43;
  --text:#3d302e; --text-dim:#705f58; --text-muted:#85766e; --star:rgba(97,62,55,.035); --glow:rgba(115,65,73,.08);
  --font-family:"Palatino Linotype",Georgia,serif; --border-width:1px;
}
html[data-theme="study"][data-theme-variant="study-campus"] {
  --bg-deep:#e9f0e7; --bg-main:#f4f8f0; --bg-panel:#dfe9dd; --bg-hover:#d4e2d3; --border:#c5d4c7;
  --purple:#38664a; --purple-dim:#2b513b; --purple-bright:#477a58; --accent:#a27542;
  --text:#29372d; --text-dim:#596c5d; --text-muted:#718174; --star:rgba(51,97,66,.04); --glow:rgba(58,111,72,.08);
  --font-family:"Trebuchet MS",system-ui,sans-serif; --border-width:1px;
}
html[data-theme="study"][data-theme-variant="study-lab"] {
  --bg-deep:#e8eef3; --bg-main:#f5f8fa; --bg-panel:#dfe8ef; --bg-hover:#d2e0ea; --border:#c2d1dd;
  --purple:#356584; --purple-dim:#284f69; --purple-bright:#3e7494; --accent:#4e806b;
  --text:#283846; --text-dim:#586b79; --text-muted:#71818d; --star:rgba(52,100,130,.035); --glow:rgba(55,111,147,.08);
  --font-family:system-ui,"Segoe UI",sans-serif; --border-width:1px;
}
html[data-theme="study"][data-theme-variant="study-notebook"] {
  --bg-deep:#f3eddb; --bg-main:#fffaf0; --bg-panel:#eee5d0; --bg-hover:#e6dcc5; --border:#d8cdb4;
  --purple:#4e6c9b; --purple-dim:#3b5885; --purple-bright:#617eac; --accent:#9b6649;
  --text:#34332e; --text-dim:#68665d; --text-muted:#817d71; --star:rgba(75,102,147,.035); --glow:rgba(75,104,154,.07);
  --font-family:"Trebuchet MS",system-ui,sans-serif; --border-width:1px;
}
html[data-theme="study"][data-theme-variant="study-graphite"] {
  --bg-deep:#e8e8e3; --bg-main:#f4f4f0; --bg-panel:#dedfda; --bg-hover:#d4d6d0; --border:#c5c8c1;
  --purple:#575f5b; --purple-dim:#424b47; --purple-bright:#66726c; --accent:#a06f48;
  --text:#303633; --text-dim:#606864; --text-muted:#777e79; --star:rgba(70,77,73,.035); --glow:rgba(79,93,84,.06);
  --font-family:system-ui,"Segoe UI",sans-serif; --border-width:1px;
}
html[data-theme="study"][data-theme-variant="study-notebook"] body::before {
  background:repeating-linear-gradient(180deg,transparent 0 31px,rgba(83,111,156,.055) 32px 33px),var(--bg-deep) !important;
}
html[data-theme="study"] .auth-screen { background:var(--bg-deep) !important; }
html[data-theme="study"][data-theme-variant="study-library"] .chat-header,
html[data-theme="study"][data-theme-variant="study-library"] .settings-section-title { font-family:"Palatino Linotype",Georgia,serif; }

html[data-theme="jimmyqrg"][data-theme-variant="jimmyqrg-solar"] {
  --font-family:'JimmyQrg',system-ui,sans-serif; --bg-deep:#100d09; --bg-main:#17120d; --bg-panel:#21190f; --bg-hover:#302313;
  --border:#4b3920; --purple:#e3a52f; --purple-dim:#b77a1d; --purple-bright:#f4bd54; --accent:#ff8f47;
  --text:#f5e8cd; --text-dim:#c6ac78; --text-muted:#98805a; --star:rgba(255,190,83,.12); --glow:rgba(226,154,41,.2); --border-width:1px;
  --theme-tint:rgba(227,165,47,.14); --theme-tint-strong:rgba(227,165,47,.28); --theme-gradient:linear-gradient(135deg,#e3a52f,#ff8f47); --theme-accent-ink:#1b130b;
}
html[data-theme="jimmyqrg"][data-theme-variant="jimmyqrg-verdant"] {
  --font-family:system-ui,"Segoe UI",sans-serif; --bg-deep:#07110d; --bg-main:#0b1711; --bg-panel:#101f17; --bg-hover:#1b3024;
  --border:#2b4938; --purple:#38c98c; --purple-dim:#219b68; --purple-bright:#69e3ab; --accent:#9acb56;
  --text:#e1f0e5; --text-dim:#91b59e; --text-muted:#71927d; --star:rgba(81,220,151,.12); --glow:rgba(63,211,140,.2); --border-width:1px;
  --theme-tint:rgba(56,201,140,.14); --theme-tint-strong:rgba(56,201,140,.28); --theme-gradient:linear-gradient(135deg,#38c98c,#9acb56); --theme-accent-ink:#06120d;
}
html[data-theme-variant="jimmyqrg-solar"] body::before {
  background:radial-gradient(ellipse 75% 52% at 50% -18%,rgba(227,165,47,.20),transparent 72%),linear-gradient(150deg,#100d09,#19120b 70%,#120e09) !important;
}
html[data-theme-variant="jimmyqrg-verdant"] body::before {
  background:radial-gradient(ellipse 80% 56% at 50% -20%,rgba(56,201,140,.18),transparent 74%),linear-gradient(150deg,#07110d,#0b1912 70%,#08110d) !important;
}
html[data-theme-variant="jimmyqrg-solar"] .auth-screen { background:radial-gradient(ellipse at 50% 0%,rgba(227,165,47,.2),transparent 62%),#100d09 !important; }
html[data-theme-variant="jimmyqrg-verdant"] .auth-screen { background:radial-gradient(ellipse at 50% 0%,rgba(56,201,140,.18),transparent 62%),#07110d !important; }

/* Solar Cabinet moves the primary navigation into a warm, arcade-style dock. */
@media (min-aspect-ratio:1/1) {
  html[data-theme-variant="jimmyqrg-solar"] .app-shell { flex-direction:column-reverse; }
  html[data-theme-variant="jimmyqrg-solar"] .left-bar,
  html[data-theme-variant="jimmyqrg-solar"] .left-bar.left-bar-expanded {
    order:0; width:100%; height:68px; min-height:68px; flex-direction:row; align-items:center; justify-content:center;
    background:#17120c; border-top:1px solid #57401e; border-right:0; box-shadow:0 -8px 24px rgba(0,0,0,.16);
  }
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-avatar,
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-bottom,
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-expand { display:none !important; }
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-nav,
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-expanded .left-bar-nav {
    width:100%; height:100%; flex-direction:row; align-items:center; justify-content:center; gap:10px; padding:0 12px;
  }
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-item,
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-expanded .left-bar-item {
    width:44px; min-width:44px; height:44px; justify-content:center; padding:10px; color:#c6ac78;
  }
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-label { display:none !important; }
  html[data-theme-variant="jimmyqrg-solar"] .left-bar-item.active { background:#3b2a12; color:#f4bd54; box-shadow:inset 0 -3px #efa82b,0 0 16px rgba(239,168,43,.12); }
}
/* Emerald Circuit mirrors the main site's right-hand navigation rail. */
@media (min-aspect-ratio:1/1) {
  html[data-theme-variant="jimmyqrg-verdant"] .app-shell { flex-direction:row-reverse; }
  html[data-theme-variant="jimmyqrg-verdant"] .left-bar { border-right:0; border-left:1px solid #2b4938; background:#0d1913; }
  html[data-theme-variant="jimmyqrg-verdant"] .panel-column { border-right:0; border-left:1px solid #2b4938; }
  html[data-theme-variant="jimmyqrg-verdant"] .panel-column-toggle { right:0; left:auto; }
  html[data-theme-variant="jimmyqrg-verdant"] .panel-column-toggle .left-bar-icon { transform:scaleX(-1); }
}

/* Shared theme chooser for the first-run screen and Settings. */
.theme-gate-box { width:min(980px,96vw); max-width:980px; max-height:calc(100dvh - 24px); overflow-y:auto; }
.theme-gate-picker { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; }
.theme-choice-group { min-width:0; }
.theme-choice-heading { margin:0 0 .55rem; color:var(--text-dim); font-size:.78rem; letter-spacing:.09em; text-transform:uppercase; }
.theme-choice-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:.65rem; }
.theme-choice-grid .theme-picker-item { min-height:132px; }
.theme-picker-swatch { height:27px; }
.theme-swatch-study { background:linear-gradient(120deg,#f1f0e7,#e5e8de 52%,#496c55); }
.theme-swatch-study-library { background:linear-gradient(120deg,#eee5d8,#f9f2e7 52%,#754451); }
.theme-swatch-study-campus { background:linear-gradient(120deg,#e9f0e7,#f4f8f0 52%,#38664a); }
.theme-swatch-study-lab { background:linear-gradient(120deg,#e8eef3,#f5f8fa 52%,#356584); }
.theme-swatch-study-notebook { background:linear-gradient(120deg,#f3eddb,#fffaf0 52%,#4e6c9b); }
.theme-swatch-study-graphite { background:linear-gradient(120deg,#e8e8e3,#f4f4f0 52%,#575f5b); }
.theme-swatch-jimmyqrg-solar { background:linear-gradient(120deg,#100d09,#21190f 52%,#e3a52f); }
.theme-swatch-jimmyqrg-verdant { background:linear-gradient(120deg,#07110d,#101f17 52%,#38c98c); }
.theme-sync-link { display:inline-flex; margin-top:.9rem; color:var(--purple-bright); font-size:.82rem; text-decoration:none; }
.theme-sync-link:hover { text-decoration:underline; }
html[data-theme="study"] .theme-choice-heading { color:var(--text-dim); }
@media(max-width:640px) {
  .theme-gate-box { width:min(96vw,560px); padding:1.1rem; }
  .theme-choice-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:.5rem; }
  .theme-choice-grid .theme-picker-item { min-height:120px; padding:.6rem; }
  .theme-picker-desc { font-size:.72rem; }
}
@media(max-width:370px) { .theme-choice-grid { grid-template-columns:1fr; } }

/* Recolor the few legacy surfaces that still carry literal purple values so
   the Solar and Verdant palettes stay consistent across premium, helper, and
   utility controls too. Custom message-bubble skins remain user-selected. */
html[data-theme-variant="jimmyqrg-solar"] .user-tag-helper,
html[data-theme-variant="jimmyqrg-solar"] .user-tag-admin,
html[data-theme-variant="jimmyqrg-solar"] .support-helper-tip,
html[data-theme-variant="jimmyqrg-solar"] .premium-settings-card,
html[data-theme-variant="jimmyqrg-solar"] .premium-banner:not(.active) { background:var(--theme-tint) !important; border-color:var(--theme-tint-strong) !important; }
html[data-theme-variant="jimmyqrg-verdant"] .user-tag-helper,
html[data-theme-variant="jimmyqrg-verdant"] .user-tag-admin,
html[data-theme-variant="jimmyqrg-verdant"] .support-helper-tip,
html[data-theme-variant="jimmyqrg-verdant"] .premium-settings-card,
html[data-theme-variant="jimmyqrg-verdant"] .premium-banner:not(.active) { background:var(--theme-tint) !important; border-color:var(--theme-tint-strong) !important; }
html[data-theme-variant="jimmyqrg-solar"] .user-tag-helper,
html[data-theme-variant="jimmyqrg-solar"] .user-tag-admin,
html[data-theme-variant="jimmyqrg-solar"] .support-helper-tip-icon,
html[data-theme-variant="jimmyqrg-solar"] .premium-tier-price,
html[data-theme-variant="jimmyqrg-solar"] .premium-status,
html[data-theme-variant="jimmyqrg-solar"] .hc-compact-btn,
html[data-theme-variant="jimmyqrg-solar"] .hq-title,
html[data-theme-variant="jimmyqrg-verdant"] .user-tag-helper,
html[data-theme-variant="jimmyqrg-verdant"] .user-tag-admin,
html[data-theme-variant="jimmyqrg-verdant"] .support-helper-tip-icon,
html[data-theme-variant="jimmyqrg-verdant"] .premium-tier-price,
html[data-theme-variant="jimmyqrg-verdant"] .premium-status,
html[data-theme-variant="jimmyqrg-verdant"] .hc-compact-btn,
html[data-theme-variant="jimmyqrg-verdant"] .hq-title { color:var(--purple-bright) !important; }
html[data-theme-variant="jimmyqrg-solar"] .premium-btn.primary,
html[data-theme-variant="jimmyqrg-solar"] .premium-plan-btn.active,
html[data-theme-variant="jimmyqrg-solar"] .premium-plan-chip.tier-premium,
html[data-theme-variant="jimmyqrg-solar"] .premium-plan-chip.tier-plus,
html[data-theme-variant="jimmyqrg-solar"] .premium-quota-cta,
html[data-theme-variant="jimmyqrg-solar"] .premium-badge-dot,
html[data-theme-variant="jimmyqrg-solar"] .premium-quota-fill,
html[data-theme-variant="jimmyqrg-solar"] .toast-action,
html[data-theme-variant="jimmyqrg-verdant"] .premium-btn.primary,
html[data-theme-variant="jimmyqrg-verdant"] .premium-plan-btn.active,
html[data-theme-variant="jimmyqrg-verdant"] .premium-plan-chip.tier-premium,
html[data-theme-variant="jimmyqrg-verdant"] .premium-plan-chip.tier-plus,
html[data-theme-variant="jimmyqrg-verdant"] .premium-quota-cta,
html[data-theme-variant="jimmyqrg-verdant"] .premium-badge-dot,
html[data-theme-variant="jimmyqrg-verdant"] .premium-quota-fill,
html[data-theme-variant="jimmyqrg-verdant"] .toast-action { background:var(--theme-gradient) !important; color:var(--theme-accent-ink) !important; border-color:var(--purple) !important; }
html[data-theme-variant="jimmyqrg-solar"] .premium-banner-icon,
html[data-theme-variant="jimmyqrg-verdant"] .premium-banner-icon { color:var(--accent) !important; }
html[data-theme-variant="jimmyqrg-solar"] .auth-box::after,
html[data-theme-variant="jimmyqrg-verdant"] .auth-box::after { background:linear-gradient(90deg,transparent,var(--purple),transparent); }
html[data-theme-variant="jimmyqrg-solar"] .auth-box,
html[data-theme-variant="jimmyqrg-verdant"] .auth-box { box-shadow:0 0 40px var(--glow); }
html[data-theme-variant="jimmyqrg-solar"] .auth-box:hover,
html[data-theme-variant="jimmyqrg-verdant"] .auth-box:hover { box-shadow:0 0 56px var(--glow); }
html[data-theme-variant="jimmyqrg-solar"] .message-body-whisper,
html[data-theme-variant="jimmyqrg-verdant"] .message-body-whisper { background:var(--theme-tint) !important; border-left-color:var(--purple) !important; }


/* ── Theme family chooser: two destinations, then a focused preset dialog. ── */
.theme-picker {
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:.85rem;
}
.theme-family-option {
  position:relative;
  display:grid;
  grid-template-columns:58px minmax(0,1fr) auto;
  align-items:center;
  gap:.9rem;
  min-height:116px;
  padding:1rem;
  overflow:hidden;
  text-align:left;
  color:var(--text);
  background:var(--bg-panel);
  border:1px solid var(--border);
  border-radius:14px;
  cursor:pointer;
  transition:transform .18s ease,border-color .18s ease,background .18s ease,box-shadow .18s ease;
}
.theme-family-option:hover,.theme-family-option:focus-visible {
  transform:translateY(-2px);
  border-color:var(--purple-bright);
  background:var(--bg-hover);
  outline:none;
  box-shadow:0 10px 28px var(--glow);
}
.theme-family-option.active { border-color:var(--purple); box-shadow:inset 0 0 0 1px var(--purple); }
.theme-family-preview { display:grid; grid-template-columns:repeat(2,23px); grid-auto-rows:23px; gap:4px; }
.theme-family-swatch { display:block; width:23px; height:23px; border:1px solid var(--border); border-radius:7px; }
.theme-family-copy { display:grid; gap:.25rem; min-width:0; }
.theme-family-copy .theme-picker-label { font-size:1.02rem; }
.theme-family-current { color:var(--purple-bright); font-size:.72rem; }
.theme-family-count { align-self:center; color:var(--text-muted); font-size:.72rem; white-space:nowrap; }
.theme-family-count span { padding-left:.3rem; font-size:1.25rem; vertical-align:-1px; }
.theme-swatch-jimmyqrg { background:linear-gradient(135deg,#100817,#261640 56%,#a78bfa); }
.theme-swatch-study { background:linear-gradient(135deg,#f1f0e7,#e5e8de 56%,#496c55); }
.theme-style-backdrop {
  position:fixed;
  inset:0;
  z-index:12000;
  display:grid;
  place-items:center;
  padding:1rem;
  background:rgba(5,7,12,.7);
  backdrop-filter:blur(12px);
  animation:overlayIn .18s ease-out both;
}
.theme-style-dialog {
  width:min(760px,96vw);
  max-height:min(88dvh,760px);
  overflow:auto;
  padding:clamp(1rem,3vw,1.65rem);
  color:var(--text);
  background:var(--bg-main);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:0 24px 90px rgba(0,0,0,.42),0 0 50px var(--glow);
}
.theme-style-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:1.2rem; }
.theme-style-back,.theme-style-close {
  display:inline-flex; align-items:center; justify-content:center; gap:.45rem;
  min-height:38px; padding:.45rem .7rem; color:var(--text-dim);
  background:var(--bg-panel); border:1px solid var(--border); border-radius:9px; cursor:pointer;
}
.theme-style-close { width:38px; padding:0; font-size:1.5rem; }
.theme-style-back:hover,.theme-style-close:hover { color:var(--text); background:var(--bg-hover); }
.theme-style-intro { margin-bottom:1rem; }
.theme-style-kicker { color:var(--purple-bright); font-size:.7rem; font-weight:700; letter-spacing:.14em; text-transform:uppercase; }
.theme-style-intro h2 { margin:.3rem 0; color:var(--text); font-size:1.55rem; }
.theme-style-intro p { color:var(--text-muted); font-size:.82rem; line-height:1.5; }
.theme-style-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:.65rem; }
.theme-style-grid .theme-picker-item { min-height:124px; }
.theme-style-current { color:var(--purple-bright); font-size:.7rem; font-weight:700; }

/* Study presets share the paper palettes but use different chat layouts. */
html[data-theme-variant="study-library"] .app-shell-inner { background:linear-gradient(90deg,rgba(117,68,81,.055),transparent 26%); }
html[data-theme-variant="study-library"] .chat-main { width:min(100%,1000px); margin-inline:auto; border-inline:1px solid var(--border); }
html[data-theme-variant="study-library"] .chat-header { border-bottom:3px double var(--border); padding-inline:clamp(1.4rem,4vw,3rem); }
html[data-theme-variant="study-library"] .messages-wrap { padding:1.6rem clamp(1rem,5vw,4.5rem); }
html[data-theme-variant="study-library"] .message-row { padding:.45rem 0 .75rem; border-bottom:1px solid rgba(117,68,81,.13); }
html[data-theme-variant="study-library"] .message-body,
html[data-theme-variant="study-library"] .message.own .message-body { border-left:3px solid var(--accent)!important; padding:.55rem 1rem .8rem; font-family:var(--font-family); }
html[data-theme-variant="study-library"] .composer { border-top:3px double var(--border); padding-inline:clamp(1.4rem,4vw,3rem); }
html[data-theme-variant="study-library"] .composer-input-wrap { border-radius:4px; border-bottom:2px solid var(--purple); }

@media (min-aspect-ratio:1/1) {
  /* Field Notes uses a horizontal tool strip and a field-journal canvas. */
  html[data-theme-variant="study-campus"] .app-shell { flex-direction:column; }
  html[data-theme-variant="study-campus"] .left-bar,
  html[data-theme-variant="study-campus"] .left-bar.left-bar-expanded {
    order:0; width:100%; height:56px; min-height:56px; flex-direction:row; align-items:center;
    border-right:0; border-bottom:1px solid var(--border); background:#e4ede0;
  }
  html[data-theme-variant="study-campus"] .left-bar-avatar,
  html[data-theme-variant="study-campus"] .left-bar-bottom,
  html[data-theme-variant="study-campus"] .left-bar-expand { display:none!important; }
  html[data-theme-variant="study-campus"] .left-bar-nav,
  html[data-theme-variant="study-campus"] .left-bar-expanded .left-bar-nav {
    width:auto; height:100%; flex:1; flex-direction:row; align-items:center; justify-content:flex-start; gap:.45rem; padding:0 .8rem;
  }
  html[data-theme-variant="study-campus"] .left-bar-item,
  html[data-theme-variant="study-campus"] .left-bar-expanded .left-bar-item {
    width:auto; height:40px; justify-content:center; padding:.45rem .7rem; border-radius:8px;
  }
  html[data-theme-variant="study-campus"] .left-bar-label { display:inline!important; }
  html[data-theme-variant="study-campus"] .left-bar-item.active { background:#cbdcc9; color:#294b35; box-shadow:inset 0 -2px #477a58; }
  html[data-theme-variant="study-campus"] .messages-wrap { background:radial-gradient(ellipse at 90% 5%,rgba(56,102,74,.09),transparent 34%),var(--bg-main); }
  html[data-theme-variant="study-campus"] .message-row { padding:.55rem .7rem; margin-bottom:.5rem; border-left:2px solid var(--accent); background:rgba(255,255,255,.34); }
  html[data-theme-variant="study-campus"] .message-body,
  html[data-theme-variant="study-campus"] .message.own .message-body { border:0!important; box-shadow:none!important; background:transparent!important; padding:.25rem .5rem; }
}
/* Lab Bench reads like a calm technical console: compact, square and ruled. */
html[data-theme-variant="study-lab"] { --font-family:ui-monospace,"SFMono-Regular",Consolas,monospace; }
html[data-theme-variant="study-lab"] .chat-header { background:#e7eff4; border-bottom:2px solid #9bb2c1; }
html[data-theme-variant="study-lab"] .chat-header-title::before { content:"// "; color:var(--purple); }
html[data-theme-variant="study-lab"] .messages-wrap { background-image:linear-gradient(rgba(53,101,132,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(53,101,132,.035) 1px,transparent 1px); background-size:24px 24px; }
html[data-theme-variant="study-lab"] .message-row { padding:.35rem .6rem; border-bottom:1px dashed var(--border); }
html[data-theme-variant="study-lab"] .message-body,
html[data-theme-variant="study-lab"] .message.own .message-body { border-radius:2px!important; box-shadow:none!important; }
html[data-theme-variant="study-lab"] .composer-input-wrap { border-radius:3px; border-width:2px; }
html[data-theme-variant="study-lab"] .composer-send { border-radius:3px!important; }
/* Notebook is a single ruled page with indented handwritten entries. */
html[data-theme-variant="study-notebook"] .messages-wrap { padding:1rem clamp(1rem,4vw,3.5rem); background-image:repeating-linear-gradient(180deg,transparent 0 31px,rgba(83,111,156,.09) 32px 33px); }
html[data-theme-variant="study-notebook"] .message-row { padding:.35rem .6rem .5rem 1rem; margin-left:clamp(.2rem,2vw,1.8rem); border-left:2px solid rgba(155,102,73,.46); }
html[data-theme-variant="study-notebook"] .message-body,
html[data-theme-variant="study-notebook"] .message.own .message-body { background:rgba(255,250,240,.82)!important; border:1px solid rgba(216,205,180,.7)!important; box-shadow:2px 3px 0 rgba(87,98,119,.08)!important; }
html[data-theme-variant="study-notebook"] .chat-header { background:#fffaf0; border-bottom:1px dashed #c6b99e; }
html[data-theme-variant="study-notebook"] .composer { background:#fffaf0; }
/* Graphite is a monochrome document workspace with navigation on the right. */
@media (min-aspect-ratio:1/1) {
  html[data-theme-variant="study-graphite"] .app-shell { flex-direction:row-reverse; }
  html[data-theme-variant="study-graphite"] .left-bar { border-right:0; border-left:1px solid #c5c8c1; background:#e1e2dd; }
  html[data-theme-variant="study-graphite"] .left-bar-item.active { background:#c9ceca; color:#303633; box-shadow:inset -3px 0 #66726c; }
  html[data-theme-variant="study-graphite"] .panel-column { border-right:0; border-left:1px solid var(--border); }
}
html[data-theme-variant="study-graphite"] .chat-header { background:#dedfda; }
html[data-theme-variant="study-graphite"] .message-row { border-bottom:1px solid #d4d6d0; padding:.5rem 0; }
html[data-theme-variant="study-graphite"] .message-body,
html[data-theme-variant="study-graphite"] .message.own .message-body { border-radius:2px!important; box-shadow:none!important; background:transparent!important; }
html[data-theme-variant="study-graphite"] .composer-input-wrap { background:#f4f4f0; border-radius:3px; }

/* JimmyQrg presets reshape the whole workspace, not just accent colors. */
html[data-theme-variant="jimmyqrg-solar"] .chat-header { background:#20170d; border-bottom:2px solid #65491e; }
html[data-theme-variant="jimmyqrg-solar"] .left-bar-item { border-radius:4px; }
html[data-theme-variant="jimmyqrg-solar"] .message-row { margin-bottom:.8rem; }
html[data-theme-variant="jimmyqrg-solar"] .message-body,
html[data-theme-variant="jimmyqrg-solar"] .message.own .message-body { border-radius:5px!important; box-shadow:3px 3px 0 rgba(0,0,0,.3)!important; }
html[data-theme-variant="jimmyqrg-solar"] .composer-input-wrap { border-radius:5px; border-color:#705020; }
html[data-theme-variant="jimmyqrg-solar"] .settings-tabs a.active,
html[data-theme-variant="jimmyqrg-solar"] .settings-tabs button.active { border-bottom-width:3px; }
html[data-theme-variant="jimmyqrg-verdant"] .chat-main { background:linear-gradient(140deg,rgba(31,93,65,.12),transparent 42%); }
html[data-theme-variant="jimmyqrg-verdant"] .left-bar { border-radius:16px 0 0 16px; margin:8px 0 8px 8px; height:calc(100% - 16px); }
html[data-theme-variant="jimmyqrg-verdant"] .left-bar-item { border-radius:999px; }
html[data-theme-variant="jimmyqrg-verdant"] .left-bar-item.active { box-shadow:inset 0 0 0 1px #38c98c,0 6px 18px rgba(56,201,140,.1); }
html[data-theme-variant="jimmyqrg-verdant"] .chat-header { background:rgba(16,31,23,.8); border-bottom-color:#2b4938; }
html[data-theme-variant="jimmyqrg-verdant"] .message-body,
html[data-theme-variant="jimmyqrg-verdant"] .message.own .message-body { border-radius:16px 16px 16px 4px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .message.own .message-body { border-radius:16px 16px 4px 16px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .composer { background:rgba(16,31,23,.92); border-top-color:#2b4938; }

/* Make selectors, menus, and overlays follow each selected surface palette. */
html[data-theme-variant="study-library"] .context-menu,
html[data-theme-variant="study-library"] .modal { border-radius:3px; box-shadow:0 14px 36px rgba(61,48,46,.14); }
html[data-theme-variant="study-lab"] .context-menu,
html[data-theme-variant="study-lab"] .modal { border-radius:3px; box-shadow:none; }
html[data-theme-variant="study-notebook"] .context-menu,
html[data-theme-variant="study-notebook"] .modal { border-radius:4px 12px 4px 12px; }
html[data-theme-variant="study-campus"] .context-menu,
html[data-theme-variant="study-campus"] .modal { border-radius:12px 3px 12px 3px; }
html[data-theme-variant="study-graphite"] .context-menu,
html[data-theme-variant="study-graphite"] .modal { border-radius:2px; box-shadow:0 4px 18px rgba(48,54,51,.12); }
html[data-theme-variant="jimmyqrg-solar"] .context-menu,
html[data-theme-variant="jimmyqrg-solar"] .modal { border-radius:5px; border-width:2px; }
html[data-theme-variant="jimmyqrg-verdant"] .context-menu,
html[data-theme-variant="jimmyqrg-verdant"] .modal { border-radius:18px 5px 18px 5px; }
@media (max-width:600px) {
  .theme-picker,.theme-gate-picker { grid-template-columns:1fr; }
  .theme-family-option { min-height:100px; grid-template-columns:50px minmax(0,1fr) auto; gap:.65rem; padding:.8rem; }
  .theme-style-grid { grid-template-columns:1fr; }
  .theme-style-dialog { max-height:92dvh; padding:1rem; }
  .theme-style-grid .theme-picker-item { min-height:98px; }
}


/* Full component treatments for each non-Classic chat preset. */
html[data-theme-variant^="study"] .app-shell-inner,
html[data-theme-variant^="study"] .chat-area,
html[data-theme-variant^="study"] .chat-main,
html[data-theme-variant^="study"] .panel-column-content,
html[data-theme-variant^="study"] .chat-side-panel,
html[data-theme-variant^="study"] .settings-page,
html[data-theme-variant^="study"] .admin-section,
html[data-theme-variant^="study"] .list-pane,
html[data-theme-variant^="study"] .conversation-list,
html[data-theme-variant^="study"] .inbox-list,
html[data-theme-variant^="study"] .friends-list,
html[data-theme-variant^="study"] .collection-list {
  color:var(--text) !important; background-color:var(--bg-main) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .chat-header,
html[data-theme-variant^="study"] .settings-section,
html[data-theme-variant^="study"] .settings-tabs,
html[data-theme-variant^="study"] .panel-list-title,
html[data-theme-variant^="study"] .list-section-header,
html[data-theme-variant^="study"] .admin-section-title,
html[data-theme-variant^="study"] .composer,
html[data-theme-variant^="study"] .context-menu,
html[data-theme-variant^="study"] .modal,
html[data-theme-variant^="study"] .profile-modal,
html[data-theme-variant^="study"] .premium-modal-card {
  color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .settings-page h2,
html[data-theme-variant^="study"] .settings-section-title,
html[data-theme-variant^="study"] .panel-list-title,
html[data-theme-variant^="study"] .list-section-header { color:var(--text) !important; }
html[data-theme-variant^="study"] .settings-page p,
html[data-theme-variant^="study"] .settings-account-desc,
html[data-theme-variant^="study"] .settings-help,
html[data-theme-variant^="study"] .chat-header-subtitle,
html[data-theme-variant^="study"] .panel-empty,
html[data-theme-variant^="study"] .empty-state,
html[data-theme-variant^="study"] .message-timestamp { color:var(--text-dim) !important; }
html[data-theme-variant^="study"] .settings-page input,
html[data-theme-variant^="study"] .settings-page select,
html[data-theme-variant^="study"] .settings-page textarea,
html[data-theme-variant^="study"] .modal input,
html[data-theme-variant^="study"] .modal select,
html[data-theme-variant^="study"] .modal textarea,
html[data-theme-variant^="study"] .context-menu,
html[data-theme-variant^="study"] .composer-input-wrap {
  color:var(--text) !important; background-color:var(--bg-main) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .settings-page input::placeholder,
html[data-theme-variant^="study"] .settings-page textarea::placeholder,
html[data-theme-variant^="study"] .modal input::placeholder,
html[data-theme-variant^="study"] .composer-input::placeholder { color:var(--text-muted) !important; opacity:1 !important; }
html[data-theme-variant^="study"] .settings-tabs button.active,
html[data-theme-variant^="study"] .settings-tabs a.active,
html[data-theme-variant^="study"] .chat-header-menu-btn:hover,
html[data-theme-variant^="study"] .composer-actions button:hover,
html[data-theme-variant^="study"] .context-menu button:hover { color:var(--text) !important; background:var(--bg-hover) !important; }
html[data-theme-variant^="study"] .settings-page .btn-primary,
html[data-theme-variant^="study"] .settings-page button.primary,
html[data-theme-variant^="study"] .modal .btn-primary,
html[data-theme-variant^="study"] .composer-send { color:#fff !important; background:var(--text) !important; border-color:var(--text) !important; box-shadow:none !important; }
html[data-theme-variant^="study"] .left-bar { border-right:1px solid var(--border) !important; box-shadow:none !important; }
html[data-theme-variant^="study"] .left-bar-item { color:var(--text-dim) !important; background:transparent !important; }
html[data-theme-variant^="study"] .left-bar-item.active { color:var(--text) !important; background:var(--bg-hover) !important; box-shadow:inset 3px 0 var(--purple) !important; }
html[data-theme-variant^="study"] .message-row { border-bottom:1px solid var(--border) !important; }
html[data-theme-variant^="study"] .message-sender,
html[data-theme-variant^="study"] .message-sender-name { color:var(--text) !important; }
html[data-theme-variant^="study"] .message-body,
html[data-theme-variant^="study"] .message.own .message-body { color:var(--text) !important; }
html[data-theme-variant^="study"] .context-menu button { color:var(--text) !important; }
html[data-theme-variant^="study"] .toast,
html[data-theme-variant^="study"] .toast-item,
html[data-theme-variant^="study"] .notification-item { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }

/* Reading Room: a centered, book-like discussion page with ruled quotations. */
html[data-theme-variant="study-library"] .app-shell-inner { background:linear-gradient(90deg,rgba(117,68,81,.07),transparent 20%,transparent 80%,rgba(117,68,81,.05)); }
html[data-theme-variant="study-library"] .chat-area { justify-content:center; }
html[data-theme-variant="study-library"] .chat-main { max-width:1100px; border-inline:1px solid var(--border); }
html[data-theme-variant="study-library"] .chat-header,
html[data-theme-variant="study-library"] .settings-section-title,
html[data-theme-variant="study-library"] .message-sender { font-family:"Palatino Linotype",Georgia,serif !important; }
html[data-theme-variant="study-library"] .message-row { padding:.65rem 1rem; margin:0 auto .5rem; max-width:76ch; }
html[data-theme-variant="study-library"] .message-body,
html[data-theme-variant="study-library"] .message.own .message-body { border-left:3px solid var(--accent)!important; border-radius:2px!important; box-shadow:none!important; }
html[data-theme-variant="study-library"] .left-bar { background:#e8ddcd !important; border-right:3px double var(--border) !important; }
html[data-theme-variant="study-library"] .left-bar-item.active { border-radius:2px!important; box-shadow:inset 3px 0 var(--purple)!important; }
html[data-theme-variant="study-library"] .composer { border-top:3px double var(--border)!important; }
html[data-theme-variant="study-library"] .composer-input-wrap,
html[data-theme-variant="study-library"] .settings-page input,
html[data-theme-variant="study-library"] .settings-page select { border-radius:3px!important; border-bottom:2px solid var(--purple)!important; }
html[data-theme-variant="study-library"] .modal,
html[data-theme-variant="study-library"] .context-menu { border-radius:3px!important; box-shadow:0 12px 30px rgba(61,48,46,.15)!important; }

/* Field Notes: a top tool strip and a workspace of field-note entries. */
@media (min-aspect-ratio:1/1) {
  html[data-theme-variant="study-campus"] .app-shell { flex-direction:column; }
  html[data-theme-variant="study-campus"] .left-bar,
  html[data-theme-variant="study-campus"] .left-bar.left-bar-expanded { order:0; width:100%; height:54px; min-height:54px; flex-direction:row; border:0; border-bottom:1px solid var(--border); background:#dfe9dd; }
  html[data-theme-variant="study-campus"] .left-bar-avatar,
  html[data-theme-variant="study-campus"] .left-bar-bottom,
  html[data-theme-variant="study-campus"] .left-bar-expand { display:none!important; }
  html[data-theme-variant="study-campus"] .left-bar-nav,
  html[data-theme-variant="study-campus"] .left-bar-expanded .left-bar-nav { width:100%; height:100%; flex-direction:row; justify-content:flex-start; align-items:center; gap:.4rem; padding:0 .8rem; }
  html[data-theme-variant="study-campus"] .left-bar-item,
  html[data-theme-variant="study-campus"] .left-bar-expanded .left-bar-item { width:auto; height:40px; padding:.4rem .7rem; border-radius:10px!important; }
  html[data-theme-variant="study-campus"] .left-bar-label { display:inline!important; }
  html[data-theme-variant="study-campus"] .left-bar-item.active { background:#c5d8c4!important; color:#29372d!important; box-shadow:inset 0 -2px #38664a!important; }
}
html[data-theme-variant="study-campus"] .chat-header { border-bottom:2px solid var(--border)!important; }
html[data-theme-variant="study-campus"] .messages-wrap { background:radial-gradient(ellipse at 92% 4%,rgba(56,102,74,.09),transparent 35%),var(--bg-main)!important; }
html[data-theme-variant="study-campus"] .message-row { margin:.3rem 1rem .7rem; padding:.55rem .75rem; border:1px solid var(--border)!important; border-left:3px solid var(--accent)!important; border-radius:10px 3px 10px 3px!important; background:rgba(255,255,255,.34); }
html[data-theme-variant="study-campus"] .message-body,
html[data-theme-variant="study-campus"] .message.own .message-body { border:0!important; box-shadow:none!important; background:transparent!important; }
html[data-theme-variant="study-campus"] .composer-input-wrap,
html[data-theme-variant="study-campus"] .settings-page input,
html[data-theme-variant="study-campus"] .settings-page select { border-radius:14px 4px 14px 4px!important; }
html[data-theme-variant="study-campus"] .modal,
html[data-theme-variant="study-campus"] .context-menu { border-radius:16px 4px 16px 4px!important; }

/* Lab Bench: dense console panels, grid paper, and technical controls. */
html[data-theme-variant="study-lab"] { --font-family:ui-monospace,"SFMono-Regular",Consolas,monospace; }
html[data-theme-variant="study-lab"] .app-shell-inner { background-image:linear-gradient(rgba(53,101,132,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(53,101,132,.035) 1px,transparent 1px); background-size:24px 24px; }
html[data-theme-variant="study-lab"] .chat-header { background:#e7eff4!important; border-bottom:2px solid #9bb2c1!important; }
html[data-theme-variant="study-lab"] .chat-header-title::before { content:"// "; color:var(--purple); }
html[data-theme-variant="study-lab"] .left-bar { background:#dfe8ef!important; border-right:2px solid #9bb2c1!important; }
html[data-theme-variant="study-lab"] .left-bar-item.active { color:#fff!important; background:#356584!important; border-radius:2px!important; box-shadow:none!important; }
html[data-theme-variant="study-lab"] .message-row { padding:.3rem .45rem; border-bottom:1px dashed var(--border)!important; }
html[data-theme-variant="study-lab"] .message-body,
html[data-theme-variant="study-lab"] .message.own .message-body { border-radius:2px!important; box-shadow:none!important; }
html[data-theme-variant="study-lab"] .composer-input-wrap,
html[data-theme-variant="study-lab"] .settings-page input,
html[data-theme-variant="study-lab"] .settings-page select,
html[data-theme-variant="study-lab"] .modal { border-radius:2px!important; border-width:2px!important; }
html[data-theme-variant="study-lab"] .left-bar-item,
html[data-theme-variant="study-lab"] .composer-actions button,
html[data-theme-variant="study-lab"] .context-menu button { font-family:var(--font-family)!important; }

/* Notebook: warm sheet, ruled thread, tabs, and paper-like dialogs. */
html[data-theme-variant="study-notebook"] .app-shell-inner { background-image:repeating-linear-gradient(180deg,transparent 0 31px,rgba(83,111,156,.075) 32px 33px); }
html[data-theme-variant="study-notebook"] .left-bar { background:#e9dfca!important; border-top:1px solid #cbbd9f!important; }
html[data-theme-variant="study-notebook"] .left-bar-nav { gap:4px!important; }
html[data-theme-variant="study-notebook"] .left-bar-item { border-radius:7px 7px 2px 2px!important; }
html[data-theme-variant="study-notebook"] .left-bar-item.active { background:#fffaf0!important; border-bottom:3px solid #4e6c9b!important; box-shadow:none!important; }
html[data-theme-variant="study-notebook"] .chat-header { background:#fffaf0!important; border-bottom:1px dashed #c6b99e!important; }
html[data-theme-variant="study-notebook"] .messages-wrap { padding-inline:clamp(1rem,4vw,3rem); }
html[data-theme-variant="study-notebook"] .message-row { margin-left:clamp(.2rem,2vw,1.8rem); padding:.4rem .7rem .55rem 1rem; border-left:2px solid rgba(155,102,73,.45)!important; }
html[data-theme-variant="study-notebook"] .message-body,
html[data-theme-variant="study-notebook"] .message.own .message-body { background:rgba(255,250,240,.82)!important; border:1px solid rgba(216,205,180,.8)!important; box-shadow:2px 3px 0 rgba(87,98,119,.08)!important; }
html[data-theme-variant="study-notebook"] .composer,
html[data-theme-variant="study-notebook"] .composer-input-wrap { background:#fffaf0!important; }
html[data-theme-variant="study-notebook"] .modal,
html[data-theme-variant="study-notebook"] .context-menu { border-radius:4px 14px 4px 14px!important; box-shadow:3px 5px 15px rgba(52,51,46,.12)!important; }

/* Graphite: right-side index rail and flat editorial thread. */
@media (min-aspect-ratio:1/1) {
  html[data-theme-variant="study-graphite"] .app-shell { flex-direction:row-reverse; }
  html[data-theme-variant="study-graphite"] .left-bar { border-right:0!important; border-left:1px solid #c5c8c1!important; background:#dedfda!important; }
  html[data-theme-variant="study-graphite"] .left-bar-item.active { color:#fff!important; background:#575f5b!important; box-shadow:inset -3px 0 #a06f48!important; }
}
html[data-theme-variant="study-graphite"] .app-shell-inner { background:#ecece7!important; }
html[data-theme-variant="study-graphite"] .chat-header { background:#dedfda!important; border-bottom:1px solid #c5c8c1!important; }
html[data-theme-variant="study-graphite"] .message-row { border-bottom:1px solid #d4d6d0!important; padding:.5rem 0; }
html[data-theme-variant="study-graphite"] .message-body,
html[data-theme-variant="study-graphite"] .message.own .message-body { border-radius:2px!important; box-shadow:none!important; background:transparent!important; }
html[data-theme-variant="study-graphite"] .composer-input-wrap,
html[data-theme-variant="study-graphite"] .settings-page input,
html[data-theme-variant="study-graphite"] .settings-page select,
html[data-theme-variant="study-graphite"] .modal { border-radius:2px!important; box-shadow:0 3px 10px rgba(48,54,51,.08)!important; }
html[data-theme-variant="study-graphite"] .context-menu { border-radius:0!important; box-shadow:0 4px 16px rgba(48,54,51,.12)!important; }

/* Solar Cabinet: bottom dock with reserved height and machine-panel controls. */
html[data-theme-variant="jimmyqrg-solar"] .chat-header { background:#20170d!important; border-bottom:2px solid #65491e!important; }
html[data-theme-variant="jimmyqrg-solar"] .left-bar-item { border-radius:4px!important; }
html[data-theme-variant="jimmyqrg-solar"] .left-bar-item.active { background:#3b2a12!important; box-shadow:inset 0 -3px #efa82b!important; }
html[data-theme-variant="jimmyqrg-solar"] .message-row { margin-bottom:.8rem; }
html[data-theme-variant="jimmyqrg-solar"] .message-body,
html[data-theme-variant="jimmyqrg-solar"] .message.own .message-body { border-radius:5px!important; box-shadow:3px 3px 0 rgba(0,0,0,.3)!important; }
html[data-theme-variant="jimmyqrg-solar"] .composer-input-wrap,
html[data-theme-variant="jimmyqrg-solar"] .settings-page input,
html[data-theme-variant="jimmyqrg-solar"] .settings-page select,
html[data-theme-variant="jimmyqrg-solar"] .context-menu,
html[data-theme-variant="jimmyqrg-solar"] .modal { border-radius:5px!important; border-width:2px!important; }
html[data-theme-variant="jimmyqrg-solar"] .settings-tabs a.active,
html[data-theme-variant="jimmyqrg-solar"] .settings-tabs button.active { border-bottom-width:3px; }
html[data-theme-variant="jimmyqrg-solar"] .composer-send { color:#1b130b!important; }

/* Emerald Circuit: right command rail, glass panels, and asymmetric bubbles. */
html[data-theme-variant="jimmyqrg-verdant"] .chat-main { background:linear-gradient(140deg,rgba(31,93,65,.12),transparent 42%); }
html[data-theme-variant="jimmyqrg-verdant"] .left-bar { border-radius:16px 0 0 16px; margin:8px 0 8px 8px; height:calc(100% - 16px); }
html[data-theme-variant="jimmyqrg-verdant"] .left-bar-item { border-radius:999px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .left-bar-item.active { box-shadow:inset 0 0 0 1px #38c98c,0 6px 18px rgba(56,201,140,.1)!important; }
html[data-theme-variant="jimmyqrg-verdant"] .chat-header { background:rgba(16,31,23,.88)!important; border-bottom-color:#2b4938!important; }
html[data-theme-variant="jimmyqrg-verdant"] .message-body,
html[data-theme-variant="jimmyqrg-verdant"] .message.own .message-body { border-radius:16px 16px 16px 4px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .message.own .message-body { border-radius:16px 16px 4px 16px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .composer { background:rgba(16,31,23,.94)!important; border-top-color:#2b4938!important; }
html[data-theme-variant="jimmyqrg-verdant"] .composer-input-wrap,
html[data-theme-variant="jimmyqrg-verdant"] .settings-page input,
html[data-theme-variant="jimmyqrg-verdant"] .settings-page select { border-radius:18px 5px 18px 5px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .context-menu,
html[data-theme-variant="jimmyqrg-verdant"] .modal { border-radius:18px 5px 18px 5px!important; }
html[data-theme-variant="jimmyqrg-verdant"] .message-row { border-left:2px solid rgba(56,201,140,.24); padding-left:.45rem; }

@media (max-width:600px) {
  html[data-theme-variant="study-campus"] .left-bar { overflow-x:auto; }
  html[data-theme-variant="study-campus"] .left-bar-item,
  html[data-theme-variant="study-campus"] .left-bar-expanded .left-bar-item { flex:0 0 auto; }
  html[data-theme-variant="jimmyqrg-verdant"] .left-bar { margin:0; height:auto; border-radius:0; }
}

/* Extend non-Classic themes to admin, account, picker, and utility surfaces. */
html[data-theme-variant^="study"] .main-content,
html[data-theme-variant^="study"] .main-content-body,
html[data-theme-variant^="study"] .main-content-header,
html[data-theme-variant^="study"] .panel-column,
html[data-theme-variant^="study"] .admin-main,
html[data-theme-variant^="study"] .admin-nav,
html[data-theme-variant^="study"] .admin-panel,
html[data-theme-variant^="study"] .profile-view-body {
  color:var(--text) !important; background-color:var(--bg-main) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .panel-column,
html[data-theme-variant^="study"] .admin-nav,
html[data-theme-variant^="study"] .chat-side-panel { background-color:var(--bg-panel) !important; }
html[data-theme-variant^="study"] .main-content-header,
html[data-theme-variant^="study"] .panel-list-header,
html[data-theme-variant^="study"] .chat-side-panel-header { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }
html[data-theme-variant^="study"] .panel-list-link,
html[data-theme-variant^="study"] .panel-tab,
html[data-theme-variant^="study"] .admin-nav-item,
html[data-theme-variant^="study"] .chat-side-panel-tab { color:var(--text-dim) !important; }
html[data-theme-variant^="study"] .panel-list-link:hover,
html[data-theme-variant^="study"] .panel-list-link.active,
html[data-theme-variant^="study"] .panel-tab:hover,
html[data-theme-variant^="study"] .panel-tab.active,
html[data-theme-variant^="study"] .admin-nav-item:hover,
html[data-theme-variant^="study"] .admin-nav-item.active,
html[data-theme-variant^="study"] .chat-side-panel-tab.active { color:var(--text) !important; background:var(--bg-hover) !important; }
html[data-theme-variant^="study"] .admin-section,
html[data-theme-variant^="study"] .admin-user-card,
html[data-theme-variant^="study"] .admin-audit-item,
html[data-theme-variant^="study"] .admin-timeout-item,
html[data-theme-variant^="study"] .admin-recalled-item,
html[data-theme-variant^="study"] .admin-user-picker-panel,
html[data-theme-variant^="study"] .admin-user-picker-trigger,
html[data-theme-variant^="study"] .settings-account-block,
html[data-theme-variant^="study"] .notif-permission-modal,
html[data-theme-variant^="study"] .wordle-modal,
html[data-theme-variant^="study"] .dm-voice-modal,
html[data-theme-variant^="study"] .vc-screen-menu {
  color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .admin-section-title,
html[data-theme-variant^="study"] .admin-user-name,
html[data-theme-variant^="study"] .settings-account-block h3,
html[data-theme-variant^="study"] .profile-modal-name,
html[data-theme-variant^="study"] .dm-voice-modal-name,
html[data-theme-variant^="study"] .notif-permission-title { color:var(--text) !important; }
html[data-theme-variant^="study"] .admin-section-desc,
html[data-theme-variant^="study"] .admin-user-handle,
html[data-theme-variant^="study"] .admin-user-email,
html[data-theme-variant^="study"] .profile-modal-username,
html[data-theme-variant^="study"] .profile-modal-description,
html[data-theme-variant^="study"] .dm-voice-modal-sub,
html[data-theme-variant^="study"] .notif-permission-desc { color:var(--text-dim) !important; }
html[data-theme-variant^="study"] .admin-form input,
html[data-theme-variant^="study"] .admin-form textarea,
html[data-theme-variant^="study"] .admin-form select,
html[data-theme-variant^="study"] .admin-user-search,
html[data-theme-variant^="study"] .admin-user-picker-search-input,
html[data-theme-variant^="study"] .admin-duration-custom-num,
html[data-theme-variant^="study"] .admin-duration-custom-unit,
html[data-theme-variant^="study"] .panel-search-bar input,
html[data-theme-variant^="study"] .chat-users-search input,
html[data-theme-variant^="study"] .dnd-modal-inputs input {
  color:var(--text) !important; background:var(--bg-main) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .admin-user-picker-item,
html[data-theme-variant^="study"] .admin-duration-chip,
html[data-theme-variant^="study"] .admin-timeout-scope-option,
html[data-theme-variant^="study"] .context-menu button,
html[data-theme-variant^="study"] .modal-actions button,
html[data-theme-variant^="study"] .profile-modal-actions button {
  color:var(--text) !important; border-color:var(--border) !important;
}
html[data-theme-variant^="study"] .admin-user-picker-item:hover,
html[data-theme-variant^="study"] .admin-user-picker-item.active,
html[data-theme-variant^="study"] .admin-duration-chip:hover,
html[data-theme-variant^="study"] .admin-duration-chip.active,
html[data-theme-variant^="study"] .admin-timeout-scope-option:hover,
html[data-theme-variant^="study"] .context-menu button:hover { background:var(--bg-hover) !important; }
html[data-theme-variant^="study"] .support-helper-tip,
html[data-theme-variant^="study"] .venory-persona-switch { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }
html[data-theme-variant^="study"] .support-helper-tip-close,
html[data-theme-variant^="study"] .venory-persona-caption { color:var(--text-dim) !important; }
html[data-theme-variant^="study"] .wordle-modal-close,
html[data-theme-variant^="study"] .profile-modal-close,
html[data-theme-variant^="study"] .dm-voice-modal-btn { color:var(--text) !important; background:var(--bg-hover) !important; border-color:var(--border) !important; }
html[data-theme-variant^="study"] .theme-style-dialog { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }

/* Each non-Classic preset carries its structure into secondary pages. */
html[data-theme-variant="study-library"] .main-content-header,
html[data-theme-variant="study-library"] .panel-list-title,
html[data-theme-variant="study-library"] .admin-section-title,
html[data-theme-variant="study-library"] .settings-page h2,
html[data-theme-variant="study-library"] .settings-section-title { font-family:"Palatino Linotype",Georgia,serif !important; }
html[data-theme-variant="study-library"] .admin-section,
html[data-theme-variant="study-library"] .admin-user-card,
html[data-theme-variant="study-library"] .admin-recalled-item,
html[data-theme-variant="study-library"] .settings-account-block { border-left:3px double var(--accent) !important; border-radius:2px !important; box-shadow:none !important; }
html[data-theme-variant="study-library"] .settings-tabs a.active,
html[data-theme-variant="study-library"] .settings-tabs button.active { border-bottom:2px double var(--purple) !important; }

html[data-theme-variant="study-campus"] .main-content-header,
html[data-theme-variant="study-campus"] .panel-column,
html[data-theme-variant="study-campus"] .admin-nav { border-bottom:2px solid var(--border) !important; }
html[data-theme-variant="study-campus"] .admin-section,
html[data-theme-variant="study-campus"] .admin-user-card,
html[data-theme-variant="study-campus"] .admin-recalled-item,
html[data-theme-variant="study-campus"] .settings-account-block { border-radius:14px 4px 14px 4px !important; box-shadow:0 3px 10px rgba(43,81,59,.07) !important; }
html[data-theme-variant="study-campus"] .panel-list-link.active,
html[data-theme-variant="study-campus"] .admin-nav-item.active { border-radius:12px 3px 12px 3px !important; box-shadow:inset 0 -2px var(--purple) !important; }

html[data-theme-variant="study-lab"] .main-content-header,
html[data-theme-variant="study-lab"] .panel-list-title,
html[data-theme-variant="study-lab"] .admin-section-title,
html[data-theme-variant="study-lab"] .settings-page h2,
html[data-theme-variant="study-lab"] .settings-section-title,
html[data-theme-variant="study-lab"] .admin-nav-item,
html[data-theme-variant="study-lab"] .panel-tab { font-family:ui-monospace,"SFMono-Regular",Consolas,monospace !important; letter-spacing:.04em; }
html[data-theme-variant="study-lab"] .admin-section,
html[data-theme-variant="study-lab"] .admin-user-card,
html[data-theme-variant="study-lab"] .admin-audit-item,
html[data-theme-variant="study-lab"] .admin-recalled-item,
html[data-theme-variant="study-lab"] .settings-account-block { border-radius:2px !important; box-shadow:none !important; }
html[data-theme-variant="study-lab"] .panel-list-link.active,
html[data-theme-variant="study-lab"] .panel-tab.active,
html[data-theme-variant="study-lab"] .admin-nav-item.active { outline:1px dashed var(--purple); outline-offset:-3px; }
html[data-theme-variant="study-lab"] .admin-panel,
html[data-theme-variant="study-lab"] .settings-page { background-image:linear-gradient(rgba(53,101,132,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(53,101,132,.035) 1px,transparent 1px); background-size:24px 24px; }

html[data-theme-variant="study-notebook"] .main-content-header,
html[data-theme-variant="study-notebook"] .panel-list-title,
html[data-theme-variant="study-notebook"] .admin-section-title,
html[data-theme-variant="study-notebook"] .settings-page h2,
html[data-theme-variant="study-notebook"] .settings-section-title { font-family:"Trebuchet MS",system-ui,sans-serif !important; }
html[data-theme-variant="study-notebook"] .admin-section,
html[data-theme-variant="study-notebook"] .admin-user-card,
html[data-theme-variant="study-notebook"] .admin-recalled-item,
html[data-theme-variant="study-notebook"] .settings-account-block { border-radius:4px 12px 4px 12px !important; box-shadow:2px 3px 0 rgba(87,98,119,.07) !important; }
html[data-theme-variant="study-notebook"] .panel-list-link.active,
html[data-theme-variant="study-notebook"] .panel-tab.active,
html[data-theme-variant="study-notebook"] .admin-nav-item.active { border-bottom:2px solid #4e6c9b !important; }
html[data-theme-variant="study-notebook"] .admin-main,
html[data-theme-variant="study-notebook"] .settings-page { background-image:repeating-linear-gradient(180deg,transparent 0 31px,rgba(83,111,156,.055) 32px 33px); }

html[data-theme-variant="study-graphite"] .main-content-header,
html[data-theme-variant="study-graphite"] .panel-column,
html[data-theme-variant="study-graphite"] .admin-nav { border-color:#c5c8c1 !important; }
html[data-theme-variant="study-graphite"] .admin-section,
html[data-theme-variant="study-graphite"] .admin-user-card,
html[data-theme-variant="study-graphite"] .admin-audit-item,
html[data-theme-variant="study-graphite"] .admin-recalled-item,
html[data-theme-variant="study-graphite"] .settings-account-block { border-radius:0 !important; box-shadow:none !important; border-inline:0 !important; border-top:0 !important; border-bottom:1px solid #c5c8c1 !important; }
html[data-theme-variant="study-graphite"] .settings-tabs a,
html[data-theme-variant="study-graphite"] .settings-tabs button { border-radius:0 !important; }
html[data-theme-variant="study-graphite"] .panel-list-link.active,
html[data-theme-variant="study-graphite"] .panel-tab.active,
html[data-theme-variant="study-graphite"] .admin-nav-item.active { box-shadow:inset -3px 0 #a06f48 !important; }

html[data-theme-variant="jimmyqrg-solar"] .main-content-header,
html[data-theme-variant="jimmyqrg-solar"] .panel-column,
html[data-theme-variant="jimmyqrg-solar"] .admin-nav,
html[data-theme-variant="jimmyqrg-solar"] .chat-side-panel { background:#21190f !important; border-color:#4b3920 !important; }
html[data-theme-variant="jimmyqrg-solar"] .admin-section,
html[data-theme-variant="jimmyqrg-solar"] .admin-user-card,
html[data-theme-variant="jimmyqrg-solar"] .admin-audit-item,
html[data-theme-variant="jimmyqrg-solar"] .admin-recalled-item,
html[data-theme-variant="jimmyqrg-solar"] .settings-account-block { border-radius:4px !important; border-width:2px !important; box-shadow:3px 3px 0 rgba(0,0,0,.24) !important; }
html[data-theme-variant="jimmyqrg-solar"] .panel-list-link.active,
html[data-theme-variant="jimmyqrg-solar"] .panel-tab.active,
html[data-theme-variant="jimmyqrg-solar"] .admin-nav-item.active { color:#f4bd54 !important; box-shadow:inset 0 -3px #efa82b !important; }
html[data-theme-variant="jimmyqrg-solar"] .admin-section-title,
html[data-theme-variant="jimmyqrg-solar"] .settings-section-title { text-transform:uppercase; letter-spacing:.08em; }

html[data-theme-variant="jimmyqrg-verdant"] .main-content-header,
html[data-theme-variant="jimmyqrg-verdant"] .panel-column,
html[data-theme-variant="jimmyqrg-verdant"] .admin-nav,
html[data-theme-variant="jimmyqrg-verdant"] .chat-side-panel { background:#101f17 !important; border-color:#2b4938 !important; }
html[data-theme-variant="jimmyqrg-verdant"] .admin-section,
html[data-theme-variant="jimmyqrg-verdant"] .admin-user-card,
html[data-theme-variant="jimmyqrg-verdant"] .admin-audit-item,
html[data-theme-variant="jimmyqrg-verdant"] .admin-recalled-item,
html[data-theme-variant="jimmyqrg-verdant"] .settings-account-block { border-radius:18px 5px 18px 5px !important; box-shadow:0 8px 22px rgba(0,0,0,.16) !important; }
html[data-theme-variant="jimmyqrg-verdant"] .panel-list-link.active,
html[data-theme-variant="jimmyqrg-verdant"] .panel-tab.active,
html[data-theme-variant="jimmyqrg-verdant"] .admin-nav-item.active { color:#69e3ab !important; background:rgba(56,201,140,.12) !important; }
html[data-theme-variant="jimmyqrg-verdant"] .admin-section-title,
html[data-theme-variant="jimmyqrg-verdant"] .settings-section-title { border-bottom:1px solid rgba(56,201,140,.2); padding-bottom:.55rem; }

/* Dialog controls and floating menus inherit their family's tokens. */
html[data-theme-variant^="study"] .notif-permission-actions button,
html[data-theme-variant^="study"] .dm-voice-modal-actions button,
html[data-theme-variant^="study"] .admin-delete-modal-actions button { border-color:var(--border) !important; }
html[data-theme-variant^="study"] .notif-permission-actions .btn-primary,
html[data-theme-variant^="study"] .dm-voice-modal-accept { color:#fff !important; background:var(--purple) !important; border-color:var(--purple) !important; }
html[data-theme-variant^="study"] .dm-voice-modal-decline,
html[data-theme-variant^="study"] .notif-permission-actions .btn-secondary { color:var(--text) !important; background:var(--bg-hover) !important; }
html[data-theme-variant^="study"] .media-popup-close,
html[data-theme-variant^="study"] .media-popup-fullscreen,
html[data-theme-variant^="study"] .media-popup-controls-row button,
html[data-theme-variant^="study"] .media-popup-controls-row a { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }
html[data-theme-variant^="study"] .media-popup-status { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }
html[data-theme-variant^="study"] .mobile-nav-more-menu,
html[data-theme-variant^="study"] .hc-session-menu,
html[data-theme-variant^="study"] .admin-user-picker-panel { color:var(--text) !important; background:var(--bg-panel) !important; border-color:var(--border) !important; }
html[data-theme-variant^="study"] .mobile-nav-more-link,
html[data-theme-variant^="study"] .hc-session-menu button { color:var(--text) !important; background:transparent !important; }
html[data-theme-variant^="study"] .mobile-nav-more-link:hover,
html[data-theme-variant^="study"] .hc-session-menu button:hover { background:var(--bg-hover) !important; }

/* ── Collapsible <details> disclosures inside messages ──────────────────────
   Messages can wrap optional depth in <details><summary>Label</summary>…
   </details>; the client renders a real disclosure instead of raw tags.
   Colours use a mid-grey alpha so they read on both light and dark themes,
   and the Study theme's global square/flat pass overrides the radius. */
.chat-details {
  margin: 8px 0;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.07);
  overflow: hidden;
}
.chat-details-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.94em;
  list-style: none;
  user-select: none;
}
.chat-details-summary::-webkit-details-marker { display: none; }
.chat-details-summary::marker { content: ''; }
.chat-details-label { flex: 1 1 auto; min-width: 0; }
.chat-details-caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.6;
  transition: transform 0.15s ease;
}
.chat-details[open] .chat-details-caret { transform: rotate(180deg); }
.chat-details-body {
  padding: 2px 12px 10px;
  border-top: 1px solid rgba(127, 127, 127, 0.28);
}
.chat-details-body > :first-child { margin-top: 8px; }
.chat-details-body > :last-child { margin-bottom: 0; }

/* Owner directive controls are visible only to the authenticated owner in group channels. */
.owner-directive-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, #e8bd67 38%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, #e8bd67 7%, var(--bg-panel));
}
.owner-directive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
  cursor: pointer;
  font: inherit;
}
.owner-directive-toggle.is-active {
  color: #211a0d;
  border-color: #e8bd67;
  background: #e8bd67;
}
.owner-directive-state {
  font-size: .8em;
  font-weight: 700;
  opacity: .85;
}
.owner-directive-help {
  flex: 1 1 260px;
  color: var(--text-muted);
  font-size: .82em;
  line-height: 1.35;
}
.message-owner-directive-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  padding: 2px 6px;
  color: #211a0d;
  border-radius: 5px;
  background: #e8bd67;
  font-size: .66em;
  font-weight: 800;
  letter-spacing: .035em;
  vertical-align: middle;
}
.message-row-owner-directive .message-body:not(.message-body-svg) {
  border-color: color-mix(in srgb, #e8bd67 60%, var(--border));
  background: color-mix(in srgb, #e8bd67 8%, var(--bg-panel));
  box-shadow: 0 0 0 1px color-mix(in srgb, #e8bd67 15%, transparent);
}

/* Media controls: consistent stroke icons, readable actions, and touch-sized targets. */
.message-file-video {
  width: min(320px, 78vw);
  height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.message-file-video .message-file-video-thumb { object-fit: cover; }
.message-file-video .message-file-video-play {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(12, 10, 18, 0.72);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}
.message-file-video-play .icon { width: 26px; height: 26px; }
.message-file-video:hover .message-file-video-play { background: rgba(12, 10, 18, 0.88); }
.message-file-image {
  max-width: min(320px, 78vw);
  max-height: 320px;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.message-file-image .message-file-image-img { max-height: 320px; object-fit: contain; }
.message-file-download,
.message-file-audio-download,
.media-popup-download,
.media-popup-close,
.media-popup-fullscreen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: rgba(12, 10, 18, 0.76);
  color: #fff;
  text-decoration: none;
  opacity: 1;
  -webkit-tap-highlight-color: transparent;
}
.message-file-download .icon,
.message-file-audio-download .icon,
.media-popup-download .icon,
.media-popup-close .icon,
.media-popup-fullscreen .icon { width: 20px; height: 20px; }
.message-file-video .message-file-download,
.message-file-image .message-file-download {
  top: 8px;
  right: 8px;
  opacity: 1;
  transition: transform 0.16s ease, background 0.16s ease;
}
.message-file-video .message-file-download:hover,
.message-file-image .message-file-download:hover,
.media-popup-download:hover,
.media-popup-close:hover,
.media-popup-fullscreen:hover {
  background: rgba(12, 10, 18, 0.94);
  transform: translateY(-1px);
}
.message-file-video:focus-visible,
.message-file-image:focus-visible,
.message-file-audio-play:focus-visible,
.message-file-audio-progress:focus-visible,
.message-file-other a:focus-visible,
.media-popup-overlay button:focus-visible,
.media-popup-overlay a:focus-visible {
  outline: 3px solid var(--purple-bright, #b47cff);
  outline-offset: 3px;
}
.message-file-audio {
  width: min(100%, 380px);
  max-width: 380px;
  padding: 12px;
  border-radius: 14px;
  border-color: color-mix(in srgb, var(--border) 78%, var(--purple));
  background: linear-gradient(135deg, color-mix(in srgb, var(--bg-panel) 92%, var(--purple)), var(--bg-panel));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
.message-file-audio-wrap {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
}
.message-file-audio-play {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--purple) 35%, transparent);
  transition: transform 0.16s ease, filter 0.16s ease;
}
.message-file-audio-play:hover:not(:disabled) { transform: scale(1.05); filter: brightness(1.12); }
.message-file-audio-play:disabled { cursor: not-allowed; opacity: 0.5; }
.message-file-audio-play .icon { width: 21px; height: 21px; }
.message-file-audio-track { display: grid; min-width: 0; gap: 5px; }
.message-file-audio-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.message-file-audio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 650;
}
.message-file-audio-label .icon {
  width: 16px;
  height: 16px;
  color: var(--purple-bright, var(--purple));
}
.message-file-audio-time {
  width: auto;
  flex: 0 0 auto;
  color: var(--text-muted, var(--text-dim));
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  white-space: nowrap;
}
.message-file-audio-progress {
  display: block;
  width: 100%;
  min-height: 22px;
  margin: 0;
  accent-color: var(--purple);
  cursor: pointer;
  touch-action: pan-y;
}
.message-file-audio-error { color: var(--danger, #ef7070); font-size: 0.76rem; line-height: 1.25; }
.message-file-audio-error[hidden] { display: none; }
.message-file-audio-download {
  position: static;
  justify-self: end;
  width: 40px;
  height: 40px;
  border-color: var(--border);
  background: var(--bg-hover);
  color: var(--text-dim);
}
.message-file-audio-download:hover,
.message-file-other-download:hover { color: var(--purple-bright, var(--purple)); background: var(--bg-hover); }
.message-file-other {
  width: min(100%, 440px);
  padding: 12px;
  border-radius: 14px;
  border-color: var(--border);
  background: var(--bg-panel);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.message-file-other-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--purple) 14%, var(--bg-hover));
  color: var(--purple-bright, var(--purple));
}
.message-file-other-icon svg { width: 25px; height: 25px; }
.message-file-other-label { min-width: 0; display: grid; gap: 3px; color: var(--text); }
.message-file-other-label strong { font-size: 0.88rem; font-weight: 650; }
.message-file-other-label small { color: var(--text-muted, var(--text-dim)); font-size: 0.76rem; }
.message-file-other-actions { display: flex; align-items: center; gap: 6px; }
.message-file-other-open,
.message-file-other-download {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}
.message-file-other-open .icon,
.message-file-other-download .icon {
  width: 18px;
  height: 18px;
  color: var(--purple-bright, var(--purple));
}
.media-popup-controls-row button,
.media-popup-controls-row a,
.media-popup-controls .media-popup-step,
.media-popup-controls .media-popup-step-fwd,
.media-popup-controls .media-popup-play {
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
}
.media-popup-controls .media-popup-play {
  min-width: 46px;
  min-height: 46px;
  padding: 0 12px;
  background: var(--purple);
}
.media-popup--video .media-popup-controls,
.media-popup-image-ui {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(12, 10, 18, 0.82);
  backdrop-filter: blur(14px);
}
.media-popup-image-ui { gap: 8px; }
.media-popup-controls-row .media-popup-prev,
.media-popup-controls-row .media-popup-next,
.media-popup-controls .media-popup-step,
.media-popup-controls .media-popup-step-fwd,
.media-popup-controls .media-popup-play {
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.media-popup-controls-row button:hover:not(:disabled),
.media-popup-controls-row a:hover,
.media-popup-controls .media-popup-step:hover,
.media-popup-controls .media-popup-step-fwd:hover { transform: translateY(-1px); }
.media-popup-controls .media-popup-step .icon,
.media-popup-controls .media-popup-step-fwd .icon,
.media-popup-controls .media-popup-play .icon { width: 19px; height: 19px; }
.media-popup-content { border-radius: 12px; }
@media (max-width: 600px) {
  .message-file-audio { width: min(100%, 360px); padding: 10px; }
  .message-file-audio-wrap { grid-template-columns: 42px minmax(0, 1fr) 38px; gap: 8px; }
  .message-file-audio-play { width: 42px; height: 42px; }
  .message-file-audio-download { width: 38px; height: 38px; }
  .message-file-other { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; }
  .message-file-other-icon { width: 40px; height: 40px; }
  .message-file-other-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .media-popup-overlay { padding: 10px; }
  .media-popup-controls-row { gap: 6px; }
}

/* ── Venory redesign: header, usage chip, composer strip, and usage panel ──
   Everything here reads the theme tokens (--bg-panel, --border, --text-dim,
   --purple-bright …) so every theme variant picks it up without overrides. */

/* Header: a clear identity on the left, controls grouped on the right. */
.chat-header-venory {
  gap: 12px;
  flex-wrap: wrap;
  padding: 0.8rem 1.25rem;
}
.chat-header-venory .chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}
.chat-header-venory-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--purple-bright) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--purple-bright) 30%, transparent);
}
.chat-header-venory-mark img,
.chat-header-venory-mark svg { width: 20px; height: 20px; }
.chat-header-title-text {
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-venory-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chat-header-venory .venory-persona-switch { margin-left: auto; }
.chat-header-venory .venory-persona-switch button { transition: background 0.15s ease, color 0.15s ease; }
.chat-header-venory .venory-persona-switch button:not(.is-active):hover { color: var(--text); }
.chat-header-venory .chat-header-menu-btn { margin-left: 2px; }

/* Usage chip in the header: "18 of 30 left", tinted by how much is left. */
.venory-header-usage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.venory-header-usage:hover {
  border-color: color-mix(in srgb, var(--purple-bright) 55%, var(--border));
  color: var(--text);
}
.venory-header-usage:focus-visible,
.premium-quota-usage:focus-visible,
.premium-quota-cta:focus-visible,
.venory-usage-close:focus-visible,
.venory-usage-upgrade:focus-visible,
.venory-usage-retry:focus-visible {
  outline: 2px solid var(--purple-bright);
  outline-offset: 2px;
}
.venory-header-usage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple-bright) 22%, transparent);
}
.venory-header-usage.warn { color: #fbbf24; border-color: rgba(251, 191, 36, 0.4); }
.venory-header-usage.warn .venory-header-usage-dot { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2); }
.venory-header-usage.exhausted { color: #fca5a5; border-color: rgba(248, 113, 113, 0.45); }
.venory-header-usage.exhausted .venory-header-usage-dot { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2); }
.venory-header-usage.unlimited { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); }
.venory-header-usage.unlimited .venory-header-usage-dot { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2); }

/* Persona switch: a quiet segmented control that matches the chip's height. */
.venory-persona-switch {
  background: var(--bg-deep);
  padding: 3px;
}
.venory-persona-switch button { min-height: 30px; }

/* Composer strip: sits above the input, one line, never shouts unless it must. */
.premium-quota-bar { padding: 0 0 8px; }
.premium-quota-bar[hidden] { display: none; }
.premium-quota-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 5px 5px 5px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 12px;
}
.premium-quota-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}
.premium-quota-text strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.premium-quota-unlimited { color: #6ee7b7; }
.premium-quota-track {
  flex: 1 1 80px;
  min-width: 60px;
  max-width: 200px;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}
.premium-quota-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--purple-bright);
  transition: width 0.35s var(--ease);
}
.premium-quota-inner.warn { border-color: rgba(251, 191, 36, 0.45); }
.premium-quota-inner.warn .premium-quota-fill { background: #fbbf24; }
.premium-quota-inner.exhausted { border-color: rgba(248, 113, 113, 0.5); }
.premium-quota-inner.exhausted .premium-quota-fill { background: #f87171; }
.premium-quota-inner.exhausted .premium-quota-text { color: #fca5a5; }
.premium-quota-inner.unlimited { border-color: rgba(52, 211, 153, 0.35); }
.premium-quota-usage {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.premium-quota-usage:hover { background: var(--bg-hover); }
.premium-quota-cta {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--purple-bright);
  color: #fff;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.premium-quota-cta:hover { filter: brightness(1.08); }

/* Usage panel: a focused dialog with today's standing, the week, and the plan. */
.venory-usage {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.venory-usage[hidden] { display: none; }
.venory-usage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 12, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: venory-usage-fade 0.18s ease both;
}
.venory-usage-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(90vh, 820px);
  overflow-y: auto;
  background: var(--bg-main);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: venory-usage-rise 0.22s var(--ease) both;
}
.venory-usage-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}
.venory-usage-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--purple-bright);
  background: color-mix(in srgb, var(--purple-bright) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--purple-bright) 28%, transparent);
}
.venory-usage-titles {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.venory-usage-kicker {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.venory-usage-title {
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
}
.venory-usage-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.venory-usage-close:hover { background: var(--bg-hover); color: var(--text); }
.venory-usage-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}
.venory-usage-loading,
.venory-usage-error {
  padding: 40px 8px;
  color: var(--text-dim);
  text-align: center;
}
.venory-usage-error p { margin: 0 0 12px; }
.venory-usage-retry,
.venory-usage-upgrade {
  border: 0;
  border-radius: 999px;
  background: var(--purple-bright);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 15px;
}
.venory-usage-retry:hover,
.venory-usage-upgrade:hover { filter: brightness(1.08); }

.venory-usage-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.venory-usage-figure {
  display: flex;
  align-items: center;
  gap: 16px;
}
.venory-usage-number {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 3.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.venory-usage-hero-warn .venory-usage-number { color: #fbbf24; }
.venory-usage-hero-exhausted .venory-usage-number { color: #f87171; }
.venory-usage-hero-unlimited .venory-usage-number { color: #34d399; }
.venory-usage-figure-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.venory-usage-figure-copy strong { color: var(--text); font-size: 0.98rem; }
.venory-usage-figure-copy span { color: var(--text-dim); font-size: 0.82rem; line-height: 1.4; }
.venory-usage-meter {
  height: 10px;
  overflow: hidden;
  background: var(--bg-hover);
  border-radius: 999px;
}
.venory-usage-meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--purple-bright);
  transition: width 0.45s var(--ease);
}
.venory-usage-hero-warn .venory-usage-meter-fill { background: #fbbf24; }
.venory-usage-hero-exhausted .venory-usage-meter-fill { background: #f87171; }
.venory-usage-meter-scale {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.venory-usage-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.venory-usage-stats > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.venory-usage-stats dt {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.venory-usage-stats dd {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.venory-usage-reset-note {
  margin: -8px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.venory-usage-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.venory-usage-section-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}
.venory-usage-section-head > span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.venory-usage-chart {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 8px;
  height: 178px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.venory-usage-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 100%;
}
.venory-usage-bar-value {
  min-height: 14px;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.venory-usage-bar-track {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: flex-end;
  width: 100%;
  max-width: 44px;
  min-height: 60px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg-hover) 75%, transparent);
  border-radius: 10px;
}
/* A dashed line at the top of the track marks the daily limit. */
.venory-usage-bar-track::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 1px dashed color-mix(in srgb, var(--text-muted) 55%, transparent);
  pointer-events: none;
}
.venory-usage-chart.is-unlimited .venory-usage-bar-track::after { display: none; }
.venory-usage-bar-fill {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 10px 10px 0 0;
  background: color-mix(in srgb, var(--purple-bright) 48%, transparent);
  transition: height 0.45s var(--ease);
}
.venory-usage-bar.is-today .venory-usage-bar-fill { background: var(--purple-bright); }
.venory-usage-bar-day {
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}
.venory-usage-bar.is-today .venory-usage-bar-day { color: var(--text); font-weight: 700; }

.venory-usage-plan {
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.venory-usage-plan .venory-usage-section-head { margin-bottom: 0; }
.venory-usage-plan ul {
  display: grid;
  gap: 5px;
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 0.84rem;
}
.venory-usage-footnote {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

@keyframes venory-usage-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes venory-usage-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .venory-usage-backdrop,
  .venory-usage-card,
  .venory-usage-bar-fill,
  .venory-usage-meter-fill,
  .premium-quota-fill { animation: none !important; transition: none !important; }
}

@media (max-width: 600px) {
  /* Two rows on a phone: identity and menu on top; usage chip and personality switch below.
     The left inset keeps the title clear of the floating menu button. */
  .chat-header-venory {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 0.7rem 0.9rem 0.7rem 4.75rem;
  }
  .chat-header-venory .chat-header-title { grid-column: 1; grid-row: 1; }
  .chat-header-venory > .chat-header-menu-btn { grid-column: 2; grid-row: 1; }
  .chat-header-venory > .venory-header-usage { grid-column: 1; grid-row: 2; justify-self: start; }
  .chat-header-venory > .venory-persona-switch { grid-column: 2; grid-row: 2; margin-left: 0; }
  .chat-header-venory-tag { display: none; }
  .venory-header-usage { min-height: 36px; padding: 0 10px; }
  .premium-quota-inner { flex-wrap: wrap; row-gap: 6px; }
  .premium-quota-text { flex: 1 0 100%; white-space: normal; }
  .premium-quota-track { order: 2; flex: 1 1 0; min-width: 40px; max-width: none; }
  .premium-quota-usage { order: 3; }
  .premium-quota-cta { order: 4; }
  .venory-usage { align-items: flex-end; padding: 0; }
  .venory-usage-card {
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .venory-usage-body { padding: 16px; }
  .venory-usage-number { font-size: 2.8rem; }
  .venory-usage-stats dd { font-size: 1.02rem; }
  .venory-usage-chart { height: 150px; gap: 5px; }
}
