/* =========================================================================
   Mason County Ranch — styles. Light by default, dark via the OS setting.
   Built phone-first: big tap targets, one column under 760px.
   ========================================================================= */
:root {
  --bg: #F4F1EA; --panel: #FFFFFF; --panel-2: #F7F5EF;
  --line: rgba(47, 58, 43, .12); --line-2: rgba(47, 58, 43, .22);
  --ink: #1F261C; --ink-soft: #3C4636; --muted: #6A7163;
  --accent: #4F6B35; --accent-ink: #FFFFFF; --accent-soft: rgba(79, 107, 53, .12);
  --good: #2F7D4A; --warn: #B7791F; --bad: #C0392B;
  --good-soft: rgba(47, 125, 74, .12); --warn-soft: rgba(183, 121, 31, .14); --bad-soft: rgba(192, 57, 43, .12);
  --bar: #6E8B4E; --bar-low: #C0392B; --bar-ref: #1F261C;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 38, 28, .06), 0 6px 20px rgba(31, 38, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141712; --panel: #1C201A; --panel-2: #232820;
    --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .16);
    --ink: #ECEEE7; --ink-soft: #C9CEC1; --muted: #979E8F;
    --accent: #8DB065; --accent-ink: #141712; --accent-soft: rgba(141, 176, 101, .15);
    --good: #6FC28A; --warn: #E3AE52; --bad: #F07A6B;
    --good-soft: rgba(111, 194, 138, .14); --warn-soft: rgba(227, 174, 82, .15); --bad-soft: rgba(240, 122, 107, .14);
    --bar: #8DB065; --bar-low: #F07A6B; --bar-ref: #ECEEE7;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 650; margin: 18px 0 8px; color: var(--ink-soft); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small, small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.bad-t { color: var(--bad); font-weight: 600; }

/* --------------------------------- chrome -------------------------------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); 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; font-weight: 700; color: var(--ink); }
.brand img { border-radius: 7px; }
#settings-btn { text-decoration: none; }
#settings-btn.on { border-color: var(--accent); color: var(--accent); }
.topbar h1 { font-size: 16px; font-weight: 600; color: var(--ink-soft); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); max-width: 1180px; margin: 0 auto; }
#nav { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); height: calc(100dvh - 56px); overflow-y: auto; padding: 14px 10px 40px; }
#nav a { display: block; padding: 7px 12px; border-radius: 9px; color: var(--ink-soft); font-size: 14px; }
#nav a:hover { background: var(--panel-2); text-decoration: none; }
#nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-version { font-size: 11px; color: var(--muted); padding: 18px 12px 0; }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 4px; }
#menu-btn { display: none; }
#scrim { display: none; }
main { padding: 8px 16px 80px; min-width: 0; }
main:focus { outline: none; }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  #menu-btn { display: inline-flex; }
  /* The drawer is pinned to the visible screen and scrolls on its own. It uses
     top/bottom 0 rather than 100vh, which runs under Safari's toolbar on iPhone.
     align-self must be reset: the desktop 'start' makes a fixed box grow to
     its content height instead of stopping at the bottom of the screen. */
  #nav { position: fixed; top: 0; left: 0; bottom: 0; align-self: stretch; width: min(280px, 85vw); height: auto; max-height: none; z-index: 40; background: var(--panel); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s ease; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  #nav a { padding: 10px 12px; font-size: 15px; }
  body.nav-open #nav { transform: none; }
  body.nav-open { overflow: hidden; }
  body.nav-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .brand span { display: none; }
}

/* -------------------------------- panels --------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 14px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; font-weight: 650; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note { font-size: 13px; color: var(--muted); margin-top: 12px; }
.note.warn { color: var(--warn); }
.note.bad { color: var(--bad); }
.note.good { color: var(--good, inherit); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.big { font-size: 18px; margin: 4px 0; }
.hero ol { margin: 10px 0 14px 20px; color: var(--ink-soft); }
.hero p { color: var(--ink-soft); }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.plain { list-style: none; display: grid; gap: 8px; }
.plain li[data-edit] { cursor: pointer; }

/* -------------------------------- buttons -------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 13px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.link { background: none; border: none; color: var(--accent); padding-left: 4px; padding-right: 4px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font-size: 17px; cursor: pointer; }
.icon-btn.sm { width: 22px; height: 22px; font-size: 11px; border-radius: 50%; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 44px; z-index: 5; display: grid; gap: 6px; padding: 8px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.seg button { font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink-soft); cursor: pointer; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* -------------------------------- pills ---------------------------------- */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* -------------------------------- stats ---------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stats > a { color: inherit; }
.stats > a:hover { text-decoration: none; }
.stats > a:hover .stat { border-color: var(--accent); }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; height: 100%; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.good .stat-value { color: var(--good); }
.stat.warn .stat-value { color: var(--warn); }
.stat.bad .stat-value { color: var(--bad); }
.stat.accent { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }

