:root {
  --indigo: #1B1F3B;
  --silver: #D9DCE6;
  --cream: #F4EFE6;
  --blue: #6F8FD8;
  --lilac: #B9A3E3;
  --gold: #F2C879;

  --bg: var(--indigo);
  --bg-raised: rgba(255, 255, 255, 0.045);
  --line: rgba(217, 220, 230, 0.16);
  --line-strong: rgba(217, 220, 230, 0.32);
  --text: var(--cream);
  --muted: rgba(244, 239, 230, 0.62);
  --faint: rgba(244, 239, 230, 0.38);
  --accent: var(--blue);
  --star: var(--gold);
  --field: rgba(255, 255, 255, 0.05);

  --aura: #D9DCE6;
  --aura-strength: 0.32;

  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  --gutter: 20px;
  --maxw: 560px;
  --tabbar-h: 64px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: var(--cream);
  --bg-raised: rgba(27, 31, 59, 0.04);
  --line: rgba(27, 31, 59, 0.12);
  --line-strong: rgba(27, 31, 59, 0.26);
  --text: var(--indigo);
  --muted: rgba(27, 31, 59, 0.64);
  --faint: rgba(27, 31, 59, 0.4);
  --accent: #4a68b5;
  --star: #c99a3c;
  --field: rgba(255, 255, 255, 0.7);
  --aura-strength: 0.42;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
body.no-tabs { padding-bottom: 0; }
body.no-tabs .tabbar { display: none; }

/* The aura: soft light behind content, never a halo. */
.aura-glow {
  position: fixed;
  inset: -20vh -30vw auto -30vw;
  height: 90vh;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--aura) calc(var(--aura-strength) * 100%), transparent), transparent);
  filter: blur(30px);
  transition: background 900ms ease;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 6px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand-mark { display: inline-flex; }

main {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px var(--gutter) 48px;
  outline: none;
}

/* ---------- Type ---------- */
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 500; letter-spacing: -0.005em; }
h1 { font-size: clamp(34px, 9vw, 46px); line-height: 1.08; margin: 0 0 16px; }
h2 { font-size: 28px; line-height: 1.15; margin: 0 0 12px; }
h3 { font-size: 22px; margin: 0 0 8px; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; color: var(--faint); }
.prompt { font-family: var(--serif); font-size: clamp(30px, 8.4vw, 40px); line-height: 1.12; margin: 4px 0 14px; font-weight: 500; }
.note-text p { font-family: var(--serif); font-size: 21px; line-height: 1.45; }
.signoff { font-family: var(--serif); font-style: italic; font-size: 22px; }

/* ---------- Layout bits ---------- */
.stack > * + * { margin-top: 22px; }
.center { text-align: center; }
.hero-mark { display: flex; justify-content: center; margin: 22px 0 26px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.callout {
  border-left: 2px solid var(--line-strong);
  padding: 4px 0 4px 14px;
  color: var(--muted);
  font-size: 14px;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 13px 22px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 200ms, border-color 200ms, opacity 200ms;
}
.btn:hover { border-color: var(--text); }
.btn-primary { background: var(--cream); color: var(--indigo); border-color: var(--cream); }
:root[data-theme="light"] .btn-primary { background: var(--indigo); color: var(--cream); border-color: var(--indigo); }
.btn-primary:hover { opacity: 0.9; }
.btn-block { width: 100%; }
.btn-quiet { border-color: transparent; padding-inline: 10px; color: var(--muted); }
.btn-quiet:hover { color: var(--text); border-color: transparent; }
.btn:disabled { opacity: 0.4; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; }

/* ---------- Forms ---------- */
.field { display: block; }
.field-label { display: block; font-size: 13px; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 8px; }
.input, .textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  line-height: 1.45;
  transition: border-color 200ms;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--line-strong); }
