:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eceef5;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e6ef;
  --accent: #6366f1;
  --good: #22c55e;
  --bad: #ef4444;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #141a2e; --surface-2: #1e2742; --text: #e8ebf5;
    --muted: #94a3b8; --border: #263052; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #141a2e; --surface-2: #1e2742; --text: #e8ebf5;
  --muted: #94a3b8; --border: #263052; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
body.noscroll { overflow: hidden; }
#app { max-width: 560px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px 32px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; line-height: 1.15; }
h2 { margin: 0 0 4px; font-size: 1.25rem; }
.h2 { font-size: 1rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.tiny { font-size: .75rem; margin: 2px 0 10px; }
.center { text-align: center; }
.eyebrow { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.sec { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; font-weight: 700; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 2px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; margin: 12px 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 16px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-weight: 650; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--c, var(--accent)); border-color: transparent; color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sos { background: var(--bad); color: #fff; border-color: transparent; }
.btn.block { width: 100%; margin: 10px 0; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .85rem; }
.btn:disabled { opacity: .6; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.row-btns.three { grid-template-columns: 1.3fr 1fr 1fr; }
.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted);
}
.icon-btn:disabled { opacity: .25; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.today-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.today-head .small { margin: 2px 0 0; }
.datenav { display: flex; align-items: center; gap: 2px; margin-left: -10px; }
.topbar { display: flex; align-items: center; gap: 8px; margin: 0 -8px 12px; }
.topbar h1 { flex: 1; text-align: center; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar.plain { margin: 4px 0 14px; }
.topbar.plain h1 { text-align: left; font-size: 1.6rem; }
.ring-wrap { position: relative; display: grid; place-items: center; flex: none; }
.ring-wrap > span { position: absolute; font-weight: 800; font-size: .95rem; }
.ring circle { transition: stroke-dashoffset .5s ease; }
.celebrate { text-align: center; background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--text); border-radius: 14px; padding: 10px; margin: 12px 0 0; font-weight: 600; }

.greet { margin: 0; font-size: 1rem; font-weight: 650; color: var(--muted); }

/* welcome / onboarding */
.welcome { text-align: center; padding-top: 28px; }
.welcome h1 { margin: 10px 0 6px; font-size: 1.75rem; }
.welcome > .muted { margin: 0 auto 18px; max-width: 34ch; }
.welcome .form { text-align: left; padding: 4px 16px 12px; }
.welcome-logo {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 26px; display: grid; place-items: center; font-size: 44px;
  background: linear-gradient(135deg, #6366f1, #14b8a6); box-shadow: 0 10px 30px rgba(99, 102, 241, .35);
}
.welcome .seg span { font-size: .82rem; padding: 10px 2px; }
.wave { font-size: 64px; display: inline-block; transform-origin: 70% 70%; animation: wave 1.6s ease-in-out 2; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
.hello .promise { text-align: left; }
.hello .promise p { margin: 0 0 4px; }

/* ---------- dashboard ---------- */
/* Top quarter: personal info + days counter */
.hp {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: stretch;
  min-height: calc(25vh - 14px); padding: 18px; border-radius: 24px; color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 45%, #0d9488 100%);
  box-shadow: 0 10px 30px rgba(79, 70, 229, .25);
}
.hp-left { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-width: 0; }
.hp-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 54px; height: 54px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .2); border: 2px solid rgba(255, 255, 255, .55); font-weight: 800; font-size: 1.2rem;
}
.hp-who { min-width: 0; }
.hp-greet { margin: 0; font-size: .85rem; opacity: .85; }
.hp-name {
  font-size: 1.4rem; color: #fff; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.hp-meta { margin: 2px 0 0; font-size: .82rem; opacity: .85; }
.hp-nudge { margin: 0; font-size: .85rem; font-style: italic; opacity: .9; }
.hp-counter {
  color: #fff; cursor: pointer; transition: transform .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 92px; padding: 10px 12px;
  border-radius: 18px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .3); text-align: center;
}
.hp-counter:hover { background: rgba(255, 255, 255, .24); }
.hp-counter:active { transform: scale(.96); }
.hp-counter small { margin-top: 6px; font-size: .68rem; font-weight: 700; opacity: .85; }
.hp-name-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.hp-gear {
  width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, .16);
}
.hp-gear:hover { background: rgba(255, 255, 255, .26); }
.hp-gear svg { width: 18px; height: 18px; }
.hp-counter b { font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.hp-counter span { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; opacity: .9; margin-top: 4px; line-height: 1.25; }

/* Middle partition */
.midband {
  display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 10px 12px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.midband .datenav { margin: 0; flex: none; }
.dn-label { display: flex; flex-direction: column; align-items: center; min-width: 78px; line-height: 1.2; }
.dn-label small { color: var(--muted); font-size: .75rem; }
.midband .icon-btn { width: 32px; height: 32px; }
.mid-progress { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mid-progress .bar { height: 9px; }
.mid-progress span { font-size: .8rem; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Four equal sections */
.quads { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 10px; }
.quad {
  display: flex; flex-direction: column; min-width: 0; min-height: 190px; padding: 10px 10px 8px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-top: 4px solid var(--q);
}
.quad-head { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.quad-head h2 { font-size: .88rem; letter-spacing: -.01em; margin: 0 0 0 2px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quad-count { font-size: .7rem; font-weight: 800; padding: 2px 6px; border-radius: 999px; color: var(--q); background: color-mix(in srgb, var(--q) 15%, transparent); }
.quad-add {
  width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem;
  color: #fff; background: var(--q);
}
.quad-list { display: flex; flex-direction: column; }
.quad-empty { margin: 8px 2px 8px; font-size: .8rem; color: var(--muted); }
.quad-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.sm { padding: 5px 9px; font-size: .74rem; background: var(--surface-2); border-color: transparent; }

.ri {
  position: relative; overflow: hidden; border-top: 1px solid var(--border);
  touch-action: pan-y; -webkit-user-select: none; user-select: none;
}
.ri:first-child { border-top: 0; }
.ri-fg {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 7px 0;
  background: var(--surface); transition: transform .25s ease;
}
.ri.swiping .ri-fg { transition: none; cursor: grabbing; }
/* Revealed behind the row while swiping right */
.ri-bg {
  position: absolute; inset: 2px 0; display: flex; align-items: center; padding-left: 8px; border-radius: 10px;
  font-size: .72rem; font-weight: 750; white-space: nowrap; color: var(--text); opacity: 0;
  background: color-mix(in srgb, var(--good) 22%, var(--surface)); transition: background .15s, color .15s;
}
.ri.swiping .ri-bg { opacity: 1; }
.ri.armed .ri-bg { background: var(--good); color: #fff; }
.ri.night .ri-bg { background: color-mix(in srgb, #6366f1 25%, var(--surface)); }
.ri.night.armed .ri-bg { background: #4f46e5; color: #fff; }
.swipe-hint {
  display: flex; align-items: center; gap: 6px; margin: -4px 0 12px; padding: 8px 4px 8px 12px; border-radius: 14px;
  font-size: .8rem; background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent);
}
.swipe-hint .icon-btn { width: 30px; height: 30px; font-size: 18px; }
.ri.rest { opacity: .5; }
.ri-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; }
.ri-emoji {
  width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center; font-size: 15px;
  background: var(--surface-2); background: color-mix(in srgb, var(--c) 16%, transparent);
}
.ri-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ri-name {
  font-size: .82rem; font-weight: 650; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.ri-sub { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-sub .timer { font-size: .72rem; color: var(--text); }
.ri.done .ri-name { color: var(--muted); }
.check.sm { width: 32px; height: 32px; flex: none; border-width: 2px; }
.check.sm svg { width: 18px; height: 18px; }
.mini {
  position: relative; width: 34px; height: 34px; flex: none; padding: 0; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center; cursor: pointer; font-size: 18px;
}
.mini:active { transform: scale(.9); }
.ring-btn svg { position: absolute; inset: 0; }
.ring-btn span { font-weight: 800; font-size: 1.05rem; color: var(--c); }
.cat-tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: var(--q); background: color-mix(in srgb, var(--q) 14%, transparent); }

@media (max-width: 359px) {
  .quads { grid-template-columns: 1fr; }
}
@media (min-width: 520px) {
  .ri-name { font-size: .9rem; }
}

/* Section picker in the habit form */
.catpick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.catpick label { position: relative; cursor: pointer; }
.catpick input { position: absolute; opacity: 0; pointer-events: none; }
.catpick span { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); }
.catpick b { font-size: .92rem; }
.catpick small { font-size: .74rem; color: var(--muted); font-weight: 500; }
.catpick input:checked + span { border-color: var(--q); background: color-mix(in srgb, var(--q) 10%, var(--surface)); }
.catpick input:focus-visible + span { outline: 2px solid var(--accent); }
.seg.two { grid-template-columns: 1fr 1fr; }

/* habit cards */
.habit { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; padding: 12px; margin-bottom: 10px; }
.habit-main, .quit { display: flex; align-items: center; gap: 12px; min-width: 0; }
.emoji {
  width: 46px; height: 46px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 23px;
  background: var(--surface-2); background: color-mix(in srgb, var(--c) 18%, transparent);
}
.htext { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hname { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hsub { font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit.skipped { opacity: .6; }
.habit .more { width: 32px; color: var(--muted); }
.check {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--border); background: transparent;
  display: grid; place-items: center; color: transparent; cursor: pointer; transition: background .2s, border-color .2s, color .2s;
}
.check svg { width: 24px; height: 24px; }
.check:hover { border-color: var(--c); color: color-mix(in srgb, var(--c) 40%, transparent); }
.check.on { background: var(--c); border-color: var(--c); color: #fff; }
.check.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.2); } }
.stepper { display: flex; gap: 6px; }
.step {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 22px; font-weight: 700; cursor: pointer; display: grid; place-items: center;
}
.step.plus { background: var(--c); color: #fff; border-color: transparent; }
.step:active, .check:active { transform: scale(.92); }
.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.habit .bar { grid-column: 1 / -1; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--c, var(--accent)); border-radius: inherit; transition: width .35s ease; }
.bar.big { height: 10px; margin: 14px 0 6px; }

.quit { padding: 14px; margin-bottom: 10px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 1.05rem; }
.ring-wrap.small { margin-left: auto; }

/* empty state */
.empty { text-align: center; padding-top: 24px; }
.empty-art { font-size: 56px; }
.empty h1 { margin: 8px 0; }
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 6px; text-align: left; }
.template { display: flex; align-items: center; gap: 10px; padding: 10px; font-weight: 600; font-size: .92rem; }
.template .emoji { width: 38px; height: 38px; font-size: 19px; border-radius: 11px; }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.tile { padding: 14px; }
.tile b { display: block; font-size: 1.45rem; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile span { color: var(--muted); font-size: .8rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiles.inner .tile { background: var(--surface-2); border-radius: 14px; }

/* heatmap */
.heat-wrap { display: flex; gap: 6px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; font-size: .62rem; color: var(--muted); align-items: center; }
.heat { flex: 1; display: grid; grid-template-columns: repeat(var(--weeks), 1fr); grid-template-rows: repeat(7, auto); grid-auto-flow: column; gap: 3px; }
.cell { display: block; width: 100%; aspect-ratio: 1; border: 0; padding: 0; border-radius: 3px; background: var(--surface-2); cursor: pointer; }
span.cell { cursor: default; }
.cell.l1 { background: color-mix(in srgb, var(--c) 30%, var(--surface-2)); }
.cell.l2 { background: color-mix(in srgb, var(--c) 55%, var(--surface-2)); }
.cell.l3 { background: color-mix(in srgb, var(--c) 80%, var(--surface-2)); }
.cell.l4 { background: var(--c); }
.cell.skip { background: repeating-linear-gradient(45deg, var(--surface-2) 0 2px, color-mix(in srgb, var(--c) 45%, var(--surface-2)) 2px 4px); }
.cell.off, .cell.pre { opacity: .35; }
.cell.slip { background: var(--bad); }
.cell.future { visibility: hidden; }
.legend { display: flex; gap: 14px; justify-content: flex-end; margin-top: 10px; font-size: .75rem; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend .cell { width: 11px; height: 11px; }

/* quit detail */
.hero { padding: 22px 18px 16px; text-align: center; margin-bottom: 12px; background: linear-gradient(160deg, color-mix(in srgb, var(--c) 20%, var(--surface)), var(--surface) 70%); }
.timer-big { font-size: clamp(1.7rem, 8vw, 2.4rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 4px 0; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { padding: 6px 10px; border-radius: 999px; background: var(--surface-2); font-size: .82rem; color: var(--muted); }
.badge.got { background: color-mix(in srgb, var(--c) 20%, transparent); color: var(--text); font-weight: 650; }
.reasons, .tips, .notes { margin: 8px 0 0; padding-left: 20px; }
.reasons li, .tips li, .notes li { margin: 4px 0; }
.tips { list-style: none; padding: 0; }
.hbar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr 40px; align-items: center; gap: 10px; margin: 6px 0; font-size: .88rem; }
.hbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar b { text-align: right; }
.sliplist { list-style: none; margin: 0; padding: 0; }
.sliplist li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.sliplist li:first-child { border-top: 0; }
.sliplist p { margin: 4px 0 0; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; color: var(--muted); }

/* stats */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 130px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.chart .b { width: 100%; max-width: 26px; border-radius: 6px 6px 2px 2px; background: var(--accent); transition: height .4s ease; }
.chart .b.none { background: var(--surface-2); }
.chart .lbl { font-size: .65rem; color: var(--muted); height: 1em; }
.chart-labels { display: flex; gap: 5px; margin-top: -14px; }
.chart-labels span { flex: 1; text-align: center; font-size: .7rem; color: var(--muted); }
.link-row { color: inherit; }
.qrow { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); }

/* forms */
.form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.field > span { font-weight: 650; font-size: .88rem; }
input, textarea, select {
  font: inherit; font-size: 16px; width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid3 .field { margin: 12px 0 4px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg.five { grid-template-columns: repeat(5, 1fr); }
.seg label { position: relative; }
.seg input, .daychips input, .swatch input, .chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 4px; border-radius: 10px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + span, .daychips input:focus-visible + span, .chip-radio input:focus-visible + span { outline: 2px solid var(--accent); }
.form:not([data-type="check"]):not([data-type="count"]) .only-build,
.form:not([data-type="count"]):not([data-type="limit"]) .only-amount,
.form:not([data-type="count"]) .only-count,
.form:not([data-type="limit"]) .only-limit,
.form:not([data-type="quit"]) .only-quit,
.form:not([data-type="check"]) .only-check,
.form[data-cat="avoid"] .only-track,
.form[data-cat="reduce"] .only-track,
.form:not([data-kind="weekdays"]) .only-weekdays,
.form:not([data-kind="weekly"]) .only-weekly { display: none; }
.daychips { display: flex; justify-content: space-between; gap: 4px; margin: 12px 0; }
.daychips span { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; cursor: pointer; color: var(--muted); }
.daychips input:checked + span { background: var(--accent); color: #fff; }
.emoji-row { display: flex; flex-direction: column; gap: 8px; }
.emoji-input { width: 72px; text-align: center; font-size: 24px; padding: 6px; }
.emoji-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 20px; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { position: relative; cursor: pointer; }
.swatch i { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); }
.swatch input:checked + i { outline: 3px solid var(--c); outline-offset: 3px; }
.templates { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 8px; padding: 2px 16px 10px; scrollbar-width: none; }
.templates::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .88rem; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-radio { position: relative; }
.chip-radio span { display: block; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); font-size: .88rem; cursor: pointer; }
.chip-radio input:checked + span { background: var(--c, var(--accent)); color: #fff; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 30; animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-width: 560px; margin: 0 auto; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  animation: up .28s cubic-bezier(.2, .9, .3, 1); overscroll-behavior: contain;
}
.sheet h2 { padding-right: 36px; }
.sheet .card { box-shadow: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.sheet-close { position: absolute; top: 14px; right: 12px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.breathe {
  width: 170px; height: 170px; margin: 16px auto; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent), color-mix(in srgb, var(--c) 12%, transparent));
  transform: scale(.62); transition: transform 4s ease-in-out;
}
.breathe.in, .breathe.hold { transform: scale(1); }
.breathe.out { transform: scale(.62); transition-duration: 6s; }
.breathe span { transform: scale(1); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 40; max-width: calc(100% - 32px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s ease;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.actionable.show { pointer-events: auto; display: flex; align-items: center; gap: 12px; width: max-content; text-align: left; }
.toast-btn { border: 0; background: none; color: #818cf8; font-weight: 800; padding: 4px 6px; cursor: pointer; }

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

/* Night check-in (Not To Do) */
.night-box {
  display: flex; flex-direction: column; gap: 4px; margin: 14px 0 0; padding: 12px; border-radius: 14px; text-align: left;
  background: color-mix(in srgb, #6366f1 12%, var(--surface)); border: 1px solid color-mix(in srgb, #6366f1 30%, transparent);
}
.night-box span { font-size: .85rem; color: var(--muted); }
.night-box.ok { background: color-mix(in srgb, var(--good) 14%, var(--surface)); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.night-btn { margin: 8px 0 0; background: #4f46e5; color: #fff; border-color: transparent; }
.night-btn:disabled { background: var(--surface-2); color: var(--muted); }

/* Built-in timer */
.play-btn { color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.mini .play { width: 16px; height: 16px; position: relative; color: var(--c); }
.timer-cta .play { width: 18px; height: 18px; }
.toggle-row { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0; padding: 12px; border-radius: 14px; background: var(--surface-2); cursor: pointer; }
.toggle-row input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.toggle-row span { display: flex; flex-direction: column; gap: 2px; }
.toggle-row small { color: var(--muted); font-size: .8rem; }

#timer-root:empty { display: none; }
.timer-screen {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  color: #f1f5f9; text-align: center; touch-action: none; -webkit-user-select: none; user-select: none;
  background: radial-gradient(120% 80% at 50% 35%, color-mix(in srgb, var(--c) 45%, #0b1020) 0%, #070b16 70%);
  animation: fade .3s ease;
}
.ts-top { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; opacity: .9; }
.ts-emoji { font-size: 1.6rem; }
.ts-mid { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.ts-pulse {
  position: absolute; top: 50%; left: 50%; width: 260px; height: 260px; margin: -170px 0 0 -130px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 35%, transparent), transparent 70%);
  animation: tsPulse 4s ease-in-out infinite; pointer-events: none;
}
.paused .ts-pulse { animation: none; opacity: .35; }
@keyframes tsPulse { 0%, 100% { transform: scale(.85); opacity: .6; } 50% { transform: scale(1.1); opacity: 1; } }
.ts-clock { position: relative; font-size: clamp(3.5rem, 18vw, 5.5rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.ts-total { position: relative; margin: 6px 0 0; font-size: .95rem; opacity: .85; }
.ts-total.over { color: #fca5a5; opacity: 1; font-weight: 700; }
.ts-msg { position: relative; margin: 22px 0 0; font-size: 1.15rem; font-weight: 650; }
.ts-hint { position: relative; margin: 4px 0 0; font-size: .9rem; opacity: .7; }
.ts-actions { width: 100%; max-width: 420px; display: grid; gap: 10px; animation: up .25s ease-out; }
.ts-actions .btn { min-height: 56px; font-size: 1.05rem; border: 0; }
.ts-stop { background: #fff; color: #0f172a; }
.ts-continue { background: rgba(255, 255, 255, .14); color: #fff; }
.ts-discard { color: rgba(255, 255, 255, .6); font-weight: 500; padding: 8px; }

/* Friends */
.invite { margin: 0 auto 12px; max-width: 36ch; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.friends-strip {
  margin: 12px 0 8px; padding: 12px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.fs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.fs-head h2 { font-size: .95rem; margin: 0; }
.fs-head .link { font-size: .85rem; }
.fs-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
.fs-row::-webkit-scrollbar { display: none; }
.fs-friend {
  flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit;
}
.fs-friend.stale { opacity: .55; }
.fs-av, .fs-plus {
  position: absolute; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; color: #fff; background: linear-gradient(135deg, #6366f1, #0d9488);
}
.fs-plus { position: static; width: 54px; height: 54px; background: var(--surface-2); font-size: 1.3rem; }
.fs-name { font-size: .75rem; font-weight: 650; max-width: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-score { font-size: .68rem; color: var(--muted); }

.fcard { border-radius: 16px; padding: 12px; background: var(--surface-2); }
.fcard.stale .fc-body { opacity: .7; }
.fc-head { display: flex; align-items: center; gap: 10px; }
.fc-av { width: 42px; height: 42px; font-size: .95rem; color: #fff; border: 0; background: linear-gradient(135deg, #6366f1, #0d9488); }
.fc-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fc-who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-who small { color: var(--muted); font-size: .78rem; }
.fc-days { font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface); }
.fc-body { display: flex; align-items: center; gap: 14px; margin: 12px 0 8px; }
.fc-secs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fc-sec { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 8px; font-size: .78rem; }
.fc-sec span { white-space: nowrap; color: var(--muted); font-weight: 600; }
.fc-sec b { text-align: right; }
.fc-sec .bar { height: 7px; background: var(--surface); }
.fc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .82rem; font-weight: 650; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 22px; }
.spark i { display: block; width: 6px; border-radius: 2px; background: var(--accent); }
.spark i.none { background: var(--border); }
.friend-item .fcard { background: transparent; padding: 0; }
.paste-row { display: flex; gap: 8px; }
.paste-row input { flex: 1; min-width: 0; }
.paste-row .btn { flex: none; }
