/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --matrix-green: #00ff41;
  --matrix-green-dim: #00cc33;
  --matrix-green-dark: #003b00;
  --matrix-bg: #000000;
  --matrix-glow: 0 0 10px #00ff41, 0 0 20px #00ff41;
  --terminal-bg: rgba(0, 10, 0, 0.85);
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--matrix-bg);
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

/* ===== ENTRY SCREEN ===== */
#entry-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.entry-content {
  text-align: center;
}

.matrix-title {
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  font-weight: 500;
  letter-spacing: 0.22em;
  color: #7dff9a;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.25);
  margin-bottom: 0.5em;
  animation: none;
  opacity: 0.92;
}

.matrix-subtitle {
  font-size: clamp(0.8rem, 2.5vw, 1.1rem);
  letter-spacing: 0.35em;
  opacity: 0.55;
  color: #5aab6a;
  text-shadow: none;
  margin-bottom: 2.5em;
}

.terminal-line {
  font-size: 1rem;
  margin-bottom: 2em;
  min-height: 1.5em;
}

.prompt {
  color: var(--matrix-green);
  margin-right: 0.5em;
}

.cursor {
  animation: blink 1s step-end infinite;
}

.matrix-btn {
  background: transparent;
  border: 1px solid var(--matrix-green);
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.8em 1.8em;
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: all 0.25s ease;
  text-shadow: 0 0 8px var(--matrix-green);
}

.matrix-btn:hover {
  background: rgba(0, 255, 65, 0.12);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.35);
}
.matrix-btn {
  position: relative;
  z-index: 2;
  pointer-events: auto;
}
#entry-screen, .entry-content {
  pointer-events: auto;
}

/* ===== MAIN APP ===== */
#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* ===== TERMINAL ===== */
#terminal {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: min(520px, calc(100vw - 40px));
  max-height: 280px;
  background: var(--terminal-bg);
  border: 1px solid var(--matrix-green-dim);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.25);
  display: flex;
  flex-direction: column;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(0, 40, 0, 0.6);
  border-bottom: 1px solid var(--matrix-green-dark);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 12px;
}

#terminal-output {
  flex: 1;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.45;
  margin-bottom: 8px;
  max-height: 180px;
}

#terminal-output .line {
  margin-bottom: 2px;
  word-break: break-word;
}

#terminal-output .system {
  color: var(--matrix-green-dim);
}

#terminal-output .agent {
  color: #7dff9a;
}

#terminal-output .error {
  color: #ff4444;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--matrix-green-dark);
  padding-top: 6px;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  caret-color: var(--matrix-green);
}

#terminal-input::placeholder {
  color: rgba(0, 255, 65, 0.35);
}

/* ===== SIDE NAV ===== */
#side-nav {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 90;
}

.nav-item {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 12px 6px;
  border: 1px solid transparent;
  color: rgba(0, 255, 65, 0.55);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(0, 15, 0, 0.5);
}

.nav-item:hover,
.nav-item.active {
  color: var(--matrix-green);
  border-color: var(--matrix-green-dim);
  text-shadow: 0 0 6px var(--matrix-green);
  background: rgba(0, 40, 0, 0.7);
}

/* ===== AGENT BUTTON ===== */
#agent-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--matrix-green);
  background: rgba(0, 20, 0, 0.8);
  color: var(--matrix-green);
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.4);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#agent-btn:hover {
  background: rgba(0, 60, 0, 0.9);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.7);
  transform: scale(1.08);
}

/* ===== PROGRESS INDICATOR ===== */
#progress-indicator {
  position: absolute;
  top: 16px;
  left: 20px;
  z-index: 90;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.signal-bar {
  width: 120px;
  height: 4px;
  background: rgba(0, 40, 0, 0.8);
  border: 1px solid var(--matrix-green-dark);
  overflow: hidden;
}

.signal-fill {
  height: 100%;
  width: 5%;
  background: var(--matrix-green);
  box-shadow: 0 0 6px var(--matrix-green);
  transition: width 0.6s ease;
}

#access-points {
  opacity: 0.7;
  letter-spacing: 0.05em;
}

/* ===== ANIMATIONS ===== */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
    opacity: 1;
    text-shadow: var(--matrix-glow);
  }
  20%, 24%, 55% {
    opacity: 0.6;
    text-shadow: none;
  }
}

/* ===== MOBILE ADJUSTMENTS ===== */
@media (max-width: 768px) {
  #terminal {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 70px;
    max-height: 220px;
  }

  #side-nav {
    right: 6px;
    gap: 4px;
  }

  .nav-item {
    font-size: 0.6rem;
    padding: 8px 4px;
  }

  #agent-btn {
    bottom: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
  }

  #progress-indicator {
    top: 10px;
    left: 10px;
  }

  .quiz-container {
    width: 95%;
    max-height: 90vh;
  }

  .hologram-card {
    padding: 20px 16px;
  }

  .question-text {
    font-size: 0.95rem;
  }

  .option-btn {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
}

/* ===== QUIZ OVERLAY ===== */
#quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.87);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.quiz-container {
  width: min(640px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: rgba(0, 12, 0, 0.92);
  border: 1px solid var(--matrix-green-dim);
  box-shadow: 0 0 40px rgba(0, 255, 65, 0.15), inset 0 0 30px rgba(0, 255, 65, 0.03);
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--matrix-green-dark);
  background: rgba(0, 30, 0, 0.5);
}

.quiz-title {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.quiz-progress {
  font-size: 0.85rem;
  opacity: 0.7;
}

.quiz-close {
  background: transparent;
  border: none;
  color: var(--matrix-green);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.quiz-close:hover {
  opacity: 1;
}

.quiz-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
}

.hologram-card {
  border: 1px solid rgba(0, 255, 65, 0.35);
  background: linear-gradient(160deg, rgba(0, 40, 0, 0.4), rgba(0, 15, 0, 0.6));
  padding: 28px 24px;
  position: relative;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.08);
}

.hologram-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  background: linear-gradient(135deg, rgba(0, 255, 65, 0.15), transparent 40%) border-box;
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.card-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  opacity: 0.5;
  margin-bottom: 14px;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.55;
  margin-bottom: 28px;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(0, 25, 0, 0.5);
  border: 1px solid rgba(0, 255, 65, 0.25);
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.option-btn:hover {
  background: rgba(0, 50, 0, 0.6);
  border-color: var(--matrix-green);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}

.option-btn.selected {
  background: rgba(0, 80, 0, 0.5);
  border-color: var(--matrix-green);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.35);
}

.option-letter {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: 1px solid var(--matrix-green-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  margin-top: 1px;
}

.option-btn.selected .option-letter {
  background: var(--matrix-green);
  color: #000;
  border-color: var(--matrix-green);
}

.quiz-footer {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--matrix-green-dark);
}

.matrix-btn.primary {
  background: rgba(0, 255, 65, 0.12);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
}

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

/* Result Screen */
#quiz-result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}

