/* BetterU — dark, quiet, mobile first.
   The design brief is "premium, minimalist, calm, not a medical app".
   In practice that means: one accent colour, a lot of empty space, one number
   that is much bigger than everything else, and no decoration that is not
   carrying information. */

:root {
  --bg:        #0A0B0D;
  --surface:   #131519;
  --surface-2: #191C22;
  --line:      #23272F;
  --line-soft: #1A1D23;

  --text:      #F3F5F8;
  --text-dim:  #A8B0BC;
  --text-mute: #6C7480;

  --accent:      #34D399;
  --accent-dim:  #1F7A5A;
  --accent-glow: rgba(52, 211, 153, .16);
  --danger:      #F87171;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;

  --pad: 20px;
  --tabs-h: 62px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* The browser hides [hidden] with `display: none`, which is the WEAKEST
   possible rule — any author `display` (a flex row, a grid) silently beats
   it and the element stays on screen with nothing to explain why. This is
   the one place !important earns its keep. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  /* A single very soft glow behind the counter. It is the only "graphic"
     in the whole app; everything else is type. */
  background-image: radial-gradient(
    120% 55% at 50% -8%, var(--accent-glow) 0%, transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ─────────────────────────────── layout ─────────────────────────────── */

.app { height: 100%; }

.screen {
  position: fixed;
  inset: 0 0 var(--tabs-h) 0;
  display: flex;
  flex-direction: column;
}

.screen[hidden] { display: none; }

.scroll {
  flex: 1;
  overflow-y: auto;
  /* The chip row is deliberately full-bleed (negative margins), which leaves
     20px hanging past this box. Without this the whole screen could be
     dragged sideways by that much — the chips keep their own scrolling. */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top, 0px) + 26px) var(--pad) 40px;
}

.screen-title {
  margin: 4px 0 20px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-title {
  margin: 30px 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.danger-title { color: #7A5252; }

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

/* ─────────────────────────────── tab bar ────────────────────────────── */

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(10, 11, 13, .92);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--text-mute);
  font-size: 11px;
  letter-spacing: .02em;
  transition: color .18s ease;
}

.tab-mark { font-size: 13px; line-height: 1; opacity: .75; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-mark { opacity: 1; }

/* ────────────────────────────── the counter ─────────────────────────── */

.counter {
  text-align: center;
  padding: 26px 0 6px;
}

.counter-number {
  font-size: clamp(76px, 26vw, 148px);
  font-weight: 200;
  line-height: .92;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
  /* Tabular figures stop the number jittering sideways as it ticks over. */
}

.counter-unit {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--accent);
}

.goal-line {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 500;
}

.goal-emoji { font-size: 21px; }

.started {
  margin-top: 5px;
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
}

.motivation {
  margin: 26px 4px 0;
  text-align: center;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dim);
}

.btn-why { margin: 22px auto 0; display: block; }

/* ─────────────────────────────── cards ──────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 16px;
}

.card-quiet { background: var(--surface-2); }

.milestone-card { margin-top: 30px; }

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.row-sub {
  margin-top: 9px;
  font-size: 12px;
  color: var(--text-mute);
}

.label { font-size: 13px; color: var(--text-dim); }
.value { font-size: 15px; font-weight: 600; }

.bar {
  margin-top: 13px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width .7s cubic-bezier(.22, .8, .3, 1);
}

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-mute);
}

.hint + .btn-row { margin-top: 14px; }

.version {
  margin: 34px 0 0;
  text-align: center;
  font-size: 11px;
  color: #3E444E;
}

/* ─────────────────────────────── chips ──────────────────────────────── */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 calc(var(--pad) * -1) 4px;
  padding: 0 var(--pad) 6px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
  transition: border-color .18s ease, color .18s ease;
}

.chip.is-active {
  border-color: var(--accent-dim);
  color: var(--text);
  background: rgba(52, 211, 153, .08);
}

/* ─────────────────────────────── buttons ────────────────────────────── */

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  background: var(--surface-2);
  color: var(--text);
  transition: transform .12s ease, opacity .18s ease, background .18s ease;
}

