/* ============================================================
   EMDR Companion — calm, minimalist styling
   Dark default, soft warm accents, generous whitespace
   ============================================================ */

:root {
  --bg: #0e1116;
  --bg-elev: #161a22;
  --bg-elev-2: #1d222c;
  --border: #262c38;
  --text: #e6e8ec;
  --text-dim: #9ba3af;
  --text-muted: #6b7280;
  --accent: #a8c8a4;          /* soft sage */
  --accent-warm: #e6c79c;      /* warm sand */
  --accent-glow: rgba(168, 200, 164, 0.25);
  --danger: #d98b8b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --transition: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  /* `dvh` accounts for iOS Safari's collapsing URL bar — without this, the
     layout is taller than the actual visible viewport and content gets cut. */
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ============================================================
   SCREENS
   ============================================================ */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 28px;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.screen-header h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  margin: 0;
}

.header-spacer {
  flex: 1;
}

.voice-mode-toggle.active {
  background: var(--accent-warm);
  color: #1a2218;
  border-color: var(--accent-warm);
  animation: micPulse 2s ease-in-out infinite;
}

.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: 6px 4px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: 0.5;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 0.9; }
}

.voice-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--accent-warm);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--accent-warm);
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.hidden {
  display: none !important;
}

/* ============================================================
   AUTH GATE
   ============================================================ */

.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  overflow-y: auto;
}

.auth-card {
  max-width: 440px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.auth-card .logo {
  margin-bottom: 0;
}

.auth-card .tagline {
  margin: 0 0 16px 0;
}

#clerk-signin-mount {
  width: 100%;
  display: flex;
  justify-content: center;
}

.auth-fineprint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 8px;
  max-width: 360px;
}

.signout-link {
  display: inline-block;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
  padding: 4px 8px;
}

.signout-link:hover {
  color: var(--text-dim);
}

.usage-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   HOME
   ============================================================ */

#screen-home {
  align-items: center;
  /* Removed `justify-content: center` so tall content (welcome-back card +
     theme picker) doesn't get clipped equally at the top and bottom on
     short viewports. .home-inner now fills the height itself. */
}

.home-inner {
  flex: 1;
  max-width: 460px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-block: max(12px, 2.5vh) max(12px, 2vh);
}

.logo {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.4rem;
  margin: 0 0 4px 0;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.tagline {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin: 0;
  font-style: italic;
  line-height: 1.6;
}

.subtagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0 0 4px 0;
  max-width: 420px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.home-suggestion {
  margin-top: 8px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-dim);
  max-width: 380px;
}

.home-suggestion strong {
  color: var(--accent-warm);
  font-weight: 500;
}

/* ============================================================
   THEME PICKER (home screen)
   ============================================================ */

.theme-picker {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.theme-picker-label {
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.theme-swatches {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.theme-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  padding: 0;
  background-clip: padding-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.theme-swatch:hover {
  transform: scale(1.12);
}

.theme-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  color: var(--text);
  user-select: none;
  /* Eliminates the iOS Safari 300ms tap delay and ensures taps register reliably. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #1a2218;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 85%, white);
  box-shadow: 0 0 24px var(--accent-glow);
}

.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--bg-elev-2);
  border-color: var(--accent);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.88rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}

.btn-icon.active {
  background: var(--accent);
  color: #1a2218;
  border-color: var(--accent);
}

/* ============================================================
   INTAKE / CHAT
   ============================================================ */

#screen-intake {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 28px 28px 0 28px;
  overflow: hidden;
}

.chat-window {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 4px 24px 4px;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.98rem;
  line-height: 1.55;
  animation: chatIn 380ms ease;
}

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

.chat-msg.bot {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-top-left-radius: 4px;
}

.chat-msg.user {
  background: var(--accent);
  color: #1a2218;
  align-self: flex-end;
  border-top-right-radius: 4px;
}

.chat-msg .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  padding: 6px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  border-color: var(--accent);
  background: var(--bg);
}

.chip.selected {
  background: var(--accent);
  color: #1a2218;
  border-color: var(--accent);
}

.chat-input-bar {
  flex: 0 0 auto;
  padding: 14px 4px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  resize: none;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.5;
  max-height: 140px;
  outline: none;
  transition: border-color var(--transition);
}

#chat-input:focus {
  border-color: var(--accent);
}