.result-card {
  width: min(480px, 92vw);
  padding: 40px 32px;
  text-align: center;
  border: 1px solid var(--matrix-green);
  background: rgba(0, 15, 0, 0.95);
  box-shadow: 0 0 50px rgba(0, 255, 65, 0.25);
}

.result-grade {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-shadow: 0 0 20px var(--matrix-green), 0 0 40px var(--matrix-green);
  margin-bottom: 16px;
  animation: grade-appear 0.8s ease;
}

.result-message {
  font-size: 0.95rem;
  opacity: 0.85;
  margin-bottom: 28px;
  line-height: 1.5;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
  font-size: 0.9rem;
  opacity: 0.9;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

@keyframes grade-appear {
  0% {
    opacity: 0;
    transform: scale(0.8);
    letter-spacing: 0.4em;
  }
  100% {
    opacity: 1;
    transform: scale(1);
    letter-spacing: 0.15em;
  }
}

/* ===== CASE INTERFACE ===== */
.case-container {
  max-width: 720px;
}

.case-textarea {
  width: 100%;
  min-height: 180px;
  background: rgba(0, 20, 0, 0.6);
  border: 1px solid rgba(0, 255, 65, 0.3);
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 14px;
  resize: vertical;
  outline: none;
  margin-top: 8px;
}

.case-textarea:focus {
  border-color: var(--matrix-green);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}

.case-textarea::placeholder {
  color: rgba(0, 255, 65, 0.35);
}

.case-hint {
  margin-top: 10px;
  font-size: 0.78rem;
  opacity: 0.55;
}

/* ===== SECTION CONTENT PANEL ===== */
#section-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100%;
  background: rgba(0, 10, 0, 0.94);
  border-left: 1px solid var(--matrix-green-dim);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 255, 65, 0.08);
  backdrop-filter: blur(8px);
  transform: translateX(0);
  transition: transform 0.35s ease;
}

.section-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  overflow: hidden;
}

.section-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--matrix-green-dark);
}

.section-panel-title {
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px var(--matrix-green);
}

.section-panel-desc {
  font-size: 0.82rem;
  opacity: 0.65;
  margin-bottom: 20px;
  line-height: 1.5;
}

.section-panel-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}

.section-card {
  border: 1px solid rgba(0, 255, 65, 0.25);
  background: rgba(0, 25, 0, 0.4);
  padding: 16px;
  margin-bottom: 14px;
}

.section-card h3 {
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  color: var(--matrix-green);
}

.section-card p {
  font-size: 0.84rem;
  line-height: 1.55;
  opacity: 0.9;
  white-space: pre-line;
}

.section-panel-footer {
  padding-top: 16px;
  border-top: 1px solid var(--matrix-green-dark);
}

@media (max-width: 600px) {
  #section-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--matrix-green-dim);
    height: 55%;
    top: auto;
    bottom: 0;
  }
}

/* ===== PERSONAL ARCHIVE ===== */
#archive-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 94vw);
  height: 100%;
  background: rgba(0, 10, 0, 0.95);
  border-left: 1px solid var(--matrix-green-dim);
  z-index: 210;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 255, 65, 0.1);
  backdrop-filter: blur(8px);
}

.archive-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 60, 0, 0.5);
  font-size: 0.85rem;
}

.archive-stat-row .label {
  opacity: 0.65;
}

.archive-section-title {
  margin: 18px 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  opacity: 0.7;
  text-transform: uppercase;
}

.achievement-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 40, 0, 0.4);
  font-size: 0.82rem;
}

.achievement-item.locked {
  opacity: 0.35;
}

.achievement-icon {
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  color: var(--matrix-green);
}

.achievement-name {
  font-weight: 500;
}

.achievement-desc {
  opacity: 0.6;
  font-size: 0.78rem;
  margin-top: 2px;
}

.recent-item {
  padding: 6px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(0, 40, 0, 0.4);
}

@media (max-width: 600px) {
  #archive-panel {
    width: 100%;
    height: 60%;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--matrix-green-dim);
  }
}

/* ===== AUTHOR FOOTER ===== */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.92);
  border-top: 1px solid rgba(0, 255, 65, 0.25);
  padding: 10px 16px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--matrix-green, #00ff41);
  backdrop-filter: blur(6px);
}

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

.footer-text {
  flex: 1;
  min-width: 200px;
}

.footer-designed {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
  margin-bottom: 4px;
}

.footer-legal {
  font-size: 0.72rem;
  opacity: 0.65;
  line-height: 1.45;
  max-width: 640px;
}

.footer-legal a {
  color: var(--matrix-green, #00ff41);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.qr-img {
  display: block;
  width: 88px;
  height: 88px;
  border: 1px solid rgba(0, 255, 65, 0.45);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
  image-rendering: pixelated;
  background: #000;
}

.qr-caption {
  font-size: 0.65rem;
  opacity: 0.7;
  letter-spacing: 0.04em;
  text-align: center;
}

/* На основном приложении поднять терминал над футером */
#app #terminal {
  bottom: 120px;
}

#app #agent-btn {
  bottom: 120px;
}

@media (max-width: 640px) {
  .site-footer {
    padding: 8px 10px;
  }
  .qr-img {
    width: 72px;
    height: 72px;
  }
  .footer-designed {
    font-size: 0.78rem;
  }
  .footer-legal {
    font-size: 0.68rem;
  }
  #app #terminal {
    bottom: 140px;
  }
  #app #agent-btn {
    bottom: 140px;
  }
}


/* ===== QUIZ JUSTIFICATION ===== */
.justify-block {
  margin-top: 8px;
  border-top: 1px solid rgba(0, 255, 65, 0.15);
  padding-top: 4px;
}
.quiz-justify {
  min-height: 72px;
  font-size: 0.82rem;
}
.justify-block .case-hint.warn {
  color: #ffaa00;
}
.justify-block .case-hint.ok {
  color: #00ff41;
  opacity: 0.8;
}

