/* ==========================================================================
   AI SECURITY SIMULATOR — PREMIUM LIGHT SAAS DASHBOARD
   --------------------------------------------------------------------------
   Design language: polished, product-grade light dashboard. Layered depth
   instead of flat gray: soft gradient canvas with drifting color blooms,
   frosted glass surfaces, gradient accents, refined hairlines, glow states.
   One primary accent (indigo) + semantic green/amber/red. No neon, no
   beveled "command deck" gimmicks, no dark terminal chrome.

   All class / variable names that module JS depends on are preserved.
   Layout constants --sidebar-w / --sidebar-min / --topbar-h are pinned and
   asserted by the automated smoke + layout tests.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

:root {
  /* Layout constants (keep — tests depend on values) */
  --sidebar-w: 256px;
  --sidebar-min: 64px;
  --topbar-h: 52px;

  /* Surfaces — light neutral scale */
  --bg: #f6f7fb;
  --bg2: #ffffff;
  --bg3: #f2f3f9;
  --bg4: #e9ebf4;
  --bg-input: #ffffff;

  --border: #e7e9f2;
  --border-strong: #d5d9e8;

  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;

  /* Accents — graphite chrome with warm copper primary */
  --primary: #b45309;
  --primary-hover: #92400e;
  --primary-soft: #fffbeb;
  --primary-soft-2: #fef3c7;
  --primary-ink: #ffffff;
  --primary-grad: linear-gradient(135deg, #d97706, #b45309 55%, #92400e);
  --secondary: #f8fafc;
  --accent: #10b981;
  --accent-bright: #34d399;
  --accent-ink: #ffffff;
  --accent-hover: #059669;
  --red: #ef4444;
  --amber: #f59e0b;
  --orange: #f97316;
  --cyan: #d97706;
  --purple: #334155;
  --violet: #334155;

  /* Module accent colors (used sparingly) */
  --m0: #b45309;
  --m1: #10b981;
  --m2: #f97316;
  --m3: #eab308;
  --m4: #ef4444;
  --m5: #475569;

  /* Geometry & type */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --font: 'Instrument Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Instrument Sans', 'Inter', sans-serif;
  --font-hero: 'Space Grotesk', 'Instrument Sans', sans-serif;
  --mono: 'IBM Plex Mono', 'JetBrains Mono', Consolas, monospace;

  --ease: cubic-bezier(.25, .8, .25, 1);
  --ease-spring: cubic-bezier(.22, 1.4, .36, 1);

  /* Layered, soft, diffuse shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .14);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .05), 0 20px 48px -20px rgba(15, 23, 42, .22);
  --shadow-tag: 0 1px 2px rgba(15, 23, 42, .08);
  --glow: 0 10px 28px -10px rgba(180, 83, 9, .45);
  --bevel: inset 0 1px 0 rgba(255, 255, 255, .8);
  --toplight: linear-gradient(180deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, 0) 46%);
  --inset-top: inset 0 1px 0 rgba(255, 255, 255, .65);

  /* Gradient canvas blooms (drift slowly) */
  --bloom-a: radial-gradient(900px 520px at 8% -6%, rgba(217, 119, 6, .16), transparent 60%);
  --bloom-b: radial-gradient(760px 460px at 92% 4%, rgba(146, 64, 14, .13), transparent 62%);
  --bloom-c: radial-gradient(700px 480px at 78% 118%, rgba(16, 185, 129, .12), transparent 62%);
}

html {
  font-size: 16px
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline
}

::selection {
  background: rgba(180, 83, 9, .16);
  color: var(--text)
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px
}

/* Ambient scene — soft gradient blooms + faint grid */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    var(--bloom-c),
    var(--bloom-b),
    var(--bloom-a),
    linear-gradient(180deg, #fbfbfe 0%, var(--bg) 40%);
}

.bg-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(15, 23, 42, .045) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(120% 100% at 50% 0%, rgba(0, 0, 0, .9), rgba(0, 0, 0, .35) 60%, transparent 100%);
  -webkit-mask-image: radial-gradient(120% 100% at 50% 0%, rgba(0, 0, 0, .9), rgba(0, 0, 0, .35) 60%, transparent 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  width: 100%;
  display: block
}

/* SVG icon sizing */
svg.icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: currentColor
}

svg.icon-lg {
  width: 16px;
  height: 16px
}

svg.icon-sm {
  width: 12px;
  height: 12px
}

/* === APP SHELL === */

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, .4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease);
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

body.sb-open {
  overflow: hidden !important;
  touch-action: none;
}

/* Sidebar — Off-canvas fixed drawer by default on mobile/tablet */
.sidebar {
  display: none !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  height: 100vh !important;
  height: 100dvh !important;
  z-index: 99999 !important;
  width: 280px;
  max-width: 85vw;
  margin: 0 !important;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--border-strong);
}

.sidebar.open {
  display: flex !important;
  box-shadow: 24px 0 60px -24px rgba(15, 23, 42, .3);
}

.side-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
  height: 100%;
  width: 100%;
}

/* Sidebar Brand Header */
.side-brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.side-brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px;
  cursor: pointer;
  background: transparent;
  transition: background .12s;
}

.side-brand:hover {
  background: var(--bg3)
}

.sidebar-mobile-close {
  display: inline-flex;
  margin-right: 10px;
  flex-shrink: 0;
}

.side-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--primary-grad);
  border: 1px solid rgba(180, 83, 9, .35);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(180, 83, 9, .5);
}

.side-brand-mark svg {
  width: 17px;
  height: 17px
}

.side-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0
}

.side-brand-title {
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.side-brand-sub {
  font-family: var(--mono);
  font-size: .56rem;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: .1em;
  text-transform: uppercase
}

.side-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px
}

.side-nav::-webkit-scrollbar {
  width: 4px
}

.side-nav::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px
}

.side-nav-divider {
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 18px 12px 8px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text2);
  text-align: left;
  transition: background .12s, color .12s, border-color .12s;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text)
}

.nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px
}

.nav-item .nav-item-icon {
  display: flex;
  flex-shrink: 0;
  color: var(--text3);
  transition: color .12s
}

.nav-item .nav-item-icon svg {
  width: 16px;
  height: 16px
}

.nav-item:hover .nav-item-icon {
  color: var(--text2)
}

.nav-item .nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .01em
}

