:root {
  /* ── Lucidity brand palette ── */
  --bg-deep:         #050814;
  --bg-surface:      rgba(15, 22, 41, 0.76);
  --bg-surface-solid:rgba(5, 8, 20, 0.92);
  --bg-raised:       rgba(26, 31, 53, 0.72);
  --glass-border:    rgba(217, 168, 255, 0.16);

  --text-primary:    #ffffff;
  --text-secondary:  #d9d7e6;
  --text-muted:      #89849d;

  /* ── Semantic mode accents (preserved) ── */
  --accent-morning:     #8be7ff;
  --accent-morning-dim: rgba(139, 231, 255, 0.12);
  --accent-morning-glow:rgba(139, 231, 255, 0.38);

  --accent-evening:     #d9a8ff;
  --accent-evening-dim: rgba(217, 168, 255, 0.13);
  --accent-evening-glow:rgba(217, 168, 255, 0.42);

  --accent-coach:       #ec4899;
  --accent-coach-dim:   rgba(236, 72, 153, 0.13);
  --accent-coach-glow:  rgba(236, 72, 153, 0.38);

  --accent-blueprint:      #7c3aed;
  --accent-blueprint-dim:  rgba(124, 58, 237, 0.16);
  --accent-blueprint-glow: rgba(124, 58, 237, 0.38);

  --accent-weekly:      #38BDF8;
  --accent-weekly-dim:  rgba(56, 189, 248, 0.13);
  --accent-weekly-glow: rgba(56, 189, 248, 0.35);

  --accent-monthly:      #A78BFA;
  --accent-monthly-dim:  rgba(167, 139, 250, 0.13);
  --accent-monthly-glow: rgba(167, 139, 250, 0.35);

  --accent-quarterly:      #FB923C;
  --accent-quarterly-dim:  rgba(251, 146, 60, 0.13);
  --accent-quarterly-glow: rgba(251, 146, 60, 0.35);

  --accent-annual:      #FBBF24;
  --accent-annual-dim:  rgba(251, 191, 36, 0.13);
  --accent-annual-glow: rgba(251, 191, 36, 0.35);

  --accent-active:      var(--accent-morning);
  --accent-active-dim:  var(--accent-morning-dim);
  --accent-active-glow: var(--accent-morning-glow);

  --accent-base:     #7c3aed;
  --accent-base-dim: rgba(124, 58, 237, 0.14);

  --success:         #22c55e;
  --success-dim:     rgba(34, 197, 94, 0.12);

  --voice-active:    #8be7ff;
  --voice-active-dim: rgba(139, 231, 255, 0.13);
  --voice-active-glow:rgba(139, 231, 255, 0.38);

  /* ── GravityUI radius scale ── */
  --r-xs: 3px;
  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-2xl:18px;

  --app-height: 100dvh;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-header-height: 72px;
  --app-header-x-padding: 32px;
  --app-header-total-height: calc(var(--app-header-height) + var(--app-safe-top));
  /* VisualViewport offset (iOS URL bar / keyboard). Set by index.html script. */
  --vv-offset-top: 0px;
  /* Space reserved under chat scroll so messages aren’t hidden behind the composer (mobile). */
  --coach-composer-pad: 220px;
  /* Bottom offset stack: tab bar + home indicator + on-screen keyboard inset. */
  --coach-nav-stack: calc(
    56px + env(safe-area-inset-bottom, 0px) + var(--keyboard-inset-bottom, 0px)
  );
}

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

html {
  /* On iPad Chrome / iOS Safari, an inner scroll container's rubber-band
     overscroll can chain up to the document and drag the fixed header off
     screen. Containing the chain at the root keeps the header truly fixed. */
  overscroll-behavior: none;
}

body {
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  height: var(--app-height);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  /* Lock the body to the viewport so the OS-level scroll/keyboard inertia
     never gets a chance to translate the .app-header. position:fixed alone
     isn't enough on iPadOS WebKit when an inner element is scrollable. */
  position: fixed;
  inset: 0;
  width: 100%;
}

/* Base Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  padding-top: var(--app-header-total-height);
  /* Reserve space for the fixed bottom nav + keep it above the keyboard. */
  padding-bottom: calc(
    var(--keyboard-inset-bottom, 0px)
    + 56px
    + env(safe-area-inset-bottom, 0px)
  );
  background:
    radial-gradient(circle at 20% 0%, rgba(124, 58, 237, 0.26), transparent 30rem),
    radial-gradient(circle at 88% 82%, rgba(236, 72, 153, 0.16), transparent 28rem),
    linear-gradient(180deg, #0f1629 0%, var(--bg-deep) 100%);
}

