/* ════════════════════════════════════════════════════
   Alexia UI — Futuristic Glassmorphism Design System
   Mobile-first, dark mode, PWA ready
   ════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────── */

:root {
  /* Background palette — deep space blacks */
  --bg-primary: #0a0a0f;
  --bg-secondary: rgba(16, 16, 24, 0.85);
  --bg-tertiary: rgba(22, 22, 34, 0.7);
  --bg-hover: rgba(30, 30, 48, 0.8);

  /* Glass surface */
  --glass: rgba(18, 18, 30, 0.55);
  --glass-border: rgba(120, 100, 255, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  --glass-blur: 20px;

  /* Text */
  --text-primary: #e4e2f0;
  --text-secondary: rgba(200, 196, 220, 0.65);
  --text-muted: rgba(160, 155, 185, 0.4);

  /* Accent spectrum — purple / blue */
  --accent: #7c5cfc;
  --accent-light: #a78bfa;
  --accent-dim: rgba(124, 92, 252, 0.15);
  --accent-glow: rgba(124, 92, 252, 0.25);
  --accent-gradient: linear-gradient(135deg, #7c5cfc, #6ee7ef);

  /* Semantic */
  --success: #34d399;
  --success-dim: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-dim: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.12);

  /* Radii */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(124, 92, 252, 0.08);
  --shadow-inset: inset 0 1px 0 var(--glass-highlight);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;

  /* Layout */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ── Reset & Base ──────────────────────────────── */

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

/* Hide scrollbars globally — keep scroll functionality */
*::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 300;
  letter-spacing: 0.01em;
}

/* ── Glass Mixin via utility class ─────────────── */

.glass {
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-inset), var(--shadow);
}

/* ── Layout ────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 768px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: calc(14px + var(--safe-top));
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 0 20px rgba(124, 92, 252, 0.25);
}

.header-info h1 {
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.header-status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 300;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
  animation: dot-pulse 3s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
  animation: none;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.25s ease;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-light);
  box-shadow: 0 0 16px rgba(124, 92, 252, 0.12);
}

.icon-btn:active { transform: scale(0.9); }

/* ── Chat area ─────────────────────────────────── */

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat::-webkit-scrollbar { width: 3px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: rgba(124, 92, 252, 0.2); border-radius: 4px; }

/* ── Messages ──────────────────────────────────── */

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  animation: msgIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}

.message.assistant .message-avatar {
  background: var(--accent-gradient);
  box-shadow: 0 0 12px rgba(124, 92, 252, 0.2);
}

.message.user .message-avatar { background: var(--bg-tertiary); }

.message-content {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  line-height: 1.6;
  word-wrap: break-word;
  font-weight: 300;
}

.message.assistant .message-bubble {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-inset);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--accent), #6343e8);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 20px rgba(124, 92, 252, 0.25);
  font-weight: 400;
}

.chat-link {
  color: #a78bfa;
  text-decoration: none;
  word-break: break-all;
  border-bottom: 1px dotted rgba(167,139,250,0.4);
  transition: color .15s;
}
.chat-link:hover { color: #c4b5fd; border-bottom-color: #c4b5fd; }

.message-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 0 4px;
  font-weight: 300;
}

.debug-panel {
  margin-top: 4px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.debug-panel summary {
  font-size: 0.65rem;
  color: var(--accent-light);
  cursor: pointer;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  user-select: none;
}
.debug-panel summary:hover {
  background: rgba(124,92,252,0.1);
}
.debug-content {
  font-size: 0.6rem;
  color: var(--text-secondary);
  padding: 8px;
  margin: 0;
  background: rgba(0,0,0,0.3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: 'Inter', monospace;
}

.message.user .message-meta { text-align: right; }

.message-footer { display: flex; align-items: center; gap: 8px; }

.feedback-btns { display: flex; gap: 2px; margin-left: auto; }

.fb-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.25;
  transition: all 0.25s;
  padding: 2px 4px;
}

.fb-btn:hover { opacity: 1; filter: drop-shadow(0 0 6px var(--accent)); }
.fb-done { font-size: 14px; opacity: 0.5; }
.fb-done.bad { filter: hue-rotate(180deg); }

/* ── Typing indicator ──────────────────────────── */

.typing { display: flex; gap: 5px; padding: 14px 18px; }

.typing span {
  width: 7px;
  height: 7px;
  background: var(--accent-light);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ── Action chips ──────────────────────────────── */

.action-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 400;
  margin-top: 6px;
  backdrop-filter: blur(8px);
}

.action-result.success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.15); }
.action-result.error { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.15); }
.action-result.pending { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.15); }