.nav-item.active {
  background: linear-gradient(90deg, var(--primary-soft), var(--primary-soft-2));
  color: var(--primary);
  border-color: rgba(180, 83, 9, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

.nav-item.active .nav-item-icon {
  color: var(--primary)
}

.nav-item.active .nav-item-label {
  font-weight: 700
}

.nav-item.nav-theory .nav-item-icon {
  color: var(--violet)
}

.nav-item.nav-theory.active {
  background: linear-gradient(90deg, #fffbeb, #fef3c7);
  color: var(--violet);
  border-color: rgba(146, 64, 14, .25)
}

.nav-item.nav-theory.active .nav-item-icon {
  color: var(--violet)
}

.nav-chip {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}

.nav-chip.chip-part {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a
}

.nav-chip.chip-done {
  color: #047857;
  background: #d1fae5;
  border-color: #a7f3d0
}

.side-footer {
  border-top: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.side-audit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  cursor: pointer;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  color: var(--text2);
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}

.side-audit:hover {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border-strong)
}

.side-audit .icon {
  color: var(--primary)
}

/* Main column — always 100% full width */
.main-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-left: 0 !important;
  transition: margin-left .18s var(--ease)
}

/* Topbar — frosted glass bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid rgba(15, 23, 42, .07);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .7);
  color: var(--text2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}

.icon-btn:hover {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow)
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor
}

.sidebar-toggle {
  display: inline-flex
}

/* Minimized sidebar (icon rail) */
@media(min-width:1200px) {
  .app-shell {
    display: flex
  }

  .sidebar {
    display: flex !important;
    position: sticky !important;
    top: 0 !important;
    height: 100vh !important;
    width: var(--sidebar-w) !important;
    max-width: none !important;
    transform: none !important;
    box-shadow: none !important;
    z-index: 60 !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .sidebar-mobile-close {
    display: none !important
  }

  .sidebar-toggle {
    display: none !important
  }

  .main-wrap {
    width: auto !important;
    flex: 1 !important
  }

  body.sb-min {
    --sidebar-w: var(--sidebar-min)
  }

  body.sb-min .side-brand {
    padding: 16px 8px;
    justify-content: center
  }

  body.sb-min .side-brand-text {
    display: none
  }

  body.sb-min .side-nav {
    padding: 14px 8px
  }

  body.sb-min .side-nav-divider {
    height: 1px;
    padding: 0;
    margin: 10px 8px;
    overflow: hidden;
    font-size: 0;
    background: var(--border);
    border-radius: 0
  }

  body.sb-min .nav-item {
    justify-content: center;
    padding: 11px 4px
  }

  body.sb-min .nav-item .nav-item-label,
  body.sb-min .nav-item .nav-chip {
    display: none
  }

  body.sb-min .nav-item .nav-item-icon svg {
    width: 18px;
    height: 18px
  }

  body.sb-min .side-footer {
    padding: 12px 8px
  }

  body.sb-min .side-audit {
    justify-content: center;
    padding: 10px 4px
  }

  body.sb-min .side-audit span {
    display: none
  }
}

.breadcrumb {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text3);
  overflow: hidden;
  white-space: nowrap
}

.breadcrumb .sep {
  color: var(--text3);
  opacity: .6;
  margin: 0 2px
}

.breadcrumb .crumb {
  color: var(--text3);
  transition: color .12s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500
}

.breadcrumb .crumb.current {
  color: var(--text);
  font-weight: 700
}

.breadcrumb .crumb.clickable {
  cursor: pointer
}

.breadcrumb .crumb.clickable:hover {
  color: var(--primary)
}

.topbar-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-left: 16px;
  border-left: 1px solid var(--border)
}

.topbar-progress .icon {
  color: var(--text3)
}

.topbar-progress-count {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap
}

.topbar-track {
  width: 90px;
  flex: none;
  height: 6px
}

.topbar-track .progress-fill {
  background: linear-gradient(90deg, #d97706, #92400e)
}

/* === LAYOUT === */
.content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto
}

.page {
  display: none;
  padding: 26px 30px 64px;
  animation: pageIn .25s var(--ease) both
}

.page.active {
  display: block
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* === HERO === */
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(255, 251, 235, .9);
  border: 1px solid rgba(253, 230, 138, .9);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  line-height: 1;
}

.hero {
  padding: 4px 0 20px
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.015em;
  margin-bottom: 5px;
  line-height: 1.2;
  background: linear-gradient(120deg, #0f172a 12%, #b45309 72%, #92400e);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--text);
}

.hero p {
  color: var(--text2);
  font-size: .88rem;
  max-width: 680px
}

/* === SUB-TABS (per module) === */
.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.sub-tab {
  padding: 9px 15px;
  cursor: pointer;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  transition: color .12s, background .12s, border-color .12s;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  border-radius: 8px 8px 0 0;
}

.sub-tab:hover {
  color: var(--text);
  background: var(--bg3)
}

.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: linear-gradient(180deg, var(--primary-soft), transparent)
}

.sub-tab .tab-status {
  display: inline-flex;
  margin-right: 5px;
  vertical-align: middle
}

.summary-caret {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  color: var(--primary)
}

.summary-caret svg {
  width: 11px;
  height: 11px;
  fill: currentColor
}

/* === SCENARIO CONTENT === */
.scenario {
  display: none
}

.scenario.active {
  display: block;
  animation: scenarioIn .2s var(--ease) both
}

@keyframes scenarioIn {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.scenario h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -.005em
}

.scenario .desc {
  color: var(--text2);
  font-size: .86rem;
  margin-bottom: 18px;
  line-height: 1.7
}

/* === QUESTIONS === */
.q-group {
  position: relative;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.q-group::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  background: linear-gradient(180deg, #d97706, #92400e);
  border-radius: 3px;
}

.q-group:focus-within {
  border-color: rgba(180, 83, 9, .4);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, .08), var(--shadow-sm)
}

.q-group .q-text {
  font-weight: 700;
  margin-bottom: 10px;
  font-size: .92rem;
  color: var(--text);
  letter-spacing: .01em
}

.q-group .q-hint {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--text3);
  margin-bottom: 12px;
  letter-spacing: .02em
}

.q-group input[type="text"],
.q-group textarea,
.q-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: .88rem;
  font-family: var(--mono);
  letter-spacing: .01em;
  transition: border-color .12s, box-shadow .12s;
}

.q-group textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6
}

.q-group input[type="text"]:focus,
.q-group textarea:focus,
.q-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, .12);
}

.q-group input[type="text"]::placeholder,
.q-group textarea::placeholder {
  color: var(--text3)
}

.q-group select {
  cursor: pointer
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 7px
}

.radio-group label,
.cb-group label {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .1s, border-color .1s;
  font-size: .86rem;
  color: var(--text2);
  background: var(--bg2);
  font-weight: 500;
}

.radio-group label:hover,
.cb-group label:hover {
  background: var(--bg3);
  border-color: var(--border-strong)
}

.radio-group input[type="radio"],
.cb-group input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px
}

.radio-group label.correct {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: var(--text)
}

.radio-group label.incorrect {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--text)
}

.feedback {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  display: none;
  line-height: 1.6;
  font-weight: 500;
  border: 1px solid transparent;
}

.feedback.show {
  display: block;
  animation: feedbackIn .18s var(--ease)
}

