:root {
  --bg: #ffffff; --surface: #f7f9f8; --border: #e2ddd6; --text: #373434; --muted: #6b8a81;
  --green: #507c6f; --green-soft: rgba(80,124,111,0.12); --haze-light: #e6eae8; --haze: #c9cfcc;
  --danger: #a0463c;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400; font-size: 17px; line-height: 1.55;
  min-height: 100vh; min-height: 100dvh;
}
#app { max-width: 480px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top, 0px)) 20px calc(150px + var(--safe-b)); }
h1 { font-size: 28px; font-weight: 700; line-height: 1.2; margin-bottom: 14px; }
h1.big { font-size: 34px; }
h2 { font-size: 22px; font-weight: 600; line-height: 1.3; }
h1:focus, h2:focus { outline: none; }
p { margin-bottom: 12px; }
.lead { font-size: 19px; line-height: 1.5; }
.note { font-size: 14px; color: var(--muted); }
.center { text-align: center; }
.warn { color: var(--danger); }
.eyebrow { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--green); font-weight: 700; margin-bottom: 8px; }
.screen { display: flex; flex-direction: column; animation: up 0.35s ease; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* buttons */
.btn { display: block; width: 100%; text-align: center; text-decoration: none; font: inherit; font-weight: 600;
  border-radius: 12px; padding: 15px 18px; margin-top: 12px; cursor: pointer; border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent; }
.btn.primary { background: var(--green); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.small { padding: 11px 14px; font-size: 15px; }
.btn:active, .choice:active, .checkin:active { transform: scale(0.98); }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* onboarding */
.intro { padding-top: 24px; }
.brandmark svg { width: 64px; height: 64px; margin-bottom: 20px; }
.points, .steps { padding-left: 20px; margin-bottom: 8px; }
.points li, .steps li { margin-bottom: 12px; }
.steps li::marker { color: var(--green); font-weight: 700; }
.fields { display: grid; gap: 14px; margin: 16px 0; }
.fields label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; }
select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 120px; }

/* home */
.checkin { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; text-align: left;
  background: var(--green); color: #fff; border: 0; border-radius: 20px; padding: 32px 24px; font: inherit; cursor: pointer;
  box-shadow: 0 10px 30px rgba(80,124,111,0.25); -webkit-tap-highlight-color: transparent; }
.checkin .t { font-size: 26px; font-weight: 700; }
.checkin .s { font-size: 16px; opacity: 0.9; }
.streak { text-align: center; color: var(--muted); font-size: 15px; margin: 16px 0 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin-top: 14px; }
.card p:last-child { margin-bottom: 0; }
.card.due { background: var(--green-soft); border-color: transparent; }

