/* ============ Tokens ============ */
:root {
  --bg: #FFF7F2;
  --surface: #FFFFFF;
  --surface-2: #FBF0EA;
  --ink: #3A2E3B;
  --muted: #8E7D8C;
  --line: #F0E2DB;

  --rose: #EE6F92;   --rose-soft: #FFE4EB;
  --lav: #8B78E6;    --lav-soft: #ECE7FF;
  --moon: #E9A92B;   --moon-soft: #FFF1D2;
  --sage: #4FAE88;   --sage-soft: #DFF4EA;
  --storm: #7887A2;  --storm-soft: #E7ECF4;
  --sky: #3E9BD6;    --sky-soft: #E0F0FB;
  --peach: #E8834A;  --peach-soft: #FDE9DC;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 6px 24px -10px rgba(122, 72, 92, .25);
  --tabbar-h: 64px;
  font-family: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1624; --surface: #251F31; --surface-2: #2E2740; --ink: #F5ECF3; --muted: #A698B0; --line: #3A3149;
    --rose: #FF8AAB;  --rose-soft: #4A2637;
    --lav: #A898FF;   --lav-soft: #352D57;
    --moon: #F7C25A;  --moon-soft: #463619;
    --sage: #6CCBA4;  --sage-soft: #1F3C31;
    --storm: #9AA8C4; --storm-soft: #2D3445;
    --sky: #6FBDF0;   --sky-soft: #1C3346;
    --peach: #F5A06E; --peach-soft: #46291C;
    --shadow: 0 6px 24px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1624; --surface: #251F31; --surface-2: #2E2740; --ink: #F5ECF3; --muted: #A698B0; --line: #3A3149;
  --rose: #FF8AAB;  --rose-soft: #4A2637;
  --lav: #A898FF;   --lav-soft: #352D57;
  --moon: #F7C25A;  --moon-soft: #463619;
  --sage: #6CCBA4;  --sage-soft: #1F3C31;
  --storm: #9AA8C4; --storm-soft: #2D3445;
  --sky: #6FBDF0;   --sky-soft: #1C3346;
  --peach: #F5A06E; --peach-soft: #46291C;
  --shadow: 0 6px 24px -10px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.45; min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar-title { min-height: 40px; display: flex; align-items: center; font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }

/* ============ Views ============ */
.view { padding: 4px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); outline: none; }
.stack > * + * { margin-top: 14px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 22px 4px 8px;
}
.section-title a, .link { color: var(--rose); text-decoration: none; text-transform: none; letter-spacing: 0; font-weight: 700; font-size: .875rem; background: none; border: 0; padding: 0; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card.flat { box-shadow: none; }
.card-row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted);
}
.pill.rose { background: var(--rose-soft); color: var(--rose); }
.pill.moon { background: var(--moon-soft); color: var(--moon); }
.pill.sage { background: var(--sage-soft); color: var(--sage); }
.pill.storm { background: var(--storm-soft); color: var(--storm); }
.pill.lav { background: var(--lav-soft); color: var(--lav); }

/* ============ Buttons & inputs ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 800;
  background: var(--rose); color: #fff; min-height: 46px;
}
.btn.block { width: 100%; }
.btn.soft { background: var(--rose-soft); color: var(--rose); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: #D9534F; }
.btn:active { transform: scale(.98); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2);
  display: grid; place-items: center; color: var(--muted); flex: none;
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .8rem; font-weight: 800; color: var(--muted); margin: 0 4px 6px; }
.input, textarea.input, select.input {
  width: 100%; max-width: 100%; min-width: 0; display: block; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px;
  padding: 12px 14px; font-size: 16px; outline: none; min-height: 46px;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: .9rem; min-height: 40px;
}
.chip.on { border-color: var(--rose); background: var(--rose-soft); color: var(--rose); }

/* iOS-like switch */
.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span[aria-hidden] {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s;
}
.switch span[aria-hidden]::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s;
}
.switch input:checked + span[aria-hidden] { background: var(--moon); }
.switch input:checked + span[aria-hidden]::after { transform: translateX(20px); }
.switch input:focus-visible + span[aria-hidden] { box-shadow: 0 0 0 3px var(--moon-soft); }

