/* ───────────── Luna — design tokens ───────────── */
:root {
  --bg: #0f1b2d;
  --card: #16253b;
  --card-2: #1b2d47;      /* hover / raised */
  --inset: #122136;       /* inputs, wells */
  --line: #233650;        /* hairlines */
  --text: #e8edf5;
  --muted: #8a9bb4;
  --faint: #5f7190;
  --accent: #e8c88a;
  --accent-ink: #1d1708;  /* text on accent */
  --accent-soft: #2a2a2c; /* accent wash on navy, kept solid */
  --sage: #9cc3a8;
  --rose: #e3a493;
  --sky: #8fb3de;
  /* Mood scale, Rough → Great (see the mood calendar styles) */
  --mood-1: #c44229; --mood-2: #ca7e31; --mood-3: #acb2b9; --mood-4: #9ad6ff; --mood-5: #b3f9ff;

  /* Shape: soft but not bubbly. Full pills are kept for tags, chips and toggles. */
  --radius: 12px;         /* cards, dialogs */
  --radius-sm: 8px;       /* buttons, inputs, rows */
  --radius-pill: 999px;
  /* Spacing scale (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --gap: var(--s-6);
  /* Type scale */
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 24px; --fs-2xl: 32px;
  --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 12px; }
.noscript { margin: 0; padding: 14px 16px; background: var(--accent); color: var(--accent-ink); text-align: center; font-weight: 500; }

/* ───────────── Shell ───────────── */
.shell { display: flex; min-height: 100vh; }
.demo-on .shell { min-height: calc(100vh - 41px); }
.rail {
  width: 220px; flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 28px 16px 20px; border-right: 1px solid var(--line); z-index: 10;
}
.demo-on .rail { top: 41px; height: calc(100vh - 41px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; padding: 0 10px; }
.brand span { font: 500 24px/1 var(--serif); color: var(--text); letter-spacing: .01em; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.nav-list a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav-list svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-list a:hover { color: var(--text); background: var(--card); }
.nav-list a[aria-current="page"] { color: var(--text); background: var(--card-2); }
.nav-list a[aria-current="page"] svg { stroke: #ffffff; }
/* Focus inside the rail is drawn inset in plain text color, so it never spills past the rail. */
.rail :focus-visible { box-shadow: inset 0 0 0 2px var(--muted); }
.rail, .rail-head, .nav-list, .nav-list li, .rail-foot { min-width: 0; max-width: 100%; }
.rail-foot { margin-top: auto; position: relative; display: grid; gap: var(--s-2); }
.nav-foot { padding-bottom: var(--s-2); border-bottom: 1px solid var(--line); }

/* Collapsible rail (desktop). Collapsed it is icons only; hovering it turns the logo into the open button. */
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); position: relative; min-height: 32px; }
.rail-head .brand { flex: 1; min-width: 0; overflow: hidden; }
.brand svg { flex: none; }
.rail-toggle {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer;
}
.rail-toggle:hover, .rail-toggle:focus-visible { color: var(--text); background: var(--card); }
.rail-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-list a, .account-btn { overflow: hidden; }
.nav-list a span, .brand span, .account-btn .who, .account-btn .chev { white-space: nowrap; }
@media (min-width: 821px) {
  .rail-anim .rail { transition: width .24s cubic-bezier(.2, .7, .2, 1), padding .24s cubic-bezier(.2, .7, .2, 1); }
  .rail-anim .nav-list a span, .rail-anim .brand span, .rail-anim .account-btn .who, .rail-anim .account-btn .chev { transition: opacity .16s; }
  .rail-anim .brand svg, .rail-anim .rail-toggle { transition: opacity .18s, transform .18s, background .15s, color .15s; }

  .rail-collapsed .rail { width: 64px; padding-left: 11px; padding-right: 11px; cursor: e-resize; }
  .rail-collapsed .rail a, .rail-collapsed .rail button { cursor: pointer; }
  .rail-collapsed .nav-list a span, .rail-collapsed .brand span,
  .rail-collapsed .account-btn .who, .rail-collapsed .account-btn .chev { opacity: 0; pointer-events: none; }
  .rail-collapsed .brand { padding: 0 6px; }
  .rail-collapsed .account-btn { padding: 5px; }
  .rail-collapsed .rail-toggle { position: absolute; left: 5px; top: 50%; margin-top: -16px; opacity: 0; transform: scale(.8); background: var(--card); color: var(--text); }
  .rail-collapsed .rail:hover .rail-toggle, .rail-collapsed .rail-toggle:focus-visible { opacity: 1; transform: none; }
  .rail-collapsed .rail:hover .brand svg, .rail-collapsed .rail-head:has(.rail-toggle:focus-visible) .brand svg { opacity: 0; transform: scale(.8) rotate(-12deg); }
}

/* Account button + menu */
.account-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); cursor: pointer; text-align: left;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--card); }
.account-btn .avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px;
}
.account-btn .avatar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.account-btn .who { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.account-btn .name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn .plan { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn .chev svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.account-btn .tab-label { display: none; }
.account-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); width: 280px; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
  box-shadow: 0 12px 32px rgba(4, 9, 18, .55);
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding: var(--s-2) 10px var(--s-1); }
.account-menu [role^="menuitem"] {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.account-menu [role^="menuitem"]:hover, .account-menu [role^="menuitem"]:focus-visible { background: var(--card-2); }
.account-menu [role^="menuitem"] > svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.menu-text { flex: 1; display: grid; gap: 1px; min-width: 0; }
.menu-check svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
[role="menuitemradio"][aria-checked="false"] .menu-check { visibility: hidden; }
.menu-note { margin: 2px 10px 6px; font-size: 12px; color: var(--faint); line-height: 1.45; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.account-menu .tag { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
[role="menuitemcheckbox"] .switch-track { pointer-events: none; }
[role="menuitemcheckbox"][aria-checked="true"] .switch-track { background: var(--accent); }
[role="menuitemcheckbox"][aria-checked="true"] .switch-track::after { transform: translateX(14px); background: var(--accent-ink); }

.main { flex: 1; min-width: 0; outline: none; }
.main:focus-visible { box-shadow: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 40px 40px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font: 500 34px/1.1 var(--serif); margin: 0; letter-spacing: -.01em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* ───────────── Demo banner ───────────── */
.demo-banner {
  position: sticky; top: 0; z-index: 30; height: 41px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px; padding: 0 16px;
}
.demo-banner .link-btn { color: var(--accent-ink); text-decoration: underline; font-weight: 600; }

/* ───────────── Controls ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--card-2); border-color: #2d4466; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #efd5a0; border-color: #efd5a0; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card); color: var(--text); border-color: transparent; }
.btn-danger { background: transparent; border-color: #5a3a3a; color: var(--rose); }
.btn-danger:hover { background: #2a2230; border-color: var(--rose); }
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }

.input, .textarea {
  width: 100%; background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 14px; color: var(--text);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
label.field, div.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 34px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }

/* ───────────── Cards ───────────── */
.card { background: var(--card); border-radius: var(--radius); padding: 24px; }
.card h2, .card h3 { margin: 0; font-weight: 600; font-size: 15px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.eyebrow { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--inset); border: 1px solid var(--line); color: var(--text); font-size: 13px;
}
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); }
.chip .count { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ───────────── States: loading / empty / error / not configured ───────────── */
.state { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 36px 16px; color: var(--muted); }
.state h3 { color: var(--text); font: 500 20px/1.3 var(--serif); margin: 4px 0 0; }
.state p { margin: 0; max-width: 42ch; }
.state .actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.state-inline { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--inset); color: var(--muted); font-size: 14px; }
.state-inline strong { color: var(--text); font-weight: 600; }
.state-inline.error { border-left: 3px solid var(--rose); }
.state-inline.notcfg { border-left: 3px solid var(--faint); }
.bunny { width: 96px; height: auto; color: var(--accent); --bunny-cut: var(--bg); }
.bunny .hop { fill: currentColor; }
.bunny .cut { stroke: var(--bunny-cut); stroke-width: 2.4; }
.bunny .eye { fill: var(--bunny-cut); }
.card .bunny, .modal .bunny { --bunny-cut: var(--card); }
.bunny.small { width: 56px; }
.bunny .hop { transform-origin: 50% 100%; }
.loading .bunny .hop { animation: hop 1.1s ease-in-out infinite; }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-7px); } }
@media (prefers-reduced-motion: reduce) { .loading .bunny .hop { animation: none; } * { transition: none !important; } }

