/* ═══════════════════════════════════════════════════════════════════════════
   Pattern Delineation — Neural Analysis Lab
   Dark-mode glassmorphism theme with neon cyan accents
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  /* Surface */
  --bg:            #06080d;
  --bg-secondary:  #0b0f18;
  --surface:       rgba(12, 17, 28, 0.65);
  --surface-hover: rgba(18, 25, 42, 0.75);
  --border:        rgba(0, 224, 255, 0.12);
  --border-hover:  rgba(0, 224, 255, 0.30);

  /* Neon accent */
  --accent:        #00e0ff;
  --accent-dim:    #00b4cc;
  --accent-glow:   rgba(0, 224, 255, 0.35);
  --accent-subtle: rgba(0, 224, 255, 0.06);

  /* Secondary accent */
  --accent2:       #7c3aed;
  --accent2-glow:  rgba(124, 58, 237, 0.25);

  /* Text */
  --text:          #e4e8f1;
  --text-dim:      #8892a8;
  --text-muted:    #505a70;

  /* Status */
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;

  /* Misc */
  --radius:        12px;
  --radius-sm:     8px;
  --glass-blur:    20px;
  --transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Ring metrics */
  --ring-circumference: 100.53;  /* 2 * π * 16 */
}

/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Ambient background ────────────────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,224,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,224,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  width: 600px; height: 600px;
  border-radius: 50%;
  filter: blur(180px);
  opacity: 0.15;
}
.bg-glow--1 { top: -200px; left: -100px; background: var(--accent); }
.bg-glow--2 { bottom: -250px; right: -150px; background: var(--accent2); }

/* ── Glass mixin ───────────────────────────────────────────────────────── */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* ── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 8, 13, 0.85);
  backdrop-filter: blur(12px);
}

.topbar__brand { display: flex; align-items: center; gap: 14px; }

.topbar__icon {
  width: 36px; height: 36px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.topbar__title {
  font-size: 1.2rem; font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar__sub {
  font-size: 0.72rem; color: var(--text-dim);
  font-weight: 400; letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar__status { display: flex; align-items: center; gap: 8px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition), box-shadow var(--transition);
}
.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}
.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.status-label {
  font-size: 0.78rem; color: var(--text-dim);
  font-family: "JetBrains Mono", monospace;
}

/* ── Metrics bar ───────────────────────────────────────────────────────── */
.metrics-bar {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  gap: 40px;
  margin: 16px 28px 0;
  padding: 16px 32px;
}

.metric {
  display: flex; align-items: center; gap: 10px;
}

.metric__ring { width: 40px; height: 40px; transform: rotate(-90deg); }

.metric__ring-bg {
  fill: none;
  stroke: rgba(0, 224, 255, 0.08);
  stroke-width: 3;
}

.metric__ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-circumference);
  stroke-dashoffset: var(--ring-circumference);
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

.metric__info { display: flex; flex-direction: column; }

