/* ═══════════════════════════════════════════
   EDITORIAL DESIGN — Libre Baskerville + Outfit
   ═══════════════════════════════════════════ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

*:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a1a;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.4s, color 0.4s;
  color: #faf9f7;
  --amber: #d4a574;
}

body.light {
  background: #ddd5c8;
  color: #1a1a1a;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  visibility: hidden;
}

canvas.visible {
  visibility: visible;
}

/* Theme transition for child elements */
.menu-content, .settings-stack-card, .slipup-screen, .menu-card,
.slipup-btn, .slipup-stat, .slipup-quote-card, .slipup-progress-item,
.consent-card, .onboarding-card, .trigger-btn, .end-stat,
.triggers-back, .badges-back, .settings-back {
  transition: background-color 0.4s, color 0.4s, border-color 0.4s;
}

/* ─── Overlay ─── */
/* ─── Menu pill below cigarette ─── */
.menu-pill {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #faf9f7;
  z-index: 50;
  opacity: 1;
  transition: opacity 0.5s ease, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.menu-pill-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(250,249,247,0.4);
  white-space: nowrap;
  pointer-events: none;
}

body.light .menu-pill-label {
  color: rgba(26,26,26,0.4);
}

.menu-pill:hover,
.menu-pill:focus-visible {
  background: rgba(255,255,255,0.15);
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.menu-pill:active {
  transform: translateX(-50%) scale(0.93);
}

body.light .menu-pill {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.08);
  color: #1a1a1a;
}

body.light .menu-pill:hover,
body.light .menu-pill:focus-visible {
  background: rgba(0,0,0,0.1);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .menu-pill {
    bottom: calc(40px + env(safe-area-inset-bottom));
  }
}

/* ─── Filter Stats ─── */
.filter-stats {
  position: fixed;
  bottom: 52px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.filter-stats.visible {
  opacity: 1;
}

.fs-streak {
  font-family: inherit;
  font-size: 20px;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  letter-spacing: -0.5px;
}

body.light .fs-streak {
  color: rgba(26,26,26,0.45);
}

.fs-streak span {
  font-weight: 700;
}

.fs-money {
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

body.light .fs-money {
  color: rgba(26,26,26,0.45);
}

.fs-lastseen {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

body.light .fs-lastseen {
  color: rgba(26,26,26,0.3);
}

/* ─── Splash Screen ─── */
.splash-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  background: #1a1a1a;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
}
.splash-screen.visible {
  opacity: 1;
  pointer-events: auto;
}
body.light .splash-screen {
  background: #f5f0e8;
}
.splash-content {
  text-align: center;
  max-width: 320px;
}
.splash-emoji {
  font-size: 56px;
  margin-bottom: 12px;
}
.splash-title {
  font-size: 32px;
  font-weight: 700;
  color: #faf9f7;
  margin-bottom: 8px;
}
body.light .splash-title {
  color: #1a1a1a;
}
.splash-tagline {
  font-size: 14px;
  color: rgba(250,249,247,0.5);
  margin-bottom: 32px;
}
body.light .splash-tagline {
  color: rgba(26,26,26,0.5);
}
.splash-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}
.splash-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(250,249,247,0.04);
  border-radius: 10px;
  text-align: left;
}
body.light .splash-feature {
  background: rgba(26,26,26,0.04);
}
.splash-feature-icon {
  font-size: 20px;
}
.splash-feature-text {
  font-size: 14px;
  color: rgba(250,249,247,0.7);
}
body.light .splash-feature-text {
  color: rgba(26,26,26,0.7);
}
.splash-google-btn {
  width: 100%;
  padding: 14px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.splash-google-btn:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.splash-google-btn:active {
  transform: scale(0.98);
}
.splash-google-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.splash-consent {
  margin-top: 16px;
  font-size: 11px;
  color: rgba(250,249,247,0.3);
  line-height: 1.5;
}
body.light .splash-consent {
  color: rgba(26,26,26,0.3);
}
.splash-consent a {
  color: rgba(250,249,247,0.5);
  text-decoration: underline;
}
body.light .splash-consent a {
  color: rgba(26,26,26,0.5);
}
.splash-error {
  display: none;
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(234,67,53,0.1);
  border: 1px solid rgba(234,67,53,0.2);
  border-radius: 8px;
  font-size: 13px;
  color: #EA4335;
  text-align: center;
}

/* ─── First-session Tooltip ─── */
.first-session-tooltip {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  padding: 24px;
}
.first-session-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}
.tooltip-content {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.tooltip-emoji {
  font-size: 40px;
  margin-bottom: 12px;
}
.tooltip-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 18px;
  color: #1a1a1a;
  margin-bottom: 8px;
}
.tooltip-desc {
  font-size: 14px;
  color: rgba(26,26,26,0.6);
  line-height: 1.5;
  margin-bottom: 20px;
}
.tooltip-dismiss {
  width: 100%;
  padding: 12px;
  background: var(--amber);
  color: #1a1a1a;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

/* ─── Menu Overlay ─── */
.menu-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.menu-content {
  width: 100%;
  max-width: 400px;
  background: #1e1e1e;
  border-radius: 20px 20px 0 0;
  padding: 12px 0 40px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-drag-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.menu-overlay.active .menu-content {
  transform: translateY(0);
}

body.light .menu-content {
  background: #fff;
}

body.light .menu-drag-handle {
  background: rgba(0,0,0,0.15);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .menu-content {
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
}

/* Horizontal scroll cards */
.menu-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 20px;
}

.menu-scroll-wrap::-webkit-scrollbar {
  display: none;
}

.menu-scroll {
  display: flex;
  gap: 12px;
  min-width: max-content;
}

.menu-card {
  width: 160px;
  height: 200px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-family: inherit;
  color: inherit;
  text-align: left;
}

.menu-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
}

.menu-card:active {
  transform: scale(0.96);
}

body.light .menu-card {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.06);
}

