:root {
  --ink: #1c1915;
  --paper: #f4efe4;
  --paper-deep: #efe6d4;
  --line: #ddcfb6;
  --forest: #1b2822;
  --muted: #6f675c;
  --danger: #8c3a32;
  --ok: #1f6b4a;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.45 "Avenir Next", "Segoe UI", sans-serif;
}

body.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow: hidden;
  background: var(--paper-deep);
}

a { color: inherit; }

.sidebar {
  background: var(--forest);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wordmark {
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  padding: 22px 18px 8px;
}

.add-entry {
  display: block;
  margin: 4px 12px 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--forest);
  text-align: center;
  text-decoration: none;
  font-weight: 600;
}

.tools {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid rgba(244, 239, 228, 0.16);
}

.tools a {
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
}

.tools a:hover, .layer-link:hover { background: rgba(244, 239, 228, 0.08); }

.layer-scroll { overflow: auto; padding: 10px 0; flex: 1; }

.layer-link {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 2px 10px;
  padding: 8px;
  border-radius: 10px;
  text-decoration: none;
}

.layer-link.active { background: var(--paper); color: var(--ink); }

.layer-name, .layer-count { display: block; }
.layer-count, .quiet { color: var(--muted); font-size: 0.82rem; }
.layer-link.active .layer-count { color: #5c564c; }

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  margin-top: 4px;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.badge {
  display: inline-block;
  min-width: 1.2rem;
  padding: 0 6px;
  border-radius: 99px;
  background: #e7c36a;
  color: var(--ink);
  font-size: 0.75rem;
  text-align: center;
}

.logout { padding: 10px; }
.logout button, .quiet-button {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(244, 239, 228, 0.3);
}

.content { position: relative; min-width: 0; min-height: 0; overflow: auto; }
#map { position: absolute; inset: 0; }

.legend, .hover-label, .flashes {
  position: absolute;
  z-index: 2;
  margin: 0;
}

.legend {
  left: 12px;
  bottom: 28px;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.hover-label {
  left: 12px;
  top: 12px;
  background: var(--forest);
  color: var(--paper);
  border-radius: 8px;
  padding: 4px 8px;
}
.hover-label:empty { display: none; }

.flashes { left: 12px; right: 12px; top: 12px; }
.content:has(.flashes) .page { padding-top: 4.5rem; }

.flash {
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fffdf8;
  border: 1px solid var(--line);
}
.flash.error { border-color: var(--danger); color: var(--danger); }
.flash.ok { border-color: var(--ok); }

.panel {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(380px, calc(100% - 24px));
  overflow: auto;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  z-index: 2;
  box-shadow: 0 16px 40px rgba(28, 25, 21, 0.14);
}
.panel header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.panel h2 { font-family: Palatino, Georgia, serif; font-size: 1.6rem; margin: 0; }
.panel ul { list-style: none; padding: 0; }
.panel li { padding: 8px 0; border-top: 1px solid var(--line); }
.panel li span { display: block; color: var(--muted); font-size: 0.85rem; }

.page { padding: 28px 32px 64px; max-width: 980px; }
.page.narrow { max-width: 680px; }
h1 { font-family: Palatino, Georgia, serif; font-size: 2.2rem; font-weight: 500; margin: 0 0 8px; }
h2 { font-family: Palatino, Georgia, serif; font-weight: 500; }
.lede { color: #3f3a33; max-width: 62ch; }
.eyebrow { color: var(--muted); margin-bottom: 0; }

label, legend { display: block; margin-top: 14px; font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="date"], input:not([type]), select, textarea, input[type="file"] {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font: inherit;
  color: inherit;
}
textarea { resize: vertical; }
input[type="color"] { width: 72px; height: 40px; padding: 0; border: 1px solid var(--line); background: white; margin-top: 4px; }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; }

button, .button {
  margin-top: 16px;
  background: var(--forest);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.danger { background: var(--danger); }
.quiet-button { margin-top: 6px; color: var(--ink); border-color: var(--line); }
.danger-zone { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--line); }

.card-list { list-style: none; padding: 0; }
.card-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.review-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.review-row button { margin: 0; }
.totals { display: flex; gap: 16px; padding: 0; list-style: none; }
.pager { display: flex; gap: 12px; align-items: center; }

.photo-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.photo-grid img { width: 160px; height: 120px; object-fit: cover; border-radius: 8px; background: var(--paper-deep); }
.photo-grid figure { margin: 0; }
.uploads { border: 1px solid var(--line); border-radius: 12px; margin-top: 18px; padding: 8px 12px 14px; }

body.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, #2c4638, transparent 40%),
    var(--forest);
}
.login-card {
  width: min(440px, calc(100% - 32px));
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  padding: 28px;
}
.login-card h1 { font-family: Palatino, Georgia, serif; font-size: 2.4rem; margin: 0 0 8px; }
.login-card pre {
  white-space: pre-wrap;
  background: var(--forest);
  color: var(--paper);
  padding: 12px;
  border-radius: 10px;
}

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { max-height: 42vh; }
  .review-row { grid-template-columns: 1fr; }
  .page { padding: 20px 16px 48px; }
  .panel { left: 8px; right: 8px; top: auto; height: 46%; width: auto; }
}