.metric__value {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.1rem; font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

.metric__label {
  font-size: 0.68rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* ── Workspace ─────────────────────────────────────────────────────────── */
.workspace {
  position: relative; z-index: 10;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  padding: 20px 28px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Panel ─────────────────────────────────────────────────────────────── */
.panel {
  padding: 24px;
  transition: border-color var(--transition);
}
.panel:hover { border-color: var(--border-hover); }

.panel__heading {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.neon-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Drop zone — REMOVED ───────────────────────────────────────────────── */

/* ── Processing box ────────────────────────────────────────────────────── */
.processing-box {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 20px;
  border: 1px solid rgba(0, 224, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(6, 8, 13, 0.6);
  margin-bottom: 16px;
}
.processing-box[hidden] { display: none; }

/* ── Processing overlay — REMOVED ──────────────────────────────────────── */

.processing-spinner {
  position: relative;
  width: 60px; height: 60px;
  margin-bottom: 16px;
}

.spinner-ring {
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
.spinner-ring--2 {
  inset: 6px;
  border-top-color: var(--accent-dim);
  animation-duration: 1.8s;
  animation-direction: reverse;
}
.spinner-ring--3 {
  inset: 12px;
  border-top-color: var(--accent2);
  animation-duration: 2.4s;
  filter: drop-shadow(0 0 6px var(--accent2-glow));
}

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

.processing-text {
  font-size: 0.78rem; color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.04em;
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── File name — REMOVED ───────────────────────────────────────────────── */

/* ── Controls ──────────────────────────────────────────────────────────── */
.controls {
  display: flex; flex-direction: column;
  gap: 12px; margin-top: 20px;
}

.control-group { display: flex; flex-direction: column; gap: 6px; }

.control-label {
  display: flex; justify-content: space-between;
  font-size: 0.72rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.control-value {
  font-family: "JetBrains Mono", monospace;
  color: var(--accent);
}

/* ── Slider ────────────────────────────────────────────────────────────── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 4px;
  background: rgba(0, 224, 255, 0.1);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.82rem; font-weight: 600;
  font-family: "Inter", sans-serif;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn--primary {
  background: linear-gradient(135deg, rgba(0, 224, 255, 0.15), rgba(0, 224, 255, 0.05));
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(0, 224, 255, 0.08);
}
.btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 224, 255, 0.25), rgba(0, 224, 255, 0.1));
  box-shadow: 0 0 24px rgba(0, 224, 255, 0.2);
  transform: translateY(-1px);
}
.btn--primary:disabled {
  opacity: 0.35; cursor: not-allowed;
}

.btn--secondary {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.3);
  color: #a78bfa;
}
.btn--secondary:hover {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: 0 0 20px var(--accent2-glow);
  transform: translateY(-1px);
}

/* ── Divider — REMOVED ───────────────────────────────────────────────── */

/* ── Toggle button ─────────────────────────────────────────────────────── */
.toggle-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  font-size: 0.72rem; font-weight: 500;
  font-family: "Inter", sans-serif;
  color: var(--text-dim);
  background: rgba(0, 224, 255, 0.04);
  border: 1px solid rgba(0, 224, 255, 0.1);
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.toggle-btn.active {
  background: rgba(0, 224, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 224, 255, 0.1);
}

/* ── Viewer panel ──────────────────────────────────────────────────────── */
.viewer-panel { display: flex; flex-direction: column; min-height: 520px; }

.viewer-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.viewer-header .panel__heading { margin-bottom: 0; }

.viewer-controls { display: flex; gap: 8px; }

.viewer-results { flex: 1; }

.viewer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.viewer-pane { display: flex; flex-direction: column; gap: 8px; }

.pane-label {
  font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding-left: 4px;
}

.pane-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  aspect-ratio: 1;
}
.pane-frame canvas {
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
}

.pane-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.pane-empty[hidden] { display: none; }

.heatmap-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0.55;
  mix-blend-mode: screen;
  pointer-events: none;
  transition: opacity var(--transition);
}
.heatmap-overlay[hidden] { display: none; }

/* ── Ground truth row ──────────────────────────────────────────────────── */
.gt-row {
  display: flex; align-items: center;
  gap: 20px; margin-top: 16px;
}
.gt-row[hidden] { display: none; }

.viewer-pane--sm { max-width: 200px; }
.pane-frame--sm { aspect-ratio: 1; }

.dice-badge {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  padding: 16px 28px;
  background: rgba(0, 224, 255, 0.04);
  border: 1px solid rgba(0, 224, 255, 0.15);
  border-radius: var(--radius-sm);
}

.dice-badge__label {
  font-size: 0.65rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.dice-badge__value {
  font-family: "JetBrains Mono", monospace;
  font-size: 2rem; font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.footer {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 14px 28px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  border-top: 1px solid var(--border);
}

.footer__sep { opacity: 0.3; }

/* ── History section ────────────────────────────────────────────────────── */
.history-section {
  position: relative; z-index: 10;
  padding: 0 28px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.history-panel { padding: 24px; }

.history-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.history-empty {
  font-size: 0.75rem; color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  text-align: center; padding: 20px 0;
}

.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(0, 224, 255, 0.02);
  border: 1px solid rgba(0, 224, 255, 0.06);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.history-item:hover {
  border-color: var(--border-hover);
  background: rgba(0, 224, 255, 0.05);
}

.history-item__num {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem; font-weight: 600;
  color: var(--text-muted);
  min-width: 24px;
}

.history-item__thumb {
  width: 36px; height: 36px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.history-item__thumb canvas {
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
}

.history-item__dice {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem; font-weight: 600;
}

.history-item__params {
  font-size: 0.68rem; color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  margin-left: auto;
}

.history-item__time {
  font-size: 0.62rem; color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
}

/* ── Architecture section ───────────────────────────────────────────────── */
.arch-section {
  position: relative; z-index: 10;
  padding: 0 28px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.arch-panel { padding: 24px; }

.arch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.arch-card {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  gap: 6px;
  padding: 20px 14px;
  background: rgba(0, 224, 255, 0.02);
  border: 1px solid rgba(0, 224, 255, 0.06);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), transform var(--transition);
}
.arch-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.arch-card__icon {
  width: 32px; height: 32px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(0, 224, 255, 0.3));
}
.arch-card__icon svg { width: 100%; height: 100%; }

.arch-card__title {
  font-size: 0.78rem; font-weight: 600;
  color: var(--text);
}

.arch-card__desc {
  font-size: 0.68rem; color: var(--text-dim);
  line-height: 1.4;
}

/* ── Toast notification ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px;
  font-size: 0.78rem; font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in forwards;
  animation-delay: 0s, 3s;
}
.toast--error { border-color: rgba(239, 68, 68, 0.4); }
.toast--success { border-color: rgba(34, 197, 94, 0.3); }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .metrics-bar {
    flex-wrap: wrap;
    gap: 20px;
  }
  .viewer-grid {
    grid-template-columns: 1fr;
  }
  .arch-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .workspace { padding: 12px 16px; }
  .metrics-bar { margin: 12px 16px 0; padding: 12px 16px; gap: 14px; }
  .history-section, .arch-section { padding: 0 16px 16px; }
  .arch-grid { grid-template-columns: 1fr; }
}
