:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-strong: #eef4ee;
  --ink: #172018;
  --muted: #667065;
  --line: #dce2d8;
  --green: #1d7f51;
  --green-strong: #0d5c39;
  --blue: #2d6cdf;
  --yellow: #d99a1e;
  --orange: #d36f24;
  --red: #c84f4f;
  --purple: #8056c9;
  --shadow: 0 18px 46px rgba(33, 45, 36, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  padding-bottom: 82px;
  background:
    linear-gradient(135deg, rgba(29, 127, 81, 0.08), transparent 28%),
    linear-gradient(315deg, rgba(45, 108, 223, 0.08), transparent 24%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a.primary-button,
a.ghost-button {
  text-decoration: none;
}

.developer-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 60;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 42px rgba(33, 45, 36, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.developer-bar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.developer-bar a.active {
  background: var(--green);
  color: #fff;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(29, 127, 81, 0.28);
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.caption,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 750;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.municipality-card {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.municipality-card strong {
  font-size: 1.2rem;
}

.municipality-card span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  display: grid;
  gap: 28px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.topbar h1,
.section-heading h2 {
  margin: 4px 0 0;
  max-width: 760px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.05;
}

.eyebrow {
  margin: 0;
  color: var(--green-strong);
}

.topbar-actions,
.scanner-toolbar,
.municipality-controls,
.search-row,
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 28px rgba(29, 127, 81, 0.24);
}

.ghost-button {
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  width: 44px;
  background: var(--surface);
  border-color: var(--line);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.scan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.65fr);
  gap: 22px;
  align-items: stretch;
}

.scanner-panel,
.result-panel,
.controls-section,
.manual-section {
  min-width: 0;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  --focus-left: 20%;
  --focus-top: 24%;
  --focus-width: 60%;
  --focus-height: 52%;
  min-height: 460px;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background: #152018;
  box-shadow: var(--shadow);
}

#cameraFeed,
#snapshotCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: none;
}

.camera-stage.unmirror-camera #cameraFeed {
  transform: scaleX(-1);
}

.blur-zones {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  pointer-events: none;
}

.camera-stage.active .blur-zones {
  display: block;
}

.blur-zone {
  position: absolute;
  background: rgba(8, 15, 10, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.blur-top {
  left: 0;
  top: 0;
  width: 100%;
  height: var(--focus-top);
}

.blur-bottom {
  left: 0;
  top: calc(var(--focus-top) + var(--focus-height));
  width: 100%;
  bottom: 0;
}

.blur-left {
  left: 0;
  top: var(--focus-top);
  width: var(--focus-left);
  height: var(--focus-height);
}

.blur-right {
  left: calc(var(--focus-left) + var(--focus-width));
  top: var(--focus-top);
  right: 0;
  height: var(--focus-height);
}

#snapshotCanvas {
  display: none;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: #eaf3ea;
  text-align: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.16), transparent 26%),
    linear-gradient(135deg, #1b3928, #102118);
}

.camera-placeholder strong {
  font-size: 1.35rem;
}

.camera-placeholder span:last-child {
  color: rgba(234, 243, 234, 0.72);
}

.material-orbit {
  position: relative;
  width: 220px;
  height: 150px;
  margin: 0 auto 12px;
}

.material {
  position: absolute;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.2);
}

.material.paper {
  left: 28px;
  top: 24px;
  width: 74px;
  height: 94px;
  border-radius: 6px;
  background: #f7efe1;
  transform: rotate(-9deg);
}

.material.bottle {
  left: 118px;
  top: 12px;
  width: 42px;
  height: 122px;
  border-radius: 16px 16px 10px 10px;
  background: linear-gradient(#d8f4ff, #7bc4de);
  transform: rotate(8deg);
}

.material.peel {
  left: 82px;
  top: 100px;
  width: 94px;
  height: 34px;
  border-radius: 50%;
  background: #f5b046;
}

.scan-frame {
  position: absolute;
  z-index: 3;
  left: var(--focus-left);
  top: var(--focus-top);
  display: none;
  width: var(--focus-width);
  height: var(--focus-height);
  transform: none;
  border: 2px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(8, 15, 10, 0.2);
}

.camera-stage.active .scan-frame {
  display: block;
}

.camera-stage.scanning .scan-frame {
  animation: scanPulse 900ms ease-in-out infinite;
}

.camera-stage.scanning::before {
  content: "";
  position: absolute;
  inset: -18% 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 38%,
    rgba(127, 243, 169, 0.62) 49%,
    rgba(255, 255, 255, 0.18) 52%,
    transparent 64%
  );
  mix-blend-mode: screen;
  animation: scanSweep 1s ease-out both;
}

.camera-stage.scanning::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 6;
  width: 58px;
  height: 52px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86) url("./assets/chatgft-icon.png") center / 72% no-repeat;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.24);
  animation: logoLoader 1.1s linear infinite;
}

.scan-frame span {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #7ff3a9;
}

.scan-frame span:nth-child(1) {
  left: -2px;
  top: -2px;
  border-left: 4px solid #7ff3a9;
  border-top: 4px solid #7ff3a9;
}

