:root {
  --navy: #14304a;
  --brand: #1f7a6d;
  --brand-soft: #e3f1ee;
  --mint: #7fd1c1;
  --amber: #f2a33a;
  --amber-soft: #fdf0dc;
  --cream: #f7f5f0;
  --card: #ffffff;
  --line: #e4e7e3;
  --muted: #6b7a86;
  --blue: #3a7bd5;
  --blue-soft: #e5eefb;
  --green-soft: #e6f4ea;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 48, 74, .06), 0 6px 18px rgba(20, 48, 74, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--navy); font: 400 16px/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.serif { font-family: Merriweather, Georgia, serif; }
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-logo, .logo-mark { display: inline-block; background: url("/icons/logo-icon.svg") center / contain no-repeat; }
.boot-logo { width: 64px; height: 64px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; transform: scale(.94); } }

/* auth / onboarding shells */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(24px + var(--safe-t)) 22px calc(28px + var(--safe-b)); }
.brand { display: flex; align-items: center; gap: 10px; font: 900 22px Merriweather, Georgia, serif; letter-spacing: -.01em; }
.brand .logo-mark { width: 36px; height: 36px; }
.brand b { color: var(--brand); font-weight: inherit; }
.hero-title { font: 900 30px/1.2 Merriweather, Georgia, serif; margin: 36px 0 10px; }
.lead { color: var(--muted); margin: 0 0 24px; font-size: 17px; }
.field { display: block; width: 100%; padding: 16px 18px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-size: 17px; outline: none; transition: border-color .15s; }
.field:focus { border-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 16px 20px; border: 0; border-radius: 999px; font-weight: 700; font-size: 17px; background: var(--amber); color: var(--navy); box-shadow: 0 6px 16px rgba(242, 163, 58, .35); transition: transform .1s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; box-shadow: none; }
.btn.secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--line); box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--brand); padding: 12px; }
.btn.teal { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(31, 122, 109, .3); }
.stack > * + * { margin-top: 12px; }
.small { font-size: 14px; color: var(--muted); }
.center { text-align: center; }
.grow { flex: 1; }
.notice { background: var(--amber-soft); border-radius: 14px; padding: 14px 16px; font-size: 15px; }
.notice.teal { background: var(--brand-soft); }
.mail-art { width: 84px; height: 84px; border-radius: 24px; background: var(--brand-soft); display: grid; place-items: center; font-size: 40px; margin: 40px 0 0; }

