:root {
  --bg-1: #1e364c;
  --bg-2: #2a4a66;
  --card: rgba(21, 40, 57, 0.86);
  --card-strong: rgba(20, 37, 54, 0.95);
  --text-main: #6bab52;
  --text-soft: #9ecf8a;
  --line: rgba(107, 171, 82, 0.34);
  --accent: #6bab52;
  --accent-strong: #8ac46e;
  --success: #83cd68;
  --warning: #d8bd71;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text-main);
  background: radial-gradient(1200px 700px at 8% 2%, #2e5576, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #355f83, transparent 55%),
    var(--bg-1);
}

#particles-js {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

.background-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: linear-gradient(120deg, transparent 0, transparent 45%, rgba(107, 171, 82, 0.11) 46%, transparent 52%);
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.2rem 2.2rem;
  position: relative;
  z-index: 1;
}

main,
dialog,
button,
input {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--text-soft);
}

h1 {
  margin: 0.4rem 0 0;
  font-family: "Sora", sans-serif;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.status-banner {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  background: var(--card-strong);
  font-weight: 600;
}

.status-neutral {
  color: var(--text-soft);
}

.status-ok {
  color: var(--success);
  border-color: rgba(131, 205, 104, 0.55);
}

.status-warn {
  color: var(--warning);
  border-color: rgba(216, 189, 113, 0.55);
}

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

.camera-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 34px rgba(8, 21, 31, 0.35);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

.chip {
  background: rgba(107, 171, 82, 0.14);
  color: var(--accent-strong);
  border: 1px solid rgba(107, 171, 82, 0.38);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

.stream-placeholder {
  margin: 0.8rem 0;
  border: 1px dashed rgba(107, 171, 82, 0.45);
  border-radius: 16px;
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  background: linear-gradient(155deg, rgba(33, 58, 80, 0.88), rgba(24, 45, 63, 0.92));
  gap: 0.4rem;
  padding: 0.65rem;
}

.stream-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(107, 171, 82, 0.42);
  display: none;
}

.stream-placeholder p {
  margin: 0;
  font-weight: 700;
}

.stream-placeholder small {
  color: var(--text-soft);
}

.info {
  margin: 0.3rem 0 0.9rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.info div {
  background: rgba(18, 34, 49, 0.9);
  border: 1px solid rgba(107, 171, 82, 0.3);
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
}

dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 0.15rem;
}

dd {
  margin: 0;
  font-weight: 700;
  font-size: 0.93rem;
}

button {
  font-family: inherit;
  border: 0;
  cursor: pointer;
}

.primary-btn,
.analyze-btn {
  width: 100%;
  border-radius: 13px;
  background: linear-gradient(130deg, #5f9f4a, #79be5f);
  color: #102131;
  font-weight: 700;
  padding: 0.72rem 1rem;
}

.ghost-btn {
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(20, 37, 54, 0.86);
  color: var(--text-main);
  padding: 0.6rem 0.9rem;
  font-weight: 600;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.result {
  margin-top: 0.9rem;
}

.result img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(107, 171, 82, 0.38);
  display: block;
}

.result .bbch {
  margin-top: 0.5rem;
  background: rgba(107, 171, 82, 0.12);
  border: 1px solid rgba(107, 171, 82, 0.35);
  color: #9ed889;
  border-radius: 11px;
  padding: 0.55rem 0.65rem;
  font-weight: 700;
}

.result .detection-note {
  margin-top: 0.5rem;
  background: rgba(107, 171, 82, 0.08);
  border: 1px solid rgba(107, 171, 82, 0.28);
  color: #a7dc93;
  border-radius: 11px;
  padding: 0.5rem 0.65rem;
  font-weight: 600;
}

/* ── Analyze loader ──────────────────────────────────────── */
.analyze-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0 1rem;
}

.analyze-loader__canvas {
  border-radius: 16px;
  display: block;
}

.analyze-loader__label {
  margin-top: 0.8rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.04em;
}

dialog {
  border: 1px solid rgba(107, 171, 82, 0.38);
  border-radius: 16px;
  width: min(560px, 92vw);
  background: rgba(21, 40, 57, 0.98);
  color: var(--text-main);
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.dialog-status {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: rgba(20, 37, 54, 0.9);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.dialog-status-clean {
  border: none;
  background: transparent;
  padding: 0;
  margin-bottom: 0;
}

.dialog-status.status-ok {
  color: var(--success);
  border-color: rgba(131, 205, 104, 0.55);
  background: rgba(131, 205, 104, 0.08);
}

.dialog-status.status-warn {
  color: var(--warning);
  border-color: rgba(216, 189, 113, 0.55);
  background: rgba(216, 189, 113, 0.08);
}

.dialog-status.status-neutral {
  color: var(--text-soft);
  border-color: var(--line);
  background: rgba(20, 37, 54, 0.9);
}

#connect-form {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
}

#connect-form h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.dialog-help {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

label {
  font-size: 0.88rem;
  display: grid;
  gap: 0.33rem;
}

input {
  border: 1px solid rgba(107, 171, 82, 0.36);
  background: rgba(16, 31, 45, 0.9);
  color: #b3e59f;
  border-radius: 10px;
  padding: 0.58rem 0.6rem;
  font: inherit;
}

input::placeholder {
  color: rgba(179, 229, 159, 0.7);
}

.dialog-actions {
  margin-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.page-footer {
  margin-top: 1.6rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-logo {
  max-width: min(240px, 40vw);
  width: auto;
  height: auto;
  background: transparent;
  object-fit: contain;
  opacity: 0.96;
}

.footer-logo[src*="sfl_logo"] {
  max-width: min(160px, 28vw);
}

@media (max-width: 1024px) {
  #particles-js {
    height: 100dvh;
  }

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

  .stream-placeholder {
    min-height: 180px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-logo {
    max-width: min(180px, 42vw);
  }
}
