:root {
  --bg-1: #0e1628;
  --bg-2: #0b2333;
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f0f4fb;
  --muted: #9fb0c6;
  --accent: #f7a440;
  --accent-2: #2fd1c5;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(47, 209, 197, 0.12), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(247, 164, 64, 0.12), transparent 26%), linear-gradient(140deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  padding: 18px 16px 24px;
  overflow-x: hidden;
}

.bg-layer {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 10% 70%, rgba(47, 209, 197, 0.1), transparent 30%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05), transparent 32%);
  pointer-events: none;
  filter: blur(50px);
  z-index: -1;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.brand-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  display: inline-block;
}

.tag {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.welcome-hero h1 {
  margin: 4px 0 8px;
  font-size: clamp(26px, 7vw, 36px);
  line-height: 1.25;
}

.eyebrow {
  letter-spacing: 0.08em;
  color: var(--accent-2);
  text-transform: uppercase;
  font-size: 12px;
  margin: 0;
}

.lede {
  color: var(--muted);
  line-height: 1.6;
  margin: 6px 0 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.form-card {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.species-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.species-card .species-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.species-card.active {
  border-color: rgba(47, 209, 197, 0.6);
  background: linear-gradient(120deg, rgba(47, 209, 197, 0.12), rgba(247, 164, 64, 0.12));
  transform: translateY(-1px);
}

input[type="text"] {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 15px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  cursor: pointer;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.primary-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0f1115;
  border: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.primary-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-btn {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.ghost-btn {
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  border-style: dashed;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

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

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 12px;
}

.center {
  text-align: center;
}

.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.screen.show {
  display: block;
}

.cam-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 4px 0 2px;
}

.cam-title {
  display: grid;
  gap: 2px;
}

.cam-title #cam-title-main {
  font-weight: 700;
}

.cam-frame {
  position: relative;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  height: clamp(320px, 60vh, 640px);
}

#cam-canvas,
#raw-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#raw-video {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.cam-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 12px;
  pointer-events: none;
}

.badge {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 12px;
}

.control-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.control-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.slider-block {
  display: grid;
  gap: 6px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.slider-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.transition-layer {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.82);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 20;
}

.transition-layer.show {
  opacity: 1;
  pointer-events: auto;
}

.transition-card {
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow);
  text-align: center;
}

.transition-text {
  font-size: 20px;
  margin-top: 8px;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: flex-end;
  z-index: 30;
}

.sheet.show {
  display: flex;
}

.sheet-panel {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  background: linear-gradient(160deg, rgba(18, 26, 44, 0.95), rgba(11, 18, 32, 0.95));
  padding: 12px 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.45);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sheet-body {
  display: grid;
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
}

.sheet-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.sheet-text p {
  margin: 6px 0;
  color: var(--text);
  line-height: 1.5;
}

.sheet .icon-btn {
  background: rgba(255, 255, 255, 0.08);
}

.sheet .chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sheet .chip-cloud .chip {
  font-size: 12px;
}

.sheet-handle {
  width: 60px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 12px;
}

.mini-list {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--text);
  display: grid;
  gap: 6px;
}

.mini-list li {
  line-height: 1.5;
}

@media (min-width: 720px) {
  body {
    padding: 28px 28px 32px;
  }
  .control-panel {
    grid-template-columns: repeat(2, 1fr);
  }
  .control-panel .secondary-btn {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .control-row {
    flex-direction: column;
  }
  .species-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
