/* Layout: one phone-width column; a sticky month header on top, a fixed tab bar below, sheets slide up for editing. */
:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --surface-2: #e2e6ec;
  --ink: #15171c;
  --muted: #5d6470;
  --line: #d3d8df;
  --me: #0d7472;
  --me-soft: #d2ebe9;
  --partner: #d63d55;
  --partner-soft: #f8d9de;
  --ours: #5b45cc;
  --ours-soft: #e3ddfa;
  --good: #23824a;
  --warn: #b26f06;
  --shadow: 0 1px 2px rgba(21, 23, 28, .06), 0 8px 24px rgba(21, 23, 28, .06);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Instrument Sans", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101217; --surface: #191c23; --surface-2: #232733; --ink: #eceef2; --muted: #9aa1ad; --line: #2c313c;
    --me: #44c2bd; --me-soft: #12312f; --partner: #ff7488; --partner-soft: #3b1c23; --ours: #a08cff; --ours-soft: #282247;
    --good: #4fc27c; --warn: #e3a33a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101217; --surface: #191c23; --surface-2: #232733; --ink: #eceef2; --muted: #9aa1ad; --line: #2c313c;
  --me: #44c2bd; --me-soft: #12312f; --partner: #ff7488; --partner-soft: #3b1c23; --ours: #a08cff; --ours-soft: #282247;
  --good: #4fc27c; --warn: #e3a33a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ours); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App frame ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.page { flex: 1; padding: 4px 16px calc(96px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 20px; }

.demo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin: 10px 16px 0; padding: 8px 10px 8px 14px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 13px;
}
.demo-bar b { font-weight: 600; }
.demo-bar button { border: 0; border-radius: 8px; padding: 6px 10px; background: var(--bg); color: var(--ink); font-weight: 600; font-size: 13px; }

.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bg); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 750; font-size: 22px; letter-spacing: -0.02em; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }

/* Month ruler: one tick per day of the month */
.month { display: flex; flex-direction: column; gap: 6px; }
.month-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.month-label strong { color: var(--ink); font-family: var(--display); font-size: 15px; font-weight: 650; }
.ruler { display: flex; gap: 2px; height: 10px; }
.ruler i { flex: 1; border-radius: 2px; background: var(--surface-2); }
.ruler i.past { background: var(--muted); opacity: .45; }
.ruler i.today { background: var(--ink); opacity: 1; transform: scaleY(1.5); }