body.light .menu-card:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.1);
}

.menu-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(212,165,116,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.menu-card-text h3 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.menu-card-text p {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  line-height: 1.4;
}

body.light .menu-card-text h3 {
  color: #1a1a1a;
}

body.light .menu-card-text p {
  color: rgba(26,26,26,0.4);
}

/* Scroll dots */
.menu-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 16px 0 12px;
}

.menu-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: all 0.2s ease;
}

.menu-dot.active {
  background: var(--amber);
  width: 18px;
  border-radius: 3px;
}

body.light .menu-dot {
  background: rgba(0,0,0,0.15);
}

/* User info */
.menu-greeting {
  padding: 0 20px 16px;
}

.menu-greeting-text {
  font-family: 'Libre Baskerville', serif;
  font-size: 22px;
  font-style: italic;
  color: #faf9f7;
  margin-bottom: 4px;
}

body.light .menu-greeting-text {
  color: #1a1a1a;
}

.menu-greeting-sub {
  font-size: 12px;
  color: rgba(250,249,247,0.5);
}

body.light .menu-greeting-sub {
  color: rgba(26,26,26,0.35);
}

/* ─── Onboarding Screen ─── */
/* ─── Trigger Analytics Screen ─── */
/* ─── Shared screen classes ─── */
.full-screen {
  position: fixed;
  inset: 0;
  background: #ddd5c8;
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

body.dark .full-screen {
  background: #1a1a1a;
}

.full-screen.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.screen-back {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  min-height: 48px;
  display: flex;
  align-items: center;
  background: rgba(250,249,247,0.92);
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  color: rgba(26,26,26,0.35);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 10;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

body.dark .screen-back {
  background: rgba(26,26,26,0.92);
  border-color: rgba(250,249,247,0.06);
  color: rgba(250,249,247,0.5);
}

.screen-content {
  padding: 32px 24px 40px;
  max-width: 400px;
  margin: 0 auto;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .screen-content {
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
}

/* ─── Triggers screen ─── */
.triggers-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 24px;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 4px;
}

body.dark .triggers-title {
  color: #faf9f7;
}

.triggers-sub {
  font-size: 13px;
  color: rgba(26,26,26,0.35);
  margin-bottom: 24px;
}

body.dark .triggers-sub {
  color: rgba(250,249,247,0.5);
}

/* Weekly summary card */
/* Horizontal bars */
.triggers-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.trigger-bar-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #1a1a1a;
}

body.dark .trigger-bar-name {
  color: #faf9f7;
}

.trigger-bar-icon {
  font-size: 16px;
}

.trigger-bar-count {
  font-family: 'Libre Baskerville', serif;
  font-size: 14px;
  color: rgba(26,26,26,0.4);
}

body.dark .trigger-bar-count {
  color: rgba(250,249,247,0.4);
}

.trigger-bar-track {
  height: 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  overflow: hidden;
}

body.dark .trigger-bar-track {
  background: rgba(250,249,247,0.06);
}

.trigger-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.trigger-bar-fill.amber { background: var(--amber); }
.trigger-bar-fill.blue { background: rgba(116,165,212,0.7); }
.trigger-bar-fill.green { background: rgba(165,212,116,0.7); }
.trigger-bar-fill.pink { background: rgba(212,116,165,0.7); }
.trigger-bar-fill.gray { background: rgba(0,0,0,0.15); }
body.dark .trigger-bar-fill.gray { background: rgba(250,249,247,0.15); }

.triggers-empty {
  font-size: 13px;
  color: rgba(26,26,26,0.3);
  padding: 20px 0;
}

body.dark .triggers-empty {
  color: rgba(250,249,247,0.5);
}

/* ─── Trigger Selection Screen ─── */
.trigger-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26,26,26,0.95);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 350;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  transform: scale(0.96);
  padding: 40px 24px;
}