/* check-in flow */
.flow { padding-top: 12px; }
.choices { display: grid; gap: 12px; margin-top: 12px; }
.choice { font: inherit; font-size: 19px; font-weight: 600; text-align: left; padding: 20px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.choice.grip-passing { background: #fff; }
.choice.grip-sticky { background: var(--haze-light); }
.choice.grip-hooked { background: var(--haze); }
.done { text-align: left; }
.narl-dots { display: flex; gap: 8px; list-style: none; margin-bottom: 24px; }
.narl-dots li { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  font-size: 15px; border: 1px solid var(--border); color: var(--muted); }
.narl-dots li.now { background: var(--green); color: #fff; border-color: var(--green); }
.narl-dots li.done { background: var(--green-soft); color: var(--green); border-color: transparent; }
.narl p { font-size: 18px; }
.narl p.lead { font-size: 21px; font-weight: 600; }

/* assessment */
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.progress svg { flex: 1; height: 2px; }
.track { fill: var(--border); } .fill { fill: var(--green); }
.qtext { min-height: 3.9em; margin-bottom: 20px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 2px 10px; font: inherit;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; cursor: pointer; color: var(--muted); -webkit-tap-highlight-color: transparent; }
.scale-btn b { font-size: 18px; }
.scale-btn span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.2; text-align: center; min-height: 2.4em; }
.scale-btn.on { background: var(--green); border-color: var(--green); color: #fff; }

/* window */
.window-wrap { margin: 16px 0; }
.window { width: 100%; height: auto; display: block; }
.window .z-stuck { fill: var(--haze-light); } .window .z-lost { fill: var(--haze); } .window .z-clear { fill: #fff; }
.window .axis { stroke: var(--text); stroke-width: 0.6; opacity: 0.25; }
.window .frame { fill: none; stroke: var(--text); stroke-width: 0.6; opacity: 0.3; }
.window .qlab { font-size: 14px; font-weight: 700; letter-spacing: 0.1em; fill: var(--muted); text-anchor: middle; }
.window .qlab.on { fill: var(--text); }
.window .axlab { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.window .dot { fill: var(--text); stroke: #fff; stroke-width: 3; }
.window .ghost { fill: var(--muted); opacity: 0.5; }
.window .wall { stroke: var(--text); stroke-width: 6; opacity: 0.55; stroke-linecap: round; }
.window .journey { fill: none; stroke: var(--text); stroke-width: 10; opacity: 0.12; stroke-linecap: round; stroke-linejoin: round; }
.window .journey-head { fill: var(--text); opacity: 0.35; }
.btn-row { display: flex; gap: 10px; justify-content: center; }
.btn-row:empty { display: none; }
.window .trail { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.brandmark .z-stuck { fill: var(--haze-light); } .brandmark .z-lost { fill: var(--haze); }
.brandmark .z-clear { fill: #fff; } .brandmark .b { stroke: var(--border); }
.brandmark .dot { fill: var(--text); }
.rounds { list-style: none; }
.rounds li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }

/* my window */
.stat { font-size: 18px; }
.stat b { font-size: 26px; color: var(--green); }
.bar { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; margin: 10px 0; font-size: 15px; }
.bar svg { width: 100%; height: 8px; }
.bar b { text-align: right; font-size: 15px; }
.bar em { grid-column: 2 / 4; color: var(--muted); font-style: normal; font-size: 14px; }

/* nav + help */
#nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px;
  background: rgba(255,255,255,0.96); border-top: 1px solid var(--border); padding: 8px 12px calc(8px + var(--safe-b));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#nav[hidden] { display: none; }
#nav a { flex: 1; max-width: 140px; text-align: center; padding: 10px 6px; border-radius: 10px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 15px; }
#nav a[aria-current="page"] { color: var(--green); background: var(--green-soft); }

#help { position: fixed; inset: 0; z-index: 10; background: rgba(55,52,52,0.4); display: flex; align-items: flex-end; justify-content: center; }
#help[hidden] { display: none; }
.sheet { background: #fff; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--safe-b)); animation: up 0.3s ease; }
.sheet h2 { margin-bottom: 16px; }
.breath { text-align: center; margin-bottom: 20px; }
.box { width: 120px; height: 120px; margin: 8px auto 10px; border: 2px solid var(--green); border-radius: 12px; position: relative; }
.ball { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--green); left: -9px; bottom: -9px; transition: left 4s linear, bottom 4s linear; }
.box[data-p="0"] .ball { left: -9px; bottom: calc(100% - 9px); }
.box[data-p="1"] .ball { left: calc(100% - 9px); bottom: calc(100% - 9px); }
.box[data-p="2"] .ball { left: calc(100% - 9px); bottom: -9px; }
.box[data-p="3"] .ball { left: -9px; bottom: -9px; }
.phase { font-size: 20px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .screen, .sheet { animation: none; }
  .ball { transition: none; }
}

#notice { position: fixed; left: 12px; right: 12px; bottom: calc(76px + var(--safe-b)); z-index: 20; max-width: 456px; margin: 0 auto;
  background: var(--text); color: #fff; font-size: 14px; line-height: 1.4; padding: 12px 14px; border-radius: 12px; }

.reset-door { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; margin-top: 12px;
  padding: 16px 20px; border-radius: 16px; border: 1px solid var(--green); background: #fff; color: var(--green);
  font: inherit; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
.reset-door .t { font-size: 19px; font-weight: 700; }
.reset-door .s { font-size: 14px; color: var(--muted); }
.reset-door:active { transform: scale(0.98); }
.card.nudge { background: var(--green-soft); border-color: transparent; margin-top: 0; margin-bottom: 14px; }
.card.nudge .lead { font-weight: 600; }

.sheet .eyebrow { margin-top: 20px; }
.sheet .breath .eyebrow { margin-top: 0; }

.ico { width: 1.25em; height: 1.25em; vertical-align: -0.25em; color: var(--green); background: var(--green-soft); border-radius: 6px; padding: 2px; }

.clear-door { display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 12px; padding: 16px 18px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent; }
.clear-door:active { transform: scale(0.98); }
.clear-door .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.clear-door .t { font-size: 19px; font-weight: 700; }
.clear-door .s { font-size: 14px; color: var(--muted); }
.narl-badge { display: grid; grid-template-columns: repeat(2, 22px); gap: 4px; flex: none; }
.narl-badge i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal;
  font-size: 11px; font-weight: 700; background: var(--green); color: #fff; }
.narl-badge i:nth-child(2), .narl-badge i:nth-child(3) { background: var(--green-soft); color: var(--green); }

.tip-link { display: block; margin: 18px auto 0; padding: 8px 14px; font: inherit; font-size: 15px; font-weight: 600;
  color: var(--green); background: none; border: 0; border-radius: 999px; cursor: pointer; }
.tip-link:active { background: var(--green-soft); }
#helpBtn[hidden] { display: none; }

.clear-bird { width: 72px; height: auto; flex: none; }
.box-ico { width: 40px; height: 40px; flex: none; color: var(--green); }
.reset-door { gap: 16px; }

#helpBtn { display: inline-flex; align-items: center; gap: 8px; }
.box-ico-sm { width: 18px; height: 18px; flex: none; }

/* Quick buttons: always within reach, never in the way */
#quick { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(80px + var(--safe-b)); z-index: 5;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
body.nonav #quick { bottom: calc(20px + var(--safe-b)); }
#quick[hidden], #quick [hidden] { display: none; }
#quick button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; box-shadow: 0 3px 12px rgba(0,0,0,0.08); }
#clearBtn { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; padding: 0; }
#clearBtn img { width: 40px; height: auto; }
#helpBtn { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--green);
  background: #fff; border: 1px solid var(--green); border-radius: 999px; padding: 9px 14px; }
#quick button:active { transform: scale(0.96); }

/* Close buttons */
.flow { position: relative; padding-top: 52px; }
.x-close { position: absolute; top: 0; right: 0; width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: #fff; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.x-close svg { width: 20px; height: 20px; }
.x-close:active { transform: scale(0.95); }
.sheet-head { position: sticky; top: -24px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; margin: -24px -20px 16px; padding: 20px 20px 10px; }
.sheet-head h2 { margin-bottom: 0; }
.sheet-head .x-close { position: static; flex: none; }
