/* --- Modern OLED Dark Design System (Smoke Free Edition) --- */
:root {
  --bg-primary: #07090e;
  --bg-card: #111622;
  --bg-card-hover: #182030;
  --bg-input: #1a2236;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(56, 189, 248, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #38bdf8;
  --accent-primary-glow: rgba(56, 189, 248, 0.35);
  --accent-success: #10b981;
  --accent-success-glow: rgba(16, 185, 129, 0.35);
  --accent-warning: #f59e0b;
  --accent-danger: #f43f5e;
  --accent-danger-glow: rgba(244, 63, 94, 0.4);

  --sos-btn-grad: radial-gradient(circle at 35% 35%, #fb7185 0%, #e11d48 55%, #9f1239 100%);
  --sos-btn-glow: rgba(225, 29, 72, 0.5);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* App Container */
.app-container {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(75px + var(--safe-bottom));
  position: relative;
}

/* Header */
.app-header {
  padding: calc(16px + var(--safe-top)) 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(7, 9, 14, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
}

.brand-title {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #ffffff 30%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-success);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Content Area & Tabs */
.content-area {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.25s ease forwards;
}

.tab-content.active {
  display: flex;
}

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

/* --- TAB 1: DASHBOARD --- */
.timer-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.timer-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #10b981, #38bdf8, #818cf8);
}

.timer-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.timer-days-counter {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #38bdf8;
  margin-top: 2px;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.timer-display {
  font-size: 2.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  color: #ffffff;
  margin: 2px 0 6px;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.15);
}

.timer-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.timer-subtext {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.edit-date-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.edit-date-pill:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Next Milestone Inside Hero */
.next-badge-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.next-badge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.next-badge-title {
  font-weight: 700;
  color: #fbbf24;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.next-badge-time-lbl {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Giant SOS Button */
.sos-btn-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 18px 0 10px;
  position: relative;
}

.sos-button-wrapper {
  position: relative;
  width: 190px;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sos-pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--sos-btn-glow);
  opacity: 0.4;
  animation: pulseSos 2.4s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

@keyframes pulseSos {
  0% { transform: scale(0.92); opacity: 0.6; }
  50% { transform: scale(1.18); opacity: 0.15; }
  100% { transform: scale(0.92); opacity: 0.6; }
}

.sos-btn {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: none;
  background: var(--sos-btn-grad);
  color: #ffffff;
  box-shadow: 0 10px 32px var(--sos-btn-glow), 0 0 0 6px rgba(244, 63, 94, 0.25);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease;
  position: relative;
  z-index: 2;
  outline: none;
}

.sos-btn:active {
  transform: scale(0.93);
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.7), 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.sos-btn-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.sos-btn-label {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.sos-btn-hint {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Discrete Relapse Link Button */
.relapse-link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  margin-top: 14px;
  padding: 6px 12px;
  transition: color 0.2s ease;
}

.relapse-link-btn:hover {
  color: var(--text-secondary);
}

/* Freedom Metrics Grid */
.freedom-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-box-val {
  font-size: 1.25rem;
  font-weight: 800;
}

.highlight-green { color: #10b981; }
.highlight-blue { color: #38bdf8; }
.highlight-amber { color: #f59e0b; }
.highlight-purple { color: #a855f7; }
.highlight-gold { color: #fbbf24; }

/* --- TAB 2: HEALTH TIMELINE --- */
.section-header-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
}

.section-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.section-counter {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.health-timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.health-milestone-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.health-milestone-card.completed {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, var(--bg-card) 100%);
}

.health-milestone-card.in-progress {
  border-color: rgba(56, 189, 248, 0.35);
}

.milestone-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.milestone-icon-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.milestone-icon {
  font-size: 1.5rem;
}

.milestone-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.milestone-target {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.milestone-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.badge-done {
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.milestone-benefit-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.milestone-progress-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.milestone-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.milestone-remaining-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Cravings Trophies Section */
.cravings-section-header {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.subsection-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.subsection-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.cravings-badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.craving-badge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.craving-badge-card.unlocked {
  border-color: rgba(168, 85, 247, 0.4);
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.08) 0%, var(--bg-card) 100%);
}

.craving-badge-icon {
  font-size: 1.6rem;
}

.craving-badge-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
}

.craving-badge-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.craving-check {
  font-size: 0.68rem;
  font-weight: 700;
  color: #10b981;
}

.craving-lock {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* --- TAB 3: FINANCE & WISHLIST --- */
.finance-highlight-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, var(--bg-card) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

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

.finance-amount {
  font-size: 2.2rem;
  font-weight: 900;
  color: #10b981;
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.finance-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.savings-rate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rate-period {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.rate-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
}

/* Wishlist Section */
.wishlist-section-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.add-wish-form {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wish-form-row {
  display: flex;
  gap: 8px;
}

.icon-select {
  width: 105px;
  padding: 8px 10px;
}

.wish-title-input {
  flex: 1;
}

.wish-price-input {
  flex: 1;
}

.btn-add-wish {
  background: var(--accent-primary);
  color: #07090e;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-add-wish:hover {
  opacity: 0.9;
}

.wishlist-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wishlist-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wishlist-card.achieved {
  border-color: rgba(16, 185, 129, 0.45);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, var(--bg-card) 100%);
}

.wishlist-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wishlist-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wishlist-icon {
  font-size: 1.4rem;
}

.wishlist-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.wishlist-price {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.delete-wish-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.delete-wish-btn:hover {
  color: var(--accent-danger);
}

.wishlist-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.wishlist-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.wishlist-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
}

.wishlist-unlocked-tag {
  color: #10b981;
  font-weight: 700;
}

.wishlist-days-left {
  color: var(--text-secondary);
}

.wishlist-progress-pct {
  font-weight: 700;
  color: var(--text-primary);
}

/* --- TAB 4: SETTINGS --- */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.setting-group.highlight-group {
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 12px;
  border-radius: var(--radius-md);
}

.setting-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.setting-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #ffffff;
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.setting-input:focus {
  border-color: var(--accent-primary);
}

.setting-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border-color);
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
}

.toggle-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 26px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.btn-primary-block {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}

.btn-primary-block:hover {
  opacity: 0.9;
}

.save-alert {
  display: none;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
  font-weight: 600;
}

.save-alert.visible {
  display: block;
}

.action-btn-sm {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

/* Share App Card */
.share-app-card {
  margin-top: 24px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-app-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.share-app-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.share-app-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.share-app-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.share-btn-row {
  display: flex;
  gap: 10px;
}

.btn-share-primary {
  flex: 1;
  background: var(--accent-primary);
  color: #07090e;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.2s;
}

.btn-share-primary:hover {
  opacity: 0.9;
}

.btn-share-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-share-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.danger-zone {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger-outline {
  width: 100%;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.18);
}

/* --- BOTTOM NAVIGATION (4 tabs) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
  height: calc(65px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(11, 15, 24, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.nav-btn span {
  font-size: 0.72rem;
  font-weight: 600;
}

.nav-btn.active {
  color: var(--accent-primary);
}

.nav-btn.active svg {
  stroke: var(--accent-primary);
}

/* --- MODALS --- */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}

.modal-backdrop.active {
  display: flex;
  animation: fadeInModal 0.2s ease forwards;
}

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

.modal-sheet {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-width: 480px;
  width: 100%;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  animation: slideUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-heading {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
}

.modal-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.modal-close-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

/* 1. SOS GUIDED BREATHING MODAL */
.sos-modal-sheet {
  text-align: center;
}

.sos-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sos-modal-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fb7185;
}

.sos-tip-banner {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fecdd3;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.4;
  margin-bottom: 24px;
}

.breathing-guide-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 16px 0 24px;
}

.breathing-circle {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, rgba(16, 185, 129, 0.05) 70%);
  border: 4px solid var(--accent-primary);
  box-shadow: 0 0 35px var(--accent-primary-glow);
  transform: scale(1);
  transition: transform 1s ease-in-out, border-color 0.4s ease, box-shadow 0.4s ease;
}

.breathing-circle.inhale {
  transform: scale(1.42);
  border-color: #38bdf8;
  box-shadow: 0 0 50px rgba(56, 189, 248, 0.6);
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
}

.breathing-circle.hold {
  transform: scale(1.42);
  border-color: #fbbf24;
  box-shadow: 0 0 50px rgba(251, 191, 36, 0.5);
  animation: holdPulse 2s infinite ease-in-out;
}

@keyframes holdPulse {
  0%, 100% { transform: scale(1.42); }
  50% { transform: scale(1.39); }
}

.breathing-circle.exhale {
  transform: scale(0.86);
  border-color: #10b981;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.4);
  transition: transform 8s cubic-bezier(0.4, 0, 0.2, 1);
}

.breathing-inner-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.breathing-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.breathing-countdown {
  font-size: 1.8rem;
  font-weight: 900;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

.breathing-instructions {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 18px;
}

.btn-sos-victory {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 15px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease;
}

.btn-sos-victory:active {
  transform: scale(0.97);
}

/* 2. RELAPSE MODAL */
.relapse-modal-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  text-align: center;
}

.relapse-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.btn-success-block {
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-relapse-reset {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  padding: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-ghost-secondary {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* 3. CELEBRATION MODAL */
.ach-celebrate-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ach-celebrate-icon {
  font-size: 3.5rem;
  animation: bounceAch 0.6s ease;
}

@keyframes bounceAch {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.ach-celebrate-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #fbbf24;
}

.ach-celebrate-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #ffffff;
}

.ach-celebrate-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.ach-celebrate-benefit {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin: 6px 0 14px;
}

.btn-celebrate-close {
  width: 100%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: calc(75px + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  max-width: 90%;
  white-space: normal;
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* PWA Banner */
.pwa-banner {
  display: none;
  background: #1e293b;
  border-bottom: 1px solid var(--border-color);
  padding: calc(8px + var(--safe-top)) 16px 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.pwa-banner.visible {
  display: flex;
}

.pwa-banner-btn {
  background: var(--accent-primary);
  color: #07090e;
  border: none;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* PWA Update Banner */
.pwa-update-banner {
  background: linear-gradient(90deg, #0284c7 0%, #059669 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.pwa-update-banner .pwa-banner-btn {
  background: #ffffff;
  color: #0f172a;
  font-weight: 800;
}

/* App Info & Update Card in Settings */
.app-info-card {
  margin-top: 20px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-info-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.app-info-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.app-info-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.app-info-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.btn-refresh-app {
  width: 100%;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-refresh-app:active {
  background: rgba(56, 189, 248, 0.25);
  transform: scale(0.98);
}

.update-status-msg {
  font-size: 0.78rem;
  color: var(--accent-secondary);
  text-align: center;
  display: none;
}

.update-status-msg.visible {
  display: block;
}