@supports (padding-top: env(safe-area-inset-top)) {
  .trigger-screen {
    padding-top: calc(40px + env(safe-area-inset-top));
  }
}

body.light .trigger-screen {
  background: rgba(250,249,247,0.95);
}

.trigger-screen.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.trigger-question {
  font-size: 16px;
  color: rgba(250,249,247,0.6);
  margin-bottom: 24px;
}

body.light .trigger-question {
  color: rgba(26,26,26,0.6);
}

.trigger-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 32px;
}

.trigger-btn {
  padding: 14px;
  background: rgba(250,249,247,0.06);
  border: 1px solid rgba(250,249,247,0.08);
  border-radius: 12px;
  color: rgba(250,249,247,0.7);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

body.light .trigger-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
  color: rgba(26,26,26,0.7);
}

.trigger-btn.selected {
  background: rgba(212,165,116,0.2);
  border-color: rgba(212,165,116,0.5);
  color: var(--amber);
}

body.light .trigger-btn.selected {
  background: rgba(212,165,116,0.15);
  border-color: rgba(212,165,116,0.5);
  color: #b8875a;
}

.trigger-skip {
  opacity: 0.5;
  font-size: 13px;
}

.trigger-skip.selected {
  opacity: 1;
}

/* ─── Milestone Card ─── */
/* ─── Milestone Card (Glow Design) ─── */
.milestone-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
  cursor: pointer;
}

