/* 我的AI小队 · 温润宣纸 · 墨石 / 暖曜石 · 柔瓷 */

:root {
  --bg: #F6F4EF;
  --chat-bg: #F6F4EF;
  --sidebar: #EFECE5;
  --surface: #FFFFFF;
  --surface-soft: #FAF8F4;
  --surface-glass: rgba(246, 244, 239, 0.84);
  --border: rgba(28, 25, 23, 0.08);
  --border-strong: rgba(28, 25, 23, 0.15);
  --specular: rgba(255, 255, 255, 0.7);
  --text: #1C1917;
  --text-secondary: #3E3A36;
  --muted: #5C554F;
  --muted-soft: #665F58;

  /* Deep Espresso Ink CTA + Muted Mineral Slate-Teal Accent */
  --primary: #1C1917;
  --primary-ink: #FAF8F4;
  --primary-hover: #302C29;
  --accent: #2C5E6B;
  --accent-soft: rgba(44, 94, 107, 0.10);
  --accent-border: rgba(44, 94, 107, 0.24);
  --primary-soft: rgba(44, 94, 107, 0.10);

  /* Bubbles */
  --bubble-me: #E7EDE9;
  --bubble-me-border: rgba(44, 94, 107, 0.12);
  --bubble-ai: #FFFFFF;
  --bubble-ai-border: rgba(28, 25, 23, 0.055);
  --bubble-ai-shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 4px 14px rgba(28, 25, 23, 0.03);
  --composer-shadow: 0 2px 6px rgba(28, 25, 23, 0.04), 0 10px 28px rgba(28, 25, 23, 0.065);

  /* Semantic Editorial Tones */
  --warn-bg: #FBF5E8;
  --warn-border: rgba(161, 98, 7, 0.22);
  --warn-text: #854D0E;
  --danger: #B83B3B;
  --danger-soft: rgba(184, 59, 59, 0.09);
  --danger-border: rgba(184, 59, 59, 0.26);

  /* Interactive Surfaces */
  --hover-wash: rgba(28, 25, 23, 0.048);
  --active-wash: rgba(28, 25, 23, 0.08);
  --chip-bg: rgba(28, 25, 23, 0.042);
  --chip-hover: rgba(28, 25, 23, 0.08);
  --seg-track: rgba(28, 25, 23, 0.055);
  --seg-active-bg: #FFFFFF;
  --seg-active-text: #1C1917;
  --seg-active-shadow: 0 1px 2px rgba(28, 25, 23, 0.08), 0 1px 4px rgba(28, 25, 23, 0.05);
  --code-bg: rgba(28, 25, 23, 0.048);
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.05), 0 6px 18px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 14px 38px rgba(28, 25, 23, 0.12), 0 2px 8px rgba(28, 25, 23, 0.05);
  --scrollbar-thumb: rgba(28, 25, 23, 0.16);
}

