/* Daily — modern monochrome minimalism. Fredoka, Apple-radius cards, soft springs. */

:root {
  --paper: #f5f5f5;
  --card: #ffffff;
  --ink: #121212;
  --ink-soft: #7d7d7d;
  --ink-faint: #c9c9c9;
  --line: #ececec;
  --shadow: 0 1px 2px rgb(0 0 0 / .03), 0 12px 32px -12px rgb(0 0 0 / .10);
  --r: 28px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --paper: #0e0e0e;
  --card: #1a1a1a;
  --ink: #f2f2f2;
  --ink-soft: #8e8e8e;
  --ink-faint: #4a4a4a;
  --line: #272727;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -12px rgb(0 0 0 / .5);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--paper);
  transition: background .5s var(--ease-out);
}

body {
  font-family: "Fredoka", sans-serif;
  font-weight: 400;
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .5s var(--ease-out), color .5s var(--ease-out);
}

::selection { background: var(--ink); color: var(--paper); }

button { font-family: inherit; }
input, textarea { font-family: inherit; }

/* ---------- gate ---------- */

.gate {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--paper);
  z-index: 10;
}
.gate-inner { text-align: center; animation: rise .8s var(--ease-out) both; }
.gate-mark {
  width: 14px; height: 14px; border: 2.5px solid var(--ink);
  border-radius: 50%; margin: 0 auto 1.3rem;
  animation: pulse 3s ease-in-out infinite;
}
.gate-word {
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -.01em;
}
.gate-sub {
  font-size: .9rem;
  font-weight: 300;
  color: var(--ink-soft);
  margin: .2rem 0 2.2rem;
}
.gate-form {
  display: flex; align-items: center; gap: .4rem;
  width: 300px;
  margin: 0 auto;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: .35rem .35rem .35rem 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color .3s, transform .3s var(--ease-spring);
}
.gate-form:focus-within { border-color: var(--ink); transform: scale(1.02); }
.gate-go {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  font-size: 1.05rem;
  cursor: pointer;
  display: grid; place-items: center;
  opacity: .3;
  transition: transform .35s var(--ease-spring), opacity .3s;
}
.gate-form:focus-within .gate-go { opacity: 1; }
.gate-go:hover { transform: scale(1.06); }
.gate-go:active { transform: scale(.92); }
#gate-input {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  background: none;
  border: none;
  color: var(--ink);
  padding: .5rem 0;
  text-align: left;
  outline: none;
  letter-spacing: .25em;
}
#gate-input::placeholder { letter-spacing: .05em; color: var(--ink-faint); font-weight: 300; }
.gate-error {
  font-size: .8rem;
  color: var(--ink-soft);
  margin-top: 1rem;
  min-height: 1em;
}
.gate.shake .gate-inner { animation: shake .4s; }

/* ---------- onboarding ---------- */