.btn:active { transform: scale(.975); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn-primary { background: var(--accent); color: #06120D; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-danger { background: transparent; border-color: #4A2C2C; color: var(--danger); }
.btn-small { padding: 9px 16px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 16px; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-row .btn { flex: 1; }

/* ─────────────────────────── empty / onboarding ─────────────────────── */

.empty {
  min-height: 64vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-mark {
  font-size: 34px;
  color: var(--accent);
  opacity: .55;
  margin-bottom: 22px;
}

.empty-title {
  margin: 0;
  font-size: 32px;
  font-weight: 300;
  line-height: 1.24;
  letter-spacing: -0.02em;
}

.empty-sub {
  margin: 14px 0 30px;
  color: var(--text-mute);
  font-size: 15px;
}

/* ──────────────────────────── goal list rows ────────────────────────── */

.goal-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 15px 16px;
}

.goal-row.is-active { border-color: var(--accent-dim); }

.goal-row-emoji { font-size: 22px; }
.goal-row-main { flex: 1; min-width: 0; }

.goal-row-title {
  /* These are spans inside a span, so they need saying explicitly — left
     inline they run together on one line as "Smoking since 26 April". */
  display: block;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-row-sub {
  display: block;
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 2px;
}

.goal-row-days {
  font-size: 21px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.goal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 0 2px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 4px 2px;
  font-size: 12.5px;
  color: var(--text-mute);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn.is-danger { color: #8A5A5A; }

/* ───────────────────────────── stats grid ───────────────────────────── */

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 15px 16px;
}

.stat-value {
  font-size: 27px;
  font-weight: 300;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 3px;
  font-size: 11.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-mute);
}

/* ───────────────────────────── badges ───────────────────────────────── */

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.badge {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  padding: 8px;
}

.badge.is-earned {
  border-color: var(--accent-dim);
  background: rgba(52, 211, 153, .07);
}

.badge-value {
  font-size: 20px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
}

.badge.is-earned .badge-value { color: var(--accent); }

.badge-name {
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--text-mute);
  line-height: 1.25;
}

.badge.is-earned .badge-name { color: var(--text-dim); }

/* ─────────────────────────── streak history ─────────────────────────── */

.streak {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 13px 15px;
}

.streak-name { font-size: 14px; font-weight: 500; }
.streak-dates { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.streak-days {
  font-size: 17px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.streak.is-current .streak-days { color: var(--accent); }
.streak.is-best { border-color: #35404A; }

.tag {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--line);
  color: var(--text-dim);
  vertical-align: middle;
}

/* ─────────────────────────────── sheets ─────────────────────────────── */

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-wrap[hidden] { display: none; }

.sheet-back {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  animation: fade .22s ease;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 12px var(--pad) calc(24px + env(safe-area-inset-bottom, 0px));
  animation: rise .26s cubic-bezier(.22, .8, .3, 1);
}

.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 0 auto 16px;
}

.sheet-title {
  margin: 0 0 18px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ─────────────────────────────── forms ──────────────────────────────── */

.field-label {
  display: block;
  margin: 16px 0 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.field {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* 16px or iOS zooms the page in on focus */
  transition: border-color .18s ease;
}

.field:focus { border-color: var(--accent-dim); outline: none; }
.field::placeholder { color: #545B66; }

.field-area { min-height: 96px; resize: vertical; line-height: 1.55; }

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cats { display: flex; flex-wrap: wrap; gap: 8px; }

.cat {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 14px;
}

.cat.is-active {
  border-color: var(--accent-dim);
  background: rgba(52, 211, 153, .09);
  color: var(--text);
}

.form-error {
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--danger);
}

/* ────────────────────────────── my why ──────────────────────────────── */

.sheet-why { text-align: center; }

.why-kicker {
  margin: 4px 0 18px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.why-text {
  margin: 0;
  font-size: 21px;
  font-weight: 300;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.why-since {
  margin: 22px 0 24px;
  font-size: 14px;
  color: var(--accent);
}

/* ──────────────────────────── celebration ───────────────────────────── */

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Fully opaque on purpose. A translucent backdrop left the day counter
     ghosting through the badge, which made the one moment the app is asking
     you to stop and look at feel like a rendering glitch. */
  background: #07080A;
  background-image: radial-gradient(90% 55% at 50% 42%, rgba(52, 211, 153, .10) 0%, transparent 65%);
  animation: fade .3s ease;
}

.celebrate[hidden] { display: none; }

.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.celebrate-inner {
  position: relative;
  text-align: center;
  padding: 0 28px;
  max-width: 420px;
}

.celebrate-badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--accent);
}

.celebrate-number {
  margin: 16px 0 20px;
  font-size: clamp(56px, 19vw, 104px);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.celebrate-message {
  margin: 0 0 30px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-dim);
}

/* ─────────────────────────────── toast ──────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 70;
  max-width: calc(100% - 40px);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13.5px;
  animation: rise .2s ease;
}

.toast[hidden] { display: none; }

/* Someone who has asked their phone to calm down should get a calm app. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
