/* ==========================================================================
   Wink — design system  ·  "Twilight Glass"
   --------------------------------------------------------------------------
   POV: deep dusk sky (navy → violet) · a single warm gradient crescent moon ·
   frosted glass cards floating over a soft mountain horizon · big, light
   numerals · pastel-rainbow accents used sparingly. Calm, premium, classy.

   Design law: one primary action per screen · no shame, ever (a bad night is
   data, never a failure) · the medicine (your sleep window) is always the
   loudest thing · comfort features are clearly labelled as comfort, not cure ·
   big tap targets · gentle motion · respects prefers-reduced-motion.
   ========================================================================== */

:root {
  /* sky */
  --sky-0:  #2b2350;   /* upper dusk */
  --sky-1:  #241c45;
  --sky-2:  #1b1538;   /* deep night */
  --sky-3:  #140f2a;   /* horizon base */

  --ink:    #f4f1ff;   /* near-white text on sky */
  --ink-2:  #c7c0e6;   /* soft lavender-grey */
  --ink-3:  #8e87b4;   /* muted */
  --line:   rgba(255,255,255,.10);
  --line-2: rgba(255,255,255,.16);

  /* the moon gradient — the one warm thing in a cool world */
  --moon-a: #ffd9a0;
  --moon-b: #ff9d7a;
  --moon-c: #ff7eb3;
  --glow:   #ff9d7a;

  /* pastel rainbow — accents only */
  --mint:   #9ff0d4;
  --lemon:  #ffe39b;
  --lilac:  #c5b3ff;
  --coral:  #ffb0a3;
  --sky-blue:#a8d6ff;

  /* glass */
  --glass:    rgba(255,255,255,.055);
  --glass-2:  rgba(255,255,255,.085);
  --glass-br: rgba(255,255,255,.12);

  --good:  #9ff0d4;
  --hold:  #ffe39b;
  --press: #ffb0a3;

  --r-xl: 30px;
  --r-lg: 24px;
  --r:    18px;
  --r-sm: 13px;
  --r-pill: 999px;

  --shadow:   0 1px 1px rgba(0,0,0,.20), 0 18px 50px -22px rgba(0,0,0,.7);
  --shadow-2: 0 2px 4px rgba(0,0,0,.25), 0 36px 80px -30px rgba(0,0,0,.85);
  --glow-moon: 0 0 60px -8px rgba(255,140,120,.55), 0 0 120px -20px rgba(255,126,179,.35);

  --maxw: 480px;

  --display: "Fraunces", Georgia, "Times New Roman", serif; /* classy numerals */
  --sans:    "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.55;
  font-size: 16.5px;
  font-weight: 440;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--sky-0) 0%, var(--sky-1) 34%, var(--sky-2) 64%, var(--sky-3) 100%) fixed;
}

/* faint star field + horizon haze, fixed behind everything */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 18% 22%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1.2px 1.2px at 72% 14%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1.1px 1.1px at 41% 31%, rgba(255,255,255,.40), transparent 60%),
    radial-gradient(1.5px 1.5px at 86% 27%, rgba(255,255,255,.50), transparent 60%),
    radial-gradient(1.1px 1.1px at 58% 8%,  rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1.3px 1.3px at 9% 12%,  rgba(255,255,255,.40), transparent 60%);
  opacity: .8;
}
/* soft violet horizon glow at the bottom */
body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 42vh; z-index: 0;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 140%, rgba(150,120,220,.30), transparent 70%);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

.wrap {
  position: relative; z-index: 1;
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px 20px 122px; min-height: 100vh;
}

/* staggered entrance */
.rise { opacity: 0; transform: translateY(14px); animation: rise .6s cubic-bezier(.2,.7,.2,1) forwards; }
.rise.d1{animation-delay:.05s} .rise.d2{animation-delay:.12s} .rise.d3{animation-delay:.2s}
.rise.d4{animation-delay:.3s}  .rise.d5{animation-delay:.4s}
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---- Top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 14px; }
.mark { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.mark .logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, var(--moon-a), var(--moon-b) 45%, var(--moon-c) 90%);
  box-shadow: 0 0 16px -2px var(--glow); position: relative;
}
.mark .logo::after { /* carve the crescent */
  content: ""; position: absolute; top: -3px; right: -5px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--sky-2);
}
.mark .name { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.topbar .quiet { color: var(--ink-3); text-decoration: none; font-size: 14px; font-weight: 600; }
.topbar .quiet:hover { color: var(--ink); }

/* ---- Type ---- */
h1 { font-family: var(--display); font-weight: 500; font-size: clamp(34px, 9vw, 46px); line-height: 1.02; letter-spacing: -.02em; margin: 8px 0 12px; }
h2 { font-family: var(--display); font-weight: 500; font-size: clamp(22px, 6vw, 27px); line-height: 1.1; letter-spacing: -.01em; margin: 30px 0 12px; }
h3 { font-family: var(--sans); font-weight: 700; letter-spacing: -.01em; margin: 0 0 8px; font-size: 16px; }
.lede { color: var(--ink-2); font-size: 17px; line-height: 1.5; margin: 0 0 22px; max-width: 34ch; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--moon-b); margin: 0 0 10px; }
.muted { color: var(--ink-2); } .small { font-size: 13.5px; } .ink3 { color: var(--ink-3); }
a { color: var(--lilac); }