.onboard {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--paper);
  z-index: 9;
  padding: 2rem 1.6rem;
}
.onboard-steps { width: min(400px, 100%); }
.ob-step { animation: rise .6s var(--ease-out) both; }
.ob-step .gate-mark { margin: 0 0 1.6rem; }
.ob-title {
  font-size: clamp(2.1rem, 8vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.12;
  margin-bottom: .9rem;
}
.ob-text {
  font-size: .98rem;
  font-weight: 300;
  color: var(--ink-soft);
  line-height: 1.65;
  margin-bottom: 1.6rem;
  max-width: 34ch;
}
.ob-text strong { color: var(--ink); font-weight: 500; }
.ob-quiet { margin-top: -0.8rem; }
.ob-label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .6rem;
}
.ob-input {
  width: 100%;
  font-size: 1.05rem;
  font-weight: 400;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  padding: .85rem 1.15rem;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color .3s;
}
.ob-input:focus { border-color: var(--ink); }
.ob-input::placeholder { color: var(--ink-faint); font-weight: 300; }
.ob-next {
  display: block;
  width: 100%;
  margin-top: 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1rem;
  font-weight: 500;
  padding: .95rem 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .35s var(--ease-spring), opacity .3s;
}
.ob-next:hover { transform: translateY(-2px); }
.ob-next:active { transform: scale(.97); }
.ob-rituals { list-style: none; margin-bottom: .8rem; }
.ob-rituals li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card);
  border-radius: 14px;
  padding: .6rem 1rem;
  margin-bottom: .45rem;
  font-size: .98rem;
  box-shadow: var(--shadow);
  animation: itemIn .4s var(--ease-out) both;
}
.ob-rituals .ob-x {
  background: none; border: none; color: var(--ink-faint);
  font-size: .95rem; cursor: pointer; padding: 0 .2rem;
}
.ob-ritual-form { display: flex; gap: .5rem; align-items: center; }
.ob-add {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border: none; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  font-size: 1.25rem; cursor: pointer;
  transition: transform .35s var(--ease-spring);
}
.ob-add:active { transform: scale(.9); }
.ob-dots {
  position: absolute;
  bottom: max(2.2rem, env(safe-area-inset-bottom, 0px) + 1.4rem);
  left: 50%; transform: translateX(-50%);
  display: flex; gap: .5rem;
}
.ob-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-faint);
  transition: background .3s, transform .35s var(--ease-spring);
}
.ob-dot.on { background: var(--ink); transform: scale(1.3); }
.ob-step.leaving { animation: swapOut .22s var(--ease-out) both; }

/* ---------- layout ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 2.6rem) 1.2rem 3.5rem;
}

/* ---------- masthead ---------- */

.masthead { animation: rise .7s var(--ease-out) both; padding: 0 .4rem; }

.masthead-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem;
}
.greeting {
  font-size: .88rem;
  font-weight: 300;
  color: var(--ink-soft);
}
.date-title {
  font-size: clamp(1.9rem, 6vw, 2.3rem);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.date-title .past-tag {
  font-size: .8rem; font-weight: 400; color: var(--ink-soft);
  vertical-align: middle; margin-left: .5rem;
}

.masthead-actions { display: flex; align-items: center; gap: .7rem; padding-top: .3rem; }

.save-state {
  font-size: .7rem;
  font-weight: 300;
  letter-spacing: .06em;
  color: var(--ink-soft);
  transition: opacity .4s;
  opacity: 0;
}
.save-state[data-state="saving"] { opacity: .8; }
.save-state[data-state="saved"] { opacity: .55; animation: fadeHold 1.6s forwards; }

.theme-toggle {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .3s, transform .5s var(--ease-spring), background .5s;
}
.theme-toggle:hover { border-color: var(--ink); transform: rotate(180deg) scale(1.05); }
.theme-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ink);
  transition: background .5s, box-shadow .5s;
}
html[data-theme="dark"] .theme-dot {
  background: transparent;
  box-shadow: inset 3px -3px 0 0 var(--ink);
}

/* ---------- day pills ---------- */

.days {
  display: flex; gap: .45rem;
  margin-top: 1.5rem;
  overflow-x: auto;
  padding: .4rem .2rem .8rem;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent, black 4%, black 96%, transparent);
          mask-image: linear-gradient(to right, transparent, black 4%, black 96%, transparent);
}
.days::-webkit-scrollbar { display: none; }

.day-pill {
  flex: 0 0 auto;
  width: 46px;
  padding: .55rem 0 .5rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  transition: background .35s var(--ease-out), color .35s, transform .35s var(--ease-spring), box-shadow .35s;
}
.day-pill:hover { transform: translateY(-3px); color: var(--ink); }
.day-pill .dow { font-size: .62rem; font-weight: 400; letter-spacing: .08em; opacity: .8; }
.day-pill .dom { font-size: .95rem; font-weight: 500; line-height: 1.2; }
.day-pill .mark {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: 0;
  transition: opacity .3s;
}
.day-pill[data-has="1"] .mark { opacity: .55; }
.day-pill[data-current="1"] {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}
.day-pill[data-current="1"]:hover { transform: none; }

