/* Reset PWA — App styles. Consumes the official Reset Design System tokens. */
@import "tokens/colors.css";
@import "tokens/typography.css";
@import "tokens/spacing.css";
@import "tokens/effects.css";
@import "tokens/backgrounds.css";

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg);
  background-image: var(--grad-app);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
/* fine grain over the gradient field */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--grain); opacity: .04; mix-blend-mode: multiply;
}

.app { max-width: var(--screen-max); margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; position: relative; }
#screen { flex: 1; overflow-y: auto; padding: var(--space-5) var(--space-5) calc(var(--nav-height) + 28px); -webkit-overflow-scrolling: touch; }

/* glass surfaces */
.glass {
  background: var(--glass-fill);
  backdrop-filter: blur(var(--blur-glass)); -webkit-backdrop-filter: blur(var(--blur-glass));
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-glass);
}
.glass-strong { background: var(--glass-fill-strong); }

/* ── header ── */
.top { padding: var(--space-3) var(--space-1) var(--space-5); }
.greet { font-size: var(--text-h1); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); color: var(--navy-900); }
.date { color: var(--ink-500); font-size: var(--text-sm); font-weight: var(--weight-medium); margin-top: 2px; }

/* ── ProgressHeader (hero) ── */
.hero {
  border-radius: var(--radius-2xl); padding: var(--space-5); margin-bottom: var(--space-4);
  display: flex; align-items: center; gap: var(--space-4); overflow: hidden;
  background: var(--white); background-image: var(--grad-hero-soft);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-md); color: var(--navy-900);
}
.hero-meta { flex: 1; min-width: 0; }
.hero-greet { font-size: var(--text-sm); color: var(--ink-500); font-weight: var(--weight-medium); margin-bottom: 4px; }
.hero-title { font-size: var(--text-h2); font-weight: var(--weight-bold); line-height: var(--leading-snug); }
.hero-sub { color: var(--ink-500); font-size: var(--text-sm); margin-top: 6px; line-height: var(--leading-snug); }

/* streak chips row */
.chips { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: 2px; margin-bottom: var(--space-5); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 34px; padding: 0 13px;
  border-radius: var(--radius-pill); white-space: nowrap; flex: none;
  background: var(--accent-tint); color: var(--accent);
  border: 1px solid var(--accent-tint); font-size: var(--text-sm); font-weight: var(--weight-semibold);
}
.chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.chip b { font-weight: var(--weight-bold); }

/* ── progress ring ── */
.ring { width: 84px; height: 84px; flex: none; }
.ring-bg { fill: none; stroke: var(--tint-300); stroke-width: 9; }
.ring-fg {
  fill: none; stroke: var(--accent, var(--blue-600)); stroke-width: 9; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset var(--dur-slow) var(--ease-in-out);
}
.ring-txt { fill: var(--navy-900); font-size: 20px; font-weight: var(--weight-bold); text-anchor: middle; font-family: var(--font-sans); }

/* ── section labels ── */
.section-label { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--ink-500); letter-spacing: var(--tracking-wide); margin: var(--space-5) var(--space-1) var(--space-3); text-transform: none; }

