/* ====================================================================
   1. SISTEM WARNA KOGNITIF & VARIABEL CSS (DEEP OBSIDIAN & NORDIC NEON)
   ==================================================================== */
:root {
  --bg-main: #0B1120;
  --bg-panel: #1E293B;
  --bg-panel-elevated: #263449;
  --bg-glass: rgba(30, 41, 59, 0.88);
  --border-subtle: #334155;
  --border-focus: #475569;
  --text-main: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Warna Semantik Kognitif */
  --c-blue: #38BDF8;     /* Parameter Populasi / Distribusi H0 / Variabel X / Level C1-C2 */
  --c-blue-dim: rgba(56, 189, 248, 0.16);
  --c-purple: #C084FC;   /* Statistik Sampel / Distribusi Posterior / Variabel Y / Level C6 */
  --c-purple-dim: rgba(192, 132, 252, 0.16);
  --c-green: #34D399;    /* Jawaban Tepat / Area Penerimaan / Model Valid / Level C3 */
  --c-green-dim: rgba(52, 211, 153, 0.16);
  --c-red: #FB7185;      /* Jawaban Keliru / Area Kritis (α) / Pelanggaran Asumsi / Level C5 */
  --c-red-dim: rgba(251, 113, 133, 0.16);
  --c-amber: #FBBF24;    /* Petunjuk Socratic (Hint) / Peringatan Diagnostik / Level C4 */
  --c-amber-dim: rgba(251, 191, 36, 0.16);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --font-math: 'Cambria Math', 'Latin Modern Math', Georgia, serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.45), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --transition-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --nav-bottom-h: 68px;
}

/* ====================================================================
   2. RESET & MOBILE-FIRST BASE ARCHITECTURE (320px+)
   ==================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(56, 189, 248, 0.06) 0%, transparent 35%),
    radial-gradient(circle at 88% 82%, rgba(192, 132, 252, 0.06) 0%, transparent 35%);
  padding-bottom: calc(var(--nav-bottom-h) + 28px);
}

img, svg, canvas, video {
  max-width: 100%;
  display: block;
  box-sizing: border-box;
}

h1 { font-size: clamp(1.32rem, 2.8vw, 2.05rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.25; }
h2 { font-size: clamp(1.12rem, 2.1vw, 1.5rem); font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; }
h3 { font-size: clamp(0.98rem, 1.6vw, 1.2rem); font-weight: 600; line-height: 1.35; }
p, li { font-size: clamp(0.86rem, 1.3vw, 0.98rem); color: var(--text-secondary); }
small { font-size: clamp(0.74rem, 1.05vw, 0.84rem); }

/* Target Sentuh Minimal 44x44px */
button, .btn, select, input[type="range"], input[type="number"], input[type="text"], .option-btn, .token-chip {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

button, .btn, select, input[type="number"], input[type="text"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-elevated);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: clamp(0.8rem, 1.15vw, 0.88rem);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
}

input[type="number"], input[type="text"] {
  cursor: text;
  font-family: var(--font-mono);
}

button:hover, .btn:hover, select:hover {
  border-color: var(--c-blue);
  background: rgba(56, 189, 248, 0.12);
}

.btn-primary {
  background: linear-gradient(135deg, #0284C7, #2563EB);
  border-color: var(--c-blue);
  color: #fff;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0369A1, #1D4ED8);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.btn-emerald {
  background: rgba(52, 211, 153, 0.16);
  border-color: var(--c-green);
  color: var(--c-green);
}
.btn-emerald:hover {
  background: rgba(52, 211, 153, 0.28);
  border-color: var(--c-green);
}

.btn-coral {
  background: rgba(251, 113, 133, 0.16);
  border-color: var(--c-red);
  color: var(--c-red);
}

.btn-purple {
  background: rgba(192, 132, 252, 0.16);
  border-color: var(--c-purple);
  color: var(--c-purple);
}
.btn-purple.active-toggle {
  background: var(--c-purple);
  color: #0B1120;
  font-weight: 800;
}

.btn-amber {
  background: rgba(251, 191, 36, 0.16);
  border-color: var(--c-amber);
  color: var(--c-amber);
}

/* ====================================================================
   3. FLUID GRID, CARDS & SEMANTIC BADGES
   ==================================================================== */
.app-container {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 12px;
}

.grid-fluid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

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

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

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}

.sem-blue { color: var(--c-blue); background: var(--c-blue-dim); border: 1px solid rgba(56, 189, 248, 0.35); }
.sem-purple { color: var(--c-purple); background: var(--c-purple-dim); border: 1px solid rgba(192, 132, 252, 0.35); }
.sem-green { color: var(--c-green); background: var(--c-green-dim); border: 1px solid rgba(52, 211, 153, 0.35); }
.sem-red { color: var(--c-red); background: var(--c-red-dim); border: 1px solid rgba(251, 113, 133, 0.35); }
.sem-amber { color: var(--c-amber); background: var(--c-amber-dim); border: 1px solid rgba(251, 191, 36, 0.35); }

