:root {
  color-scheme: dark;
  --bg: #111720;
  --panel: #19212c;
  --line: #2e3948;
  --text: #f0f3f8;
  --muted: #a4afbe;
  --accent: #c9ef81;
  --canvas: #0c1118;
  font: 16px/1.5 "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.masthead { border-bottom: 1px solid var(--line); background: #141b25; }
.mast-inner, main { width: min(1540px, 100%); margin: auto; padding-inline: clamp(16px, 3vw, 48px); }
.mast-inner { min-height: 70px; display: flex; align-items: center; gap: 12px; font-weight: 700; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: #172010;
  background: var(--accent);
}
.brand-mark i { width: 17px; height: 17px; border: 2px solid; border-radius: 5px; display: grid; place-items: center; }
.brand-mark i::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.engine { margin-left: auto; color: var(--muted); font-size: .875rem; font-weight: 500; }
main { padding-block: 36px 48px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 3.7vw, 3.05rem); line-height: 1.08; letter-spacing: -.045em; font-weight: 720; }
.intro p { margin-top: 10px; color: var(--muted); }
.mode-picker, .view-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--canvas);
}
.mode-picker button, .view-switch button {
  border: 0;
  border-radius: 6px;
  padding: 7px 12px;
  background: transparent;
  white-space: nowrap;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
}
.mode-picker button:hover, .view-switch button:hover { color: var(--text); }
.mode-picker button[aria-pressed="true"], .view-switch button[aria-pressed="true"] { background: #303e33; color: var(--accent); }
.workspace { display: grid; grid-template-columns: minmax(155px, .75fr) minmax(0, 3fr) minmax(220px, 1fr); align-items: start; gap: 16px; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.panel-heading {
  min-height: 60px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  border-bottom: 1px solid var(--line);
}
h2 { font-size: 1rem; letter-spacing: -.012em; }
.count { min-width: 27px; padding: 1px 5px; border-radius: 5px; background: #2a3442; color: var(--muted); font-size: .8125rem; text-align: center; }
.count:empty { display: none; }
.gallery { display: grid; gap: 10px; align-content: start; height: clamp(380px, 61vh, 630px); overflow: auto; padding: 12px; scrollbar-color: #465366 transparent; }
.gallery p { color: var(--muted); font-size: .875rem; }
.thumb { min-width: 0; display: block; width: 100%; padding: 4px; background: var(--canvas); border: 1px solid var(--line); border-radius: 9px; text-align: left; color: var(--muted); }
.thumb:hover { border-color: var(--muted); }
.thumb[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #26332a; }
.thumb img { width: 100%; aspect-ratio: 1.85; object-fit: cover; border-radius: 5px; display: block; }
.thumb span, .filename { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8125rem; }
.thumb span { padding: 4px 3px 1px; }
.viewer-label { min-width: 0; }
.filename { font-family: ui-monospace, monospace; color: var(--muted); }
.canvas {
  display: grid;
  place-items: center;
  height: clamp(340px, 56vh, 592px);
  padding: 14px;
  background: radial-gradient(ellipse at center, #202b39, var(--canvas) 77%);
  color: var(--muted);
  text-align: center;
}
.canvas img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.viewer-footer { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 16px; font-size: .8125rem; color: var(--muted); border-top: 1px solid var(--line); }
.trap-photo { padding: 12px 16px; border-top: 1px solid var(--line); }
.trap-photo summary {
  width: fit-content;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--accent);
  font-size: .875rem;
  font-weight: 650;
  cursor: pointer;
}
.trap-photo summary:hover { border-color: var(--accent); }
.trap-photo:not([open]) .trap-hide, .trap-photo[open] .trap-show { display: none; }
.trap-photo img { display: block; max-width: 100%; height: auto; margin: 12px auto 0; border-radius: 8px; }
.analysis { display: grid; gap: 16px; }
.panel-body { padding: 16px; }
.model-name { font-weight: 700; }
.muted { color: var(--muted); font-size: .875rem; }
.model-name + .muted { margin-top: 5px; }
.gender-option { display: flex; align-items: center; gap: 9px; margin-top: 16px; font-size: .875rem; cursor: pointer; }
.gender-option input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.run { width: 100%; display: flex; justify-content: center; align-items: center; gap: 9px; margin-top: 18px; border: 0; border-radius: 8px; padding: 11px 6px; color: #192411; background: var(--accent); font-weight: 750; font-size: .875rem; }
.run:hover:enabled { background: #dbffa0; }
.run-icon { width: 0; height: 0; border: 5px solid transparent; border-left: 8px solid currentColor; border-right: 0; }
.run[aria-busy="true"] .run-icon { width: 13px; height: 13px; border: 2px solid #53633a; border-top-color: transparent; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.results { margin: 10px 0 0; }
.results div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .875rem; }
.results dt { overflow-wrap: anywhere; }
.results dd { margin: 0; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.error { color: #ffb6a9; }
@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(150px, 1fr) minmax(0, 3fr); }
  .analysis { grid-column: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  main { padding-top: 26px; }
  .intro { align-items: start; flex-direction: column; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .gallery { display: flex; height: auto; }
  .thumb { flex: 0 0 125px; }
  .canvas { height: min(50vh, 440px); min-height: 220px; }
  .analysis { grid-column: 1; grid-template-columns: minmax(0, 1fr); }
  .viewer .panel-heading { flex-wrap: wrap; }
  .viewer-label { flex: 1 1 145px; }
}
@media (prefers-reduced-motion: reduce) {
  .run[aria-busy="true"] .run-icon { animation: none; }
}