/* ── Quick actions ─────────────────────────────── */

.quick-actions {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.quick-actions.visible { display: flex; }

.quick-chip {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 300;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.quick-chip:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 16px rgba(124, 92, 252, 0.1);
}

.quick-chip:active { transform: scale(0.95); }

/* ── Status cards ──────────────────────────────── */

.status-cards {
  display: none;
  gap: 6px;
  padding: 8px 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
}
.status-cards::-webkit-scrollbar { display: none; }

.status-cards.visible { display: flex; }

.status-card {
  flex: 0 0 auto;
  min-width: 64px;
  max-width: 180px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-inset);
}

.status-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0.5;
}

.status-card:hover {
  border-color: rgba(124, 92, 252, 0.2);
  box-shadow: var(--shadow-inset), 0 0 24px rgba(124, 92, 252, 0.06);
}
.status-card[data-action] { cursor: pointer; }
.status-card[data-action]:hover { border-color: rgba(124, 92, 252, 0.4); }

.status-card .label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-card .value {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 2px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-card .card-sub {
  font-size: 0.6rem;
  color: var(--text-secondary);
  margin-top: 1px;
  font-weight: 300;
  line-height: 1.4;
}

.status-card .unit {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-weight: 300;
}

/* ── Circular progress ring (for status cards) ── */

.progress-ring {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 4px auto 8px;
}

.progress-ring svg {
  transform: rotate(-90deg);
  width: 52px;
  height: 52px;
}

.progress-ring .ring-bg {
  fill: none;
  stroke: rgba(124, 92, 252, 0.08);
  stroke-width: 3;
}

.progress-ring .ring-fill {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-ring .ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ── Timers bar ────────────────────────────────── */

.timers-bar {
  display: none;
  gap: 8px;
  padding: 8px 14px;
  flex-wrap: wrap;
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
}

.timers-bar.visible { display: flex; }

.timer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  border: 1px solid rgba(124, 92, 252, 0.2);
  flex-shrink: 0;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 0 20px rgba(124, 92, 252, 0.06);
}

.timer-chip .timer-icon { font-size: 15px; }

.timer-chip .timer-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 300;
}

.timer-chip .timer-countdown {
  font-size: var(--text-base);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-light);
  min-width: 48px;
  text-align: right;
  text-shadow: 0 0 12px rgba(167, 139, 250, 0.3);
}

.timer-chip.expiring {
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--danger-dim);
}

.timer-chip.expiring .timer-countdown {
  color: var(--danger);
  animation: blink 1s step-end infinite;
  text-shadow: 0 0 12px rgba(248, 113, 113, 0.4);
}

@keyframes blink { 50% { opacity: 0.3; } }

.timer-chip .timer-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  transition: all 0.2s;
}

.timer-chip .timer-cancel:hover { color: var(--danger); }

/* ── Notification bell + popup ─────────────────── */

.notif-bell { position: relative; }

.notif-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.5);
}

.notif-badge.visible { display: flex; }

/* Alert panel tabs */
.notif-tabs { display: flex; gap: 4px; }
.notif-tab {
  background: transparent; border: 1px solid var(--glass-border); border-radius: var(--radius-full);
  color: var(--text-muted); font-size: 12px; padding: 6px 12px; cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.notif-tab:hover { color: var(--text-primary); border-color: var(--text-muted); }
.notif-tab:active { transform: scale(0.95); }
.notif-tab.active { background: var(--accent-gradient); color: white; border-color: transparent; }

/* Snooze buttons */
.snooze-btns { display: flex; gap: 6px; margin-top: 6px; }
.snooze-btn {
  background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.25); border-radius: var(--radius-full);
  color: #fbbf24; font-size: 12px; padding: 6px 14px; cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; min-height: 32px;
}
.snooze-btn:hover { background: rgba(251, 191, 36, 0.25); }
.snooze-btn:active { transform: scale(0.93); background: rgba(251, 191, 36, 0.35); }