.milestone-card {
  background: rgba(0,0,0,0.8);
  border-radius: 20px;
  padding: 40px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.milestone-glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(212,165,116,0.3) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.milestone-emoji {
  font-size: 56px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.milestone-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 22px;
  color: #faf9f7;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.milestone-desc {
  font-size: 13px;
  color: rgba(250,249,247,0.5);
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.milestone-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.milestone-stat {
  text-align: center;
}

.milestone-stat-num {
  font-family: 'Libre Baskerville', serif;
  font-size: 22px;
  color: var(--amber);
}

.milestone-stat-label {
  font-size: 10px;
  color: rgba(250,249,247,0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.milestone-brand {
  font-size: 11px;
  color: rgba(250,249,247,0.15);
  font-style: italic;
  position: relative;
  z-index: 1;
  margin-bottom: 16px;
}

.milestone-hint {
  font-size: 12px;
  color: rgba(250,249,247,0.2);
  position: relative;
  z-index: 1;
}

body.light .milestone-card {
  background: rgba(255,255,255,0.95);
}

body.light .milestone-title {
  color: #1a1a1a;
}

body.light .milestone-desc {
  color: rgba(26,26,26,0.5);
}

body.light .milestone-stat-label {
  color: rgba(26,26,26,0.3);
}

body.light .milestone-brand {
  color: rgba(26,26,26,0.2);
}

body.light .milestone-hint {
  color: rgba(26,26,26,0.25);
}

body.light .milestone-glow {
  background: radial-gradient(circle, rgba(212,165,116,0.2) 0%, transparent 70%);
}

/* ─── Badge Notification ─── */
.badge-notification {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 600;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

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

.badge-notification-content {
  background: #1e1e1e;
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  max-width: 280px;
  width: 100%;
}

.badge-notification-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.badge-notification-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 22px;
  color: #fff;
  margin-bottom: 16px;
}

.badge-notification-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: rgba(212,165,116,0.15);
  border: 1px solid rgba(212,165,116,0.2);
  border-radius: 16px;
  margin-bottom: 20px;
}

.badge-notification-emoji {
  font-size: 28px;
}

.badge-notification-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 18px;
  color: var(--amber);
}

.badge-notification-close {
  padding: 14px 32px;
  min-height: 48px;
  background: var(--amber);
  border: none;
  border-radius: 12px;
  color: #1a1a1a;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.badge-notification-close:hover {
  background: #c49564;
}

.badge-notification-close:active {
  transform: scale(0.96);
}

body.light .badge-notification-content {
  background: #fff;
}

body.light .badge-notification-title {
  color: #1a1a1a;
}

body.light .badge-notification-name {
  color: #b8875a;
}

/* ─── Badges Screen ─── */
.badges-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 24px;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 4px;
}

body.dark .badges-title {
  color: #faf9f7;
}

.badges-sub {
  font-size: 13px;
  color: rgba(26,26,26,0.5);
  margin-bottom: 24px;
}

body.dark .badges-sub {
  color: rgba(250,249,247,0.5);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 12px;
}

.badge-item {
  text-align: center;
  cursor: pointer;
  min-height: 48px;
  padding: 8px 4px;
}

.badge-item-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.04);
  border: 2px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 6px;
  transition: all 0.2s ease;
  position: relative;
}

body.dark .badge-item-icon {
  background: rgba(250,249,247,0.04);
  border-color: rgba(250,249,247,0.08);
}

.badge-item-icon.earned {
  background: rgba(212,165,116,0.15);
  border-color: var(--amber);
  box-shadow: 0 0 12px rgba(212,165,116,0.2);
}

.badge-item-icon.earned::after {
  content: '✓';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber);
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-item-name {
  font-size: 11px;
  color: rgba(26,26,26,0.3);
  line-height: 1.3;
}

body.dark .badge-item-name {
  color: rgba(250,249,247,0.3);
}

.badge-item-name.earned {
  color: var(--amber);
}

.badges-section {
  margin-bottom: 28px;
}

.badges-section-title {
  font-size: 12px;
  color: rgba(26,26,26,0.25);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  padding-left: 4px;
}

body.dark .badges-section-title {
  color: rgba(250,249,247,0.25);
}

/* Mic permission modal */
.mic-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.mic-modal-content {
  background: #1e1e1e;
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  max-width: 300px;
  width: 100%;
}

body.light .mic-modal-content {
  background: #fff;
}

.mic-modal-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.mic-modal-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 18px;
  color: #faf9f7;
  margin-bottom: 8px;
}

body.light .mic-modal-title {
  color: #1a1a1a;
}

.mic-modal-desc {
  font-size: 13px;
  color: rgba(250,249,247,0.5);
  line-height: 1.5;
  margin-bottom: 20px;
}

body.light .mic-modal-desc {
  color: rgba(26,26,26,0.5);
}

/* Badge detail modal */
.badge-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.badge-modal-content {
  background: #1e1e1e;
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  max-width: 280px;
  width: 100%;
}

body.light .badge-modal-content {
  background: #fff;
}

.badge-modal-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.badge-modal-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 22px;
  color: #fff;
  margin-bottom: 8px;
}

body.light .badge-modal-name {
  color: #1a1a1a;
}

.badge-modal-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 16px;
}

body.light .badge-modal-desc {
  color: rgba(26,26,26,0.5);
}