/* ───────────── Journal ───────────── */
.journal { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }
.demo-on .journal { min-height: calc(100vh - 41px); }
.entry-sidebar { border-right: 1px solid var(--line); padding: 28px 16px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.demo-on .entry-sidebar { top: 41px; height: calc(100vh - 41px); }
.entry-sidebar .search { position: relative; }
.entry-sidebar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--faint); fill: none; stroke-width: 1.7; }
.entry-sidebar .search .input { padding-left: 36px; }
.month-group h4 { margin: var(--s-4) 10px var(--s-1); font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.month-group h4 .count { color: var(--faint); font-weight: 500; margin-left: var(--s-1); }
.group-by { display: flex; }
.group-by button { flex: 1; }
.list-summary { margin: 12px 8px 0; font-size: 12px; color: var(--faint); }
.entry-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.entry-link {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--radius-sm);
  background: none; border: 0; cursor: pointer; color: var(--text); text-decoration: none;
}
.entry-link:hover { background: var(--card); }
.entry-link[aria-current="true"] { background: var(--card); box-shadow: inset 2px 0 0 var(--accent); }
.entry-link .t { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-link .d { display: block; font-size: 12px; color: var(--muted); }

.editor-wrap { padding: 40px 56px 120px; max-width: 820px; width: 100%; margin: 0 auto; }
@media (max-width: 1100px) and (min-width: 821px) {
  .journal { grid-template-columns: 232px 1fr; }
  .editor-wrap { padding: var(--s-8) var(--s-8) 120px; }
}
.editor-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.save-state { font-size: 13px; color: var(--faint); min-width: 64px; transition: color .2s; }
.save-state.saved { color: var(--muted); }
.save-state.err { color: var(--rose); }
.entry-date { font-size: 13px; color: var(--muted); }
.editor-meta { display: flex; align-items: baseline; gap: var(--s-3); }
.editor-actions { display: flex; align-items: center; gap: var(--s-1); }
.title-input {
  display: block; width: 100%; border: 0; background: none; color: var(--text); padding: 0; margin: var(--s-2) 0 var(--s-3);
  font: 500 clamp(28px, 3vw, 38px)/1.2 var(--serif); letter-spacing: -.01em; resize: none; overflow: hidden;
}
.entry-props { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-5); }
.entry-props .tag-row { margin: 0; }
.prop-btn {
  display: inline-flex; align-items: center; gap: var(--s-2); padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: none; color: var(--text); font-size: var(--fs-sm); cursor: pointer;
}
.prop-btn:hover, .prop-btn[aria-expanded="true"] { border-color: var(--faint); }
.prop-label { color: var(--muted); }
.mood-note { flex-basis: 100%; font-size: var(--fs-xs); color: var(--faint); margin-top: var(--s-1); }
.tb-italic { font-family: var(--serif); font-size: var(--fs-md); }
.title-input::placeholder { color: var(--faint); }
.title-input:focus { outline: none; box-shadow: none; }

