:root {
  --bg: #f5f8f4;
  --surface: #ffffff;
  --surface-soft: #eef7f0;
  --surface-warm: #fbfcf8;
  --ink: #17352a;
  --ink-soft: #446258;
  --muted: #71827a;
  --line: #dce8df;
  --line-strong: #c5dccb;
  --green: #15734f;
  --green-bright: #219363;
  --green-dark: #0d4e37;
  --red: #b44e4e;
  --red-soft: #fff2f1;
  --amber: #a36a19;
  --amber-soft: #fff8e9;
  --shadow-sm: 0 8px 24px rgba(23, 53, 42, .06);
  --shadow-md: 0 18px 48px rgba(23, 53, 42, .09);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 max(5vw, 24px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  margin-right: 9px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 17px;
}

.header-note { color: var(--muted); font-size: 13px; }

.page-shell {
  width: min(100% - 40px, 980px);
  margin: 0 auto;
  padding: 64px 0 88px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 40px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

.hero h1, .results-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 6vw, 60px);
  font-weight: 800;
  letter-spacing: -.055em;
  line-height: 1.05;
}

.hero h1 span { color: var(--green); }

.hero-copy {
  max-width: 510px;
  margin: 19px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
}

.hero-badge {
  display: grid;
  flex: 0 0 166px;
  gap: 2px;
  padding: 19px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
}

.hero-badge span { color: var(--green-bright); font-size: 25px; line-height: 1; }
.hero-badge strong { margin-top: 5px; font-size: 14px; }
.hero-badge small { color: var(--muted); font-size: 12px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.upload-card { padding: 27px; }

.mode-switch {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-warm);
}

.mode-button {
  min-width: 104px;
  padding: 10px 18px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.mode-button:hover { color: var(--green); }
.mode-button.active { background: var(--surface); color: var(--green); box-shadow: 0 3px 12px rgba(23, 53, 42, .09); }

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 232px;
  padding: 30px 20px;
  border: 1.5px dashed #a9cbb4;
  border-radius: var(--radius-md);
  background: var(--surface-warm);
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--green-bright);
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 3px rgba(33, 147, 99, .06);
}

.drop-zone input { display: none; }

.upload-icon {
  display: grid;
  place-items: center;
  width: 53px;
  height: 53px;
  margin-bottom: 13px;
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 27px;
  font-weight: 700;
}

.drop-zone strong { font-size: 17px; letter-spacing: -.01em; }
.drop-zone span { color: var(--muted); font-size: 13px; }
.drop-zone .choose-link { margin-top: 15px; color: var(--green); font-weight: 750; }

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  color: var(--ink-soft);
  font-size: 14px;
}

