:root {
  --bg-0: #02060f;
  --bg-1: #07172a;
  --bg-2: #0d2b45;
  --ink: #eff8ff;
  --muted: #99b6cb;
  --accent: #63f3d9;
  --accent-2: #45a3ff;
  --accent-3: #ff8b6a;
  --danger: #ff6f6f;
  --glass: rgba(8, 21, 36, 0.64);
  --glass-2: rgba(8, 28, 46, 0.72);
  --border: rgba(108, 159, 196, 0.3);
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at 12% 14%, #123b57 0%, transparent 35%),
    radial-gradient(circle at 88% 82%, #1f355f 0%, transparent 40%),
    linear-gradient(145deg, var(--bg-0), #041120 45%, #081b2e);
}

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.noise-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.18;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 0.8px, transparent 0.8px);
  background-size: 3px 3px;
}

.shell {
  position: relative;
  z-index: 2;
  width: min(1300px, 95vw);
  margin: 20px auto 42px;
  display: grid;
  gap: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(135deg, rgba(8, 22, 38, 0.74), rgba(6, 18, 31, 0.62));
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: conic-gradient(from 80deg, #63f3d9, #4ca9ff, #ff8b6a, #63f3d9);
  box-shadow: 0 0 22px rgba(99, 243, 217, 0.9);
}

.brand-title {
  margin: 0;
  font-family: "Syne", sans-serif;
  font-size: 1.9rem;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.76rem;
  color: var(--muted);
  background: rgba(10, 30, 48, 0.65);
}

.warning {
  border-color: rgba(255, 139, 106, 0.42);
  color: #ffd7cc;
}

.hero {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
}

.kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-size: 0.74rem;
}

.hero-copy h1 {
  margin: 0 0 10px;
  font-family: "Syne", sans-serif;
  font-size: clamp(1.5rem, 2.8vw, 2.5rem);
  line-height: 1.1;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  max-width: 66ch;
}

.hero-metrics {
  display: grid;
  gap: 9px;
}

.metric-tile {
  border: 1px solid rgba(108, 159, 196, 0.34);
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(120deg, rgba(10, 29, 47, 0.85), rgba(7, 21, 34, 0.78));
}

.metric-tile span {
  color: var(--muted);
  font-size: 0.76rem;
}

.metric-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
}

.control-panel h2,
.result-panel h2 {
  margin: 0 0 8px;
  font-family: "Syne", sans-serif;
  font-size: 1.15rem;
}

.panel-text {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dropzone {
  display: grid;
  gap: 6px;
  align-content: center;
  min-height: 116px;
  border: 1px dashed rgba(99, 243, 217, 0.5);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(140deg, rgba(9, 29, 47, 0.78), rgba(5, 16, 28, 0.82));
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.dropzone:hover {
  border-color: rgba(99, 243, 217, 0.86);
  transform: translateY(-1px);
}

.dropzone input {
  display: none;
}

.drop-title {
  font-weight: 700;
  font-size: 1.02rem;
}

.drop-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
}

.samples-wrap {
  margin-top: 12px;
  border: 1px solid rgba(108, 159, 196, 0.32);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(140deg, rgba(8, 24, 39, 0.84), rgba(6, 18, 30, 0.82));
}

.samples-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.samples-head h3 {
  margin: 0;
  font-family: "Syne", sans-serif;
  font-size: 0.95rem;
}

#samples-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 272px;
  overflow: auto;
  padding-right: 4px;
}

.sample-grid::-webkit-scrollbar {
  width: 8px;
}

.sample-grid::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(99, 243, 217, 0.7), rgba(69, 163, 255, 0.7));
}

.sample-card {
  border: 1px solid rgba(108, 159, 196, 0.3);
  border-radius: 11px;
  background: rgba(5, 16, 28, 0.88);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.sample-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 243, 217, 0.7);
}

.sample-card.active {
  border-color: rgba(99, 243, 217, 0.98);
  box-shadow: 0 0 0 1px rgba(99, 243, 217, 0.35), 0 10px 18px rgba(0, 0, 0, 0.25);
}

.sample-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  filter: saturate(1.05) contrast(1.12);
}

.sample-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
}

.sample-id {
  font-size: 0.72rem;
  color: var(--muted);
}

.sample-chip {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  padding: 2px 7px;
}

.sample-chip.benign {
  color: #c7fff5;
  background: rgba(99, 243, 217, 0.24);
}

.sample-chip.malignant {
  color: #ffd7cf;
  background: rgba(255, 111, 111, 0.24);
}