.badge-modal-status {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

body.light .badge-modal-status {
  color: rgba(26,26,26,0.3);
}

.badge-modal-status.earned {
  color: var(--amber);
}

.badge-modal-close {
  margin-top: 20px;
  padding: 14px 32px;
  min-height: 48px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: rgba(255,255,255,0.5);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.light .badge-modal-close {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
  color: rgba(26,26,26,0.5);
}

.badge-modal-close:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

body.light .badge-modal-close:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
}

/* ─── End Screen (Sticky Note) ─── */
.end-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: #f5f0e8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  transform: scale(0.96);
  padding: 40px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.end-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(0,0,0,0.02) 27px, rgba(0,0,0,0.02) 28px);
  pointer-events: none;
}

.end-screen.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

body.dark .end-screen {
  background: #1a1a1a;
}

body.dark .end-screen::before {
  background: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(250,249,247,0.02) 27px, rgba(250,249,247,0.02) 28px);
}

@supports (padding-top: env(safe-area-inset-top)) {
  .end-screen {
    padding-top: calc(40px + env(safe-area-inset-top));
  }
}

.end-card {
  background: #fff;
  padding: 24px 20px;
  border-radius: 4px;
  box-shadow: 2px 4px 20px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.02);
  transform: rotate(-1deg);
  width: 100%;
  max-width: 300px;
  position: relative;
  text-align: center;
}

body.dark .end-card {
  background: #222;
  box-shadow: 2px 4px 20px rgba(0,0,0,0.3), 0 0 0 1px rgba(250,249,247,0.05);
}

.end-tape {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(2deg);
  width: 60px;
  height: 16px;
  background: rgba(212,165,116,0.3);
  border-radius: 2px;
}

.end-header {
  margin-bottom: 20px;
}

.end-emoji {
  font-size: 32px;
  margin-bottom: 8px;
}

.end-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 20px;
  color: #1a1a1a;
}

body.dark .end-title {
  color: #f5f0eb;
}

.end-sub {
  font-size: 12px;
  color: rgba(26,26,26,0.35);
  margin-top: 4px;
}

body.dark .end-sub {
  color: rgba(245,240,235,0.35);
}

.end-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.end-stat {
  flex: 1;
  text-align: center;
}

.end-stat-num {
  font-family: 'Libre Baskerville', serif;
  font-size: 24px;
  color: var(--amber);
}

.end-stat-lbl {
  font-size: 10px;
  color: rgba(26,26,26,0.3);
  text-transform: uppercase;
  margin-top: 2px;
}

body.dark .end-stat-lbl {
  color: rgba(245,240,235,0.3);
}

.end-triggers {
  margin-bottom: 16px;
  text-align: left;
}

.end-triggers-title {
  font-size: 11px;
  color: rgba(26,26,26,0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

body.dark .end-triggers-title {
  color: rgba(245,240,235,0.3);
}

.end-trigger-list {
  display: flex;
  flex-direction: column;
}

.end-trigger-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.end-trigger-row + .end-trigger-row {
  border-top: 1px solid rgba(0,0,0,0.04);
}

body.dark .end-trigger-row + .end-trigger-row {
  border-top-color: rgba(250,249,247,0.04);
}

.end-trigger-icon {
  font-size: 14px;
  width: 20px;
}

.end-trigger-name {
  font-size: 12px;
  color: rgba(26,26,26,0.6);
  flex: 1;
}

body.dark .end-trigger-name {
  color: rgba(245,240,235,0.6);
}

.end-trigger-count {
  font-size: 11px;
  color: rgba(26,26,26,0.3);
  margin-right: 6px;
}

body.dark .end-trigger-count {
  color: rgba(245,240,235,0.3);
}

.end-trigger-time {
  font-size: 10px;
  color: rgba(26,26,26,0.25);
}

body.dark .end-trigger-time {
  color: rgba(245,240,235,0.25);
}

.end-coping {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(212,165,116,0.08);
  border-radius: 10px;
  border-left: 3px solid var(--amber);
}

body.dark .end-coping {
  background: rgba(212,165,116,0.06);
}

.end-coping-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--amber);
  margin-bottom: 6px;
  font-weight: 600;
}