@keyframes feedbackIn {
  from {
    opacity: 0;
    transform: translateY(-3px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.feedback.correct {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857
}

.feedback.incorrect {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c
}

.verdict {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: .78rem;
  line-height: 1.5;
  margin-top: 2px
}

.verdict>span {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase
}

.verdict>div {
  font-size: .78rem;
  color: var(--text2)
}

.verdict-blocked {
  color: #15803d
}

.verdict-breached {
  color: #b91c1c
}

.verdict-info {
  color: var(--text3)
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .84rem;
  font-weight: 600;
  font-family: var(--font);
  line-height: 1;
  letter-spacing: .01em;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(2px) scale(.985)
}

.btn-primary:active {
  box-shadow: 0 2px 10px -4px rgba(180, 83, 9, .5)
}

.btn-primary {
  background: linear-gradient(135deg, #d97706, #b45309 55%, #92400e);
  color: var(--primary-ink);
  border-color: rgba(146, 64, 14, .6);
  box-shadow: var(--glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #f59e0b, #b45309 55%, #92400e);
  box-shadow: 0 12px 32px -10px rgba(180, 83, 9, .55)
}

.btn-secondary {
  background: rgba(255, 255, 255, .85);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg3)
}

.btn-sm {
  padding: 8px 16px;
  font-size: .78rem
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0
}

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

/* === SHIELD BUTTONS === */
.shield-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 16px
}

.shield-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg2);
  transition: border-color .1s, background .1s, transform .12s var(--ease), box-shadow .12s;
  font-size: .76rem;
  color: var(--text2);
  font-weight: 700;
  font-family: var(--font);
}

.shield-btn:hover {
  border-color: rgba(217, 119, 6, .4);
  background: var(--bg3)
}

.shield-btn:active {
  background: var(--bg2)
}

.shield-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

.shield-btn.selected {
  border-color: rgba(180, 83, 9, .5);
  background: linear-gradient(180deg, var(--primary-soft), #fafaff);
  color: var(--primary)
}

.shield-btn.correct {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857
}

.shield-btn.correct.selected {
  border-color: #6ee7b7;
  background: #d1fae5
}

/* === RISK RADIO === */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
  max-width: 520px
}

.risk-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg2);
  transition: border-color .1s, background .1s, transform .12s var(--ease), box-shadow .12s;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text2);
  font-family: var(--font);
}

.risk-label:hover {
  border-color: rgba(217, 119, 6, .4);
  background: var(--bg3)
}

.risk-label:active {
  background: var(--bg2)
}

.risk-label:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

.risk-label input[type="radio"] {
  accent-color: var(--primary)
}

.risk-label.selected {
  border-color: rgba(180, 83, 9, .5);
  background: linear-gradient(180deg, var(--primary-soft), #fafaff);
  color: var(--primary)
}

.risk-label.correct {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857
}

.risk-label.incorrect {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c
}

/* === REALISTIC CHATBOT UI === */
.chat-box {
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  max-height: 460px;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), var(--shadow-sm);
}

.chat-msg {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  max-width: 88%;
  font-size: .85rem;
  line-height: 1.55;
  animation: msgIn .18s var(--ease-spring);
  border: 1px solid var(--border)
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.chat-msg.bot {
  background: var(--bg2);
  align-self: flex-start;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chat-msg.user {
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border-color: rgba(217, 119, 6, .35);
  align-self: flex-end;
  color: var(--text);
  margin-left: auto;
}

.chat-msg .msg-label {
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 5px
}

.chat-msg.bot .msg-label {
  color: var(--primary)
}

.chat-msg.user .msg-label {
  color: var(--primary)
}

.chat-msg .msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em
}

.chat-msg.bot .msg-header {
  color: var(--primary)
}

.chat-msg.user .msg-header {
  color: var(--primary)
}

.chat-msg .msg-body {
  font-size: .82rem;
  white-space: pre-wrap;
  word-break: break-word
}

.inline-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: -2px
}

.inline-icon svg {
  width: 13px;
  height: 13px;
  fill: currentColor
}

.inline-icon.file-icon {
  color: var(--primary)
}

.inline-icon.chat-icon {
  color: var(--violet)
}

.chat-msg .msg-badge {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.chat-msg .msg-badge.breached {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca
}

.chat-msg .msg-badge.blocked {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0
}

.chat-input-row {
  display: flex;
  gap: 9px
}

.chat-input-row input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-size: .86rem;
  font-family: var(--mono);
  transition: border-color .12s, box-shadow .12s;
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, .12)
}

.thinking {
  opacity: .6;
  animation: thinkPulse 1.4s steps(2, end) infinite
}

@keyframes thinkPulse {

  0%,
  100% {
    opacity: .35
  }

  50% {
    opacity: .85
  }
}

/* === MATCHING TABLES === */
.match-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  font-size: .82rem
}

.match-table th,
.match-table td {
  padding: 11px 14px;
  border: 1px solid var(--border);
  text-align: left
}

.match-table th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 700;
  font-size: .76rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em
}

.match-table select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-size: .8rem;
  font-family: var(--mono)
}

.match-table select:focus {
  outline: none;
  border-color: var(--primary)
}

/* === PROGRESS === */
.progress-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border)
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px
}

.progress-track {
  flex: 1;
  height: 8px;
  background: rgba(15, 23, 42, .07);
  border: 1px solid rgba(15, 23, 42, .05);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #92400e);
  transition: width .4s var(--ease);
  width: 0%;
  border-radius: var(--radius-pill);
}

.progress-label {
  font-size: .78rem;
  color: var(--text2);
  min-width: 100px;
  font-weight: 700;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em
}

.progress-pct {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--text3);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.status-badge.completed {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0
}

.status-badge.partial {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a
}

.status-badge.pending {
  background: var(--bg3);
  color: var(--text3);
  border: 1px solid var(--border)
}

/* === DASHBOARD === */
.dashboard-hero {
  padding: 6px 0 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
}

.dashboard-hero h1 {
  font-family: var(--font-hero);
  font-size: clamp(1.9rem, 3vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.08;
  color: var(--text);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-fill-color: initial;
}

.dashboard-hero p {
  color: var(--text2);
  font-size: .88rem;
  margin-top: 6px
}

.hero-chip-wrap {
  display: flex;
  gap: 8px;
  padding-top: 6px
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text2);
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  box-shadow: var(--shadow-sm);
}

.hero-chip-live {
  color: #047857;
  border-color: #a7f3d0;
  background: rgba(236, 253, 245, .85)
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, .5);
  animation: livePulse 2.2s ease-in-out infinite
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .45)
  }

  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0)
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0)
  }
}

.dash-overall {
  margin-bottom: 20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 251, 235, .6), rgba(255, 255, 255, .92));
  border: 1px solid rgba(217, 119, 6, .18);
  box-shadow: var(--shadow);
}

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

.dash-overall .overall-header .label {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--text2)
}

.dash-overall .overall-header .count {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 700
}

