:root {
  color-scheme: light;
  --peach: #FFB38A;
  --coral: #FF7A85;
  --lilac: #B9A4FF;
  --sky: #8FD3FF;
  --cream: #FFF8F1;
  --ink: #2B2440;
  --bg: var(--cream);
  --card: #FFFEFC;
  --text: var(--ink);
  --muted: #665B73;
  --page: #F2EAF8;
  --line: #E8DCD7;
  --peach-wash: #FFF0E7;
  --coral-wash: #FFECEF;
  --lilac-wash: #F0EBFF;
  --sky-wash: #E9F7FF;
  --focus: #6441B5;
  --danger: #A12643;
  --scrim: rgba(23, 19, 31, 0.62);
  --shadow: rgba(43, 36, 64, 0.12);
  --shadow-soft: rgba(43, 36, 64, 0.07);
  --clear: rgba(255, 255, 255, 0);
  --glass: rgba(255, 254, 252, 0.88);
  --viewer-bg: #17131F;
  --viewer-text: #F6F1FF;
  --viewer-muted: #D2C8DF;
  --viewer-control: rgba(246, 241, 255, 0.14);
  --empty-dot: #DCD1E2;
  --selection: #E4D9FF;
  --accent: var(--coral);
}

:root.night-active {
  color-scheme: dark;
  --bg: #241C1A;
  --page: #171312;
  --card: #342724;
  --text: #FFF1DD;
  --muted: #E6CDB5;
  --line: #694D40;
  --peach-wash: #4A3028;
  --coral-wash: #4B2931;
  --lilac-wash: #393048;
  --sky-wash: #263D4B;
  --focus: #D9C6FF;
  --danger: #FFB4BF;
  --scrim: rgba(0,0,0,.76);
  --glass: rgba(52,39,36,.92);
  --viewer-bg: #110E0D;
  --viewer-text: #FFF1DD;
  --viewer-muted: #E6CDB5;
  --viewer-control: rgba(255,241,221,.16);
  --empty-dot: #6A554C;
  --selection: #5D4564;
  --shadow: rgba(0,0,0,.42);
  --shadow-soft: rgba(0,0,0,.28);
  transition: background-color 600ms ease, color 600ms ease;
}
:root.night-active #dot-field { opacity: .35; }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --peach: #FFC0A1;
    --coral: #FF959D;
    --lilac: #C9BBFF;
    --sky: #ABDFFF;
    --bg: #17131F;
    --card: #221C2E;
    --text: #F6F1FF;
    --muted: #C9BED5;
    --page: #100D17;
    --line: #493D57;
    --peach-wash: #38282C;
    --coral-wash: #382631;
    --lilac-wash: #2D2641;
    --sky-wash: #21313F;
    --focus: #CDBEFF;
    --danger: #FFA9B6;
    --scrim: rgba(0, 0, 0, 0.72);
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-soft: rgba(0, 0, 0, 0.2);
    --glass: rgba(34, 28, 46, 0.9);
    --viewer-control: rgba(246, 241, 255, 0.16);
    --empty-dot: #51445E;
    --selection: #493B6B;
  }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: var(--clear);
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

a {
  color: inherit;
}

svg {
  display: block;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.18;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 8vw, 38px);
}

h2 {
  margin-bottom: 12px;
  font-size: 24px;
}

h3 {
  margin-bottom: 8px;
  font-size: 19px;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
h1:focus:not(:focus-visible), h2:focus:not(:focus-visible), h3:focus:not(:focus-visible) { outline: none; }

.skip-navigation {
  position: fixed;
  z-index: 100;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  min-height: 48px;
  padding: 12px 16px;
  transform: translateY(-180%);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 20px var(--shadow);
  font-weight: 700;
}

.skip-navigation:focus {
  transform: translateY(0);
}

.phone-shell {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: clip;
}

.app-main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 20px calc(144px + env(safe-area-inset-bottom));
}

.screen {
  width: 100%;
  opacity: 1;
}

.screen--exit {
  opacity: 0;
  transition: opacity 180ms ease-in;
}

.screen--enter {
  opacity: 0;
  transform: translateY(12px);
}

.screen--enter.screen--visible {
  opacity: 1;
  transform: translateY(0);
  transition: transform 260ms ease-out, opacity 260ms ease-out;
}

#dot-field {
  position: absolute;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  inset: 0;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    animation: card-in 260ms ease-out both;
    animation-delay: var(--stagger, 0ms);
  }
}

.empty-doodle > svg,
.door-sun > svg {
  width: 100%;
  height: 100%;
}

