/* ========== CSS VARIABLES ========== */
:root {
  --primary: #3b8ac4;
  --primary-light: #5ca8dc;
  --primary-dark: #2a6fa6;
  --secondary: #52a98a;
  --accent: #6bc5c5;
  --warn: #e07a4e;
  --bg: #f0f7fb;
  --bg2: #e4f0f7;
  --card: #ffffff;
  --card2: #f7fbfd;
  --text: #1e3045;
  --text2: #4a6882;
  --text3: #7fa0b8;
  --border: rgba(59,138,196,0.15);
  --shadow: 0 2px 16px rgba(30,48,69,0.08);
  --shadow2: 0 4px 24px rgba(30,48,69,0.14);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --nav-h: 68px;
  --header-h: 54px;
  --transition: 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1e2e;
    --bg2: #0f2234;
    --card: #142a3d;
    --card2: #1a3248;
    --text: #ddeef8;
    --text2: #8ab4ce;
    --text3: #4d7a96;
    --border: rgba(59,138,196,0.2);
    --shadow: 0 2px 16px rgba(0,0,0,0.3);
    --shadow2: 0 4px 24px rgba(0,0,0,0.4);
  }
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* ========== AUTH SCREEN ========== */
#auth-screen {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, #0d1e2e 0%, #0f2e45 60%, #0a2b3d 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.auth-inner {
  width: 100%; max-width: 360px;
  padding: 32px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
}

.auth-logo {
  width: 88px; height: 88px;
  background: rgba(59,138,196,0.12);
  border-radius: 26px;
  border: 1.5px solid rgba(59,138,196,0.3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.auth-logo img { width: 60px; height: 60px; }

.auth-title {
  font-size: 2rem; font-weight: 700;
  color: #ddeef8; letter-spacing: -0.5px;
  text-align: center;
}

.auth-subtitle {
  font-size: 0.95rem; color: #7fa0b8;
  text-align: center; margin-top: -16px;
}

.pin-dots {
  display: flex; gap: 16px; justify-content: center;
}

.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(59,138,196,0.25);
  border: 2px solid rgba(59,138,196,0.5);
  transition: background 0.15s, transform 0.15s;
}

.pin-dot.filled {
  background: #3b8ac4;
  border-color: #3b8ac4;
  transform: scale(1.1);
}

.pin-dot.error {
  background: #c0392b;
  border-color: #c0392b;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  80% { transform: translateX(-4px); }
}

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; width: 100%; max-width: 280px;
}

.pin-btn {
  height: 64px;
  background: rgba(59,138,196,0.1);
  border: 1.5px solid rgba(59,138,196,0.2);
  border-radius: var(--radius-sm);
  color: #ddeef8; font-size: 1.4rem; font-weight: 600;
  transition: background 0.12s, transform 0.1s;
  user-select: none; -webkit-user-select: none;
}

.pin-btn:active { background: rgba(59,138,196,0.3); transform: scale(0.94); }
.pin-btn.del { font-size: 1.1rem; color: #7fa0b8; }

.auth-error {
  font-size: 0.85rem; color: #e07a4e;
  text-align: center; min-height: 20px;
}

/* ========== MAIN APP ========== */
#app {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  background: var(--bg);
}

/* ========== HEADER ========== */
#app-header {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-title {
  font-size: 1.15rem; font-weight: 700;
  color: var(--text);
}

.header-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--text2);
  transition: background var(--transition);
}
.header-btn:active { background: var(--border); }

/* ========== TAB CONTENT ========== */
#tab-container {
  flex: 1; overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--nav-h) + 16px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}

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

/* ========== BOTTOM NAV ========== */
#bottom-nav {
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 0.65rem; font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.02em;
  transition: color var(--transition);
  padding: 6px 2px;
}

.nav-btn .nav-icon { font-size: 1.35rem; line-height: 1; }
.nav-btn.active { color: var(--primary); }
.nav-btn:active { opacity: 0.7; }

