*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f23;
  --card: #1a1a2e;
  --accent: #818cf8; /* Was #6366f1 — bumped for 4.5:1 on dark bg */
  --accent-glow: rgba(129,140,248,0.3);
  --text: #e2e8f0;
  --text-dim: #cbd5e1; /* Was #b0bec5 — bumped for 4.5:1 contrast */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --min-touch: 44px; /* WCAG minimum touch target */
}

html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* Removed user-select: none to allow text selection for assistive tech */
  font-size: 100%; /* Respect user's browser font size */
}

/* ---- DYNAMIC TEXT SIZING ---- */
@supports (font-size: clamp(1rem, 2vw, 1.25rem)) {
  html { font-size: clamp(87.5%, 100%, 150%); }
}

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

/* ---- HIGH CONTRAST MODE ---- */
@media (forced-colors: active) {
  :root {
    --accent: LinkText;
    --text: CanvasText;
    --bg: Canvas;
    --card: Canvas;
  }
  .voice-btn, .nav-item, .mode-btn, #login-btn, #send-btn {
    border: 2px solid ButtonText;
  }
}

/* ---- ACCESSIBILITY ---- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  width: auto; height: auto; clip: auto; margin: 0;
  padding: 12px 16px; background: var(--accent); color: #000;
  border-radius: 8px; font-size: 1rem; font-weight: 600;
  text-decoration: none;
}

/* Focus visible outlines for keyboard navigation */
*:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- LOGIN ---- */
#login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); gap: 1.5rem;
  transition: opacity 0.4s, transform 0.4s;
}
#login-screen.hidden { opacity: 0; transform: scale(0.95); pointer-events: none; }
#login-screen h1 { font-size: 3rem; font-weight: 800; color: var(--accent); }
#login-screen p { color: var(--text-dim); font-size: 0.875rem; }
#login-form {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem; width: 280px;
}
#username-input, #password-input {
  width: 100%; padding: 0.875rem 1rem; font-size: 1rem;
  background: var(--card); border: 2px solid transparent; border-radius: 12px;
  color: var(--text); outline: none; transition: border-color 0.2s;
  box-sizing: border-box;
  min-height: var(--min-touch);
}
#username-input::placeholder, #password-input::placeholder {
  color: var(--text-dim);
}
#username-input:focus, #password-input:focus { border-color: var(--accent); }
#login-btn {
  width: 100%; padding: 0.875rem; font-size: 1rem; font-weight: 600;
  background: var(--accent); color: #000; border: none; border-radius: 12px;
  cursor: pointer; transition: opacity 0.2s;
  min-height: var(--min-touch);
}
#login-btn:hover { opacity: 0.9; }
#login-btn:active { opacity: 0.8; }
.login-error {
  color: #fca5a5; /* Lighter red for contrast on dark bg — was #ef4444 */
  font-size: 0.8125rem;
}
.login-error.hidden { display: none; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ---- APP SHELL ---- */
#app {
  display: none; flex-direction: column; height: 100%;
  padding-top: var(--safe-top);
}
#app.active { display: flex; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: center;
  padding: 0.75rem 1rem; flex-shrink: 0;
}
.header-title {
  font-size: 1.25rem; font-weight: 700; color: var(--accent);
  margin: 0;
}

