:root {
  --green: #2E7D32;
  --green-dark: #1B5E20;
  --green-tint: #E8F3E9;
  --ink: #1A1C19;
  --muted: #5C6660;
  --line: #DCE3DD;
  --surface: #FFFFFF;
  --surface-2: #F4F7F4;
  --danger: #B3261E;
  --danger-tint: #FBEAE9;
  --gold: #C8920A;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
  --maxw: 860px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over author `display` rules (e.g. .btn sets
   display:inline-flex, which would otherwise keep hidden buttons visible). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-2);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.wordmark { height: 40px; display: block; }

/* Hero */
.hero { padding: 40px 0 8px; text-align: center; }
.hero h1 {
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.sub { max-width: 560px; margin: 0 auto 16px; color: var(--muted); font-size: 16px; }
.privacy-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--green-dark);
  background: var(--green-tint); padding: 6px 14px; border-radius: 999px; margin: 0;
}
.privacy-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: center; margin: 28px 0 20px; }
.control { display: flex; align-items: center; gap: 12px; }
.control-label { font-size: 14px; font-weight: 600; color: var(--muted); }
#sensVal { color: var(--green-dark); text-transform: capitalize; }
#sensitivity { accent-color: var(--green); width: 200px; }

/* Browser-support note (set at runtime by app.js) */
.browser-note { text-align: center; font-size: 13px; margin: 0 0 14px; color: var(--muted); }
.browser-note.ok { color: var(--green-dark); font-weight: 600; }
.browser-note.warn {
  color: var(--danger); font-weight: 600;
  background: var(--danger-tint); border: 1px solid #f0c9c6;
  padding: 12px 16px; border-radius: 12px; max-width: 560px; margin: 0 auto 16px;
}

/* Dropzone */
.dropzone {
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
  outline: none;
}
.dropzone.dragover { border-color: var(--green); background: var(--green-tint); }
.dz-icon { width: 40px; height: 40px; color: var(--green); margin-bottom: 8px; }
.dz-title { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.dz-hint { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.dz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Explainer */
.explainer { max-width: 640px; margin: 18px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2px 18px; }
.explainer summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 13px 0; color: var(--ink); list-style-position: inside; }
.explainer summary:hover { color: var(--green-dark); }
.explainer-body { font-size: 14px; color: var(--muted); padding: 0 0 10px; }
.explainer-body p { margin: 8px 0; }
.explainer-body ol, .explainer-body ul { margin: 8px 0; padding-left: 22px; }
.explainer-body li { margin: 5px 0; }
.explainer-body strong { color: var(--ink); }

/* Progress */
.progress { margin-top: 22px; }
.progress-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--green); transition: width .2s ease; }
.progress-text { margin: 8px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* Notice */
.notice {
  margin-top: 18px; padding: 12px 16px;
  background: var(--green-tint); border: 1px solid var(--line);
  border-radius: 12px; font-size: 14px; color: var(--ink);
}
.notice a { color: var(--green-dark); font-weight: 600; }
.notice.empty { text-align: center; }

/* Results */
.results { margin-top: 24px; }
.results-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.summary { font-size: 15px; font-weight: 700; }
.summary .sub-num { color: var(--muted); font-weight: 600; }
.results-actions { display: flex; gap: 8px; align-items: center; }

.groups { display: grid; gap: 18px; }
.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.group-title { font-size: 14px; font-weight: 700; }
.group-meta { font-size: 12px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

.tile { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); background: var(--surface-2); }
.tile.keeper { border-color: var(--green); }
.tile.marked { border-color: var(--danger); }
.tile img { display: block; width: 100%; height: 120px; object-fit: cover; background: var(--surface-2); }
.tile-info { padding: 6px 8px; font-size: 11px; }
.tile-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tile-dim { color: var(--muted); }

.badge {
  position: absolute; top: 6px; left: 6px;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  color: #fff; letter-spacing: .03em; text-transform: uppercase;
}
.badge.keep { background: var(--green); }
.tile-check {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; accent-color: var(--danger);
  cursor: pointer;
}
.tile.keeper .tile-check { display: none; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  border-radius: 999px; padding: 9px 18px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  display: inline-flex; align-items: center; white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Cross-sell */
.cross-sell {
  margin: 36px 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.cs-body h2 { margin: 0 0 6px; font-size: 19px; }
.cs-body p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.cs-secondary { font-size: 14px; }
.cs-secondary a { color: var(--green-dark); font-weight: 600; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 12px; }
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; font-size: 13px; color: var(--muted);
}
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--green-dark); text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }

@media (max-width: 540px) {
  .results-head { flex-direction: column; align-items: stretch; }
  .results-actions { justify-content: flex-end; }
  .tile img { height: 100px; }
}