/* ===== LECTURE ACCORDION ===== */
.lecture-wrap {
  margin-bottom: 12px;
  border: 1px solid rgba(0, 255, 65, 0.3);
  background: rgba(0, 20, 0, 0.35);
}
.lecture-toggle {
  width: 100%;
  text-align: left;
  background: rgba(0, 40, 0, 0.5);
  border: none;
  color: var(--matrix-green, #00ff41);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 12px 14px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.lecture-toggle:hover {
  background: rgba(0, 255, 65, 0.08);
}
.lecture-arrow {
  display: inline-block;
  width: 1em;
}
.lecture-body {
  display: none;
  padding: 8px 10px 12px;
}
.lecture-wrap.open .lecture-body {
  display: block;
}
.block-badge {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  opacity: 0.7;
  margin-bottom: 6px;
}
.block-extra {
  border-color: rgba(0, 255, 65, 0.55);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.08);
}
.block-extra .block-badge {
  color: #7dff9a;
}
.matrix-toast {
  position: fixed;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(0, 20, 0, 0.95);
  border: 1px solid var(--matrix-green, #00ff41);
  color: var(--matrix-green, #00ff41);
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  padding: 10px 16px;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}
.matrix-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ===== TOPIC BADGES H2 ===== */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 16px;
}
.topic-badge {
  border: 1px solid rgba(0, 255, 65, 0.25);
  background: rgba(0, 20, 0, 0.4);
  padding: 8px 12px;
  min-width: 88px;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  opacity: 0.35;
  filter: grayscale(0.8);
}
.topic-badge.unlocked {
  opacity: 1;
  filter: none;
  border-color: rgba(0, 255, 65, 0.65);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.15);
  color: #00ff41;
}
.topic-badge .badge-glyph {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.topic-badge .badge-title {
  display: block;
  opacity: 0.9;
}

.topic-badge .badge-label {
  display: block;
  font-size: 0.65rem;
  opacity: 0.75;
  margin-top: 2px;
}
.topic-badge.perfect {
  border-color: rgba(255, 220, 100, 0.7);
  color: #ffe066;
  box-shadow: 0 0 14px rgba(255, 200, 50, 0.2);
}

/* ===== BADGE UNLOCK FX ===== */
#badge-unlock-layer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  background: rgba(0, 0, 0, 0);
  transition: opacity 0.35s ease, background 0.35s ease;
}
#badge-unlock-layer.show {
  pointer-events: auto;
  opacity: 1;
  background: rgba(0, 0, 0, 0.72);
}
#badge-unlock-layer.show.out {
  opacity: 0;
}
.badge-unlock-burst {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 2px solid rgba(0, 255, 65, 0.5);
  box-shadow: 0 0 40px rgba(0, 255, 65, 0.35), inset 0 0 30px rgba(0, 255, 65, 0.15);
  opacity: 0;
  transform: scale(0.4);
}
#badge-unlock-layer.show .badge-unlock-burst {
  animation: badge-burst 1.2s ease-out forwards;
}
#badge-unlock-layer.is-perfect .badge-unlock-burst {
  border-color: rgba(255, 220, 100, 0.6);
  box-shadow: 0 0 48px rgba(255, 200, 50, 0.4), inset 0 0 30px rgba(255, 200, 50, 0.12);
}
.badge-unlock-card {
  position: relative;
  text-align: center;
  font-family: "JetBrains Mono", "Share Tech Mono", monospace;
  color: #00ff41;
  padding: 28px 36px;
  border: 1px solid rgba(0, 255, 65, 0.55);
  background: rgba(0, 18, 0, 0.92);
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  min-width: 220px;
  max-width: 90vw;
}
#badge-unlock-layer.show .badge-unlock-card {
  animation: badge-card-in 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}
#badge-unlock-layer.is-perfect .badge-unlock-card {
  border-color: rgba(255, 220, 100, 0.7);
  color: #ffe066;
  box-shadow: 0 0 28px rgba(255, 200, 50, 0.25);
}
.badge-unlock-label {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  opacity: 0.75;
  margin-bottom: 12px;
}
.badge-unlock-glyph {
  font-size: 3rem;
  line-height: 1.2;
  text-shadow: 0 0 20px rgba(0, 255, 65, 0.7);
  animation: badge-glyph-pulse 1.4s ease-in-out infinite;
}
#badge-unlock-layer.is-perfect .badge-unlock-glyph {
  text-shadow: 0 0 22px rgba(255, 200, 50, 0.8);
}
.badge-unlock-title {
  margin-top: 10px;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}
.badge-unlock-sub {
  margin-top: 6px;
  font-size: 0.78rem;
  opacity: 0.7;
}
@keyframes badge-burst {
  0% { opacity: 0; transform: scale(0.3); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.8); }
}
@keyframes badge-card-in {
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes badge-glyph-pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.25); }
}


/* ===== ARTIFACT / CERTIFICATE ===== */
#artifact-unlock-layer {
  position: fixed; inset: 0; z-index: 1250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.8); opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
}
#artifact-unlock-layer.show { opacity: 1; pointer-events: auto; }
#artifact-unlock-layer.show.out { opacity: 0; }
.artifact-card {
  max-width: 420px; width: 92vw;
  border: 1px solid #00ff41; background: rgba(0,15,0,0.95);
  padding: 28px 24px; text-align: center;
  font-family: "JetBrains Mono", monospace; color: #00ff41;
  transform: scale(0.92); animation: badge-card-in 0.5s forwards;
}
#artifact-unlock-layer.is-perfect .artifact-card {
  border-color: #ffe066; color: #ffe066;
  box-shadow: 0 0 30px rgba(255,200,50,0.25);
}
.artifact-label { font-size: 0.7rem; letter-spacing: 0.2em; opacity: 0.7; margin-bottom: 12px; }
.artifact-glyph { font-size: 2.8rem; margin: 8px 0; text-shadow: 0 0 18px rgba(0,255,65,0.6); }
.artifact-name { font-size: 1.1rem; letter-spacing: 0.06em; margin-bottom: 8px; }
.artifact-blurb { font-size: 0.8rem; opacity: 0.75; margin-bottom: 14px; }
.artifact-cert {
  text-align: left; white-space: pre-wrap; font-size: 0.78rem;
  border: 1px solid rgba(0,255,65,0.3); padding: 12px;
  background: rgba(0,0,0,0.35); line-height: 1.45; margin: 0;
}
.artifact-hint { margin-top: 12px; font-size: 0.7rem; opacity: 0.5; }
.artifact-archive {
  border: 1px solid rgba(0,255,65,0.4); padding: 12px; margin: 8px 0 16px;
  font-size: 0.82rem;
}
.artifact-arch-glyph { font-size: 1.4rem; }
.artifact-arch-cert {
  white-space: pre-wrap; font-size: 0.75rem; opacity: 0.85;
  margin: 8px 0 0; font-family: inherit;
}

/* ===== RANK AVATAR H3 ===== */
.rank-avatar-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 16px;
  padding: 10px;
  border: 1px solid rgba(0, 255, 65, 0.35);
  background: rgba(0, 15, 0, 0.5);
}
.rank-avatar-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 1px solid rgba(0, 255, 65, 0.5);
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.25);
  border-radius: 8px;
  background: #000;
}
.rank-avatar-meta {
  flex: 1;
  min-width: 0;
}
.rank-avatar-name {
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: #00ff41;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}
.rank-avatar-hint {
  font-size: 0.72rem;
  opacity: 0.6;
  margin-top: 4px;
}
#hud-rank-avatar {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border: 1px solid rgba(0, 255, 65, 0.45);
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 8px;
}

/* ===== SECTION ICONS H4 ===== */
.nav-icon {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
  border: 1px solid rgba(0, 255, 65, 0.25);
  opacity: 0.9;
}
.nav-item {
  display: flex;
  align-items: center;
}
.section-panel-icon {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(0, 255, 65, 0.4);
  margin-right: 12px;
  vertical-align: middle;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}