/* ──────────────────────────────────────────────────────────
 * App Header
 * ────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-header-total-height);
  background: var(--bg-surface-solid);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--app-safe-top) var(--app-header-x-padding) 0;
  z-index: 150;
  box-shadow: 0 12px 42px rgba(0,0,0,0.18);
  /* iOS Safari: keep header pinned to the visible (visualViewport) top. */
  transform: translate3d(0, var(--vv-offset-top, 0px), 0);
  will-change: transform;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  color: var(--accent-evening);
  filter: drop-shadow(0 0 14px rgba(217, 168, 255, 0.38));
}

.logo-mark::before,
.begin-mark::before,
.welcome-icon::before {
  content: '';
  width: 100%;
  height: 100%;
  background: currentColor;
  -webkit-mask: url('/brand-mark.svg') center / contain no-repeat;
  mask: url('/brand-mark.svg') center / contain no-repeat;
}

.logo h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.logo h1 span {
  color: var(--text-secondary);
  font-weight: 400;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  min-width: 0;
}

.status-pill {
  font-size: 11.5px;
  font-family: 'JetBrains Mono', monospace;
  padding: 6px 12px;
  border-radius: var(--r-md);
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-date {
  max-width: min(280px, 42vw);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ──────────────────────────────────────────────────────────
 * Voice Toggle Button (header)
 * ────────────────────────────────────────────────────────── */
.voice-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.voice-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.voice-toggle.active {
  background: var(--voice-active-dim);
  color: var(--voice-active);
  border-color: rgba(52, 211, 153, 0.3);
  box-shadow: 0 0 12px var(--voice-active-glow);
}

.voice-toggle .voice-icon-off { display: block; }
.voice-toggle .voice-icon-on { display: none; }
.voice-toggle.active .voice-icon-off { display: none; }
.voice-toggle.active .voice-icon-on { display: block; }

/* ──────────────────────────────────────────────────────────
 * Notification bell (header)
 * ────────────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.notif-bell:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.notif-bell.has-notifications {
  color: var(--text-secondary);
}

.notif-bell.is-open {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Counter badge — soft red, top-right of the bell. Hidden when count is 0. */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  letter-spacing: 0.2px;
  box-shadow: 0 0 0 2px var(--bg-deep);
  pointer-events: none;
}
.notif-badge[hidden] { display: none; }

/* Commitments button — quick access to actionables dashboard */
.commitments-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.commitments-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

/* Avatar button base styles live in nav.css (shared across all pages).
 * Mobile size override is in the @media block lower in this file. */

/* ──────────────────────────────────────────────────────────
 * Notification panel — anchored under the bell
 * ────────────────────────────────────────────────────────── */
.notif-panel {
  position: fixed;
  top: calc(var(--app-header-total-height) + 8px);
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(480px, calc(100dvh - 100px));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  z-index: 100;
  overflow: hidden;
  animation: notifPanelIn 0.18s ease-out;
}
.notif-panel[hidden] { display: none; }

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

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--glass-border);
}

.notif-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.notif-panel-close {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all 0.15s ease;
}
.notif-panel-close:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.notif-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Individual notification row */
.notif-item {
  padding: 10px 12px;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background 0.15s ease;
}
.notif-item + .notif-item { margin-top: 2px; }
.notif-item:hover { background: rgba(255,255,255,0.03); }

.notif-item-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

.notif-item-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.notif-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.notif-item-when {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.15px;
  flex-shrink: 0;
}
.notif-item-when.is-overdue { color: #fb7185; }

.notif-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.notif-action {
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}
.notif-action:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.18);
}
/* Primary action — Check-In. Green accent matches the voice-active treatment
 * elsewhere and feels like "go" rather than "done." */
.notif-action.is-primary {
  color: var(--voice-active);
  border-color: rgba(52,211,153,0.3);
}
.notif-action.is-primary:hover {
  background: var(--voice-active-dim);
  color: var(--voice-active);
  border-color: rgba(52,211,153,0.5);
}

/* ──────────────────────────────────────────────────────────
 * Floating chat action buttons — top-right of chat pane
 * ────────────────────────────────────────────────────────── */