.dash-overall .overall-track {
  height: 10px;
  background: rgba(15, 23, 42, .07);
  border: 1px solid rgba(15, 23, 42, .05);
  border-radius: var(--radius-pill);
  overflow: hidden
}

.dash-overall .overall-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #92400e, #92400e);
  transition: width .5s var(--ease);
  width: 0%;
  border-radius: var(--radius-pill)
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
  gap: 16px
}

.dash-card {
  position: relative;
  cursor: pointer;
  padding: 18px 20px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
  animation: cardIn .5s var(--ease) backwards;
  overflow: hidden;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.dash-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(90deg, #d97706, #92400e);
  opacity: 0;
  transition: opacity .2s var(--ease);
  border-radius: var(--radius) var(--radius) 0 0;
}

.dash-card:hover::before {
  opacity: 1
}

.dash-card:hover {
  border-color: rgba(217, 119, 6, .35)
}

.dash-card-theory {
  grid-column: 1/-1;
  border-color: rgba(217, 119, 6, .22);
  background: linear-gradient(120deg, rgba(255, 251, 235, .75), rgba(255, 255, 255, .95) 55%);
}

.dash-card-theory .card-header h3 .icon {
  color: var(--primary)
}

.dash-card-theory .theory-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px
}

.dash-card-theory .card-scenario-item {
  flex: 0 0 auto
}

.dash-card-theory .card-progress {
  margin-bottom: 10px
}

.dash-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

.dash-card .card-header {
  margin-bottom: 4px
}

.dash-card .card-header h3 {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: .01em;
}

.dash-card .card-header h3 .icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
  color: var(--primary)
}

.dash-card .card-header h3 .icon.icon-lg {
  width: 16px;
  height: 16px
}

.dash-card .card-header h3 .card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  color: var(--primary);
  border-radius: var(--radius-sm);
}

.dash-card.mod-1 .card-icon {
  color: #047857;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-color: #a7f3d0
}

.dash-card.mod-2 .card-icon {
  color: #c2410c;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border-color: #fed7aa
}

.dash-card.mod-3 .card-icon {
  color: #a16207;
  background: linear-gradient(135deg, #fefce8, #fef9c3);
  border-color: #fef08a
}

.dash-card.mod-4 .card-icon {
  color: #b91c1c;
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border-color: #fecaca
}

.dash-card.mod-5 .card-icon {
  color: #475569;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border-color: #cbd5e1
}

.dash-card.mod-1::before {
  background: linear-gradient(90deg, #34d399, #059669)
}

.dash-card.mod-2::before {
  background: linear-gradient(90deg, #fb923c, #ea580c)
}

.dash-card.mod-3::before {
  background: linear-gradient(90deg, #facc15, #ca8a04)
}

.dash-card.mod-4::before {
  background: linear-gradient(90deg, #f87171, #dc2626)
}

.dash-card.mod-5::before {
  background: linear-gradient(90deg, #64748b, #334155)
}

.dash-card .card-progress {
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--text3);
  margin-bottom: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em
}

.dash-card .card-scenario-list {
  display: flex;
  flex-direction: column;
  gap: 3px
}

.dash-card .card-scenario-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .76rem;
  color: var(--text2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.dash-card .card-scenario-item:hover {
  background: var(--bg3)
}

.card-goal {
  font-size: .74rem;
  color: var(--text3);
  line-height: 1.55;
  margin-bottom: 10px
}

.card-footer {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-tag {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  white-space: nowrap
}

.card-cta {
  font-size: .72rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  transition: transform .15s var(--ease), opacity .15s
}

.dash-card:hover .card-cta {
  opacity: .9;
  transform: translateX(3px)
}

/* === RESULTS === */
.results-summary {
  background: linear-gradient(180deg, rgba(255, 251, 235, .5), rgba(255, 255, 255, .95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  margin-top: 26px;
  box-shadow: var(--shadow);
}

.results-summary h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 6px
}

.results-summary .grade {
  font-size: 3.4rem;
  font-weight: 800;
  margin: 12px 0;
  letter-spacing: -.02em;
  font-family: var(--font-display);
  background: linear-gradient(120deg, #b45309, #92400e);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.results-summary .grade.S {
  background: linear-gradient(120deg, #059669, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent
}

.results-summary .grade.A {
  background: linear-gradient(120deg, #b45309, #92400e);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent
}

.results-summary .grade.B {
  background: linear-gradient(120deg, #f97316, #fb923c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent
}

.results-summary .grade.C {
  background: linear-gradient(120deg, #d97706, #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent
}

.results-summary .grade.D {
  background: linear-gradient(120deg, #dc2626, #f87171);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent
}

.results-summary .score-text {
  color: var(--text2);
  font-size: .86rem
}

.results-summary .btn {
  margin-top: 16px
}

/* === ATTACK SUBMIT BOX === */
.attack-box {
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.attack-box h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px
}

.attack-box .desc {
  margin-bottom: 14px;
  font-size: .82rem;
  color: var(--text2)
}

.attack-box pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: .74rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
  width: 9px;
  height: 9px
}

::-webkit-scrollbar-track {
  background: transparent
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg)
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text3)
}

/* === RESPONSIVE & MOBILE OPTIMIZATIONS === */
@media(max-width:1199.98px) {

  html,
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative;
  }

  .app-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .sidebar {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    z-index: 99999 !important;
    background: rgba(255, 255, 255, .98);
    border-right: none !important;
    transform: none !important;
    box-shadow: none !important;
  }

  .sidebar.open {
    display: flex !important;
    animation: mobileNavFade 0.18s ease-out;
  }

  @keyframes mobileNavFade {
    from {
      opacity: 0;
      transform: scale(0.98);
    }

    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  .sidebar-mobile-close {
    display: inline-flex !important;
  }

  .side-inner {
    position: relative !important;
    height: 100% !important;
    width: 100% !important;
  }

  .main-wrap {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-x: hidden !important;
  }

  .sidebar-toggle {
    display: inline-flex !important
  }

  .sidebar-minimize {
    display: none !important
  }

  .topbar-progress {
    display: none !important
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important
  }

  .content {
    max-width: none !important;
    width: 100% !important;
    overflow-x: hidden !important
  }
}

@media(max-width:768px) {
  .shield-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .risk-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .chat-msg {
    max-width: 95%
  }

  .page {
    padding: 16px 14px 44px
  }

  .topbar {
    padding: 0 12px;
    gap: 8px
  }

  .breadcrumb {
    max-width: 180px;
    font-size: .72rem
  }

  .dashboard-hero {
    padding: 16px 0
  }

  .dashboard-hero h1 {
    font-size: 1.5rem
  }

  .sub-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sub-tabs::-webkit-scrollbar {
    display: none
  }

  .sub-tab {
    padding: 8px 12px;
    font-size: .74rem;
    flex-shrink: 0
  }

  .theory-glossary-grid {
    grid-template-columns: 1fr
  }

  .theory-code,
  .colang-code,
  .attack-box pre,
  code {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-content {
    width: calc(100% - 24px);
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 16px;
  }
}

@media(max-width:480px) {
  .page {
    padding: 12px 10px 36px
  }

  .topbar {
    padding: 0 8px;
    gap: 6px
  }

  .breadcrumb {
    max-width: 130px
  }

  .dashboard-hero h1 {
    font-size: 1.3rem
  }

  .home-hero h1 {
    font-size: 1.8rem
  }

  .home-stat b {
    font-size: 1.4rem
  }

  .nav-item {
    padding: 10px
  }

  .btn {
    padding: 8px 14px;
    font-size: .74rem
  }
}

/* === REDUCED MOTION === */
@media(prefers-reduced-motion:reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transform: none !important;
    scroll-behavior: auto !important
  }

  .bg-scene {
    display: none
  }
}

/* === COLANG ACCORDION PANEL === */
.colang-panel {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
  box-shadow: var(--shadow-sm)
}

.colang-panel-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, .9);
  cursor: pointer;
  user-select: none;
  transition: background .12s
}

.colang-panel-header:hover {
  background: var(--bg3)
}

.colang-panel-badge {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  white-space: nowrap;
}

.colang-panel-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text);
  flex: 1
}

.colang-panel-sub {
  font-size: .74rem;
  color: var(--text3);
  margin-left: 4px
}

.colang-chevron {
  transition: transform .18s var(--ease);
  color: var(--text3);
  flex-shrink: 0
}

.colang-panel.open .colang-chevron {
  transform: rotate(180deg)
}

.colang-panel-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s var(--ease)
}

.colang-panel.open .colang-panel-body {
  max-height: 1400px
}

.colang-panel-inner {
  padding: 16px
}

.colang-panel-desc {
  font-size: .78rem;
  color: var(--text2);
  margin-bottom: 14px;
  line-height: 1.6
}

.colang-panel-desc strong {
  color: var(--text)
}

.colang-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 4px
}

.colang-compare-label {
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px
}

.colang-code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: .72rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

@media(max-width:700px) {
  .colang-compare {
    grid-template-columns: 1fr
  }
}

/* === LLM GUARD VERDICT CARD === */
.guard-step {
  margin: 7px 0;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: .78rem;
  box-shadow: var(--shadow-sm);
  animation: msgIn .2s var(--ease) both;
}

.guard-step-header {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700
}

.guard-step-icon {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .68rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg3);
}

.guard-step-icon.checking {
  color: var(--amber);
  border-color: #fcd34d;
  animation: pulse 1s steps(2, end) infinite
}

.guard-step-icon.safe {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5
}

.guard-step-icon.threat {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .45
  }
}

.guard-step-label {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase
}

.guard-step-label.checking {
  color: var(--amber)
}

.guard-step-label.safe {
  color: #047857
}

.guard-step-label.threat {
  color: #b91c1c
}

.guard-threat-badge {
  font-family: var(--mono);
  font-size: .6rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em
}

.guard-conf-badge {
  font-family: var(--mono);
  font-size: .6rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em
}

.guard-conf-badge.high {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca
}

.guard-conf-badge.medium {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a
}

.guard-conf-badge.low {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border-strong)
}

.guard-reasoning {
  color: var(--text2);
  font-size: .75rem;
  line-height: 1.45;
  margin-top: 2px
}

/* === GUARDRAIL TOGGLE CONTROL === */
.guard-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.guard-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.guard-toggle-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text)
}

