/* LastScene — "Darkroom": warm near-black ground, safelight amber accent,
   Bricolage Grotesque for type, IBM Plex Mono for times and counts. */
:root {
  --ground: #121110;
  --surface: #1c1b19;
  --surface-2: #2a2825;
  --line: #2a2825;
  --line-strong: #34312d;
  --text: #f3efe8;
  --text-2: #c9c2b6;
  --muted: #a8a196;
  --faint: #6b655c;
  --amber: #f4a73b;
  --amber-hi: #ffc56e;
  --on-amber: #121110;
  /* Chart series: validated pair (blue / deep amber) on --surface */
  --series-1: #3987e5;
  --series-2: #c98500;
  /* Status: always paired with an icon + label */
  --good-bg: #183424;
  --good-ink: #8fd6a5;
  --warn-bg: #3a2c10;
  --warn-line: #5a4418;
  --warn-ink: #f1c46b;
  --danger: #ff8a7a;

  --radius-lg: 20px;
  --radius: 16px;
  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1200px; margin-inline: auto; padding-inline: 32px; }
.mono { font-family: var(--mono); }
a { color: var(--amber); }
a:hover { color: var(--amber-hi); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }

/* ---------- header & tabs ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--amber);
  text-decoration: none;
}
.brand span { color: var(--text); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand:hover { color: var(--amber); }
.user-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.user-bar .mono { font-size: 13px; color: var(--muted); }

button { font: inherit; cursor: pointer; }
.pill {
  font-size: 14px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  transition: background-color 0.15s, border-color 0.15s;
}
.pill:hover { background: var(--surface); border-color: var(--faint); }
.pill.quiet { color: var(--muted); }
.primary {
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  border: 0;
  background: var(--amber);
  color: var(--on-amber);
  font-size: 17px;
  font-weight: 700;
  transition: background-color 0.15s;
}
.primary:hover { background: var(--amber-hi); }

.tabs {
  display: flex;
  gap: 28px;
  margin-top: 20px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
}
.tabs a {
  padding: 12px 0;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--amber); }

main { padding-block: 40px 72px; }

/* ---------- type ---------- */
.eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}
.eyebrow.small { font-size: 11px; color: var(--faint); margin: 0; }
.display {
  margin: 0;
  font-size: clamp(36px, 6vw, 56px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
}
h2 { margin: 0; font-size: 18px; font-weight: 700; }
h3 { margin: 0; }
.lede { margin: 16px 0 28px; font-size: 20px; color: var(--text-2); max-width: 32ch; }
#status { color: var(--muted); margin: 0 0 16px; }
#status:empty { display: none; }
.empty { margin: 0; color: var(--muted); font-size: 17px; }
.error { color: var(--danger); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
}
.page { animation: rise 0.35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- sign-in ---------- */
.signin { padding: 12vh 0 8vh; max-width: 640px; }

/* ---------- shared bits ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.card > h2 { margin-bottom: 16px; }
.card-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.chip.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn-ink); }
.chip.place { font-family: var(--sans); font-size: 14px; padding: 4px 12px; background: var(--surface-2); border: 0; color: var(--text); }
.chip.place b { font-weight: 400; color: var(--amber); }

.photo {
  position: relative;
  background: var(--surface-2);
  overflow: hidden;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.empty-photo::after {
  content: "No photo";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 12px var(--mono);
  color: var(--faint);
}
.quote { margin: 0; color: var(--text-2); }
.saw { margin: 0; font-size: 15px; color: var(--muted); }
.saw::before { content: "◉ "; color: var(--amber); }
.summary { background: var(--surface); }
.summary-text { margin: 0; font-size: 22px; line-height: 1.45; letter-spacing: -0.01em; max-width: 60ch; }
.summary-by { margin: 12px 0 0; font: 12px var(--mono); color: var(--faint); }

.search { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); width: 280px; max-width: 100%; }
.search input {
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}
.search input::placeholder { color: var(--faint); }

/* ---------- Items ---------- */
.featured {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.featured .photo { min-height: 300px; }
.featured .tag {
  position: absolute;
  z-index: 1;
  top: 16px;
  left: 16px;
  font: 12px var(--mono);
  color: var(--on-amber);
  background: var(--amber);
  padding: 4px 10px;
  border-radius: 999px;
}
.featured-body { padding: 32px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.featured .when { font-size: 13px; color: var(--muted); }
.featured .item-name { margin: 0; font-size: 40px; letter-spacing: -0.02em; font-weight: 700; }
.featured .item-location { margin: 0; font-size: 24px; color: var(--amber); }
.featured .quote { margin-top: 6px; font-size: 17px; }
.featured .chips { margin-top: 8px; }

.items-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s;
}
.item-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.item-card .photo { aspect-ratio: 4 / 3; }
.item-body { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.item-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-card .item-name { font-size: 22px; font-weight: 700; }
.item-card .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.item-card .item-location { margin: 0 0 8px; font-size: 18px; color: var(--amber); }
.before { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.before ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: 15px; color: var(--text-2); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.scene {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
}
.scene:last-child { border-bottom: 1px solid var(--line); }
.scene-time { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.scene-time time { font-size: 15px; }
.scene-time .ago { font-size: 12px; color: var(--faint); }
.scene-body { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.scene .photo { width: 240px; max-width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; }
.scene-text { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.scene .quote { font-size: 26px; line-height: 1.35; letter-spacing: -0.01em; color: var(--text); }

/* ---------- Map ---------- */
.map-card { padding: 0; overflow: hidden; }
.home-map { position: relative; height: clamp(320px, 56vw, 560px); background: var(--ground); }
.home-map .empty { padding: 24px; }
.map-legend { padding: 16px 24px 0; }
.map-card details { padding: 0 24px 20px; }
.map-controls { display: flex; align-items: center; gap: 12px; }
.map-clock { font-size: 13px; color: var(--muted); min-width: 12ch; }
.room-swatch { background: rgba(201, 133, 0, 0.6); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-asked { background: var(--amber); }
.dot-calm { background: var(--series-1); }
.trail-swatch { width: 18px; height: 3px; border-radius: 2px; background: var(--amber); display: inline-block; }

/* ---------- Map modes, places & public maps ---------- */
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.map-controls { flex-wrap: wrap; }
.attribution { margin: 0; padding: 6px 24px 0; font-size: 11px; color: var(--faint); }
.attribution a { color: var(--muted); }
.dot-memory { background: var(--text); }
.places-hint { padding: 0 24px 20px; margin: 8px 0 0; }
.public-map { height: clamp(360px, 60vw, 620px); }
.privacy-card ul { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 6px; }
.public-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.public-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.public-where, .public-total { font-size: 13px; color: var(--muted); }
.signin-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.link-pill { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }

/* ---------- Household setup ---------- */
.household { display: grid; gap: 16px; }
.household .two-col { margin-bottom: 0; }
.setup-card { display: flex; flex-direction: column; gap: 12px; margin-bottom: 0; }
.setup-card h2 { margin: 0; }
.setup-card .hint { margin: 0; }
.setup-card .primary { align-self: flex-start; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .place-row input, .place-row select {
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--ground);
  color: var(--text);
}
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rows li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.muted { color: var(--muted); font-size: 14px; }
.place-row { align-items: center; }
.place-row input { flex: 1 1 200px; min-width: 0; }
.toggle { display: flex; gap: 10px; align-items: center; font-size: 17px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--amber); }
.invite-code { margin: 0; color: var(--amber); font-size: 15px; }
.invite-code:empty { display: none; }
.form-msg { margin: 0; color: var(--muted); }
.form-msg:empty { display: none; }

/* ---------- Search ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.search-form { display: flex; gap: 12px; flex-wrap: wrap; }
.search-form input {
  flex: 1 1 280px;
  font: inherit;
  font-size: 20px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}
.search-form input::placeholder { color: var(--faint); }
.search-hint { margin: 12px 0 24px; }
.search-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.result {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.result .photo { min-height: 140px; }
.result-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.result-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; font-size: 13px; color: var(--muted); }
.result-rank { color: var(--amber); font-size: 15px; }
.result-score { margin-left: auto; color: var(--faint); }
.chunks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.chunk { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; color: var(--faint); font-size: 15px; }
.chunk.matched { color: var(--text); }
.kind { font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chunk.matched .kind { background: var(--warn-bg); color: var(--warn-ink); }
.chunk-text { flex: 1 1 200px; min-width: 0; }
.why { font-size: 12px; color: var(--amber); }

/* ---------- Insights ---------- */
.tiles {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 16px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tile-value { font-size: 52px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 15px; color: var(--muted); }
.tile.alert { background: var(--warn-bg); border-color: var(--warn-line); }
.tile.alert .tile-value { color: var(--amber); }
.tile.alert .tile-label { color: var(--warn-ink); }

.notice { display: flex; gap: 20px; align-items: flex-start; color: var(--amber); }
.notice > div { flex: 1; min-width: 0; color: var(--text); }
.notice h2 { margin-bottom: 10px; font-size: 20px; }
.notice p { margin: 0; font-size: 18px; line-height: 1.5; color: #e2dcd2; }
.notice p + p { margin-top: 10px; }
.notice strong { color: var(--text); }

.two-col { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 16px; }
.two-col .card { margin-bottom: 0; }

.s1 { background: var(--series-1); }
.s2 { background: var(--series-2); }

.bar-list { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 14px 12px; align-items: center; }
.bar-row { display: contents; }
.bar-list .empty { grid-column: 1 / -1; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; display: flex; }
.bar { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; transform-origin: left; animation: grow-x 0.6s cubic-bezier(.2,.7,.2,1) both; }
.bar-value { font: 14px var(--mono); color: var(--muted); min-width: 2ch; text-align: right; }
@keyframes grow-x { from { transform: scaleX(0); } }

.legend { display: flex; flex-wrap: wrap; gap: 20px; color: var(--muted); font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.column-chart { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; height: 200px; }
.col-group { display: flex; flex-direction: column; min-width: 0; }
.col-bars { flex: 1; display: flex; gap: 2px; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line-strong); }
.col-hit { flex: 1; max-width: 22px; height: 100%; display: flex; align-items: flex-end; }
.col { width: 100%; border-radius: 4px 4px 0 0; transform-origin: bottom; animation: grow-y 0.6s cubic-bezier(.2,.7,.2,1) both; }
@keyframes grow-y { from { transform: scaleY(0); } }
.col-label { text-align: center; font: 11px var(--mono); color: var(--faint); padding-top: 8px; white-space: nowrap; }
details { margin-top: 16px; color: var(--muted); }
summary { cursor: pointer; font-size: 14px; }
details table { margin-top: 8px; border-collapse: collapse; font-size: 14px; color: var(--text-2); }
details th, details td { text-align: left; padding: 6px 16px 6px 0; border-bottom: 1px solid var(--line); }
details th { color: var(--muted); font-weight: 500; }

.questions { list-style: none; margin: 0; padding: 0; }
.questions li { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); }
.q-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.q-head strong { font-size: 19px; font-weight: 500; }
.q-answer { margin: 0; font-size: 16px; color: var(--text-2); }
.questions time { font: 12px var(--mono); color: var(--faint); }
.badge { font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.badge.good { background: var(--good-bg); color: var(--good-ink); }
.badge.warning { background: var(--warn-bg); color: var(--warn-ink); }

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--text);
  color: var(--ground);
  padding: 4px 8px;
  border-radius: 6px;
  font: 13px var(--mono);
  z-index: 10;
  white-space: nowrap;
}

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

@media (max-width: 640px) {
  .wrap { padding-inline: 16px; }
  .tabs { gap: 20px; }
  .featured .photo { min-height: 220px; }
  .featured-body { padding: 24px; }
  .featured .item-name { font-size: 32px; }
  .scene { grid-template-columns: 1fr; gap: 12px; }
  .scene-time { flex-direction: row; gap: 12px; align-items: baseline; }
  .scene .photo { width: 100%; }
  .scene .quote { font-size: 22px; }
  .col-label { font-size: 10px; }
  .tile-value { font-size: 40px; }
  .result { grid-template-columns: 1fr; }
  .public-row { grid-template-columns: 1fr; }
  .result .photo { aspect-ratio: 4 / 3; }
}