.mode-switch {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.mode-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.mode-btn {
  flex: 1;
  border: 1px solid rgba(108, 159, 196, 0.35);
  border-radius: 10px;
  padding: 10px;
  background: rgba(7, 21, 35, 0.82);
  color: var(--ink);
  cursor: pointer;
  transition: all 160ms ease;
}

.mode-btn:hover {
  border-color: rgba(99, 243, 217, 0.62);
}

.mode-btn.active {
  background: linear-gradient(120deg, rgba(99, 243, 217, 0.25), rgba(69, 163, 255, 0.22));
  border-color: rgba(99, 243, 217, 0.8);
}

.action-btn {
  margin-top: 12px;
  width: 100%;
  border: none;
  border-radius: 11px;
  padding: 12px;
  color: #031218;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(115deg, var(--accent), #86ffe8, #89bbff);
  background-size: 180% 180%;
  animation: pulseGradient 5s ease infinite;
}

@keyframes pulseGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.action-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.status-box {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.86rem;
  border: 1px solid rgba(108, 159, 196, 0.16);
}

.status-box.idle {
  background: rgba(16, 42, 63, 0.62);
  color: var(--muted);
}

.status-box.loading {
  background: rgba(255, 139, 106, 0.2);
  color: #ffd9cc;
}

.status-box.ok {
  background: rgba(99, 243, 217, 0.2);
  color: #c8fff6;
}

.status-box.error {
  background: rgba(255, 111, 111, 0.21);
  color: #ffd8d8;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

#result-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.clinical-summary {
  margin-top: 10px;
  border: 1px solid rgba(108, 159, 196, 0.34);
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(140deg, rgba(9, 26, 42, 0.84), rgba(7, 18, 33, 0.82));
}

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

.summary-cell {
  border: 1px solid rgba(108, 159, 196, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(6, 18, 32, 0.84);
}

.summary-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.summary-cell strong {
  display: block;
  margin-top: 4px;
  color: #def2ff;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.summary-banner {
  margin-top: 9px;
  border-radius: 10px;
  border: 1px solid rgba(108, 159, 196, 0.25);
  padding: 9px 10px;
  font-size: 0.83rem;
}

.summary-banner.neutral {
  color: #d6ecff;
  background: rgba(15, 40, 64, 0.6);
}

.summary-banner.good {
  color: #cafff5;
  background: rgba(34, 92, 82, 0.36);
  border-color: rgba(99, 243, 217, 0.45);
}

.summary-banner.caution {
  color: #ffe6b8;
  background: rgba(99, 77, 25, 0.36);
  border-color: rgba(255, 203, 98, 0.45);
}

.summary-banner.alert {
  color: #ffd8d8;
  background: rgba(96, 35, 35, 0.4);
  border-color: rgba(255, 111, 111, 0.45);
}

.explain-box {
  margin-top: 10px;
  border: 1px solid rgba(108, 159, 196, 0.28);
  border-radius: 12px;
  background: rgba(6, 20, 35, 0.78);
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.explain-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--muted);
}

.explain-row strong {
  color: #d5eeff;
  font-weight: 700;
  text-transform: uppercase;
}

.warning-text {
  font-size: 0.78rem;
  color: #ffd9cc;
  border-top: 1px dashed rgba(255, 139, 106, 0.28);
  padding-top: 6px;
  line-height: 1.35;
}

.overlay-stage {
  position: relative;
  margin-top: 10px;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(108, 159, 196, 0.32);
  background: radial-gradient(circle at 30% 40%, #0e3550, #041220 70%);
}

.overlay-stage::after {
  content: attr(data-placeholder);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(153, 182, 203, 0.82);
  font-size: 0.94rem;
}

.overlay-stage.has-image::after {
  display: none;
}

.overlay-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.overlay-stage img.is-empty,
.thumb img.is-empty {
  display: none;
}

#img-overlay {
  opacity: 0.55;
}

.slider-row {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.slider-row label {
  color: var(--muted);
  font-size: 0.84rem;
}

.slider-row input[type="range"] {
  width: 100%;
}

.gallery {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.limits-box {
  margin-top: 12px;
  border: 1px solid rgba(108, 159, 196, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(4, 15, 27, 0.82);
}

.limits-box h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-family: "Syne", sans-serif;
}

#limits-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.thumb {
  margin: 0;
  border-radius: 12px;
  border: 1px solid rgba(108, 159, 196, 0.3);
  overflow: hidden;
  background: rgba(4, 15, 26, 0.88);
}

.thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  display: block;
}

.thumb figcaption {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.79rem;
}

@media (max-width: 1120px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .shell {
    width: 96vw;
    margin-top: 14px;
  }

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

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

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

  .sample-grid {
    max-height: 230px;
  }

  .brand-title {
    font-size: 1.55rem;
  }
}
