:root {
  --ground: #F3F5F7;
  --surface: #FFFFFF;
  --ink: #17202E;
  --ink-2: #3E4A5C;
  --muted: #556070;
  --accent: #2F4B7C;
  --accent-ink: #1E3358;
  --accent-soft: #E3E9F2;
  --on-accent: #FFFFFF;
  --on-accent-soft: #C9D6EA;
  --border: #E1E6EC;
  --line: #9AA6B6;
  --track-off: #B8C2CF;
  --field: #F9FAFB;
  --field-border: #C9D2DE;
  --serif: Newsreader, Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0F1520;
    --surface: #18212F;
    --ink: #E8EDF4;
    --ink-2: #C3CCD8;
    --muted: #9AA6B6;
    --accent: #8FAEE0;
    --accent-ink: #DCE6F7;
    --accent-soft: #223149;
    --on-accent: #0F1520;
    --on-accent-soft: #2F4B7C;
    --border: #263244;
    --line: #556070;
    --track-off: #3A475A;
    --field: #121A26;
    --field-border: #34425A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
  padding: calc(20px + env(safe-area-inset-top)) 22px calc(100px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  outline: none;
}

/* Bottom navigation */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(68px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  z-index: 10;
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 11px; color: var(--muted); min-height: 44px;
}
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabs svg, .ico {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.ico.sm { width: 18px; height: 18px; stroke-width: 1.8; }

/* Type */
.eyebrow { font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.1; }
.h1.sm { font-size: 32px; }
.h2 { margin: 0; font-size: 17px; font-weight: 600; }
.label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.lede { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Layout pieces */
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.card.lg { border-radius: 22px; padding: 16px 20px; }
.card.soft { background: var(--accent-soft); }
.card.dashed { background: transparent; border: 1.5px dashed var(--line); flex-direction: row; align-items: flex-start; gap: 12px; }

.hero {
  background: var(--accent); color: var(--on-accent);
  border-radius: 22px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 12px;
  position: relative; overflow: hidden;
}
.hero .rings { position: absolute; right: -40px; top: -40px; opacity: .18; }
.hero .label { color: var(--on-accent-soft); }
.hero p { margin: 0; font-family: var(--serif); font-size: 19px; line-height: 1.35; position: relative; }
@media (prefers-color-scheme: dark) { .hero .label { color: #2F4B7C; } }

.back {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; font-size: 15px;
}

/* Buttons */
.btn {
  min-height: 48px; border: none; border-radius: 14px;
  background: var(--accent); color: var(--on-accent);
  font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 18px;
}
.btn.lg { min-height: 54px; border-radius: 16px; font-size: 16px; }
.btn.soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn.pill {
  align-self: flex-start; border-radius: 999px; min-height: 44px;
  background: var(--surface); color: var(--accent-ink); font-weight: 500;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.text { background: transparent; color: var(--accent); min-height: 44px; padding: 0 8px; font-weight: 500; }
.btn.danger { background: transparent; color: #A33A3A; border: 1.5px solid currentColor; }
@media (prefers-color-scheme: dark) { .btn.danger { color: #E08A8A; } }
.btn:disabled { opacity: .55; cursor: default; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 22px; flex: none;
  background: var(--surface); color: var(--accent); border: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn.filled { background: var(--accent); color: var(--on-accent); }
.iconbtn.outline { background: var(--surface); border: 1.5px solid var(--accent); font-size: 20px; }

/* Moments dots */
.dots { display: flex; flex-wrap: wrap; gap: 8px; }
.dot {
  width: 22px; height: 22px; border-radius: 11px;
  border: 1.5px solid var(--accent);
  transition: background .3s;
}
.dot.on { background: var(--accent); }

/* List items */
.item {
  background: var(--surface); border-radius: 16px;
  padding: 10px 14px; min-height: 60px;
  display: flex; align-items: center; gap: 14px; color: var(--ink);
}
.badge {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.badge.round { width: 36px; height: 36px; border-radius: 18px; font-family: var(--serif); font-size: 18px; font-weight: 400; }
.title { font-size: 15px; font-weight: 500; }
.sub { font-size: 13px; color: var(--muted); }
.check {
  width: 44px; height: 44px; margin: -11px -11px -11px 0; flex: none;
  border: none; background: transparent; padding: 11px;
  display: flex; align-items: center; justify-content: center;
}
.check span {
  width: 22px; height: 22px; border-radius: 11px; display: block;
  border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.check.on span { background: var(--accent); border-color: var(--accent); }
.check svg { width: 14px; height: 14px; stroke: var(--on-accent); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Timer */
.timer { display: flex; justify-content: center; padding: 6px 0; }
.dial { width: 250px; height: 250px; position: relative; display: flex; align-items: center; justify-content: center; }
.dial svg { position: absolute; inset: 0; }
.dial .face { fill: var(--surface); stroke: var(--accent-soft); }
.dial .inner { fill: none; stroke: var(--accent-soft); }
.dial .prog { fill: none; stroke: var(--accent); transition: stroke-dashoffset 1s linear; }
.clock { font-size: 44px; font-weight: 300; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.seg button {
  min-height: 44px; border-radius: 999px; border: 1.5px solid var(--accent);
  background: var(--surface); color: var(--accent-ink); font-size: 14px; font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.instruction { margin: 0; font-family: var(--serif); font-size: 19px; line-height: 1.35; }

/* Forms */
textarea {
  resize: vertical; width: 100%;
  border: 1px solid var(--field-border); border-radius: 12px;
  padding: 10px 12px; font-size: 15px; line-height: 1.4;
  background: var(--field); color: var(--ink);
}
.switch {
  width: 52px; height: 32px; border-radius: 16px; border: none; padding: 3px; flex: none;
  background: var(--track-off); display: flex; justify-content: flex-start;
  transition: background .2s;
}
.switch span { width: 26px; height: 26px; border-radius: 13px; background: #FFFFFF; }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }
.list { padding: 4px 16px; gap: 0; }
.list > .li { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list > .li:last-child { border-bottom: none; }

/* Pad */
.bar { height: 6px; border-radius: 3px; background: var(--accent-soft); display: flex; overflow: hidden; }
.bar span { background: var(--accent); border-radius: 3px; transition: width .4s; }
ol.points { margin: 0; padding-left: 20px; font-family: var(--serif); font-size: 16px; line-height: 1.45; display: flex; flex-direction: column; gap: 2px; }

/* Week mirror */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week .c {
  width: 34px; height: 34px; border-radius: 17px;
  border: 1.5px solid var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--on-accent);
}
.week .c.on { background: var(--accent); border-color: var(--accent); }
.week .c.today { border-color: var(--accent); }
.week .c.future { border-style: dashed; opacity: .5; }
.week .d.today > span:first-child { color: var(--accent); font-weight: 600; }

article.entry p { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 14px; line-height: 1.5; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ground);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); text-align: center;
  z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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