.mood-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin: calc(-1 * var(--s-2)) 0 var(--s-5); padding: var(--s-3); border-radius: var(--radius-sm); background: var(--inset); }
.mood-btn { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.mood-btn:hover { color: var(--text); border-color: #2d4466; }
.mood-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.tag-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.tag-row .chip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; line-height: 1; font-size: 15px; }
.tag-input { background: none; border: 0; color: var(--text); font-size: 13px; width: 110px; padding: 5px 4px; }
.tag-input:focus { outline: none; box-shadow: none; border-bottom: 1px solid var(--accent); }

.toolbar { display: flex; gap: 2px; flex-wrap: wrap; padding: 4px; background: var(--card); border-radius: 12px; width: fit-content; margin-bottom: 18px; }
.toolbar button { background: none; border: 0; color: var(--muted); width: 34px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.toolbar button:hover { background: var(--card-2); color: var(--text); }
.toolbar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.toolbar .sep { width: 1px; background: var(--line); margin: 6px 4px; }

.blocks { font: 400 19px/1.7 var(--serif); }
.block { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 2px 0; }
.block [contenteditable] { flex: 1; min-width: 0; outline: none; white-space: pre-wrap; word-break: break-word; caret-color: var(--accent); }
/* No box around the line you're typing in; a thin bar in the margin marks it instead. */
.block [contenteditable]:focus-visible { box-shadow: none; }
.block:focus-within::after { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--accent); opacity: .55; pointer-events: none; }
.block [contenteditable]:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }
.block:not(.focused) [contenteditable]:empty::before { content: ""; }
.blocks.is-empty .block:first-child [contenteditable]:empty::before { content: attr(data-placeholder); }
.block[data-type="h1"] [contenteditable] { font: 500 28px/1.3 var(--serif); margin-top: 14px; }
.block[data-type="h2"] [contenteditable] { font: 500 22px/1.35 var(--serif); margin-top: 10px; }
.block[data-type="bullet"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin: 13px 6px 0 8px; flex: none; }
.block[data-type="quote"] [contenteditable] { border-left: 3px solid var(--accent); padding-left: 18px; color: #cfd7e4; font-style: italic; }
.block[data-type="todo"] input { margin: 8px 2px 0 4px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.block[data-type="todo"].done [contenteditable] { color: var(--muted); text-decoration: line-through; }
.block b, .block strong { font-weight: 600; color: #fff; }
.editor-hint { margin-top: 28px; font-size: 13px; color: var(--faint); }
.editor-hint kbd { font: 12px var(--ui); background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--muted); }

.reflection { margin-top: 36px; max-width: 100%; min-width: 0; }
.reflection .card { border: 1px solid var(--line); width: 100%; max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
.reflection .card-head { flex-wrap: wrap; min-width: 0; }
.reflection-body { font: 400 17px/1.7 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; }
.refl-thread { display: flex; flex-direction: column; gap: var(--s-4); max-height: 60vh; overflow-y: auto; overflow-x: hidden; padding: 2px 2px var(--s-2); scroll-behavior: smooth; }
.refl-thread .msg { max-width: 92%; min-width: 0; overflow-wrap: anywhere; }
.refl-thread .msg.user { white-space: pre-wrap; }
.msg .who .sample-tag { margin-left: var(--s-2); }
.typing-dots { display: inline-flex; gap: 5px; padding: 10px 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing-dots span { animation: none; opacity: .7; } }
.refl-composer { display: flex; align-items: flex-end; gap: var(--s-2); margin-top: var(--s-4); background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 6px 6px 14px; min-width: 0; }
.refl-composer:focus-within { border-color: var(--muted); }
.refl-composer textarea { flex: 1; min-width: 0; border: 0; background: none; resize: none; padding: 8px 0; line-height: 24px; max-height: 192px; }
.refl-composer textarea:focus { outline: none; box-shadow: none; }
.send-btn { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.send-btn:disabled { opacity: .5; cursor: default; }
.send-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.refl-hint { margin: var(--s-1) 0 0; }
.refl-offer, .refl-preview { display: grid; gap: var(--s-3); margin-top: var(--s-4); padding: var(--s-4); background: var(--inset); border-radius: var(--radius-sm); border: 1px solid var(--line); min-width: 0; }
.refl-offer { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
@media (max-width: 520px) { .refl-offer { grid-template-columns: minmax(0, 1fr); } }
.refl-preview .textarea { width: 100%; max-width: 100%; }

.journal-mobile-bar { display: none; }

/* ───────────── Dashboard ───────────── */
.dash { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
/* "This month at a glance": one strip instead of three separate cards */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; }
.summary > div { padding: var(--s-5) var(--s-6); display: grid; align-content: start; gap: var(--s-1); }
.summary > div + div { border-left: 1px solid var(--line); }
.card .summary-label { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.summary-num { margin: 0; font: 500 var(--fs-2xl)/1.1 var(--serif); }
.summary-unit { font: 500 var(--fs-md) var(--ui); color: var(--muted); }
.summary p.small, .summary .link-btn { margin: 0; justify-self: start; }
.card .sub-label { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.chip-btn { text-decoration: none; }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }
.seg { display: inline-flex; background: var(--inset); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: var(--fs-sm); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--card-2); color: var(--text); }

.trend-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.legend-btn { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--text); font-size: 13px; cursor: pointer; }
.legend-btn .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-btn[aria-pressed="false"] { color: var(--faint); }
.legend-btn[aria-pressed="false"] .sw { background: var(--line) !important; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--faint); font: 12px var(--ui); }
.chart .hover-line { stroke: var(--muted); stroke-dasharray: 3 4; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; min-width: 160px; transform: translate(-50%, -100%); white-space: nowrap; z-index: 2;
}
.chart-tip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.chart-tip .row span:first-child { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-tip .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-note { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

.noticed { display: flex; flex-direction: column; gap: 12px; }
.noticed .insight { font: 400 21px/1.45 var(--serif); margin: 0; }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conf .dots { display: inline-flex; gap: 3px; }
.conf .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); display: block; }
.conf .dots i.on { background: var(--accent); }
.sample-tag { font-size: var(--fs-xs); font-weight: 600; color: var(--accent); border: 1px solid currentColor; padding: 1px 8px; border-radius: var(--radius-pill); }

/* Moods you picked */
.mood-bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 28px; }
.mood-bar {
  display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 12px; padding: 6px 8px; margin: 0 -8px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); cursor: pointer; text-align: left; font-size: 14px;
}
.mood-bar:hover { background: var(--card-2); }
.mood-bar .track { height: 8px; border-radius: 999px; background: var(--inset); overflow: hidden; }
.mood-bar .fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.mood-bar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Calendar */
/* Mood calendar. A diverging, colorblind-safe ramp whose lightness rises from Rough to Great,
   so it also reads in order in grayscale. Checked with the dataviz validator against the card
   (#16253b): monotone lightness, every step >= 0.06 apart, all >= 3:1 contrast, adjacent CVD ΔE >= 9.8. */
.mc-tools { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.mc-summary { margin: 0 0 var(--s-3); color: var(--text); display: flex; flex-wrap: wrap; gap: 4px 6px; }
.mc-summary b { font-weight: 600; }
.mc-scroll { overflow-x: auto; padding: 4px 2px 6px; }
.mc { --cell: 15px; display: inline-flex; gap: 3px; }
.mc.mc-r30 { --cell: 22px; } .mc.mc-r365 { --cell: 12px; }
.mc-col { display: grid; grid-template-rows: 16px repeat(7, var(--cell)); gap: 3px; }
.mc-month { font-size: 11px; color: var(--muted); white-space: nowrap; width: var(--cell); overflow: visible; }
.mc-wd span { font-size: 10px; color: var(--faint); line-height: var(--cell); padding-right: 4px; }
.mc-cell { width: var(--cell); height: var(--cell); border-radius: 3px; border: 0; padding: 0; cursor: pointer; }
.mc-pad { background: none; cursor: default; }
.mc-none, .mc-legend i.mc-none { background: var(--inset); }
.mc-unrated, .mc-legend i.mc-unrated { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.mc-1 { background: var(--mood-1); } .mc-2 { background: var(--mood-2); } .mc-3 { background: var(--mood-3); }
.mc-4 { background: var(--mood-4); } .mc-5 { background: var(--mood-5); }
.mc-today { outline: 1.5px solid var(--text); outline-offset: 1px; }
.mc-cell:hover { filter: brightness(1.15); }
.mc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: var(--s-3); }
.mc-legend span { display: inline-flex; align-items: center; gap: 4px; }
.mc-legend i, .mc-moods i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.mc-map { margin-top: var(--s-2); }
.mc-map summary { cursor: pointer; width: fit-content; }
.mc-map p { margin: 6px 0 0; line-height: 1.6; }
.card:has(.mc) { position: relative; }
.mc-pop { position: absolute; z-index: 20; width: min(340px, calc(100% - 24px)); background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-4); display: grid; gap: var(--s-3); box-shadow: 0 12px 32px rgba(0, 0, 0, .45); }
.mc-pop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-2); }
.mc-entry { display: grid; gap: 2px; text-decoration: none; color: inherit; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--inset); }
.mc-entry .t { font-weight: 600; font-size: var(--fs-sm); }
.mc-entry .x { color: var(--muted); font: 400 14px/1.45 var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mc-rate { display: grid; gap: var(--s-2); }
.mc-moods { display: flex; flex-wrap: wrap; gap: 6px; }
.mc-moods button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: var(--fs-sm); cursor: pointer; }
.mc-moods button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.mc-moods button:disabled { opacity: .6; cursor: wait; }
.mc-status:empty { display: none; }
.mc-step { display: flex; justify-content: space-between; gap: var(--s-2); }