.guard-toggle-desc {
  font-size: .73rem;
  color: var(--text3)
}

.switch-label {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  flex-shrink: 0
}

.switch-label input {
  opacity: 0;
  width: 0;
  height: 0
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-strong);
  transition: background .12s;
  border-radius: var(--radius-pill);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: transform .15s var(--ease-spring);
  border-radius: 50%;
  box-shadow: var(--shadow-tag)
}

input:checked+.slider {
  background-color: var(--primary)
}

input:checked+.slider:before {
  transform: translateX(22px)
}

/* === MODAL & AUDIT LOG UI === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.open {
  display: flex;
  animation: modalIn .15s var(--ease)
}

@keyframes modalIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.modal-content {
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.audit-entry {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  margin-bottom: 9px;
  font-size: .76rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audit-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700
}

.audit-tag {
  font-family: var(--mono);
  font-size: .58rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase
}

.audit-tag.GUARD_EVALUATION {
  background: #fffbeb;
  color: var(--primary);
  border: 1px solid #fde68a
}

.audit-tag.BYPASS_SUCCESS {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca
}

.audit-tag.CHAT_RESPONSE {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0
}

/* === THEORY HANDBOOK === */
.theory-part {
  display: flex;
  flex-direction: column;
  gap: 14px
}

/* Sticky part selector (sits below the topbar) */
.theory-part-tabs {
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
  background: rgba(246, 247, 251, .88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  margin: 0 -30px 18px;
  padding: 12px 30px 0;
  overflow-x: auto;
  scrollbar-width: none
}

.theory-part-tabs::-webkit-scrollbar {
  display: none
}

.theory-part-header {
  padding: 18px 22px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm)
}

.theory-part-header h2 {
  font-family: var(--font-display);
  color: var(--primary);
  font-size: 1.25rem;
  margin-bottom: 6px
}

.theory-part-header p {
  color: var(--text2);
  font-size: .85rem;
  line-height: 1.65;
  max-width: 900px
}

/* Beginner quick-start glossary */
.theory-glossary {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm)
}

.theory-glossary summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 17px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font)
}

.theory-glossary-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0
}

.theory-glossary-head svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  color: var(--primary);
  flex-shrink: 0
}

.theory-glossary summary::-webkit-details-marker {
  display: none
}

.theory-glossary summary:hover {
  background: var(--bg3)
}

.theory-glossary[open] summary {
  border-bottom: 1px dashed var(--border)
}

.theory-glossary[open] .theory-chapter-toggle {
  transform: rotate(180deg)
}

.theory-glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1px;
  background: var(--border)
}

.theory-glossary-item {
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 15px
}

.theory-glossary-term {
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--mono)
}

.theory-glossary-def {
  font-size: .78rem;
  color: var(--text2);
  line-height: 1.6
}

/* Chapter jump bar (sticky under the part tabs) */
.theory-toc {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: sticky;
  top: calc(var(--topbar-h) + 49px);
  z-index: 89;
  box-shadow: var(--shadow-sm);
}

.theory-toc-label {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-right: 2px
}

.theory-toc-chip {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  cursor: pointer;
  font-family: var(--mono);
  transition: background .12s, color .12s, border-color .12s;
}

.theory-toc-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--glow)
}

.theory-toc-toggle {
  margin-left: auto;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: var(--mono);
  text-transform: uppercase
}

.theory-toc-toggle:hover {
  color: var(--text);
  border-color: var(--text3)
}