/* Alarm control panel */
.alarm-control { padding: 16px; }
.alarm-status {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--bg-tertiary); margin-bottom: 16px;
}
.alarm-status-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.alarm-status-dot.armed { background: #34d399; box-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
.alarm-status-dot.disarmed { background: var(--text-muted); }
.alarm-status-dot.pending { background: #fbbf24; animation: pulse 1s infinite; }
.alarm-status-label { font-size: var(--text-base); font-weight: 500; color: var(--text-primary); }
.alarm-status-time { font-size: var(--text-xs); color: var(--text-muted); margin-left: auto; }
.alarm-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.alarm-mode-btn {
  padding: 14px 10px; border-radius: var(--radius); border: 1px solid var(--glass-border);
  background: var(--bg-tertiary); color: var(--text-primary); font-size: var(--text-base);
  cursor: pointer; transition: all 0.15s; text-align: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; min-height: 48px;
}
.alarm-mode-btn:hover { border-color: var(--accent-light); background: var(--accent-dim); }
.alarm-mode-btn:active { transform: scale(0.96); }
.alarm-mode-btn.active { border-color: var(--accent-light); background: var(--accent-dim); font-weight: 600; }
.alarm-mode-btn.danger { border-color: var(--danger); color: var(--danger); }
.alarm-mode-btn.danger:hover { background: rgba(248, 113, 113, 0.12); }
.alarm-mode-btn.danger:active { background: rgba(248, 113, 113, 0.25); }

/* Visualization (charts + tables) */
.viz-container {
  margin: 8px 0 4px; border-radius: var(--radius); overflow: hidden;
  background: rgba(14, 14, 22, 0.6); border: 1px solid var(--glass-border); padding: 12px;
}
.viz-container canvas { width: 100% !important; max-height: 250px; }
.viz-table {
  width: 100%; border-collapse: collapse; font-size: var(--text-sm); color: var(--text-primary);
}
.viz-table th {
  text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--glass-border);
  color: var(--text-secondary); font-weight: 500; font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.viz-table td { padding: 5px 10px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.viz-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-table tr:hover td { background: rgba(124, 92, 252, 0.05); }
.viz-error { color: var(--danger); font-size: var(--text-xs); padding: 8px; }

/* Snoozed alert item */
.snoozed-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
}
.snoozed-ttl { font-size: var(--text-xs); color: #fbbf24; font-weight: 500; margin-left: auto; }

/* Popup overlay (click-outside to close) */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
}

.popup-overlay.visible { display: block; }

/* Shared popup style */
.popup {
  display: none;
  position: fixed;
  top: 60px;
  right: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: min(420px, calc(100dvh - 120px));
  overflow-y: auto;
  z-index: 100;
  flex-direction: column;
  background: rgba(14, 14, 22, 0.92);
  backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--shadow-glow), 0 0 60px rgba(0, 0, 0, 0.5);
  animation: popupIn 0.2s ease;
}

.popup.visible { display: flex; }

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

.popup-title {
  padding: 14px 18px 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(120, 100, 255, 0.08);
  flex-shrink: 0;
}

.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(120, 100, 255, 0.04);
  transition: background 0.15s;
}

.notif-item:hover { background: rgba(124, 92, 252, 0.04); }
.notif-item:last-child { border-bottom: none; }

.notif-item .notif-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.notif-item .notif-text {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 300;
}

.notif-item .notif-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