/* ========== CARDS ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.card-sm {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}

.card-title {
  font-size: 0.8rem; font-weight: 700;
  color: var(--text3); letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 12px;
}

.card-heading {
  font-size: 1.05rem; font-weight: 700;
  color: var(--text); margin-bottom: 6px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 600;
  transition: all var(--transition);
  user-select: none;
}

.btn-primary {
  background: var(--primary); color: white;
  box-shadow: 0 2px 10px rgba(59,138,196,0.35);
}
.btn-primary:active { background: var(--primary-dark); transform: scale(0.97); }

.btn-secondary {
  background: var(--bg2); color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:active { background: var(--border); transform: scale(0.97); }

.btn-green {
  background: var(--secondary); color: white;
  box-shadow: 0 2px 10px rgba(82,169,138,0.3);
}
.btn-green:active { background: #3d9070; transform: scale(0.97); }

.btn-danger {
  background: rgba(192,57,43,0.1); color: #c0392b;
  border: 1.5px solid rgba(192,57,43,0.2);
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.875rem; }

/* ========== HOME TAB ========== */
.welcome-card {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--accent) 100%);
  color: white; border-radius: var(--radius); padding: 20px 18px;
  margin-bottom: 12px; overflow: hidden; position: relative;
}

.welcome-card::before {
  content: '';
  position: absolute; top: -30px; right: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,0.07);
}

.welcome-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.welcome-sub { font-size: 0.9rem; opacity: 0.85; }

.streak-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.18);
  border-radius: 20px; padding: 4px 12px; margin-top: 12px;
  font-size: 0.85rem; font-weight: 600;
}

.slider-container { margin-bottom: 16px; }
.slider-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.9rem; font-weight: 600; margin-bottom: 8px;
  color: var(--text2);
}
.slider-value {
  font-size: 1.1rem; font-weight: 700; color: var(--primary);
}

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: var(--bg2); border-radius: 3px; border: none;
  padding: 0; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(59,138,196,0.4);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); border: none;
  box-shadow: 0 2px 8px rgba(59,138,196,0.4);
}

.tip-card {
  background: linear-gradient(135deg, rgba(82,169,138,0.08), rgba(59,138,196,0.08));
  border: 1.5px solid rgba(82,169,138,0.2);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.tip-label { font-size: 0.75rem; font-weight: 700; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.tip-text { font-size: 0.95rem; color: var(--text2); line-height: 1.5; font-style: italic; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-btn {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 0.85rem; font-weight: 600; color: var(--text2);
  transition: all var(--transition); box-shadow: var(--shadow);
}
.quick-btn:active { transform: scale(0.96); background: var(--bg2); }
.quick-btn .qb-icon { font-size: 1.6rem; }

/* ========== CHAT ========== */
.chat-wrap {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 0;
}

.chat-messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 14px 80px;
  -webkit-overflow-scrolling: touch;
}

.chat-bubble-wrap {
  display: flex; margin-bottom: 12px;
  align-items: flex-end; gap: 8px;
}

.chat-bubble-wrap.user { flex-direction: row-reverse; }

.bubble-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; flex-shrink: 0;
}

.chat-bubble {
  max-width: 78%; padding: 12px 14px;
  border-radius: 18px; line-height: 1.5; font-size: 0.95rem;
  box-shadow: var(--shadow);
}

.bubble-wrap.ai .chat-bubble {
  background: var(--card);
  border-bottom-left-radius: 6px;
  color: var(--text);
}

.bubble-wrap.user .chat-bubble {
  background: var(--primary);
  border-bottom-right-radius: 6px;
  color: white;
}

.chat-bubble-wrap.user .chat-bubble {
  background: var(--primary); color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble-wrap.ai .chat-bubble {
  background: var(--card); color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble-wrap.ai .bubble-avatar {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.chat-bubble-wrap.user .bubble-avatar {
  background: var(--secondary);
}

.typing-dots { display: flex; gap: 5px; padding: 4px 2px; }
.typing-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text3);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-8px); opacity: 1; }
}