.chat-fab-group {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-fab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(20, 20, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.chat-fab[hidden] { display: none; }
.chat-fab:hover {
  background: rgba(28, 28, 34, 0.95);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-1px);
}
.chat-fab svg { flex-shrink: 0; }
.chat-fab-label { white-space: nowrap; }
.feedback-fab.is-active {
  background: var(--accent-coach-dim);
  color: var(--text-primary);
  border-color: var(--accent-coach);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35), 0 0 12px var(--accent-coach-glow);
}

/* ──────────────────────────────────────────────────────────
 * Main Chat Area
 * ────────────────────────────────────────────────────────── */
.chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
}

.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  /* Stop the rubber-band scroll chain from bubbling up to <body>/<html> on
     iPadOS WebKit; without this the fixed header gets dragged with the
     elastic overscroll when the user pulls the chat past its bounds. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
  /* Helps iOS scroll focused content into view without tucking under the header. */
  scroll-padding-top: calc(var(--app-header-total-height) + 12px);
}

/* Custom Scrollbar */
.chat-scroll-area::-webkit-scrollbar { width: 6px; }
.chat-scroll-area::-webkit-scrollbar-track { background: transparent; }
.chat-scroll-area::-webkit-scrollbar-thumb {  
  background: rgba(255,255,255,0.1); 
  border-radius: 3px; 
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  animation: fadeIn 0.6s ease;
  padding-bottom: 60px; /* offset for chips */
}

.welcome-icon {
  width: 64px;
  height: 64px;
  font-size: 0;
  color: var(--accent-evening);
  opacity: 0.72;
  filter: drop-shadow(0 0 18px rgba(217, 168, 255, 0.36));
}

.welcome-screen h2 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
}

.welcome-screen p {
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.5;
}

/* Actionables Dashboard Section */
.actionables-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--app-header-total-height) + 12px);
}

.actionables-section::-webkit-scrollbar { width: 6px; }
.actionables-section::-webkit-scrollbar-track { background: transparent; }
.actionables-section::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.actionables-section::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.message {
  max-width: 760px;
  padding: 16px 20px;
  line-height: 1.6;
  font-size: 15px;
  animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  margin: 0 auto;
  width: 100%;
}

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

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

.message.user {
  margin-left: auto;
  margin-right: max(calc(50% - 380px), 20px);
  background: rgba(26, 31, 53, 0.78);
  border: 1px solid var(--glass-border);
  border-radius: 16px 16px 4px 16px;
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.message.assistant {
  margin-right: auto;
  margin-left: max(calc(50% - 380px), 20px);
  background: linear-gradient(145deg, var(--accent-active-dim), rgba(217,168,255,0.04));
  border: 1px solid rgba(217,168,255,0.11);
  border-radius: 16px 16px 16px 4px;
  color: var(--text-primary);
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  position: relative;
}

.message.assistant::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
  pointer-events: none;
}

