:root {
  --bg: #f3f5fa;
  --bg-accent: #e9effd;
  --surface: #ffffff;
  --surface-subtle: #f6f8fc;
  --surface-dark: #0f172a;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --indigo-soft: #eef2ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-bento: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -14px rgba(15, 23, 42, 0.12);
  --shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.06), 0 16px 32px -12px rgba(37, 99, 235, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(900px 420px at 10% -5%, rgba(37, 99, 235, 0.08), transparent 60%),
    radial-gradient(760px 380px at 95% 0%, rgba(16, 185, 129, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Floating Bento Topbar */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  padding: 12px 0 0;
}

.topbar-inner {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-bento);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 6px 14px -4px rgba(37, 99, 235, 0.45);
}

.brand-sub {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--primary-hover);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 10px 17px;
  font-size: 0.89rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, border-color 0.14s ease;
  font-family: inherit;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, 0.55);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 8px 20px -6px rgba(37, 99, 235, 0.65);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: rgba(15, 23, 42, 0.22);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #fff;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecdd3;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.81rem;
  border-radius: 9px;
}

/* Bento Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-bento);
}

.bento-tile-soft {
  background: linear-gradient(155deg, #ffffff 0%, #f5f8ff 100%);
}

.bento-tile-dark {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.08);
}

.bento-tile-dark .muted {
  color: #94a3b8;
}

.main-wrap {
  padding: 24px 0 64px;
}

/* Gate / Login Bento Split */
.gate-wrap {
  margin: 22px auto 0;
}

.gate-wrap-single {
  max-width: 460px;
  margin: 40px auto 0;
}

.bento-gate-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 18px;
  align-items: stretch;
}

.bento-hero-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: 30px;
}

.bento-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bento-feature-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px;
}

.bento-feature-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.bento-feature-label {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.gate-title {
  margin: 0 0 6px;
  font-size: 1.45rem;
  letter-spacing: -0.025em;
}

.muted {
  color: var(--muted);
  font-size: 0.91rem;
}

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  font-size: 0.93rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-subtle);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

/* Asymmetric Bento Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  grid-column: span 4;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-bento);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card-wide {
  grid-column: span 5;
}

.stat-card-mid {
  grid-column: span 4;
}

.stat-card-accent {
  grid-column: span 3;
  background: linear-gradient(145deg, #eff6ff 0%, #eef2ff 100%);
  border-color: #dbeafe;
}

.stat-label {
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  margin: 6px 0 10px;
  letter-spacing: -0.03em;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-subtle);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb 0%, #4f46e5 100%);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* Segmented Bento Pill Tabs */
.tabs-dock {
  margin-bottom: 18px;
  overflow-x: auto;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: rgba(15, 23, 42, 0.055);
  border: 1px solid var(--border);
  border-radius: 15px;
  margin-bottom: 18px;
  max-width: 100%;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 11px;
  padding: 9px 16px;
  font-size: 0.89rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.16s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* Bento Split Panels */
.split-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.bento-setup-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: 16px;
  align-items: start;
}

.bento-side-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.bento-side-item {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.86rem;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chapter-item {
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.chapter-item:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-bento);
}

.chapter-item.active {
  border-color: #93c5fd;
  background: linear-gradient(145deg, #eff6ff 0%, #f5f3ff 100%);
  box-shadow: var(--shadow-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  background: var(--surface-subtle);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: #a7f3d0;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecdd3;
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #fde68a;
}

/* Prose & Reading Content */
.prose h3 {
  font-size: 1.07rem;
  margin: 20px 0 8px;
  letter-spacing: -0.01em;
}

.prose p {
  margin: 0 0 12px;
}

.prose ul {
  margin: 0 0 14px;
  padding-left: 20px;
}

.prose li {
  margin-bottom: 6px;
}

.prose pre, .stimulus-box {
  background: #0f172a;
  color: #f8fafc;
  padding: 14px 16px;
  border-radius: 14px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 10px 0 14px;
  white-space: pre-wrap;
}

.prose code {
  background: #eef2ff;
  color: #1e3a8a;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.86em;
}

.prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

.callout {
  border-radius: 14px;
  padding: 13px 16px;
  margin: 12px 0 16px;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}

.callout-tip {
  background: var(--primary-soft);
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.callout-warn {
  background: var(--warn-soft);
  border-color: #fde68a;
  color: #78350f;
}

.callout-success {
  background: var(--success-soft);
  border-color: #a7f3d0;
  color: #065f46;
}

.review-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 0.89rem;
}

.review-opt-key {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.78rem;
}

.review-opt-right {
  background: var(--success-soft);
  border-color: #a7f3d0;
}

.review-opt-wrong {
  background: var(--danger-soft);
  border-color: #fecdd3;
}

.prose table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0 18px;
  font-size: 0.89rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.prose th, .prose td {
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}

.prose tr:last-child td {
  border-bottom: none;
}

.prose th {
  background: var(--surface-subtle);
  color: var(--text);
  font-weight: 700;
  text-transform: none;
  font-size: 0.85rem;
}

/* Quiz Runner */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  width: 100%;
  background: var(--surface-subtle);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 0.94rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: all 0.14s ease;
}

.option-btn:hover {
  border-color: #93c5fd;
  background: var(--primary-soft);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.option-key {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.82rem;
}

.option-btn.selected .option-key {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nav-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.dot-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.dot-btn.answered {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.dot-btn.current {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(246, 248, 252, 0.7);
}

th {
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-subtle);
  font-weight: 700;
}

/* Alerts & Modals */
.alert {
  padding: 12px 15px;
  border-radius: 13px;
  font-size: 0.89rem;
  margin-bottom: 14px;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecdd3;
}

.alert-info {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border: 1px solid #bfdbfe;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.28);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
}

/* Kisi-Kisi Bento Grid */
.kk-summary-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.kk-mini-stat {
  grid-column: span 4;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}

.kk-mini-stat-accent {
  background: linear-gradient(145deg, #eff6ff 0%, #eef2ff 100%);
  border-color: #dbeafe;
}

.kk-mini-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
}

.kk-topic-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .bento-gate-grid, .bento-setup-grid, .split-layout {
    grid-template-columns: 1fr;
  }
  .stat-card, .stat-card-wide, .stat-card-mid, .stat-card-accent, .kk-mini-stat {
    grid-column: span 12;
  }
  .bento-feature-grid, .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media print {
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .card {
    box-shadow: none;
    break-inside: avoid;
  }
}