/* ───────────── Support panel ───────────── */
.support { border: 1px solid var(--line); }
.support h2 { font: 500 19px/1.3 var(--serif) !important; }
.support ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.support li { display: grid; gap: 2px; font-size: 14px; }
.support li strong { font-weight: 600; }
.support li span { color: var(--muted); }
.support .foot { font-size: 12px; color: var(--faint); margin: 14px 0 0; }
.support-mini { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; font-size: 14px; color: var(--muted); padding: 14px 18px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.safety-note { border: 1px solid var(--accent); }

/* ───────────── Check-in ───────────── */
.checkin { max-width: 640px; margin: 0 auto; }
.progress { display: flex; gap: 6px; margin-bottom: 26px; }
.progress i { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.progress i.on { background: var(--accent); }
.card .question, .question { font: 500 28px/1.3 var(--serif); margin: 0 0 8px; }
.word-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.word-grid button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; }
.word-grid button:hover { border-color: #2d4466; background: var(--card); }
.word-grid button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.step-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; gap: 12px; }
.summary-list { display: grid; gap: 16px; margin: 0; }
.summary-list dt { font-size: 13px; color: var(--muted); }
.summary-list dd { margin: 2px 0 0; font: 400 17px/1.6 var(--serif); }

/* ───────────── Ask Luna ───────────── */
.ask { display: grid; grid-template-rows: 1fr auto; max-width: 780px; margin: 0 auto; min-height: calc(100vh - 220px); }
.thread { display: flex; flex-direction: column; gap: 18px; padding-bottom: 20px; }
.msg { max-width: 88%; }
.msg.user { align-self: flex-end; background: var(--card-2); padding: 12px 16px; border-radius: 16px 16px 4px 16px; }
.msg.luna { align-self: flex-start; }
.msg.luna .body { font: 400 17px/1.65 var(--serif); white-space: pre-wrap; }
.msg .who { font-size: var(--fs-xs); color: var(--muted); margin-bottom: var(--s-1); font-weight: 600; }
.cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cite { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--inset); color: var(--text); font-size: 12px; text-decoration: none; cursor: pointer; }
.cite:hover { border-color: var(--accent); }
.cite svg { width: 12px; height: 12px; stroke: var(--accent); fill: none; stroke-width: 1.8; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 8px; }
.composer form { display: flex; gap: 10px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px 8px 8px 16px; }
.composer form:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; background: none; resize: none; min-height: 24px; max-height: calc(1.5em * 8 + 16px); overflow-y: hidden; padding: 8px 0; line-height: 1.5; }
.composer textarea:focus { outline: none; box-shadow: none; }
.copy-btn { float: right; font-weight: 500; letter-spacing: 0; text-transform: none; }
.ask-count { margin: 6px 4px 0; text-align: right; color: var(--muted); }
.quote-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.quote-list li { display: grid; gap: var(--s-2); align-self: start; padding-left: var(--s-4); border-left: 2px solid var(--accent); }
.quote-list blockquote { margin: 0; font: 400 18px/1.5 var(--serif); color: var(--text); overflow-wrap: anywhere; }
.quote-src { font-size: var(--fs-sm); color: var(--muted); text-decoration: none; font-variant-numeric: tabular-nums; width: fit-content; }
.quote-src:hover { color: var(--text); text-decoration: underline; }
.split-table-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: var(--s-3) 0; }
.split-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.split-table th, .split-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.split-table th { position: sticky; top: 0; background: var(--card-2); color: var(--muted); font-weight: 600; font-size: var(--fs-xs); }
.split-table td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.split-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.split-table tr:last-child td { border-bottom: 0; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* Ask Luna chats: a sidebar of saved chats beside the conversation (a slide-over drawer on phones). */
.ask-page { max-width: 1240px; }
.ask-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.chats { position: sticky; top: 24px; display: grid; gap: var(--s-3); max-height: calc(100vh - 48px); grid-template-rows: auto auto minmax(0, 1fr); }
.chats-new { width: 100%; }
.chats-list { min-width: 0; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.chats-list ul { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.chats-group { font-size: var(--fs-xs); color: var(--faint); font-weight: 600; margin: var(--s-3) 10px var(--s-1); }
.chats-empty { padding: 0 10px; }
.chat-item { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); }
.chat-item:hover, .chat-item:focus-within { background: var(--card); }
.chat-item.active { background: var(--card-2); }
.chat-open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--muted); padding: 8px 10px; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-radius: var(--radius-sm); }
.chat-item.active .chat-open { color: var(--text); font-weight: 600; }
.chat-actions { display: flex; opacity: 0; }
.chat-item:hover .chat-actions, .chat-item:focus-within .chat-actions, .chat-item.active .chat-actions { opacity: 1; }
.chat-actions .icon-btn { width: 28px; height: 28px; }
.chat-rename { padding: 6px 10px; font-size: var(--fs-sm); }
.ask-head { margin-bottom: var(--s-4); }
.ask-head p { max-width: 60ch; overflow: hidden; text-overflow: ellipsis; }
.ask-page .ask { min-height: calc(100vh - 200px); }
.chats-toggle { display: none; }
.chats-scrim { position: fixed; inset: 0; background: rgba(6, 12, 22, .6); z-index: 29; }
@media (max-width: 820px) {
  .ask-layout { grid-template-columns: 1fr; }
  .chats-toggle { display: inline-flex; }
  .chats { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 85vw); max-height: none; z-index: 30; background: var(--bg); border-right: 1px solid var(--line); padding: 16px; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  .chats.open { transform: none; visibility: visible; }
  .chat-actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .chats { transition: none; } }