.message.assistant p { margin-bottom: 12px; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant strong { font-weight: 600; color: #fff; }
.message.assistant em { font-style: italic; color: #d4d4db; }
.message.assistant ul, .message.assistant ol { margin-left: 20px; margin-bottom: 12px; }

/* Old History Modifier */
.message.old-history {
  color: var(--text-muted);
  font-style: italic;
}
.message.user.old-history {
  background: rgba(26, 26, 35, 0.3);
  border-color: rgba(255, 255, 255, 0.02);
}
.message.assistant.old-history {
  background: rgba(255, 255, 255, 0.01);
  border-color: rgba(255, 255, 255, 0.02);
}
.message.assistant.old-history strong { color: var(--text-secondary); }
.message.assistant.old-history em { color: var(--text-muted); }

.message.system {
  margin: 10px auto;
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 100px;
  text-align: center;
  max-width: fit-content;
}

.message.system.success {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

.message.system.success.save-link-message {
  padding: 0;
}

.message.system.success .save-link {
  display: block;
  color: inherit;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: inherit;
}

.message.system.success .save-link:hover {
  background: rgba(34, 197, 94, 0.08);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Typing Indicator */
.typing-indicator {
  margin-right: auto;
  margin-left: max(calc(50% - 380px), 20px);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 16px 20px;
  background: var(--accent-active-dim);
  border-radius: 20px 20px 20px 4px;
  animation: fadeIn 0.3s;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--active-accent);
  opacity: 0.6;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); opacity: 1; box-shadow: 0 0 8px var(--active-accent-glow); }
}

/* ──────────────────────────────────────────────────────────
 * Input Area & Mode Chips
 * ────────────────────────────────────────────────────────── */
.input-container {
  padding: 0 40px 40px;
  background: linear-gradient(to top, var(--bg-deep) 62%, rgba(5, 8, 20, 0));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mode-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

/* ── Resume choice chips (shown after vault resume) ─────────────────────── */
.resume-choice-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px auto 6px;
  padding: 0 14px;
  max-width: 720px;
}
.mode-chip.resume-choice {
  padding: 10px 14px;
  font-size: 13.5px;
  border-radius: 999px;
}
.mode-chip.resume-choice.primary {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.45);
  color: rgb(199, 210, 254);
}
.mode-chip.resume-choice.primary:hover {
  background: rgba(99, 102, 241, 0.34);
  color: rgb(224, 231, 255);
}

/* ── Meditation continuation CTA (shown after a Close the Day save) ──────── */
.message.system.meditation-cta {
  background: transparent;
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 10px auto;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meditation-cta-prompt {
  font-size: 0.95rem;
  color: var(--text-secondary, #9494a8);
  line-height: 1.5;
  text-align: center;
}
.meditation-cta-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Nudge bar (pending commitments surfaced above chips) ───────────────── */
/* Stacked layout: top row = badge + time, full-width title, then action row.
   Single-row was unworkable on mobile — title wrapped mid-word and Dismiss
   fell off the right edge. */
.nudge-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto 16px;
  width: 100%;
}
.nudge-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl, 14px);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.2s;
  position: relative;
}
.nudge-card:hover { background: rgba(255, 255, 255, 0.05); }
.nudge-card.overdue   { border-color: rgba(239, 68, 68, 0.35);  box-shadow: 0 0 14px rgba(239, 68, 68, 0.12); }
.nudge-card.due_now   { border-color: rgba(251, 191, 36, 0.45); box-shadow: 0 0 14px rgba(251, 191, 36, 0.15); }
.nudge-card.upcoming  { border-color: rgba(99, 102, 241, 0.25); }

.nudge-card .nudge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nudge-card .nudge-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.nudge-card.overdue  .nudge-badge { background: rgba(239, 68, 68, 0.15);  color: rgb(252, 165, 165); }
.nudge-card.due_now  .nudge-badge { background: rgba(251, 191, 36, 0.15); color: rgb(252, 211, 77);  }
.nudge-card.upcoming .nudge-badge { background: rgba(99, 102, 241, 0.15); color: rgb(165, 180, 252); }
.nudge-card .nudge-time {
  color: var(--text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}
.nudge-card .nudge-text {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.nudge-card .nudge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.nudge-card .nudge-actions button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: var(--r-md, 8px);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  min-height: 32px;
  transition: all 0.15s;
}
.nudge-card .nudge-actions button:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }
.nudge-card .nudge-actions button.primary {
  background: rgba(124, 58, 237, 0.22);
  border-color: rgba(217, 168, 255, 0.45);
  color: var(--accent-evening);
}
.nudge-card .nudge-actions button.primary:hover { background: rgba(124, 58, 237, 0.34); }

/* Tighten on narrower screens — ensure all four buttons can fit without overflow.
   At < 360px the buttons go full-width grid; everything else flexes. */
@media (max-width: 420px) {
  .nudge-card { padding: 10px 12px; }
  .nudge-card .nudge-actions { gap: 5px; }
  .nudge-card .nudge-actions button { padding: 7px 10px; font-size: 12px; }
}

.mode-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 8px 16px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mode-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.mode-chip.active {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.1);
}

.mode-chip.planday.active   { background: var(--accent-morning-dim);   box-shadow: 0 0 12px var(--accent-morning-glow);   border-color: var(--accent-morning); }
.mode-chip.closeday.active  { background: var(--accent-evening-dim);   box-shadow: 0 0 12px var(--accent-evening-glow);   border-color: var(--accent-evening); }
.mode-chip.meditation.active{ background: var(--accent-evening-dim);   box-shadow: 0 0 12px var(--accent-evening-glow);   border-color: var(--accent-evening); }
.mode-chip.coaching.active  { background: var(--accent-coach-dim);     box-shadow: 0 0 12px var(--accent-coach-glow);     border-color: var(--accent-coach); }
.mode-chip.blueprint.active { background: var(--accent-blueprint-dim); box-shadow: 0 0 12px var(--accent-blueprint-glow); border-color: var(--accent-blueprint); }
.mode-chip.weekly.active    { background: var(--accent-weekly-dim);    box-shadow: 0 0 12px var(--accent-weekly-glow);    border-color: var(--accent-weekly); }
.mode-chip.monthly.active   { background: var(--accent-monthly-dim);   box-shadow: 0 0 12px var(--accent-monthly-glow);   border-color: var(--accent-monthly); }
.mode-chip.quarterly.active { background: var(--accent-quarterly-dim); box-shadow: 0 0 12px var(--accent-quarterly-glow); border-color: var(--accent-quarterly); }
.mode-chip.annual.active    { background: var(--accent-annual-dim);    box-shadow: 0 0 12px var(--accent-annual-glow);    border-color: var(--accent-annual); }
.mode-chip.feedback.active  { background: var(--accent-coach-dim);     box-shadow: 0 0 12px var(--accent-coach-glow);     border-color: var(--accent-coach); }

