@font-face {
  font-family: 'Bodoni Moda';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/bodoni-moda.woff2) format('woff2');
}
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/figtree.woff2) format('woff2');
}

/* ---------- Velvet tokens ---------- */
:root {
  --bg: #17101B;
  --surface: #211826;
  --raised: #2A1F30;
  --ink: #F3E8EC;
  --muted: #AE9AA8;
  --faint: #6F5E6A;
  --line: #31253A;
  --accent: #E3B3A7;
  --accent-ink: #2A1720;
  --accent-soft: #3A2733;
  --danger: #E89A9A;
  --scrim: rgba(5, 2, 6, .55);
  --glass: rgba(33, 24, 38, .74);
  --font-d: 'Bodoni Moda', Georgia, serif;
  --font-b: 'Figtree', system-ui, -apple-system, sans-serif;
  --radius: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); }
body {
  color: var(--ink);
  font-family: var(--font-b);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* Scroll-edge fade under the status bar */
.edge {
  position: fixed; top: 0; left: 0; right: 0; height: calc(var(--safe-top) + 18px);
  background: linear-gradient(var(--bg) 55%, transparent);
  z-index: 5; pointer-events: none;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 28px) 22px calc(var(--safe-bottom) + 112px);
}
.app.no-tabs { padding-bottom: calc(var(--safe-bottom) + 40px); }

/* ---------- Type ---------- */
.date { font-size: 14px; color: var(--muted); margin: 0; }
.title {
  font-family: var(--font-d); font-weight: 400;
  font-size: 40px; line-height: 1.05; letter-spacing: -0.015em;
  margin: 2px 0 0;
}
.head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
.lede { margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.lede b { color: var(--ink); font-weight: 600; }
.sec { margin-top: 32px; }
.sec-h {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 0 2px; font-family: var(--font-d); font-weight: 400; font-size: 17px;
}
.sec-h small { font-family: var(--font-b); font-size: 13px; color: var(--muted); }
.empty { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }

/* ---------- Progress ring ---------- */
.ring { position: relative; width: 58px; height: 58px; }
.ring svg { width: 58px; height: 58px; transform: rotate(-90deg); overflow: visible; }
.ring .track { fill: none; stroke: var(--line); stroke-width: 3; }
.ring .arc {
  fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
  transition: stroke-dashoffset 700ms var(--ease-in-out);
  filter: drop-shadow(0 0 5px rgba(227, 179, 167, .55));
}
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-d); font-size: 21px; }