.text-blue { color: var(--c-blue) !important; }
.text-purple { color: var(--c-purple) !important; }
.text-green { color: var(--c-green) !important; }
.text-red { color: var(--c-red) !important; }
.text-amber { color: var(--c-amber) !important; }

/* ====================================================================
   4. HEADER & NAVIGASI 6 FILE KONSISTEN
   ==================================================================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px;
}

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--c-blue), var(--c-purple));
  display: grid;
  place-items: center;
  font-weight: 900;
  font-family: var(--font-math);
  font-size: 1.35rem;
  color: #0B1120;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
  flex-shrink: 0;
}

.desktop-nav {
  display: none;
  max-width: 1480px;
  margin: 8px auto 0;
  padding-top: 8px;
  border-top: 1px solid rgba(51, 65, 85, 0.6);
  gap: 6px;
  overflow-x: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-subtle);
}

.nav-link.active {
  color: var(--c-blue);
  background: var(--c-blue-dim);
  border-color: rgba(56, 189, 248, 0.4);
}

.nav-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-main);
}

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-bottom-h);
  background: rgba(11, 17, 32, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  z-index: 120;
  padding: 4px;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 4px 2px;
  text-align: center;
  line-height: 1.1;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.mobile-nav-item.active {
  color: var(--c-blue);
  background: var(--c-blue-dim);
}

/* ====================================================================
   5. KOMPONEN MATRIKS 30 SEL (5x6), WORKBENCH SOAL & MODEL COURTROOM
   ==================================================================== */
.matrix-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}

.mini-matrix-grid {
  display: grid;
  grid-template-columns: 105px repeat(6, minmax(48px, 1fr));
  gap: 5px;
  min-width: 440px;
}

.mini-col-hdr {
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 2px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.mini-row-hdr {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mini-cell-btn {
  min-height: 44px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.mini-cell-btn.active-cell {
  border: 2px solid #FFFFFF !important;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.75);
  transform: scale(1.06);
  z-index: 2;
}

.canvas-stage {
  width: 100%;
  height: 330px;
  background: #070B14;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.canvas-stage canvas {
  width: 100%;
  height: 100%;
}

.options-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.option-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-main);
}

.option-btn:hover {
  border-color: var(--c-blue);
  background: rgba(56, 189, 248, 0.1);
}

.option-btn.correct-choice {
  border-color: var(--c-green) !important;
  background: rgba(52, 211, 153, 0.22) !important;
  color: #fff;
}

.option-btn.wrong-choice {
  border-color: var(--c-red) !important;
  background: rgba(251, 113, 133, 0.22) !important;
  color: #fff;
}

/* Kartu Komparasi Model Courtroom (C5) */
.courtroom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 10px;
  margin: 12px 0;
}

.model-dossier {
  background: #070C17;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.8rem;
}

.model-dossier h4 {
  color: var(--c-blue);
  font-size: 0.9rem;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

.model-dossier .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-family: var(--font-mono);
}

/* Interactive Formula & DAG Builder (C6) */
.formula-slots-stage {
  background: #070C17;
  border: 1px dashed var(--c-purple);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 10px 0;
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.token-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.token-chip {
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid var(--c-blue);
  color: var(--text-main);
}

.token-chip.placed {
  background: rgba(192, 132, 252, 0.24);
  border-color: var(--c-purple);
}

/* Feedback Dekonstruksi Visual */
.deconstruction-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.9);
  border-left: 4px solid var(--c-green);
  display: none;
}

.deconstruction-panel.show {
  display: block;
  animation: fadeSlideIn 0.25s ease-out;
}

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

/* Kalkulator Bantu Mini (C3) */
.mini-calc-box {
  background: #070C17;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
}

/* Toast Notification */
#toastNotification {
  position: fixed;
  bottom: 84px;
  right: 16px;
  z-index: 999;
  background: #0F172A;
  border: 1px solid var(--c-green);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.25s ease;
}
#toastNotification.show {
  opacity: 1;
  transform: translateY(0);
}

/* ====================================================================
   6. PROGRESSIVE MEDIA QUERIES (TABLET, LAPTOP, ULTRA-WIDE)
   ==================================================================== */
@media (min-width: 768px) {
  .app-container {
    padding: 20px;
  }
  .card {
    padding: 22px;
  }
  .section-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 1024px) {
  body {
    padding-bottom: 40px;
  }
  .desktop-nav {
    display: flex;
  }
  .mobile-bottom-nav {
    display: none;
  }
  .grid-control-layout {
    grid-template-columns: 1.25fr 0.75fr;
  }
  .grid-workbench {
    grid-template-columns: 1.02fr 0.98fr;
  }
  #toastNotification {
    bottom: 24px;
  }
}

@media (min-width: 1440px) {
  .app-container {
    padding: 28px 32px;
  }
  .canvas-stage {
    height: 370px;
  }
}