.mode-chip .icon { font-size: 15px; filter: grayscale(1) opacity(0.7); }
.mode-chip.active .icon { filter: grayscale(0) opacity(1); }

.input-wrapper {
  width: 100%;
  max-width: 800px;
  position: relative;
  background: rgba(5, 8, 20, 0.88);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-2xl);
  padding: 4px;
  display: flex;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-active);
  box-shadow: 0 12px 34px rgba(0,0,0,0.38), 0 0 0 3px var(--accent-active-dim);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  display: block;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  /* Two wrapped lines of placeholder + tiny slack; autoResize() sets exact height after layout */
  padding: 12px 20px;
  resize: none;
  min-height: calc(2 * 22px + 4px);
  max-height: 200px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  overflow-y: hidden;
  /* iOS: keep scroll-into-view from tucking the caret under the fixed header. */
  scroll-margin-top: calc(var(--app-header-total-height) + 16px);
}

textarea::placeholder { color: var(--text-muted); }

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.action-btn {
  border: none;
  border-radius: var(--r-lg);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--active-accent);
  color: #000;
  box-shadow: 0 4px 12px var(--active-accent-glow);
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--active-accent-glow);
}

.send-btn:disabled {
  background: var(--bg-raised);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.save-btn {
  padding: 0 16px;
  height: 40px;
  background: var(--success-dim);
  color: var(--success);
  font-size: 14px;
}

.save-btn:hover {
  background: rgba(16, 185, 129, 0.25);
  transform: translateY(-2px);
}

/* ──────────────────────────────────────────────────────────
 * Mic Button
 * ────────────────────────────────────────────────────────── */
.mic-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  /* Suppress iOS long-press behaviors so press-and-hold for barge-in doesn't
     trigger the callout, drag preview, force-touch lift, or text magnifier.
     Belt-and-suspenders — different iOS versions/settings honor different
     subsets of these properties. */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
}
/* Apply suppression to ALL descendants too — iOS sometimes detects the
   long-press on inner SVG elements rather than the button itself, which
   bypasses the rules above. */
.mic-btn,
.mic-btn * {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
  -webkit-tap-highlight-color: transparent !important;
  pointer-events: none;
}
.mic-btn { pointer-events: auto; }   /* the button itself stays interactive */

.mic-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.mic-btn .mic-icon-active { display: none; }
.mic-btn .mic-icon-default { display: block; }

/* Recording state */
.mic-btn.recording {
  background: rgba(239, 68, 68, 0.2);
  color: #EF4444;
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  animation: micPulse 1.5s ease-in-out infinite;
}

.mic-btn.recording .mic-icon-active { display: block; }
.mic-btn.recording .mic-icon-default { display: none; }

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Stop audio button */
.stop-audio-btn {
  width: 40px;
  height: 40px;
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 50%;
}

.stop-audio-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ──────────────────────────────────────────────────────────
 * Voice Status Indicator
 * ────────────────────────────────────────────────────────── */
.voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.voice-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.voice-status.listening .voice-status-dot {
  background: #EF4444;
  animation: statusPulse 1s ease-in-out infinite;
}

.voice-status.processing .voice-status-dot {
  background: var(--active-accent);
  animation: statusPulse 0.6s ease-in-out infinite;
}

.voice-status.speaking .voice-status-dot {
  background: var(--voice-active);
  animation: statusPulse 1.2s ease-in-out infinite;
}

