:root {
  --paper: #f4efe5;
  --ink: #1c1b19;
  --muted: #6d665a;
  --faint: #c9bfad;
  --line: #d6ccba;
  --accent: #2b5895;
  --ok: #3b7a4d;
  --warn: #d6941a;
  --bad: #c63a2c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15171b;
    --ink: #ebe5d8;
    --muted: #9a9487;
    --faint: #3b3e45;
    --line: #2a2d33;
    --accent: #709fe2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: #1d1c1a;
  color: var(--ink);
  font: 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* The poster fills the whole window. */

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.stage.idle { cursor: none; }

.poster {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.stage.idle .poster { cursor: none; }

.hover-hint {
  position: fixed;
  z-index: 5;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}


.poster-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.poster-svg text { font-family: var(--sans); }
.poster-svg .p-wordmark,
.poster-svg .p-empty { font-family: var(--serif); }
.poster-svg .p-empty { font-style: italic; }
.poster-svg .p-caption { font-weight: 600; }
.poster-svg .ac-title,
.poster-svg .ac-code { letter-spacing: 0.02em; }

/* Controls appear on pointer movement and hide again for the wall. */

.tools {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 1;
  transition: opacity 0.4s;
}

.stage.idle .tools { opacity: 0; pointer-events: none; }
.stage.idle .tools:has(.status[data-state="bad"]) { opacity: 1; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--muted); }

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 7px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.status[data-state="ok"] .status-dot { background: var(--ok); }
.status[data-state="warn"] .status-dot { background: var(--warn); }
.status[data-state="bad"] .status-dot { background: var(--bad); }

/* Setup dialog */

.eyebrow {
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.setup {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 28px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.setup::backdrop { background: rgba(20, 18, 14, 0.55); }

.setup h2 {
  margin: 0 0 8px;
  font: 500 28px/1.1 var(--serif);
}

.setup-note {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.setup code { font-size: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}

.field small { font-size: 11px; }

.field input,
.field select {
  font: 15px/1.3 var(--sans);
  padding: 8px 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--faint);
  border-radius: 4px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.field-row { display: flex; gap: 12px; }

.map-picker {
  height: 230px;
  margin: 0 0 6px;
  border: 1px solid var(--faint);
  border-radius: 4px;
  background: var(--line);
  cursor: crosshair;
}

.map-picker.leaflet-container { font: 11px/1.3 var(--sans); }

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.number-unit {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
}

.number-unit input {
  width: 64px;
  font: 15px/1.3 var(--sans);
  padding: 6px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--faint);
  border-radius: 4px;
}

.form-section {
  margin: 8px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.setup-hint {
  margin: -2px 0 10px;
  font-size: 12px;
  color: var(--muted);
}

/* Colour changes cross-fade: the new poster fades in over the old one. */
.poster-layer {
  position: absolute;
  inset: 0;
}

.poster-layer.fade-in {
  animation: poster-fade 2.4s ease-in-out both;
}

@keyframes poster-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.link-btn {
  margin: -4px 0 14px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-error {
  margin: 0 0 12px;
  color: var(--bad);
  font-size: 13px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  padding: 9px 18px;
  font: 600 14px/1 var(--sans);
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}

.btn-quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--faint);
}

a.btn { text-decoration: none; display: inline-flex; align-items: center; }

.profile-actions {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 6px;
}

.profile-actions .link-btn { margin: 0; }
.link-danger { color: var(--bad); }

/* Home and login */

.page-center {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-card {
  width: min(460px, 100%);
}

.login-card h1 {
  margin: 4px 0 10px;
  font: 500 clamp(30px, 5vw, 42px)/1.05 var(--serif);
}

.login-form { margin-top: 22px; }

.home-section {
  max-width: 720px;
  margin: 28px 0;
}

.home-h2 {
  margin: 0 0 12px;
  font: 500 24px/1.2 var(--serif);
}

.profile-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.profile-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.profile-list .link-btn { margin: 0; flex: none; }

.profile-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  min-width: 0;
}

.profile-link strong { font: 500 22px/1.2 var(--serif); }

.profile-link span {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-profile {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.new-profile .field { margin: 0; min-width: 240px; }

.home-foot { margin-top: 40px; }
.actions-start { margin-right: auto; }

/* ---------- Catalog page ---------- */

body.page {
  overflow: auto;
  background: var(--paper);
  padding: clamp(18px, 3vw, 44px);
}

.page a { color: inherit; }

.catalog-link {
  display: inline-block;
  margin: -4px 0 14px;
}

.cat-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ink);
}

.cat-head h1 {
  margin: 4px 0 6px;
  font: 500 clamp(34px, 5vw, 56px)/1 var(--serif);
}

.cat-lede {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
}

.cat-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, auto));
  gap: 12px 28px;
  margin: 0;
}

.cat-stats dt {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.cat-stats dd {
  margin: 2px 0 0;
  font: 500 22px/1.1 var(--serif);
  font-variant-numeric: tabular-nums;
}

.cat-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 18px 0 22px;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.segmented button {
  padding: 6px 14px;
  font: 600 12.5px/1 var(--sans);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
}

#search {
  flex: 1 1 220px;
  max-width: 340px;
  padding: 8px 12px;
  font: 14px/1.3 var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--faint);
  border-radius: 999px;
}

.cat-message {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--ok);
  background: rgba(59, 122, 77, 0.08);
}

.cat-message.is-error {
  border-color: var(--bad);
  background: rgba(198, 58, 44, 0.08);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--paper);
}

.cat-figure {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 7;
  padding: 14px 18px;
  background: #3f65a9;
}

.cat-figure img,
.cat-figure svg {
  max-width: 100%;
  max-height: 100%;
}

.cat-figure.is-placeholder svg { opacity: 0.55; }

.cat-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding: 12px 14px 14px;
}

.cat-body h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font: 600 16px/1.25 var(--sans);
}

.cat-badge {
  flex: none;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

.status-ready .cat-badge { color: var(--ok); border-color: currentColor; }
.status-drawing .cat-badge { color: var(--accent); border-color: currentColor; }
.status-failed .cat-badge { color: var(--bad); border-color: currentColor; }

.cat-type { margin: 0; }

.cat-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.cat-details {
  font-size: 12px;
  color: var(--muted);
}

.cat-details summary {
  cursor: pointer;
  width: fit-content;
}

.cat-sightings {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
}

.cat-sightings li {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.cat-reg {
  color: var(--ink);
  font-weight: 600;
}

.cat-error {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--bad);
}

.cat-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.btn-small {
  padding: 7px 12px;
  font-size: 12.5px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cat-empty {
  color: var(--muted);
  font: italic 16px/1.4 var(--serif);
}

.cone-label {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
