:root {
  color-scheme: light;
  --ink: #18222c;
  --muted: #63707b;
  --line: #d8e0e5;
  --paper: #f6f8f9;
  --surface: #ffffff;
  --accent: #0b6573;
  --accent-dark: #064653;
  --accent-soft: #e1f0f2;
  --photo: #17644f;
  --photo-soft: #e0f1eb;
  --reported: #825f16;
  --reported-soft: #fff4d5;
  --uncertain: #7c3340;
  --uncertain-soft: #fce8ec;
  --shadow: 0 12px 30px rgba(24, 34, 44, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.5; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }
.site-header { padding: 3.5rem 0 3rem; color: #fff; background: linear-gradient(135deg, #073d4b, #0b6573); }
.eyebrow { margin: 0 0 .35rem; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.site-header .eyebrow { color: #9ed8dc; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 14ch; margin-bottom: .8rem; font-size: clamp(2.35rem, 6vw, 4.75rem); line-height: .98; letter-spacing: -.055em; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 3vw, 1.9rem); letter-spacing: -.025em; }
.lede { max-width: 44rem; margin-bottom: .8rem; color: #e2f4f4; font-size: 1.1rem; }
.updated { margin: 0; color: #b9e1e2; font-size: .9rem; }
main { padding: 2.25rem 0 4rem; }
.controls, .stats, .inventory-section, .legend { margin-bottom: 2.5rem; }
.section-heading { margin-bottom: 1rem; }
.section-heading.compact { margin-bottom: .75rem; }
.row-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.control-grid { display: grid; gap: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.field { display: grid; gap: .35rem; color: var(--muted); font-size: .85rem; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 2.8rem; padding: .6rem .75rem; border: 1px solid #b9c6cd; border-radius: .55rem; color: var(--ink); background: #fff; }
.field input:focus, .field select:focus, button:focus-visible { outline: 3px solid #80cbd0; outline-offset: 2px; }
.field small { font-weight: 400; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.stat-card { display: grid; gap: .15rem; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); }
.stat-value { font-size: 1.75rem; line-height: 1; }
.stat-label { color: var(--muted); font-size: .85rem; }
.result-count { margin: 0; color: var(--muted); font-size: .9rem; }
.box-grid { display: grid; gap: 1rem; }
.box-card { overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.box-cover { width: 100%; height: 12rem; object-fit: cover; background: #dce7e9; }
.box-card-body { padding: 1rem; }
.box-card-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .65rem; }
.box-id { color: var(--accent-dark); font-size: 1.25rem; font-weight: 900; letter-spacing: .03em; }
.box-category, .box-meta, .dialog-category { color: var(--muted); font-size: .85rem; }
.box-title { min-height: 3.1em; margin-bottom: .65rem; font-size: 1.05rem; line-height: 1.35; }
.box-meta { margin-bottom: .8rem; }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.badge, .confidence { display: inline-flex; align-items: center; width: fit-content; padding: .28rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 800; line-height: 1.1; }
.status-partial { color: #73520d; background: #fff1c2; }
.status-reviewed { color: #155b4a; background: #d9f0e8; }
.status-needs-photo { color: #7c3340; background: #fce8ec; }
.confidence-photo { color: var(--photo); background: var(--photo-soft); }
.confidence-reported { color: var(--reported); background: var(--reported-soft); }
.confidence-uncertain { color: var(--uncertain); background: var(--uncertain-soft); }
.button { min-height: 2.65rem; padding: .55rem .85rem; border: 1px solid transparent; border-radius: .55rem; font-weight: 800; }
.button-secondary { color: var(--accent-dark); border-color: #9cc8cc; background: var(--accent-soft); }
.button-secondary:hover { background: #cce5e7; }
.box-card .button { width: 100%; margin-top: 1rem; }
.empty-state { padding: 2rem; border: 1px dashed #a9bac0; border-radius: .8rem; color: var(--muted); text-align: center; }
.legend { padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.legend-list { display: grid; gap: .65rem; padding: 0; margin: 0; list-style: none; }
.legend-list li { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-size: .9rem; }

#detail-dialog { width: min(860px, calc(100% - 1.25rem)); max-height: calc(100% - 1.25rem); padding: 0; border: 0; border-radius: 1rem; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); }
#detail-dialog::backdrop { background: rgba(5, 28, 35, .7); }
.dialog-shell { padding: 1rem; overflow: auto; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.dialog-header h2 { margin: 0; }
.icon-button { display: grid; width: 2.6rem; height: 2.6rem; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--paper); font-size: 1.5rem; line-height: 1; }
.dialog-intro { padding: .9rem; margin-bottom: 1.25rem; border-radius: .75rem; background: var(--paper); }
.dialog-category, .dialog-summary { margin-bottom: .5rem; }
.dialog-summary { color: var(--ink); font-size: 1.1rem; }
.subheading { margin-bottom: .7rem; font-size: 1.05rem; }
.gallery { margin-bottom: 1.5rem; }
.gallery-main { margin: 0; border: 1px solid var(--line); border-radius: .75rem; overflow: hidden; background: #eef3f4; }
.gallery-image { width: 100%; max-height: 55vh; object-fit: contain; background: #e5edef; }
.gallery-caption { padding: .6rem .75rem; color: var(--muted); font-size: .8rem; }
.gallery-navigation { display: flex; gap: .6rem; margin: .7rem 0; }
.gallery-navigation .button { flex: 1; }
.gallery-navigation .button:disabled { cursor: not-allowed; opacity: .45; }
.thumbnails { display: flex; gap: .55rem; overflow-x: auto; padding: .15rem; margin: 0; list-style: none; }
.thumbnails > li { flex: 0 0 4.5rem; }
.thumbnail { width: 100%; padding: .2rem; border: 2px solid transparent; border-radius: .5rem; background: transparent; }
.thumbnail.is-selected { border-color: var(--accent); }
.thumbnail img { width: 4rem; height: 3.3rem; object-fit: cover; border-radius: .3rem; }
.item-list, .notes-list { display: grid; gap: .7rem; padding: 0; margin: 0; list-style: none; }
.item-row { padding: .8rem; border: 1px solid var(--line); border-radius: .65rem; }
.item-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.item-name { line-height: 1.35; }
.item-quantity, .item-note { margin: .35rem 0 0; color: var(--muted); font-size: .85rem; }
.notes-heading { margin-top: 1.35rem; }
.fatal-error { width: min(36rem, calc(100% - 2rem)); margin: 4rem auto; padding: 1.5rem; border: 2px solid #a94755; border-radius: .8rem; color: #7c3340; background: #fce8ec; font-weight: 800; }

@media (min-width: 600px) {
  .shell { width: min(1120px, calc(100% - 3rem)); }
  .control-grid { grid-template-columns: 2fr 1fr 1fr; align-items: start; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .box-grid { grid-template-columns: repeat(2, 1fr); }
  .box-cover { height: 14rem; }
  .dialog-shell { padding: 1.5rem; }
}

@media (min-width: 900px) {
  .site-header { padding: 5rem 0 4.5rem; }
  .box-grid { grid-template-columns: repeat(3, 1fr); }
  .box-cover { height: 15rem; }
}