.voice-status.error .voice-status-dot {
  background: #EF4444;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

/* Discrete Token Counter */
.discrete-token-counter {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.5;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  transition: opacity 0.3s ease;
}

.discrete-token-counter:hover {
  opacity: 1;
}

/* ──────────────────────────────────────────────────────────
 * Responsive — Mobile First
 * ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --app-header-height: 64px;
    --app-header-x-padding: 18px;
  }

  .header-status {
    gap: 8px;
  }

  .status-pill.status-date {
    max-width: min(180px, 34vw);
  }
}

/* Coach: fixed composer + chat bottom padding — up to iPad portrait width. */
@media (max-width: 1024px) {
  .app-layout .chat-container .chat-scroll-area {
    padding-bottom: calc(var(--coach-composer-pad) + 8px);
    scroll-padding-bottom: calc(var(--coach-composer-pad) + 8px);
  }

  .app-layout .chat-container .input-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--coach-nav-stack);
    z-index: 140;
    padding: 10px 12px 12px;
    margin: 0;
    max-height: min(52vh, 440px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(to top, var(--bg-deep) 78%, rgba(13, 13, 15, 0));
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.38);
  }
}

@media (max-width: 768px) {
  :root {
    --app-header-x-padding: 18px;
  }

  .logo {
    gap: 12px;
  }

  .logo-mark {
    width: 34px;
    height: 34px;
    font-size: 0;
    border-radius: 0;
  }

  .logo h1 {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 17px;
    line-height: 1;
    letter-spacing: 0.18em;
  }

  .logo h1 span {
    display: block;
    color: var(--text-secondary);
    font-weight: 400;
  }

  .header-status {
    gap: 6px;
  }

  .status-pill.status-date.date-compact {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    max-width: none;
    min-width: 42px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 13px;
    line-height: 1;
  }

  .date-weekday {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .date-monthday {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
  }

  /* Bigger header touch targets */
  .voice-toggle,
  .notif-bell,
  .commitments-btn,
  .avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-lg);
  }
  .avatar-btn { border-radius: 50%; }
  .avatar-initials { font-size: 13.5px; }

  /* Floating chat actions: shrink to icon-only on small screens to leave room for content */
  .chat-fab-group {
    top: 10px;
    right: 12px;
  }
  .chat-fab {
    padding: 9px;
  }
  .chat-fab-label { display: none; }

  /* Notification panel: pad against the new mobile right offset */
  .notif-panel {
    right: 12px;
  }

  .chat-scroll-area { padding: 16px; gap: 16px; }

  /* Mode chips — full-width rows, tall enough to tap easily */
  .mode-chips-container {
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 800px;
  }
  .mode-chip {
    justify-content: center;
    padding: 13px 20px;
    font-size: 14.5px;
    border-radius: var(--r-xl);
  }
  .mode-chip .icon { font-size: 18px; }

  .message { padding: 14px 16px; font-size: 15px; }
  .message.user, .message.assistant { margin-left: 0; margin-right: 0; }
  .typing-indicator { margin-left: 0; }

  .input-wrapper { border-radius: var(--r-2xl); }
  textarea { padding: 12px 16px; font-size: 16px; line-height: 22px; min-height: calc(2 * 22px + 4px); }

  /* Send & stop buttons */
  .send-btn,
  .stop-audio-btn {
    width: 48px;
    height: 48px;
  }

  /* Mic button — large and prominent on mobile */
  .mic-btn {
    width: 56px;
    height: 56px;
    background: var(--voice-active-dim);
    color: var(--voice-active);
    border-color: rgba(52, 211, 153, 0.35);
    box-shadow: 0 0 16px var(--voice-active-glow);
    border-radius: 50%;
  }
  .mic-btn:active,
  .mic-btn.recording {
    background: rgba(239, 68, 68, 0.2);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
  }
  .mic-btn svg {
    width: 24px;
    height: 24px;
  }
}

/* Extra small phones */
@media (max-width: 380px) {
  :root { --app-header-x-padding: 18px; }
  .logo { gap: 12px; }
  .logo-mark { width: 34px; height: 34px; }
  .logo h1 { font-size: 17px; letter-spacing: 0.18em; }
  .status-pill.status-date.date-compact {
    min-width: 38px;
    font-size: 12px;
  }
  .date-monthday { font-size: 12px; }
  .voice-toggle,
  .notif-bell,
  .commitments-btn,
  .avatar-btn {
    width: 34px;
    height: 34px;
  }
  .chat-scroll-area {
    padding: 12px;
    /* Don’t reset padding shorthand — keep room under fixed composer (768px block). */
    padding-bottom: calc(var(--coach-composer-pad) + 8px);
  }
  .app-layout .chat-container .input-container { padding: 8px 8px 12px; }
  .mode-chip { padding: 12px 16px; font-size: 14px; }
}