.popup-section-label {
  padding: 10px 18px 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.popup-section-label.danger { color: var(--danger); }

.popup-empty {
  padding: 24px 18px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.notif-countdown {
  color: var(--accent-light);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.notif-countdown.planned {
  color: var(--warning);
  font-weight: 500;
}

.alert-pending {
  background: var(--danger-dim);
  border-radius: var(--radius-xs);
  margin: 2px 12px;
  padding: 10px 14px !important;
}

.alert-icon { background: rgba(248, 113, 113, 0.2) !important; }

.timer-cancel.danger { color: var(--danger); }

/* ── Shopping list popup ──────────────────────── */

.shopping-panel {
  /* Uses .popup base style — just add specifics here */
  right: auto;
  left: 12px;
}

.shopping-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(120, 100, 255, 0.05);
}

.shopping-add { display: flex; gap: 8px; }

.shopping-add input {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  width: 160px;
  font-weight: 300;
  transition: border-color 0.25s;
}

.shopping-add input:focus { border-color: var(--accent); box-shadow: 0 0 12px rgba(124, 92, 252, 0.1); }

.shopping-add button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(124, 92, 252, 0.2);
  transition: all 0.2s;
}

.shopping-add button:hover { transform: scale(1.08); }

.shopping-items { overflow-y: auto; padding: 8px 18px; flex: 1; }

.shopping-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(120, 100, 255, 0.05);
  animation: fadeIn 0.2s ease;
}

.shopping-item:last-child { border-bottom: none; }

.shopping-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.shopping-item .item-name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 300;
}

.shopping-item.completed .item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.shopping-item .item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  opacity: 0;
  transition: all 0.2s;
}

.shopping-item:hover .item-remove { opacity: 1; }
.shopping-item .item-remove:hover { color: var(--danger); }

/* ── Input area ────────────────────────────────── */

.input-area {
  padding: 12px 18px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(18, 18, 30, 0.6);
  border-radius: var(--radius-full);
  padding: 6px 6px 6px 18px;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
}

.input-row:focus-within {
  border-color: rgba(124, 92, 252, 0.35);
  box-shadow: 0 0 24px rgba(124, 92, 252, 0.08);
}

.input-row textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 300;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 7px 0;
}

.input-row textarea::placeholder { color: var(--text-muted); font-weight: 300; }

.mic-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  flex-shrink: 0;
}

.mic-btn:hover { color: var(--accent-light); border-color: var(--accent); }
.mic-btn:active { transform: scale(0.9); }

.mic-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 20px rgba(124, 92, 252, 0.3);
}

.mic-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.35); }
  50% { box-shadow: 0 0 0 12px rgba(248, 113, 113, 0); }
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.25s;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(124, 92, 252, 0.2);
}

.send-btn:hover { box-shadow: 0 0 28px rgba(124, 92, 252, 0.35); transform: scale(1.05); }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }

/* ── Voice bar ─────────────────────────────────── */

.voice-bar {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.voice-bar.visible { display: flex; }
.voice-bar.visible + .input-area { display: none; }

.voice-bar-orb {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.voice-orb {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-light), var(--accent));
  opacity: 0.15;
  transition: all 0.4s ease;
}

.voice-orb-core {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  box-shadow: 0 0 24px rgba(124, 92, 252, 0.3), 0 0 48px rgba(124, 92, 252, 0.1);
  transition: all 0.4s ease;
}

/* Ambient ring around orb */
.voice-bar-orb::before {
  content: '';
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(124, 92, 252, 0.1);
  animation: ring-expand 4s ease-in-out infinite;
}

@keyframes ring-expand {
  0%, 100% { transform: scale(0.9); opacity: 0.3; }
  50% { transform: scale(1.15); opacity: 0; }
}

.voice-bar-info { flex: 1; min-width: 0; }

.voice-status {
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.voice-bar-stop {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s;
}

.voice-bar-stop:hover {
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.12);
}

/* Voice orb states */

.voice-orb.listening {
  animation: orb-breathe 3.5s ease-in-out infinite;
  opacity: 0.12;
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); opacity: 0.12; }
  50% { transform: scale(1.2); opacity: 0.22; }
}

.voice-orb.recording {
  animation: orb-record 0.7s ease-in-out infinite;
  background: radial-gradient(circle, #f87171, #dc2626);
  opacity: 0.3;
}

.voice-orb.recording + .voice-orb-core {
  background: linear-gradient(135deg, #f87171, #fca5a5);
  box-shadow: 0 0 28px rgba(248, 113, 113, 0.4), 0 0 56px rgba(248, 113, 113, 0.15);
}

@keyframes orb-record {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.4); opacity: 0.4; }
}