[data-theme="dark"] {
  --bg: #141312;
  --chat-bg: #141312;
  --sidebar: #1A1917;
  --surface: #211F1D;
  --surface-soft: #1C1B19;
  --surface-glass: rgba(20, 19, 18, 0.84);
  --border: rgba(255, 250, 240, 0.075);
  --border-strong: rgba(255, 250, 240, 0.14);
  --specular: rgba(255, 250, 240, 0.06);
  --text: #EFECE6;
  --text-secondary: #D4CEC4;
  --muted: #ACA59B;
  --muted-soft: #9C958B;

  /* Warm Porcelain CTA + Calm Mist-Teal Accent */
  --primary: #EFECE6;
  --primary-ink: #161514;
  --primary-hover: #FFFFFF;
  --accent: #75AEB8;
  --accent-soft: rgba(117, 174, 184, 0.14);
  --accent-border: rgba(117, 174, 184, 0.28);
  --primary-soft: rgba(117, 174, 184, 0.14);

  /* Bubbles */
  --bubble-me: #223136;
  --bubble-me-border: rgba(117, 174, 184, 0.16);
  --bubble-ai: #211F1D;
  --bubble-ai-border: rgba(255, 250, 240, 0.065);
  --bubble-ai-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.06), 0 4px 16px rgba(0, 0, 0, 0.28);
  --composer-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.06), 0 12px 32px rgba(0, 0, 0, 0.42);

  /* Semantic Editorial Tones */
  --warn-bg: #262017;
  --warn-border: rgba(217, 169, 98, 0.24);
  --warn-text: #E5BE7C;
  --danger: #DF7572;
  --danger-soft: rgba(223, 117, 114, 0.14);
  --danger-border: rgba(223, 117, 114, 0.30);

  /* Interactive Surfaces */
  --hover-wash: rgba(255, 250, 240, 0.055);
  --active-wash: rgba(255, 250, 240, 0.095);
  --chip-bg: rgba(255, 250, 240, 0.055);
  --chip-hover: rgba(255, 250, 240, 0.10);
  --seg-track: rgba(255, 250, 240, 0.06);
  --seg-active-bg: #2B2926;
  --seg-active-text: #EFECE6;
  --seg-active-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.08), 0 1px 4px rgba(0, 0, 0, 0.35);
  --code-bg: rgba(255, 250, 240, 0.065);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 42px rgba(0, 0, 0, 0.55);
  --scrollbar-thumb: rgba(255, 250, 240, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Subtle bespoke scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ===================== Sidebar ===================== */
.sidebar {
  width: 262px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand-title {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}
.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  display: inline-block;
  flex-shrink: 0;
}

.section-label {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.section-divider {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 12px;
}

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 10px;
}
.room-btn {
  position: relative;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  border-radius: 11px;
  cursor: pointer;
  margin-bottom: 3px;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}
.room-btn:hover { background: var(--hover-wash); }
.room-btn.active {
  background: var(--surface);
  box-shadow: var(--seg-active-shadow);
  font-weight: 600;
}
[data-theme="dark"] .room-btn.active {
  background: rgba(255, 250, 240, 0.075);
}
.room-btn.active::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 10px;
  bottom: 10px;
  width: 2.5px;
  border-radius: 999px;
  background: var(--accent);
}
.room-btn .room-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  letter-spacing: -0.005em;
}
.room-btn .room-desc {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}
.room-name-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.room-paused-tag {
  font-size: 10.5px;
  color: var(--muted);
}
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sidebar-roster {
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.roster-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 8px;
}
.roster-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.roster-name {
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
}
.roster-backend {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 118px;
}
.roster-backend.thinking {
  color: var(--accent);
  font-weight: 550;
}