.section-panel-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* ===== UX LAYOUT OVERRIDE (polish 2026-08) ===== */
#side-nav.top-nav,
#side-nav {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 10px 12px !important;
  background: rgba(0, 8, 0, 0.94) !important;
  border-bottom: 1px solid rgba(0, 255, 65, 0.35) !important;
  border-right: none !important;
  z-index: 50 !important;
  overflow-x: auto !important;
  writing-mode: horizontal-tb !important;
}

#side-nav .nav-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px 12px !important;
  min-height: 44px !important;
  font-size: 0.95rem !important;
  letter-spacing: 0.04em !important;
  cursor: pointer !important;
  border: 1px solid transparent !important;
  border-radius: 4px !important;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  transform: none !important;
}

#side-nav .nav-item:hover,
#side-nav .nav-item.active {
  border-color: rgba(0, 255, 65, 0.45) !important;
  background: rgba(0, 255, 65, 0.08) !important;
}

#side-nav .nav-icon {
  width: 36px !important;
  height: 36px !important;
  object-fit: cover !important;
  border-radius: 6px !important;
  margin-right: 0 !important;
  flex-shrink: 0 !important;
}

#side-nav .nav-label {
  font-size: 0.95rem !important;
  opacity: 0.95 !important;
}

#agent-btn,
.nav-agent-btn {
  position: static !important;
  margin-left: auto !important;
  min-height: 44px !important;
  padding: 8px 14px !important;
  font-size: 0.95rem !important;
  border: 1px solid rgba(0, 255, 65, 0.5) !important;
  background: rgba(0, 30, 0, 0.6) !important;
  color: #00ff41 !important;
  cursor: pointer !important;
  border-radius: 4px !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 51 !important;
}

#terminal {
  left: 12px !important;
  right: 12px !important;
  bottom: 48px !important;
  top: auto !important;
  width: auto !important;
  max-width: 920px !important;
  margin: 0 auto !important;
  max-height: 42vh !important;
  z-index: 40 !important;
}

#progress-indicator {
  top: auto !important;
  bottom: 52px !important;
  left: 16px !important;
  right: auto !important;
  z-index: 41 !important;
}

.site-footer {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: auto !important;
  padding: 6px 12px !important;
  background: rgba(0, 0, 0, 0.9) !important;
  border-top: 1px solid rgba(0, 255, 65, 0.2) !important;
  z-index: 45 !important;
}
.site-footer .footer-inner {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  max-width: 100% !important;
  font-size: 0.72rem !important;
  opacity: 0.75 !important;
}
.site-footer .footer-qr,
.site-footer .qr-img,
.site-footer .qr-caption,
.site-footer .footer-legal {
  display: none !important;
}
.site-footer a {
  color: #7dff9a !important;
}

#section-panel {
  top: 70px !important;
  bottom: 56px !important;
  left: 12px !important;
  right: 12px !important;
  max-width: 900px !important;
  margin: 0 auto !important;
  z-index: 35 !important;
}

body.no-webgl #c {
  display: none !important;
}
body.no-webgl #app {
  background: radial-gradient(ellipse at center, #021a08 0%, #000 70%) !important;
}

#app::after { display: none !important; content: none !important; }

/* ===== READABILITY PASS ===== */
:root {
  --matrix-green: #6fdb86;
  --matrix-green-dim: #4aaa5e;
  --matrix-glow: 0 0 6px rgba(0, 200, 80, 0.2);
}

body, #app, #terminal, .nav-item, .section-panel-inner {
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#terminal {
  max-height: 28vh !important;
  bottom: 44px !important;
  opacity: 0.92;
  font-size: 13px !important;
  line-height: 1.45 !important;
}

#terminal .line, #terminal-output {
  color: #8fdc9c !important;
  text-shadow: none !important;
}

#side-nav {
  padding: 8px 10px !important;
  background: rgba(0, 10, 0, 0.97) !important;
}

#side-nav .nav-item {
  font-size: 0.88rem !important;
  color: #9de5ae !important;
  text-shadow: none !important;
}

#section-panel .section-panel-inner,
.section-panel-inner {
  background: rgba(0, 12, 0, 0.94) !important;
  color: #b6ebc0 !important;
  line-height: 1.65 !important;
  font-size: 0.95rem !important;
  letter-spacing: 0.02em !important;
  text-shadow: none !important;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

.section-card, .lecture-block, .lecture-main, .lecture-extra {
  background: rgba(0, 22, 0, 0.55) !important;
  border: 1px solid rgba(0, 180, 70, 0.25) !important;
  padding: 14px 16px !important;
  margin: 12px 0 !important;
  border-radius: 6px;
  line-height: 1.7 !important;
}

.section-card h3, .lecture-title {
  color: #c5f5d0 !important;
  font-weight: 500 !important;
  margin-bottom: 8px !important;
  letter-spacing: 0.04em;
}

.lecture-accordion details {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid rgba(0, 160, 60, 0.3);
  border-radius: 6px;
  background: rgba(0, 18, 0, 0.5);
}
.lecture-accordion summary {
  cursor: pointer;
  color: #a8e6b4;
  font-size: 1.02rem;
  padding: 6px 0;
}
.lecture-accordion p {
  margin: 0.6em 0;
  color: #b5e6c0;
}

#app::after { display: none !important; content: none !important; }

.lecture-wrap { margin: 14px 0; }
.lecture-toggle {
  width: 100%;
  text-align: left;
  background: rgba(0, 28, 0, 0.7);
  border: 1px solid rgba(0, 180, 70, 0.35);
  color: #c5f0ce;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 0.03em;
}
.lecture-body { display: none; padding: 8px 2px 4px; }
.lecture-wrap.open .lecture-body { display: block; }
.block-badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 6px;
  color: #8fdc9c;
}
.block-extra { border-left: 3px solid rgba(255, 200, 80, 0.45) !important; }
.block-main { border-left: 3px solid rgba(0, 200, 80, 0.4) !important; }


/* ===== ORBIT HUB UX 2026-08 ===== */
#app::after { content: none !important; display: none !important; }

#side-nav.nav-fallback.hidden { display: none !important; }
#side-nav.nav-fallback:not(.hidden) {
  position: fixed !important;
  top: 56px !important;
  left: 12px !important;
  right: auto !important;
  width: min(280px, 90vw) !important;
  flex-direction: column !important;
  background: rgba(0,8,0,0.96) !important;
  border: 1px solid rgba(0,255,65,0.3) !important;
  padding: 10px !important;
  z-index: 60 !important;
  max-height: 70vh;
  overflow-y: auto;
}

.sections-fab {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 55;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(0, 200, 80, 0.45);
  background: rgba(0, 12, 0, 0.85);
  color: #9de5ae;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 6px;
}
.sections-fab:hover { border-color: #00ff41; }

#terminal {
  left: 12px !important;
  right: 12px !important;
  bottom: 36px !important;
  width: auto !important;
  max-width: 720px !important;
  margin: 0 auto !important;
  z-index: 40 !important;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  background: rgba(0, 8, 0, 0.92) !important;
  border: 1px solid rgba(0, 160, 60, 0.35) !important;
  font-size: 13px !important;
  color: #9dceb0 !important;
}
#terminal.collapsed {
  max-height: 42px !important;
  overflow: hidden !important;
}
#terminal.collapsed .terminal-body {
  display: none !important;
}
#terminal.expanded {
  max-height: 32vh !important;
}
#terminal .terminal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 40px;
}
.terminal-toggle {
  background: transparent;
  border: 1px solid rgba(0,180,70,0.4);
  color: #9de5ae;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
}
#terminal .terminal-title {
  opacity: 0.55;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}