/* ── BlockCard ── */
.block-card {
  width: 100%; display: flex; align-items: center; gap: var(--space-4); text-align: right;
  border-radius: var(--radius-2xl); padding: var(--space-4); margin-bottom: var(--space-3); cursor: pointer;
  font-family: var(--font-sans); border: 1px solid var(--glass-border);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.block-card:active { transform: scale(.98); }
.block-card.done { opacity: .72; }
.block-card.next { border: 1.5px solid var(--accent); box-shadow: var(--shadow-lg); }
.bc-dial { flex: none; }
.bc-dial .ring { width: 60px; height: 60px; }
.bc-dial .ring-txt { font-size: 21px; }
.bc-body { flex: 1; min-width: 0; }
.bc-cat { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.bc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.bc-cat span { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--accent); }
.bc-title { font-size: var(--text-h3); font-weight: var(--weight-bold); color: var(--navy-900); line-height: 1.2; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-cue { font-size: var(--text-sm); color: var(--ink-500); line-height: 1.35; display: flex; align-items: center; gap: 5px; }
.bc-cue svg { flex: none; }
.bc-cue span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-check {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--white); border: 2px solid var(--line-300); box-shadow: var(--shadow-inset); color: transparent;
}
.bc-check.on { background: var(--action-primary); border: none; box-shadow: var(--shadow-brand-press); color: #fff; }
.bc-count { flex: none; min-width: 30px; height: 30px; padding: 0 10px; border-radius: var(--radius-pill); display: grid; place-items: center; font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--accent); background: var(--accent-tint); }

.safety { margin-top: var(--space-5); font-size: var(--text-xs); color: var(--ink-400); line-height: var(--leading-relaxed); padding: 0 var(--space-1); }
.safety b { color: var(--danger); }

/* ── active block overlay (timer) ── */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; background: var(--navy-900); background-image: var(--grad-hero); color: #fff; }
.overlay.show { display: block; }
.overlay::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .05; mix-blend-mode: overlay;
  background-image: var(--grain);
}
.ov-body {
  position: relative; z-index: 1; max-width: var(--screen-max); margin: 0 auto; height: 100dvh;
  padding: var(--space-6) var(--space-6) calc(var(--space-7) + var(--safe-bottom));
  display: flex; flex-direction: column; text-align: center;
}
.ov-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-5); }
.ov-close { width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 17px; cursor: pointer; }
.ov-cat { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); background: rgba(255,255,255,.16); padding: 6px 13px; border-radius: var(--radius-pill); }
.ov-step { font-size: var(--text-sm); font-weight: var(--weight-bold); opacity: .8; }
.ov-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: var(--space-7); }
.ov-dots .dot { width: 28px; height: 5px; border-radius: var(--radius-pill); background: rgba(255,255,255,.28); }
.ov-dots .dot.past { background: rgba(255,255,255,.7); }
.ov-dots .dot.cur { background: #fff; }
.ov-name { font-size: var(--text-display-md); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); margin-bottom: var(--space-3); line-height: 1.1; }
.ov-cue { font-size: var(--text-body-lg); line-height: var(--leading-relaxed); opacity: .95; max-width: 340px; margin: 0 auto; }
.ov-benefit { font-size: var(--text-sm); opacity: .9; margin-top: var(--space-4); background: rgba(255,255,255,.12); padding: 8px 14px; border-radius: var(--radius-pill); display: inline-block; }