.clear-all-button {
  padding: 5px 2px;
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.clear-all-button:hover { text-decoration: underline; }

.file-list { display: grid; gap: 9px; margin-top: 10px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.file-row.has-warning { border-color: #e7c98f; background: var(--amber-soft); }

.file-thumb {
  display: grid;
  flex: 0 0 62px;
  place-items: center;
  width: 62px;
  height: 52px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--surface-soft);
}

.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-file-icon { color: var(--green); font-size: 21px; }

.file-details { display: grid; min-width: 0; gap: 2px; }
.file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-details span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.file-warning { color: var(--amber) !important; font-weight: 650; }

.remove-button {
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f1f5f2;
  color: var(--muted);
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.remove-button:hover { background: var(--red-soft); color: var(--red); }

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.status.loading { background: var(--surface-soft); color: var(--green-dark); }
.status.error { background: var(--red-soft); color: var(--red); }

.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.primary-button {
  width: 100%;
  margin-top: 20px;
  padding: 15px 18px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
}

.primary-button:hover:not(:disabled) { transform: translateY(-1px); background: var(--green-dark); }
.primary-button:disabled { border-color: #b6c5bd; background: #b6c5bd; cursor: not-allowed; }
.button-arrow { font-size: 20px; }

.secondary-button {
  padding: 11px 17px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--green);
  white-space: nowrap;
}

.secondary-button:hover { border-color: var(--green-bright); background: var(--surface-soft); }
.privacy-note, .connection-hint { color: var(--muted); font-size: 12px; text-align: center; }
.privacy-note { margin: 15px 0 0; }
.connection-hint { margin-top: 20px; }
.dot, .fresh-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--green-bright); }

footer {
  padding: 24px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.results-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.results-heading h1 { font-size: clamp(38px, 5vw, 50px); }

.batch-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-bottom: 27px;
}

.batch-summary > div {
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.batch-summary strong { display: block; color: var(--ink); font-size: 26px; line-height: 1.1; }
.batch-summary span { color: var(--muted); font-size: 12px; }
.batch-success strong { color: var(--green); }
.batch-failure strong { color: var(--red); }

.file-result { margin-bottom: 34px; }

.file-result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 12px;
}

.file-result-heading > div { min-width: 0; }
.file-result-heading h2 { display: inline; margin: 0 8px 0 10px; font-size: 20px; letter-spacing: -.025em; overflow-wrap: anywhere; }
.file-number { display: inline-grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--surface-soft); color: var(--green); font-weight: 800; }
.result-status { padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.result-status.success { background: var(--surface-soft); color: var(--green); }
.result-status.failed { background: var(--red-soft); color: var(--red); }

.result-summary {
  margin-bottom: 13px;
  padding: 19px 22px;
  border: 1px solid #cfe6d6;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.result-summary > div, .section-title { display: flex; align-items: center; gap: 12px; }
.success-check { display: grid; flex: 0 0 29px; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; }
.result-summary strong { font-size: 16px; }
.result-summary p, .section-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.detection-list { display: grid; gap: 10px; }

.detection-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px 18px;
  padding: 18px 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.detection-card h3 { margin: 0; color: var(--ink); font-size: 17px; letter-spacing: -.015em; }
.detection-title { min-width: 0; }
.detection-number { display: inline-grid; place-items: center; width: 25px; height: 25px; margin-right: 8px; border-radius: 50%; background: var(--detection-color); color: #fff; font-size: 13px; font-weight: 800; vertical-align: middle; }
.detection-title h3 { display: inline; }
.linked-detection { border-left: 5px solid var(--detection-color); cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.linked-detection:hover, .linked-detection.is-selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--detection-color) 22%, transparent), var(--shadow-sm); transform: translateY(-1px); }
.confidence { text-align: right; }
.confidence span { display: block; color: var(--muted); font-size: 12px; }
.confidence strong { color: var(--green); font-size: 18px; }
.freshness { display: flex; grid-column: 1 / -1; align-items: center; gap: 7px; padding: 9px 11px; border-radius: 9px; background: var(--surface-soft); color: var(--green); font-size: 13px; font-weight: 750; }
.freshness b { margin-left: auto; font-size: 13px; }
.box { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.inference-warning { grid-column: 1 / -1; padding: 8px 10px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); font-size: 12px; }
.image-result-layout { margin: 0 0 14px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.annotated-image { position: relative; width: 100%; max-height: 72vh; overflow: hidden; border-radius: 10px; background: #10231b; line-height: 0; }
.annotated-image > img { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.image-boxes { position: absolute; inset: 0; }
.image-box { position: absolute; min-width: 29px; min-height: 29px; padding: 0; border: 3px solid var(--detection-color); border-radius: 5px; background: color-mix(in srgb, var(--detection-color) 12%, transparent); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.image-box span { position: absolute; top: -3px; left: -3px; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 4px 0 5px 0; background: var(--detection-color); color: #fff; font-size: 13px; font-weight: 800; line-height: 1; }
.image-box:hover, .image-box.is-selected { z-index: 2; border-width: 4px; background: color-mix(in srgb, var(--detection-color) 25%, transparent); }
.image-help, .image-unavailable { margin: 10px 2px 0; color: var(--muted); font-size: 12px; }

.raw-details { margin-top: 7px; color: var(--muted); font-size: 12px; }
.raw-details summary { width: max-content; color: var(--green); cursor: pointer; font-weight: 700; }
.raw-details span { display: block; margin-top: 3px; }

.summary-card, .frames-card { padding: 21px; }
.summary-card, .frames-card { margin-bottom: 13px; }
.section-title h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.food-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 19px; }
.food-chip { display: grid; gap: 4px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-warm); }
.food-chip strong { font-size: 14px; }
.food-chip small { color: var(--muted); font-size: 11px; }

.frames-card details > summary { color: var(--ink); cursor: pointer; font-weight: 800; }
.frames-card summary span { float: right; color: var(--green); }
.frame-list { margin-top: 15px; border-top: 1px solid var(--line); }
.frame-row { display: grid; grid-template-columns: 118px 78px minmax(0, 1fr); gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.frame-row > span { color: var(--muted); }
.frame-detections { grid-column: 1 / -1; margin-top: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-warm); }
.frame-detections summary { color: var(--green); cursor: pointer; font-weight: 700; }
.frame-detections .detection-card { margin-top: 10px; box-shadow: none; }

.empty-state { padding: 42px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 21px; font-weight: 800; }
.empty-state h2 { margin: 15px 0 6px; font-size: 20px; }
.empty-state p { margin: 0; color: var(--muted); }

@media (max-width: 700px) {
  .site-header { min-height: 64px; }
  .header-note { display: none; }
  .page-shell { width: min(100% - 28px, 620px); padding: 40px 0 60px; }
  .hero { display: block; margin-bottom: 27px; }
  .hero-badge { display: none; }
  .hero h1 { font-size: clamp(37px, 12vw, 49px); }
  .hero-copy { font-size: 14px; }
  .upload-card { padding: 18px; border-radius: 18px; }
  .drop-zone { min-height: 215px; }
  .results-heading { display: block; margin-bottom: 25px; }
  .results-heading h1 { margin-bottom: 18px; font-size: 39px; }
  .batch-summary { gap: 7px; }
  .batch-summary > div { padding: 13px 11px; }
  .batch-summary strong { font-size: 22px; }
  .file-result-heading { align-items: flex-start; }
  .file-result-heading h2 { font-size: 16px; }
  .detection-card { grid-template-columns: 1fr; }
  .confidence { text-align: left; }
  .frame-row { grid-template-columns: 80px 57px minmax(0, 1fr); gap: 7px; }
}

@media (max-width: 430px) {
  .mode-button { min-width: 0; padding: 9px 14px; }
  .file-thumb { flex-basis: 53px; width: 53px; height: 46px; }
  .file-row { gap: 9px; padding: 8px; }
  .file-details span { max-width: 190px; }
  .batch-summary strong { font-size: 20px; }
  .batch-summary span { font-size: 11px; }
  .secondary-button { width: 100%; }
}