/* ---------- cards ---------- */

.panel { margin-top: .6rem; }

.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.5rem 1.4rem;
  margin-bottom: 1rem;
  animation: cardIn .9s cubic-bezier(.22, 1.2, .36, 1) both;
  animation-delay: calc(.08s + var(--i) * .11s);
  transition: background .5s var(--ease-out);
  will-change: transform, opacity;
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .9rem;
}
.label {
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.count {
  font-size: .78rem;
  font-weight: 400;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.round-btn {
  background: var(--paper);
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  color: var(--ink-soft);
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: color .25s, background .3s, transform .35s var(--ease-spring);
}
.round-btn:hover { color: var(--paper); background: var(--ink); transform: rotate(90deg) scale(1.08); }

/* ---------- hero ---------- */

.card-hero {
  display: flex; align-items: center; gap: 1.4rem;
  padding: 1.6rem 1.7rem;
}
.ring { flex: 0 0 auto; width: 132px; height: 132px; position: relative; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring .halo-dot { fill: var(--ink); transition: opacity .6s; }
.ring .p-dot {
  fill: var(--ink-faint);
  transform-box: fill-box; transform-origin: center;
  transition: fill .45s, transform .45s var(--ease-spring);
}
.ring .p-dot.on { fill: var(--ink); transform: scale(1.65); }

.hero-figures { flex: 1; min-width: 0; }
.pct {
  font-size: clamp(2.9rem, 10vw, 3.6rem);
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pct-sign { font-size: .5em; font-weight: 400; color: var(--ink-soft); margin-left: .06em; }
.pct-sub {
  font-size: .82rem;
  font-weight: 300;
  color: var(--ink-soft);
  margin-top: .45rem;
}

/* ---------- checks ---------- */

.check {
  --size: 26px;
  width: var(--size); height: var(--size);
  flex: 0 0 var(--size);
  background: none; border: none; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.check svg { width: 100%; height: 100%; overflow: visible; }
.check .ring-c {
  fill: none; stroke: var(--ink-faint); stroke-width: 1.8;
  transition: stroke .3s;
}
.check:hover .ring-c { stroke: var(--ink); }
.check .fill-c {
  fill: var(--ink); transform-origin: center;
  transform: scale(0);
  transition: transform .45s var(--ease-spring);
}
.checked-row .check .fill-c, .task.done .check .fill-c { transform: scale(1); }
.check .tick-c {
  fill: none; stroke: var(--card); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 16; stroke-dashoffset: 16;
  transition: stroke-dashoffset .35s var(--ease-out) .12s, stroke .5s;
}
.checked-row .check .tick-c, .task.done .check .tick-c { stroke-dashoffset: 0; }

/* ---------- scrollable card lists ---------- */

.rituals, .tasks, .notes {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
}
.rituals::-webkit-scrollbar, .tasks::-webkit-scrollbar, .notes::-webkit-scrollbar { width: 4px; }
.rituals::-webkit-scrollbar-thumb, .tasks::-webkit-scrollbar-thumb, .notes::-webkit-scrollbar-thumb {
  background: var(--ink-faint);
  border-radius: 999px;
}
.rituals { max-height: 232px; }
.tasks { max-height: 320px; }
.notes {
  max-height: 348px;
  padding: 4px; margin: -4px;   /* room for hover lift + shadow inside the clip */
}
/* soft fade at the edges, only while the list actually scrolls */
.rituals.scrolly, .tasks.scrolly, .notes.scrolly {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, black 14px, black calc(100% - 14px), transparent 100%);
}

/* ---------- rituals ---------- */

.rituals { list-style: none; }
.ritual {
  display: flex; align-items: center; gap: .9rem;
  padding: .55rem 0;
  animation: itemIn .45s var(--ease-out) both;
}
.ritual-label { flex: 1; font-size: 1rem; font-weight: 400; transition: color .35s; }
.ritual.checked-row .ritual-label { color: var(--ink-soft); }
.streak {
  font-size: .78rem;
  font-weight: 500;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  background: var(--paper);
  border-radius: 999px;
  padding: .18rem .6rem;
  transition: color .3s, background .3s;
}
.ritual.checked-row .streak { color: var(--paper); background: var(--ink); }
.streak:empty { display: none; }
.streak.tick { animation: popIn .45s var(--ease-spring); }
.ritual-del, .task-del {
  background: none; border: none; color: var(--ink-faint);
  font-size: .95rem; cursor: pointer; opacity: 0;
  transition: opacity .2s, color .2s, transform .3s var(--ease-spring);
  padding: .15rem .35rem;
  border-radius: 50%;
}
.ritual:hover .ritual-del, .task:hover .task-del { opacity: .7; }
.ritual-del:hover, .task-del:hover { color: var(--ink); opacity: 1; transform: scale(1.25); }

.inline-form { padding: .5rem 0 .2rem; }
#ritual-input {
  width: 100%;
  font-size: 1rem;
  background: var(--paper);
  border: none; outline: none;
  border-radius: 999px;
  color: var(--ink);
  padding: .6rem 1.1rem;
}

/* ---------- tasks (ink card) ---------- */

.card-ink {
  background: var(--ink);
  color: var(--paper);
}
.card-ink .label, .card-ink .count { color: color-mix(in srgb, var(--paper) 62%, transparent); }

.tasks { list-style: none; }
.task {
  display: flex; align-items: flex-start; gap: .9rem;
  padding: .6rem 0;
  border-radius: 12px;
  animation: itemIn .5s cubic-bezier(.22, 1.2, .36, 1) both;
  transition: opacity .3s, transform .4s var(--ease-spring);
}
.task:hover { transform: translateX(3px); }

/* tactile press feedback everywhere */
.check:active svg { transform: scale(.8); }
.check svg { transition: transform .3s var(--ease-spring); }
.day-pill:active, .round-btn:active, .theme-toggle:active, .profile-btn:active { transform: scale(.9); }
.ritual:active .ritual-label, .task:active .task-text { opacity: .7; }

.card-ink .check { margin-top: .05rem; }
.card-ink .check .ring-c { stroke: color-mix(in srgb, var(--paper) 40%, transparent); }
.card-ink .check:hover .ring-c { stroke: var(--paper); }
.card-ink .check .fill-c { fill: var(--paper); }
.card-ink .check .tick-c { stroke: var(--ink); }

.task-text {
  flex: 1; font-size: 1rem; font-weight: 400;
  position: relative;
  transition: color .4s, opacity .4s;
  word-break: break-word;
  padding-top: .05rem;
}
.task-text::after {
  content: "";
  position: absolute; left: -2px; right: -2px; top: .78em;
  height: 1.5px; background: color-mix(in srgb, var(--paper) 55%, transparent);
  transform: scaleX(0); transform-origin: left center;
  transition: transform .45s var(--ease-out);
  border-radius: 2px;
}
.task.done .task-text { opacity: .45; }
.task.done .task-text::after { transform: scaleX(1); }

.card-ink .task-del { color: color-mix(in srgb, var(--paper) 45%, transparent); margin-top: .1rem; }
.card-ink .task-del:hover { color: var(--paper); }

.task-add {
  display: flex; align-items: center; gap: .8rem;
  margin-top: .7rem;
  background: color-mix(in srgb, var(--paper) 10%, transparent);
  border-radius: 999px;
  padding: .55rem 1.1rem;
  transition: background .3s;
}
.task-add:focus-within { background: color-mix(in srgb, var(--paper) 16%, transparent); }
.task-add-mark {
  color: color-mix(in srgb, var(--paper) 55%, transparent);
  font-size: 1.05rem;
  transition: color .3s, transform .35s var(--ease-spring);
}
.task-add:focus-within .task-add-mark { color: var(--paper); transform: rotate(90deg); }
#task-input {
  flex: 1;
  font-size: .98rem;
  background: none; border: none; outline: none;
  color: var(--paper);
}
#task-input::placeholder, #ritual-input::placeholder, .note::placeholder {
  color: inherit; opacity: .45; font-weight: 300;
}

.empty {
  font-size: .95rem;
  font-weight: 300;
  opacity: .5;
  padding: .3rem 0 .1rem;
}

/* ---------- notes ---------- */

.notes { list-style: none; }
.note-item {
  background: var(--paper);
  border-radius: 18px;
  padding: .75rem 1rem .65rem;
  margin-bottom: .55rem;
  animation: itemIn .55s cubic-bezier(.22, 1.2, .36, 1) both;
  position: relative;
  transition: background .5s var(--ease-out),
              transform .45s var(--ease-spring),
              box-shadow .45s var(--ease-out);
}
.note-item:hover {
  transform: translateY(-2px) scale(1.008);
  box-shadow: 0 6px 18px -8px rgb(0 0 0 / .16);
}
.note-item.fresh { animation: notePop .6s cubic-bezier(.22, 1.4, .36, 1) both; }
.note-text {
  font-size: .95rem;
  font-weight: 300;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .35rem;
}
.note-time {
  font-size: .66rem;
  font-weight: 400;
  letter-spacing: .08em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.note-del {
  background: none; border: none; color: var(--ink-faint);
  font-size: .85rem; cursor: pointer; opacity: 0;
  padding: 0 .2rem;
  transition: opacity .2s, color .2s, transform .3s var(--ease-spring);
}
.note-item:hover .note-del { opacity: .7; }
.note-del:hover { color: var(--ink); opacity: 1; transform: scale(1.25); }

.empty-soft {
  font-size: .92rem;
  font-weight: 300;
  color: var(--ink-faint);
  padding: .2rem 0 .3rem;
}

.note-add {
  display: flex; align-items: flex-end; gap: .6rem;
  margin-top: .8rem;
  background: var(--paper);
  border-radius: 22px;
  padding: .5rem .5rem .5rem 1.1rem;
  transition: box-shadow .3s, background .5s var(--ease-out);
}
.note-add:focus-within { box-shadow: inset 0 0 0 1.5px var(--ink-faint); }
.note-input {
  flex: 1;
  font-size: .95rem;
  font-weight: 300;
  line-height: 1.5;
  background: none; border: none; outline: none;
  color: var(--ink);
  resize: none;
  max-height: 9rem;
  padding: .3rem 0;
}
.note-send {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 1rem;
  cursor: pointer;
  display: grid; place-items: center;
  opacity: .25;
  transition: opacity .3s, transform .35s var(--ease-spring);
}
.note-add:focus-within .note-send { opacity: 1; }
.note-send:hover { transform: translateY(-2px) scale(1.06); }
.note-send:active { transform: scale(.92); }

/* ---------- profile ---------- */

.profile-btn {
  width: 36px; height: 36px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
  overflow: hidden;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  transition: border-color .3s, transform .4s var(--ease-spring);
}
.profile-btn:hover { border-color: var(--ink); transform: scale(1.08); }
.avatar {
  width: 100%; height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  display: grid; place-items: center;
  font-size: .82rem;
  font-weight: 500;
  color: var(--paper);
  background-color: var(--ink);
}
.avatar-big { font-size: 1.6rem; }

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / .28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 20;
  animation: fadeIn .35s var(--ease-out) both;
}
.sheet-backdrop.closing { animation: fadeOut .25s var(--ease-out) both; }

.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: .8rem 1.7rem calc(1.6rem + env(safe-area-inset-bottom, 0px));
  z-index: 21;
  box-shadow: 0 -8px 40px -12px rgb(0 0 0 / .25);
  animation: sheetUp .55s cubic-bezier(.22, 1.2, .36, 1) both;
  transition: background .5s var(--ease-out);
}
.sheet.closing { animation: sheetDown .3s var(--ease-out) both; }

