/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app { height: 100%; position: relative; }

/* === Screens === */
.screen { display: none; height: 100%; flex-direction: column; }
.screen.active-screen { display: flex; }

/* === Login === */
.login-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 2rem;
}
.login-logo { font-size: 3rem; margin-bottom: 0.5rem; }
.login-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-subtitle { color: #888; font-size: 0.875rem; margin-bottom: 2rem; }
#login-form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 0.75rem; }
#login-form input {
  width: 100%; padding: 0.875rem 1rem; border: 1px solid #e0e0e0; border-radius: 12px;
  font-size: 1rem; background: #fff; outline: none; transition: border-color 0.2s;
  font-family: inherit;
}
#login-form input:focus { border-color: #1a1a1a; }
.btn-primary {
  width: 100%; padding: 0.875rem; border: none; border-radius: 12px;
  background: #1a1a1a; color: #fff; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; font-family: inherit;
}
.btn-primary:active { opacity: 0.8; }
.error-text { color: #e53e3e; font-size: 0.8rem; text-align: center; min-height: 1.2rem; }

/* === App Header === */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; background: #fff; border-bottom: 1px solid #f0f0f0;
  position: sticky; top: 0; z-index: 100;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}
.header-icon {
  width: 40px; height: 40px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #1a1a1a; transition: background 0.2s;
}
.header-icon:active { background: #f0f0f0; }
.header-tabs { display: flex; background: #f0f0f0; border-radius: 20px; padding: 3px; }
.tab-btn {
  padding: 0.5rem 1.25rem; border: none; background: none; border-radius: 18px;
  font-size: 0.875rem; font-weight: 500; cursor: pointer; color: #666;
  transition: all 0.2s; font-family: inherit;
}
.tab-btn.active { background: #fff; color: #1a1a1a; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* === Views === */
.view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.view.active-view { display: flex; }

/* === Sub Navigation === */
.sub-nav {
  display: flex; gap: 0.5rem; padding: 1rem; overflow-x: auto;
  -webkit-overflow-scrolling: touch; justify-content: center;
}
.sub-nav::-webkit-scrollbar { display: none; }
.sub-nav-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.375rem;
  padding: 0.875rem 1.25rem; border: 1px solid #e8e8e8; border-radius: 12px;
  background: #fff; cursor: pointer; min-width: 90px; flex-shrink: 0;
  transition: all 0.2s; font-size: 0.75rem; font-weight: 500; color: #666;
  font-family: inherit;
}
.sub-nav-card .material-icons-outlined { font-size: 1.25rem; }
.sub-nav-card.active { border-color: #1a1a1a; background: #1a1a1a; color: #fff; }

/* === Sections === */
.section { display: none; flex-direction: column; flex: 1; overflow-y: auto; padding: 0 1rem 1rem; }
.section.active-section { display: flex; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.section-header h2 { font-size: 1.125rem; font-weight: 600; }
.badge {
  background: #e53e3e; color: #fff; font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 10px; min-width: 20px; text-align: center;
}
.badge:empty { display: none; }

/* === Item List === */
.item-list { display: flex; flex-direction: column; }
.item-row {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem 0;
  border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.15s;
}
.item-row:active { background: #f8f8f8; }
.item-row:last-child { border-bottom: none; }
.item-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.item-icon.comms { background: #e8f4fd; color: #0284c7; }
.item-icon.ops { background: #ecfdf5; color: #059669; }
.item-icon.project { background: #fef3c7; color: #d97706; }
.item-icon.task { background: #f3e8ff; color: #7c3aed; }
.item-icon.brainstorm { background: #fef3c7; color: #d97706; }
.item-icon.build { background: #e0f2fe; color: #0284c7; }
.item-icon.golive { background: #fce7f3; color: #db2777; }
.item-icon.live { background: #ecfdf5; color: #059669; }
.item-content { flex: 1; min-width: 0; }
.item-title { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-subtitle { font-size: 0.75rem; color: #888; margin-top: 0.125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: 0.7rem; color: #aaa; flex-shrink: 0; }
.item-phase {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0.2rem 0.5rem; border-radius: 6px; flex-shrink: 0;
}
.item-phase.brainstorm { background: #fef3c7; color: #92400e; }
.item-phase.build { background: #e0f2fe; color: #075985; }
.item-phase.golive { background: #fce7f3; color: #9d174d; }
.item-phase.live { background: #ecfdf5; color: #065f46; }

/* === Card List (Approvals) === */
.card-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.approval-card {
  background: #fff; border: 1px solid #e8e8e8; border-radius: 12px;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.approval-card .card-title { font-size: 0.875rem; font-weight: 600; }
.approval-card .card-desc { font-size: 0.8rem; color: #666; line-height: 1.4; }
.approval-card .card-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.btn-approve, .btn-deny {
  flex: 1; padding: 0.5rem; border: none; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: opacity 0.2s; font-family: inherit;
}
.btn-approve { background: #059669; color: #fff; }
.btn-deny { background: #f0f0f0; color: #666; }
.btn-approve:active, .btn-deny:active { opacity: 0.7; }

/* === Status Grid (Olly) === */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.status-card {
  background: #fff; border: 1px solid #e8e8e8; border-radius: 12px;
  padding: 0.875rem; display: flex; flex-direction: column; gap: 0.25rem;
}
.status-label { font-size: 0.7rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.status-value { font-size: 1.125rem; font-weight: 700; }
.status-indicator { display: flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.green { background: #059669; }
.dot.yellow { background: #d97706; }
.dot.red { background: #e53e3e; }

/* === Empty State === */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem 2rem; text-align: center; flex: 1;
}
.empty-state.hidden { display: none; }
.empty-icon { font-size: 3rem; color: #ccc; margin-bottom: 1rem; }
.empty-state p { color: #888; font-size: 0.875rem; max-width: 260px; line-height: 1.5; }
.btn-dark {
  margin-top: 1rem; padding: 0.75rem 1.5rem; border: none; border-radius: 10px;
  background: #1a1a1a; color: #fff; font-size: 0.875rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-dark:active { opacity: 0.8; }

/* === Agent View === */
.agent-welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem; text-align: center;
}
.agent-welcome h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; color: #1a1a1a; }
.agent-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.chip {
  padding: 0.5rem 1rem; border: 1px solid #e0e0e0; border-radius: 20px;
  background: #fff; font-size: 0.8rem; color: #666; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.chip:active { background: #f0f0f0; border-color: #ccc; }

/* === Compose Bar === */
.compose-bar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem;
  background: #fff; border-top: 1px solid #f0f0f0;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}
.compose-bar input {
  flex: 1; padding: 0.75rem 1rem; border: 1px solid #e8e8e8; border-radius: 24px;
  font-size: 0.9rem; outline: none; background: #f8f8f8; transition: border-color 0.2s; font-family: inherit;
}
.compose-bar input:focus { border-color: #1a1a1a; background: #fff; }
.compose-btn {
  width: 36px; height: 36px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #888; transition: all 0.2s;
}
.compose-btn:active { background: #f0f0f0; }
.send-btn { background: #1a1a1a; color: #fff; }
.send-btn:disabled { background: #e0e0e0; color: #aaa; cursor: default; }
.send-btn:not(:disabled):active { opacity: 0.8; }

/* === Chat Messages === */
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.msg-row { display: flex; flex-direction: column; max-width: 85%; }
.msg-row.user { align-self: flex-end; }
.msg-row.assistant { align-self: flex-start; }
.msg-bubble {
  padding: 0.75rem 1rem; border-radius: 16px; font-size: 0.875rem; line-height: 1.5;
  word-wrap: break-word;
}
.msg-row.user .msg-bubble { background: #1a1a1a; color: #fff; border-bottom-right-radius: 4px; }
.msg-row.assistant .msg-bubble { background: #f0f0f0; color: #1a1a1a; border-bottom-left-radius: 4px; }
.msg-time { font-size: 0.65rem; color: #aaa; margin-top: 0.25rem; padding: 0 0.25rem; }
.msg-row.user .msg-time { text-align: right; }
.typing-indicator { align-self: flex-start; padding: 0.75rem 1rem; background: #f0f0f0; border-radius: 16px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: #aaa; animation: typePulse 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typePulse { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* === Detail Header === */
.detail-header {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
  background: #fff; border-bottom: 1px solid #f0f0f0;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}
.detail-header h2 { flex: 1; font-size: 1.125rem; font-weight: 600; }

/* === Phase Tracker === */
.phase-tracker {
  display: flex; align-items: center; justify-content: center; gap: 0;
  padding: 1.25rem 1.5rem; background: #fff; border-bottom: 1px solid #f0f0f0;
}
.phase-step { display: flex; flex-direction: column; align-items: center; gap: 0.375rem; }
.phase-dot {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid #ddd; background: #fff;
  transition: all 0.3s;
}
.phase-step.completed .phase-dot { border-color: #059669; background: #059669; }
.phase-step.active .phase-dot { border-color: #1a1a1a; background: #1a1a1a; box-shadow: 0 0 0 3px rgba(26,26,26,0.1); }
.phase-step span { font-size: 0.65rem; color: #888; font-weight: 500; }
.phase-step.completed span { color: #059669; }
.phase-step.active span { color: #1a1a1a; font-weight: 600; }
.phase-connector { width: 28px; height: 2px; background: #e0e0e0; margin-bottom: 1.25rem; }
.phase-step.completed ~ .phase-connector { background: #059669; }

/* === FAB === */
.fab {
  position: fixed; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); right: 1.5rem;
  width: 52px; height: 52px; border-radius: 50%; background: #1a1a1a; color: #fff;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: transform 0.2s; z-index: 50;
}
.fab:active { transform: scale(0.9); }

/* === WebSocket Indicator === */
.ws-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #059669;
  animation: wsPulse 2s infinite;
}
.ws-dot.disconnected { background: #e53e3e; animation: none; }
@keyframes wsPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* === Modal === */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative; background: #fff; border-radius: 16px; padding: 1.5rem;
  width: calc(100% - 2rem); max-width: 360px; display: flex; flex-direction: column; gap: 0.75rem;
  z-index: 1;
}
.modal-content h3 { font-size: 1.125rem; font-weight: 700; }
.modal-content input, .modal-content textarea, .modal-content select {
  width: 100%; padding: 0.75rem 1rem; border: 1px solid #e0e0e0; border-radius: 10px;
  font-size: 0.875rem; font-family: inherit; outline: none; resize: none; background: #fff;
}
.modal-content input:focus, .modal-content textarea:focus, .modal-content select:focus { border-color: #1a1a1a; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }
.btn-ghost { padding: 0.5rem 1rem; border: none; background: none; color: #666; font-weight: 500; cursor: pointer; border-radius: 8px; font-family: inherit; }
.btn-ghost:active { background: #f0f0f0; }

/* === Drawer === */
.drawer { display: none; position: fixed; inset: 0; z-index: 1000; }
.drawer.active { display: flex; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.drawer-panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: 280px; background: #fff;
  padding: 1.5rem; display: flex; flex-direction: column; z-index: 1;
  padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.drawer-header h3 { font-size: 1.25rem; font-weight: 700; }
.drawer-items { display: flex; flex-direction: column; gap: 0.25rem; }
.drawer-items hr { border: none; border-top: 1px solid #f0f0f0; margin: 0.5rem 0; }
.drawer-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
  border: none; background: none; cursor: pointer; border-radius: 10px;
  font-size: 0.9rem; color: #1a1a1a; transition: background 0.15s; width: 100%; text-align: left; font-family: inherit;
}
.drawer-item:active { background: #f0f0f0; }
.drawer-item .material-icons-outlined { font-size: 1.25rem; color: #666; }
.drawer-item.danger { color: #e53e3e; }
.drawer-item.danger .material-icons-outlined { color: #e53e3e; }

/* === Icon Button === */
.icon-btn {
  width: 36px; height: 36px; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #666; transition: background 0.15s;
}
.icon-btn:active { background: #f0f0f0; }

/* === Toast === */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #fff; padding: 0.75rem 1.5rem; border-radius: 10px;
  font-size: 0.8rem; font-weight: 500; opacity: 0; transition: opacity 0.3s;
  pointer-events: none; z-index: 9999;
}
.toast.show { opacity: 1; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 0; }

/* === Email Inbox === */
.item-icon.email { background: #fef2f2; color: #dc2626; }
.email-stats {
  display: flex; gap: 0.5rem; padding: 0.75rem 1rem; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stat-pill {
  display: flex; flex-direction: column; align-items: center; gap: 0.125rem;
  padding: 0.625rem 1rem; background: #fff; border: 1px solid #e8e8e8;
  border-radius: 10px; min-width: 80px; flex-shrink: 0;
}
.stat-num { font-size: 1.25rem; font-weight: 700; color: #1a1a1a; }
.stat-label { font-size: 0.65rem; color: #888; text-transform: uppercase; letter-spacing: 0.3px; }
.email-item.priority-high { background: #fef2f2; }
.email-item.priority-high .item-icon.email { background: #fee2e2; color: #b91c1c; }

/* === Project Info Cards === */
.project-info-card {
  background: #fff; border: 1px solid #e8e8e8; border-radius: 12px;
  padding: 1rem; margin-bottom: 0.75rem;
}
.project-info-card .info-label {
  font-size: 0.7rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 0.375rem;
}
.project-info-card .info-value { font-size: 0.875rem; color: #1a1a1a; line-height: 1.5; }
.flow-items { display: flex; flex-direction: column; gap: 0.375rem; margin-top: 0.25rem; }
.flow-item {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #888;
  text-transform: capitalize;
}
.flow-item.completed { color: #059669; }
.flow-item .material-icons-outlined { font-size: 1rem; }

/* === Connected indicator === */
.ws-dot.connected { background: #059669; }


/* === Atlas Voice Conversation UI === */
.compose-btn.recording,
.compose-btn.conversation-active {
  background: #fff3e0;
  color: #b45309;
  box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.22);
}
.compose-btn.conversation-active {
  opacity: 0.72;
  cursor: not-allowed;
}
.conversation-mode-btn {
  position: relative;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.conversation-mode-btn.active {
  background: #111827;
  color: #fff;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.22);
}
.conversation-mode-btn.connecting {
  background: #fef3c7;
  color: #92400e;
  box-shadow: inset 0 0 0 1px rgba(146, 64, 14, 0.22);
}
.conversation-mode-btn.listening {
  background: #dcfce7;
  color: #166534;
  box-shadow: inset 0 0 0 1px rgba(22, 101, 52, 0.22), 0 0 0 4px rgba(34, 197, 94, 0.10);
}
.conversation-mode-btn.speaking {
  background: #dbeafe;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.22), 0 0 0 4px rgba(59, 130, 246, 0.12);
}
.conversation-mode-btn.error {
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: inset 0 0 0 1px rgba(185, 28, 28, 0.22);
}
.conversation-mode-btn .voice-pulse {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
}
.conversation-mode-btn.active .voice-pulse,
.conversation-mode-btn.connecting .voice-pulse,
.conversation-mode-btn.listening .voice-pulse,
.conversation-mode-btn.speaking .voice-pulse {
  opacity: 1;
  animation: atlasVoicePulse 1.25s infinite ease-in-out;
}
.conversation-mode-btn.speaking .voice-pulse { animation-duration: 0.7s; }
.voice-status {
  display: none;
  align-items: center;
  max-width: 180px;
  min-height: 36px;
  padding: 0 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #f3f4f6;
  color: #6b7280;
}
.voice-status.active,
.voice-status.connecting,
.voice-status.error {
  display: inline-flex;
}
.voice-status.connecting { background: #fef3c7; color: #92400e; }
.voice-status.listening { background: #dcfce7; color: #166534; }
.voice-status.speaking { background: #dbeafe; color: #1d4ed8; }
.voice-status.error { background: #fee2e2; color: #b91c1c; }
@keyframes atlasVoicePulse {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50% { transform: scale(1.35); opacity: 1; }
}
@media (max-width: 520px) {
  .voice-status {
    max-width: 112px;
    font-size: 0.68rem;
    padding: 0 0.5rem;
  }
}



/* ============================================
   Phase 1.6 — Nelly Email UI Styles
   ============================================ */

/* Nelly Sub-navigation */
.nelly-subnav {
  display: flex;
  gap: 2px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nelly-subnav-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  position: relative;
}
.nelly-subnav-btn .material-icons-outlined {
  font-size: 1rem;
}
.nelly-subnav-btn.active {
  background: #111;
  color: #fff;
}
.nelly-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0 4px;
}
.nelly-badge:empty { display: none; }

/* Nelly Sections */
.nelly-section { display: none; }
.nelly-section.active-nelly-section { display: block; }

/* Stats bar */
.nelly-stats {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}
.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  background: #f0f0f0;
  border-radius: 12px;
  min-width: 80px;
}
.stat-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111;
}
.stat-label {
  font-size: 0.65rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Email List */
.nelly-email-list {
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}
.nelly-email-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}
.nelly-email-row:hover { background: #fafafa; }
.nelly-email-row:active { background: #f0f0f0; }
.nelly-email-row.priority-high {
  border-left: 3px solid #e74c3c;
  background: #fff5f5;
}
.nelly-email-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e8eaf6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nelly-email-icon .material-icons-outlined {
  font-size: 1.1rem;
  color: #5c6bc0;
}
.nelly-email-row.priority-high .nelly-email-icon {
  background: #fce4ec;
}
.nelly-email-row.priority-high .nelly-email-icon .material-icons-outlined {
  color: #e53935;
}
.nelly-email-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.nelly-email-from {
  font-size: 0.85rem;
  font-weight: 600;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nelly-email-subject {
  font-size: 0.8rem;
  font-weight: 500;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nelly-attach-icon {
  font-size: 0.85rem !important;
  color: #999;
}
.nelly-email-preview {
  font-size: 0.75rem;
  color: #888;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nelly-email-time {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: #aaa;
  margin-top: 2px;
}
.nelly-loading {
  text-align: center;
  color: #aaa;
  padding: 2rem;
  font-size: 0.875rem;
}

/* Search */
.nelly-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}
.nelly-search-bar .material-icons-outlined {
  color: #999;
  font-size: 1.2rem;
}
.nelly-search-bar input[type="text"] {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
}
.nelly-search-bar input:focus { border-color: #5c6bc0; }
.nelly-search-bar select {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  font-size: 0.8rem;
  background: #fff;
  outline: none;
}
.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}
.nelly-search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}
.filter-input {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  flex: 1;
  min-width: 100px;
  outline: none;
}
.filter-input:focus { border-color: #5c6bc0; }
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: #555;
  white-space: nowrap;
}
.nelly-search-meta {
  padding: 8px 16px;
  font-size: 0.75rem;
  color: #888;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
}
.nelly-score {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

/* Compose Form */
.nelly-compose-form {
  padding: 16px;
}
.compose-field {
  margin-bottom: 12px;
}
.compose-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.compose-field input,
.compose-field select,
.compose-field textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.compose-field input:focus,
.compose-field select:focus,
.compose-field textarea:focus {
  border-color: #5c6bc0;
}
.compose-field textarea {
  resize: vertical;
  min-height: 120px;
}
.compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.compose-status {
  padding: 8px 16px;
  font-size: 0.8rem;
}
.nelly-success { color: #2e7d32; }
.nelly-error { color: #e53935; }

/* Email Detail */
.nelly-detail-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 100px);
}
.nelly-detail-headers {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.nelly-detail-field {
  font-size: 0.82rem;
  color: #555;
  padding: 3px 0;
  word-break: break-all;
}
.nelly-detail-field strong {
  color: #333;
  font-weight: 600;
}
.nelly-detail-email-body {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
  word-wrap: break-word;
}
.nelly-email-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.85rem;
  margin: 0;
}
.nelly-detail-attachments,
.nelly-detail-ai,
.nelly-detail-docs {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.nelly-detail-attachments h4,
.nelly-detail-ai h4,
.nelly-detail-docs h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nelly-detail-attachments h4 .material-icons-outlined,
.nelly-detail-ai h4 .material-icons-outlined,
.nelly-detail-docs h4 .material-icons-outlined {
  font-size: 1rem;
}
.nelly-attachment-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 6px;
  text-decoration: none;
  color: #5c6bc0;
  font-size: 0.82rem;
  transition: background 0.15s;
}
.nelly-attachment-link:hover { background: #e8eaf6; }
.nelly-attachment-link .material-icons-outlined { font-size: 1.1rem; }
.nelly-detail-ai p {
  font-size: 0.82rem;
  color: #555;
  line-height: 1.5;
  margin: 0;
}
.nelly-doc-item {
  font-size: 0.82rem;
  color: #555;
  padding: 4px 0;
  border-bottom: 1px solid #eee;
}

/* Detail header actions */
.detail-header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* Reply original */
.reply-original {
  background: #f5f5f5;
  border-left: 3px solid #ccc;
  border-radius: 4px;
  padding: 12px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: #666;
  max-height: 200px;
  overflow-y: auto;
}
.reply-original-header {
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
}
.reply-original-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Mailbox Config */
.nelly-config-list {
  padding: 12px 16px;
}
.nelly-config-list h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin: 0 0 10px 0;
}
.nelly-config-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: #444;
}
.nelly-config-item .material-icons-outlined {
  font-size: 1.1rem;
  color: #5c6bc0;
}
.nelly-tier-badge {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
}
.nelly-rate-info {
  background: #fff8e1;
  color: #f57f17;
}
.nelly-rate-info .material-icons-outlined { color: #f57f17; }

/* Search result highlight */
.nelly-search-result { border-left: 2px solid #5c6bc0; }

/* Responsive */
@media (max-width: 480px) {
  .nelly-subnav { padding: 6px 8px; }
  .nelly-subnav-btn { padding: 6px 10px; font-size: 0.75rem; }
  .nelly-search-bar { flex-wrap: wrap; }
  .nelly-search-bar select { flex: 0 0 auto; }
  .nelly-search-filters { flex-direction: column; }
  .nelly-email-row { padding: 10px 12px; }
  .nelly-detail-body { padding: 12px; }
}

/* ── Wake Word UI ──────────────────────────────────────────────── */

/* Wake word indicator dot on compose bar */
.wake-word-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 0 0.6rem;
  min-height: 32px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 200ms, color 200ms, opacity 200ms;
  user-select: none;
}
.wake-word-indicator.active { display: inline-flex; }
.wake-word-indicator .ww-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  transition: background 200ms;
}
.wake-word-indicator.listening  { background: #f0fdf4; color: #15803d; }
.wake-word-indicator.listening .ww-dot { background: #22c55e; animation: wwPulse 2s infinite ease-in-out; }
.wake-word-indicator.detected   { background: #eff6ff; color: #1d4ed8; }
.wake-word-indicator.detected .ww-dot  { background: #3b82f6; animation: wwFlash 0.4s ease-out 3; }
.wake-word-indicator.paused     { background: #fefce8; color: #a16207; }
.wake-word-indicator.paused .ww-dot    { background: #eab308; opacity: 0.6; }
.wake-word-indicator.stopped    { background: #f3f4f6; color: #6b7280; }
.wake-word-indicator.stopped .ww-dot   { background: #9ca3af; }
.wake-word-indicator.error      { background: #fef2f2; color: #b91c1c; }
.wake-word-indicator.error .ww-dot     { background: #ef4444; }

@keyframes wwPulse {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50%      { transform: scale(1.4); opacity: 1; }
}
@keyframes wwFlash {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.8); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}

/* Wake word settings panel in drawer */
.wake-word-settings {
  padding: 0.75rem 1rem;
  background: #fafafa;
  border-radius: 12px;
  margin-top: 0.25rem;
}
.wake-word-settings .ww-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0;
}
.wake-word-settings .ww-row + .ww-row { border-top: 1px solid #f0f0f0; }
.wake-word-settings .ww-label {
  font-size: 0.82rem; font-weight: 500; color: #374151;
}
.wake-word-settings .ww-sublabel {
  font-size: 0.7rem; color: #9ca3af; margin-top: 2px;
}
.wake-word-settings .ww-privacy {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.7rem; color: #6b7280; padding: 0.4rem 0 0;
}
.wake-word-settings .ww-privacy .material-icons-outlined { font-size: 0.9rem; color: #22c55e; }

/* Toggle switch */
.toggle-switch {
  position: relative; width: 44px; height: 24px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: #d1d5db; cursor: pointer;
  transition: background 200ms;
}
.toggle-switch .slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 200ms;
}
.toggle-switch input:checked + .slider { background: #22c55e; }
.toggle-switch input:checked + .slider::before { transform: translateX(20px); }

/* Sensitivity slider */
.ww-slider {
  width: 100px; height: 4px; -webkit-appearance: none; appearance: none;
  background: #e5e7eb; border-radius: 2px; outline: none;
}
.ww-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #111827; cursor: pointer;
}
.ww-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #111827; cursor: pointer; border: none;
}

/* Wake word detected flash overlay */
.wake-flash-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(circle at center, rgba(59,130,246,0.15) 0%, transparent 70%);
  pointer-events: none;
  animation: wakeFlashIn 0.6s ease-out forwards;
}
.wake-flash-overlay.active { display: block; }
@keyframes wakeFlashIn {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; display: none; }
}

@media (max-width: 520px) {
  .wake-word-indicator { font-size: 0.66rem; padding: 0 0.45rem; }
  .wake-word-settings { padding: 0.5rem 0.75rem; }
}