#rank-display {
  margin-left: auto;
  font-size: 0.78rem;
  opacity: 0.85;
  color: #a8d4b4 !important;
  text-shadow: none !important;
}

#progress-indicator {
  top: 12px !important;
  right: 12px !important;
  left: auto !important;
  bottom: auto !important;
  background: rgba(0,10,0,0.75);
  padding: 6px 10px;
  border: 1px solid rgba(0,160,60,0.3);
  border-radius: 4px;
  font-size: 0.78rem;
  color: #a8d4b4;
  z-index: 50;
}
#access-points {
  text-shadow: none !important;
  letter-spacing: 0.03em;
}

#mode-badge {
  top: 12px !important;
  left: 60px !important;
  transform: none !important;
  bottom: auto !important;
  font-size: 10px !important;
  opacity: 0.75;
}

#section-panel {
  top: 56px !important;
  bottom: 56px !important;
  z-index: 45 !important;
}

.site-footer {
  font-size: 0.68rem !important;
  opacity: 0.55 !important;
  padding: 4px 10px !important;
}

/* softer overall */
body {
  color: #9dceb0;
}

/* ===== READING MODE ===== */
.section-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.reader-toggle {
  background: transparent;
  border: 1px solid rgba(0, 180, 80, 0.4);
  color: #a8d4b4;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.reader-toggle:hover {
  border-color: #7dcc8e;
  color: #c5f0ce;
}

#section-panel.reading-mode {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  max-width: none !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  z-index: 200 !important;
  background: #070b08 !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  border: none !important;
}

#section-panel.reading-mode .section-panel-inner {
  max-width: 42rem !important;
  width: 100% !important;
  margin: 0 auto !important;
  height: 100% !important;
  max-height: none !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 1.25rem 2rem !important;
  overflow: hidden !important;
}

#section-panel.reading-mode .section-panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #070b08;
  padding: 1rem 0 0.75rem;
  border-bottom: 1px solid rgba(120, 160, 130, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
}

#section-panel.reading-mode .section-panel-title,
#section-panel.reading-mode .section-panel-header-row {
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: #d5e8da !important;
  text-shadow: none !important;
  letter-spacing: 0.02em !important;
}

#section-panel.reading-mode .section-panel-icon {
  width: 28px !important;
  height: 28px !important;
  opacity: 0.85;
}

#section-panel.reading-mode .section-panel-desc {
  font-family: Inter, system-ui, sans-serif !important;
  color: #8aa894 !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  margin: 0.75rem 0 1rem !important;
  text-shadow: none !important;
}

#section-panel.reading-mode .section-panel-content {
  flex: 1 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 3rem !important;
  font-family: Inter, system-ui, -apple-system, sans-serif !important;
  font-size: 1.125rem !important;
  line-height: 1.75 !important;
  color: #c5d4c9 !important;
  text-shadow: none !important;
  letter-spacing: 0.01em !important;
  font-weight: 400 !important;
}

#section-panel.reading-mode .section-card,
#section-panel.reading-mode .lecture-block {
  background: rgba(12, 20, 14, 0.9) !important;
  border: 1px solid rgba(100, 140, 110, 0.22) !important;
  border-radius: 10px !important;
  padding: 1.25rem 1.35rem !important;
  margin: 1rem 0 !important;
  box-shadow: none !important;
}

#section-panel.reading-mode .section-card h3,
#section-panel.reading-mode .lecture-block h3 {
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 1.05rem !important;
  font-weight: 600 !important;
  color: #dceee0 !important;
  margin-bottom: 0.65rem !important;
  letter-spacing: 0.01em !important;
  text-shadow: none !important;
}

#section-panel.reading-mode .section-card p,
#section-panel.reading-mode .lecture-block p {
  font-size: 1.125rem !important;
  line-height: 1.8 !important;
  color: #c5d4c9 !important;
  margin: 0.75em 0 !important;
}

#section-panel.reading-mode .lecture-toggle {
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 1.1rem !important;
  font-weight: 500 !important;
  color: #d5e8da !important;
  background: rgba(16, 28, 18, 0.95) !important;
  border: 1px solid rgba(100, 140, 110, 0.28) !important;
  padding: 14px 16px !important;
  border-radius: 10px !important;
  text-shadow: none !important;
}

#section-panel.reading-mode .block-badge {
  font-family: JetBrains Mono, monospace !important;
  font-size: 0.68rem !important;
  letter-spacing: 0.14em !important;
  color: #7a9a82 !important;
  opacity: 1 !important;
}

#section-panel.reading-mode .block-main {
  border-left: 3px solid rgba(90, 160, 110, 0.55) !important;
}
#section-panel.reading-mode .block-extra {
  border-left: 3px solid rgba(180, 160, 90, 0.45) !important;
}

#section-panel.reading-mode .section-panel-footer {
  display: none !important;
}

body.reading-mode #terminal,
body.reading-mode #progress-indicator,
body.reading-mode #mode-badge,
body.reading-mode .sections-fab,
body.reading-mode #side-nav,
body.reading-mode #c {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.reading-mode #c {
  filter: brightness(0.15);
}

/* чуть мягче скроллбар в чтении */
#section-panel.reading-mode .section-panel-content::-webkit-scrollbar {
  width: 8px;
}
#section-panel.reading-mode .section-panel-content::-webkit-scrollbar-thumb {
  background: rgba(100, 140, 110, 0.35);
  border-radius: 4px;
}

@media (max-width: 600px) {
  #section-panel.reading-mode .section-panel-content {
    font-size: 1.05rem !important;
  }
  #section-panel.reading-mode .section-panel-inner {
    padding: 0 1rem 2rem !important;
  }
}

/* ===== READING MODE polish ===== */
body.reading-mode {
  background: #070b08 !important;
}
body.reading-mode #site-footer {
  display: none !important;
}
body.reading-mode #c {
  opacity: 0 !important;
  visibility: hidden !important;
}

#section-panel.reading-mode {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  max-width: none !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  z-index: 200 !important;
  background: #070b08 !important;
  border: none !important;
  padding: 0 !important;
}

#section-panel.reading-mode .lecture-prose .lecture-p {
  margin: 0 0 1em 0 !important;
  max-width: 42rem;
  color: #c5d4c9 !important;
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 1.125rem !important;
  line-height: 1.75 !important;
}

#section-panel.reading-mode .lecture-toggle {
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 1.1rem !important;
  font-weight: 500 !important;
  color: #d5e8da !important;
  background: rgba(14, 24, 16, 0.95) !important;
  border-color: rgba(100, 140, 110, 0.3) !important;
  padding: 14px 16px !important;
}