/* Tabs content */
.tab-content {
  flex: 1; overflow: hidden; position: relative;
}
.tab-pane {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.tab-pane.active { opacity: 1; transform: none; pointer-events: auto; }

/* ---- CHAT ---- */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 0.5rem 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 80%; padding: 0.625rem 0.875rem; border-radius: 1rem;
  font-size: 0.9375rem; line-height: 1.45; word-wrap: break-word;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
.msg.sent {
  align-self: flex-end; background: var(--accent); color: #000;
  border-bottom-right-radius: 4px;
}
.msg.received {
  align-self: flex-start; background: var(--card); color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.typing { color: var(--text-dim); font-style: italic; }

.chat-input-bar {
  display: flex; gap: 0.5rem; padding: 0.5rem 1rem;
  padding-bottom: calc(0.5rem + var(--safe-bottom));
  flex-shrink: 0;
}
.chat-input-bar input {
  flex: 1; padding: 0.75rem 1rem; font-size: 1rem;
  background: var(--card); border: none; border-radius: 1.5rem;
  color: var(--text); outline: none;
  min-height: var(--min-touch);
}
.chat-input-bar input::placeholder {
  color: var(--text-dim);
}
.chat-input-bar button {
  width: var(--min-touch); height: var(--min-touch); border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.chat-input-bar button:active { transform: scale(0.9); }
.chat-input-bar button svg { fill: #000; width: 20px; height: 20px; }

/* ---- VOICE ---- */
.voice-pane {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem;
}
.voice-btn {
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: transform 0.2s;
}
.voice-btn:active { transform: scale(0.93); }
.voice-btn svg { width: 48px; height: 48px; fill: #000; }
.voice-btn::before {
  content: ''; position: absolute; inset: -12px;
  border-radius: 50%; border: 2px solid var(--accent-glow);
  animation: voicePulse 2s ease-in-out infinite;
}
.voice-btn.active { background: #ef4444; }
.voice-btn.active svg { fill: #fff; }
.voice-btn.active::before { border-color: rgba(239,68,68,0.4); animation-duration: 0.8s; }
@keyframes voicePulse {
  0%,100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0; }
}
.voice-status { color: var(--text-dim); font-size: 0.875rem; }
.voice-mode-toggle {
  display: flex; gap: 4px; background: var(--card); border-radius: 12px; padding: 4px;
}
.mode-btn {
  padding: 0.75rem 1.25rem; border-radius: 10px; border: none;
  background: transparent; color: var(--text-dim); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  min-height: var(--min-touch); min-width: var(--min-touch);
}
.mode-btn.active { background: var(--accent); color: #000; }
.mode-btn.real-active { background: #10b981; color: #000; }
.voice-mode-label { color: var(--text-dim); font-size: 0.75rem; }

/* ---- BRIEFING ---- */
.briefing-pane {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  padding: 2rem;
}
.briefing-pane .icon { font-size: 3rem; }
.briefing-pane h2 { font-size: 1.25rem; font-weight: 600; }
.briefing-pane p { color: var(--text-dim); text-align: center; font-size: 0.875rem; line-height: 1.5; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  display: flex; flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
  background: var(--card); border-top: 1px solid rgba(255,255,255,0.06);
  order: -1; /* Move nav before content for visual layout, DOM order is correct for a11y */
}
#app { display: none; flex-direction: column; }
#app.active { display: flex; }

.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 0.625rem 0 0.375rem; gap: 0.25rem; cursor: pointer;
  color: var(--text-dim); font-size: 0.6875rem; font-weight: 500;
  transition: color 0.2s; border: none; background: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px; min-width: 48px;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; fill: currentColor; }

/* ---- A2HS BANNER ---- */
.a2hs-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--card); padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
  display: flex; align-items: center; gap: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  animation: slideUp 0.4s ease;
}
.a2hs-banner.hidden { display: none; }
@keyframes slideUp { from { transform: translateY(100%); } }
.a2hs-banner p { flex: 1; font-size: 0.8125rem; line-height: 1.4; }
.a2hs-banner button {
  padding: 0.5rem 1rem; border-radius: 8px; border: none;
  background: var(--accent); color: #000; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  min-height: var(--min-touch); min-width: var(--min-touch);
}
.a2hs-close {
  background: none !important; color: var(--text-dim) !important; font-size: 1.125rem;
  padding: 0.5rem 0.75rem !important;
  min-width: var(--min-touch); min-height: var(--min-touch);
  display: flex; align-items: center; justify-content: center;
}

/* ---- Briefing ---- */
.briefing-scroll {
  overflow-y: auto;
  padding: 1rem;
  height: 100%;
  -webkit-overflow-scrolling: touch;
}
.briefing-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1rem;
  position: relative;
}
.briefing-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}
.briefing-date {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0;
  flex: 1;
}
.briefing-refresh {
  background: none;
  border: 1px solid #555; /* Was #333 — improved contrast */
  color: var(--text-dim);
  font-size: 1.1rem;
  border-radius: 8px;
  width: var(--min-touch);
  height: var(--min-touch);
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.briefing-refresh:hover { color: #fff; border-color: #888; }
.briefing-refresh.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.briefing-card {
  background: #1a1a2e;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  border: 1px solid #353560; /* Was #252540 — improved contrast */
}
.card-header {
  padding: 0.625rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #a5a5e0; /* Was #8888cc — improved contrast */
  letter-spacing: 0.02em;
  border-bottom: 1px solid #353560;
  margin: 0;
}
.card-body {
  padding: 0.75rem 0.875rem;
}
.loading-pulse {
  color: var(--text-dim);
  animation: loadPulse 1.5s ease-in-out infinite;
}
@keyframes loadPulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* Weather */
.weather-current {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.weather-temp {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
}
.weather-desc {
  color: var(--text-dim);
  font-size: 0.9rem;
}
.weather-details {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim); /* Was #777 — now passes contrast */
}
.weather-forecast {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #353560;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Calendar */
.cal-event {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid #252540;
}
.cal-event:last-child { border-bottom: none; }
.cal-time {
  font-size: 0.8rem;
  color: var(--accent);
  min-width: 50px;
  font-weight: 600;
}
.cal-title {
  color: var(--text);
  font-size: 0.9rem;
}
.cal-empty {
  color: var(--text-dim);
  font-style: italic;
}

/* Emails */
.email-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #252540;
}
.email-item:last-child { border-bottom: none; }
.email-from {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
}
.email-subject {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.125rem;
}
.email-time {
  color: var(--text-dim);
  font-size: 0.7rem;
  margin-top: 0.125rem;
  opacity: 0.7;
}
.email-unread .email-from { color: #fff; }
.email-unread .email-subject { color: var(--text); }

/* Tasks */
.task-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0;
  color: var(--text);
  font-size: 0.85rem;
}
.task-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.briefing-error {
  color: #fca5a5; /* Was #ff6b6b — improved contrast */
  font-size: 0.85rem;
}

/* ---- NETWORK STATUS BANNER ---- */
.network-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.network-banner.hidden { display: none; }
.network-banner.offline {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5; /* Was #f87171 — improved contrast */
  border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}
.network-banner.online {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7; /* Was #34d399 — improved contrast */
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}
.network-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.network-banner.offline .network-dot {
  background: #ef4444;
  animation: blink 1.5s ease-in-out infinite;
}
.network-banner.online .network-dot {
  background: #10b981;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- PENDING / SYNCED MESSAGE STATES ---- */
.msg.pending {
  opacity: 0.6;
  position: relative;
}
.msg.pending::after {
  content: '⏳';
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 10px;
}
.msg.synced::after {
  content: '✓';
  position: absolute;
  bottom: -2px;
  right: 4px;
  font-size: 11px;
  color: #6ee7b7;
}
.msg.sent {
  position: relative;
}

/* ---- NAV ORDER FIX ---- */
/* Nav is in DOM before content for tab order, but visually at bottom */
.bottom-nav { order: 1; }
.tab-content { order: 0; }
.header { order: -1; }
#network-status { order: -1; }

/* ---- Performance Optimizations ---- */
.chat-messages {
  will-change: scroll-position;
  contain: layout style;
  overflow-anchor: auto;
}
.msg {
  contain: content;
}
.tab-pane:not(.active) {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}
.briefing-scroll {
  contain: layout style;
}
.skip-to-content { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; z-index: 9999; } .skip-to-content:focus { position: fixed; top: 10px; left: 10px; width: auto; height: auto; padding: 10px 20px; background: var(--accent, #6366f1); color: white; font-size: 1rem; border-radius: 4px; text-decoration: none; }
/* ---- LOCK SCREEN ---- */
#lock-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
#lock-screen.visible {
  opacity: 1; pointer-events: auto;
}
.lock-container {
  display: flex; flex-direction: column; align-items: center;
  gap: 1.25rem; padding: 2rem; max-width: 320px; width: 100%;
}
.lock-icon { font-size: 3.5rem; animation: lockBounce 0.5s ease; }
@keyframes lockBounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.lock-title {
  font-size: 1.5rem; font-weight: 700; color: #fff; margin: 0;
}
.lock-subtitle {
  color: var(--text-dim); font-size: 0.875rem; text-align: center; margin: 0;
}
.lock-actions {
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; width: 100%;
}
.lock-btn {
  width: 100%; padding: 0.875rem 1.5rem; border-radius: 12px;
  border: none; font-size: 1rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--min-touch); transition: all 0.2s;
}
.lock-btn-bio {
  background: var(--accent); color: #000;
}
.lock-btn-bio:hover { opacity: 0.9; }
.lock-btn-bio:active { transform: scale(0.97); }
.lock-btn-icon { font-size: 1.25rem; }
.lock-btn-pin-submit {
  background: var(--accent); color: #000;
}
.lock-btn-text {
  background: none; border: none; color: var(--accent);
  font-size: 0.875rem; cursor: pointer; padding: 0.5rem;
  min-height: var(--min-touch);
}
.lock-btn-text:hover { text-decoration: underline; }

/* PIN input */
.lock-pin-section {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; width: 100%;
}
.pin-dots {
  display: flex; gap: 0.625rem; margin-bottom: 0.25rem;
}
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-dim); background: transparent;
  transition: all 0.2s;
}
.pin-dot.filled {
  background: var(--accent); border-color: var(--accent);
}
.lock-pin-input {
  width: 100%; padding: 0.875rem 1rem; font-size: 1.25rem;
  background: var(--card); border: 2px solid transparent; border-radius: 12px;
  color: var(--text); outline: none; text-align: center;
  letter-spacing: 0.3em; min-height: var(--min-touch);
  transition: border-color 0.2s;
}
.lock-pin-input:focus { border-color: var(--accent); }
.lock-pin-input::placeholder {
  color: var(--text-dim); letter-spacing: normal; font-size: 1rem;
}
.lock-pin-error {
  color: #fca5a5; font-size: 0.8125rem; text-align: center;
}
.lock-pin-error.hidden { display: none; }

/* ---- SECURITY SETTINGS ---- */
.security-settings {
  padding: 0;
}
.settings-section-title {
  font-size: 1rem; font-weight: 600; color: #fff;
  margin: 0 0 0.75rem; padding: 0;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0; border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 0.75rem;
}
.setting-row:last-of-type { border-bottom: none; }
.setting-info {
  display: flex; flex-direction: column; gap: 0.125rem; flex: 1;
}
.setting-label {
  color: var(--text); font-size: 0.9375rem; font-weight: 500;
}
.setting-desc {
  color: var(--text-dim); font-size: 0.75rem;
}
.setting-action-btn {
  padding: 0.5rem 1rem; border-radius: 8px;
  background: var(--card); border: 1px solid rgba(255,255,255,0.1);
  color: var(--accent); font-size: 0.8125rem; font-weight: 500;
  cursor: pointer; min-height: var(--min-touch);
  transition: all 0.2s;
}
.setting-action-btn:hover { background: rgba(255,255,255,0.05); }
.setting-select {
  padding: 0.5rem 0.75rem; border-radius: 8px;
  background: var(--card); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text); font-size: 0.8125rem;
  min-height: var(--min-touch); cursor: pointer;
}

/* Toggle switch */
.toggle-switch {
  position: relative; width: 48px; height: 28px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #333; border-radius: 14px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 22px; width: 22px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* PIN Setup Modal */
.pin-setup-modal {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center;
}
.pin-setup-modal.hidden { display: none; }
.pin-setup-content {
  background: var(--card); border-radius: 16px;
  padding: 1.5rem; max-width: 300px; width: 90%;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.pin-setup-content h3 {
  color: #fff; font-size: 1.125rem; margin: 0; text-align: center;
}
.pin-setup-content p {
  color: var(--text-dim); font-size: 0.875rem; margin: 0; text-align: center;
}
.pin-setup-actions {
  display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem;
}
/* ---- Rich Messages ---- */
.msg.received { word-break: break-word; }
.msg.received a, .msg.sent a { word-break: break-all; }

/* Links */
.rich-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.rich-link:hover { opacity: .85; }

/* Inline code */
.rich-inline-code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-family: 'SF Mono', Menlo, monospace; font-size: .9em; }

/* Code blocks */
.rich-codeblock { background: #0d0d1a; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; margin: 8px 0; overflow: hidden; }
.rich-cb-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px; background: rgba(255,255,255,.05); font-size: .75em; }
.rich-cb-lang { color: var(--text-dim); text-transform: uppercase; }
.rich-cb-copy { background: none; border: 1px solid rgba(255,255,255,.15); color: var(--text-dim); border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: .85em; }
.rich-cb-copy:hover { background: rgba(255,255,255,.1); }
.rich-codeblock pre { padding: 10px; overflow-x: auto; margin: 0; }
.rich-codeblock code { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: .85em; color: #a5d6ff; line-height: 1.5; }

/* Tables */
.rich-table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .9em; }
.rich-table th, .rich-table td { border: 1px solid rgba(255,255,255,.12); padding: 6px 10px; text-align: left; }
.rich-table th { background: rgba(255,255,255,.06); color: var(--accent); font-weight: 600; }
.rich-table tr:nth-child(even) { background: rgba(255,255,255,.03); }

/* Headings */
.rich-h { margin: 8px 0 4px; color: #f1f5f9; }
h2.rich-h { font-size: 1.3em; }
h3.rich-h { font-size: 1.15em; }
h4.rich-h { font-size: 1.05em; }

/* Lists */
.rich-ul, .rich-ol { padding-left: 20px; margin: 4px 0; }
.rich-li, .rich-oli { margin: 2px 0; }

/* Blockquote */
.rich-bq { border-left: 3px solid var(--accent); padding: 2px 10px; margin: 4px 0; color: var(--text-dim); background: rgba(129,140,248,.06); border-radius: 0 4px 4px 0; }

/* Rich cards (shared) */
.rich-card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 12px; margin: 8px 0; display: flex; gap: 10px; align-items: flex-start; }
.rich-card-icon { font-size: 1.8em; flex-shrink: 0; }
.rich-card-body { flex: 1; min-width: 0; }
.rich-card-title { font-weight: 600; font-size: 1em; margin-bottom: 2px; }
.rich-card-meta { font-size: .85em; color: var(--text-dim); margin-top: 2px; }
.rich-card-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Buttons */
.rich-btn { padding: 6px 14px; border-radius: 6px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: var(--text); cursor: pointer; font-size: .85em; min-height: var(--min-touch); display: inline-flex; align-items: center; }
.rich-btn:hover { background: rgba(255,255,255,.12); }
.rich-btn:disabled { opacity: .5; cursor: default; }
.rich-btn-accept.chosen { background: rgba(34,197,94,.2); border-color: #22c55e; color: #22c55e; }
.rich-btn-decline.chosen { background: rgba(239,68,68,.2); border-color: #ef4444; color: #ef4444; }
.rich-btn-download { text-decoration: none; margin-left: auto; align-self: center; }

/* Calendar */
.rich-calendar { border-left: 3px solid #818cf8; }
.rich-attendees { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rich-attendee { background: rgba(129,140,248,.15); padding: 1px 8px; border-radius: 12px; font-size: .8em; color: var(--accent); }

/* Task */
.rich-task { border-left: 3px solid #f59e0b; align-items: center; }
.rich-task.completed { opacity: .6; }
.rich-task.completed .rich-card-title { text-decoration: line-through; }
.rich-task-check { flex-shrink: 0; cursor: pointer; }
.rich-task-check input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.rich-priority-badge { display: inline-block; font-size: .8em; padding: 1px 8px; border-radius: 10px; background: rgba(255,255,255,.06); margin-top: 4px; }

/* Poll */
.rich-poll { flex-direction: column; border-left: 3px solid #8b5cf6; }
.rich-poll-options { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.rich-poll-option { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: var(--text); cursor: pointer; font-size: .9em; min-height: var(--min-touch); transition: background .2s; }
.rich-poll-option:hover { background: rgba(255,255,255,.1); }
.rich-poll-option.voted { background: rgba(129,140,248,.15); border-color: var(--accent); }
.rich-poll-votes { font-size: .8em; color: var(--text-dim); margin-left: 8px; }
.rich-poll.voted .rich-poll-option { cursor: default; }

/* File card */
.rich-file { align-items: center; border-left: 3px solid #06b6d4; }

/* Quote card */
.rich-quote { flex-direction: column; border-left: 3px solid #a78bfa; }
.rich-blockquote { font-style: italic; font-size: 1.05em; line-height: 1.5; color: var(--text); }
.rich-quote-author { font-size: .85em; color: var(--text-dim); margin-top: 4px; text-align: right; }

/* ---- Wake Word Indicator ---- */
.wakeword-indicator {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  z-index: 9999;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s;
}
.wakeword-indicator.hidden { display: none; }
.wakeword-dot {
  width: 8px; height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: wakeword-pulse 1.5s ease-in-out infinite;
}
@keyframes wakeword-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}
.wakeword-label { white-space: nowrap; }

/* ---- Wake Word Settings ---- */
.wakeword-settings { padding: 16px 0; }
.wakeword-settings h3 { margin: 0 0 12px; font-size: 16px; }
.wakeword-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.wakeword-row label { flex: 1; font-size: 14px; }
.wakeword-row select {
  background: rgba(255,255,255,0.1);
  color: inherit;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}
.wakeword-toggle {
  position: relative;
  width: 44px; height: 24px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
}
.wakeword-toggle.active { background: #22c55e; }
.wakeword-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.wakeword-toggle.active::after { transform: translateX(20px); }
.wakeword-note {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 12px;
  line-height: 1.4;
}
