:root {
  --bg: #16180f;
  --surface: #20231a;
  --surface-2: #2a2e22;
  --line: #3a3f30;
  --text: #ece8da;
  --muted: #a3a18f;
  --accent: #ff7a1a;        /* blaze orange */
  --accent-ink: #1a1206;
  --olive: #8a9a4c;
  --danger: #e2533f;
  --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f1e8; --surface: #fffdf7; --surface-2: #ebe7da; --line: #d8d2c0;
    --text: #23251c; --muted: #6b6a5b; --accent: #d95f00; --accent-ink: #fff; --olive: #5f6e2a;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 17px; margin: 28px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin: 0 0 10px; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.spacer { flex: 1; }
button, input, select { font: inherit; color: inherit; }

.btn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; min-height: 44px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.icon-btn {
  background: none; border: 0; color: var(--text); width: 44px; height: 44px;
  display: inline-grid; place-items: center; cursor: pointer; border-radius: 10px;
}
.icon-btn:hover { background: var(--surface-2); }
input:not([type=checkbox]), select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 44px; width: 100%;
}
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px; background: var(--surface);
  padding: 28px 22px; border-radius: 18px; border: 1px solid var(--line);
}
.login-logo { width: 56px; height: 56px; }
.login-card h1 { font-size: 24px; }
.login-card p { margin: -6px 0 4px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; margin-right: auto; }
.top select { flex: 1; min-width: 0; max-width: 340px; }
.menu {
  position: fixed; right: 10px; top: calc(62px + env(safe-area-inset-top)); z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  min-width: 210px; padding: 6px; display: grid; box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.menu button { background: none; border: 0; text-align: left; padding: 12px 14px; border-radius: 10px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu-who { padding: 10px 14px 8px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.view { padding: 0 12px 40px; max-width: 1400px; margin: 0 auto; }
.view.narrow { max-width: 440px; }

/* Gallery layout: filter column + results */
.view.gallery-layout { max-width: none; }
.gallery-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.side {
  position: sticky; top: calc(61px + env(safe-area-inset-top)); max-height: calc(100dvh - 61px - env(safe-area-inset-top));
  overflow-y: auto; overflow-x: hidden; padding: 14px 8px 24px 0; scrollbar-width: thin; scrollbar-gutter: stable;
}
.side-head { display: none; }
.side-sec { padding: 4px 0 14px; }
.side-sec + .side-sec { border-top: 1px solid var(--line); padding-top: 14px; }
.side-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 6px 10px;
}
.side-group { font-size: 12px; color: var(--muted); margin: 10px 0 2px 10px; }
.side-group:first-child { margin-top: 0; }
.side-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.side-list .tab, .side-list .cam {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-radius: 8px; padding: 8px 10px; min-height: 38px;
  color: var(--text); position: relative;
}
.side-list .tab:hover, .side-list .cam:hover { background: var(--surface-2); }
.side-list .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list .n { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.side-list .tab[aria-selected=true], .side-list .cam[aria-selected=true] { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }
.side-list [aria-selected=true]::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--accent);
}
.side-list [aria-selected=true] .n { color: var(--text); }
.date-pair { display: grid; gap: 8px; padding: 0 2px 0 10px; }
.date-pair label { font-size: 13px; }
.date-pair input { min-height: 40px; padding: 6px 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; margin-left: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 8px 6px; cursor: pointer; min-height: 38px; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side-clear { margin: 4px 0 0 10px; width: calc(100% - 10px); min-height: 40px; padding: 8px; font-size: 14px; }

.results { min-width: 0; }
.results-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 16px 0 4px; }
.results-head h2 { margin: 0; font-size: 20px; }
.scrim { display: none; }
.filter-btn { margin-left: -6px; }

/* Phones and narrow windows: the filter column slides in from the left */
@media (max-width: 860px) {
  .gallery-layout { display: block; }
  .side {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); max-height: none;
    background: var(--surface); border-right: 1px solid var(--line); box-shadow: 8px 0 30px rgba(0,0,0,.35);
    padding: calc(8px + env(safe-area-inset-top)) 10px calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-105%); transition: transform .22s ease; visibility: hidden;
  }
  body.filters-open .side { transform: none; visibility: visible; }
  .side-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; padding: 0 0 6px 10px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.5); }
  .results-head { padding-top: 12px; }
  .results-head h2 { font-size: 18px; }
}
@media (min-width: 861px) { .filter-btn { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* Grid */
.day-head {
  position: sticky; top: calc(61px + env(safe-area-inset-top)); z-index: 5; background: var(--bg);
  padding: 12px 2px 8px; font-weight: 600; font-size: 14px; display: flex; gap: 8px;
}
.day-head span { color: var(--muted); font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } }
.cell {
  position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); border: 0; padding: 0;
  cursor: pointer; overflow: hidden; border-radius: 6px;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .badge {
  position: absolute; left: 4px; top: 4px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px;
}
.cell .time {
  position: absolute; right: 4px; bottom: 4px; font-size: 11px; color: #fff;
  background: rgba(0,0,0,.55); padding: 0 5px; border-radius: 5px; font-variant-numeric: tabular-nums;
}
.more { text-align: center; padding: 24px; }
.updated { text-align: center; font-size: 13px; }
.empty-msg { padding: 40px 10px; text-align: center; }

/* Viewer */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #eee;
  display: grid; grid-template-rows: auto 1fr auto;
}
.v-top { display: flex; align-items: center; justify-content: space-between; padding: calc(4px + env(safe-area-inset-top)) 6px 4px; }
.v-top .icon-btn { color: #eee; }
.v-top .icon-btn:hover { background: #222; }
.v-stage { position: relative; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.4); color: #fff;
  border: 0; font-size: 40px; width: 48px; height: 72px; cursor: pointer; border-radius: 8px;
}
.v-nav.prev { left: 6px; } .v-nav.next { right: 6px; }
@media (hover: none) { .v-nav { display: none; } }
.v-info {
  background: #111; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); font-size: 14px;
  max-height: 38dvh; overflow-y: auto; border-top: 1px solid #222;
}
.v-info .when { font-weight: 600; font-size: 15px; }
.v-info .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: #262a1d; border: 1px solid #3a3f30; border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chip.hot { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 700; }
.v-info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0 0; }
.v-info dt { color: #9a9a88; }
.v-info dd { margin: 0; }

/* Activity charts */
.legend { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.key:first-child { margin-left: 0; }
.k-bucks { background: var(--accent); }
.k-deer { background: color-mix(in srgb, var(--olive) 55%, transparent); }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 8px 4px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }

/* Admin */
.cards { display: grid; gap: 8px; margin-bottom: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.card .main { flex: 1; min-width: 0; }
.card .title { font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.log {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; font-size: 12px; overflow-y: auto; max-height: 340px; white-space: pre-wrap; overflow-wrap: anywhere;
}
dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  width: min(460px, calc(100% - 24px)); padding: 20px;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
fieldset { border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 8px; padding: 10px 12px; }
legend { color: var(--muted); font-size: 14px; padding: 0 4px; }

/* Fix a photo */
.v-info .fix-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.v-info .fix-row .btn { padding: 6px 14px; }
.num-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.num-row input { width: 100%; }
#fixDlg select { width: 100%; }
.badge.moved { background: #3a3f30; color: #e8e6d8; }
.more-btn { min-width: 220px; }
.side-note { margin: 2px 0 0 10px; }

/* Points slider under Bucks */
.sub-list { margin: 2px 0 8px 18px; padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
.sub-list .side-note { margin: 4px 0; }
.pts-box { padding: 6px 4px 2px 0; }
.pts-read { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.pts-read .n { color: var(--muted); font-weight: 400; font-size: 12px; font-variant-numeric: tabular-nums; }
.pts-bars { display: flex; align-items: flex-end; gap: 2px; height: 28px; padding: 0 9px; }
.pts-bars span { flex: 1; background: var(--line); border-radius: 2px 2px 0 0; min-width: 2px; }
.pts-bars span.on { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.dual { position: relative; height: 28px; }
.dual-track { position: absolute; left: 9px; right: 9px; top: 12px; height: 4px; border-radius: 4px; background: var(--line); }
.dual-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.dual input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 28px; margin: 0; padding: 0; min-height: 0;
  background: none; border: 0; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.dual input[type=range]::-webkit-slider-runnable-track { background: none; height: 28px; }
.dual input[type=range]::-moz-range-track { background: none; }
.dual input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 20px; height: 20px; margin-top: 4px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); cursor: grab;
}
.dual input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); cursor: grab;
}
.dual input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--text); outline-offset: 2px; }
.dual[data-same] { opacity: .5; }
.pts-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 2px; }
.link-btn { background: none; border: 0; padding: 6px 0 2px; color: var(--accent); cursor: pointer; font-size: 13px; }
.run-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 4px; }
.run-row .small { margin: 0; }
.btn:disabled { opacity: .6; cursor: default; }

/* "Other animals & more" fold */
.side-more { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.side-more > summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  padding: 8px 10px; min-height: 38px; border-radius: 8px; color: var(--text); font-weight: 600;
}
.side-more > summary::-webkit-details-marker { display: none; }
.side-more > summary::before {
  content: ""; width: 7px; height: 7px; flex: none; margin: 0 2px 0 1px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s;
}
.side-more[open] > summary::before { transform: rotate(45deg); margin-top: -3px; }
.side-more > summary:hover { background: var(--surface-2); }
.side-more > summary .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-more > summary .n { flex: none; color: var(--muted); font-size: 13px; font-weight: 400; font-variant-numeric: tabular-nums; }
.side-more-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; padding-left: 12px; }
@media (prefers-reduced-motion: reduce) { .side-more > summary::before { transition: none; } }