.chat-input-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
  display: flex; gap: 10px; align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.95rem;
  resize: none;
  min-height: 42px; max-height: 120px;
  overflow-y: auto; line-height: 1.4;
  width: auto;
}

.chat-textarea:focus { border-color: var(--primary); }

.chat-send-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: white;
  font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(59,138,196,0.4);
}
.chat-send-btn:active { transform: scale(0.92); }

.chat-header-bar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.provider-tag {
  font-size: 0.75rem; font-weight: 600; color: var(--text3);
  background: var(--bg2); border-radius: 8px; padding: 3px 8px;
}

/* ========== TOOLS ========== */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tool-card {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 18px 14px; box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; cursor: pointer; transition: all var(--transition);
}
.tool-card:active { transform: scale(0.96); background: var(--card2); }
.tool-icon { font-size: 2rem; }
.tool-name { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.tool-desc { font-size: 0.78rem; color: var(--text3); line-height: 1.3; }

/* ========== THOUGHT RECORD ========== */
.tr-step {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.tr-step-number {
  font-size: 0.72rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px;
}
.tr-step-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.tr-step-hint { font-size: 0.82rem; color: var(--text3); margin-bottom: 10px; line-height: 1.4; }

.emotion-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 10px; align-items: center; margin-bottom: 10px;
}
.emotion-row input[type=text] { font-size: 0.9rem; }
.intensity-badge {
  font-size: 0.85rem; font-weight: 700; color: var(--primary);
  background: rgba(59,138,196,0.1); border-radius: 8px;
  padding: 4px 10px; white-space: nowrap;
}

.saved-list { margin-top: 8px; }
.saved-item {
  background: var(--card2); border-radius: var(--radius-xs);
  padding: 12px 14px; margin-bottom: 8px;
  border: 1px solid var(--border); cursor: pointer;
}
.saved-item-date { font-size: 0.75rem; color: var(--text3); margin-bottom: 4px; }
.saved-item-preview { font-size: 0.88rem; color: var(--text2); }

/* ========== EXPOSURE LADDER ========== */
.ladder-item {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 8px;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  transition: all var(--transition);
}
.ladder-item.done { opacity: 0.6; }
.ladder-item.done .ladder-text { text-decoration: line-through; color: var(--text3); }

.ladder-score {
  min-width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 800; flex-shrink: 0;
}

.ladder-score.low { background: var(--secondary); }
.ladder-score.med { background: #e8a040; }
.ladder-score.high { background: #c0392b; }

.ladder-text { flex: 1; font-size: 0.92rem; color: var(--text); }
.ladder-check {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0; transition: all var(--transition);
}
.ladder-check.checked {
  background: var(--secondary); border-color: var(--secondary); color: white;
}

/* ========== CALM EXERCISES ========== */
.calm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calm-card {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 16px 12px; box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; cursor: pointer; transition: all var(--transition);
}
.calm-card:active { transform: scale(0.96); }
.calm-card .calm-icon { font-size: 1.9rem; }
.calm-card .calm-name { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.calm-card .calm-time { font-size: 0.75rem; color: var(--text3); }

/* ========== BREATHING EXERCISE ========== */
.exercise-view {
  display: flex; flex-direction: column;
  align-items: center; padding: 20px 16px;
  gap: 20px;
}

.exercise-title { font-size: 1.1rem; font-weight: 700; color: var(--text); text-align: center; }
.exercise-subtitle { font-size: 0.85rem; color: var(--text3); text-align: center; line-height: 1.4; }

.breath-stage {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 20px 0;
}

.breath-circle-wrap {
  position: relative;
  width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
}

.breath-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0.2;
  animation: ring-pulse 2.5s ease-out infinite;
}
.breath-ring:nth-child(1) { width: 200px; height: 200px; }
.breath-ring:nth-child(2) { width: 180px; height: 180px; animation-delay: 0.4s; }

@keyframes ring-pulse {
  0% { transform: scale(0.9); opacity: 0.25; }
  100% { transform: scale(1.15); opacity: 0; }
}

.breath-circle {
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--primary-light), var(--primary-dark));
  box-shadow: 0 0 30px rgba(59,138,196,0.4);
  transition: transform 1s ease-in-out, box-shadow 0.5s;
  will-change: transform;
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}

.breath-count {
  font-size: 2rem; font-weight: 700; color: white;
  line-height: 1;
}

.breath-phase-label {
  font-size: 1.1rem; font-weight: 700;
  color: var(--text); letter-spacing: 0.02em;
}
.breath-instruction {
  font-size: 0.88rem; color: var(--text3); text-align: center;
}

.breath-cycles {
  font-size: 0.82rem; color: var(--text3);
}

/* ========== PMR ========== */
.pmr-muscle {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
  text-align: center; padding: 8px 0;
}
.pmr-action {
  font-size: 0.9rem; color: var(--text2); text-align: center;
  padding: 6px 20px; line-height: 1.5;
}
.pmr-bar {
  width: 100%; height: 8px; border-radius: 4px;
  background: var(--bg2); overflow: hidden;
}
.pmr-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 1s linear;
  width: 0%;
}
.pmr-progress {
  font-size: 0.8rem; color: var(--text3); text-align: center;
}