/* ---------- Rows ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative; display: grid; grid-template-columns: 30px 1fr auto; column-gap: 14px;
  align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; padding: 4px 0; }
.row-title { display: block; font-size: 16px; line-height: 1.3; transition: color 200ms ease; overflow-wrap: anywhere; }
.row-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row.is-done .row-title { color: var(--muted); }
.row.punish .row-sub { color: var(--accent); }
.row.punish .ck-ring { border-color: var(--accent); }
.row.overdue .row-sub { color: var(--danger); }
.meta { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pips { display: flex; gap: 4px; justify-content: flex-end; margin-top: 5px; }
.pips b { width: 6px; height: 6px; border-radius: 50%; background: var(--line); transition: background-color 200ms ease; }
.pips b.on { background: var(--accent); }
.bloom {
  position: absolute; inset: 0 -22px; pointer-events: none; opacity: 0;
  background: radial-gradient(120px 60px at 37px 50%, rgba(227, 179, 167, .22), transparent 70%);
}

/* ---------- The check: Velvet glow ---------- */
.check {
  position: relative; width: 30px; height: 30px; border: 0; padding: 0;
  background: none; border-radius: 50%; cursor: pointer;
}
.check::before { content: ''; position: absolute; inset: -9px; }
.check:disabled { cursor: default; }
.ck-ring {
  position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--faint);
  transition: border-color 180ms ease, transform 120ms var(--ease-out), opacity 180ms ease;
}
.check:not(:disabled):active .ck-ring { transform: scale(.88); }
.ck-glow {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #F8DCD3, var(--accent) 58%, #B98479);
  box-shadow: 0 0 18px rgba(227, 179, 167, .5);
  opacity: 0; transform: scale(.6);
  transition: opacity 220ms ease, transform 380ms var(--ease-out);
}
.ck-mark {
  position: absolute; left: 3px; top: 3px; width: 24px; height: 24px;
  fill: none; stroke: var(--accent-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset 280ms var(--ease-out);
}
.is-done .ck-glow { opacity: 1; transform: scale(1); }
.is-done .ck-ring { opacity: 0; }
.is-done .ck-mark { stroke-dashoffset: 0; transition-delay: 90ms; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 20px; min-height: 46px;
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
  transition: transform 120ms var(--ease-out), background-color 160ms ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.block { width: 100%; }
.linkish {
  border: 0; background: none; padding: 6px 0; color: var(--accent); font-weight: 500; cursor: pointer;
  font-size: 14px;
}
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 14px; color: var(--muted); }
.input {
  width: 100%; border: 0; border-radius: 12px; padding: 12px 14px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px; line-height: 1.4;
}
.input::placeholder { color: var(--faint); }
textarea.input { resize: none; min-height: 76px; }
.input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.stepper { display: inline-grid; grid-template-columns: 46px 52px 46px; align-items: center; justify-items: center; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); width: max-content; }
.stepper button { width: 46px; height: 46px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--accent); }
.stepper button:disabled { color: var(--faint); cursor: default; }
.stepper output { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.error { color: var(--danger); font-size: 14px; margin: -6px 0 12px; }

/* ---------- Manage list ---------- */
.mrow {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list li:last-child > .mrow { border-bottom: 0; }
.mrow .chev { width: 8px; height: 8px; border-right: 1.5px solid var(--faint); border-top: 1.5px solid var(--faint); transform: rotate(45deg); margin-right: 4px; }
.mrow.static { cursor: default; }
.add { font-family: var(--font-b); }

/* ---------- Overview ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-top: 12px; }
.wk { display: grid; gap: 6px; justify-items: center; font-size: 12px; color: var(--muted); }
.wk .bar { position: relative; width: 100%; height: 48px; border-radius: 7px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.wk .fill { position: absolute; inset: 0; background: var(--accent); opacity: .8; transform-origin: bottom; transform: scaleY(0); transition: transform 600ms var(--ease-in-out); }
.wk.today { color: var(--ink); font-weight: 600; }
.wk.today .fill { opacity: 1; }
.wk.future .bar { background: transparent; box-shadow: inset 0 0 0 1px var(--line); opacity: .5; }
.wrow { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.wrow:last-child { border-bottom: 0; }
.feed li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .t { font-size: 15px; }
.feed .tm { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .n { grid-column: 1 / -1; font-size: 14px; color: var(--muted); font-style: italic; }
.open-list { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.closes { font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.closes .linkish { padding: 0; margin-left: 4px; text-decoration: none; }

/* ---------- Her view (owner preview) ---------- */
.preview-bar {
  position: sticky; top: 0; z-index: 7;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: calc(-1 * var(--safe-top) - 28px) -22px 0; padding: calc(var(--safe-top) + 12px) 22px 12px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 1px 0 var(--line);
}
.back { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; text-decoration: none; }
.back::before { content: ''; width: 8px; height: 8px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: none; border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background-color 160ms ease, color 160ms ease; }
.seg button[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); }
.preview-note { margin: 16px 0 24px; font-size: 14px; color: var(--muted); }
.preview-frame { border-top: 1px solid var(--line); padding-top: 24px; }

/* ---------- Rules ---------- */
.rules { list-style: none; margin: 18px 0 0; padding: 0; counter-reset: r; }
.rules li { counter-increment: r; display: grid; grid-template-columns: 28px 1fr; padding: 14px 0; border-bottom: 1px solid var(--line); line-height: 1.45; }
.rules li:last-child { border-bottom: 0; }
.rules li::before { content: counter(r); font-family: var(--font-d); color: var(--accent); font-size: 19px; line-height: 1.2; }

/* ---------- Settings ---------- */
.setting { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.setting .input { width: auto; padding: 8px 12px; }

/* ---------- Sign-in ---------- */
.signin { min-height: calc(100dvh - var(--safe-top) - 80px); display: grid; align-content: center; justify-items: center; text-align: center; gap: 0; }
.signin .mark { width: 64px; height: 64px; position: relative; margin-bottom: 26px; }
.signin .mark .ck-glow { opacity: 1; transform: none; }
.signin .mark .ck-mark { left: 14px; top: 14px; width: 36px; height: 36px; stroke-width: 2.4; stroke-dashoffset: 0; }
.signin .title { font-size: 48px; }
.signin p { color: var(--muted); max-width: 30ch; margin: 12px 0 30px; }
.signin .btn { min-width: 240px; }
.signin .g { width: 18px; height: 18px; }
.signin .dev { margin-top: 26px; display: grid; gap: 10px; }
.signin .notice { color: var(--danger); margin: -14px 0 24px; max-width: 32ch; font-size: 14px; }

/* ---------- Tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 20px calc(var(--safe-bottom) + 10px);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 -1px 0 var(--line);
}
.tabs a {
  position: relative; flex: 0 1 140px; text-align: center; text-decoration: none;
  padding: 12px 10px 14px; font-size: 14px; font-weight: 500; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"]::after {
  content: ''; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--accent);
}

/* ---------- Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.sheet-wrap.open { pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 280ms ease; }
.sheet-wrap.open .scrim { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: calc(100dvh - var(--safe-top) - 24px); overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 22px calc(var(--safe-bottom) + 24px);
  border-radius: 28px 28px 0 0; background: var(--raised);
  transform: translateY(100%); transition: transform 440ms var(--ease-drawer);
}
.sheet-wrap.open .sheet { transform: translateY(0); }
.sheet.kb { padding-bottom: 16px; border-radius: 28px; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 16px; }
.sheet .btn.ghost, .sheet .btn.danger { box-shadow: inset 0 0 0 1.5px rgba(243, 232, 236, .14); }
.sheet .input { background: var(--bg); }
.sheet .stepper { box-shadow: inset 0 0 0 1.5px rgba(243, 232, 236, .14); }
.sheet h2 { margin: 0 0 18px; font-family: var(--font-d); font-weight: 400; font-size: 28px; letter-spacing: -0.015em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; top: calc(var(--safe-top) + 10px); z-index: 30;
  max-width: 520px; margin: 0 auto; padding: 14px 16px; border-radius: 18px;
  background: var(--glass); backdrop-filter: blur(22px) saturate(170%); -webkit-backdrop-filter: blur(22px) saturate(170%);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .5), inset 0 0 0 1px var(--line);
  font-size: 15px;
  transform: translateY(calc(-100% - var(--safe-top) - 20px));
  transition: transform 420ms var(--ease-drawer);
  pointer-events: none;
}
.toast.show { transform: translateY(0); }

@media (hover: hover) and (pointer: fine) {
  .btn.ghost:hover, .btn.danger:hover { background: var(--surface); }
  .mrow:hover .row-title { color: var(--accent); }
  .tabs a:hover { color: var(--ink); }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .sheet, .ring .arc, .wk .fill { transition-duration: 1ms !important; }
  .toast:not(.show) { opacity: 0; }
  .ck-glow { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .tabs, .toast { background: var(--raised); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