.sidebar-nav {
  border-top: 1px solid var(--border);
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.nav-pill {
  border: 0;
  background: var(--hover-wash);
  color: var(--text-secondary);
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-pill:hover {
  background: var(--active-wash);
  color: var(--text);
}
.nav-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.nav-badge.show { display: inline-flex; }

/* ===================== Chat Main & Topbar ===================== */
.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  position: relative;
}

.topbar {
  min-height: calc(56px + env(safe-area-inset-top, 0px));
  height: auto;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 20px 8px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}
.topbar-left {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.topbar-title-wrap {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}
.topbar-title {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.label-mobile { display: none; }
#menuBtn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Airy Reply Mode Strip */
.reply-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 20px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.reply-mode-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
}
.reply-mode-label {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}
.mode-seg-group {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  background: var(--seg-track);
  gap: 2px;
  flex-shrink: 0;
}
.mode-seg {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 3.5px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.mode-seg:hover:not(:disabled) { color: var(--text); }
.mode-seg.active {
  background: var(--seg-active-bg);
  color: var(--seg-active-text);
  box-shadow: var(--seg-active-shadow);
  font-weight: 600;
}
.mode-seg:disabled { opacity: 0.55; cursor: wait; }
.reply-mode-hint {
  font-size: 11.5px;
  color: var(--muted-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Connection Banner & Toast */
.conn-banner {
  display: none;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
  text-align: center;
}
.conn-banner.show { display: block; }
.conn-banner.resyncing {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.toast-bar {
  opacity: 0;
  pointer-events: none;
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(92vw, 440px);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.toast-bar.show { opacity: 1; animation: msg-enter 0.18s ease-out; }
.toast-bar.error { border-color: var(--danger-border); color: var(--danger); }
.toast-bar.ok { border-color: var(--accent-border); color: var(--accent); }
.toast-bar.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }

/* ===================== Buttons ===================== */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--accent-border);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }

.btn-ghost {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 9px;
  border-radius: 8px;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--hover-wash);
  color: var(--text);
}
.btn-ghost-danger {
  color: var(--danger);
}
.btn-ghost-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: transparent;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: transparent;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: transparent;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.btn-xs {
  padding: 3.5px 9px;
  font-size: 11.5px;
  border-radius: 999px;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover:not(:disabled) {
  background: var(--hover-wash);
  color: var(--text);
}
.icon-btn.recording {
  color: var(--danger);
  background: var(--danger-soft);
  animation: voice-pulse 1.3s ease-in-out infinite;
}
.icon-btn.transcribing {
  color: var(--accent);
  background: var(--accent-soft);
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 59, 59, 0.28); }
  50% { box-shadow: 0 0 0 6px rgba(184, 59, 59, 0); }
}

.mobile-only { display: none; }

/* ===================== Voice Bar ===================== */
.voice-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  margin-bottom: 6px;
  border-radius: 13px;
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
  font-size: 12px;
}
.voice-bar.show { display: flex; }
.voice-bar.transcribing {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.voice-bar.failed {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}
.voice-bar.failed .voice-dot {
  background: var(--warn-text);
  animation: none;
}
.voice-bar.failed .voice-meter,
.voice-bar.failed .voice-timer {
  display: none;
}
.voice-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--danger);
  flex-shrink: 0;
  animation: voice-pulse 1.3s ease-in-out infinite;
}
.voice-bar.transcribing .voice-dot {
  background: var(--accent);
  animation: stream-breathe 1.6s ease-in-out infinite;
}
.voice-status-text {
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-timer {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.voice-meter {
  flex: 1;
  min-width: 28px;
  max-width: 96px;
  height: 5px;
  border-radius: 999px;
  background: var(--border-strong);
  overflow: hidden;
}
.voice-meter-fill {
  display: block;
  width: 12%;
  height: 100%;
  border-radius: 999px;
  background: var(--danger);
  transition: width 80ms linear;
}
.voice-bar.transcribing .voice-meter { display: none; }
.voice-bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.voice-bar-actions .btn {
  padding: 4.5px 10px;
  font-size: 11.5px;
  border-radius: 999px;
}
.voice-lang-select {
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}
.voice-lang-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.voice-retry-btn {
  display: none;
}
.voice-bar.failed .voice-retry-btn {
  display: inline-flex;
}
.voice-bar.failed #voiceStopBtn {
  display: none;
}

/* ===================== Messages Stream ===================== */
@keyframes msg-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.messages {
  flex: 0 0 auto;
  overflow: visible;
  padding: 20px 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.stream-preview-wrap {
  flex: 0 0 auto;
  width: 100%;
  padding: 0 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  overflow: visible;
}

.msg-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  width: 100%;
  max-width: 720px;
  animation: msg-enter 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.msg-row.streaming-row,
.msg-row.msg-streaming,
.stream-preview-wrap .msg-row {
  animation: none !important;
}
.msg-row.agent { justify-content: flex-start; }
.msg-row.me {
  flex-direction: row-reverse;
  justify-content: flex-start;
}
.msg-row.system-row {
  justify-content: center;
  max-width: 720px;
  width: 100%;
  min-width: 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: 12.5px;
  flex-shrink: 0;
  margin-top: 2px;
}
.avatar.sm {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 10.5px;
  margin-top: 0;
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.av-chief,
.av-builder,
.av-reviewer,
.av-strategist { background: #FDF7EE; }
.av-me { background: var(--bubble-me); }
[data-theme="dark"] .av-me .avatar-img {
  filter: saturate(0.76) brightness(0.9);
}

.msg-body {
  min-width: 0;
  max-width: calc(100% - 48px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg-row.me .msg-body { align-items: flex-end; }
.msg-row.agent .msg-body { align-items: flex-start; }

/* Serene Typographic Metadata (No pill-box clutter!) */
.msg-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
  padding: 0 2px;
  line-height: 1.3;
}
.msg-row.me .msg-meta { justify-content: flex-end; }
.msg-name {
  font-weight: 600;
  color: var(--text-secondary);
}
.meta-sep {
  color: var(--muted-soft);
  user-select: none;
}
.msg-meta-note {
  color: var(--muted);
  font-weight: 450;
}
.msg-time {
  color: var(--muted-soft);
  font-variant-numeric: tabular-nums;
}

/* Badges (for drawers, action cards, status chips) */
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--hover-wash);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1.5px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.badge-vision-ok,
.badge-ok {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.badge-vision-off {
  color: var(--muted);
}
.badge-danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}
.badge-locked {
  color: var(--warn-text);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

/* Tactile Bubbles */
.bubble {
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 14.25px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bubble-ai);
  border: 1px solid var(--bubble-ai-border);
  box-shadow: var(--bubble-ai-shadow);
  color: var(--text);
  max-width: 100%;
}
.msg-row.agent .bubble {
  border-top-left-radius: 5px;
}
.msg-row.me .bubble {
  background: var(--bubble-me);
  border-color: var(--bubble-me-border);
  box-shadow: none;
  border-top-right-radius: 5px;
  color: var(--text);
}
[data-theme="dark"] .msg-row.me .bubble {
  box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.05);
}

.bubble pre,
.detail-fold pre {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.lead-key {
  font-weight: 650;
  color: var(--accent);
}
.detail-fold {
  margin-top: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.detail-fold summary {
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  color: var(--text-secondary);
}
.detail-fold pre {
  margin: 8px 0 2px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11.5px;
}

/* W1 Safe Markdown Code-Block Copy, Tables, Links & Mermaid Fallback */
.md-code-wrap {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}
.md-mermaid-wrap {
  border-color: var(--accent-border);
}
.md-code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.md-code-lang {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
.md-mermaid-wrap .md-code-lang {
  color: var(--accent);
}
.md-code-copy {
  padding: 1px 7px;
  font-size: 11px;
}
.md-code-wrap pre.md-code-block {
  margin: 0;
  border: 0;
  border-radius: 0;
}
.md-table-wrap {
  margin: 8px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.5;
}
.md-table th,
.md-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.md-table th:last-child,
.md-table td:last-child {
  border-right: 0;
}
.md-table tr:last-child td {
  border-bottom: 0;
}
.md-table th {
  background: var(--surface-soft);
  font-weight: 650;
  color: var(--text-secondary);
}
.md-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.system-pill {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.system-pill-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 4px;
}
.system-pill-body {
  color: var(--text);
}
.system-pill.vision-notice {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

/* Message Image Attachments */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.msg-attach-btn {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  cursor: zoom-in;
  display: block;
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.msg-attach-btn:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
}
.msg-attach-img {
  max-width: 196px;
  max-height: 196px;
  object-fit: cover;
  display: block;
}

/* P1-6 Document Attachment Pills (in composer & message bubbles) */
.attach-doc-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 7px 26px 7px 9px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  flex-shrink: 0;
}
.attach-doc-ext,
.msg-doc-ext {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.attach-doc-info,
.msg-doc-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.attach-doc-name,
.msg-doc-name {
  font-size: 12px;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-doc-meta,
.msg-doc-meta {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-doc-remove {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--hover-wash);
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}
.attach-doc-remove:hover {
  background: var(--danger);
  color: #FAF8F4;
}
.msg-doc-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}
.msg-doc-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
}
.msg-row.me .msg-doc-pill {
  background: var(--surface);
}
.msg-doc-link {
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.msg-doc-link:hover {
  border-color: var(--accent-border);
  background: var(--hover-wash);
}

/* W2 Media & File Artifact Cards */
.msg-artifacts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.msg-artifact-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 420px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
}
.msg-artifact-player {
  width: 100%;
  max-height: 280px;
  border-radius: 8px;
  background: #141312;
  display: block;
}
.msg-artifact-audio-player {
  width: 100%;
  height: 36px;
}
.msg-artifact-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}
.msg-artifact-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-artifact-meta {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
}
.msg-artifact-dl {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 7px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
}
.msg-artifact-dl:hover {
  filter: brightness(0.95);
}
.msg-artifact-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
button.msg-artifact-dl {
  cursor: pointer;
  font-family: inherit;
}
.msg-attach-card {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  max-width: 198px;
}
.msg-attach-tools {
  display: flex;
  align-items: center;
  gap: 5px;
}
.msg-attach-action {
  flex: 1 1 0;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 550;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}
.msg-attach-action:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}
.msg-artifact-file-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.msg-artifact-file-card:hover {
  border-color: var(--accent-border);
  background: var(--hover-wash);
}

/* P1-7 Debate Decision Card & Mention Truncation Note */
.bubble.debate-bubble {
  border-left-width: 3px;
}
.bubble.debate-proposal {
  border-left-color: var(--accent);
}
.bubble.debate-critique {
  border-left-color: var(--warn-text);
}
.debate-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
}
.debate-stage-tag {
  display: inline-flex;
  align-items: center;
  padding: 1.5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.debate-stage-proposal .debate-stage-tag {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}
.debate-stage-critique .debate-stage-tag {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}
.debate-card-meta {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.debate-card-topic {
  color: var(--text-secondary);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.mention-trunc-note {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 4px 8px;
}

/* P1-8 Knowledge Citations Fold & Memory Shadow Review */
.citation-fold {
  margin-top: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.citation-fold summary {
  cursor: pointer;
  user-select: none;
  font-weight: 550;
  color: var(--accent);
  font-size: 11.5px;
}
.citation-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
}
.citation-item {
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.citation-item-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}
.citation-kind {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 999px;
}
.citation-title {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
}
.citation-loc {
  font-size: 11px;
  color: var(--muted);
  word-break: break-word;
}
.citation-snippet {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.badge-offsite {
  color: var(--warn-text);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}
.shadow-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
}
.shadow-sub-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}
.shadow-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* Action Approval Cards (Warm Amber Parchment) */
.action-card {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--bubble-ai-shadow);
  min-width: 0;
}
.action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.action-title {
  font-weight: 650;
  color: var(--warn-text);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.action-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.action-text {
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 12px;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.action-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.action-btns .btn {
  border-radius: 999px;
  padding: 6.5px 15px;
}
.action-done {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.action-done.stale { color: var(--muted); }

/* Accessible Quiet Message Actions (WCAG AA >= 4.5:1) */
.msg-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
  padding: 0 2px;
  opacity: 1;
}
.msg-row.me .msg-tools { justify-content: flex-end; }
.tiny-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  min-height: 28px;
  padding: 4px 7px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 0.14s ease, background 0.14s ease;
}
.tiny-link:hover,
.tiny-link:focus-visible {
  color: var(--text);
  background: var(--hover-wash);
}
.tiny-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
@media (hover: none), (pointer: coarse) {
  .tiny-link {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12.5px;
  }
}
.msg-more-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.msg-more-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 25;
  min-width: 132px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-more-menu.hidden,
.msg-more-menu[hidden] {
  display: none;
}
.msg-row.me .msg-more-menu {
  left: auto;
  right: 0;
}
.more-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  min-height: 38px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}
.more-menu-item:hover,
.more-menu-item:focus-visible {
  background: var(--hover-wash);
  outline: none;
}
.more-menu-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.more-menu-item[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.room-conn-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 550;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
}
.room-conn-pill.is-warn {
  color: var(--warn-text);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}
.room-conn-pill.hidden,
.room-conn-pill[hidden] {
  display: none;
}
.topbar-more-wrap {
  position: relative;
  display: none;
  align-items: center;
}
.topbar-more-wrap.native-active {
  display: inline-flex;
}
.topbar-more-mobile-item {
  display: none;
}
.native-only-menu-item.hidden,
.native-only-menu-item[hidden] {
  display: none;
}
.topbar-more-btn {
  min-width: 38px;
  min-height: 38px;
  padding: 6px !important;
  justify-content: center;
}
.topbar-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 45;
  min-width: 152px;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topbar-more-menu.hidden,
.topbar-more-menu[hidden] {
  display: none;
}
body.ime-open .composer {
  padding-top: 2px;
  padding-bottom: 6px;
}

/* ===================== P0-2 Streaming Preview Bubble ===================== */
.streaming-bubble {
  border: 1px solid var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--bubble-ai-shadow);
}
.stream-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-weight: 550;
  font-size: 11.5px;
}
.stream-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  display: inline-block;
  animation: stream-breathe 1.6s ease-in-out infinite;
}
@keyframes stream-breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}
.badge-stream-phase {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.stream-elapsed {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted-soft);
}
.stream-stop-btn {
  margin-left: 2px;
  padding: 2px 8px;
  font-size: 11px;
}
.stream-placeholder {
  color: var(--muted);
}
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--accent);
  animation: stream-blink 1s ease-in-out infinite;
}
@keyframes stream-blink {
  0%, 45% { opacity: 1; }
  55%, 100% { opacity: 0.15; }
}