.screen-header {
  position: relative;
  margin-bottom: 24px;
}
.screen:not([data-screen="home"]) .screen-header::before { content: ''; position: absolute; z-index: -1; top: -24px; right: -20px; left: -20px; height: 8px; opacity: .7; background: var(--wallpaper-gradient); }
.help-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.me-button { position: absolute; top: 0; right: 0; min-width: 44px; min-height: 44px; border-radius: 50%; background: var(--accent); color: var(--ink); font-weight: 700; }
/* The help button (decision D2): same place on every screen, above every sheet (.layer z 50), the toast (80),
   the skip link and the noscript note (100). A 44 px target, never animated. */
.help-button { position: fixed; z-index: 1000; transition: none; animation: none; right: max(16px, calc((100vw - 480px) / 2 + 16px)); bottom: calc(76px + env(safe-area-inset-bottom)); display: inline-flex; gap: 6px; align-items: center; min-height: 44px; padding: 10px 16px; border-radius: 999px; background: var(--card); box-shadow: 0 4px 16px var(--shadow); text-decoration: none; font-size: 14px; font-weight: 700; }

.screen-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.screen-header-row > div {
  min-width: 0;
}

.screen-subtitle {
  max-width: 36ch;
  margin-bottom: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.muted,
.helper {
  color: var(--muted);
}

.helper {
  margin: 12px 0 0;
  font-size: 14px;
}

.pressable {
  transition: transform 120ms ease-out;
}

.pressable:active {
  transform: scale(0.97);
}

.primary-button,
.secondary-button,
.soft-button,
.delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 20px;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 6px 16px var(--shadow-soft);
}

.primary-button svg,
.secondary-button svg,
.soft-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.primary-button svg path[d^="m9"] {
  fill: currentColor;
  stroke: none;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.soft-button {
  background: var(--lilac-wash);
  color: var(--text);
}

.full-width {
  width: 100%;
}

.text-button,
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 4px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  color: var(--accent);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.icon-button {
  display: inline-flex;
  flex: 0 0 48px;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.empty-state,
.error-state {
  padding: 28px 24px;
  border: 1px dashed var(--line);
  border-radius: 24px;
  background: var(--card);
  text-align: center;
}

.empty-state p:last-child,
.error-state p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.empty-doodle {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  color: var(--coral);
}

/* Home */
.home-greeting {
  position: relative;
  padding-top: 4px;
}
:root[data-wallpaper="waves"] { --wallpaper-gradient: linear-gradient(135deg, rgba(143,211,255,.34), rgba(255,179,138,.28)); }
:root[data-wallpaper="hills"] { --wallpaper-gradient: linear-gradient(135deg, rgba(185,164,255,.34), rgba(143,211,255,.28)); }
:root[data-wallpaper="rainbow"] { --wallpaper-gradient: linear-gradient(135deg, rgba(255,122,133,.28), rgba(185,164,255,.34)); }
:root[data-wallpaper="confetti"] { --wallpaper-gradient: linear-gradient(135deg, rgba(255,179,138,.34), rgba(255,122,133,.28)); }
:root[data-wallpaper="bloom"] { --wallpaper-gradient: linear-gradient(135deg, rgba(185,164,255,.32), rgba(255,179,138,.3)); }
:root[data-wallpaper="sun"] { --wallpaper-gradient: linear-gradient(135deg, rgba(255,179,138,.4), rgba(255,248,241,.2)); }
.screen[data-screen="home"]::before { content: ''; position: fixed; z-index: 0; top: 0; right: 0; bottom: 0; left: 0; opacity: .25; background: var(--wallpaper-gradient); -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 100%); mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 100%); pointer-events: none; }
.screen[data-screen="home"] > * { position: relative; z-index: 1; }

.home-date {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
}

.surprise-card {
  position: relative;
  min-height: 220px;
  margin-bottom: 24px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--peach-wash);
  box-shadow: 0 10px 28px var(--shadow-soft);
}

.surprise-content {
  min-height: 96px;
}