@media (min-width: 920px) {
  .sheet {
    bottom: auto; top: 50%;
    border-radius: 28px;
    animation: sheetPop .5s cubic-bezier(.22, 1.3, .36, 1) both;
    transform: translate(-50%, -50%);
    padding-bottom: 1.6rem;
  }
  .sheet.closing { animation: sheetPopOut .25s var(--ease-out) both; }
  .sheet-handle { visibility: hidden; }
}

.sheet-handle {
  width: 38px; height: 4px;
  border-radius: 999px;
  background: var(--ink-faint);
  margin: 0 auto 1.3rem;
  opacity: .6;
}
.sheet-avatar-wrap { display: grid; place-items: center; margin-bottom: 1.4rem; }
.sheet-avatar {
  position: relative;
  width: 84px; height: 84px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
  transition: transform .4s var(--ease-spring), border-color .3s;
}
.sheet-avatar:hover { transform: scale(1.05); border-color: var(--ink); }
.avatar-edit-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  background: rgb(0 0 0 / .45);
  padding: .22rem 0 .3rem;
  opacity: 0;
  transition: opacity .25s;
}
.sheet-avatar:hover .avatar-edit-hint { opacity: 1; }

.sheet-label {
  display: block;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .45rem;
}
.sheet-input {
  width: 100%;
  font-size: 1.02rem;
  background: var(--paper);
  border: 1.5px solid transparent;
  border-radius: 16px;
  color: var(--ink);
  padding: .7rem 1rem;
  outline: none;
  margin-bottom: 1.1rem;
  transition: border-color .3s, background .5s var(--ease-out);
}
.sheet-input:focus { border-color: var(--ink); }
.sheet-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .15rem;
  border-top: 1px solid var(--line);
}
.sheet-row-label { font-size: .92rem; font-weight: 300; color: var(--ink-soft); }
.sheet-row-value { font-size: .92rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.sheet-chip {
  border: 1.5px solid var(--line);
  background: none;
  border-radius: 999px;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 500;
  padding: .3rem .9rem;
  cursor: pointer;
  transition: border-color .25s, transform .35s var(--ease-spring);
}
.sheet-chip:hover { border-color: var(--ink); }
.sheet-chip:active { transform: scale(.92); }
.sheet-signout {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  border: none;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: .95rem;
  font-weight: 500;
  padding: .85rem;
  cursor: pointer;
  transition: background .3s, color .3s, transform .35s var(--ease-spring);
}
.sheet-signout:hover { background: var(--ink); color: var(--paper); }
.sheet-signout:active { transform: scale(.97); }

@keyframes sheetUp {
  from { transform: translate(-50%, 105%); }
  to { transform: translate(-50%, 0); }
}
@keyframes sheetDown {
  from { transform: translate(-50%, 0); }
  to { transform: translate(-50%, 105%); }
}
@keyframes sheetPop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.92); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes sheetPopOut {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -47%) scale(.95); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ---------- avatar cropper ---------- */