/* ===================== P0-3 Light Markdown ===================== */
.inline-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.87em;
  padding: 1.5px 6px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--border);
}
.md-heading {
  font-weight: 650;
  font-size: 14.5px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin: 10px 0 4px;
  color: var(--text);
}
.md-heading:first-child { margin-top: 0; }
.md-quote {
  border-left: 2.5px solid var(--accent);
  background: var(--code-bg);
  border-radius: 0 9px 9px 0;
  padding: 6px 11px;
  margin: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.md-list-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 3px 0;
  line-height: 1.65;
}
.md-list-marker {
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}
.md-code-block {
  margin: 8px 0;
  white-space: pre-wrap;
}

/* ===================== Pagination, Search, Highlight, Quote & Failed ===================== */
.load-older-wrap {
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: center;
  padding: 0 0 4px;
}
.load-older-btn {
  font-size: 12px;
  padding: 5px 15px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--bubble-ai-shadow);
}
.load-older-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-border);
}

.msg-row.msg-highlight .bubble {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px var(--accent-soft), var(--bubble-ai-shadow);
}

.room-search-bar {
  display: none;
  padding: 10px 20px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.room-search-bar.show { display: block; }
.room-search-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.room-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.room-search-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.room-search-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.room-search-results {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.room-search-results:empty { display: none; }
.room-search-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.room-search-item:hover {
  border-color: var(--accent-border);
  background: var(--surface-soft);
}
.room-search-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.room-search-snippet {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.room-search-detail {
  border: 1px solid var(--accent-border);
  background: var(--surface);
  border-radius: 13px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: var(--bubble-ai-shadow);
}
.room-search-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 4px;
}

.quote-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 11px;
  border-left: 2.5px solid var(--accent);
  background: var(--surface-soft);
  font-size: 12px;
}
.quote-bar.show { display: flex; }
.quote-bar-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
}
.quote-sender {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}
.quote-snippet {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quote-clear-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.quote-clear-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.failed-bubble {
  border-color: var(--danger-border) !important;
  opacity: 0.96;
}
.failed-error-line {
  margin-top: 5px;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.4;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.failed-tools {
  margin-top: 5px;
  gap: 8px;
}
.room-empty-state {
  margin: 28px auto;
  padding: 10px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ===================== P0-4 Tasks Drawer ===================== */
.tasks-readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.tasks-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
}
.tasks-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.tasks-card-sub {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}
.tasks-dryrun-box {
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
}

.sr-only {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Typing bar */
.typing-bar {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 2px 22px 4px;
  font-size: 12px;
  color: var(--accent);
  display: none;
}
.typing-bar.show { display: block; }

/* ===================== Tactile Floating Capsule Composer ===================== */
.composer {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  background: transparent;
  padding: 2px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.composer-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 8px 10px;
  box-shadow: var(--composer-shadow);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.composer-card:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--composer-shadow);
}
.composer.drag-active .composer-card {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--composer-shadow);
}

/* Borderless Tinted Quick Chips */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: var(--chip-bg);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4.5px 11px 4.5px 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.chip:hover {
  background: var(--chip-hover);
  color: var(--text);
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  font-weight: 650;
}
.mention-recipients {
  color: var(--text-secondary);
  font-size: 12px;
}
.mention-recipients:empty { display: none; }
.chip.highlight {
  padding-left: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.chip.highlight:hover {
  background: rgba(44, 94, 107, 0.16);
}
[data-theme="dark"] .chip.highlight:hover {
  background: rgba(117, 174, 184, 0.22);
}
.chip.chip-utility {
  padding-left: 11px;
  color: var(--muted);
}
.chip-av {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
  background: #FDF7EE;
}

/* Attachment Preview Bar & Vision Hint */
.attach-bar {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  align-items: center;
}
.attach-bar.show { display: flex; }
.attach-pill {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.attach-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(28, 25, 23, 0.78);
  color: #FAF8F4;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}
.attach-remove:hover { background: var(--danger); }
.attach-uploading {
  font-size: 12px;
  color: var(--accent);
  padding: 6px 10px;
  border: 1px dashed var(--accent-border);
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.vision-hint {
  display: none;
  font-size: 11.5px;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  line-height: 1.45;
}
.vision-hint.show { display: block; }

/* @ Mention Autocomplete Popup */
.mention-popup {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(100% + 4px);
  max-width: 340px;
  max-height: 248px;
  overflow-y: auto;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  box-shadow: var(--shadow-lg);
  display: none;
  padding: 5px;
}
.mention-popup.show {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mention-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}
.mention-item:hover,
.mention-item.active {
  background: var(--accent-soft);
}
.mention-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mention-av {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #FDF7EE;
}
.mention-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  resize: none;
  border: 0;
  border-radius: 10px;
  padding: 8px 6px 6px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.48;
  outline: none;
  overflow-y: hidden;
}
.input-row textarea::placeholder {
  color: var(--muted-soft);
}
.send-btn {
  height: 36px;
  min-height: 36px;
  border-radius: 999px;
  padding: 0 16px;
  font-size: 13px;
}
.send-btn:disabled,
.send-btn[aria-disabled="true"] {
  background: var(--chip-bg);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
  transform: none;
}
.send-btn:disabled:hover,
.send-btn[aria-disabled="true"]:hover {
  background: var(--chip-bg);
  color: var(--muted);
}

/* ===================== Drawers, Lightbox & Login ===================== */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.34);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  z-index: 30;
}
.sidebar-backdrop.open { display: block; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.34);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  justify-content: flex-end;
  z-index: 40;
}
.drawer-backdrop.open { display: flex; }
.drawer {
  width: 404px;
  max-width: 94vw;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.drawer-head {
  padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-card select,
.panel-card input[type="text"],
.panel-card input:not([type]) {
  width: 100%;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.panel-card select:focus,
.panel-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chk-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.chk-label input[type="checkbox"] {
  accent-color: var(--accent);
}

/* W1 Quota Progress Bars & Quiet Hours Settings */
.quota-card {
  gap: 8px;
}
.quota-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.quota-bar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quota-bar-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.quota-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.quota-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--hover-wash);
  border: 1px solid var(--border);
  overflow: hidden;
}
.quota-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}
.quota-bar-fill.is-warn {
  background: var(--warn-text);
}
.quota-bar-fill.is-danger {
  background: var(--danger);
}
.quota-bar-sub {
  font-size: 10.5px;
  color: var(--muted);
}
.quiet-hours-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quiet-hours-row input[type="time"] {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.slash-cmd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 650;
}