/* ───────────── Settings ───────────── */
.settings { max-width: 960px; }
/* One row per setting: name and description on the left, controls on the right. */
.setting { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: var(--s-4) var(--s-10); padding: var(--s-8) 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; padding-top: 0; }
.setting > header h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.setting > header p { margin: var(--s-1) 0 0; font-size: var(--fs-sm); color: var(--muted); }
.sent-list { margin: 0 0 var(--s-2); display: grid; gap: var(--s-2); }
.sent-list div { display: grid; grid-template-columns: 170px 1fr; gap: var(--s-3); }
.sent-list dt { font-weight: 600; color: var(--text); }
.sent-list dd { margin: 0; color: var(--muted); }
.data-rows { border: 1px solid var(--line); border-radius: var(--radius); }
.data-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-5); flex-wrap: wrap; }
.data-row + .data-row { border-top: 1px solid var(--line); }
.data-row p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--muted); }
.data-row.danger strong { color: var(--rose); }
.memory-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.memory-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--inset); }
.memory-list .type { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); width: 72px; flex: none; }
.memory-list .content { flex: 1; min-width: 0; }
.icon-btn { background: none; border: 0; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--rose); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.plain { font-size: var(--fs-md); line-height: 1.65; }
.plain h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin: var(--s-5) 0 var(--s-2); }
.plain h3:first-child { margin-top: 0; }
.plain ul { margin: 0; padding-left: var(--s-5); color: var(--muted); }
.plain li { margin: 4px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ───────────── Auth ───────────── */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth .card { display: grid; gap: 16px; padding: 32px; }
.auth h1 { font: 500 30px/1.2 var(--serif); margin: 0; }
.auth .tabs { display: flex; gap: 4px; }
.seg-lg { display: flex; padding: 4px; }
.seg-lg button { flex: 1; padding: 10px 12px; font-size: var(--fs-md); font-weight: 600; }
.error-text { color: var(--rose); overflow-wrap: anywhere; }
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { width: 100%; padding-right: 44px; }
.forgot { justify-self: end; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn-google { width: 100%; gap: 10px; }
.btn-google svg { width: 18px; height: 18px; stroke: none; flex: none; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* About Luna (settings) */
.about > header .bunny { width: 56px; display: block; margin-bottom: var(--s-3); }
.about-body { display: grid; gap: var(--s-4); }
.about-body > p { margin: 0; color: var(--muted); }
.about-body > p.about-note { font: italic 400 20px/1.4 var(--serif); color: var(--text); }
.about-quote { margin: 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--accent); }
.about-quote blockquote { margin: 0; font: italic 400 19px/1.5 var(--serif); color: var(--text); }
.about-quote figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.about-quote figcaption::before { content: "— "; }
.about-facts { margin: 0; display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.about-facts div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; font-size: 14px; }
.about-facts dt { color: var(--faint); }
.about-facts dd { margin: 0; color: var(--muted); }

/* ───────────── Home ───────────── */
.home {
  --moon-y: 44%;         /* vertical center of the moon */
  --moon: #ebe3d3; --moon-ink: #16223a; --hill: #1c362f; --hill-text: #b9c9bf;
  position: relative; overflow: hidden; min-height: 100vh;
  display: grid; place-items: center; padding: 32px 16px 168px;
}
.demo-on .home { min-height: calc(100vh - 41px); }
.home-moon {
  position: absolute; left: 50%; top: var(--moon-y); transform: translate(-50%, -50%);
  width: min(600px, 90vw, 78vh); aspect-ratio: 1; border-radius: 50%; background: var(--moon);
}
.moon-tex { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; }
.home-hill {
  position: absolute; left: -15%; right: -15%; bottom: 0; height: 30%; min-height: 150px;
  background: var(--hill); border-radius: 50% 50% 0 0 / 46% 46% 0 0;
}
.tuft { position: absolute; height: auto; fill: none; stroke: #2a4a3f; stroke-width: 1.3; stroke-linecap: round; }
/* The ask bar sits exactly on the moon's center line; the greeting and buttons hang off it. */
.home-center { position: absolute; z-index: 1; left: 50%; top: var(--moon-y); transform: translate(-50%, -50%); width: min(500px, calc(100% - 32px)); text-align: center; }
.home-center h1 { position: absolute; left: 0; right: 0; bottom: calc(100% + var(--s-5)); margin: 0; color: var(--moon-ink); font: 500 clamp(26px, 4.2vw, 38px)/1.15 var(--serif); letter-spacing: -.01em; }
.home-ask {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 20px;
}
.home-ask:focus-within { border-color: var(--accent); }
.home-ask input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 0; }
.home-ask input::placeholder { color: var(--muted); }
.home-ask input:focus { outline: none; box-shadow: none; }
.home-send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent); cursor: pointer; }
.home-send:hover { background: #efd5a0; }
.home-send svg { width: 18px; height: 18px; fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.home-actions { position: absolute; left: 0; right: 0; top: calc(100% + var(--s-4)); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); }
.home-pill {
  display: inline-flex; align-items: center; gap: 10px; padding: 11px 22px; border-radius: 999px; border: 0;
  background: var(--bg); color: var(--text); font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer;
}
.home-pill:hover { background: var(--card-2); }
.home-pill:disabled { opacity: .6; cursor: default; }
.home-pill svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.home-ground { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; display: grid; justify-items: center; gap: 6px; padding: 0 16px 18px; text-align: center; color: var(--hill-text); }
.home-ground > p { margin: 0; max-width: 52ch; font-size: var(--fs-xs); opacity: .8; }
.qotd { margin: 0 0 var(--s-2); max-width: 46ch; }
.qotd blockquote { margin: 0; font: italic 400 var(--fs-lg)/1.4 var(--serif); color: var(--moon); }
.qotd figcaption { margin-top: var(--s-1); font-size: var(--fs-sm); color: var(--hill-text); }
.qotd figcaption::before { content: "— "; }
.home-bunny-spot { position: absolute; left: 50%; bottom: calc(max(30%, 150px) - 6px); transform: translateX(-50%); z-index: 1; line-height: 0; }
.bunny.home-bunny { width: 150px; color: var(--bg); --bunny-cut: var(--moon); }
@media (max-height: 780px), (max-width: 520px) { .bunny.home-bunny { width: 112px; } }

/* ───────────── Modal + toast ───────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6, 12, 22, .72); display: grid; place-items: center; padding: 20px; z-index: 40; }
.modal { background: var(--card); border-radius: var(--radius); width: min(620px, 100%); max-height: 85vh; overflow: auto; padding: 28px; border: 1px solid var(--line); }
.modal h2 { font: 500 24px/1.3 var(--serif); margin: 0 0 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
/* Import dialog */
.import-sources { display: grid; gap: 8px; margin: 18px 0 8px; }
.import-source {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--inset); color: var(--text); text-align: left; cursor: pointer;
}
.import-source:hover { border-color: var(--faint); }
.import-source .logo { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 8px; background: #fff; color: #3a4a63; }
.import-source .logo svg { width: 22px; height: 22px; }
.import-source .text { display: grid; gap: 2px; }
.import-source .name { font-weight: 600; }
.import-source .how { font-size: 13px; color: var(--muted); }
.import-status { margin: 14px 0 8px; }
.import-status.error { color: var(--rose); }
.import-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.import-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 6px; background: var(--inset); }
.import-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-note { color: var(--accent); margin: 10px 0; }
.import-preview .btn { margin-top: 6px; }
.mini-entry { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--inset); display: grid; gap: 4px; text-decoration: none; color: inherit; }
.mini-entry + .mini-entry { margin-top: 10px; }
.mini-entry .t { font-weight: 600; }
.mini-entry .x { color: var(--muted); font: 400 15px/1.55 var(--serif); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ───────────── Responsive ───────────── */
@media (max-width: 1000px) {
  .span-8, .span-4, .span-6 { grid-column: span 12; }
}
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .rail {
    position: fixed; bottom: 0; top: auto !important; left: 0; right: 0; height: auto !important; width: 100%;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 0; z-index: 20;
    border-right: 0; border-top: 1px solid var(--line); background: var(--bg);
  }
  .rail-head, .nav-foot { display: none; }
  .nav-list { grid-template-columns: repeat(5, 1fr); flex: 5; }
  .rail-foot { flex: 1; margin: 0; position: static; }
  .account-btn { flex-direction: column; justify-content: center; gap: 3px; padding: 6px 4px; height: 100%; color: var(--muted); font-size: 11px; font-weight: 500; }
  .account-btn .avatar { width: 20px; height: 20px; font-size: 11px; }
  .account-btn .avatar svg { width: 13px; height: 13px; }
  .account-btn .who, .account-btn .chev { display: none; }
  .account-btn .tab-label { display: block; }
  .account-menu { left: auto; right: 8px; bottom: calc(100% + 8px); width: min(300px, calc(100vw - 16px)); max-height: calc(100vh - 140px); overflow: auto; }
  .nav-list a { flex-direction: column; gap: 3px; padding: 8px 4px; font-size: 11px; }
  .main { padding-bottom: 76px; }
  .page { padding: 24px 16px 40px; }
  .page-head h1 { font-size: 28px; }
  .summary > div { padding: var(--s-4) var(--s-3); }
  .summary-num { font-size: var(--fs-xl); }
  .setting { grid-template-columns: 1fr; padding: var(--s-6) 0; }
  .sent-list div { grid-template-columns: 1fr; gap: 0; }
  .home { min-height: calc(100vh - 76px); padding-bottom: 150px; }
  .demo-on .home { min-height: calc(100vh - 117px); }
  .home { --moon-y: 42%; }
  .journal { grid-template-columns: 1fr; }
  .entry-sidebar { position: fixed; inset: 0 0 64px 0; height: auto !important; z-index: 15; background: var(--bg); transform: translateX(-100%); transition: transform .2s; border: 0; }
  .demo-on .entry-sidebar { top: 41px; }
  .journal.drawer-open .entry-sidebar { transform: none; }
  .journal-mobile-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .editor-wrap { padding: 20px 16px 80px; }
  .title-input { font-size: 30px; }
  .mobile-only { display: inline-flex; }
  .toast { bottom: 88px; max-width: calc(100% - 32px); text-align: center; }
  .demo-mobile { display: flex !important; }
}
.demo-mobile { display: none !important; }
@media (min-width: 821px) { .mobile-only { display: none !important; } }