/* ========== GROUNDING ========== */
.grounding-step {
  text-align: center; padding: 20px;
}
.grounding-num {
  font-size: 3.5rem; font-weight: 800; color: var(--primary);
  line-height: 1;
}
.grounding-sense {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.05em; margin: 8px 0;
}
.grounding-prompt {
  font-size: 0.92rem; color: var(--text2); line-height: 1.5;
  margin-bottom: 20px;
}
.grounding-inputs { display: flex; flex-direction: column; gap: 8px; }

/* ========== IS IT ANXIETY ========== */
.anxiety-search {
  margin-bottom: 14px;
}

.symptom-card {
  background: var(--card); border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); margin-bottom: 10px;
  overflow: hidden; cursor: pointer; transition: border-color var(--transition);
}
.symptom-card:hover { border-color: var(--primary); }

.symptom-header {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.symptom-emoji { font-size: 1.5rem; flex-shrink: 0; }
.symptom-name { font-size: 1rem; font-weight: 700; color: var(--text); flex: 1; }
.symptom-chevron { font-size: 0.8rem; color: var(--text3); transition: transform var(--transition); }
.symptom-card.open .symptom-chevron { transform: rotate(90deg); }

.symptom-body {
  padding: 0 16px 16px;
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.symptom-card.open .symptom-body { display: block; }

.symptom-explanation { font-size: 0.92rem; color: var(--text2); line-height: 1.55; margin-bottom: 10px; }
.symptom-source { font-size: 0.78rem; color: var(--text3); margin-bottom: 10px; font-style: italic; }
.symptom-reassurance {
  background: rgba(82,169,138,0.1); border-left: 3px solid var(--secondary);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px; font-size: 0.88rem; color: var(--secondary);
  font-weight: 600; line-height: 1.4;
}

/* ========== SMOKING LOG ========== */
.safety-banner {
  background: rgba(59,138,196,0.1); border: 1.5px solid rgba(59,138,196,0.25);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 0.85rem; color: var(--primary); line-height: 1.5;
  margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start;
}

.session-entry {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 8px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.session-entry-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.session-time { font-size: 0.8rem; color: var(--text3); }
.session-puffs { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.session-anxiety-row {
  display: flex; gap: 12px; font-size: 0.82rem; color: var(--text3);
}
.session-anxiety-row span { display: flex; align-items: center; gap: 4px; }
.anx-badge {
  font-weight: 700; padding: 1px 6px; border-radius: 6px;
  background: rgba(59,138,196,0.1); color: var(--primary);
}
.session-notes { font-size: 0.85rem; color: var(--text2); margin-top: 6px; }

/* ========== PROGRESS ========== */
.chart-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
  border: 1px solid var(--border);
}
.chart-title {
  font-size: 0.85rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 12px;
}
.chart-canvas {
  width: 100%; height: 160px; display: block;
  border-radius: var(--radius-xs);
}
.chart-legend {
  display: flex; gap: 16px; margin-top: 10px;
  font-size: 0.78rem; color: var(--text3);
}
.legend-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 4px;
}

.weekly-card {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white; border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
.weekly-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; margin-bottom: 10px; }
.weekly-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.weekly-stat { text-align: center; }
.weekly-stat-num { font-size: 1.6rem; font-weight: 800; }
.weekly-stat-label { font-size: 0.72rem; opacity: 0.8; margin-top: 2px; }

.panic-item {
  background: var(--card); border-radius: var(--radius-xs);
  padding: 12px 14px; margin-bottom: 8px;
  border-left: 3px solid var(--warn);
}
.panic-item-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.panic-date { font-size: 0.78rem; color: var(--text3); }
.panic-intensity { font-size: 0.82rem; font-weight: 700; color: var(--warn); }
.panic-trigger { font-size: 0.88rem; color: var(--text2); }

.win-item {
  background: rgba(82,169,138,0.08); border-radius: var(--radius-xs);
  padding: 12px 14px; margin-bottom: 8px;
  border-left: 3px solid var(--secondary);
  font-size: 0.9rem; color: var(--text2);
}
.win-date { font-size: 0.75rem; color: var(--text3); margin-bottom: 4px; }

/* ========== SETTINGS ========== */
.settings-section-title {
  font-size: 0.78rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 16px 0 8px; display: block;
}

.setting-row {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 8px;
  border: 1px solid var(--border);
}
.setting-label { font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 8px; display: block; }
.setting-desc { font-size: 0.78rem; color: var(--text3); margin-top: 6px; line-height: 1.4; }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
}
.toggle {
  width: 48px; height: 28px; border-radius: 14px;
  background: var(--bg2); border: 2px solid var(--border);
  position: relative; cursor: pointer; transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--primary); border-color: var(--primary); }