#section-panel.reading-mode .block-badge {
  font-family: JetBrains Mono, monospace !important;
  font-size: 0.68rem !important;
  color: #8aa894 !important;
  letter-spacing: 0.14em !important;
}

.reader-toggle {
  background: transparent !important;
  border: 1px solid rgba(120, 160, 130, 0.45) !important;
  color: #b6d4be !important;
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 0.85rem !important;
  padding: 6px 12px !important;
  cursor: pointer !important;
  border-radius: 6px !important;
  letter-spacing: 0.02em;
}
.reader-toggle:hover {
  border-color: rgba(160, 200, 170, 0.7) !important;
  background: rgba(20, 40, 25, 0.5) !important;
}

.section-panel-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-left: auto !important;
}

/* ===== FORCE BUILD ORB-2026-08-02c ===== */
#build-stamp {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 9999;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #6a9a78;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(0,120,50,0.4);
  padding: 4px 8px;
  pointer-events: none;
  font-family: JetBrains Mono, monospace;
}
#side-nav,
nav#side-nav,
#side-nav.top-nav {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
#side-nav.nav-fallback-open,
#side-nav.is-open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
#app::after,
body::after {
  content: none !important;
  display: none !important;
}

/* U5 hover + build ORB-2026-08-02d */
#hub-hover-label {
  position: fixed; z-index: 80; pointer-events: none;
  transform: translate(-50%, -100%);
  background: rgba(0,12,0,0.9); border: 1px solid rgba(0,180,80,0.45);
  color: #b8e6c4; font-size: 0.8rem; padding: 6px 10px;
  font-family: JetBrains Mono, monospace; opacity: 0; transition: opacity 0.15s;
  white-space: nowrap;
}
#hub-hover-label.show { opacity: 1; }
#result-construct { border-color: #00ff41 !important; }
#build-stamp { content: "ORB-2026-08-02d"; }

/* construct menu */
#construct-menu .cmenu-card {
  width: min(420px, 92vw);
  background: rgba(0, 12, 0, 0.96);
  border: 1px solid rgba(0, 220, 90, 0.45);
  padding: 1.25rem 1.4rem;
  font-family: JetBrains Mono, monospace;
  color: #b8f0c4;
}
#construct-menu .cmenu-title {
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
  color: #e0ffe8;
}
#construct-menu .cmenu-desc {
  font-size: 0.8rem;
  opacity: 0.75;
  margin-bottom: 1rem;
  line-height: 1.45;
}
#construct-menu button {
  display: block;
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.65rem 0.8rem;
  background: rgba(0, 40, 0, 0.6);
  border: 1px solid rgba(0, 200, 80, 0.4);
  color: #b8f0c4;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
#construct-menu button:hover { border-color: #00ff66; background: rgba(0, 60, 0, 0.7); }
#construct-menu .cmenu-close { margin-top: 0.8rem; opacity: 0.85; }
#construct-menu .cmenu-row {
  font-size: 0.82rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(0, 80, 30, 0.35);
}

#side-nav .nav-ico {
  display: inline-flex;
  width: 28px;
  justify-content: center;
  opacity: 0.9;
}
#side-nav .nav-item {
  gap: 10px !important;
}

/* reading mode more screen */
#section-panel.reading-mode .section-panel-inner {
  max-width: min(52rem, 96vw) !important;
  padding: 0 1rem 2rem !important;
}
#section-panel.reading-mode .section-panel-content {
  font-size: 1.2rem !important;
  line-height: 1.8 !important;
}
#section-panel.reading-mode .lecture-prose .lecture-p {
  max-width: 52rem !important;
  font-size: 1.2rem !important;
  line-height: 1.8 !important;
}

/* ===== LAYOUT FIX 02f ===== */
#build-stamp {
  top: auto !important;
  bottom: 28px !important;
  right: 10px !important;
  left: auto !important;
  z-index: 46 !important;
  font-size: 10px !important;
  opacity: 0.8;
}
#progress-indicator {
  top: auto !important;
  bottom: 28px !important;
  left: 10px !important;
  right: auto !important;
  z-index: 46 !important;
}
#mode-badge {
  top: 10px !important;
  left: 58px !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  z-index: 56 !important;
}
#side-nav.nav-fallback:not([hidden]),
#side-nav.is-open,
#side-nav.nav-fallback-open {
  top: 52px !important;
  left: 10px !important;
  max-height: calc(100vh - 120px) !important;
  z-index: 70 !important;
}
#side-nav .nav-item,
#side-nav .nav-agent-btn {
  position: relative !important;
  z-index: 1 !important;
}

/* 02f nav hard rules */
#side-nav[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
#side-nav:not([hidden]).is-open,
#side-nav:not([hidden]).nav-fallback-open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
  flex-direction: column !important;
}

/* ===== NAV FIX 02i ===== */
#side-nav[hidden] {
  display: none !important;
}
#side-nav:not([hidden]) {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  position: fixed !important;
  top: 52px !important;
  left: 10px !important;
  right: auto !important;
  bottom: 56px !important;
  width: min(280px, 85vw) !important;
  max-height: none !important;
  height: auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding: 10px 8px !important;
  gap: 4px !important;
  background: rgba(0, 8, 0, 0.96) !important;
  border: 1px solid rgba(0, 200, 80, 0.35) !important;
  z-index: 80 !important;
  writing-mode: horizontal-tb !important;
}
#side-nav .nav-item,
#side-nav .nav-agent-btn {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  min-height: 44px !important;
  padding: 8px 10px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  font-size: 0.95rem !important;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  transform: none !important;
  border-radius: 6px !important;
}
#side-nav .nav-icon {
  width: 28px !important;
  height: 28px !important;
  flex-shrink: 0 !important;
  border-radius: 4px !important;
}
#side-nav .nav-ico {
  width: 28px !important;
  text-align: center !important;
  flex-shrink: 0 !important;
}
#side-nav .nav-label {
  flex: 1 !important;
  text-align: left !important;
}
#side-nav .nav-agent-btn {
  margin-top: 8px !important;
  justify-content: flex-start !important;
}

/* ===== NAV PANEL 02l — position + matrix scrollbar ===== */
#side-nav[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#side-nav:not([hidden]),
#side-nav:not([hidden]).is-open,
#side-nav:not([hidden]).nav-fallback-open {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  justify-content: flex-start !important;

  position: fixed !important;
  top: 56px !important;
  left: 12px !important;
  right: auto !important;
  bottom: 64px !important;
  width: min(300px, calc(100vw - 24px)) !important;
  max-width: 300px !important;
  height: auto !important;
  max-height: calc(100vh - 56px - 64px) !important;

  margin: 0 !important;
  padding: 12px 8px 12px 10px !important;
  gap: 6px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain;

  background: rgba(0, 10, 0, 0.97) !important;
  border: 1px solid rgba(0, 200, 80, 0.4) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65) !important;
  z-index: 90 !important;
  writing-mode: horizontal-tb !important;
  transform: none !important;
}