/* -------------------------------- tables --------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr[data-edit] { cursor: pointer; }
.tbl tr[data-edit]:hover td { background: var(--panel-2); }
.tbl tr.hl td, .tbl th.hl { background: var(--accent-soft); }
.tbl tr.total td { font-weight: 700; border-top: 1px solid var(--line-2); }
.tbl.compact td, .tbl.compact th { padding: 5px 6px; font-size: 13px; }
.lines summary { cursor: pointer; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--accent); }

/* -------------------------------- charts --------------------------------- */
.bars { width: 100%; height: 150px; display: block; margin-top: 16px; }
.bar { fill: var(--bar); }
.bar.low { fill: var(--bar-low); }
.bar-ref { fill: var(--bar-ref); opacity: .55; }
.bar-labels { display: flex; font-size: 11px; color: var(--muted); }
.bar-labels span { flex: 1; text-align: center; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.sw { display: inline-block; width: 12px; height: 10px; border-radius: 2px; }
.sw.bar { background: var(--bar); }
.sw.ref { background: var(--bar-ref); height: 2px; opacity: .55; margin-left: 10px; }
.gauge { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 4px 0; }
.gauge span, .progress span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0 10px; }

/* --------------------------------- cards --------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
.card.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.card.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.card-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-head small { color: var(--muted); }
.card-body { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; flex: 1; }
.card-foot { display: flex; gap: 6px; flex-wrap: wrap; }
.contract, .dove-field { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.contract:first-of-type, .dove-field:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }

/* --------------------------- alerts / lists ------------------------------ */
.alerts { list-style: none; display: grid; gap: 6px; }
.alerts li { border-left: 4px solid var(--muted); background: var(--panel-2); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.alerts li a { color: var(--ink); display: block; }
.alerts li.bad { border-color: var(--bad); }
.alerts li.warn { border-color: var(--warn); }
.alerts li.info { border-color: var(--accent); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.quick .btn { min-height: 48px; justify-content: flex-start; }
.timeline { list-style: none; margin: 10px 0; border-left: 2px solid var(--line-2); padding-left: 14px; display: grid; gap: 6px; font-size: 14px; }
.timeline li span { display: inline-block; min-width: 110px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline li.past { opacity: .55; }
.advice { font-size: 13.5px; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; margin: 6px 0 8px; display: grid; gap: 4px; }
.ok-t { color: var(--good); }
.warn-t { color: var(--warn); }
.steps { margin: 6px 0 12px 20px; display: grid; gap: 6px; font-size: 14px; }
.checklist { list-style: none; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.checklist input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.tasks { list-style: none; display: grid; gap: 6px; }
.tasks li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.tasks label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.tasks input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.practices { display: grid; gap: 8px; }
.practice { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.practice.met { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: var(--good-soft); }
.practice-head { display: flex; align-items: center; gap: 8px; }
.practice-head b { flex: 1; }
.tick { font-weight: 700; color: var(--good); width: 16px; }
.practice ul { margin: 6px 0 0 24px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { font: inherit; font-size: 13px; padding: 4px 11px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink-soft); cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { cursor: pointer; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: var(--panel-2); display: block; }
.gallery figcaption { font-size: 12.5px; margin-top: 4px; }
.ai-label { color: var(--accent); }
.quick-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.quick-tags .chip { font-size: 12px; padding: 3px 9px; }
.layer-toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; font-size: 13px; }
.layer-toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leaflet-host { height: 62vh; min-height: 320px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); margin: 10px 0; }
.leaflet-host .leaflet-control-attribution { font-size: 9px; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.map-tools .inline select { max-width: 190px; }
.map-panel .head-actions select { width: auto; min-height: 38px; padding: 6px 8px; font-size: 14px; }
.map-status { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.map-status-actions { display: flex; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
.leaflet-tooltip.map-label { background: rgba(0,0,0,.55); color: #fff; border: 0; box-shadow: none; font-weight: 600; }
.leaflet-tooltip.map-label::before { display: none; }
.ranch-map { width: 100%; height: auto; max-height: 70vh; background: var(--panel-2); border-radius: 12px; border: 1px solid var(--line); }
.ranch-map .boundary { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3; }
.ranch-map .pin { cursor: pointer; }
.ranch-map .pin circle { stroke: var(--panel); stroke-width: 3; }
.ranch-map text { font-size: 28px; fill: var(--ink); paint-order: stroke; stroke: var(--panel-2); stroke-width: 5px; }
.relay-out { margin-top: 12px; padding: 10px; background: var(--panel-2); border-radius: 10px; overflow-x: auto; white-space: pre-wrap; }
.btn[disabled] { opacity: .5; cursor: default; }
.normals { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.normals label { font-size: 12px; color: var(--muted); display: grid; gap: 3px; }

/* --------------------------------- forms --------------------------------- */
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px; width: 100%; min-height: 40px; }
input[type=checkbox] { width: auto; min-height: 0; }
textarea { resize: vertical; }
.inline select { width: auto; font-size: 14px; min-height: 34px; padding: 4px 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field.wide { grid-column: 1 / -1; }
.field.check label, .field.check > span { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.help { font-weight: 400; color: var(--muted); font-size: 12px; }
.req { color: var(--bad); }
.loc-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px; }
@media (max-width: 420px) { .loc-row { grid-template-columns: 1fr 1fr; } }
dialog.map-sheet { max-width: 900px; }
.map-sheet .sheet-form { height: 92vh; height: 92dvh; max-height: none; }
.pin-body { grid-template-columns: 1fr; }
.pin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pin-grid .btn { justify-content: flex-start; min-height: 46px; white-space: normal; text-align: left; }
.map-pick { flex: 1; min-height: 240px; }
.map-sheet .sheet-foot { flex-wrap: wrap; align-items: center; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.thumb-wrap { position: relative; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: block; background: var(--panel-2); }
.thumb-wrap .icon-btn { position: absolute; top: -6px; right: -6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; max-height: 40vh; overflow-y: auto; font-weight: 500; }
.checks label { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

/* the record form: a bottom sheet on phones, a dialog on desktop */
dialog.sheet { border: none; padding: 0; background: transparent; max-width: 640px; width: 100%; margin: auto; max-height: 100vh; color: var(--ink); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-form { background: var(--panel); border-radius: 16px; display: flex; flex-direction: column; max-height: 92vh; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 17px; }
.sheet-body { padding: 16px 18px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  dialog.sheet { margin: auto 0 0 0; max-width: none; }
  .sheet-form { border-radius: 16px 16px 0 0; max-height: 94vh; }
  .sheet-body { grid-template-columns: 1fr; }
}

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; transition: opacity .4s; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.toast.out { opacity: 0; }

/* -------------------------------- packet --------------------------------- */
.packet-bar { display: flex; gap: 8px; margin-top: 14px; }
.packet { background: #fff; color: #111; max-width: 820px; margin: 14px auto; padding: 48px 56px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13.5px; }
.packet h1 { font-size: 28px; margin: 6px 0 18px; }
.packet h2 { font-size: 16px; margin: 28px 0 10px; padding-bottom: 4px; border-bottom: 2px solid #2F3A2B; break-after: avoid; }
.packet h3 { color: #333; }
.packet p { margin: 8px 0; }
.packet ul { margin: 6px 0 6px 20px; }
.packet .tbl { font-size: 12.5px; }
.packet .tbl th { color: #555; border-color: #bbb; }
.packet .tbl td { border-color: #ddd; }
.packet .tbl tr { break-inside: avoid; }
.packet-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #4F6B35; }
.kv { border-collapse: collapse; }
.kv th { text-align: left; font-weight: 600; color: #555; padding: 4px 18px 4px 0; vertical-align: top; }
.kv td { padding: 4px 0; }
.packet-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.packet-photos figure { break-inside: avoid; }
.packet-photos img { width: 100%; border: 1px solid #ccc; }
.packet-photos figcaption { font-size: 11px; color: #555; }
.attest { margin-top: 40px; break-inside: avoid; }
.sig { display: grid; grid-template-columns: 2fr 1fr; gap: 40px; margin-top: 40px; }
.sig span { border-top: 1px solid #333; padding-top: 4px; font-size: 12px; color: #555; }
.packet .muted { color: #777; }
@media (max-width: 640px) { .packet { padding: 24px 18px; } }

@media print {
  .noprint, .packet-bar, #nav, .topbar { display: none !important; }
  body, .layout, main { background: #fff !important; display: block; padding: 0; margin: 0; }
  .packet { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .packet h2 { margin-top: 22px; }
  @page { margin: 0.7in; }
}

/* Brush density from a photo */
.scan-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.scan-top { display: flex; gap: 12px; align-items: flex-start; }
.scan-thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--line); flex: none; }
.scan-species { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.scan-species li { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.btn.scan-use { padding: 4px 10px; font-size: 13px; white-space: nowrap; }

/* Fishing outlook */
.fish-factors { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.fish-factors li { display: flex; gap: 10px; align-items: baseline; }
.fish-pts { flex: none; width: 40px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.good-t { color: var(--good); }
#fishing { scroll-margin-top: 72px; }

/* Photo log filter bar */
.photo-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.photo-filter span { flex: 1 1 100%; }
a.chip { display: inline-block; text-decoration: none; }

/* Full-screen photo viewer */
dialog.viewer { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; color: #fff; overflow: hidden; }
dialog.viewer::backdrop { background: #000; }
.v-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: zoom-in; }
.viewer.zoomed .v-stage { cursor: grab; }
.v-stage img { max-width: 100%; max-height: 100%; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; will-change: transform; transform-origin: center center; }
.v-top, .v-bottom { position: absolute; left: 0; right: 0; z-index: 2; padding: 10px 14px; transition: opacity .2s; }
.v-top { top: 0; padding-top: calc(env(safe-area-inset-top) + 10px); display: flex; gap: 12px; align-items: flex-start; background: linear-gradient(rgba(0,0,0,.75), rgba(0,0,0,0)); }
.v-cap { flex: 1; font-size: 14px; line-height: 1.35; }
.v-cap small { opacity: .8; }
.v-bottom { bottom: 0; padding-bottom: calc(env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; gap: 8px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.85) 30%); padding-top: 28px; }
.v-ai { font-size: 13px; line-height: 1.4; }
.v-ai small { opacity: .75; }
.v-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.v-tag { font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 16px; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.08); color: #fff; }
.v-tag.on { background: #fff; color: #000; border-color: #fff; font-weight: 600; }
.v-actions { display: flex; gap: 10px; align-items: center; }
.v-count, .v-hd { font-size: 12px; opacity: .75; }
.v-count { flex: 1; }
.v-btn { font: inherit; font-size: 14px; color: #fff; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); border-radius: 10px; padding: 7px 12px; text-decoration: none; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; font-size: 40px; line-height: 1; color: #fff; background: rgba(0,0,0,.35); border: 0; border-radius: 50%; width: 52px; height: 52px; cursor: pointer; transition: opacity .2s; }
.v-prev { left: 10px; } .v-next { right: 10px; }
@media (hover: none) { .v-nav { display: none; } }
.viewer.bare .v-top, .viewer.bare .v-bottom, .viewer.bare .v-nav, .viewer.zoomed .v-nav { opacity: 0; pointer-events: none; }
.gallery figure img { cursor: zoom-in; }

/* Person/vehicle camera alerts */
.alerts li.cam-alert { display: flex; gap: 10px; align-items: flex-start; }
.cam-alert-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--line); flex: none; cursor: zoom-in; }
.cam-alert-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip.ok-chip { background: var(--good); border-color: var(--good); color: #fff; font-weight: 600; }
.v-ok { font: inherit; font-size: 16px; font-weight: 700; padding: 11px 14px; border-radius: 12px; border: 0; background: #2F9E55; color: #fff; }

/* Hunting outlook */
.hunt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.hunt-card summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.hunt-card summary::-webkit-details-marker { display: none; }
.hunt-top { display: flex; align-items: center; gap: 8px; }
.hunt-icon { font-size: 22px; }
.hunt-score { margin-left: auto; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.hunt-card.closed { opacity: .72; }
.hunt-card.excellent, .hunt-card.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.hunt-card.unsafe { border-color: var(--bad); }

/* Buck ID in the viewer */
.v-buck { font-size: 13px; line-height: 1.45; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid rgba(255,255,255,.2); padding-top: 8px; }
.v-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.v-link { font: inherit; font-size: 12px; color: #fff; background: none; border: 0; text-decoration: underline; padding: 0 4px; opacity: .85; }

/* Buck tracker */
.buck-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--line); flex: none; cursor: zoom-in; }
.empty-thumb { display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: default; }
.buck-card { text-decoration: none; color: inherit; }
.buck-card.harvested, .buck-card.gone { opacity: .6; }
.buck-card-top { display: flex; gap: 10px; align-items: center; }
.buck-review { display: flex; flex-direction: column; gap: 10px; }
.buck-review li { display: flex; gap: 10px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 10px; }
.buck-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.buck-gallery figure { margin: 0; }
.buck-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--line); cursor: zoom-in; display: block; }
.hour-chart { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 90px; align-items: end; margin-bottom: 18px; }
.hour-bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.hour-bar span { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.hour-bar small { position: absolute; top: 100%; left: 0; font-size: 10px; white-space: nowrap; color: var(--muted); }
.alerts li.info { border-color: var(--good); }

/* Hunting planner */
.best-sits { margin: 6px 0 12px; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.plan-day { border-top: 1px solid var(--line); padding: 8px 0; }
.plan-date { margin-bottom: 4px; }
.plan-sit summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; }
.plan-sit summary::-webkit-details-marker { display: none; }
.plan-sit summary > div { flex-basis: 100%; }
.plan-session { width: 56px; font-weight: 600; }
.plan-sit.closed { opacity: .7; }
.cam-act li { margin: 6px 0 10px; }
.mini-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 1px; height: 26px; align-items: end; margin-top: 4px; background: linear-gradient(to right, var(--line) 0 25%, transparent 25% 75%, var(--line) 75%); background-size: 100% 1px; background-repeat: no-repeat; background-position: bottom; }
.mini-hours span { display: block; background: var(--accent); min-height: 1px; border-radius: 1px 1px 0 0; }
tr.best-row td { font-weight: 700; }
.seg { flex-wrap: wrap; }

/* Census: tappable numbers */
.stat-btn { font: inherit; color: inherit; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; display: block; }
.stat-btn:disabled { cursor: default; }
.stat-btn:not(:disabled) .stat { box-shadow: inset 0 0 0 1px var(--accent); }
.stat-btn:not(:disabled) .stat::after { content: 'tap to see photos ›'; display: block; font-size: 11px; color: var(--accent); margin-top: 4px; }
.census-chips { margin-bottom: 6px; }
.chip.warn-chip { border-color: var(--warn); color: var(--warn); }
.v-census { font-size: 13px; line-height: 1.45; border-top: 1px solid rgba(255,255,255,.2); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.v-cnt { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.v-cnt button { font: inherit; width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.08); color: #fff; }
.v-cnt b { min-width: 14px; text-align: center; }

/* Camera census layout */
.csec { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.csec:first-of-type { border-top: 0; }
.csec-title { font-weight: 700; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.census-setup { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.census-setup .field { min-width: 0; }
.census-setup input, .census-setup select { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
.census-setup label:last-child { grid-column: 1 / -1; }
.review-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.review-progress, .cr-progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.review-progress span, .cr-progress span { display: block; height: 100%; background: var(--good); border-radius: 4px; }
.review-go { font-size: 16px; padding: 12px; }
.cres-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cres { font: inherit; color: inherit; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
button.cres:not(:disabled) { cursor: pointer; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.cres-label { font-size: 12px; color: var(--muted); }
.cres-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.cres-sub { font-size: 12px; color: var(--muted); }
.cres-go { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 4px; }
.cres.total { background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); }
.cres-ratios { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; margin: 10px 0 6px; }

/* Census review (one visit at a time) */
dialog.creview { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg, #f6f3ec); color: var(--ink); display: flex; flex-direction: column; overflow: hidden; }
dialog.creview:not([open]) { display: none; }
dialog.creview::backdrop { background: rgba(0,0,0,.6); }
.cr-head { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 12px 6px; }
.cr-x { font-size: 20px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: inherit; flex: none; }
.cr-title { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cr-title small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-head select { max-width: 42%; font: inherit; font-size: 13px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: inherit; }
.cr-progress { margin: 0 12px; }
.cr-progress-label { font-size: 11px; color: var(--muted); padding: 2px 12px 6px; }
.cr-photo { position: relative; background: #000; flex: 1 1 auto; min-height: 180px; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.cr-photo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cr-zoom { position: absolute; right: 8px; top: 8px; font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 16px; border: 0; background: rgba(0,0,0,.55); color: #fff; }
.cr-badge { position: absolute; left: 8px; bottom: 8px; font-size: 12px; padding: 4px 10px; border-radius: 12px; background: rgba(0,0,0,.6); color: #fff; }
.cr-badge.ok { background: var(--good); }
.cr-strip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px; background: #111; flex: none; }
.cr-thumb { flex: none; border: 2px solid transparent; border-radius: 6px; padding: 0; background: none; color: #ccc; display: flex; flex-direction: column; align-items: center; font: inherit; }
.cr-thumb img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; display: block; background: #333; }
.cr-thumb small { font-size: 10px; }
.cr-thumb.on { border-color: #fff; }
.cr-panel { flex: none; padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.cr-q { font-size: 13px; font-weight: 600; }
.cr-q small { font-weight: 400; color: var(--muted); }
.cr-counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cr-counter { border: 1px solid var(--line); border-radius: 12px; padding: 6px 4px; text-align: center; background: var(--panel); min-width: 0; }
.cr-counter.has { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.cr-counter-label { font-size: 12px; color: var(--muted); }
.cr-counter-row { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.cr-counter-row b { font-size: 24px; min-width: 20px; }
.cr-counter-row button { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 1px solid var(--line-2, var(--line)); background: var(--panel-2); color: inherit; font-size: 22px; line-height: 1; }
.cr-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.cr-quick button { flex: none; font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: inherit; }
.cr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-chip { font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); color: inherit; }
.cr-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); font-weight: 600; }
.cr-chip.ai { border-style: dashed; border-color: var(--accent); }
.cr-foot { flex: none; display: flex; gap: 8px; padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); border-top: 1px solid var(--line); background: var(--panel); }
.cr-foot .btn { padding: 12px 14px; font-size: 15px; }
.cr-ok { flex: 1; font-weight: 700; }
.cr-done { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 20px; }
.cr-done .cr-foot { border: 0; background: none; }
.cr-done-icon { font-size: 48px; width: 80px; height: 80px; border-radius: 50%; background: var(--good); color: #fff; display: flex; align-items: center; justify-content: center; }

/* Auto-sort */
.auto-check { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; background: var(--panel-2); border: 1px dashed var(--warn); border-radius: 10px; padding: 10px; margin-top: 6px; }
.auto-banner { border: 1px dashed var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--panel)); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.merge-row { display: flex; gap: 6px; }
.merge-row select { flex: 1; min-width: 0; font: inherit; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: inherit; }
.buck-gallery figure.is-auto img { outline: 2px dashed var(--warn); outline-offset: -2px; }

/* Buck tracker v2 */
.bt-top { display: flex; flex-direction: column; gap: 10px; }
.bt-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.bt-stat { font: inherit; color: inherit; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.bt-stat b { font-size: 22px; line-height: 1.1; }
.bt-stat span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bt-stat.warn:not(:disabled) { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--panel-2)); }
.bt-stat:disabled { opacity: .55; cursor: default; }
.bt-actions, .bt-row { display: flex; flex-wrap: wrap; gap: 6px; }
.bt-actions:empty { display: none; }
.bt-how summary { color: var(--muted); }
.bt-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; margin-bottom: 8px; }
.bt-filters .chip { flex: none; }
.bt-dedupe-row { margin-bottom: 10px; }
.bt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bt-tile { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel-2); color: inherit; text-decoration: none; min-width: 0; }
.bt-tile.auto { border-style: dashed; border-color: var(--warn); }
.bt-tile.harvested, .bt-tile.gone { opacity: .6; }
.bt-tile-img { position: relative; aspect-ratio: 4 / 3; background: var(--line); }
.bt-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bt-img.empty-thumb { display: flex; align-items: center; justify-content: center; font-size: 32px; }
.bt-flag { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.62); color: #fff; }
.bt-sun { position: absolute; right: 6px; top: 6px; font-size: 14px; background: rgba(0,0,0,.45); border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.bt-tile-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.bt-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-dupes { border: 1px solid var(--warn); border-radius: 12px; padding: 10px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 12px; background: color-mix(in srgb, var(--warn) 6%, var(--panel)); }
.bt-dupe { display: flex; flex-direction: column; gap: 6px; }
.bt-dupe + .bt-dupe { border-top: 1px solid var(--line); padding-top: 12px; }
.bt-dupe-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.bt-dupe-pair figure { margin: 0; min-width: 0; }
.bt-dupe-img { width: 100%; height: 78px; object-fit: cover; border-radius: 8px; display: block; background: var(--line); cursor: zoom-in; }
.bt-dupe-pair figcaption { display: flex; flex-direction: column; font-size: 13px; margin-top: 2px; min-width: 0; }
.bt-dupe-pair figcaption b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-dupe-pair figcaption small { color: var(--muted); }
.bt-dupe-arrow { font-size: 20px; color: var(--muted); }
.bt-dupes-none { margin: 0 0 10px; }

/* Buck detail */
.bd { display: flex; flex-direction: column; gap: 8px; }
.bd-back { text-decoration: none; }
.bd-hero { position: relative; border-radius: 12px; overflow: hidden; background: var(--line); }
.bd-hero-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; cursor: zoom-in; }
.bd-hero-img.empty-thumb { display: flex; align-items: center; justify-content: center; font-size: 48px; }
.bd-count { position: absolute; right: 8px; bottom: 8px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; background: rgba(0,0,0,.6); color: #fff; pointer-events: none; }
.bd-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bd-head h2 { margin: 0; flex: 1 1 auto; min-width: 0; }
.bd-marks { margin: 0; color: var(--muted); }
.bd-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.bd-stats div { display: flex; flex-direction: column; align-items: center; padding: 8px 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.bd-stats b { font-size: 18px; line-height: 1.2; white-space: nowrap; }
.bd-stats span { font-size: 11px; color: var(--muted); }
.bd-stats .good b { color: var(--good); }
.bd-last { margin: 0; }
.auto-banner .head-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.auto-banner .head-actions .btn { width: 100%; }

/* Viewer: folded tag/buck pickers */
.v-sum { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.v-sum > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-dim { opacity: .65; }
.v-sum-btn { flex: none; font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.1); color: #fff; }
.v-tags { display: flex; flex-direction: column; gap: 6px; }

/* Compare two bucks */
.bt-dupe-pair figure { cursor: pointer; }
dialog.bcmp { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0d0f0c; color: #fff; display: flex; flex-direction: column; overflow: hidden; }
dialog.bcmp:not([open]) { display: none; }
.bcmp-head { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 12px 6px; }
.bcmp-x { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; font-size: 18px; }
.bcmp-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.bcmp-title small { opacity: .75; font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bcmp-panes { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: 1fr 1fr; gap: 6px; padding: 0 8px; }
@media (min-aspect-ratio: 1/1) { .bcmp-panes { grid-template-rows: none; grid-template-columns: 1fr 1fr; } }
.bcmp-pane { min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.bcmp-label { flex: none; display: flex; align-items: baseline; gap: 6px; font-size: 14px; }
.bcmp-label small { margin-left: auto; opacity: .7; font-size: 12px; }
.bcmp-photo { position: relative; flex: 1 1 auto; min-height: 0; background: #000; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.bcmp-photo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.bcmp-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 24px; line-height: 1; }
.bcmp-nav.prev { left: 6px; } .bcmp-nav.next { right: 6px; }
.bcmp-nav:disabled { opacity: .25; }
.bcmp-zoom { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 14px; }
.bcmp-when { position: absolute; left: 6px; bottom: 6px; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.55); }
.bcmp-auto { font-size: 12px; }
.bcmp-strip { flex: none; display: flex; gap: 4px; overflow-x: auto; }
.bcmp-thumb { flex: none; padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; }
.bcmp-thumb img { width: 52px; height: 39px; object-fit: cover; border-radius: 4px; display: block; background: #333; }
.bcmp-thumb.on { border-color: #fff; }
.bcmp-foot { flex: none; display: flex; gap: 8px; padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); }
.bcmp-foot .btn { flex: 1; padding: 12px; font-size: 15px; }
.merge-row { flex-wrap: wrap; }

/* Who's who outlines */
.spots { position: absolute; pointer-events: none; transform-origin: center center; }
.spot { position: absolute; border: 2px solid var(--c, #F59E0B); border-radius: 6px; box-shadow: 0 0 0 1px rgba(0,0,0,.45); }
.spot span { position: absolute; left: -2px; top: -1.6em; font-size: 12px; font-weight: 700; line-height: 1.3; padding: 1px 6px; border-radius: 4px; background: var(--c, #F59E0B); color: #111; white-space: nowrap; }
.spot.low span { top: auto; bottom: -1.6em; }

.v-places { display: flex; flex-direction: column; gap: 4px; }
.v-place { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.v-place b { min-width: 70px; font-size: 13px; }
.v-place .v-tag { padding: 3px 9px; font-size: 12px; }

.bcmp-which { position: absolute; left: 6px; top: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 10px; background: #F59E0B; color: #111; max-width: calc(100% - 50px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-photo { position: relative; }

/* Start over */
.so summary { list-style: none; cursor: pointer; }
.so summary::-webkit-details-marker { display: none; }
.so summary h2 { margin: 0; font-size: 17px; }
.so[open] summary { margin-bottom: 8px; }
.so-opts { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.so-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.so-opt input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.so-opt span { display: flex; flex-direction: column; gap: 2px; }
.so-opt small { color: var(--muted); font-size: 12px; }
.so-opt:has(input:disabled:not(:checked)) { opacity: .55; }
.so-preview { font-size: 14px; background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border-radius: 10px; padding: 10px; }
.so .btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Placing a box by tapping */
dialog.viewer.moving .v-stage { cursor: crosshair; outline: 3px dashed #F59E0B; outline-offset: -3px; }
dialog.viewer.moving::after { content: attr(data-hint); position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 64px); transform: translateX(-50%); background: #F59E0B; color: #111; font-weight: 700; font-size: 14px; padding: 6px 14px; border-radius: 16px; z-index: 5; pointer-events: none; }
.bcmp-fix { position: absolute; right: 44px; top: 6px; font: inherit; font-size: 12px; padding: 5px 10px; border-radius: 14px; border: 0; background: rgba(0,0,0,.55); color: #fff; }
.bcmp-fix.on { background: #F59E0B; color: #111; font-weight: 700; }

/* Boxes on/off */
.no-spots .spots { display: none; }
.box-toggle { font: inherit; white-space: nowrap; }
.v-top .box-toggle { flex: none; }
.bcmp-boxes, .cr-boxes { position: absolute; font-size: 12px; padding: 5px 10px; border-radius: 14px; border: 0; background: rgba(0,0,0,.55); color: #fff; z-index: 1; }
.bcmp-boxes { right: 6px; bottom: 6px; }
.cr-boxes { left: 8px; top: 8px; }

/* Viewer paging on phones: ‹ 3 / 12 › by the counter, and swipes on the panels */
.v-top, .v-bottom { touch-action: pan-y; }
.v-pager { display: inline-flex; align-items: center; gap: 2px; flex: 1; }
.v-pager[hidden] + .v-hd { flex: 1; }
.v-pager[hidden] { display: none; }
.v-step { font: inherit; font-size: 26px; line-height: 1; width: 44px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.14); color: #fff; }
.v-step:disabled { opacity: .3; }
.v-pager .v-count { flex: none; min-width: 3.5em; text-align: center; }

/* The AI's suggested buck: dashed until you say yes */
.spot.guess { border-style: dashed; }
.spot.guess span { opacity: .9; }

/* Buck tracker: sort order and sizes */
.bt-order { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 8px; }
.bt-order .chip { padding-left: 10px; padding-right: 10px; }
.bt-order .chip { flex: none; }
.bt-size-note { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bt-meta.bt-size { color: var(--text, inherit); font-weight: 600; white-space: normal; line-height: 1.3; }
.bd-size { margin: 4px 0 8px; }