/* ---------- Tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabs-inner { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tab { border: 0; background: none; padding: 6px 2px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Sections ---------- */
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: 19px; font-weight: 700; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.page-title { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.page-title h1 { font-size: 30px; font-weight: 750; letter-spacing: -0.025em; line-height: 1.1; }
.page-title p { margin: 0; color: var(--muted); }

.seg { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); align-self: flex-start; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Scoreboard ---------- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score {
  border: 0; text-align: left; background: var(--surface); border-radius: var(--radius); padding: 14px 12px 12px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); min-width: 0;
}
.score .who { font-size: 13px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .big { font-family: var(--display); font-size: 28px; font-weight: 750; line-height: 1; letter-spacing: -0.02em; }
.score .big small { font-size: 15px; color: var(--muted); font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar b { display: block; height: 100%; border-radius: 3px; transition: width .4s ease; }

/* ---------- Goal cards ---------- */
.goals { display: flex; flex-direction: column; gap: 8px; }
.goal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 14px 14px 16px; align-items: center;
}
.goal-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; border: 0; background: none; padding: 0; text-align: left; }
.goal-title { font-weight: 600; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.goal.is-done .goal-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.goal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.goal .bar { grid-column: 1 / -1; margin-top: 6px; }
.goal-why { grid-column: 1 / -1; margin: 6px 0 0; font-size: 14px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; }
.goal-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip.me { background: var(--me-soft); color: var(--me); }
.chip.partner { background: var(--partner-soft); color: var(--partner); }
.chip.ours { background: var(--ours-soft); color: var(--ours); }
.chip.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.chip.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

.log {
  min-width: 52px; height: 44px; padding: 0 12px; border-radius: 14px; border: 1.5px solid var(--accent, var(--me));
  background: transparent; color: var(--accent, var(--me)); font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.log.check { width: 44px; min-width: 44px; padding: 0; border-radius: 50%; }
.log.on { background: var(--accent, var(--me)); color: var(--surface); }
.log svg { width: 20px; height: 20px; }
.log:active { transform: scale(.95); }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; font-size: 15px;
  background: var(--ink); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: transparent; color: var(--partner); border: 1px solid var(--line); }
.btn.cheer { background: var(--partner-soft); color: var(--partner); }
.btn.nudge { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }

.fab {
  position: fixed; z-index: 9; right: max(16px, calc(50% - 224px)); bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  border: 0; border-radius: 16px; padding: 14px 18px; background: var(--accent, var(--ink)); color: var(--surface);
  font-weight: 700; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.fab svg { width: 20px; height: 20px; }

/* ---------- Cards / callouts ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { font-size: 17px; font-weight: 700; }
.card p { margin: 0; color: var(--muted); }
.callout { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.callout p { margin: 0; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.code { font-family: var(--display); font-weight: 750; font-size: 30px; letter-spacing: .18em; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h3 { color: var(--ink); font-size: 18px; }
.empty p { margin: 0; max-width: 32ch; }

/* ---------- Feed ---------- */
.feed { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.feed-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; }
.feed-item + .feed-item { border-top: 1px solid var(--line); }
.feed-item p { margin: 0; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.feed-item time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--surface); }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(10, 12, 16, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet {
  width: 100%; max-width: 480px; max-height: 92%; overflow-y: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 16px; animation: rise .22s ease;
}
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font-size: 22px; font-weight: 750; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--bg); font-size: 16px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--ours); }
.field textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.error { font-size: 14px; color: var(--partner); margin: 0; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.choice button { border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.choice button small { color: var(--muted); font-size: 12px; }
.choice button[aria-pressed="true"] { border-color: var(--accent, var(--ink)); background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent, var(--ink)); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 108px; text-align: center; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); font-size: 18px; font-weight: 700; }

.settings-group { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.settings-group + .settings-group { border-top: 1px solid var(--line); padding-top: 16px; }
.status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status.on i { background: var(--good); }

/* ---------- Toasts and simulated notifications ---------- */
.toasts { position: fixed; z-index: 30; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; max-width: 440px; width: 100%; background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: 14px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); animation: drop .22s ease; }
.notif {
  pointer-events: auto; max-width: 440px; width: 100%; display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: start;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 18px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); animation: drop .25s ease;
}
.notif .app-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--ink); display: grid; place-items: center; }
.notif .app-icon svg { width: 26px; height: 26px; }
.notif-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.notif b { display: block; font-size: 14px; }
.notif p { margin: 0; font-size: 14px; }
.notif .via { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- Auth ---------- */
.auth { max-width: 420px; margin: 0 auto; min-height: 100%; padding-block: 40px 24px; padding-inline: 20px; display: flex; flex-direction: column; gap: 28px; justify-content: center; }
.auth-hero { display: flex; flex-direction: column; gap: 12px; }
.auth-hero h1 { font-size: 40px; font-weight: 800; line-height: 1.02; letter-spacing: -0.035em; }
.auth-hero p { margin: 0; color: var(--muted); font-size: 16px; max-width: 34ch; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.switch { text-align: center; color: var(--muted); font-size: 14px; }
.switch button { border: 0; background: none; color: var(--ink); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }

@keyframes rise { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.12); } }
.popped { animation: pop .3s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Steps goals ---------- */
.choice.three { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.log.steps { min-width: 64px; padding: 0 10px; font-size: 14px; }
.log.steps svg { width: 17px; height: 17px; }
.strip { grid-column: 1 / -1; display: flex; gap: 2px; margin-top: 8px; }
.strip i { flex: 1; height: 14px; border-radius: 3px; background: var(--surface-2); opacity: .6; }
.strip i.miss { opacity: 1; background: color-mix(in srgb, var(--muted) 28%, var(--surface-2)); }
.strip i.hit { opacity: 1; background: var(--accent); }
.strip i.today { opacity: 1; box-shadow: inset 0 0 0 1.5px var(--accent); }
.copy-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.copy-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.copy-text .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.copy-text code { font-size: 13px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.steps-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.steps-list li { padding-left: 2px; }
.steps-list code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