.cropper {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgb(0 0 0 / .45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 30;
  animation: fadeIn .3s var(--ease-out) both;
  padding: 1.4rem;
}
.crop-card {
  background: var(--card);
  border-radius: 26px;
  padding: 1.5rem 1.5rem 1.3rem;
  width: min(340px, 100%);
  box-shadow: 0 20px 60px -18px rgb(0 0 0 / .4);
  animation: sheetPopIn .5s cubic-bezier(.22, 1.3, .36, 1) both;
  text-align: center;
}
@keyframes sheetPopIn {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
  to { opacity: 1; transform: none; }
}
.crop-title {
  font-size: .95rem;
  font-weight: 500;
  margin-bottom: 1rem;
}
.crop-viewport {
  position: relative;
  width: 264px; height: 264px;
  margin: 0 auto;
  border-radius: 20px;
  overflow: hidden;
  background: var(--paper);
  cursor: grab;
  touch-action: none;
}
.crop-viewport:active { cursor: grabbing; }
#crop-img {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  max-width: none;
}
.crop-mask {
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 400px rgb(0 0 0 / .38);
  pointer-events: none;
}
.crop-zoom {
  width: 80%;
  margin: 1.1rem auto .9rem;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  outline: none;
}
.crop-zoom::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  transition: transform .3s var(--ease-spring);
}
.crop-zoom::-webkit-slider-thumb:hover { transform: scale(1.2); }
.crop-actions { display: flex; gap: .6rem; }
.crop-btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 500;
  padding: .75rem;
  cursor: pointer;
  transition: transform .35s var(--ease-spring), opacity .3s;
}
.crop-btn:active { transform: scale(.95); }
.crop-cancel { background: var(--paper); color: var(--ink-soft); }
.crop-confirm { background: var(--ink); color: var(--paper); }