.timer-wrap { margin: auto 0; display: grid; place-items: center; }
.timer-wrap .ring { width: 232px; height: 232px; }
.timer-wrap .ring-bg { stroke: rgba(255,255,255,.22); }
.timer-wrap .ring-fg { stroke: #fff; }
.timer-wrap .ring-txt { fill: #fff; font-size: 26px; }
.reps { font-size: var(--text-display-xl); font-weight: var(--weight-bold); margin: auto 0; letter-spacing: var(--tracking-tight); }

.ov-actions { display: flex; gap: var(--space-3); margin-top: auto; }
.ov-actions button { flex: 1; }
.btn-primary { width: 100%; border: none; border-radius: var(--radius-pill); padding: 17px; font-size: var(--text-body-lg); font-weight: var(--weight-bold); background: #fff; color: var(--blue-600); cursor: pointer; font-family: var(--font-sans); }
.btn-ghost { border: 1.5px solid rgba(255,255,255,.5); border-radius: var(--radius-pill); padding: 16px; font-size: var(--text-body); font-weight: var(--weight-semibold); background: rgba(255,255,255,.12); color: #fff; cursor: pointer; font-family: var(--font-sans); }

/* done screen */
.ov-done-screen { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.confetti { font-size: 64px; }
.ov-done-screen h2 { font-size: var(--text-display-md); font-weight: var(--weight-bold); }
.ov-done-sub { opacity: .9; font-size: var(--text-body-lg); }
.ov-done-count { font-size: var(--text-body); font-weight: var(--weight-bold); background: rgba(255,255,255,.16); padding: 7px 16px; border-radius: var(--radius-pill); margin-top: 6px; }
.ov-done-streak { font-size: var(--text-body); font-weight: var(--weight-semibold); margin: 6px 0 var(--space-6); }
.ov-done-screen .btn-primary { max-width: 280px; }

/* ── progress screen ── */
.streak-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.streak-tile { border-radius: var(--radius-xl); padding: var(--space-4); text-align: center; }
.st-emoji { font-size: 24px; }
.st-num { font-size: var(--text-display-md); font-weight: var(--weight-bold); color: var(--accent, var(--blue-600)); line-height: 1.1; }
.st-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--navy-900); }
.st-best { font-size: var(--text-xs); color: var(--ink-400); margin-top: 2px; }

.mwt-card { border-radius: var(--radius-xl); padding: var(--space-5); }
.mwt-hint { font-size: var(--text-sm); color: var(--ink-500); line-height: var(--leading-normal); margin-bottom: var(--space-4); }
.mwt-log { margin-top: var(--space-4); }
.mwt-row { display: flex; justify-content: space-between; font-size: var(--text-body); padding: 9px 2px; border-top: 1px solid var(--line-200); }
.mwt-row span { color: var(--ink-500); }
.mwt-clock { font-size: var(--text-display-lg); font-weight: var(--weight-bold); color: var(--blue-600); margin: var(--space-4) 0 var(--space-6); letter-spacing: var(--tracking-tight); }
.mwt-input { width: 100%; padding: 15px; font-size: var(--text-h2); text-align: center; border: 1.5px solid var(--line-300); border-radius: var(--radius-md); margin: var(--space-4) 0 var(--space-5); font-family: var(--font-sans); }

/* smoking */
.smoke-card { border-radius: var(--radius-xl); padding: var(--space-5); }
.smoke-hint { font-size: var(--text-sm); color: var(--ink-500); margin-bottom: var(--space-4); }
.smoke-counter { display: flex; align-items: center; justify-content: center; gap: var(--space-6); margin-bottom: var(--space-4); }
.sc-btn { width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--tint-200); color: var(--blue-600); font-size: 28px; font-weight: var(--weight-bold); cursor: pointer; }
.sc-num { text-align: center; min-width: 90px; }
.sc-num b { display: block; font-size: 40px; font-weight: var(--weight-bold); line-height: 1; color: var(--navy-900); }
.sc-num span { font-size: var(--text-xs); color: var(--ink-500); }
.smoke-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 76px; }
.sb { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.sb-fill { width: 100%; min-height: 4px; background: var(--blue-600); border-radius: 6px 6px 0 0; opacity: .85; }
.sb-n { font-size: var(--text-xs); color: var(--ink-500); }
.smoke-days { text-align: center; font-size: var(--text-xs); color: var(--ink-400); margin-top: 8px; }

/* ── settings ── */
.set-card { border-radius: var(--radius-xl); padding: 6px var(--space-4); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line-200); cursor: pointer; font-size: var(--text-body); font-weight: var(--weight-medium); color: var(--navy-900); }
.toggle-row:last-child { border-bottom: none; }
.switch { width: 46px; height: 27px; border-radius: var(--radius-pill); background: var(--line-300); position: relative; transition: background var(--dur-base) var(--ease-out); flex: none; }
.switch i { position: absolute; top: 3px; right: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-base) var(--ease-out); }
.switch.on { background: var(--blue-600); }
.switch.on i { transform: translateX(-19px); }

.phase-pills { display: flex; gap: var(--space-2); padding: var(--space-3) 0; }
.phase-pill { flex: 1; border: 1.5px solid var(--line-200); background: var(--white); border-radius: var(--radius-md); padding: 11px 6px; font-size: var(--text-body); font-weight: var(--weight-bold); color: var(--navy-900); cursor: pointer; font-family: var(--font-sans); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.phase-pill small { font-size: 10px; font-weight: var(--weight-medium); color: var(--ink-500); }
.phase-pill.on { border-color: var(--blue-600); background: var(--tint-200); color: var(--blue-600); }
.phase-pill.on small { color: var(--blue-600); }
.phase-detail { font-size: var(--text-sm); line-height: var(--leading-relaxed); color: var(--ink-500); padding: var(--space-3) 0 6px; border-top: 1px solid var(--line-200); }
.phase-detail b { color: var(--navy-900); }

.time-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line-200); }
.time-row label { font-size: var(--text-body); font-weight: var(--weight-medium); }
.time-row input { border: 1px solid var(--line-300); border-radius: var(--radius-sm); padding: 8px 12px; font-family: var(--font-sans); font-size: var(--text-body); }
.time-row input#push-api { flex: 1; min-width: 0; margin-inline-start: 12px; font-size: var(--text-sm); direction: ltr; text-align: left; }
.set-note { font-size: var(--text-xs); color: var(--ink-400); padding: var(--space-3) 0 6px; }