/* Offline Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 15, 14, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 80;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
  outline: none;
}
.lightbox-modal.open { display: flex; }
.lightbox-toolbar {
  width: 100%;
  max-width: 920px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #EFECE6;
}
.lightbox-caption {
  font-size: 13px;
  color: #C8C1B6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.lightbox-btn,
.lightbox-close {
  background: rgba(255, 250, 240, 0.12);
  color: #FAF8F4;
  border-color: rgba(255, 250, 240, 0.22);
  border-radius: 999px;
}
.lightbox-btn:hover:not(:disabled),
.lightbox-close:hover:not(:disabled) {
  background: rgba(255, 250, 240, 0.22);
  border-color: rgba(255, 250, 240, 0.35);
}
.lightbox-btn.hidden {
  display: none;
}
.lightbox-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.lightbox-img {
  max-width: 94vw;
  max-height: 82vh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  transition: transform 0.16s ease;
  transform-origin: center center;
  cursor: zoom-in;
  user-select: none;
}
.lightbox-img.zoomed {
  cursor: zoom-out;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.login-overlay.show { display: flex; }
.login-box {
  width: 360px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-emblem {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
}
.login-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.login-sub {
  font-size: 12px;
  color: var(--muted);
}
.login-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}
.login-desc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--text-secondary);
}
.login-box input {
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-submit {
  height: 40px;
  border-radius: 12px;
  font-size: 13.5px;
}
.login-err {
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
}

/* ===================== Responsive ===================== */
@media (max-width: 820px) {
  .topbar,
  .reply-mode-bar,
  .room-search-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--surface);
  }
  .sidebar-backdrop,
  .drawer-backdrop,
  .lightbox-modal {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

@media (max-width: 780px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 35;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.24);
  }
  .mobile-only { display: inline-flex; }
  .topbar-sub { display: none; }
  .topbar-fold-mobile { display: none !important; }
  .topbar-more-wrap { display: inline-flex; }
  .topbar-more-mobile-item { display: flex; }
}