/* ---------- footer ---------- */

.foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.6rem;
  padding: 0 .6rem;
  font-size: .68rem;
  font-weight: 300;
  letter-spacing: .05em;
  color: var(--ink-faint);
  animation: rise .7s var(--ease-out) .5s both;
}
kbd {
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .4em;
  background: var(--card);
}
.foot-hint kbd { margin-right: .1em; }

@media (max-width: 480px) {
  .foot-hint { display: none; }
  .foot { justify-content: center; }
  .card-hero { gap: 1.1rem; padding: 1.4rem 1.3rem; }
  .ring { width: 112px; height: 112px; }
}

/* ---------- iPhone / touch polish ---------- */

.app {
  padding-left: max(1.2rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.2rem, env(safe-area-inset-right, 0px));
  padding-top: max(clamp(1.4rem, 4vw, 2.6rem), env(safe-area-inset-top, 0px));
  padding-bottom: max(3.5rem, env(safe-area-inset-bottom, 0px) + 2rem);
}

@media (pointer: coarse) {
  /* 16px+ inputs stop iOS Safari's focus zoom */
  #task-input, #ritual-input, .note-input, #gate-input, .ob-input { font-size: 16px; }
  /* comfortable tap targets without changing the visual size */
  .check { --size: 28px; position: relative; }
  .check::after { content: ""; position: absolute; inset: -9px; }
  .task-del, .ritual-del, .note-del { opacity: .45; padding: .3rem .5rem; }
  .day-pill { width: 48px; }
  .theme-toggle { width: 40px; height: 40px; }
}