#side-nav:not([hidden]) .nav-item,
#side-nav:not([hidden]) .nav-agent-btn {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex: 0 0 auto !important;
  width: 100% !important;
  min-height: 48px !important;
  height: auto !important;
  padding: 10px 12px !important;
  margin: 0 !important;
  gap: 12px !important;
  box-sizing: border-box !important;
  font-size: 1rem !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  transform: none !important;
  border-radius: 6px !important;
  border: 1px solid transparent !important;
  color: #b8f0c4 !important;
  background: transparent !important;
  cursor: pointer !important;
}

#side-nav:not([hidden]) .nav-item:hover,
#side-nav:not([hidden]) .nav-agent-btn:hover {
  border-color: rgba(0, 255, 100, 0.35) !important;
  background: rgba(0, 40, 0, 0.45) !important;
}

#side-nav:not([hidden]) .nav-icon {
  width: 32px !important;
  height: 32px !important;
  flex-shrink: 0 !important;
  border-radius: 5px !important;
  object-fit: cover !important;
}

#side-nav:not([hidden]) .nav-ico {
  width: 32px !important;
  flex-shrink: 0 !important;
  text-align: center !important;
  font-size: 1.1rem !important;
}

#side-nav:not([hidden]) .nav-label {
  flex: 1 1 auto !important;
  text-align: left !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#side-nav:not([hidden]) .nav-agent-btn {
  margin-top: 6px !important;
  border-color: rgba(0, 200, 80, 0.35) !important;
}

/* Matrix scrollbar (WebKit + Firefox) */
#side-nav {
  scrollbar-width: thin;
  scrollbar-color: #2a9a4a rgba(0, 20, 0, 0.9);
}
#side-nav::-webkit-scrollbar {
  width: 8px;
}
#side-nav::-webkit-scrollbar-track {
  background: rgba(0, 18, 0, 0.95);
  border-radius: 4px;
  margin: 4px 0;
}
#side-nav::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3dff7a 0%, #1a7a3a 100%);
  border-radius: 4px;
  border: 1px solid rgba(0, 40, 0, 0.8);
}
#side-nav::-webkit-scrollbar-thumb:hover {
  background: #55ff99;
}
#side-nav::-webkit-scrollbar-corner {
  background: transparent;
}

/* keep hamburger clear of badge */
.sections-fab {
  top: 10px !important;
  left: 10px !important;
  z-index: 95 !important;
}
#mode-badge {
  top: 12px !important;
  left: 58px !important;
  z-index: 55 !important;
}

/* nick generator modal */
.nick-options { display: flex; flex-direction: column; gap: 6px; margin: 0.75rem 0; }
.nick-opt {
  display: block; width: 100%; text-align: left;
  padding: 0.65rem 0.8rem; cursor: pointer;
  background: rgba(0, 40, 0, 0.55);
  border: 1px solid rgba(0, 200, 80, 0.35);
  color: #b8f0c4; font-family: inherit;
}
.nick-opt:hover { border-color: #00ff66; }
.nick-custom-row { display: flex; gap: 8px; margin: 0.5rem 0 0.75rem; }
.nick-custom-row input {
  flex: 1; min-width: 0;
  background: rgba(0, 20, 0, 0.9);
  border: 1px solid rgba(0, 180, 70, 0.4);
  color: #b8f0c4; padding: 0.55rem 0.65rem;
  font-family: JetBrains Mono, monospace;
}
.nick-custom-row button {
  border: 1px solid rgba(0, 200, 80, 0.45);
  background: rgba(0, 50, 0, 0.7); color: #b8f0c4;
  padding: 0.55rem 0.75rem; cursor: pointer; font-family: inherit;
}

/* Construct Arena */
#construct-arena-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
}
.arena-wrap {
  display: flex; flex-direction: column; gap: 8px;
  max-width: 100vw; padding: 8px;
}
.arena-top {
  display: flex; justify-content: space-between; align-items: center;
  color: #9de5ae; font-family: JetBrains Mono, monospace; font-size: 0.9rem;
}
.arena-top button, .arena-end button {
  background: rgba(0,40,0,0.8); border: 1px solid rgba(0,200,80,0.45);
  color: #b8f0c4; padding: 6px 12px; cursor: pointer; font-family: inherit;
}
#arena-canvas {
  display: block; max-width: 100%;
  border: 1px solid rgba(0,200,80,0.4);
  touch-action: none;
  background: #000;
}
.arena-help {
  color: #6a9a78; font-size: 0.75rem; font-family: JetBrains Mono, monospace;
}
.arena-end {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(0,12,0,0.96); border: 1px solid rgba(0,220,90,0.5);
  padding: 1.25rem; color: #b8f0c4; text-align: center; min-width: 260px;
}
.arena-end.hidden { display: none !important; }
.cmenu-sep {
  margin: 0.6rem 0 0.35rem; font-size: 0.75rem; opacity: 0.65;
  letter-spacing: 0.06em;
}

/* Matrix pills feedback */
.option-btn.pill-red {
  border-color: #e02020 !important;
  box-shadow: 0 0 16px rgba(220, 30, 30, 0.55), inset 0 0 12px rgba(180, 0, 0, 0.25) !important;
  animation: pillPulseRed 0.6s ease;
}
.option-btn.pill-blue {
  border-color: #2a6aff !important;
  box-shadow: 0 0 16px rgba(40, 100, 255, 0.5), inset 0 0 12px rgba(0, 40, 120, 0.25) !important;
  animation: pillPulseBlue 0.6s ease;
}
@keyframes pillPulseRed {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes pillPulseBlue {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.pill-toast {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%) translateY(-12px);
  z-index: 1200; padding: 12px 20px; border-radius: 999px;
  font-family: Inter, system-ui, sans-serif; font-size: 0.95rem;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  display: flex; align-items: center; gap: 10px;
}
.pill-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.pill-toast.red {
  background: rgba(40, 0, 0, 0.92); border: 1px solid #e02020; color: #ffb0b0;
}
.pill-toast.blue {
  background: rgba(0, 10, 40, 0.92); border: 1px solid #2a6aff; color: #b0c8ff;
}
.pill-icon {
  width: 18px; height: 18px; border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}
.red-pill { background: radial-gradient(circle at 30% 30%, #ff6666, #a01010); }
.blue-pill { background: radial-gradient(circle at 30% 30%, #88aaff, #1a3aaa); }

#side-nav .nav-ico-agent {
  font-size: 1.55rem !important;
  width: 36px !important;
  line-height: 1 !important;
  color: #e8eef4 !important;
  text-shadow: 0 0 10px rgba(220, 230, 240, 0.75);
}
#side-nav .nav-agent-btn {
  min-height: 52px !important;
  border-color: rgba(200, 210, 220, 0.35) !important;
}


/* ===== Digital themes: 3D + Reading (independent) ===== */
#theme-quick-bar { display: none !important; /* removed from 3D scene */
  position: fixed;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 121;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.theme-quick-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border: 1px solid rgba(0, 255, 100, 0.35);
  background: rgba(0, 12, 6, 0.88);
  color: #7dff9a;
  cursor: pointer;
  border-radius: 2px;
}
.theme-quick-btn:hover {
  border-color: rgba(0, 255, 120, 0.55);
  color: #b6ffcc;
}
.nav-theme-block {
  margin: 10px 8px 6px;
  padding: 8px;
  border: 1px solid rgba(0, 255, 80, 0.2);
  border-radius: 4px;
  background: rgba(0, 20, 10, 0.35);
}
.nav-theme-title {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(125, 255, 154, 0.7);
  margin-bottom: 6px;
}
.nav-theme-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-theme-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid rgba(0, 255, 80, 0.25);
  background: transparent;
  color: #9de5ae;
  cursor: pointer;
}
.nav-theme-btn.is-active {
  border-color: rgba(0, 255, 120, 0.65);
  background: rgba(0, 60, 30, 0.45);
  color: #c8ffd8;
}
.theme-read-panel-btn {
  margin-right: 6px;
}


/* 3D light: slightly lift UI chrome contrast without whitening hub */
html[data-theme-3d="light"] #terminal {
  background: rgba(8, 24, 14, 0.92);
}
html[data-theme-3d="light"] #theme-quick-bar .theme-quick-btn {
  background: rgba(12, 28, 18, 0.9);
}