.mic-btn {
  flex-shrink: 0;
}

.mic-btn.listening {
  background: var(--accent-warm);
  color: #1a2218;
  border-color: var(--accent-warm);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 199, 156, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(230, 199, 156, 0); }
}

/* ============================================================
   SESSION
   ============================================================ */

#screen-session {
  align-items: center;
  justify-content: center;
  padding: 0;
  background: radial-gradient(ellipse at center, #161a22 0%, #0e1116 70%);
}

.session-stage {
  width: 100%;
  max-width: 720px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-height: 100vh;
  min-height: 100dvh;
}

.session-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.timer {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 300;
  color: var(--accent);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

.session-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.affirmation-display {
  min-height: 140px;
  max-width: 600px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
}

.affirmation-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1.5;
  color: var(--text);
  opacity: 0;
  transition: opacity 600ms ease;
}

.affirmation-text.visible {
  opacity: 1;
}

/* Bilateral track + dot */

.bilateral-track {
  /* Break out of the 720px session-stage to give the ball a much wider swing */
  width: 92vw;
  max-width: 1100px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.bilateral-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 28px var(--accent-glow), 0 0 56px var(--accent-glow);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  transition: none;
}

.speed-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px 6px 16px;
}

.speed-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-right: 4px;
}

.speed-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}

.speed-btn:hover {
  color: var(--text);
  background: var(--bg-elev-2);
}

.speed-btn.active {
  background: var(--accent);
  color: #1a2218;
  border-color: var(--accent);
}

.speed-btn.auto-changed {
  animation: speedBump 600ms ease;
}

@keyframes speedBump {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%  { box-shadow: 0 0 0 14px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.session-controls {
  display: flex;
  gap: 12px;
}

.voice-cmd-hint {
  margin-top: 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Small one-time tooltip pointing at the voice-mode toggle in the intake header. */
.voice-mode-hint {
  position: absolute;
  top: 56px;
  right: 14px;
  max-width: 240px;
  background: var(--accent);
  color: #1a2218;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
  animation: voiceHintIn 320ms ease both;
  cursor: pointer;
}
.voice-mode-hint[hidden] { display: none; }

.voice-mode-hint-arrow {
  position: absolute;
  top: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  transform: rotate(45deg);
  border-radius: 2px;
}

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

.voice-cmd-status.heard {
  color: var(--accent-warm);
  font-style: normal;
  font-weight: 500;
}

/* Post-session feedback */

.session-feedback {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 18px;
  text-align: center;
}

.session-feedback h2 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 0;
}

.session-feedback p {
  color: var(--text-dim);
  margin: 0 0 16px 0;
}

.feedback-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.feedback-buttons .btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

#feedback-notes {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
}

#feedback-notes:focus {
  border-color: var(--accent);
}

/* ============================================================
   SETTINGS
   ============================================================ */

#screen-settings {
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 120px;
  flex-shrink: 0;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-size: 0.92rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 12px var(--accent-glow);
}

.setting-group input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.setting-group select,
.setting-group input[type="text"],
.setting-group input[type="password"] {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}

.setting-group select:focus,
.setting-group input:focus {
  border-color: var(--accent);
}