/* ---- Glass card ---- */
.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-br);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}
.card + .card { margin-top: 14px; }
.card.tight { padding: 15px 17px; }

/* ---- The crescent moon hero ---- */
.moon-hero { text-align: center; padding: 26px 20px 30px; }
.moon {
  width: 132px; height: 132px; margin: 6px auto 22px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 36% 30%, var(--moon-a) 0%, var(--moon-b) 42%, var(--moon-c) 92%);
  box-shadow: var(--glow-moon);
  animation: float 7s ease-in-out infinite;
}
.moon::after { /* crescent carve, same colour as sky behind it */
  content: ""; position: absolute; top: -14px; right: -20px; width: 112px; height: 112px;
  border-radius: 50%;
  background: radial-gradient(120% 120% at 50% 10%, var(--sky-1), var(--sky-2) 70%);
}
.moon .spark { position: absolute; z-index: 2; color: var(--moon-a); filter: drop-shadow(0 0 6px var(--glow)); }
.moon .spark.s1 { top: 6px; right: -10px; font-size: 18px; }
.moon .spark.s2 { top: 30px; right: -22px; font-size: 12px; }
@keyframes float { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-9px) } }

/* rendered hero moon — fade the square edges into the sky */
.moon-img {
  width: 240px; height: 240px; display: block; margin: 0 auto 14px;
  animation: float 7s ease-in-out infinite;
  -webkit-mask-image: radial-gradient(circle at 50% 46%, #000 52%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 46%, #000 52%, transparent 72%);
  filter: drop-shadow(0 18px 50px rgba(255,140,120,.28));
}

/* ---- The big clock / window numerals ---- */
.bignum { font-family: var(--display); font-weight: 500; letter-spacing: -.02em; line-height: 1; }
.window-clock { display: flex; align-items: baseline; justify-content: center; gap: 14px; margin: 6px 0 4px; }
.window-clock .t { font-family: var(--display); font-size: clamp(40px, 13vw, 58px); font-weight: 500; }
.window-clock .arrow { color: var(--ink-3); font-size: 26px; }
.window-sub { text-align: center; color: var(--ink-2); font-size: 15px; }
.window-sub b { color: var(--ink); font-weight: 700; }

/* time chips (bedtime / waketime cards) */
.timepair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 6px; }
.timepair .leg { text-align: center; }
.timepair .leg .lbl { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; margin-bottom: 4px; }
.timepair .leg .val { font-family: var(--display); font-size: clamp(30px, 9vw, 40px); font-weight: 500; }
.timepair .leg .ic { font-size: 18px; opacity: .85; }
.timepair .mid { color: var(--ink-3); font-size: 22px; }

