@font-face {
  font-family: 'Big Shoulders';
  src: url('../fonts/bigshoulders.woff2') format('woff2');
  font-weight: 500 900;
  font-display: swap;
}

:root {
  --bg: #e9edf2;
  --surface: #ffffff;
  --ink: #16203a;
  --muted: #5d6781;
  --tide: #2d5bff;
  --tide-soft: #dde5ff;
  --bloom: #ff6f9f;
  --moss: #1f8a5c;
  --danger: #cf3434;
  --line: rgba(22, 32, 58, 0.1);
  --line-strong: rgba(22, 32, 58, 0.22);
  --on-accent: #ffffff;
  --display: 'Big Shoulders', 'Arial Narrow', sans-serif;
  --text: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  --r-panel: 22px;
  --r-cell: 9px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1222;
    --surface: #151d33;
    --ink: #e7ebf5;
    --muted: #98a2bc;
    --tide: #6e8dff;
    --tide-soft: #1f2a55;
    --moss: #3dba84;
    --danger: #ff6b6b;
    --line: rgba(231, 235, 245, 0.1);
    --line-strong: rgba(231, 235, 245, 0.24);
    --on-accent: #0c1222;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--tide); outline-offset: 2px; border-radius: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- Shell ---------------------------------------------------------- */

.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto;
  padding: calc(var(--safe-top) + 6px) 14px 6px 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.sync { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.sync::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--moss); }
.sync[data-state='saving']::before { background: var(--tide); }
.sync[data-state='offline']::before { background: var(--bloom); }

.view {
  max-width: 560px; margin: 0 auto;
  padding: 4px 16px calc(var(--safe-bottom) + 96px);
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px max(8px, calc((100vw - 560px) / 2)) calc(var(--safe-bottom) + 4px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: none; padding: 6px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--muted);
}
.tabbar button[aria-current='page'] { color: var(--tide); }

.iconbtn {
  border: 0; background: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink);
}
.iconbtn:disabled { opacity: 0.25; cursor: default; }
.iconbtn:not(:disabled):active { background: var(--line); }

/* ---- Buttons & fields ---------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 999px;
  background: var(--tide); color: var(--on-accent);
  font-weight: 600; font-size: 16px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.small { min-height: 38px; padding: 0 15px; font-size: 15px; }
.btn.small .icon { width: 20px; height: 20px; }
.btn.wide { width: 100%; }
.linkbtn { border: 0; background: none; color: var(--tide); font-weight: 600; padding: 10px 4px; }

.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.row-btns.tight { gap: 8px; margin-top: 12px; }
.row-btns.center { justify-content: center; }

.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-size: 14px; font-weight: 600; color: var(--muted); padding: 0; }
.field small, .form small { color: var(--muted); font-size: 13px; }
input:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1.5px solid var(--line-strong); border-radius: 14px;
  background: var(--surface); font-size: 17px;
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; line-height: 1.4; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238891a8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 20px; padding-right: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tide); }
input[type=date] { display: block; }
.form-error { color: var(--danger); font-size: 15px; min-height: 1px; }
.form-error:empty { display: none; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 11px; font-weight: 600; font-size: 15px; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg input:focus-visible + span { outline: 3px solid var(--tide); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; font-weight: 600; }
.switch input {
  -webkit-appearance: none; appearance: none; order: 2;
  width: 52px; height: 32px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background 0.2s; margin: 0; flex: none;
}
.switch input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked { background: var(--moss); }
.switch input:checked::after { transform: translateX(20px); }

.panel { background: var(--surface); border-radius: var(--r-panel); padding: 20px; margin-top: 16px; }
.panel h2, .panel h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.panel p + p { margin-top: 10px; }
.form { display: grid; gap: 16px; }
.form h3 { margin-bottom: -4px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.setting-row > span { font-weight: 600; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; }
.inline-form .field { flex: 1; }

/* ---- The numeral ---------------------------------------------------- */

.numeral { display: block; width: 100%; max-width: 380px; height: auto; margin: 0 auto; overflow: visible; }
.numeral text { font-family: var(--display); font-weight: 900; font-size: 300px; letter-spacing: -4px; }
.n-outline { fill: none; stroke: color-mix(in srgb, var(--ink) 26%, transparent); stroke-width: 2.5; }
.n-fill { fill: var(--tide); transition: fill 0.6s ease; }
.n-fill.full { fill: var(--moss); }

.hero { text-align: center; padding: 4px 0 8px; }
.hero-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.hero-date { font-size: 15px; font-weight: 600; color: var(--muted); }
.hero-line { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; margin-top: 6px; letter-spacing: 0.2px; }
.hero-sub { color: var(--muted); margin-top: 6px; }
.hero .linkbtn { margin-top: 2px; }