/* onboarding */
.ob-top { display: flex; align-items: center; gap: 12px; }
.ob-back { border: 0; background: #fff; width: 40px; height: 40px; border-radius: 50%; box-shadow: var(--shadow); font-size: 18px; }
.ob-bar { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.ob-bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.ob-count { font-size: 13px; color: var(--muted); min-width: 40px; text-align: right; }
.ob-q { font: 900 24px/1.3 Merriweather, Georgia, serif; margin: 34px 0 22px; }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; padding: 17px 18px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: space-between; transition: border-color .15s, background .15s; }
.opt::after { content: ''; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-left: 12px; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.sel::after { border-color: var(--brand); background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12l4 4 8-8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.time-input { font-size: 34px; font-weight: 700; padding: 18px; text-align: center; border-radius: 18px; border: 1.5px solid var(--line); background: #fff; width: 100%; }

/* main app */
.main { padding: calc(18px + var(--safe-t)) 18px calc(96px + var(--safe-b)); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.hello { font-size: 14px; color: var(--muted); }
.hello b { display: block; font: 900 23px Merriweather, Georgia, serif; color: var(--navy); margin-top: 2px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; border: 0; }
.daynav { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: 14px; padding: 6px; box-shadow: var(--shadow); margin-bottom: 14px; }
.daynav button { border: 0; background: transparent; width: 40px; height: 36px; border-radius: 10px; font-size: 18px; color: var(--brand); }
.daynav button[disabled] { color: var(--line); }
.daynav span { font-weight: 600; font-size: 15px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.today-card { display: flex; align-items: center; gap: 16px; background: linear-gradient(135deg, #14304a, #1f7a6d); color: #fff; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.today-card h2 { font: 700 18px Merriweather, Georgia, serif; }
.today-card p { margin: 4px 0 0; opacity: .85; font-size: 14px; }
.theme { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--mint); margin-bottom: 4px; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 4px 10px; }
.section-h h3 { font: 700 18px Merriweather, Georgia, serif; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 12px 12px 12px 14px; box-shadow: var(--shadow); }
.task .ti { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; flex: none; }
.ti.eat { background: var(--amber-soft); } .ti.drink { background: var(--blue-soft); } .ti.move { background: var(--green-soft); } .ti.sleep, .ti.track { background: #ece9f7; }
.task .tt { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 0; }
.task .tt b { display: block; font-weight: 600; font-size: 16px; line-height: 1.3; }
.task .tt small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.task .chk { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: #fff; flex: none; display: grid; place-items: center; color: #fff; font-size: 16px; font-weight: 800; transition: all .15s; }
.task.done .chk { background: var(--brand); border-color: var(--brand); }
.task.done .tt b { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(107, 122, 134, .5); }
.task .time { font-size: 12px; font-weight: 700; color: var(--brand); }
.tip { background: var(--amber-soft); box-shadow: none; }
.tip .k { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #b5701a; }
.tip h3 { font: 700 18px Merriweather, Georgia, serif; margin: 6px 0; }
.tip p { margin: 0; font-size: 15px; }
.log-card { display: flex; align-items: center; gap: 14px; }
.log-card .big { font: 900 30px Merriweather, Georgia, serif; color: var(--brand); }
.disclaimer { font-size: 12px; color: var(--muted); margin: 18px 4px 0; line-height: 1.5; }

/* tab bar */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; padding: 8px 8px calc(8px + var(--safe-b)); z-index: 20; }
.tabbar button { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 12px; }
.tabbar button .i { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .6; }
.tabbar button.on { color: var(--brand); }
.tabbar button.on .i { filter: none; opacity: 1; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 48, 74, .45); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--cream); border-radius: 24px 24px 0 0; z-index: 41; padding: 10px 20px calc(24px + var(--safe-b)); transition: transform .25s ease; }
.sheet.open { transform: translate(-50%, 0); }
.sheet-bg.open { opacity: 1; }
.grabber { width: 44px; height: 5px; border-radius: 99px; background: #cfd5d2; margin: 0 auto 14px; }
.sheet h2 { font: 900 22px/1.3 Merriweather, Georgia, serif; margin-bottom: 6px; }
.sheet .meta { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.sheet h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.sheet ul, .sheet ol { margin: 0; padding-left: 22px; }
.sheet li { margin: 6px 0; }
.sheet .close { position: absolute; right: 14px; top: 12px; border: 0; background: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; box-shadow: var(--shadow); }
.steps { counter-reset: s; list-style: none; padding: 0 !important; }
.steps li { counter-increment: s; position: relative; padding: 12px 12px 12px 48px; background: #fff; border-radius: 14px; margin: 8px 0; }
.steps li::before { content: counter(s); position: absolute; left: 12px; top: 11px; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.why { background: var(--brand-soft); border-radius: 14px; padding: 12px 14px; font-size: 15px; }

/* routine timer */
.timer { text-align: center; background: #fff; border-radius: 18px; padding: 18px; margin-top: 14px; }
.timer .clock { font: 800 44px Inter, sans-serif; font-variant-numeric: tabular-nums; }
.timer .phase { color: var(--muted); font-weight: 600; min-height: 24px; }

/* night log */
.pick { display: flex; gap: 8px; flex-wrap: wrap; }
.pick button { flex: 1; min-width: 48px; padding: 14px 0; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; font-size: 18px; }
.pick button.sel { border-color: var(--brand); background: var(--brand); color: #fff; }
.faces button { font-size: 26px; padding: 10px 0; }
.faces button.sel { background: var(--brand-soft); color: inherit; }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* progress */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat .v { font: 900 26px Merriweather, Georgia, serif; color: var(--navy); }
.stat .l { font-size: 13px; color: var(--muted); }
.stat .d { font-size: 13px; font-weight: 700; margin-top: 2px; }
.d.good { color: var(--brand); } .d.bad { color: #c0612b; }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* me */
.list { background: #fff; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.list > * { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 15px 16px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; text-decoration: none; color: inherit; font-size: 16px; }
.list > *:last-child { border-bottom: 0; }
.list .k { color: var(--muted); font-size: 14px; }
.list .chev { color: var(--muted); }
.danger { color: #b3412b !important; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  body { background: #eceae4; }
  .app { background: var(--cream); box-shadow: 0 0 40px rgba(20, 48, 74, .08); }
}