.scan-frame span:nth-child(2) {
  right: -2px;
  top: -2px;
  border-right: 4px solid #7ff3a9;
  border-top: 4px solid #7ff3a9;
}

.scan-frame span:nth-child(3) {
  right: -2px;
  bottom: -2px;
  border-right: 4px solid #7ff3a9;
  border-bottom: 4px solid #7ff3a9;
}

.scan-frame span:nth-child(4) {
  left: -2px;
  bottom: -2px;
  border-left: 4px solid #7ff3a9;
  border-bottom: 4px solid #7ff3a9;
}

@keyframes scanPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.025);
  }
}

@keyframes logoLoader {
  to {
    transform: rotate(360deg);
  }
}

@keyframes scanSweep {
  from {
    transform: translateY(-72%);
  }
  to {
    transform: translateY(72%);
  }
}

.scanner-toolbar {
  margin-top: 14px;
}

.result-panel {
  display: grid;
  gap: 14px;
}

.result-card,
.confidence-card,
.controls-section,
.manual-section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(33, 45, 36, 0.08);
}

.result-card h2 {
  margin: 8px 0;
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
  line-height: 1.05;
}

.result-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.waste-bin {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 88px;
  padding: 14px;
  border-radius: 8px;
  color: #fff;
  background: #647064;
}

.waste-bin span:first-child {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.3rem;
  font-weight: 900;
}

.waste-bin strong,
.waste-bin span {
  display: block;
}

.waste-bin span:last-child {
  color: rgba(255, 255, 255, 0.78);
}

.waste-bin.paper { background: var(--blue); }
.waste-bin.plastic { background: var(--orange); }
.waste-bin.glass { background: #20906d; }
.waste-bin.gft { background: var(--green-strong); }
.waste-bin.residual { background: #525a63; }
.waste-bin.chemical { background: var(--red); }
.waste-bin.textile { background: var(--purple); }

.disposal-info {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(12, 74, 55, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.disposal-info[hidden] {
  display: none;
}

.disposal-kicker {
  color: var(--green-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.disposal-info strong {
  font-size: 1.04rem;
}

.disposal-info p {
  margin: 0;
  color: var(--muted);
}

.disposal-info a {
  display: inline-flex;
  justify-content: center;
  width: fit-content;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--green-strong);
  color: #fff;
  font-weight: 850;
  text-decoration: none;
}

.confidence-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-weight: 800;
}

.meter {
  overflow: hidden;
  height: 10px;
  margin: 12px 0;
  border-radius: 999px;
  background: #e1e7de;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 320ms ease;
}

#scanStatus {
  margin: 0;
  color: var(--muted);
}

.controls-section,
.manual-section {
  display: grid;
  gap: 18px;
}

.municipality-controls label {
  font-weight: 800;
}

select,
input {
  min-height: 44px;
  min-width: min(100%, 280px);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rule-card {
  min-height: 128px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.rule-card strong,
.rule-card span {
  display: block;
}

.rule-card strong {
  margin-bottom: 8px;
}

.rule-card span {
  color: var(--muted);
  font-size: 0.94rem;
}

.search-row input {
  flex: 1 1 260px;
}

.suggestion-chip {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.suggestions {
  display: none;
}

.icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.camera-icon::before {
  content: "";
  position: absolute;
  inset: 4px 2px 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.camera-icon::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  width: 4px;
  height: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.pin-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.pin-icon::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 5px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
}

.bins-icon::before,
.bins-icon::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 7px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-width: 4px;
  border-radius: 2px;
}

.bins-icon::before { left: 1px; }
.bins-icon::after { right: 1px; }

.scan-icon::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.scan-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 8px;
  height: 2px;
  background: currentColor;
}

.switch-icon::before,
.switch-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  width: 14px;
  height: 6px;
  border: 2px solid currentColor;
}

.switch-icon::before {
  top: 2px;
  border-left: 0;
  border-bottom: 0;
}

.switch-icon::after {
  bottom: 2px;
  border-right: 0;
  border-top: 0;
}

.stop-icon::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 3px;
  background: currentColor;
}

.search-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 9px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 7px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: center;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .municipality-card {
    margin-top: 0;
  }

  .content {
    padding: 20px;
  }

  .topbar,
  .scan-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .content {
    padding: 14px;
  }

  .topbar h1 {
    font-size: 2.55rem;
  }

  .topbar-actions,
  .topbar-actions button,
  .scanner-toolbar .primary-button,
  .municipality-controls select,
  .municipality-controls button,
  .search-row button,
  .search-row input {
    width: 100%;
  }

  .nav-item {
    justify-content: center;
    padding: 0 8px;
    font-size: 0.92rem;
  }

  .camera-stage {
    width: 100%;
    min-height: 0;
    height: 360px;
    aspect-ratio: auto;
  }

  .scanner-toolbar {
    display: grid;
    grid-template-columns: 1fr 44px 44px;
  }

  .rule-grid {
    grid-template-columns: 1fr;
  }
}
