/* Memory Lane — warm paper in daylight, lamplight at night. */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --top-h: 60px;
  --pad: 38px;    /* space left of timeline content */
  --spine: 13px;  /* x of the timeline line inside that space */

  /* Light or dark follows the computer, unless Settings → Appearance picks one
     (data-theme on <html>). Every color is a light-dark(daylight, lamplight) pair. */
  color-scheme: light dark;

  /* Shades mixed from the four palette colors below, so every theme stays consistent. */
  --ink-2: color-mix(in srgb, var(--ink) 82%, var(--bg));
  --muted: color-mix(in srgb, var(--ink) 62%, var(--bg));
  --line: color-mix(in srgb, var(--ink) 11%, var(--bg));
  --line-strong: color-mix(in srgb, var(--ink) 21%, var(--bg));
  --accent-strong: color-mix(in srgb, var(--accent) 82%, var(--ink));
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --on-accent: light-dark(#fff, #141210);
  --chip: color-mix(in srgb, var(--ink) 6%, var(--bg));
  --hover: color-mix(in srgb, var(--ink) 5%, var(--bg));
  --input-bg: var(--surface);
  --photo-bg: color-mix(in srgb, var(--ink) 9%, var(--bg));
  --loose-bg: color-mix(in srgb, var(--surface) 45%, transparent);
  --banner-bg: color-mix(in srgb, var(--accent) 8%, var(--bg));
  --banner-line: color-mix(in srgb, var(--accent) 26%, var(--bg));
  --danger: light-dark(#b3261e, #ef6b5f);
  --ok: light-dark(#3d7a4f, #6fbf86);
  --shadow: 0 1px 2px light-dark(rgba(40, 30, 20, 0.08), rgba(0, 0, 0, 0.3)),
    0 4px 14px light-dark(rgba(40, 30, 20, 0.08), rgba(0, 0, 0, 0.25));
  --shadow-lift: 0 4px 10px light-dark(rgba(40, 30, 20, 0.12), rgba(0, 0, 0, 0.35)),
    0 16px 32px light-dark(rgba(40, 30, 20, 0.14), rgba(0, 0, 0, 0.35));
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---- color themes (Settings → Appearance) ----------------------------------
   Four colors each: background, surface (cards), ink (text) and accent. They can
   also be set on any element, which is how the theme previews in Settings work. */
:root, [data-palette="paper"] {
  --bg: light-dark(#f5efe6, #1b1815);
  --surface: light-dark(#fffdf9, #24201c);
  --ink: light-dark(#2a2420, #f0e8dd);
  --accent: light-dark(#c2563a, #e07856);
}
[data-palette="ocean"] {
  --bg: light-dark(#edf2f5, #10171c);
  --surface: light-dark(#fbfdfe, #172128);
  --ink: light-dark(#1b2a35, #e3edf3);
  --accent: light-dark(#246b9e, #5aa9e0);
}
[data-palette="forest"] {
  --bg: light-dark(#eef1e8, #12170f);
  --surface: light-dark(#fbfcf7, #1a2117);
  --ink: light-dark(#222b1d, #e6eedc);
  --accent: light-dark(#3d7a37, #84c26f);
}
[data-palette="dusk"] {
  --bg: light-dark(#f1eef6, #15121c);
  --surface: light-dark(#fcfbfe, #1f1a28);
  --ink: light-dark(#29233a, #ebe5f5);
  --accent: light-dark(#6a4bb0, #a98ae6);
}
[data-palette="rose"] {
  --bg: light-dark(#f8eef0, #1b1214);
  --surface: light-dark(#fffbfc, #261a1d);
  --ink: light-dark(#35222a, #f4e6ea);
  --accent: light-dark(#b2385b, #ea7f9c);
}
[data-palette="graphite"] {
  --bg: light-dark(#f1f1ef, #121212);
  --surface: light-dark(#ffffff, #1c1c1c);
  --ink: light-dark(#1d1d1d, #ececec);
  --accent: light-dark(#2f2f2f, #e6e6e6);
}

/* ---- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--top-h) + 8px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.has-modal { overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 34px; line-height: 1.15; margin: 0 0 4px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
code {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.9em;
  background: var(--chip); padding: 2px 6px; border-radius: 6px; word-break: break-all;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.spacer { flex: 1; }
.indent { margin-left: 26px; }
.is-hidden { visibility: hidden; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

.icon { display: inline-flex; flex: none; }
.icon svg { width: 18px; height: 18px; display: block; }

/* ---- controls -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 14px/1.2 var(--sans);
  padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-small { padding: 5px 11px; font-size: 13px; }
.danger-text { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on-dark { color: #eee; }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.flip svg { transform: scaleX(-1); }
.chip-btn {
  font: 500 12.5px/1.3 var(--sans); padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--chip); color: var(--ink); cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

input[type="text"], input[type="search"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], select, textarea {
  font: inherit; color: var(--ink); background: var(--input-bg);
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.55; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > input[type="text"], .field > input[type="date"] { width: 100%; }
.field-label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex: none; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions:empty { display: none; }

/* ---- top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  height: var(--top-h); padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; color: var(--ink); text-decoration: none; font: 600 20px var(--serif); white-space: nowrap; }
.brand-mark { color: var(--accent); }
.brand-mark svg { width: 26px; height: 26px; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14px;
}
.tabs a:hover { background: var(--hover); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.badge { background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.badge:empty { display: none; }
.tabs a { white-space: nowrap; }
.top-actions { flex: 1; min-width: 0; display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.search {
  flex: 0 1 270px; min-width: 110px;
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; outline: 0; background: transparent; padding: 7px 0; width: 100%; min-width: 0; }
.search input:focus { outline: 0; }
.save-status { font-size: 12.5px; color: var(--muted); min-width: 64px; text-align: right; }
.save-status[data-state="error"], .save-status[data-state="conflict"] { color: var(--danger); font-weight: 700; }

/* ---- pages --------------------------------------------------------------- */
.page { max-width: 1120px; margin: 0 auto; padding: 30px 24px 90px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { padding: 30px 0; color: var(--muted); }
.empty-state ul { color: var(--ink-2); }
.banner {
  display: flex; align-items: center; gap: 12px; margin-top: 20px; padding: 13px 16px;
  border-radius: 12px; background: var(--banner-bg); border: 1px solid var(--banner-line);
  color: var(--ink); text-decoration: none;
}
.banner:hover { border-color: var(--accent); }
.banner > .icon { color: var(--accent); }
.banner-go { margin-left: auto; display: flex; align-items: center; gap: 2px; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* welcome */
.welcome { max-width: 760px; }
.welcome h1 { font-size: 44px; margin-top: 34px; }
.lede { font-size: 18px; line-height: 1.6; color: var(--ink-2); }
.steps { list-style: none; padding: 0; margin: 30px 0 22px; display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 16px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.step-num {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--chip); font: 700 17px var(--serif);
}
.step.is-done .step-num { background: var(--ok); color: #fff; }
.step h3 { margin: 4px 0; font-size: 19px; }
.step-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.privacy { color: var(--muted); font-size: 13.5px; }

/* ---- overview strip ------------------------------------------------------ */
.overview-card { margin: 20px 0 6px; padding: 12px 14px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.overview-legend { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 6px; }
.overview { width: 100%; overflow: hidden; }
.overview-svg { display: block; cursor: pointer; }
.ov-grid { stroke: var(--line); stroke-width: 1; }
.ov-year { fill: var(--muted); font: 600 11px var(--sans); }
.ov-label { fill: var(--muted); font: 700 10px var(--sans); letter-spacing: 0.06em; text-transform: uppercase; }
.ov-point[data-eid], .ov-span { cursor: pointer; }
.ov-point[data-eid]:hover circle { stroke: var(--ink); stroke-width: 2; }
.ov-col { fill: transparent; }
.ov-col:hover { fill: var(--hover); }
.ov-density { fill: var(--accent); opacity: 0.5; }
.ov-span rect { opacity: 0.9; }
.ov-span:hover rect { opacity: 1; }
.ov-span-label { fill: #fff; font: 600 10.5px var(--sans); pointer-events: none; }
.ov-point circle { stroke: var(--surface); stroke-width: 2; }
.ov-point circle.is-major { stroke: var(--ink); stroke-width: 1.5; }
.ov-birth { fill: var(--accent); }
.ov-now { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }

/* ---- timeline -------------------------------------------------------------- */
.timeline { margin-top: 10px; }
.tl { position: relative; display: grid; grid-template-columns: calc(var(--lanes, 0) * 12px + 4px) minmax(0, 1fr); }
.tl-lanes { position: relative; }
.tl-body { position: relative; padding-left: var(--pad); min-width: 0; }
.tl-body::before {
  content: ""; position: absolute; left: calc(var(--spine) - 1px); top: 0; bottom: 0; width: 2px;
  background: linear-gradient(var(--line-strong), var(--line-strong)) no-repeat;
}

.lane-bar {
  position: absolute; width: 6px; margin-left: 3px; padding: 0; border: 0; border-radius: 3px;
  background: var(--c); opacity: 0.85; cursor: pointer;
}
.lane-bar:hover, .lane-bar:focus-visible { opacity: 1; width: 8px; margin-left: 2px; }
.lane-bar.is-ongoing { background: linear-gradient(var(--c) 85%, transparent); border-radius: 3px 3px 0 0; }
.lane-bar::before, .lane-bar::after {
  content: ""; position: absolute; left: 100%; width: var(--reach); height: 2px; background: var(--c);
}
.lane-bar::before { top: 0; }
.lane-bar::after { bottom: 0; }
.lane-bar.is-ongoing::after { display: none; }

.year { position: relative; padding-bottom: 6px; }
.year-head {
  position: sticky; top: var(--top-h); z-index: 4;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  /* Reaches left over the timeline line too, so event dots slide under it when pinned. */
  margin-left: calc(-1 * var(--pad)); padding: 16px 0 8px var(--pad);
  background: linear-gradient(var(--bg) 90%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.year-head::before {
  content: ""; position: absolute; top: 31px; left: calc(var(--spine) - 8px);
  width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--ink);
}
.year-head::after { /* the timeline line, continued behind the pinned header */
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: calc(var(--spine) - 1px);
  width: 2px; background: var(--line-strong);
}
.year-head h2 { margin: 0; font-size: 36px; line-height: 1.1; }
.year-age { font: italic 18px var(--serif); color: var(--accent); }
.year-count { font-size: 13px; color: var(--muted); }

.empty-years { position: relative; display: flex; align-items: baseline; gap: 14px; padding: 12px 0; color: var(--muted); font-style: italic; }
.empty-years::before {
  content: ""; position: absolute; top: 19px; left: calc(var(--spine) - var(--pad) - 5px);
  width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line-strong);
}
.empty-years-label { font: normal 600 20px var(--serif); color: var(--muted); }

.loose {
  margin: 6px 0 16px; padding: 10px 12px 2px;
  border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--loose-bg);
}
.loose-label { font: italic 15px var(--serif); color: var(--muted); }
.loose .ev-dot { margin-left: -13.5px; } /* back onto the timeline line, past the box's padding */
.ev-untitled { font-style: italic; font-weight: 400; color: var(--muted); }
.loose .gallery { margin-top: 8px; }

/* a photo in a box of its (rotated) shape; the picture is turned inside it */
.ph { position: relative; display: block; overflow: hidden; background: var(--photo-bg); }
.ph img.turn {
  position: absolute; top: 50%; left: 50%; width: 100%; height: 100%;
  object-fit: cover; transform: translate(-50%, -50%) rotate(var(--turn, 0deg));
}
.ph img.turn-90 { --turn: 90deg; }
.ph img.turn-180 { --turn: 180deg; }
.ph img.turn-270 { --turn: 270deg; }

/* an event's photos — justified rows, order preserved */
.gallery { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.gallery::after { content: ""; flex-grow: 1000000; }
.tile {
  position: relative; min-width: 0; max-width: 100%; padding: 0; border: 0; border-radius: 6px;
  overflow: hidden; background: none; cursor: zoom-in; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.tile .ph { width: 100%; }
.tile-more {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.5); color: #fff; font: 700 22px var(--sans);
}

/* events on the timeline */
.ev {
  --dot: 26px;
  position: relative; display: flex; gap: 12px; max-width: 860px;
  margin: 12px 0; padding: 11px 15px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.ev:hover { border-color: var(--c); }
.ev.is-approx { border-style: dashed; }
.ev.is-flash { animation: flash 1.8s ease; }
@keyframes flash {
  15%, 55% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 55%, transparent); border-color: var(--c); }
}
.ev-body { flex: 1; min-width: 0; }
button.ev-title { display: block; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
button.ev-title:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ev-facts { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.ev-dot {
  position: absolute; top: 9px; left: calc(var(--spine) - var(--pad) - 1px - var(--dot) / 2);
  display: grid; place-items: center; width: var(--dot); height: var(--dot); border-radius: 50%;
  background: var(--c); color: #fff; box-shadow: 0 0 0 4px var(--bg);
}
.ev-dot svg { width: 14px; height: 14px; }
.ev-meta { font-size: 12.5px; color: var(--muted); }
.ev-title { font: 600 17px/1.3 var(--serif); }
.ev-notes { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ev.is-major {
  --dot: 34px;
  padding: 16px 20px; border-color: color-mix(in srgb, var(--c) 45%, transparent);
  background: color-mix(in srgb, var(--c) 11%, var(--surface));
}
.ev.is-major .ev-dot { top: 15px; }
.ev.is-major .ev-dot svg { width: 18px; height: 18px; fill: currentColor; }
.ev.is-major .ev-title { font-size: 23px; }
.ev.is-major .ev-meta { color: var(--c); font-weight: 600; }
.ev-start:not(.is-major) { border-left: 4px solid var(--c); }
.ev-end { --dot: 14px; padding: 5px 13px; background: transparent; border-style: dashed; max-width: 520px; }
.ev-end .ev-dot { top: 10px; }
.ev-end .ev-dot svg { display: none; }
.ev-end .ev-title { font-size: 14.5px; }
.ev-end .ev-meta { font-size: 12px; }
.ev-birth { cursor: default; }
.ev-birth:hover { border-color: color-mix(in srgb, var(--c) 45%, transparent); }

/* ---- modals ---------------------------------------------------------------- */
.backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: rgba(24, 18, 12, 0.5); backdrop-filter: blur(2px);
  animation: fade 0.15s ease;
}
.modal {
  position: relative; width: 100%; max-width: 580px; max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border-radius: 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  animation: rise 0.18s ease;
}
.modal-wide { max-width: 880px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px 0 24px; }
.modal-head h2 { margin: 0; font-size: 23px; }
.modal-body { padding: 16px 24px 24px; }
.modal > .modal-close { position: absolute; top: 10px; right: 10px; z-index: 5; }
.modal-confirm { max-width: 440px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.99); } }

/* event editor: photos on the left, details on the right */
.modal-event { display: flex; flex-direction: column; max-width: 1240px; height: calc(100vh - 48px); overflow: hidden; }
.modal-event .modal-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.modal-event .modal-body { flex: 1; min-height: 0; padding: 0; }
.ee { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); height: 100%; }
.ee-photos { position: relative; display: flex; flex-direction: column; min-height: 0; background: #15120f; color: #e8e0d6; }
.ee-stage, .viewer-stage { position: relative; flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; padding: 18px; }
.ee-stage .ph, .viewer-stage .ph {
  width: min(100cqw, calc(100cqh * var(--ar, 1.333)));
  border-radius: 3px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}
.ee-tools { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 4px 12px; font-size: 13px; color: #cfc6bb; }
.ee-count { margin-right: 8px; }
.ee-move { max-width: 230px; padding: 5px 8px; font-size: 13px; color: #eee; background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
.ee-move option { color: initial; background: initial; }
.ee-strip { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 12px; }
.ee-thumb { flex: none; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 7px; overflow: hidden; background: none; cursor: pointer; }
.ee-thumb .ph { height: 100%; }
.ee-thumb.is-selected { border-color: var(--accent); }
.ee-add { width: 64px; display: grid; place-items: center; color: #ddd; border: 2px dashed rgba(255, 255, 255, 0.3); }
.ee-add:hover { border-color: var(--accent); color: #fff; }
.ee-drop {
  margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 34px 40px;
  border: 2px dashed rgba(255, 255, 255, 0.25); border-radius: 18px; text-align: center;
}
.ee-drop p { margin: 0; }
.ee-drop .hint { color: #a99d90; }
.ee-drop-icon svg { width: 42px; height: 42px; color: #a99d90; }
.ee-progress { margin: 0; padding: 0 14px 10px; font-size: 13px; color: #e8e0d6; }
.ee-form { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; padding: 18px 22px 0; }
.ee-foot {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px;
  margin-top: auto; padding: 12px 0 16px; background: var(--surface); border-top: 1px solid var(--line);
}

/* photo viewer */
.modal-viewer { display: flex; flex-direction: column; max-width: 1400px; height: calc(100vh - 48px); overflow: hidden; background: #15120f; }
.modal-viewer .modal-body { flex: 1; min-height: 0; padding: 0; }
.modal-viewer .modal-close { color: #eee; }
.modal-viewer .modal-close:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-stage { padding: 52px 64px 12px; }
.viewer-bar { display: flex; align-items: center; gap: 14px; padding: 12px 20px 16px; color: #eee; }
.viewer-caption { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-caption strong { font: 600 18px var(--serif); }
.viewer-caption span, .viewer-count { font-size: 13px; color: #b9ada1; }

.stage-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.45); color: #fff; cursor: pointer;
}
.stage-nav:hover { background: rgba(0, 0, 0, 0.7); }
.stage-nav:disabled { opacity: 0.25; cursor: default; }
.stage-nav.prev { left: 12px; }
.stage-nav.next { right: 12px; }

/* fuzzy date input */
.date-input { display: flex; flex-direction: column; gap: 10px; }
.segmented { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--chip); border-radius: 11px; }
.seg { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font: 500 13px var(--sans); color: var(--ink-2); cursor: pointer; }
.seg:hover { color: var(--ink); }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.date-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.age-input { width: 58px; padding: 4px 8px !important; }
.date-preview { font-size: 14px; min-height: 21px; }
.date-preview.is-hint { color: var(--muted); }
.date-preview.is-ok { color: var(--ok); font-weight: 600; }
.date-helpers { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line-strong); font-size: 13.5px; }
.helper { display: inline-flex; align-items: center; gap: 4px; }
.event-pick { font-size: 13px; padding: 5px 8px; max-width: 100%; }

/* event form */
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kind-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px;
  border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  color: var(--ink); font: 600 13px var(--sans); cursor: pointer; text-align: center;
}
.kind-btn:hover { border-color: var(--accent); }
.kind-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.end-date { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.major-check .icon svg { width: 16px; height: 16px; color: #d39b16; fill: currentColor; }
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.swatch-auto { width: auto; padding: 0 11px; border-radius: 999px; color: #fff; font: 700 12px var(--sans); }

/* events page */
.event-group h2 { display: flex; align-items: center; gap: 8px; margin: 30px 0 10px; font-size: 21px; }
.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.event-item {
  width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.event-item:hover { border-color: var(--c); }
.event-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.event-item-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.event-item-when { color: var(--muted); font-size: 13.5px; text-align: right; }
.event-item-photos { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.event-item-photos svg { width: 14px; height: 14px; }
.icon.star svg { width: 15px; height: 15px; color: #d39b16; fill: currentColor; }

/* unsorted: undated events, not on the timeline line */
.unsorted-list { margin-top: 20px; }
.unsorted-list .ev-dot { display: none; }

/* day / month / year fields, in the user's order */
.parts { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.part-day { width: 76px; }
.part-month { width: 150px; }
.part-year { width: 96px; }
.date-range { display: flex; flex-direction: column; gap: 8px; }
.range-label { width: 40px; color: var(--muted); font-size: 13.5px; }
.date-range .hint { margin-left: 48px; }
.world-pick { width: 100%; }

/* date style choices */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.choice {
  position: relative; display: flex; flex-direction: column; gap: 1px; padding: 11px 14px 11px 40px;
  border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface); cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { position: absolute; left: 14px; top: 14px; width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.choice-main { font: 600 17px var(--serif); }
.choice-sub { font-size: 12.5px; color: var(--muted); }

/* color theme cards — each card is drawn in its own theme (data-palette on the card) */
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.palette {
  display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 10px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
  font: 600 13.5px var(--sans); text-align: left; cursor: pointer;
}
.palette:hover { border-color: var(--accent); }
.palette[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.palette-preview { position: relative; display: block; height: 54px; padding: 8px; border-radius: 8px; background: var(--bg); }
.pp-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 9px 10px; border-radius: 6px; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.pp-line { display: block; height: 5px; width: 70%; border-radius: 3px; background: var(--ink); opacity: 0.75; }
.pp-short { width: 42%; opacity: 0.35; }
.pp-dot { position: absolute; right: 14px; bottom: 14px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); }
.palette-name { padding: 0 2px; }

/* website mode: sign in / create account */
body.signed-out .topbar { display: none; }
.auth { max-width: 440px; margin: 0 auto; padding: 56px 20px 40px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font: 600 30px var(--serif); }
.auth-logo svg { width: 34px; height: 34px; color: var(--accent); }
.auth-tagline { margin: 8px 0 26px; text-align: center; color: var(--muted); }
.auth-card { display: flex; flex-direction: column; gap: 16px; padding: 26px 26px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0; font-size: 26px; }
.auth-tabs .seg { flex: 1; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form input { width: 100%; }
.auth-submit { justify-content: center; padding: 11px 16px; }
.auth-message { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.auth-message.is-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.auth-message.is-ok { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok); }
.auth-links { display: flex; justify-content: center; font-size: 14px; }
.auth-note { margin-top: 18px; font-size: 12.5px; line-height: 1.55; color: var(--muted); text-align: center; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* first-run setup */
.modal-setup { max-width: 640px; }
.setup { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.setup h2 { margin: 0; font-size: 30px; }
.setup-kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }

/* settings, import, export */
.settings { display: flex; flex-direction: column; gap: 6px; }
.settings-section { display: flex; flex-direction: column; gap: 10px; padding: 14px 0 16px; border-bottom: 1px solid var(--line); }
.settings-section:last-of-type { border-bottom: 0; }
.settings-section h3 { margin: 0; font-size: 18px; }
.settings-section .field-label { margin: 0; }
.library-path { display: block; padding: 8px 10px; }
.export-text { margin-top: 10px; font: 13px/1.55 ui-monospace, Consolas, monospace; min-height: 340px; background: var(--bg); }

/* toasts and drop zone */
#toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px 9px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: rise 0.18s ease;
}
.toast > span { flex: 1; }
.toast .icon-btn { width: 28px; height: 28px; color: inherit; }
.toast .icon-btn:hover { background: rgba(127, 127, 127, 0.25); }
.toast-error { background: var(--danger); color: #fff; }
#drop-overlay {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 16%, rgba(0, 0, 0, 0.25));
}
.drop-card { padding: 40px 56px; border: 3px dashed var(--accent); border-radius: 22px; background: var(--surface); font: 600 24px var(--serif); text-align: center; }

/* ---- small screens -------------------------------------------------------- */
@media (max-width: 1000px) {
  .brand-name { display: none; }
  .topbar { gap: 12px; padding: 0 16px; }
}
@media (max-width: 860px) {
  .ee { grid-template-columns: 1fr; grid-template-rows: 38vh minmax(0, 1fr); }
  #btn-add .label, .save-status { display: none; }
  #btn-add { padding: 9px; }
}
@media (max-width: 720px) {
  .topbar { position: static; height: auto; flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .year-head { top: 0; }
  html { scroll-padding-top: 8px; }
  .page { padding: 20px 16px 80px; }
  h1, .welcome h1 { font-size: 30px; }
  .kinds { grid-template-columns: 1fr; }
  .kind-btn { flex-direction: row; justify-content: flex-start; }
  .backdrop { padding: 0; }
  .modal { max-height: 100vh; border-radius: 0; min-height: 100vh; }
  .modal-event, .modal-viewer { height: 100vh; }
  .viewer-stage { padding: 52px 12px 12px; }
  .event-item { grid-template-columns: 10px minmax(0, 1fr); }
  .event-item-when { grid-column: 2; text-align: left; }
  .ev.is-major .ev-title { font-size: 19px; }
}