/* ---------- desktop ---------- */

@media (min-width: 920px) {
  .app {
    max-width: 1000px;
    padding-top: 3.2rem;
  }
  .masthead {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 2rem;
    padding: 0 .6rem;
  }
  .masthead-top { flex: 0 0 auto; }
  .days {
    margin-top: 0;
    justify-content: flex-end;
    -webkit-mask-image: linear-gradient(to right, transparent, black 6%);
            mask-image: linear-gradient(to right, transparent, black 6%);
  }
  .panel {
    margin-top: 1.4rem;
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 1.1rem;
    align-items: start;
  }
  .col { display: flex; flex-direction: column; gap: 1.1rem; }
  .card { margin-bottom: 0; padding: 1.7rem 1.7rem 1.6rem; }
  .card-hero { padding: 1.9rem 1.9rem; }
  .ring { width: 148px; height: 148px; }
}

/* ---------- keyframes ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes cardIn {
  0% { opacity: 0; transform: translateY(26px) scale(.96); filter: blur(6px); }
  60% { filter: blur(0); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes itemOut {
  to { opacity: 0; transform: translateX(14px); }
}
@keyframes notePop {
  0% { opacity: 0; transform: translateY(14px) scale(.92); }
  60% { transform: translateY(-2px) scale(1.015); }
  100% { opacity: 1; transform: none; }
}
@keyframes popIn {
  0% { transform: scale(.6); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.7); opacity: .5; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}
@keyframes fadeHold {
  0%, 70% { opacity: .55; }
  100% { opacity: 0; }
}
@keyframes swapOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes swapIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.panel.swap-out, .masthead-top.swap-out { animation: swapOut .22s var(--ease-out) both; }
.panel.swap-in, .masthead-top.swap-in { animation: swapIn .4s var(--ease-out) both; }

/* theme wipe via view transitions */
::view-transition-old(root), ::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-new(root) { z-index: 1; }
::view-transition-old(root) { z-index: 0; }

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