/* ---- The efficiency dial (SVG ring) ---- */
.dial { width: 188px; height: 188px; margin: 4px auto 8px; position: relative; }
.dial svg { transform: rotate(-90deg); display: block; }
.dial .track { stroke: rgba(255,255,255,.10); }
.dial .fill { stroke: url(#winkgrad); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.7,.2,1); }
.dial .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.dial .center .pct { font-family: var(--display); font-size: 46px; font-weight: 500; line-height: 1; }
.dial .center .cap { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 800; margin-top: 4px; }

/* stat rows */
.statrow { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.statrow:last-child { border-bottom: 0; }
.statrow .dot { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; flex: 0 0 auto;
  background: var(--glass-2); border: 1px solid var(--line); }
.statrow .dot.mint{ color: var(--mint) } .statrow .dot.lemon{ color: var(--lemon) }
.statrow .dot.lilac{ color: var(--lilac) } .statrow .dot.coral{ color: var(--coral) }
.statrow .meta { flex: 1; min-width: 0; }
.statrow .meta .k { font-size: 13px; color: var(--ink-3); }
.statrow .meta .v { font-family: var(--display); font-size: 21px; font-weight: 500; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--sans); font-weight: 700; font-size: 16px;
  padding: 17px 22px; border-radius: var(--r-pill); border: 0; cursor: pointer;
  text-decoration: none; transition: transform .12s ease, filter .2s ease;
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: #fbf6ff; color: #241c45; box-shadow: 0 10px 30px -10px rgba(255,255,255,.4); }
.btn-primary:hover { filter: brightness(1.03); }
.btn-glow { color: #241c45; background: linear-gradient(100deg, var(--moon-a), var(--moon-b) 55%, var(--moon-c)); box-shadow: 0 12px 36px -10px var(--glow); }
.btn-ghost { background: var(--glass-2); color: var(--ink); border: 1px solid var(--glass-br); backdrop-filter: blur(10px); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn .go { width: 26px; height: 26px; border-radius: 50%; background: #241c45; color: #fbf6ff; display: grid; place-items: center; font-size: 13px; }
.btn-glow .go { background: rgba(36,28,69,.18); color: #241c45; }

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

/* ---- Forms (time + number inputs) ---- */
.field { margin: 0 0 16px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 0 7px; letter-spacing: .01em; }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0; }
input[type="time"], input[type="number"], input[type="text"], input[type="email"], select {
  width: 100%; font-family: var(--sans); font-size: 17px; font-weight: 600; color: var(--ink);
  background: var(--glass-2); border: 1px solid var(--glass-br); border-radius: var(--r);
  padding: 14px 15px; -webkit-appearance: none; appearance: none;
}
input::-webkit-calendar-picker-indicator { filter: invert(.85); opacity: .7; }
input:focus, select:focus { outline: none; border-color: var(--moon-b); box-shadow: 0 0 0 3px rgba(255,157,122,.18); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* segmented quality picker */
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span {
  display: block; text-align: center; padding: 12px 0; border-radius: 14px; cursor: pointer;
  background: var(--glass-2); border: 1px solid var(--glass-br); font-weight: 700; font-size: 18px;
  transition: all .15s ease;
}
.seg input:checked + span { background: linear-gradient(120deg, var(--moon-a), var(--moon-c)); color: #241c45; border-color: transparent; }

/* pills / tags */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--glass-2); border: 1px solid var(--glass-br); color: var(--ink-2); }
.tag.good { color: var(--good); border-color: rgba(159,240,212,.3); }
.tag.hold { color: var(--hold); border-color: rgba(255,227,155,.3); }
.tag.press{ color: var(--press); border-color: rgba(255,176,163,.3); }

/* honesty banner — "comfort, not cure" */
.honest { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink-2);
  background: rgba(168,214,255,.07); border: 1px solid rgba(168,214,255,.18); border-radius: var(--r);
  padding: 12px 14px; margin: 14px 0; }
.honest .i { color: var(--sky-blue); flex: 0 0 auto; }

/* house rules list */
.rule { display: flex; gap: 13px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule .n { width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: var(--glass-2); border: 1px solid var(--glass-br); color: var(--moon-b); }
.rule .rt { font-weight: 700; margin-bottom: 3px; }
.rule .rb { color: var(--ink-2); font-size: 14px; line-height: 1.45; }

/* week strip (days) */
.weekstrip { display: flex; gap: 7px; overflow-x: auto; padding: 4px 0 2px; -webkit-overflow-scrolling: touch; }
.weekstrip .day { flex: 0 0 auto; width: 46px; text-align: center; padding: 9px 0; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--line); }
.weekstrip .day .dn { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.weekstrip .day .dd { font-family: var(--display); font-size: 17px; margin-top: 2px; }
.weekstrip .day.on { background: linear-gradient(150deg, rgba(255,157,122,.22), rgba(255,126,179,.16)); border-color: rgba(255,157,122,.4); }
.weekstrip .day.logged .dd { color: var(--mint); }

/* mini bar chart (efficiency trend) */
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 7px; height: 116px; padding-top: 6px; position: relative; }
.bars .bar { max-width: 42px; } /* a 1-night chart shouldn't be one giant slab */
/* the 85% sweet-spot guide — the number the whole method aims at */
.goal-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px dashed rgba(159,240,212,.42); pointer-events: none; z-index: 1; }
.goal-line span { position: absolute; right: 0; top: -17px; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--mint); opacity: .8; }
.bars .bar { z-index: 0; }
.bars .bar { flex: 1; border-radius: 7px 7px 4px 4px; min-height: 6px;
  background: linear-gradient(to top, rgba(197,179,255,.35), var(--lilac)); position: relative; }
.bars .bar.good { background: linear-gradient(to top, rgba(159,240,212,.35), var(--mint)); }
.bars .bar.press { background: linear-gradient(to top, rgba(255,176,163,.35), var(--coral)); }
.bars .bar .bl { position: absolute; bottom: -19px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--ink-3); }
.bars-x { height: 16px; }

/* breathing pacer */
.breath-stage { display: grid; place-items: center; padding: 18px 0 6px; }
.breath-orb {
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255,217,160,.9), rgba(255,126,179,.6) 70%);
  box-shadow: 0 0 50px -6px var(--glow); display: grid; place-items: center;
  color: #241c45; font-weight: 800; font-size: 15px; letter-spacing: .02em;
  transition: transform 4s cubic-bezier(.4,0,.4,1), box-shadow 4s ease;
}
.breath-orb.in { transform: scale(1.32); }
.breath-orb.hold { transform: scale(1.32); }
.breath-orb.out { transform: scale(.82); }
.breath-pick { display: flex; gap: 8px; margin: 4px 0 16px; }
.breath-pick button { flex: 1; padding: 11px 0; border-radius: 13px; border: 1px solid var(--glass-br);
  background: var(--glass-2); color: var(--ink-2); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.breath-pick button.on { background: linear-gradient(120deg, var(--moon-a), var(--moon-c)); color: #241c45; border-color: transparent; }

/* soundscape grid */
.sounds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sound { display: flex; align-items: center; gap: 10px; padding: 13px; border-radius: var(--r);
  background: var(--glass-2); border: 1px solid var(--glass-br); cursor: pointer; color: var(--ink); }
.sound .si { font-size: 20px; }
.sound.on { border-color: var(--moon-b); box-shadow: 0 0 0 2px rgba(255,157,122,.2) inset; }

/* flashes */
.flash { padding: 12px 15px; border-radius: var(--r); font-size: 14px; font-weight: 600; margin: 0 0 14px; }
.flash.ok { background: rgba(159,240,212,.12); color: var(--good); border: 1px solid rgba(159,240,212,.25); }
.flash.err { background: rgba(255,176,163,.12); color: var(--press); border: 1px solid rgba(255,176,163,.25); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 54px; height: 32px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: var(--glass-2); border: 1px solid var(--glass-br); transition: background .2s ease; }
.switch .track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: var(--ink-2); transition: transform .2s cubic-bezier(.2,.7,.2,1), background .2s ease; }
.switch input:checked + .track { background: linear-gradient(120deg, var(--moon-a), var(--moon-c)); border-color: transparent; }
.switch input:checked + .track::before { transform: translateX(22px); background: #fff; }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* code chip */
.codechip { font-family: var(--display); font-size: 30px; letter-spacing: .22em; text-align: center;
  padding: 16px; border-radius: var(--r); background: var(--glass-2); border: 1px dashed var(--glass-br); }

/* ---- Floating pill nav ---- */
.footnav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 20;
  display: flex; gap: 4px; padding: 7px; border-radius: var(--r-pill);
  background: rgba(28,21,56,.72); border: 1px solid var(--glass-br);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 14px 40px -12px rgba(0,0,0,.7);
  max-width: calc(var(--maxw) - 24px); width: max-content;
}
.footnav a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  color: var(--ink-3); font-weight: 700; font-size: 13px; padding: 11px 13px; border-radius: var(--r-pill);
  transition: all .18s ease;
}
.footnav a svg { width: 20px; height: 20px; }
.footnav a .lbl { display: none; }
.footnav a.on { background: #fbf6ff; color: #241c45; }
.footnav a.on .lbl { display: inline; }

/* utility */
.center { text-align: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt0{margin-top:0}.mt8{margin-top:8px}.mt16{margin-top:16px}.mt24{margin-top:24px}
.mb0{margin-bottom:0}.mb8{margin-bottom:8px}
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.stack-sm > * + * { margin-top: 10px; }

/* install bar */
.install-bar { position: relative; z-index: 6; display: flex; align-items: center; gap: 10px; max-width: var(--maxw); margin: 0 auto;
  background: var(--glass-2); border: 1px solid var(--glass-br); color: var(--ink); padding: 10px 14px; border-radius: 0 0 16px 16px; font-size: 14px; backdrop-filter: blur(12px); }
.install-bar[hidden] { display: none; }   /* class display:flex would otherwise override the hidden attr */
.install-bar span { flex: 1; }
.install-bar #installBtn { border: 0; background: linear-gradient(120deg, var(--moon-a), var(--moon-c)); color: #241c45; font-weight: 700; font-size: 13px; padding: 7px 13px; border-radius: 9px; cursor: pointer; }
.install-bar #installX { border: 0; background: transparent; color: var(--ink-2); font-size: 20px; line-height: 1; cursor: pointer; }