body.reading-mode #theme-quick-bar { display: none !important; /* removed from 3D scene */
  opacity: 0.35;
  pointer-events: none;
}


/* =========================================================
   Digital Light — READING (Paper Archive)
   Surfaces light, text dark, soft green accents only
   ========================================================= */
html[data-theme-read="light"] #section-panel,
html[data-theme-read="light"] #section-panel.reading-mode {
  background: #F4F6F4 !important;
  color: #1C2B22 !important;
  border-color: #D0DAD4 !important;
  box-shadow: none !important;
}

/* Header bar: light (Google/Apple style), not black matrix strip */
html[data-theme-read="light"] #section-panel .section-panel-header,
html[data-theme-read="light"] #section-panel.reading-mode .section-panel-header {
  background: #F9FAF9 !important;
  border-bottom: 1px solid #D8E0DB !important;
  color: #1C2B22 !important;
}

html[data-theme-read="light"] #section-panel .section-panel-title,
html[data-theme-read="light"] #section-panel .section-panel-header-row,
html[data-theme-read="light"] #section-panel.reading-mode .section-panel-title {
  color: #1E4D38 !important; /* slightly green headings */
  text-shadow: none !important;
}

html[data-theme-read="light"] #section-panel .section-panel-desc,
html[data-theme-read="light"] #section-panel.reading-mode .section-panel-desc {
  color: #4A5C52 !important;
}

html[data-theme-read="light"] #section-panel .section-panel-inner,
html[data-theme-read="light"] #section-panel.reading-mode .section-panel-inner {
  background: #F4F6F4 !important;
  color: #1C2B22 !important;
  max-width: 720px;
}

html[data-theme-read="light"] #section-panel .section-panel-content,
html[data-theme-read="light"] #section-panel.reading-mode .section-panel-content {
  background: transparent !important;
  color: #1C2B22 !important;
}

/* Cards: white paper documents — NOT dark terminals */
html[data-theme-read="light"] #section-panel .section-card,
html[data-theme-read="light"] #section-panel .lecture-block,
html[data-theme-read="light"] #section-panel .lecture-main,
html[data-theme-read="light"] #section-panel .lecture-extra,
html[data-theme-read="light"] #section-panel .hologram-card,
html[data-theme-read="light"] #section-panel.reading-mode .section-card,
html[data-theme-read="light"] #section-panel.reading-mode .lecture-block {
  background: #FFFFFF !important;
  border: 1px solid #D5DFD9 !important;
  box-shadow: 0 1px 2px rgba(28, 43, 34, 0.04) !important;
  color: #1C2B22 !important;
}

html[data-theme-read="light"] #section-panel .section-card h3,
html[data-theme-read="light"] #section-panel .lecture-block h3,
html[data-theme-read="light"] #section-panel .lecture-title,
html[data-theme-read="light"] #section-panel.reading-mode .section-card h3,
html[data-theme-read="light"] #section-panel.reading-mode .lecture-block h3 {
  color: #1E4D38 !important; /* soft green titles */
  text-shadow: none !important;
}

html[data-theme-read="light"] #section-panel .section-card p,
html[data-theme-read="light"] #section-panel .lecture-block p,
html[data-theme-read="light"] #section-panel .lecture-prose .lecture-p,
html[data-theme-read="light"] #section-panel.reading-mode .section-card p,
html[data-theme-read="light"] #section-panel.reading-mode .lecture-block p {
  color: #1C2B22 !important;
  line-height: 1.65 !important;
  font-size: 16px !important;
}

html[data-theme-read="light"] #section-panel a {
  color: #2F6B4F !important;
}

html[data-theme-read="light"] #section-panel .matrix-btn,
html[data-theme-read="light"] #section-panel .reader-toggle,
html[data-theme-read="light"] #section-panel .theme-read-panel-btn,
html[data-theme-read="light"] #section-panel .quiz-close {
  background: #FFFFFF !important;
  color: #2F6B4F !important;
  border: 1px solid #B7C9BE !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

html[data-theme-read="light"] #section-panel .matrix-btn:hover,
html[data-theme-read="light"] #section-panel .reader-toggle:hover {
  background: #EEF3EF !important;
  border-color: #8FAD9A !important;
}

html[data-theme-read="light"] #section-panel .lecture-toggle,
html[data-theme-read="light"] #section-panel .block-badge {
  background: #EEF3EF !important;
  color: #2F6B4F !important;
  border-color: #C5D4CB !important;
}

html[data-theme-read="light"] #section-panel .section-panel-footer,
html[data-theme-read="light"] #section-panel.reading-mode .section-panel-footer {
  background: #F9FAF9 !important;
  border-top: 1px solid #D8E0DB !important;
}

/* Full reading: no 3D distraction */
html[data-theme-read="light"] body.reading-mode,
body.reading-mode {
  background: #F4F6F4 !important;
}
body.reading-mode #c,
body.reading-mode #terminal,
body.reading-mode #progress-indicator,
body.reading-mode #mode-badge,
body.reading-mode .sections-fab,
body.reading-mode #side-nav,
body.reading-mode #theme-quick-bar,
body.reading-mode #site-footer {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}
body.reading-mode #section-panel.reading-mode {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  z-index: 500 !important;
  border-radius: 0 !important;
  overflow: auto !important;
}
body.reading-mode #section-panel.reading-mode .section-panel-inner {
  max-width: 720px !important;
  margin: 0 auto !important;
  min-height: 100% !important;
  padding: 24px 20px 48px !important;
}

/* Dark reading stays comfortable matrix doc */
html[data-theme-read="dark"] #section-panel.reading-mode {
  background: #0a100c !important;
}