/* Collapsible chapters */
.theory-chapter {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm)
}

.theory-chapter summary {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 17px 19px;
  cursor: pointer;
  transition: background .12s
}

.theory-chapter summary::-webkit-details-marker {
  display: none
}

.theory-chapter summary:hover {
  background: var(--bg3)
}

.theory-chapter[open] summary {
  border-bottom: 1px dashed var(--border)
}

.theory-chapter-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 700;
  color: var(--primary);
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  margin-top: 2px;
}

.theory-chapter-titles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0
}

.theory-chapter-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4
}

.theory-chapter-toggle {
  flex-shrink: 0;
  color: var(--text3);
  display: flex;
  transition: transform .18s var(--ease);
  margin-top: 8px
}

.theory-chapter-toggle svg {
  width: 13px;
  height: 13px;
  fill: currentColor
}

.theory-chapter[open] .theory-chapter-toggle {
  transform: rotate(180deg)
}

.theory-badge {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
  align-self: flex-start;
}

.theory-ov {
  color: var(--text2);
  font-size: .85rem;
  line-height: 1.7;
  border-left: 3px solid var(--border-strong);
  padding-left: 13px
}

.theory-chapter-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 8px 19px 19px
}

.theory-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 17px
}

.theory-sec-h {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--primary);
  margin: 0 0 11px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.theory-text .theory-html {
  font-size: .86rem;
  color: var(--text);
  line-height: 1.75
}

.theory-text .theory-html code,
.theory-ex-caption code {
  font-family: var(--mono);
  font-size: .8em;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: #b91c1c
}

.theory-svg-inner {
  overflow-x: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: center;
}

.theory-svg-inner svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.theory-svg-inner svg rect:not([fill="none"]):not([fill="#fffbeb"]):not([fill="#fef2f2"]):not([fill="#ecfdf5"]) {
  fill: #ffffff !important;
  stroke: var(--border-strong) !important;
  stroke-width: 1.5px !important;
}

.theory-svg-inner svg text {
  fill: var(--text) !important;
  font-weight: 700 !important;
}

.theory-figure-box {
  margin: 0;
  text-align: center
}

.theory-figure-box img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px
}

.theory-figure-box figcaption {
  font-size: .75rem;
  color: var(--text3);
  line-height: 1.6;
  margin-top: 9px;
  text-align: left
}

.theory-img-fallback {
  display: none;
  font-size: .72rem;
  color: var(--text3);
  border: 1px dashed var(--border-strong);
  padding: 11px;
  border-radius: var(--radius-sm);
  margin-top: 7px
}

.theory-table-scroll {
  overflow-x: auto
}

.theory-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem
}

.theory-table th,
.theory-table td {
  padding: 9px 13px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  line-height: 1.55
}

.theory-table th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 700;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-family: var(--mono)
}

.theory-table td code {
  font-family: var(--mono);
  font-size: .8em;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  color: #b91c1c
}

.theory-ex-caption {
  font-size: .78rem;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 11px
}

.theory-code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px;
  font-family: var(--mono);
  font-size: .74rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

.theory-code code {
  font-family: var(--mono);
  color: inherit;
  background: none;
  padding: 0
}

@media(max-width:700px) {
  .theory-part-tabs {
    margin: 0 -16px 14px;
    padding: 12px 16px 0
  }

  .theory-toc {
    position: static
  }

  .theory-chapter summary {
    padding: 13px 15px
  }

  .theory-chapter-body {
    padding: 6px 15px 15px
  }
}

/* ------------------------------------------------------------
   THEORY LMS — progress + section chrome + explanations
------------------------------------------------------------ */
.theory-hero-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  max-width: 760px
}

.theory-hero-count {
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums
}

.theory-hero-progress .progress-track {
  height: 8px
}

.theory-part-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap
}

.theory-part-progress {
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums
}

.theory-part-bar {
  margin-top: 8px
}

.theory-part-bar .progress-fill {
  background: var(--primary)
}

.theory-chap-pill {
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  align-self: flex-start
}

.theory-chap-pill.done {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0
}

.theory-chap-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px
}

.theory-chap-count {
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--text3);
  white-space: nowrap
}

.theory-chap-bar .progress-fill {
  background: var(--primary)
}

.theory-section {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  background: var(--bg2);
  box-shadow: var(--shadow-sm);
}

.theory-section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  background: var(--border-strong);
  border-radius: 3px
}

.theory-section.section-done {
  border-color: #a7f3d0
}

.theory-section.section-done::before {
  background: var(--accent)
}

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

.theory-sec-count {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3)
}

.theory-mark {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  cursor: pointer;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .03em;
  transition: color .12s, border-color .12s, background .12s;
}

.theory-mark:hover {
  color: var(--text);
  border-color: var(--text3)
}

.theory-mark.done {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0
}

.theory-next {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px
}

.theory-sec-end {
  font-size: .72rem;
  color: var(--text3);
  font-style: italic
}

.theory-explain {
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: .8rem;
  line-height: 1.7
}

.theory-explain-title {
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 6px
}

.theory-explain-code {
  background: #fffbeb;
  border: 1px solid #fde68a
}

.theory-explain-code .theory-explain-title {
  color: var(--primary)
}

.theory-explain-dia {
  background: #fffbeb;
  border: 1px solid #fde68a
}

.theory-explain-dia .theory-explain-title {
  color: #b45309
}

.theory-explain-body {
  color: var(--text2)
}

.theory-explain-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px
}

.theory-explain-list li {
  position: relative;
  padding-left: 24px;
  color: var(--text2)
}

.theory-explain-list li::before {
  content: '>';
  position: absolute;
  left: 4px;
  top: 0;
  color: var(--primary);
  font-family: var(--mono);
  font-weight: 700
}

.theory-explain-list li code {
  font-family: var(--mono);
  font-size: .8em;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  color: #b91c1c
}

.theory-explain-list li strong {
  color: var(--text)
}

.theory-toc-chip.done {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0
}

.theory-toc-chip.done:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent)
}

.theory-toc-chip.partial {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a
}

.theory-toc-chip.partial:hover {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber)
}

/* ------------------------------------------------------------
   THEORY LMS READER — sidebar TOC + single-section reading pane
------------------------------------------------------------ */
.theory-hero {
  margin-bottom: 6px
}

.theory-lms {
  display: grid;
  grid-template-columns: 312px 1fr;
  gap: 22px;
  align-items: start;
  margin-top: 12px
}

.theory-side {
  position: sticky;
  top: calc(var(--topbar-h) + 12px);
  max-height: calc(100vh - var(--topbar-h) - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .9);
  padding: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.theory-side-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 13px;
  margin-bottom: 13px
}

.theory-side-progress-label {
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 7px
}

.theory-side-head .theory-hero-progress {
  margin-top: 9px;
  max-width: none
}