/* ---------- auth ---------- */

.auth-form { display: grid; gap: .7rem; width: 280px; margin: 0 auto; }
.auth-field { text-align: left; }
.auth-submit { margin-top: .3rem; }
.auth-switch {
  background: none; border: none;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 300;
  color: var(--ink-soft);
  cursor: pointer;
  margin-top: 1.2rem;
  transition: color .25s;
}
.auth-switch:hover { color: var(--ink); }
.auth-switch strong { font-weight: 500; color: var(--ink); }
.sheet-email { font-weight: 300; font-size: .8rem; color: var(--ink-soft); max-width: 60%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- coach-mark tour ---------- */

.tour { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.tour-spot {
  position: fixed;
  border-radius: 32px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / .5);
  pointer-events: none;
  transition: top .5s cubic-bezier(.22,1.2,.36,1), left .5s cubic-bezier(.22,1.2,.36,1),
              width .5s cubic-bezier(.22,1.2,.36,1), height .5s cubic-bezier(.22,1.2,.36,1);
}
.tour-tip {
  position: fixed;
  width: min(320px, calc(100vw - 24px));
  background: var(--card);
  border-radius: 20px;
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 16px 48px -14px rgb(0 0 0 / .4);
  pointer-events: auto;
  transition: top .5s cubic-bezier(.22,1.2,.36,1), left .5s cubic-bezier(.22,1.2,.36,1);
  animation: sheetPopIn .5s cubic-bezier(.22,1.3,.36,1) both;
}
.tour-text { font-size: .95rem; font-weight: 300; line-height: 1.55; margin-bottom: .9rem; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; }
.tour-skip {
  background: none; border: none;
  font-family: inherit; font-size: .82rem; font-weight: 400;
  color: var(--ink-faint); cursor: pointer;
  transition: color .25s;
}
.tour-skip:hover { color: var(--ink); }
.tour-next {
  border: none; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-family: inherit; font-size: .85rem; font-weight: 500;
  padding: .5rem 1.2rem; cursor: pointer;
  transition: transform .35s var(--ease-spring);
}
.tour-next:active { transform: scale(.93); }
.tour-dots { display: flex; gap: .35rem; }
.tour-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); transition: background .3s, transform .3s var(--ease-spring); }
.tour-dot.on { background: var(--ink); transform: scale(1.4); }

/* ---------- google auth button ---------- */

.auth-google {
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  width: 280px;
  margin: .8rem auto 0;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit; font-size: .92rem; font-weight: 500;
  padding: .75rem 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .3s, transform .35s var(--ease-spring);
}
.auth-google:hover { border-color: var(--ink); transform: translateY(-1px); }
.auth-google:active { transform: scale(.97); }

.auth-divider {
  display: flex; align-items: center; gap: .8rem;
  width: 280px; margin: 1rem auto;
  color: var(--ink-faint);
  font-size: .72rem; font-weight: 400;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