.end-coping-text {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(26,26,26,0.65);
}

body.dark .end-coping-text {
  color: rgba(245,240,235,0.6);
}

.end-another {
  width: 100%;
  padding: 14px;
  background: var(--amber);
  border: none;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.end-another:hover {
  background: #c49564;
}

.end-another:active {
  transform: scale(0.96);
}

.end-note {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(26,26,26,0.2);
  font-style: italic;
}

body.dark .end-note {
  color: rgba(245,240,235,0.15);
}

/* ─── Slip-up Handling ─── */
.slipup-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(250,249,247,0.98);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  transform: scale(0.96);
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.dark .slipup-screen {
  background: rgba(26,26,26,0.98);
}

.slipup-screen.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.slipup-content {
  text-align: center;
  max-width: 300px;
  width: 100%;
}

.slipup-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.slipup-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 28px;
  font-style: italic;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 8px;
}

body.dark .slipup-title {
  color: #faf9f7;
}

.slipup-title-amber {
  color: var(--amber);
}

.slipup-subtitle {
  font-size: 14px;
  color: rgba(26,26,26,0.5);
  line-height: 1.6;
  margin-bottom: 24px;
}

body.dark .slipup-subtitle {
  color: rgba(250,249,247,0.5);
}

.slipup-stats {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  margin-bottom: 24px;
}

body.dark .slipup-stats {
  border-color: rgba(255,255,255,0.08);
}

.slipup-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

body.dark .slipup-stat {
  border-color: rgba(255,255,255,0.08);
}

.slipup-stat:last-child {
  border-bottom: none;
}

.slipup-stat-label {
  font-size: 12px;
  color: rgba(26,26,26,0.5);
}

body.dark .slipup-stat-label {
  color: rgba(250,249,247,0.5);
}

.slipup-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
}

body.dark .slipup-stat-value {
  color: #faf9f7;
}

.slipup-quote-card {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
}

body.dark .slipup-quote-card {
  border-color: rgba(255,255,255,0.08);
}

.slipup-quote {
  font-family: 'Libre Baskerville', serif;
  font-size: 14px;
  font-style: italic;
  color: rgba(26,26,26,0.7);
  line-height: 1.6;
  margin-bottom: 8px;
  -webkit-user-select: text;
  user-select: text;
}

body.dark .slipup-quote {
  color: rgba(250,249,247,0.7);
}

.slipup-author {
  font-size: 12px;
  color: rgba(26,26,26,0.45);
  text-transform: uppercase;
  letter-spacing: 1px;
}

body.dark .slipup-author {
  color: rgba(250,249,247,0.45);
}