/* ============ Tab bar ============ */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 20;
  width: 100%; max-width: 520px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 700; border-radius: 14px;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--rose); }
.tabbar a.active svg { fill: var(--rose-soft); }

/* ============ Sheet ============ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(40, 20, 35, .35);
  opacity: 0; transition: opacity .2s;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 50; left: 50%; bottom: 0; width: 100%; max-width: 520px;
  max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 100%); transition: transform .22s ease-out;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; position: sticky; top: -8px; background: var(--bg); padding: 6px 0; z-index: 1; }
.sheet-head h2 { font-size: 1.2rem; font-weight: 800; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .9rem;
  transition: all .2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ Home ============ */
.hello { margin: 6px 4px 14px; }
.hello h1 { font-size: 1.6rem; font-weight: 800; }
.hello p { margin: 2px 0 0; color: var(--muted); }

.tonight {
  position: relative; overflow: hidden; border-radius: 26px; padding: 20px;
  background: linear-gradient(140deg, #3B2D63 0%, #6E4D9E 55%, #E78BA8 120%); color: #fff;
  box-shadow: var(--shadow);
}
.tonight.apart { background: linear-gradient(140deg, #FFE4EB 0%, #ECE7FF 100%); color: var(--ink); }
:root[data-theme="dark"] .tonight.apart { background: linear-gradient(140deg, #3A2533 0%, #2C2747 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tonight.apart { background: linear-gradient(140deg, #3A2533 0%, #2C2747 100%); } }
.tonight .kicker { font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.tonight h2 { font-size: 1.5rem; font-weight: 800; margin: 4px 0 4px; max-width: 75%; }
.tonight p { margin: 0; opacity: .9; max-width: 75%; }
.tonight .moon-art { position: absolute; right: 12px; top: 10px; font-size: 76px; line-height: 1; filter: drop-shadow(0 6px 18px rgba(255, 220, 140, .5)); }
.tonight .stars { position: absolute; inset: 0; pointer-events: none; opacity: .7;
  background-image: radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 60% 18%, #fff 50%, transparent 51%),
                    radial-gradient(1.5px 1.5px at 80% 70%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 40% 80%, #fff 50%, transparent 51%); }
.tonight.apart .stars { display: none; }
.tonight .btn { margin-top: 14px; background: rgba(255,255,255,.2); color: inherit; min-height: 40px; padding: 8px 14px; font-size: .9rem; }
.tonight.apart .btn { background: var(--surface); }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 8px;
  border-radius: 16px; background: var(--surface-2); font-size: .75rem; font-weight: 800; color: var(--muted);
  border: 0; position: relative;
}
.week-day .num { font-size: 1rem; color: var(--ink); }
.week-day .ic { font-size: 1rem; height: 20px; line-height: 20px; }
.week-day.sleep { background: var(--moon-soft); color: var(--moon); }
.week-day.today { box-shadow: inset 0 0 0 2px var(--rose); }
.week-day.changed::after { content: ''; position: absolute; top: 6px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--rose); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; }
.stat span { font-size: .8rem; color: var(--muted); font-weight: 700; }

.event-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.event-row:last-child { border-bottom: 0; }
.event-ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.event-ic.rose { background: var(--rose-soft); } .event-ic.lav { background: var(--lav-soft); }
.event-ic.storm { background: var(--storm-soft); } .event-ic.sage { background: var(--sage-soft); }
.event-ic.moon { background: var(--moon-soft); }
.event-title { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-sub { font-size: .85rem; color: var(--muted); }
.countdown { text-align: right; font-weight: 800; color: var(--rose); font-size: .9rem; white-space: nowrap; }

.q-teaser { background: linear-gradient(140deg, var(--lav-soft), var(--rose-soft)); border: 0; text-align: left; width: 100%; }
.q-teaser .q { font-weight: 800; font-size: 1.05rem; margin: 6px 0 10px; }

/* ============ Calendar (flatpickr skin) ============ */
.cal-card { padding: 10px 6px 12px; }
.cal-card > input { display: none !important; }
.flatpickr-calendar.inline {
  width: 100% !important; max-width: none; box-shadow: none; background: transparent; border: 0;
  font-family: inherit; top: 0;
}
.flatpickr-calendar.inline::before, .flatpickr-calendar.inline::after { display: none; }
.flatpickr-innerContainer, .flatpickr-rContainer { width: 100%; display: block; }
.flatpickr-days { width: 100% !important; border: 0; }
.dayContainer { width: 100% !important; min-width: 100% !important; max-width: 100% !important; justify-content: flex-start; padding: 0; }
.flatpickr-weekdays { height: 32px; }
.flatpickr-weekdaycontainer { display: flex; width: 100%; }
span.flatpickr-weekday { color: var(--muted); font-weight: 800; font-size: .75rem; background: transparent; flex: 1; }
.flatpickr-months { align-items: center; padding: 4px 0 10px; }
.flatpickr-months .flatpickr-month { height: 44px; color: var(--ink); fill: var(--ink); background: transparent; }
.flatpickr-current-month { font-size: 1.15rem; font-weight: 800; padding-top: 10px; left: 12.5%; width: 75%; }
.flatpickr-current-month span.cur-month { font-weight: 800; margin-left: 0; }
.flatpickr-current-month span.cur-month:hover { background: transparent; }
.flatpickr-current-month input.cur-year { font-weight: 800; color: var(--ink); }
.flatpickr-current-month .numInputWrapper span { display: none; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month {
  top: 4px; height: 40px; width: 40px; padding: 12px; border-radius: 50%; color: var(--ink); fill: var(--ink);
  background: var(--surface-2); margin: 0 6px;
}
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--rose); }

.flatpickr-day {
  flex: 0 0 calc(100% / 7 - 4px) !important; max-width: none !important; margin: 2px;
  height: 52px; line-height: 1; border-radius: 14px; border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-weight: 800; color: var(--ink); position: relative;
}
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--surface-2); border-color: transparent; }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: var(--muted); opacity: .35; }
.flatpickr-day.today { border-color: var(--rose); }
.flatpickr-day.today:hover, .flatpickr-day.today:focus { border-color: var(--rose); background: var(--surface-2); color: var(--ink); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus {
  background: var(--lav); border-color: var(--lav); color: #fff;
}
.flatpickr-day.is-sleep { background: var(--moon-soft); }
.flatpickr-day.is-sleep.selected { background: var(--lav); }
.flatpickr-day.is-changed::before {
  content: ''; position: absolute; inset: 2px; border-radius: 11px; border: 1.5px dashed var(--moon); pointer-events: none;
}
.flatpickr-day .moon-ic { position: absolute; top: 3px; right: 4px; font-size: 9px; line-height: 1; }
.flatpickr-day .dots { display: flex; gap: 3px; height: 6px; }
.flatpickr-day .dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.rose { background: var(--rose); } .dot.lav { background: var(--lav); }
.dot.storm { background: var(--storm); } .dot.sage { background: var(--sage); }
.flatpickr-day.selected .dot { box-shadow: 0 0 0 1.5px #fff; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .78rem; font-weight: 700; color: var(--muted); padding: 4px 8px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend .sw-moon { border-radius: 3px; background: var(--moon-soft); border: 1.5px solid var(--moon); }
.legend .sw-changed { border-radius: 3px; border: 1.5px dashed var(--moon); }

.day-sleep { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; background: var(--moon-soft); }
.day-sleep.off { background: var(--surface-2); }
.day-sleep .big { font-size: 1.8rem; }

/* ============ Lists ============ */
.list-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.list-card { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; min-height: 130px; }
.list-card .emoji { font-size: 1.8rem; }
.list-card .name { font-weight: 800; font-size: 1.05rem; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: auto; }
.progress > i { display: block; height: 100%; background: var(--sage); border-radius: 3px; }
.list-card.add { align-items: center; justify-content: center; border: 2px dashed var(--line); background: transparent; box-shadow: none; color: var(--muted); font-weight: 800; }

.add-row { display: flex; gap: 8px; }
.add-row .btn { padding: 0 16px; }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface);
  display: grid; place-items: center; flex: none; color: #fff; font-size: .9rem; padding: 0;
}
.item.done .check { background: var(--sage); border-color: var(--sage); }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.item-text { flex: 1; min-width: 0; word-break: break-word; }
.item .icon-btn { width: 30px; height: 30px; background: transparent; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick button { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.3rem; }
.emoji-pick button.on { border-color: var(--rose); background: var(--rose-soft); }

/* ============ Us ============ */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--surface-2); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 12px; padding: 9px 10px; font-weight: 800; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.question-card { background: linear-gradient(150deg, var(--lav-soft), var(--rose-soft)); border: 0; }
.question-card .q { font-size: 1.25rem; font-weight: 800; margin: 8px 0 14px; }
.answer { background: var(--surface); border-radius: 16px; padding: 12px 14px; margin-top: 10px; }
.answer .who { font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.answer.locked { color: var(--muted); font-style: italic; }
.q-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.q-actions .btn { font-size: .9rem; padding: 10px 12px; }
.past-answer { margin-top: 8px; }
.fp-name { min-height: 40px; padding: 8px 10px; border-color: transparent; background: transparent; font-weight: 700; }
.fp-name:focus { background: var(--surface); }
.gcal-link { text-decoration: none; margin-top: 4px; }
.q-pick { background: none; border: 0; padding: 4px 0; text-align: left; font-weight: 600; }
.past-answer b { display: block; font-size: .8rem; color: var(--muted); }

/* Long text with a "Read more…" toggle */
.clamp { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.clamp.open { display: block; -webkit-line-clamp: unset !important; }
.more { display: inline-block; margin-top: 4px; }

.fact { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; }
.fact:last-child { border-bottom: 0; }
.fact .label { font-size: .8rem; font-weight: 800; color: var(--muted); }
.fact .val { font-weight: 700; }
.fact .val.is-empty { color: var(--muted); font-weight: 600; font-style: italic; }

.note-card { position: relative; padding: 14px 16px; border-radius: 18px; background: var(--moon-soft); }
.note-card:nth-child(3n+2) { background: var(--rose-soft); }
.note-card:nth-child(3n+3) { background: var(--lav-soft); }
.note-card .meta { font-size: .78rem; font-weight: 800; color: var(--muted); margin-top: 6px; }
.note-card .icon-btn { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; background: transparent; }
.notes { display: grid; gap: 10px; }

/* ============ Settings ============ */
.set-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row > label:not(.switch) { flex: 1; font-weight: 700; }
.set-row .input { max-width: 52%; }
.set-row .hint { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.weekday-pick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 14px 16px; }
.weekday-pick button {
  aspect-ratio: 1; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 800; font-size: .8rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
}
.weekday-pick button.on { background: var(--moon-soft); border-color: var(--moon); color: var(--ink); }
.weekday-pick button .m { font-size: .9rem; height: 16px; }

.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.who-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px; border-radius: 20px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; }
.who-btn.on { border-color: var(--rose); background: var(--rose-soft); }
.who-emoji { font-size: 2rem; }

/* Kid view */
.kid-week { display: grid; gap: 8px; }
.kid-day { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 18px; background: var(--surface-2); font-size: 1.15rem; font-weight: 800; }
.kid-day.sleep { background: var(--moon-soft); }
.kid-day .ic { font-size: 1.6rem; width: 34px; text-align: center; }
.kid-day.today { box-shadow: inset 0 0 0 2px var(--rose); }

.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 6px; }

@media (min-width: 420px) {
  .view { padding-left: 20px; padding-right: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ============ Sign in ============ */
.signed-out .topbar, .signed-out .tabbar { display: none; }
.auth { max-width: 400px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 4px 40px; text-align: center; }
.auth-moon { font-size: 64px; line-height: 1; margin-bottom: 14px; filter: drop-shadow(0 8px 22px rgba(233, 169, 43, .45)); }
.auth h1 { font-size: 1.6rem; font-weight: 800; }
.auth > p { margin: 6px 0 22px; }
.auth form { text-align: left; }
.auth-error { background: var(--rose-soft); color: var(--rose); border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: .9rem; margin-bottom: 12px; }
.auth-msg { background: var(--moon-soft); border-radius: 14px; padding: 12px 14px; font-weight: 700; font-size: .9rem; margin-bottom: 16px; }
.auth-switch { margin-top: 18px; color: var(--muted); font-size: .9rem; }

/* Shown while changes are waiting for a connection */
.is-offline .topbar-title::after {
  content: 'offline · will sync'; display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: .7rem; font-weight: 800; color: var(--muted); background: var(--surface-2); padding: 3px 8px; border-radius: 999px;
}
.invite-box { display: flex; gap: 8px; padding: 0 16px 14px; }
.invite-box .input { font-size: .85rem; max-width: none; }

/* iOS Safari: date inputs ignore width and center their text unless reset */
input[type="date"].input { -webkit-appearance: none; appearance: none; text-align: left; line-height: 1.2; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; margin: 0; }
.field, .set-row, .sheet-body, form { min-width: 0; }
.sheet { overflow-x: hidden; }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.date-row > :only-child { grid-column: 1 / -1; }
.date-row .field span i { font-weight: 600; font-style: normal; }

/* Entry type colors (picked in Settings) */
.dot.peach { background: var(--peach); } .dot.sky { background: var(--sky); } .dot.moon { background: var(--moon); }
.event-ic.peach { background: var(--peach-soft); } .event-ic.sky { background: var(--sky-soft); }
.event-ic.add { background: var(--surface-2); color: var(--muted); font-weight: 800; }
.type-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; }
.type-row .event-ic { width: 36px; height: 36px; border-radius: 12px; font-size: 1.05rem; }
.type-preview { display: flex; justify-content: center; margin: 0 0 16px; }
.type-preview .event-ic { width: 64px; height: 64px; border-radius: 20px; font-size: 2rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--bg); box-shadow: 0 0 0 1.5px var(--line); padding: 0; }
.swatch.on { box-shadow: 0 0 0 2.5px var(--ink); }
.swatch.rose { background: var(--rose); } .swatch.peach { background: var(--peach); } .swatch.moon { background: var(--moon); }
.swatch.sage { background: var(--sage); } .swatch.sky { background: var(--sky); } .swatch.lav { background: var(--lav); } .swatch.storm { background: var(--storm); }
.emoji-input { width: 92px !important; min-height: 44px; text-align: center; font-size: 1.2rem; padding: 6px; }

/* Thoughts added later under an answer */
.thought { margin-top: 10px; padding: 8px 0 0 12px; border-left: 2px solid var(--line); }
.thought[data-thought] { cursor: pointer; }
.thought-date { font-size: .75rem; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.thought.is-new { border-left-color: var(--rose); }
.add-thought { display: inline-block; margin-top: 8px; }
.past-answer .add-thought { font-size: .8rem; }

/* Gentle "new" dot */
.new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rose); margin-left: 6px; vertical-align: middle; }
.tabbar a { position: relative; }
.tabbar a.has-new::after { content: ''; position: absolute; top: 5px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 2px var(--surface); }

/* Swiping between months */
.cal-card .flatpickr-calendar { touch-action: pan-y; }
.flatpickr-days.slide-next { animation: slide-next .22s ease-out; }
.flatpickr-days.slide-prev { animation: slide-prev .22s ease-out; }
@keyframes slide-next { from { transform: translateX(28px); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes slide-prev { from { transform: translateX(-28px); opacity: .2; } to { transform: none; opacity: 1; } }