/* ---- Alerts --------------------------------------------------------- */

.alert {
  margin-top: 8px; padding: 18px 20px; border-radius: var(--r-panel);
  background: color-mix(in srgb, var(--bloom) 16%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--bloom) 50%, transparent);
}
.alert-sub { margin-top: 6px; color: var(--muted); font-size: 15px; }
.alert .btn { margin-top: 12px; }
.alert .row-btns .btn { margin-top: 0; }

/* ---- Tasks ---------------------------------------------------------- */

.tasks { background: var(--surface); border-radius: var(--r-panel); margin-top: 18px; overflow: hidden; }
.task { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 18px 18px 18px 16px; }
.task + .task { border-top: 1px solid var(--line); }
.task h3 { font-size: 17px; font-weight: 650; }
.task-body > p { color: var(--muted); font-size: 15px; margin-top: 2px; }
.task-body[data-action] { cursor: pointer; }
.task-warn { color: var(--danger) !important; font-size: 14px !important; margin-top: 8px !important; }

.check {
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  border: 2px solid var(--line-strong); background: transparent; color: transparent;
  display: grid; place-items: center; margin-top: -4px;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.15s ease;
}
.check .icon { width: 20px; height: 20px; stroke-width: 2.6; }
.check:active:not(.static) { transform: scale(0.9); }
.check.static { cursor: default; }
.task.done .check { background: var(--moss); border-color: var(--moss); color: #fff; }
.task.done h3 { color: var(--moss); }

.sub {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  width: 100%; margin-top: 8px; padding: 11px 14px;
  border: 0; border-radius: 13px; background: var(--bg); text-align: left;
}
.sub span { font-weight: 600; font-size: 15px; }
.sub em { font-style: normal; color: var(--muted); font-size: 15px; text-align: right; }
.sub.ok em { color: var(--moss); font-weight: 600; }

.meter { height: 10px; border-radius: 999px; background: var(--tide-soft); margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; width: calc(var(--pct, 0) * 100%); background: var(--tide); border-radius: inherit; transition: width 0.4s ease; }
.task.done .meter span { background: var(--moss); }
.meter.thick { height: 14px; }

.stepper { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.stepper output { min-width: 76px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper.big { justify-content: center; margin: 20px 0 12px; }
.stepper.big output { font-size: 20px; min-width: 120px; }
.stepper.big output b { font-family: var(--display); font-size: 56px; font-weight: 800; line-height: 1; }
.stepper.big .btn { width: 56px; height: 56px; padding: 0; }

.thumb { border: 0; padding: 0; background: none; margin: 10px 0; display: block; }
.thumb img { width: 96px; height: 128px; object-fit: cover; border-radius: 12px; background: var(--line); display: block; }
label.btn { cursor: pointer; margin-top: 10px; }

.note { margin-top: 16px; }
.note h3 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 0 4px 8px; }
.note textarea { border-color: transparent; border-radius: var(--r-panel); padding: 16px 18px; }

/* ---- Progress ------------------------------------------------------- */

.progress-head h1 { font-family: var(--display); font-weight: 800; font-size: 30px; display: flex; align-items: baseline; gap: 10px; margin: 6px 0 12px; }
.progress-head .big { font-size: 84px; line-height: 0.8; color: var(--tide); }
.progress-head .muted { font-size: 15px; margin-top: 10px; }
.grid75 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-top: 22px; }
@media (min-width: 400px) { .grid75 { grid-template-columns: repeat(15, 1fr); gap: 4px; } }
.cell {
  aspect-ratio: 1; border: 0; border-radius: var(--r-cell); padding: 0;
  background: var(--surface); color: var(--muted);
  font: 700 12px/1 var(--display); font-size: 13px;
  display: grid; place-items: center;
}
.cell.done { background: var(--moss); color: #fff; }
.cell.missed { background: transparent; box-shadow: inset 0 0 0 1.5px var(--danger); color: var(--danger); }
.cell.today { box-shadow: inset 0 0 0 2.5px var(--tide); color: var(--tide); }
.cell.done.today { box-shadow: inset 0 0 0 2.5px var(--tide); color: #fff; }
.cell.future { opacity: 0.55; cursor: default; }
.legend { display: flex; gap: 18px; margin: 12px 2px 0; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; display: inline-block; border-radius: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 22px; background: var(--line); border-radius: var(--r-panel); overflow: hidden; }
.stats div { background: var(--surface); padding: 16px 12px; display: grid; gap: 2px; }
.stats b { font: 800 32px/1 var(--display); }
.stats span { font-size: 13px; color: var(--muted); }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.empty { text-align: center; padding: 22vh 20px 0; display: grid; gap: 16px; justify-items: center; }
.empty h2 { font: 800 34px/1 var(--display); }
.empty p { color: var(--muted); max-width: 32ch; }

/* ---- Photos --------------------------------------------------------- */

.page-title { font: 800 44px/1 var(--display); margin: 8px 2px 16px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-cell { border: 0; padding: 0; background: var(--line); border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 3 / 4; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell span { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(12, 18, 34, 0.6); color: #fff; font-size: 12px; font-weight: 600; }
img[data-photo] { opacity: 0; transition: opacity 0.3s; }
img[data-photo].ready { opacity: 1; }
img[data-photo].broken { opacity: 1; font-size: 12px; color: var(--muted); }
.small-print { font-size: 13px; margin: 18px 4px 0; }

.compare { margin-bottom: 18px; }
.compare-stage { position: relative; aspect-ratio: 3 / 4; border-radius: var(--r-panel); overflow: hidden; background: var(--line); }
.compare-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare-top { position: absolute; inset: 0; clip-path: inset(0 0 0 calc(var(--pct, 0.5) * 100%)); }
.compare-top::before { content: ''; position: absolute; top: 0; bottom: 0; left: calc(var(--pct, 0.5) * 100%); width: 2px; margin-left: -1px; background: #fff; z-index: 1; }
.compare-tag { position: absolute; top: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(12, 18, 34, 0.6); color: #fff; font-size: 13px; font-weight: 600; }
.compare-tag.left { left: 10px; }
.compare-tag.right { right: 10px; }
.compare input[type=range] { width: 100%; margin-top: 12px; accent-color: var(--tide); }

/* ---- Guide ---------------------------------------------------------- */

.lede { font-size: 19px; line-height: 1.45; max-width: 36ch; margin: 0 2px; }
.rules { margin-top: 22px; display: grid; gap: 2px; border-radius: var(--r-panel); overflow: hidden; }
.rule { background: var(--surface); padding: 20px 20px 20px 22px; border-left: 5px solid var(--tide); }
.rule h2 { font: 800 26px/1.05 var(--display); margin-bottom: 6px; }
.rule p { color: var(--muted); }
.callout { border: 1.5px solid color-mix(in srgb, var(--bloom) 50%, transparent); }
.section-title { font: 800 30px/1 var(--display); margin: 30px 2px 12px; }
.tips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tip { background: var(--surface); border-radius: 18px; padding: 16px; }
.tip h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.tip p { font-size: 14px; color: var(--muted); line-height: 1.4; }
@media (max-width: 360px) { .tips { grid-template-columns: 1fr; } }

/* ---- Sheets & toasts ------------------------------------------------ */

.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(8, 12, 24, 0.45); opacity: 0; transition: opacity 0.22s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 26px 20px calc(var(--safe-bottom) + 20px);
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: grid; gap: 12px;
}
.sheet::before { content: ''; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line-strong); }
.sheet form { display: grid; gap: 14px; }
.sheet h2 { font: 800 30px/1 var(--display); }
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-scrim { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.center { justify-content: center; }
.chip { border: 0; border-radius: 999px; padding: 9px 15px; background: var(--bg); font-weight: 600; font-size: 15px; }
.chip[aria-pressed='true'] { background: var(--tide); color: var(--on-accent); }
.viewer img { width: 100%; max-height: 66dvh; object-fit: contain; border-radius: 16px; background: var(--line); display: block; }
.viewer p { margin-top: 10px; color: var(--muted); text-align: center; }
.viewer .row-btns { justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 88px); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; transition: opacity 0.25s, transform 0.25s;
  max-width: calc(100vw - 40px); padding: 12px 18px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 500; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Login & onboarding --------------------------------------------- */

.login, .onboard {
  min-height: 100dvh; max-width: 420px; margin: 0 auto;
  padding: calc(var(--safe-top) + 7vh) 24px calc(var(--safe-bottom) + 24px);
  display: flex; flex-direction: column;
}
.onboard { text-align: center; gap: 4px; }
.onboard .btn { margin-top: 12px; }
.onboard .hero-sub { margin-bottom: 18px; }
.login-mark { text-align: center; }
.wordmark { font: 900 56px/1 var(--display); letter-spacing: 1px; margin-top: 10px; }
.login-form { display: grid; gap: 12px; margin-top: 7vh; }
.login-form input { text-align: center; font-size: 20px; letter-spacing: 2px; }
.or { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0; }
.hint { text-align: center; color: var(--muted); font-size: 15px; }
.install { margin-top: auto; padding: 16px 18px; border-radius: 18px; background: var(--surface); font-size: 15px; }
.install .linkbtn { padding: 8px 0 0; }

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

.waterline { transition: transform 1s cubic-bezier(0.3, 0.7, 0.2, 1); }