.surprise-text {
  margin-bottom: 20px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.surprise-doodle {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.surprise-doodle svg {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  color: var(--coral);
}

.surprise-doodle p {
  margin: 0;
  font-weight: 700;
}

.quick-heading {
  margin-bottom: 12px;
  font-size: 19px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-tile {
  display: flex;
  min-width: 0;
  min-height: 128px;
  padding: 16px 8px;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border-radius: 24px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.quick-tile:nth-child(1) {
  background: var(--coral-wash);
}

.quick-tile:nth-child(2) {
  background: var(--lilac-wash);
}

.quick-tile:nth-child(3) {
  background: var(--sky-wash);
}

.quick-tile svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.home-footer {
  margin-top: 16px;
  text-align: center;
}

/* Watch */
.watch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.watch-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 6px 18px var(--shadow-soft);
  text-align: left;
}

.watch-card .art {
  aspect-ratio: 4 / 3;
  border-radius: 0;
}

.watch-info {
  padding: 12px;
}

.watch-title {
  display: block;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.watch-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

/* Generated artwork */
.art {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 22px;
  color: var(--ink);
  isolation: isolate;
}

.art svg {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
}

.art-0 { background: linear-gradient(145deg, var(--peach), var(--coral)); }
.art-1 { background: linear-gradient(145deg, var(--sky), var(--lilac)); }
.art-2 { background: linear-gradient(145deg, var(--lilac), var(--peach)); }
.art-3 { background: linear-gradient(145deg, var(--coral), var(--lilac)); }
.art-4 { background: linear-gradient(145deg, var(--peach), var(--sky)); }
.art-5 { background: linear-gradient(145deg, var(--sky), var(--peach)); }
.art-6 { background: linear-gradient(160deg, var(--lilac), var(--sky)); }
.art-7 { background: linear-gradient(160deg, var(--coral), var(--peach)); }
.art-8 { background: linear-gradient(160deg, var(--sky), var(--coral)); }
.art-9 { background: linear-gradient(160deg, var(--peach), var(--lilac)); }
.art-10 { background: linear-gradient(160deg, var(--lilac), var(--coral)); }
.art-11 { background: linear-gradient(160deg, var(--sky), var(--lilac)); }
.watch-card .art { color: var(--coral); }
.watch-card .art-1,
.watch-card .art-6,
.watch-card .art-11 { color: var(--lilac); }
.watch-card .art-2,
.watch-card .art-5,
.watch-card .art-8 { color: var(--sky); }
.watch-card .art-4,
.watch-card .art-7,
.watch-card .art-9 { color: var(--peach); }
:root.night-active .watch-card .art { opacity: .7; }

.art--tall { aspect-ratio: 3 / 4.4; }
.art--medium { aspect-ratio: 3 / 3.5; }
.art--short { aspect-ratio: 3 / 2.8; }
.art--square { aspect-ratio: 1; }

/* Gallery */
.masonry {
  column-count: 2;
  column-gap: 12px;
}

.gallery-card {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  break-inside: avoid;
  border-radius: 22px;
  background: transparent;
  box-shadow: 0 6px 18px var(--shadow-soft);
}

.gallery-card .art {
  margin: 0;
}
.gallery-card img, .viewer-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* The sheet is a column: its fields scroll, and Save sits BELOW them, in its own row above the fixed help
   button (76 px up, 44 px tall). So Save is never under the button and never covers a field. */
.setup-sheet { position: absolute; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; max-height: 92%; overflow: hidden; padding: 24px 20px 0; border-radius: 28px 28px 0 0; background: var(--card); }
#setup-form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.setup-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#setup-form > button[type="submit"] { flex: none; margin: 12px 0 calc(136px + env(safe-area-inset-bottom)); }
.swatch-options, .wallpaper-options { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch input, .wallpaper-choice input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 40px; height: 40px; border: 3px solid transparent; border-radius: 50%; }
.swatch input:checked + span { border-color: var(--text); }
.wallpaper-choice { width: 64px; }
.wallpaper-choice .art { width: 64px; height: 56px; }
.toggle-row { display: flex; gap: 10px; align-items: center; margin: 20px 0; }
.link-form { display: grid; gap: 10px; margin-top: 20px; }
.saved-link { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }

/* Journal */
.privacy-note {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--lilac-wash);
}

.privacy-note svg {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.privacy-note p {
  margin: 0;
  font-weight: 700;
}

.privacy-note small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.write-button {
  margin-bottom: 28px;
}

.journal-day {
  margin-bottom: 24px;
}

.journal-day > h2 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0;
}

.entry-card {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 88px;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  text-align: left;
}

.entry-copy {
  min-width: 0;
  flex: 1;
}

.entry-title {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.entry-first-line {
  display: block;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-mood {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  color: var(--coral);
}

/* Check-in */
.checkin-form {
  display: grid;
  gap: 20px;
}

.checkin-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
}

.mood-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.mood-field legend {
  width: 100%;
  margin-bottom: 16px;
  padding: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mood-field legend span,
.field-label span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
}

.mood-options {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2px;
}

.mood-choice {
  position: relative;
  display: flex;
  min-width: 48px;
  min-height: 72px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.mood-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.mood-face {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid var(--clear);
  border-radius: 50%;
  color: var(--text);
  transition: transform 120ms ease-out;
}

.mood-face svg,
.week-face svg,
.entry-mood svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.mood-choice input:checked + .mood-face {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  transform: translateY(-2px);
}

.mood-choice input:checked ~ .mood-label {
  color: var(--text);
  font-weight: 700;
}

.mood-choice input:focus-visible + .mood-face {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sleep-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sleep-heading label {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sleep-heading output {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.sleep-slider {
  width: 100%;
  height: 48px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.sleep-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 8px;
  background: var(--lilac-wash);
}

.sleep-slider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border: 3px solid var(--card);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--coral);
  box-shadow: 0 2px 8px var(--shadow);
}

.sleep-slider::-moz-range-track {
  height: 8px;
  border-radius: 8px;
  background: var(--lilac-wash);
}

.sleep-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 3px solid var(--card);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 2px 8px var(--shadow);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.week-section {
  margin-top: 28px;
}

.week-section h2 {
  font-size: 20px;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 12px 4px;
  border-radius: 22px;
  background: var(--card);
}

.week-day {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.week-face {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--coral);
}

.week-empty {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--empty-dot);
}

.week-note {
  margin: 8px 4px 0;
  color: var(--muted);
  font-size: 13px;
}

/* Door */
.door-screen {
  display: flex;
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
  flex-direction: column;
  justify-content: center;
  padding-bottom: 32px;
  text-align: center;
}

.door-sun {
  width: 144px;
  height: 144px;
  margin: 0 auto 28px;
  color: var(--coral);
}

.door-screen .screen-subtitle {
  margin-right: auto;
  margin-bottom: 28px;
  margin-left: auto;
}

.door-actions {
  display: grid;
  gap: 8px;
}

.door-demo-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.door-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Navigation */
.tab-bar {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: 100%;
  max-width: 480px;
  min-height: calc(72px + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 6px 4px env(safe-area-inset-bottom);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: var(--glass);
  box-shadow: 0 -6px 24px var(--shadow-soft);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.tab-link {
  display: flex;
  min-width: 0;
  min-height: 60px;
  padding: 5px 1px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.tab-link svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.tab-link[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text);
}

.tab-link[aria-current="page"] svg {
  color: var(--accent);
}

/* Sheets, viewer and writer */
.layer {
  position: fixed;
  z-index: 50;
  inset: 0;
}

.layer-backdrop {
  position: absolute;
  background: var(--scrim);
  inset: 0;
}

.media-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  /* Clears the fixed help button, so it never sits over Play. */
  padding: 20px 20px calc(136px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 28px 28px 0 0;
  background: var(--card);
  box-shadow: 0 -12px 40px var(--shadow);
  animation: sheet-in 260ms ease-out both;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 4px;
  background: var(--line);
}

.sheet-close {
  position: absolute;
  z-index: 2;
  top: 20px;
  right: 20px;
}

.media-art {
  height: min(38vh, 300px);
  margin-bottom: 20px;
}

.media-art .art {
  height: 100%;
  border-radius: 24px;
}

.media-sheet .primary-button {
  width: 100%;
  margin-top: 8px;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.viewer-layer {
  background: var(--viewer-bg);
  color: var(--viewer-text);
}

.viewer {
  position: relative;
  display: grid;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.viewer-header {
  z-index: 2;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
}

.viewer-header p {
  margin: 0;
  color: var(--viewer-muted);
  font-size: 14px;
}

.viewer .icon-button {
  background: var(--viewer-control);
  color: var(--viewer-text);
}

.viewer-art {
  display: grid;
  width: calc(100% - 40px);
  min-width: 0;
  min-height: 0;
  margin: auto;
  padding: 0;
  place-items: center;
  border-radius: 24px;
  background: transparent;
  touch-action: pan-y;
}

.viewer-art .art {
  width: 100%;
  height: min(64vh, 620px);
  max-height: 100%;
  border-radius: 24px;
}

.viewer-arrow {
  position: absolute;
  z-index: 3;
  top: 50%;
  transform: translateY(-50%);
}

.viewer-arrow:active {
  transform: translateY(-50%) scale(0.97);
}

.viewer-previous { left: 8px; }
.viewer-next { right: 8px; }

.viewer-footer {
  min-height: 104px;
  /* Clears the fixed help button, so it never sits over "Delete picture". */
  padding: 20px 28px calc(132px + env(safe-area-inset-bottom));
  text-align: center;
}

.viewer-footer h2 {
  margin-bottom: 4px;
  color: var(--viewer-text);
  font-size: 22px;
}

.viewer-footer p {
  margin: 0;
  color: var(--viewer-muted);
  font-size: 13px;
}

.writer-layer {
  overflow-y: auto;
  background: var(--bg);
}

.writer {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  /* Room under the last line for the fixed help button. */
  padding-bottom: calc(136px + env(safe-area-inset-bottom));
  background: var(--bg);
}

.writer-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: grid;
  min-height: calc(68px + env(safe-area-inset-top));
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.writer-header h2 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.writer-header .text-button:first-child {
  justify-content: flex-start;
}

.writer-header .save-entry {
  justify-content: flex-end;
  color: var(--danger);
}

.writer-body {
  padding: 24px 20px calc(32px + env(safe-area-inset-bottom));
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.text-input,
.entry-textarea {
  width: 100%;
  min-height: 52px;
  margin-bottom: 24px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--text);
  font-size: 17px;
}

.text-input::placeholder,
.entry-textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.entry-textarea {
  min-height: 230px;
  resize: vertical;
  line-height: 1.6;
}

.delete-button {
  width: 100%;
  margin-top: 20px;
  background: var(--coral-wash);
  color: var(--danger);
}

.writer-note {
  text-align: center;
}

.form-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 16px;
  /* Above the help button (76 px up, 44 px tall), so the button never covers the toast's Undo. */
  bottom: calc(132px + env(safe-area-inset-bottom));
  left: 16px;
  display: flex;
  width: auto;
  max-width: 432px;
  min-height: 56px;
  margin: 0 auto;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 8px 28px var(--shadow);
  color: var(--text);
  font-size: 15px;
  animation: toast-in 180ms ease-out both;
}

/* Round 8b: a notice of several lines shows each on its own line; a long one scrolls in the toast. */
#toast-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-line {
  display: block;
}

.toast-line + .toast-line {
  margin-top: 6px;
}

.toast {
  max-height: 50vh;
  overflow-y: auto;
}

/* While a sheet is open, the toast goes to the top, so it never covers the sheet's Save. */
.modal-open .toast {
  top: calc(16px + env(safe-area-inset-top));
  bottom: auto;
}

/* Round 8b: the writer's Save is at the TOP, so over the writer the toast stays at the bottom, above
   the help button (a notice that stays until tapped would otherwise sit on Cancel, Save and the title). */
.modal-open #writer-layer:not([hidden]) ~ .toast {
  top: auto;
  bottom: calc(132px + env(safe-area-inset-bottom));
}

.toast-action {
  min-width: 48px;
  min-height: 48px;
  margin: -8px -8px -8px 0;
  border-radius: 14px;
  background: var(--lilac-wash);
  color: var(--text);
  font-weight: 700;
}

input,
textarea,
.setup-sheet,
.media-sheet,
.writer,
.tab-bar,
.toast,
.privacy-note,
.quick-tile,
.surprise-card,
.checkin-card,
.week-strip,
.empty-state,
.error-state,
.watch-card,
.entry-card { color: var(--text); }

h1:focus,
h2:focus,
h3:focus { outline: none; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading-screen {
  display: grid;
  min-height: 70vh;
  place-content: center;
  text-align: center;
}

.loading-screen h1 {
  font-size: 22px;
}

.loading-sun {
  color: var(--coral);
  font-size: 56px;
}

.noscript-note {
  position: fixed;
  z-index: 100;
  padding: 24px;
  border-radius: 24px;
  background: var(--card);
  color: var(--text);
  inset: 24px;
}

@media (min-width: 520px) {
  body {
    padding: 24px 0;
  }

  .phone-shell {
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
    border-radius: 28px;
    box-shadow: 0 20px 70px var(--shadow);
  }

  .app-main {
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
  }

  .tab-bar {
    bottom: 24px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0 0 28px 28px;
  }

  .media-sheet {
    bottom: 24px;
    border-radius: 28px;
  }

  .viewer,
  .writer {
    border-radius: 28px;
  }
}

@media (max-width: 359px) {
  .app-main {
    padding-right: 16px;
    padding-left: 16px;
  }

  .mood-choice {
    font-size: 10px;
  }

  .mood-face {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }

  .screen--enter,
  .screen--exit {
    opacity: 1;
    transform: none;
  }

  .pressable:active,
  .mood-choice input:checked + .mood-face {
    transform: none;
  }
}

/* The help link inside the <noscript> note. */
.noscript-note .help-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--text); }
.noscript-note p + p { margin-top: 12px; }