.textarea { min-height: 110px; resize: vertical; font-family: var(--serif); font-size: 19px; }
.input.serif { font-family: var(--serif); font-size: 19px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* Stars */
.stars { display: flex; gap: 4px; align-items: center; }
.star {
  appearance: none;
  background: none;
  border: 0;
  padding: 3px;
  cursor: pointer;
  color: var(--faint);
  line-height: 0;
  border-radius: 8px;
  transition: transform 150ms, color 200ms;
}
.star svg { width: min(32px, calc((100vw - 2 * var(--gutter) - 76px) / 7 - 6px)); height: auto; aspect-ratio: 1; }
.star.on { color: var(--star); }
.star:active { transform: scale(0.9); }
.rating-readout { margin-left: 6px; font-family: var(--serif); font-size: 22px; color: var(--muted); min-width: 40px; }
.stars-static { display: inline-flex; gap: 2px; color: var(--faint); vertical-align: middle; }
.stars-static .on { color: var(--star); }
.stars-static svg { width: 14px; height: 14px; }

/* Aura picker */
.auras { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.aura-opt { position: relative; }
.aura-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.aura-dot {
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--c) 0%, color-mix(in srgb, var(--c) 55%, transparent) 55%, transparent 72%);
  border: 1px solid transparent;
  transition: transform 200ms, border-color 200ms;
}
.aura-opt input:checked + .aura-dot { border-color: var(--text); transform: scale(1.08); }
.aura-opt input:focus-visible + .aura-dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.aura-chosen { min-height: 22px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.aura-chosen strong { color: var(--text); font-weight: 500; }

/* Photo */
.photo-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  min-height: 64px;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}
.photo-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-preview { position: relative; border-radius: 14px; overflow: hidden; }
.photo-preview img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.photo-preview .btn { position: absolute; right: 10px; bottom: 10px; min-height: 36px; padding: 6px 14px; background: rgba(27,31,59,0.7); color: var(--cream); border-color: transparent; backdrop-filter: blur(6px); }

/* ---------- Journal grid ---------- */
.grid30 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (min-width: 480px) { .grid30 { grid-template-columns: repeat(6, 1fr); } }
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  text-decoration: none;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
}
.tile.filled {
  border-color: transparent;
  color: var(--indigo);
  background:
    radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--c) 95%, white) 0%, var(--c) 40%, color-mix(in srgb, var(--c) 40%, var(--bg)) 100%);
}
.tile.locked { opacity: 0.35; }
.tile.future { opacity: 0.55; border-style: dashed; }
.tile-day { font-weight: 600; font-size: 13px; }
.tile-kind { font-family: var(--serif); font-size: 14px; line-height: 1; }
.tile-rating { font-family: var(--serif); font-size: 16px; text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; }

/* ---------- Entry view ---------- */
.entry-photo { border-radius: 16px; overflow: hidden; }
.entry-photo img { display: block; width: 100%; }
.kv dt { font-size: 13px; color: var(--muted); margin-top: 18px; }
.kv dd { margin: 4px 0 0; font-family: var(--serif); font-size: 21px; line-height: 1.4; white-space: pre-wrap; }

/* ---------- Reference sheets ---------- */
.aura-list { list-style: none; padding: 0; margin: 0; }
.aura-list li { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.aura-list .aura-dot { width: 44px; }
.aura-list strong { font-weight: 500; display: block; }
.aura-list .hex { font-size: 12px; color: var(--faint); }
.rules { list-style: none; padding: 0; margin: 0; counter-reset: r; }
.rules li { counter-increment: r; display: grid; grid-template-columns: 34px 1fr; padding: 12px 0; border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 21px; line-height: 1.35; }
.rules li::before { content: counter(r); font-family: var(--sans); font-size: 12px; color: var(--muted); padding-top: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { appearance: none; border: 0; background: none; border-radius: 999px; padding: 8px 16px; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg-raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ---------- 7/7 list ---------- */
.seven { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.seven li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 8px; margin-bottom: 10px; }
.seven li::before { content: counter(s); font-family: var(--serif); font-size: 22px; color: var(--star); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.chip:disabled { opacity: 0.4; }

/* ---------- Share ---------- */
.share-stage { display: flex; justify-content: center; }
.share-stage canvas { width: 100%; max-width: 340px; height: auto; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }

/* ---------- Paywall ---------- */
.paywall { text-align: center; padding: 28px 20px; }
.paywall .price { font-family: var(--serif); font-size: 34px; margin: 6px 0 2px; }

/* ---------- Catch up ---------- */
.catchup { display: flex; gap: 8px; flex-wrap: wrap; }
.catchup a { text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--muted); }

/* ---------- Settings ---------- */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting-label { font-weight: 500; }
.setting-help { font-size: 13px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 200ms; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--cream); transition: transform 200ms; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="time"].input { width: auto; min-width: 120px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  z-index: 5;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
  color: var(--muted);
  position: relative;
}
.tabbar a[aria-current="page"] { color: var(--text); }
.tabbar a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 12px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 10px 2px color-mix(in srgb, var(--aura) 70%, transparent);
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  background: var(--cream);
  color: var(--indigo);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms, transform 250ms;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Motion ---------- */
/* Movement only, so content is never left invisible if animation stalls. */
.fade-in { animation: rise 450ms ease; }
@keyframes rise { from { transform: translateY(8px); } to { transform: none; } }
.pleiades circle:nth-child(even) { animation: twinkle 6s ease-in-out infinite; }
.pleiades circle:nth-child(4n) { animation-delay: -2s; }
@keyframes twinkle { 50% { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Install + price ---------- */
.price { font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.install-steps { margin: 0; padding-left: 20px; font-size: 15px; }
.install-steps li { margin: 4px 0; }