.theory-side-head .theory-hero-count {
  font-size: .7rem
}

.theory-side-part-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px
}

.theory-side-part-label {
  font-size: .72rem;
  color: var(--text3)
}

.theory-side-part-label b {
  color: var(--primary)
}

.theory-reset-btn {
  font-size: .62rem;
  font-weight: 700;
  color: var(--text3);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--mono);
  text-transform: uppercase;
  transition: color .12s, border-color .12s
}

.theory-reset-btn:hover {
  color: #b91c1c;
  border-color: #fecaca
}

.theory-part-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 11px
}

.theory-part-chip {
  min-width: 30px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  cursor: pointer;
  font-family: var(--mono);
  text-align: center;
  transition: color .12s, border-color .12s, background .12s;
}

.theory-part-chip:hover {
  color: var(--text);
  border-color: var(--border-strong)
}

.theory-part-chip.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft)
}

.theory-part-chip.done {
  color: #047857;
  border-color: #a7f3d0
}

.theory-part-chip svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
  vertical-align: -1px
}

.theory-side-nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 13px
}

.theory-side-ch {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg2)
}

.theory-side-ch.active {
  border-color: rgba(180, 83, 9, .5);
  box-shadow: 0 2px 10px -4px rgba(180, 83, 9, .25)
}

.theory-side-ch.done {
  border-color: #a7f3d0
}

.theory-side-ch-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  color: var(--text);
  text-align: left;
}

.theory-side-ch-head:hover {
  background: var(--bg3)
}

.theory-side-ch-num {
  flex-shrink: 0;
  width: 25px;
  height: 25px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 700;
  color: var(--primary);
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
}

.theory-side-ch-title {
  flex: 1;
  min-width: 0;
  font-size: .76rem;
  font-weight: 600;
  line-height: 1.4
}

.theory-side-ch-pill {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 700;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.theory-side-ch-pill.done {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5
}

.theory-side-ch-pill svg {
  width: 9px;
  height: 9px
}

.theory-side-ch-caret {
  flex-shrink: 0;
  color: var(--text3);
  display: flex;
  transition: transform .18s var(--ease)
}

.theory-side-ch-head.open .theory-side-ch-caret {
  transform: rotate(180deg)
}

.theory-side-ch-caret svg {
  width: 12px;
  height: 12px;
  fill: currentColor
}

.theory-side-secs {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border)
}

.theory-side-sec {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 11px 7px 15px;
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: var(--font);
  color: var(--text2);
  text-align: left;
  transition: background .1s, color .1s;
}

.theory-side-sec:last-child {
  border-bottom: none
}

.theory-side-sec:hover {
  background: var(--bg3);
  color: var(--text)
}

.theory-side-sec.active {
  background: linear-gradient(90deg, var(--primary-soft), #fafaff);
  color: var(--primary)
}

.theory-side-sec.done {
  color: var(--text3)
}

.theory-side-sec-dot {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .58rem;
  color: var(--text3);
}

.theory-side-sec-dot svg {
  width: 9px;
  height: 9px;
  fill: currentColor
}

.theory-side-sec.done .theory-side-sec-dot {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857
}

.theory-side-sec.active .theory-side-sec-dot {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff
}

.theory-side-sec-label {
  font-size: .72rem;
  line-height: 1.4
}

.theory-side .theory-glossary-grid {
  grid-template-columns: 1fr
}

.theory-side .theory-glossary summary {
  padding: 11px 13px;
  font-size: .78rem
}

.theory-reader {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 15px
}

.theory-reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border)
}

.theory-reader-crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: .74rem;
  color: var(--text3);
  font-family: var(--mono)
}

.theory-reader-crumb-part {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  font-family: var(--mono);
  font-size: .74rem;
  padding: 0
}

.theory-reader-crumb-part:hover {
  text-decoration: underline
}

.theory-reader-sep {
  color: var(--text3);
  opacity: .5
}

.theory-reader-crumb-ch {
  font-weight: 700;
  color: var(--text2)
}

.theory-reader-crumb-sec {
  color: var(--text3)
}

.theory-reader-done-tag {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase
}

.theory-reader-done-tag svg,
.theory-mark svg {
  width: 10px;
  height: 10px;
  fill: currentColor
}

.theory-reader-pending-tag {
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  text-transform: uppercase
}

.theory-reader-title h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.005em
}

.theory-reader-title p {
  font-size: .72rem;
  color: var(--text3);
  margin-top: 3px
}

.theory-reader-foot {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-top: 14px;
  border-top: 1px solid var(--border)
}

.theory-reader-foot-spacer {
  flex: 1
}

.theory-reader-foot .btn:disabled {
  opacity: .35;
  cursor: not-allowed
}

@media(max-width:1199.98px) {
  .theory-lms {
    grid-template-columns: 1fr
  }

  .theory-side {
    position: static;
    max-height: none;
    overflow: visible
  }

  .theory-side-nav {
    max-height: 400px;
    overflow-y: auto
  }
}

/* ==========================================================================
   HOME LANDING PAGE (no login, no app chrome)
   ========================================================================== */
body.home-view .sidebar {
  display: none !important
}

body.home-view .main-wrap {
  margin-left: 0
}

body.home-view .topbar {
  display: none
}

body.home-view .page {
  padding: 28px 44px 72px
}

.home-hero {
  padding: 24px 0 36px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.home-hero::before {
  content: '';
  position: absolute;
  z-index: 0;
  top: -120px;
  right: -140px;
  width: 760px;
  height: 760px;
  pointer-events: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 9%, rgba(15, 23, 42, .06) 9% 9.3%, transparent 9.3% 20%, rgba(15, 23, 42, .05) 20% 20.3%, transparent 20.3% 31%, rgba(15, 23, 42, .045) 31% 31.3%, transparent 31.3% 42%, rgba(15, 23, 42, .04) 42% 42.3%, transparent 42.3% 53%, rgba(180, 83, 9, .06) 53% 53.3%, transparent 53.3% 64%, rgba(180, 83, 9, .05) 64% 64.3%, transparent 64.3%);
}

.home-hero>div,
.home-hero>.hero-visual {
  position: relative;
  z-index: 1
}

.home-hero h1 {
  display: block;
  position: relative;
  padding-bottom: 18px;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.15;
  color: var(--text);
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: var(--text) !important;
  word-break: break-word;
  overflow-wrap: break-word;
}

.home-hero h1::after {
  content: '';
  position: absolute;
  left: 2px;
  bottom: 0;
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: #b45309;
}

.home-sub {
  max-width: 660px;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  margin-top: 18px;
  line-height: 1.85;
  color: var(--text2)
}

.home-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 4px 0 30px;
}

.home-stat {
  padding: 16px 18px;
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), border-color .14s var(--ease);
}

.home-stat:hover {
  border-color: rgba(217, 119, 6, .3)
}