.toggle::after {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(20px); }

.signal-steps {
  background: var(--bg2); border-radius: var(--radius-xs);
  padding: 14px 16px; margin-top: 10px;
  font-size: 0.82rem; color: var(--text2); line-height: 1.7;
}
.signal-steps strong { color: var(--text); }

.api-selector {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 12px;
}
.api-option {
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; cursor: pointer;
  transition: all var(--transition);
}
.api-option.active {
  border-color: var(--primary);
  background: rgba(59,138,196,0.08);
}
.api-option-name { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.api-option-model { font-size: 0.72rem; color: var(--text3); margin-top: 3px; }

/* ========== MODAL ========== */
#modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end;
  backdrop-filter: blur(4px);
}

.modal-sheet {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  width: 100%; max-height: 92vh;
  overflow-y: auto;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  animation: slide-up 0.3s ease;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 12px auto 0;
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg2); color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.modal-body {
  padding: 16px 20px;
}

/* ========== TOASTS ========== */
#toast-container {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  z-index: 900; pointer-events: none;
}

.toast {
  background: var(--text); color: var(--card);
  padding: 10px 18px; border-radius: 22px;
  font-size: 0.88rem; font-weight: 600;
  box-shadow: var(--shadow2);
  animation: toast-in 0.25s ease;
  white-space: nowrap;
}

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

/* ========== INSTALL BANNER ========== */
#install-banner {
  position: fixed; bottom: calc(var(--nav-h) + 8px); left: 12px; right: 12px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white; border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow2); z-index: 200;
  animation: slide-up 0.3s ease;
}
.install-text { font-size: 0.88rem; line-height: 1.3; flex: 1; }
.install-btns { display: flex; gap: 8px; }
.install-btn {
  background: rgba(255,255,255,0.2); color: white;
  border-radius: 8px; padding: 6px 12px;
  font-size: 0.82rem; font-weight: 600;
}
.install-btn.primary { background: white; color: var(--primary-dark); }

/* ========== MISC ========== */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text3); font-size: 0.9rem;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 10px; }

.form-row { margin-bottom: 14px; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; display: block; }