.slipup-progress-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.slipup-progress-item {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

body.dark .slipup-progress-item {
  border-color: rgba(255,255,255,0.08);
}

.slipup-progress-num {
  font-family: 'Libre Baskerville', serif;
  font-size: 28px;
  font-weight: 400;
  color: #1a1a1a;
}

body.dark .slipup-progress-num {
  color: #faf9f7;
}

.slipup-progress-lbl {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(26,26,26,0.45);
  margin-top: 4px;
}

body.dark .slipup-progress-lbl {
  color: rgba(250,249,247,0.45);
}

.slipup-btn {
  display: block;
  width: 100%;
  padding: 16px 40px;
  border-radius: 12px;
  border: 1px solid #1a1a1a;
  background: #1a1a1a;
  color: #faf9f7;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

body.dark .slipup-btn {
  border-color: #faf9f7;
  background: #faf9f7;
  color: #1a1a1a;
}

.slipup-btn:hover,
.slipup-btn:focus-visible {
  opacity: 0.8;
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.slipup-secondary {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-radius: 12px;
  color: rgba(26,26,26,0.4);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 14px 24px;
  min-height: 48px;
  text-transform: uppercase;
  letter-spacing: 1px;
  -webkit-tap-highlight-color: transparent;
}

body.dark .slipup-secondary {
  color: rgba(250,249,247,0.4);
}

.slipup-secondary:hover,
.slipup-secondary:focus-visible {
  color: rgba(26,26,26,0.7);
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

body.dark .slipup-secondary:hover,
body.dark .slipup-secondary:focus-visible {
  color: rgba(250,249,247,0.7);
}

/* Settings Screen */
.settings-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 24px;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 4px;
}

body.dark .settings-title {
  color: #faf9f7;
}

.settings-sub {
  font-size: 13px;
  color: rgba(26,26,26,0.35);
  margin-bottom: 24px;
}

body.dark .settings-sub {
  color: rgba(250,249,247,0.5);
}

/* Card stack design */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-stack-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: left;
  width: 100%;
  color: inherit;
}

body.dark .settings-stack-card {
  background: rgba(250,249,247,0.04);
  border-color: rgba(250,249,247,0.06);
}

.settings-stack-card:hover {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.1);
}

body.dark .settings-stack-card:hover {
  background: rgba(250,249,247,0.07);
  border-color: rgba(250,249,247,0.1);
}

.settings-stack-card:active {
  transform: scale(0.98);
}

.settings-stack-danger {
  border-color: rgba(255,80,80,0.1);
}

body.dark .settings-stack-danger {
  border-color: rgba(255,80,80,0.08);
}

.settings-stack-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(212,165,116,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.settings-stack-text {
  flex: 1;
}

.settings-stack-text h3 {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 2px;
}

body.dark .settings-stack-text h3 {
  color: #faf9f7;
}

.settings-stack-text p {
  font-size: 12px;
  color: rgba(26,26,26,0.3);
}

body.dark .settings-stack-text p {
  color: rgba(250,249,247,0.5);
}

.settings-stack-arrow {
  color: rgba(26,26,26,0.15);
  font-size: 16px;
}

body.dark .settings-stack-arrow {
  color: rgba(250,249,247,0.15);
}

.settings-stack-value {
  font-family: 'Libre Baskerville', serif;
  font-size: 14px;
  color: var(--amber);
}

/* Edit modal */
.settings-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.settings-edit-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-edit-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: calc(100% - 48px);
  max-width: 320px;
}

body.dark .settings-edit-content {
  background: #1e1e1e;
}

.settings-edit-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 18px;
  color: #1a1a1a;
  margin-bottom: 16px;
}

body.dark .settings-edit-title {
  color: #faf9f7;
}

.settings-edit-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  color: #1a1a1a;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.dark .settings-edit-input {
  background: rgba(250,249,247,0.06);
  border-color: rgba(250,249,247,0.1);
  color: #faf9f7;
}

.settings-edit-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(212,165,116,0.2);
}

.settings-edit-actions {
  display: flex;
  gap: 12px;
}

.settings-edit-cancel {
  flex: 1;
  padding: 14px;
  min-height: 48px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  background: transparent;
  color: rgba(26,26,26,0.5);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  cursor: pointer;
}

body.dark .settings-edit-cancel {
  border-color: rgba(250,249,247,0.1);
  color: rgba(250,249,247,0.5);
}

.settings-edit-save {
  flex: 1;
  padding: 14px;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--amber);
  color: #1a1a1a;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.confirm-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 24px;
}

body.light .confirm-desc {
  color: rgba(26,26,26,0.5);
}

.settings-edit-save.confirm-danger {
  background: #e74c3c;
  color: #fff;
}

.settings-edit-save.confirm-danger:hover {
  background: #c0392b;
}

/* Toggle switch */
.settings-toggle {
  position: relative;
  width: 51px;
  height: 31px;
  background: rgba(26, 26, 26, 0.1);
  border: none;
  border-radius: 15.5px;
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

body.dark .settings-toggle {
  background: rgba(250, 249, 247, 0.1);
}

.settings-toggle.active {
  background: #1a1a1a;
}

body.dark .settings-toggle.active {
  background: var(--amber);
}

.settings-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.3s ease;
}

body.dark .settings-toggle::after {
  background: #1a1a1a;
}

.settings-toggle.active::after {
  transform: translateX(20px);
}

.settings-version {
  text-align: center;
  font-size: 11px;
  color: rgba(26, 26, 26, 0.3);
  margin-top: 24px;
}

body.dark .settings-version {
  color: rgba(250, 249, 247, 0.3);
}