.toggle-label {
  display: flex !important;
  align-items: center;
  gap: 12px;
  justify-content: flex-start !important;
  cursor: pointer;
  color: var(--text) !important;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.value-tag {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

.muted {
  color: var(--text-muted);
  font-weight: normal;
  font-size: 0.85rem;
}

.small {
  font-size: 0.82rem;
  margin: 4px 0 0 0;
  line-height: 1.5;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

/* ============================================================
   HISTORY
   ============================================================ */

#screen-history {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.history-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 40px;
}

.history-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item .h-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.history-item .h-affirmations {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
}

.history-item .h-affirmations span {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 10px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.history-item .h-feedback {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}

.history-item .h-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* ============================================================
   INFO BUTTON + "HOW IT WORKS" MODAL
   ============================================================ */

.info-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 5;
  padding: 0;
}

.info-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.06);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 32px 28px 28px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(8px);
  transition: transform 240ms ease;
}

.modal-backdrop.visible .modal-card {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  margin: 0 0 16px 0;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.modal-subtitle {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1rem;
  margin: 22px 0 10px 0;
  color: var(--accent-warm);
  letter-spacing: 0.4px;
}

.modal-lede {
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.7;
  margin: 0 0 14px 0;
}

.modal-body {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.7;
  margin: 0 0 8px 0;
}

.modal-steps {
  margin: 0 0 18px 0;
  padding-left: 22px;
  color: var(--text-dim);
}

.modal-steps li {
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 10px;
}

.modal-steps li strong {
  color: var(--text);
  font-weight: 500;
}

.modal-disclaimer {
  margin-top: 22px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--accent-warm);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.65;
}

.modal-disclaimer strong {
  display: block;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 4px;
}

.modal-disclaimer a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

.modal-disclaimer a:hover {
  border-bottom-style: solid;
}

/* Make body links inside modals match the calm palette instead of default blue. */
.modal-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.modal-body a:hover {
  border-bottom-style: solid;
}

/* Consent modal extras */
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 22px 0 18px 0;
  padding: 12px 14px;
  background: rgba(168, 200, 164, 0.08);
  border: 1px solid rgba(168, 200, 164, 0.25);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}
.consent-checkbox input {
  flex: 0 0 auto;
  margin-top: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}
.modal-card .btn-primary {
  width: 100%;
  margin-top: 4px;
}
.modal-fineprint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin: 16px 0 0 0;
  line-height: 1.5;
}
.modal-fineprint a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 2px;
}

/* Home footer legal links — quiet, single line, dismissible buttons styled as links. */
.home-legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
  margin: 8px 0 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.home-legal-links a,
.home-legal-links .link-button {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: rgba(155, 163, 175, 0.4);
  text-underline-offset: 2px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  font-family: inherit;
}
.home-legal-links a:hover,
.home-legal-links .link-button:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.home-legal-links span { color: var(--text-muted); opacity: 0.55; }

/* Cookie & data notice — small, calm, pinned to the bottom. */
.cookie-notice {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 150;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 240ms ease, transform 240ms ease;
}
.cookie-notice[hidden] { display: none; }
.cookie-notice.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.cookie-notice-inner {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 720px;
  width: 100%;
}
.cookie-notice p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-dim);
  flex: 1;
}
.cookie-notice strong { color: var(--text); font-weight: 500; }
.cookie-notice a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.cookie-notice a:hover { border-bottom-style: solid; }
.cookie-notice .btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}
@media (max-width: 540px) {
  .cookie-notice-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .cookie-notice .btn { width: 100%; }
}

/* Crisis link in the home footer — quiet but always there. */
.crisis-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 12px 0 0 0;
  text-align: center;
}
.crisis-link a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: rgba(155, 163, 175, 0.4);
  text-underline-offset: 2px;
}
.crisis-link a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Settings sub-section title + danger button + help text */
.settings-section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  margin: 4px 0 10px 0;
}
.setting-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 6px 0 0 0;
}
.btn-ghost.danger {
  color: #d99;
  border: 1px solid rgba(220, 130, 130, 0.35);
}
.btn-ghost.danger:hover {
  background: rgba(220, 130, 130, 0.08);
  border-color: rgba(220, 130, 130, 0.6);
}