.divider {
  height: 1px; background: var(--border); margin: 16px 0;
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.75rem; font-weight: 700; padding: 3px 8px;
  border-radius: 6px;
}
.badge-blue { background: rgba(59,138,196,0.1); color: var(--primary); }
.badge-green { background: rgba(82,169,138,0.1); color: var(--secondary); }

.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }

.scroll-inner { padding: 16px; }

.wins-input-row {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.wins-input-row input { flex: 1; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ========== CHAT EMPTY STATE ========== */
.chat-empty-state {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: 32px 16px 16px;
}

.suggestion-list {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; text-align: left;
}

.suggestion-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.92rem; font-weight: 500;
  color: var(--text2);
  text-align: left;
  transition: all var(--transition);
  box-shadow: var(--shadow);
  line-height: 1.3;
}
.suggestion-btn:active { background: var(--bg2); transform: scale(0.98); border-color: var(--primary); }

/* ========== INTRO CARD ========== */
.intro-card {
  background: rgba(59,138,196,0.06);
  border: 1.5px solid rgba(59,138,196,0.15);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-bottom: 14px;
}
.intro-card-title {
  font-size: 0.75rem; font-weight: 700;
  color: var(--primary); text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 6px;
}
.intro-card-text {
  font-size: 0.87rem; color: var(--text2); line-height: 1.5;
}

/* ========== EXAMPLE CARD ========== */
.example-card {
  background: var(--card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.example-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  font-size: 0.88rem; font-weight: 600; color: var(--text2);
  cursor: pointer; user-select: none;
  transition: background var(--transition);
}
.example-card-header:active { background: var(--bg2); }
.example-chevron { font-size: 1rem; color: var(--text3); transition: transform 0.2s; }
.example-body {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.example-field {}
.example-label {
  font-size: 0.72rem; font-weight: 700;
  color: var(--primary); text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 3px;
}
.example-value {
  font-size: 0.87rem; color: var(--text2); line-height: 1.45;
  font-style: italic;
}

/* ========== CRISIS CARD ========== */
.crisis-card {
  background: linear-gradient(135deg, rgba(224,122,78,0.1), rgba(224,122,78,0.05));
  border: 1.5px solid rgba(224,122,78,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.crisis-label {
  font-size: 0.88rem; font-weight: 800;
  color: var(--warn); margin-bottom: 4px;
}
.crisis-desc {
  font-size: 0.82rem; color: var(--text3);
  margin-bottom: 12px; line-height: 1.4;
}
.crisis-btns {
  display: flex; gap: 8px;
}
.crisis-btn {
  flex: 1;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  cursor: pointer; transition: all var(--transition);
  box-shadow: var(--shadow);
}
.crisis-btn:active { transform: scale(0.96); background: var(--bg2); border-color: var(--primary); }
.crisis-btn-icon { font-size: 1.4rem; }
.crisis-btn-name { font-size: 0.72rem; font-weight: 700; color: var(--text); text-align: center; line-height: 1.2; }
.crisis-btn-time { font-size: 0.65rem; color: var(--text3); }

/* ========== CALM CARD DESCRIPTION ========== */
.calm-card .calm-desc {
  font-size: 0.71rem; color: var(--text3); line-height: 1.3;
  text-align: center; padding: 0 2px;
}

/* ========== ONBOARDING CARD ========== */
.onboarding-card {
  background: linear-gradient(135deg, rgba(59,138,196,0.07), rgba(82,169,138,0.07));
  border: 1.5px solid rgba(59,138,196,0.2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.onboarding-title {
  font-size: 0.92rem; font-weight: 700; color: var(--text);
  margin-bottom: 12px;
}
.onboarding-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.86rem; color: var(--text2); line-height: 1.45;
  margin-bottom: 9px;
}
.onboarding-row:last-child { margin-bottom: 0; }
.onboarding-num {
  min-width: 22px; height: 22px;
  background: var(--primary); color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800;
  flex-shrink: 0; margin-top: 1px;
}
