/* Load after the existing themes. Colours come from the active profile. */
:root {
  --paper: #f7f8fa;
  --white: #fff;
  --ink: #20242d;
  --sub: #5b6474;
  --honey: #4263eb;
  --honey2: #e8ecfd;
  --stroke: #dce1e9;
  --danger: #ad302e;
  --theme-accent-ink: #fff;
  --theme-link: #3655cc;
  --theme-soft: #f0f3f7;
  --theme-success-bg: #e8f3ed;
  --theme-success-ink: #245b3b;
  --theme-shadow: 0 4px 24px rgb(35 49 77 / 4%);
}

html, body, .intro { background: var(--paper); color: var(--ink); }
a, .short-link { color: var(--theme-link); }
.rail, .pane, .room, .record, .hero, .hero-copy, .empty,
.modal, .modalheader, .bottom-nav, .pill, .status-choice,
.secondary, .smallbtn, .chip, .profile-switch button {
  background: var(--white);
  color: var(--ink);
  border-color: var(--stroke);
}
.pane, .room, .hero, .modal, .bottom-nav { box-shadow: var(--theme-shadow); }
.brand, .empty b, .family-names { color: var(--ink); }
.navbtn, .bottom-nav button, .ghost { color: var(--sub); }
.brand small, .eyebrow, .hero-date, .meta-label, .storydate,
.intro-content .step, .room .index, .family-plus { color: var(--theme-link); }
.hero-copy p, .intro-content p, .family-intro p, .record-owner,
.mood-person small, .field label, .calendar-grid > strong { color: var(--sub); }
.primary, .accent, .appearance-preview-button {
  background: var(--honey);
  color: var(--theme-accent-ink);
  border-color: transparent;
}
.primary:hover, .accent:hover { background: var(--honey); }
.navbtn.active, .chip.active, .status-choice.chosen,
.bottom-nav button.active, .profile-switch button.active {
  background: var(--honey2);
  color: var(--ink);
  border-color: var(--theme-link);
}
.navbtn.active { box-shadow: inset 3px 0 0 var(--theme-link); }
.bottom-nav button.active { box-shadow: inset 0 -2px 0 var(--theme-link); }
.status-choice.chosen { box-shadow: inset 0 0 0 1px var(--theme-link); }
.room:hover { background: var(--honey2); border-color: var(--theme-link); }
.mood-person, .mood-person:nth-child(2), .subtle,
.family-symbol, .family-intro { background: var(--honey2); border-color: var(--stroke); color: var(--ink); }
.mood-person:nth-child(2) { background: var(--theme-soft); }
.hero-photo, .intro-image, .record-photo, .img-preview,
.maparea, .progress { background: var(--theme-soft); }
.photo-placeholder, .photo-placeholder small { color: var(--sub); }
.photo-placeholder span { color: var(--theme-link); }
.field input, .field textarea, .field select, .search,
.toolbar select, .record-check {
  background: var(--white);
  color: var(--ink);
  border-color: var(--stroke);
}
.field input::placeholder, .field textarea::placeholder,
.search::placeholder { color: var(--sub); opacity: 1; }
.record-check.checked { background: var(--honey); color: var(--theme-accent-ink); border-color: var(--theme-link); }
.record-check.checked + .record-main .record-title { color: var(--sub); text-decoration-color: currentColor; }
.status { background: var(--theme-soft); color: var(--sub); }
.status.ok { background: var(--theme-success-bg); color: var(--theme-success-ink); }
.status.warn { background: var(--honey2); color: var(--theme-link); }
.calendar-day[aria-current="date"] { border-color: var(--theme-link); }
.calendar-day[aria-pressed="true"] { background: var(--honey); color: var(--theme-accent-ink); border-color: var(--theme-link); }
.calendar-day span { color: var(--theme-link); }
.calendar-day[aria-pressed="true"] span { color: inherit; }
.progress > span, .storyitem::before { background: var(--honey); }
.storyline, .intro-content blockquote, .upcoming-head { border-color: var(--stroke); }
.intro-content blockquote { color: var(--ink); }
.memory-count progress, .field input[type="range"], .event-repeat input { accent-color: var(--theme-link); }
.error { background: var(--honey2); color: var(--ink); border-color: var(--stroke); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip,
.leaflet-bar a, .leaflet-control-attribution {
  background: var(--white);
  color: var(--ink);
  border-color: var(--stroke);
}
.leaflet-control-attribution a { color: var(--theme-link); }
.leaflet-bar a:hover { background: var(--theme-soft); color: var(--ink); }
.backdrop { background: rgb(9 14 24 / 58%); }
#toast { background: var(--ink); color: var(--white); }
button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible,
.search:focus, input:focus, textarea:focus, select:focus {
  outline: 3px solid var(--theme-link);
  outline-offset: 3px;
}

.appearance-form { display: grid; gap: 1.25rem; }
.appearance-form .field { margin: 0; }
.appearance-presets { margin: 0; padding: 0; border: 0; min-width: 0; }
.appearance-presets legend { padding: 0; margin-bottom: .75rem; font-size: .875rem; font-weight: 700; }
.appearance-preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.appearance-preset {
  display: grid;
  gap: .5rem;
  justify-items: center;
  padding: .75rem .375rem;
  min-height: 84px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font-size: .875rem;
}
.appearance-preset[aria-pressed="true"] { border-color: var(--theme-link); box-shadow: inset 0 0 0 1px var(--theme-link); background: var(--honey2); }
.appearance-swatch { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgb(0 0 0 / 14%); }
.appearance-swatch-light { background: linear-gradient(135deg, #fff 50%, #4263eb 50%); }
.appearance-swatch-sunny { background: #ffd43b; }
.appearance-swatch-sage { background: #78a58b; }
.appearance-swatch-lavender { background: #b09ae6; }
.appearance-swatch-dark { background: linear-gradient(135deg, #1d2129 50%, #a0b4ff 50%); }
.appearance-color-row { display: flex; align-items: center; gap: 1rem; }
.appearance-color-row input[type="color"] { width: 64px; height: 48px; min-height: 48px; padding: .25rem; cursor: pointer; }
.appearance-color-row output { font-size: .875rem; font-variant-numeric: tabular-nums; color: var(--sub); }
.appearance-preview { padding: 1.25rem; border: 1px solid var(--stroke); border-radius: 18px; background: var(--white); color: var(--ink); }
.appearance-preview h3 { margin: .5rem 0; font: normal 1.5rem/1.25 Georgia, serif; }
.appearance-preview p { color: var(--sub); line-height: 1.5; margin: .5rem 0 1rem; }
.appearance-preview-button { display: inline-block; padding: .75rem 1rem; border-radius: 12px; font-size: .875rem; font-weight: 700; }
.appearance-note { margin: 0; font-size: .875rem; line-height: 1.6; color: var(--sub); }
.appearance-message { margin: 0; font-size: .875rem; line-height: 1.5; }
.appearance-message:empty { display: none; }
.appearance-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.appearance-actions button { flex: 1 1 140px; }

@media (max-width: 360px) {
  .appearance-preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