/* ============================================================
   ORIENTATION HINT (small screens in portrait)
   ============================================================ */

.orientation-hint {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
}

/* JS toggles `.visible` only on the session screen on small portrait phones —
   never on home / intake / history / settings, so it can't intercept taps. */
.orientation-hint.visible {
  display: flex;
}

.orientation-hint-card {
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.orientation-hint-icon {
  font-size: 2.4rem;
  /* gentle rotation animation */
  animation: rotateHint 2.4s ease-in-out infinite;
  display: inline-block;
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(90deg); }
}

.orientation-hint-card h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--accent);
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.4px;
}

.orientation-hint-card p {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
  .screen { padding: 20px; }
  .logo { font-size: 2rem; }
  .timer { font-size: 2.8rem; }
  .affirmation-text { font-size: 1.5rem; }
  .chat-input-bar { padding: 12px 20px 16px; }
  .info-btn { top: 14px; right: 14px; }
  .modal-card { padding: 28px 22px 22px; }
  .modal-title { font-size: 1.3rem; }
}

/* ============================================================
   SESSION SCREEN — phone (portrait + landscape)
   Hero: timer + affirmation + ball stays centered.
   Controls: spaced out at the bottom and visually de-emphasized so
   they don't compete with the affirmation text.
   ============================================================ */
@media (max-width: 820px) {
  .session-stage {
    justify-content: flex-start;
    padding: max(16px, 3vh) 14px max(12px, 2vh);
    gap: max(14px, 1.8vh);
  }

  /* Push the hero block down from the top so it lands near the vertical center,
     and pin the controls to the bottom via margin-top: auto. */
  .session-top { margin-top: auto; }
  .speed-controls { margin-top: auto; }

  .timer { font-size: 2.4rem; letter-spacing: 1.5px; }
  .session-status { font-size: 0.72rem; letter-spacing: 1.2px; }

  .affirmation-display { min-height: 96px; padding: 0 12px; }
  .affirmation-text { font-size: 1.35rem; line-height: 1.45; }

  .bilateral-track { height: 56px; }
  .bilateral-dot {
    width: 28px;
    height: 28px;
    box-shadow: 0 0 22px var(--accent-glow), 0 0 44px var(--accent-glow);
  }

  /* De-emphasize the bottom controls — dim by default, brighten on tap. */
  .speed-controls {
    padding: 4px 8px 4px 12px;
    gap: 4px;
    opacity: 0.45;
    transition: opacity 220ms ease;
  }
  .speed-controls .speed-label { font-size: 0.68rem; letter-spacing: 1px; }
  .speed-controls .speed-btn { padding: 4px 8px; font-size: 0.78rem; }
  .speed-controls:active,
  .speed-controls:focus-within { opacity: 0.95; }

  .session-controls {
    gap: 8px;
    opacity: 0.55;
    transition: opacity 220ms ease;
  }
  .session-controls .btn { padding: 8px 14px; font-size: 0.85rem; }
  .session-controls:active,
  .session-controls:focus-within { opacity: 0.95; }

  .voice-cmd-hint {
    margin-top: 4px;
    font-size: 0.68rem;
    line-height: 1.4;
    opacity: 0.4;
    padding: 0 12px;
  }
}

/* Phones in landscape are short — claw back vertical space aggressively. */
@media (max-width: 980px) and (orientation: landscape) and (max-height: 500px) {
  .session-stage {
    padding: 10px 14px 8px;
    gap: 10px;
  }
  .timer { font-size: 1.8rem; }
  .affirmation-display { min-height: 60px; }
  .affirmation-text { font-size: 1.2rem; }
  .bilateral-track { height: 44px; }
  .bilateral-dot { width: 24px; height: 24px; }
  .voice-cmd-hint { font-size: 0.62rem; opacity: 0.35; }
}