@media (max-width: 560px) {
  .topbar {
    min-height: calc(50px + env(safe-area-inset-top, 0px));
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
    gap: 6px;
  }
  .topbar-left { gap: 4px; }
  .topbar-title { font-size: 14.5px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .btn,
  #menuBtn {
    padding: 6px 7px;
    font-size: 12px;
    border-radius: 8px;
  }
  .label-desktop { display: none; }
  .label-mobile { display: inline; }
  #roomSearchToggleBtn,
  #themeBtn {
    padding: 6px;
    min-width: 32px;
  }
  .reply-mode-bar { padding: 6px 12px; }
  .mode-seg { padding: 3.5px 9px; font-size: 11.5px; }
  .room-search-bar { padding: 8px 12px; }
  .messages { padding: 14px 12px 10px; gap: 14px; }
  .stream-preview-wrap { padding: 0 12px 10px; gap: 12px; }
  .topbar,
  .reply-mode-bar,
  .room-search-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--surface);
  }
  .sidebar-backdrop,
  .drawer-backdrop,
  .lightbox-modal {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .msg-row { max-width: 100%; gap: 9px; }
  .avatar { width: 32px; height: 32px; border-radius: 10px; }
  .msg-body { max-width: calc(100% - 42px); }
  .bubble { padding: 10px 13px; font-size: 14px; border-radius: 16px; }
  .composer {
    padding: 2px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  .chips {
    gap: 5px;
    padding-right: 12px;
    scroll-snap-type: x proximity;
  }
  .chip {
    padding: 4px 9px 4px 6px;
    font-size: 11.5px;
    gap: 4px;
    scroll-snap-align: start;
  }
  .chip.highlight,
  .chip.chip-utility {
    padding-left: 9px;
  }
  .chip-av {
    width: 15px;
    height: 15px;
  }
  .composer-card {
    border-radius: 20px;
    padding: 6px 8px;
  }
  .mention-popup,
  .slash-popup { left: 10px; right: 10px; }
  .input-row { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
  .input-row textarea { min-height: 36px; padding: 7px 4px; font-size: 13.5px; }
  .send-btn { height: 36px; min-height: 36px; padding: 0 13px; font-size: 12.5px; }
}

@media (max-width: 420px) {
  .topbar-title { font-size: 14px; }
  .msg-attach-img { max-width: 140px; max-height: 140px; }
  .reply-mode-hint { display: none; }
}

@media (max-width: 350px) {
  .composer { padding: 2px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .input-row { gap: 3px; }
  .icon-btn { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
  .input-row textarea { min-height: 34px; padding: 6px 4px; font-size: 12.5px; }
  .send-btn { height: 32px; min-height: 32px; padding: 0 11px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Wave 4: Guest Sandbox & Mode 1 Read-Only Diagnostic Pack */
.hidden {
  display: none !important;
}

.nav-pill-wide {
  grid-column: 1 / -1;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: var(--hover-wash);
  border: 1px solid var(--border);
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.login-form-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form-panel input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
}

.guest-invite-card {
  border: 1px solid var(--accent);
  background: var(--warn-bg);
}

.guest-invite-passcode {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
}

.guest-form-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guest-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.guest-form-grid input,
.guest-form-grid select {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
}

.diag-template-pre {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.guest-sandbox-banner {
  border-left: 3px solid var(--accent);
}

/* M2: PC Desktop Console Drawer (Loopback-only) */
.pc-console-section {
  gap: 10px;
}

.pc-console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pc-console-title {
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
}

.pc-health-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-secondary);
}
.pc-health-bar.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}
.pc-health-bar.is-danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.pc-health-main {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.pc-health-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  flex-shrink: 0;
}
.pc-health-bar.is-warn .pc-health-dot { background: var(--warn-text); }
.pc-health-bar.is-danger .pc-health-dot { background: var(--danger); }
.pc-health-text {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-details-fold {
  margin-top: 6px;
}
.pc-details-fold > summary {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 5px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  border-radius: 6px;
}
.pc-details-fold > summary::-webkit-details-marker { display: none; }
.pc-details-fold > summary:hover { color: var(--text); }
.pc-details-fold > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.pc-details-fold[open] > summary {
  margin-bottom: 8px;
  color: var(--text);
}

.pc-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pc-stat-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pc-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pc-stat-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-stat-val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.pc-stat-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pc-stat-tile.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.pc-stat-tile.is-danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
}

.pc-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  padding: 12px 12px;
  text-align: center;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.pc-dropzone:hover,
.pc-dropzone.drag-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pc-dropzone-title {
  font-size: 13px;
  font-weight: 600;
}

.pc-dropzone-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.pc-push-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pc-push-field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.pc-upload-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pc-progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--hover-wash);
  border: 1px solid var(--border);
  overflow: hidden;
}

.pc-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.15s ease;
}

.pc-progress-text {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.pc-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pc-queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pc-queue-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pc-queue-name {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-queue-meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pc-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pc-notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.pc-notify-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

@media (max-width: 480px) {
  .pc-status-grid {
    grid-template-columns: 1fr;
  }
  .pc-queue-row {
    flex-wrap: wrap;
  }
}