.home-stat b {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(120deg, #b45309, #92400e);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-variant-numeric: tabular-nums;
}

.home-stat span {
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text3)
}

.home-section {
  margin-bottom: 34px
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 11px;
  margin-bottom: 18px;
}

.home-section-head h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .01em;
}

.home-section-tag {
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .1em
}

.home-modules .dash-card {
  cursor: pointer
}

.home-module-desc {
  font-size: .76rem;
  color: var(--text3);
  line-height: 1.6;
  margin-top: 2px
}

.home-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px
}

.home-step {
  padding: 18px;
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
}

.home-step:hover {
  border-color: rgba(217, 119, 6, .3)
}

.home-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px
}

.home-step-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-grad);
  color: #fff;
  border: 1px solid rgba(217, 119, 6, .4);
}

.home-step-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor
}

.home-step-num {
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--primary);
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  align-self: flex-start;
}

.home-step h3 {
  font-family: var(--font-display);
  font-size: .98rem;
  font-weight: 700
}

.home-step p {
  font-size: .78rem;
  color: var(--text3);
  line-height: 1.65
}

/* ==========================================================================
   FULLSCREEN COURSE VIEW
   ========================================================================== */
.fs-toggle {
  flex-shrink: 0
}

body.fs-course .sidebar {
  display: none !important
}

body.fs-course .main-wrap {
  margin-left: 0
}

body.fs-course .topbar {
  display: none
}

body.fs-course .content {
  max-width: none
}

body.fs-course .page {
  padding-top: 26px
}

.fs-exit {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  height: auto;
  min-width: 0;
  white-space: nowrap;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .92);
  color: var(--text2);
  cursor: pointer;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  box-shadow: var(--shadow-lg);
  transition: background .12s, color .12s, border-color .12s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.fs-exit:hover {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--text3)
}

body.fs-course .fs-exit {
  display: flex
}

.fs-exit svg {
  width: 16px;
  height: 16px
}

/* ==========================================================================
   HOME HERO EMBLEM — static Lucide shield on a soft card
   ========================================================================== */
.hero-visual {
  position: relative;
  width: 240px;
  height: 240px;
  flex-shrink: 0;
  display: none;
  margin: 0 auto;
  perspective: 800px;
}

@media(min-width:900px) {
  .hero-visual {
    display: block;
    margin: 0;
  }
}

.hero-emblem {
  position: absolute;
  inset: 40px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: 
    0 16px 36px -12px rgba(15, 23, 42, 0.1),
    0 2px 6px -1px rgba(15, 23, 42, 0.04);
  transform: rotateX(6deg) rotateY(-8deg);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: floatMinimal 6s ease-in-out infinite alternate;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@keyframes floatMinimal {
  0% { transform: rotateX(6deg) rotateY(-8deg) translateY(0); }
  100% { transform: rotateX(8deg) rotateY(-4deg) translateY(-8px); }
}

.hero-emblem:hover {
  transform: rotateX(0deg) rotateY(0deg) translateY(-2px);
  box-shadow: 0 20px 44px -10px rgba(180, 83, 9, 0.15);
  border-color: rgba(217, 119, 6, 0.3);
}

.hero-emblem::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(217, 119, 6, 0.15);
}

.hero-emblem svg {
  width: 92px;
  height: 92px;
  color: var(--primary);
  opacity: 0.92;
}

.home-section {
  animation: secIn .55s var(--ease) backwards
}

.home-section+.home-section {
  animation-delay: .08s
}

@keyframes secIn {
  from {
    opacity: 0;
    transform: translateY(16px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* ==========================================================================
   COMPLETION — per-scenario toast + module-complete popup + confetti
   ========================================================================== */
.scenario-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(217, 119, 6, .3);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  font-family: var(--font);
  animation: toastIn .3s var(--ease) forwards;
}

.scenario-toast.out {
  animation: toastOut .3s var(--ease) forwards
}

.scenario-toast .icon {
  width: 14px;
  height: 14px;
  color: #15803d
}

.scenario-toast span {
  display: flex;
  flex-direction: column;
  line-height: 1.25
}

.scenario-toast b {
  font-size: .76rem;
  color: var(--text)
}

.scenario-toast i {
  font-style: normal;
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, -10px)
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0)
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translate(-50%, 0)
  }

  to {
    opacity: 0;
    transform: translate(-50%, -10px)
  }
}

.module-complete-card {
  max-width: 360px;
  width: 90%;
  text-align: center;
  padding: 28px 26px
}

.mc-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-grad);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.mc-badge svg {
  width: 26px;
  height: 26px;
  fill: currentColor
}

.mc-mod {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg2);
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.mc-mod .icon {
  width: 13px;
  height: 13px
}

.module-complete-card h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px
}

.module-complete-card p {
  font-size: .8rem;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 20px
}

.mc-actions {
  display: flex;
  flex-direction: column;
  gap: 9px
}

.mc-actions .btn {
  width: 100%
}

.celeb {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center
}

.celeb-p {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  color: var(--c);
  opacity: 0;
  animation: celebP .9s var(--ease-spring) forwards;
  animation-delay: var(--delay)
}

.celeb-p svg {
  width: 100%;
  height: 100%;
  fill: currentColor
}

@keyframes celebP {
  0% {
    transform: translate(-50%, -50%) scale(.2);
    opacity: 0
  }

  20% {
    opacity: 1
  }

  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
    opacity: 0
  }
}

/* ==========================================================================
   MOBILE UX ENHANCEMENTS & KEYBOARD FIXES (iOS & Android)
   ========================================================================== */

/* 1. Mobile Theory LMS Layout: Reader First, Sidebar Below & Collapsible */
@media(max-width: 900px) {
  .theory-lms {
    display: flex;
    flex-direction: column-reverse;
    gap: 16px;
  }

  .theory-side {
    position: static;
    max-height: none;
    overflow: visible;
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-top: 10px;
  }

  .theory-side-nav {
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .theory-hero h1 {
    font-size: 1.6rem !important;
  }

  .theory-hero p {
    font-size: 0.88rem !important;
    line-height: 1.6;
  }
}

/* 2. Mobile Keyboard & Chat Input Optimization */
@media(max-width: 768px) {
  .chat-box {
    max-height: calc(100vh - 280px);
    min-height: 200px;
    padding: 12px;
    gap: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chat-msg {
    max-width: 92%;
    font-size: 0.84rem;
    padding: 10px 12px;
  }

  .chat-input-row {
    position: sticky;
    bottom: 0;
    z-index: 60;
    background: var(--bg);
    padding: 6px 0;
    gap: 8px;
  }

  .chat-input-row input {
    font-size: 0.92rem;
    padding: 12px 14px;
    min-height: 46px;
  }

  .chat-input-row button,
  .btn-sm,
  .btn-secondary {
    min-height: 44px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
  }

  /* Prevent body horizontal jitter on mobile keyboard popup */
  body {
    overflow-x: hidden;
  }
}