.btn-secondary { width: 100%; margin: var(--space-3) 0 6px; border: none; background: var(--tint-200); color: var(--blue-600); border-radius: var(--radius-md); padding: 13px; font-size: var(--text-body); font-weight: var(--weight-bold); cursor: pointer; font-family: var(--font-sans); }
.btn-danger { width: 100%; margin-top: var(--space-5); border: 1.5px solid var(--danger-tint); background: var(--danger-tint); color: var(--danger); border-radius: var(--radius-md); padding: 15px; font-size: var(--text-body); font-weight: var(--weight-semibold); cursor: pointer; font-family: var(--font-sans); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-height) + 16px); transform: translateX(-50%) translateY(8px); z-index: 70; background: var(--navy-900); color: #fff; font-size: var(--text-sm); font-weight: var(--weight-medium); padding: 11px 18px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ver { text-align: center; font-size: var(--text-xs); color: var(--ink-400); margin: var(--space-4) 0 4px; }

/* ── bottom nav ── */
.nav {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: center; height: var(--nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--glass-fill-strong); backdrop-filter: blur(var(--blur-strong)); -webkit-backdrop-filter: blur(var(--blur-strong));
  border-top: 1px solid var(--glass-border); box-shadow: 0 -6px 24px rgba(12,35,68,.06);
}
.nav-btn { border: none; background: none; cursor: pointer; font-family: var(--font-sans); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 18px; color: var(--ink-400); font-size: var(--text-xs); font-weight: var(--weight-medium); transition: color var(--dur-fast) var(--ease-out); }
.nav-btn .ic { font-size: 21px; line-height: 1; }
.nav-btn.active { color: var(--blue-600); font-weight: var(--weight-semibold); }

/* ── onboarding / modal ── */
.onboarding { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; padding: var(--space-6); background: rgba(12,35,68,.42); backdrop-filter: blur(6px); }
.onboarding.show { display: grid; }
.ob-card { width: 100%; max-width: 400px; border-radius: var(--radius-2xl); padding: var(--space-7) var(--space-6); text-align: center; background: rgba(255,255,255,.96); box-shadow: var(--shadow-xl); }
.ob-emoji { font-size: 48px; margin-bottom: 6px; }
.ob-card h2 { font-size: var(--text-h1); font-weight: var(--weight-bold); margin-bottom: 10px; letter-spacing: var(--tracking-tight); color: var(--navy-900); }
.ob-card p { font-size: var(--text-body); color: var(--ink-500); line-height: var(--leading-relaxed); margin-bottom: 12px; }
.ob-principle { font-weight: var(--weight-bold); color: var(--blue-600) !important; }
.ob-ios { font-size: var(--text-sm); background: var(--tint-200); padding: 12px; border-radius: var(--radius-sm); }
.ob-phases { flex-wrap: wrap; }
.ob-phases .phase-pill { flex: 1 1 40%; }
.ob-card .btn-primary { background: var(--blue-600); color: #fff; margin-top: 8px; box-shadow: var(--shadow-brand); }
.ob-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-5); }
.ob-dots { display: flex; gap: 6px; }
.ob-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line-300); transition: width var(--dur-base) var(--ease-out); }
.ob-dots span.on { background: var(--blue-600); width: 20px; border-radius: var(--radius-pill); }
.ob-nav .btn-primary { width: auto; margin-top: 0; padding: 13px 26px; }
.ob-card .btn-ghost { border-color: var(--line-300); color: var(--ink-500); background: transparent; margin-top: 8px; width: 100%; }