.voice-orb.processing {
  animation: orb-think 2s linear infinite;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-light), #6ee7ef, var(--accent));
  opacity: 0.25;
}

.voice-orb.processing + .voice-orb-core {
  animation: orb-core-pulse 1.2s ease-in-out infinite;
}

@keyframes orb-think {
  from { transform: rotate(0deg) scale(1.15); }
  to { transform: rotate(360deg) scale(1.15); }
}

@keyframes orb-core-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.88); }
}

.voice-orb.speaking {
  animation: orb-speak 1.2s ease-in-out infinite;
  background: radial-gradient(circle, var(--success), #6ee7b7);
  opacity: 0.2;
}

.voice-orb.speaking + .voice-orb-core {
  background: linear-gradient(135deg, var(--success), #6ee7b7);
  box-shadow: 0 0 28px rgba(52, 211, 153, 0.3), 0 0 56px rgba(52, 211, 153, 0.1);
}

@keyframes orb-speak {
  0%, 100% { transform: scale(1.05); opacity: 0.15; }
  50% { transform: scale(1.35); opacity: 0.3; }
}

.voice-orb.follow_up {
  animation: orb-followup 2s ease-in-out infinite;
  background: radial-gradient(circle, var(--accent-light), var(--accent));
  opacity: 0.15;
}

.voice-orb.follow_up + .voice-orb-core {
  background: var(--accent-gradient);
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.3);
}

@keyframes orb-followup {
  0%, 100% { transform: scale(1); opacity: 0.12; }
  50% { transform: scale(1.25); opacity: 0.28; }
}

/* ── Welcome screen ────────────────────────────── */

.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 600;
  margin-bottom: 20px;
  box-shadow: 0 0 40px rgba(124, 92, 252, 0.25), 0 0 80px rgba(124, 92, 252, 0.08);
  animation: welcome-glow 4s ease-in-out infinite;
}

@keyframes welcome-glow {
  0%, 100% { box-shadow: 0 0 40px rgba(124, 92, 252, 0.25), 0 0 80px rgba(124, 92, 252, 0.08); }
  50% { box-shadow: 0 0 60px rgba(124, 92, 252, 0.35), 0 0 100px rgba(124, 92, 252, 0.12); }
}

.welcome h2 {
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.welcome p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 300;
  max-width: 300px;
  line-height: 1.6;
}

/* ── Alarm overlay ─────────────────────────────── */

#alarm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(6, 6, 12, 0.94);
  backdrop-filter: blur(24px);
  align-items: center;
  justify-content: center;
}

#alarm-overlay.visible { display: flex; }

#alarm-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(248, 113, 113, 0.08) 0%, transparent 60%);
  animation: alarm-ambient 2s ease-in-out infinite;
}

@keyframes alarm-ambient {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.alarm-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 48px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.alarm-icon {
  font-size: 72px;
  animation: alarm-shake 0.4s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(248, 113, 113, 0.4));
}

@keyframes alarm-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-18deg); }
  40% { transform: rotate(18deg); }
  60% { transform: rotate(-12deg); }
  80% { transform: rotate(12deg); }
}

.alarm-message {
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--text-primary);
  max-width: 300px;
  line-height: 1.5;
}

.alarm-stop-btn {
  padding: 18px 56px;
  font-size: var(--text-lg);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: white;
  cursor: pointer;
  transition: all 0.25s;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: 0 0 32px rgba(248, 113, 113, 0.3);
}

.alarm-stop-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 0 48px rgba(248, 113, 113, 0.45);
}

.alarm-stop-btn:active { transform: scale(0.95); }

/* ── Responsive ────────────────────────────────── */

@media (min-width: 769px) {
  .app {
    border-left: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--shadow-glow);
  }
}

/* ── HA iframe mode ────────────────────────────── */

body.ha-embed .header { display: none; }
body.ha-embed .app { max-width: 100%; }