/* ───────────── Small pieces used by the page templates ───────────── */
.auth-narrow { max-width: 560px; }
.steps-list { margin: 0; padding-left: var(--s-5); line-height: 1.8; }
.card-roomy { padding: var(--s-8); }
.card-inset { background: var(--inset); }
.start-wrap { justify-content: flex-start; flex-wrap: wrap; }
.lede { margin: var(--s-2) 0 var(--s-3); font: 400 17px/1.6 var(--serif); }
.table-wrap { overflow: auto; margin-top: var(--s-3); }
.tip-title { font-weight: 600; margin-bottom: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th { padding: 6px; text-align: left; color: var(--muted); font-weight: 500; }
.data-table td { padding: 6px; border-top: 1px solid var(--line); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Utilities, all on the spacing scale. Kept last so they win over component defaults. */
.m-0 { margin: 0; }
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }
.p-2 { padding: var(--s-2); }
.hstack { display: flex; align-items: center; }
.stack { display: grid; gap: var(--s-3); }
.stack-tight { display: grid; gap: var(--s-2); }
.gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.self-center { align-self: center; }
.text-strong { color: var(--text); }

/* ───────────── Print: just the entry, black on white ───────────── */
@media print {
  :root { --bg: #fff; --card: #fff; --text: #111; --muted: #444; --faint: #666; }
  body { background: #fff; color: #111; }
  .rail, .demo-banner, .entry-sidebar, .journal-mobile-bar, .toolbar, .editor-hint, .mood-row,
  .editor-top div, .tag-row button, .tag-input, .toast, .skip-link, #modal-root, .reflection button { display: none !important; }
  [data-blocks] *, .title-input, .entry-date { color: #111 !important; }
  .tag-row .chip { background: none; border: 1px solid #999; color: #111; }
  .shell, .journal { display: block; min-height: 0; }
  .editor-wrap { padding: 0; max-width: none; }
  a { color: inherit; }
}

/* ───────────── Settings → AI model ───────────── */
.aim { display: grid; gap: var(--s-4); min-width: 0; }
.aim-status { padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--inset); overflow-wrap: anywhere; }
.aim-status code, .aim code { font-size: var(--fs-sm); }
.aim-providers { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.aim-option { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; min-width: 0; }
.aim-option:hover { background: var(--card); }
.aim-option:has(input:checked) { border-color: var(--muted); background: var(--card); }
.aim-option input { margin: 4px 0 0; accent-color: var(--accent); flex: none; }
.aim-option > span { display: grid; gap: 2px; min-width: 0; }
.aim-form { display: grid; gap: var(--s-3); min-width: 0; }
.aim-form .input { width: 100%; }
.aim-steps { margin: 0; padding-left: 1.3em; color: var(--muted); display: grid; gap: 2px; }
.aim-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
@media (max-width: 520px) { .aim-providers { grid-template-columns: minmax(0, 1fr); } }
.menu-sub { font-size: 11px; color: var(--faint); padding: var(--s-1) 10px 2px; text-transform: none; }
.account-menu [aria-busy="true"] { opacity: .6; pointer-events: none; }
.account-menu .menu-more { padding-top: 4px; padding-bottom: 4px; color: var(--muted); }
.account-menu [data-own-model] { padding-top: 6px; padding-bottom: 6px; }
@media (min-width: 821px) { .account-menu { max-height: calc(100vh - 96px); overflow-y: auto; } }
