:root {
  --bg: #0d0d0d;
  --card: #1a1a1a;
  --card-alt: #242424;
  --text: #f5f2ea;
  --text-dim: #a3a3a3;
  --hot-pink: #ff2d6e;
  --electric-purple: #b026ff;
  --acid-green: #c6ff00;
  --border: #333;
  --ember: #ff5b3d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); /* space for tab bar + home indicator */
  padding-top: env(safe-area-inset-top, 0px);
}

.pride-stripe {
  display: flex;
  width: 100%;
  height: 5px;
  flex-shrink: 0;
}
.pride-stripe span { flex: 1; }

.screen { padding: 20px; padding-bottom: 60px; }
.hidden { display: none !important; }

h1.title { color: var(--hot-pink); font-size: 42px; font-weight: 900; letter-spacing: 2px; margin: 20px 0 4px; }
.subtitle { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }

label.field-label { display: block; color: var(--text); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type="number"], input[type="text"] {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 16px;
  margin-bottom: 16px;
}

.tone-option, .settings-tone-option {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.tone-option.active, .settings-tone-option.active { border-color: var(--hot-pink); background: var(--card-alt); }
.tone-option .t-label { font-weight: 700; font-size: 14px; }
.tone-option .t-blurb { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.btn-primary {
  background: var(--hot-pink);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px;
  width: 100%;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-top: 10px;
  cursor: pointer;
}
.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  cursor: pointer;
}
.btn-danger {
  background: transparent;
  color: #ff4d4d;
  border: 1px solid #ff4d4d;
  border-radius: 14px;
  padding: 14px;
  width: 100%;
  font-weight: 700;
  font-size: 13px;
  margin-top: 20px;
  cursor: pointer;
}

/* Home screen */
.date-label { color: var(--text-dim); font-size: 12px; margin-top: 8px; }
.status-msg { font-size: 17px; font-weight: 700; margin: 6px 0 18px; }
.stats-row { display: flex; margin-bottom: 22px; gap: 8px; }
.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 10px;
  flex: 1;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-card .val { font-size: 20px; font-weight: 800; }
.stat-card .lbl { color: var(--text-dim); font-size: 10px; margin-top: 4px; }

.section-label { font-size: 14px; font-weight: 700; margin: 14px 0 8px; }

.cig-grid { display: flex; flex-direction: column; align-items: center; }

/* Cigarette drag component */
.cig-wrap { margin: 10px 0; text-align: center; user-select: none; }
.cig-tag { color: #ccc; font-size: 11px; margin-bottom: 4px; font-weight: 600; }
.cig-track {
  position: relative;
  width: 220px;
  height: 26px;
  border-radius: 13px;
  overflow: hidden;
  background: #222;
  touch-action: none;
}
.cig-burnt { position: absolute; top: 0; left: 0; height: 100%; background: #3a3a3a; }
.cig-paper { position: absolute; top: 0; height: 100%; background: #f5f2ea; }
.cig-filter { position: absolute; top: 0; left: 0; width: 44px; height: 100%; background: #d99b5f; }
.cig-handle {
  position: absolute;
  top: -7px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.cig-ember {
  width: 18px; height: 18px; border-radius: 9px;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember);
  border: 2px solid #ffb199;
}
.cig-ember.done { background: #5a5a5a; box-shadow: none; border-color: #333; }
.cig-pct { color: #888; font-size: 10px; margin-top: 4px; }

.extra-btn, .sos-btn { margin-top: 12px; }

/* Habits */
.habit-card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 14px; border-width: 1px; border-style: solid; }
.habit-head { display: flex; align-items: center; margin-bottom: 12px; }
.habit-icon { font-size: 28px; margin-right: 12px; }
.habit-name { font-size: 15px; font-weight: 700; }
.habit-meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.habit-count { font-size: 22px; font-weight: 900; margin-left: 8px; }
.habit-buttons { display: flex; }
.habit-log-btn { flex: 1; border: none; border-radius: 10px; padding: 10px; font-weight: 800; font-size: 13px; cursor: pointer; }
.habit-undo-btn { margin-left: 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); font-size: 12px; cursor: pointer; }

/* Milestones */
.mile-row { display: flex; align-items: flex-start; background: var(--card); border-radius: 12px; padding: 14px; margin-bottom: 10px; opacity: 0.55; border: 1px solid transparent; }
.mile-row.achieved { opacity: 1; border-color: var(--acid-green); }
.mile-dot { width: 10px; height: 10px; border-radius: 5px; background: var(--border); margin-top: 5px; margin-right: 12px; flex-shrink: 0; }
.mile-dot.achieved { background: var(--acid-green); }
.mile-label { font-size: 14px; font-weight: 700; color: var(--text-dim); }
.mile-row.achieved .mile-label { color: var(--text); }
.mile-fact { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.mile-check { color: var(--acid-green); font-size: 18px; font-weight: 900; margin-left: 8px; }

/* SOS */
.sos-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 50;
  display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sos-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.sos-title { color: var(--hot-pink); font-size: 26px; font-weight: 900; margin-bottom: 24px; }
.sos-circle {
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--electric-purple);
  margin-bottom: 16px;
  animation: breathe 8s ease-in-out infinite;
}
@keyframes breathe {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.sos-timer { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.sos-hint { color: var(--text-dim); font-size: 13px; margin-bottom: 30px; }
.sos-distraction { font-size: 15px; padding: 0 10px; margin-bottom: 30px; }
.sos-question { font-size: 16px; margin-bottom: 30px; }
.sos-yes-no { width: 100%; }
.sos-no-btn { background: var(--acid-green); color: #111; border: none; border-radius: 14px; padding: 16px 30px; width: 100%; font-weight: 800; font-size: 15px; margin-bottom: 14px; cursor: pointer; }
.sos-yes-btn { background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: 14px; padding: 16px 30px; width: 100%; font-weight: 600; font-size: 14px; cursor: pointer; }
.sos-result { font-size: 16px; margin-bottom: 30px; }
.sos-close-btn { background: var(--hot-pink); color: #fff; border: none; border-radius: 14px; padding: 14px 30px; font-weight: 800; font-size: 14px; cursor: pointer; }

/* Tab bar */
.tab-bar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 10px 6px calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}
.tab-btn {
  flex: 1;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer;
  padding: 6px 0;
}
.tab-btn .tab-icon { font-size: 18px; }
.tab-btn.active { color: var(--hot-pink); }

@media (min-width: 561px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
