:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: rgba(12, 18, 31, 0.82);
  --panel-strong: rgba(18, 25, 42, 0.96);
  --line: rgba(126, 242, 255, 0.23);
  --line-hot: rgba(255, 77, 196, 0.36);
  --text: #eef9ff;
  --muted: #98a6bb;
  --cyan: #52f4ff;
  --pink: #ff4dc4;
  --green: #44f28f;
  --red: #ff4c6a;
  --amber: #ffd166;
  --violet: #a18cff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(82, 244, 255, 0.06), transparent 32%),
    linear-gradient(225deg, rgba(255, 77, 196, 0.08), transparent 36%),
    linear-gradient(180deg, #070914 0%, #060910 48%, #030509 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.ambient-grid,
.ambient-stars,
.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ambient-grid {
  z-index: 0;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(82, 244, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 77, 196, 0.09) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(700px) rotateX(58deg) translateY(-28%);
  transform-origin: center top;
  animation: grid-rush 13s linear infinite;
}

.ambient-stars {
  z-index: 1;
  opacity: 0.45;
  background-image:
    radial-gradient(circle at 12% 22%, rgba(82, 244, 255, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 48% 32%, rgba(255, 209, 102, 0.85) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 18%, rgba(255, 77, 196, 0.78) 0 1px, transparent 2px),
    radial-gradient(circle at 28% 72%, rgba(68, 242, 143, 0.72) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 66%, rgba(161, 140, 255, 0.72) 0 1px, transparent 2px);
  background-size: 240px 220px, 320px 260px, 280px 300px, 360px 240px, 260px 340px;
  animation: star-drift 22s linear infinite;
}

.scanline {
  z-index: 2;
  opacity: 0.18;
  background: linear-gradient(180deg, transparent, rgba(82, 244, 255, 0.32), transparent);
  height: 24vh;
  animation: scan 7s ease-in-out infinite;
}

.shell {
  position: relative;
  z-index: 3;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: stretch;
}

.brand-block,
.control-panel,
.question-card,
.jump-panel,
.nav-row {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(9, 13, 24, 0.94), rgba(16, 23, 39, 0.78));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(18px);
}

.brand-block {
  position: relative;
  min-height: 142px;
  overflow: hidden;
  padding: 26px;
  border-radius: var(--radius);
}

.brand-block::after,
.question-card::after,
.control-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(82, 244, 255, 0.12) 42%, rgba(255, 77, 196, 0.12) 48%, transparent 56%);
  transform: translateX(-120%);
  animation: sheen 6.5s ease-in-out infinite;
}

.brand-block > *,
.control-panel > *,
.question-card > * {
  position: relative;
  z-index: 1;
}

.brand-chip {
  display: inline-flex;
  min-width: 72px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(82, 244, 255, 0.42);
  border-radius: 6px;
  color: var(--cyan);
  background: rgba(82, 244, 255, 0.08);
  font-weight: 800;
  animation: chip-flicker 3.8s steps(2, end) infinite;
}

h1 {
  margin: 16px 0 8px;
  font-size: 2.6rem;
  line-height: 1.02;
}

.brand-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.holo-book-panel {
  position: relative;
  width: 336px;
  min-height: 142px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(82, 244, 255, 0.22);
  background:
    radial-gradient(circle at 50% 72%, rgba(82, 244, 255, 0.16), transparent 34%),
    linear-gradient(145deg, rgba(7, 12, 23, 0.9), rgba(19, 14, 30, 0.8));
  box-shadow: var(--shadow), inset 0 0 36px rgba(82, 244, 255, 0.08);
  perspective: 900px;
}

.holo-book-panel::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 210px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(82, 244, 255, 0.55), rgba(82, 244, 255, 0.12) 48%, transparent 72%);
  filter: blur(2px);
  transform: translateX(-50%);
  animation: platform-pulse 2.6s ease-in-out infinite;
}

.holo-book-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-120%);
  animation: sheen 5.5s ease-in-out infinite;
}

.book-scene {
  position: absolute;
  inset: 20px 18px 12px;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  animation: book-float 3.8s ease-in-out infinite;
}

.holo-book {
  position: relative;
  width: 170px;
  height: 96px;
  transform-style: preserve-3d;
  transform: rotateX(58deg) rotateZ(-8deg);
  animation: book-yaw 7s ease-in-out infinite;
}

.book-cover,
.book-pages,
.book-spine {
  position: absolute;
  top: 0;
  height: 96px;
  border-radius: 6px;
  transform-style: preserve-3d;
}

.book-cover {
  width: 84px;
  border: 1px solid rgba(82, 244, 255, 0.45);
  background:
    linear-gradient(135deg, rgba(82, 244, 255, 0.28), rgba(255, 77, 196, 0.24)),
    linear-gradient(180deg, rgba(4, 10, 20, 0.92), rgba(6, 18, 28, 0.86));
  box-shadow: inset 0 0 22px rgba(82, 244, 255, 0.16), 0 0 18px rgba(82, 244, 255, 0.16);
}

.left-cover {
  right: 84px;
  transform-origin: right center;
  transform: rotateY(32deg);
  animation: left-page-breathe 4.2s ease-in-out infinite;
}

.right-cover {
  left: 84px;
  transform-origin: left center;
  transform: rotateY(-32deg);
  animation: right-page-breathe 4.2s ease-in-out infinite;
}

.book-spine {
  left: 80px;
  width: 10px;
  background: linear-gradient(180deg, var(--cyan), var(--pink));
  box-shadow: 0 0 18px rgba(82, 244, 255, 0.7);
}

.book-pages {
  width: 76px;
  top: 8px;
  height: 82px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(228, 250, 255, 0.08);
}

.left-pages {
  right: 86px;
  transform-origin: right center;
  transform: rotateY(24deg) translateZ(3px);
}

.right-pages {
  left: 86px;
  transform-origin: left center;
  transform: rotateY(-24deg) translateZ(3px);
}

.book-pages span {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 999px;
  background: rgba(82, 244, 255, 0.52);
  box-shadow: 0 0 8px rgba(82, 244, 255, 0.5);
  animation: text-glow 2.4s ease-in-out infinite;
}

.book-pages span:nth-child(1) { top: 22px; }
.book-pages span:nth-child(2) { top: 40px; animation-delay: 0.25s; }
.book-pages span:nth-child(3) { top: 58px; animation-delay: 0.5s; }

.holo-ring {
  position: absolute;
  left: 50%;
  bottom: 15px;
  border: 1px solid rgba(82, 244, 255, 0.28);
  border-radius: 50%;
  transform: translateX(-50%) rotateX(72deg);
}

.ring-one {
  width: 230px;
  height: 72px;
  animation: ring-spin 6s linear infinite;
}

.ring-two {
  width: 170px;
  height: 52px;
  border-color: rgba(255, 77, 196, 0.28);
  animation: ring-spin 4.8s linear infinite reverse;
}

.data-lines span {
  position: absolute;
  left: 50%;
  bottom: 38px;
  width: 2px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(82, 244, 255, 0.8), transparent);
  box-shadow: 0 0 10px rgba(82, 244, 255, 0.45);
  animation: data-rise 2.7s ease-in-out infinite;
}

.data-lines span:nth-child(1) { margin-left: -76px; animation-delay: 0.1s; }
.data-lines span:nth-child(2) { margin-left: -38px; animation-delay: 0.55s; }
.data-lines span:nth-child(3) { margin-left: 0; animation-delay: 0.25s; }
.data-lines span:nth-child(4) { margin-left: 38px; animation-delay: 0.85s; }
.data-lines span:nth-child(5) { margin-left: 76px; animation-delay: 0.4s; }
}

.control-panel {
  position: relative;
  display: grid;
  gap: 18px;
  margin-top: 20px;
  padding: 18px;
  overflow: hidden;
  border-radius: var(--radius);
}

.subject-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tab-button,
.ghost-button,
.nav-button {
  border: 1px solid rgba(152, 166, 187, 0.22);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.tab-button {
  min-height: 42px;
  min-width: 0;
  padding: 0 14px;
  color: var(--muted);
  line-height: 1.2;
  overflow-wrap: anywhere;
  white-space: normal;
}

.tab-button.is-active {
  color: #041016;
  border-color: transparent;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 24px rgba(82, 244, 255, 0.28);
}

.tab-button:hover,
.ghost-button:hover,
.nav-button:hover {
  transform: translateY(-2px);
  border-color: rgba(82, 244, 255, 0.48);
  box-shadow: 0 0 20px rgba(82, 244, 255, 0.18);
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(82, 244, 255, 0.22);
  border-radius: 7px;
  background: rgba(2, 6, 14, 0.66);
}

.search-box span {
  color: var(--cyan);
  font-size: 0.88rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-box input::placeholder {
  color: rgba(152, 166, 187, 0.74);
}

.ghost-button {
  min-height: 46px;
  padding: 0 16px;
  color: var(--text);
}

.ghost-button.danger {
  border-color: rgba(255, 76, 106, 0.26);
  color: #ffc5ce;
}

.progress-wrap {
  display: grid;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(82, 244, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--pink), var(--amber));
  box-shadow: 0 0 18px rgba(82, 244, 255, 0.4);
  transition: width 280ms ease;
  animation: progress-flow 1.7s linear infinite;
}

.quiz-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.quiz-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.question-card {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  padding: 24px;
  border-radius: var(--radius);
  animation: card-in 360ms ease both;
}

.question-card.is-correct {
  animation: answer-good 520ms ease both;
}

.question-card.is-wrong {
  animation: answer-bad 460ms ease both;
}

.card-topline {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(360px, 520px);
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.question-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid rgba(82, 244, 255, 0.28);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(82, 244, 255, 0.08);
  font-size: 0.86rem;
  font-weight: 800;
}

.pill.chance {
  border-color: rgba(255, 209, 102, 0.36);
  color: var(--amber);
  background: rgba(255, 209, 102, 0.08);
}

.mark-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 999px;
  color: var(--amber);
  background: rgba(255, 209, 102, 0.06);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.mark-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 209, 102, 0.7);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.18);
}

.mark-button.is-marked {
  color: #160f02;
  border-color: transparent;
  background: var(--amber);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.24);
}

.mark-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.live-meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.live-meter {
  position: relative;
  min-height: 66px;
  overflow: hidden;
  padding: 10px 12px;
  border: 1px solid rgba(152, 166, 187, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.live-meter::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.13;
  background: linear-gradient(135deg, currentColor, transparent 62%);
}

.live-meter strong,
.live-meter span {
  position: relative;
  z-index: 1;
  display: block;
}

.live-meter strong {
  font-size: 1.18rem;
  line-height: 1.15;
  font-weight: 900;
}

.live-meter span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.2;
}

.live-meter.correct {
  color: var(--green);
  border-color: rgba(68, 242, 143, 0.32);
}

.live-meter.wrong {
  color: var(--red);
  border-color: rgba(255, 76, 106, 0.32);
}

.live-meter.attempted {
  color: var(--cyan);
  border-color: rgba(82, 244, 255, 0.32);
}

#questionText {
  min-height: 132px;
  margin: 24px 0;
  font-size: 1.55rem;
  line-height: 1.42;
}

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

.option-button {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  min-height: 86px;
  align-items: center;
  width: 100%;
  padding: 14px;
  overflow: hidden;
  text-align: left;
  border: 1px solid rgba(152, 166, 187, 0.18);
  border-radius: var(--radius);
  color: var(--text);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
  cursor: pointer;
  isolation: isolate;
  transform: translateY(8px);
  opacity: 0;
  animation: option-rise 360ms ease forwards;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.option-button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-120%);
  transition: transform 420ms ease;
}

.option-button:hover {
  transform: translateY(-2px);
  border-color: rgba(82, 244, 255, 0.5);
  box-shadow: 0 0 24px rgba(82, 244, 255, 0.14);
}

.option-button:hover::after {
  transform: translateX(120%);
}

.option-button:disabled {
  cursor: default;
}

.option-letter {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(82, 244, 255, 0.3);
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(82, 244, 255, 0.08);
  font-weight: 900;
}

.option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.option-button.is-correct {
  opacity: 1;
  transform: translateY(0);
  border-color: rgba(68, 242, 143, 0.92);
  background: linear-gradient(145deg, rgba(68, 242, 143, 0.26), rgba(68, 242, 143, 0.08));
  box-shadow: 0 0 28px rgba(68, 242, 143, 0.24), inset 0 0 24px rgba(68, 242, 143, 0.1);
}

.option-button.is-correct .option-letter {
  color: #04120a;
  border-color: transparent;
  background: var(--green);
}

.option-button.is-wrong {
  opacity: 1;
  transform: translateY(0);
  border-color: rgba(255, 76, 106, 0.9);
  background: linear-gradient(145deg, rgba(255, 76, 106, 0.25), rgba(255, 76, 106, 0.08));
  box-shadow: 0 0 28px rgba(255, 76, 106, 0.22), inset 0 0 24px rgba(255, 76, 106, 0.08);
  animation: wrong-shake 360ms ease both;
}

.option-button.is-wrong .option-letter {
  color: #180207;
  border-color: transparent;
  background: var(--red);
}

.explanation-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(255, 209, 102, 0.26);
  border-radius: var(--radius);
  background: rgba(255, 209, 102, 0.06);
  transform-origin: top center;
  animation: explanation-open 360ms ease both;
}

.explanation-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

#answerStatus {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 900;
}

#answerStatus.good {
  color: #04120a;
  background: var(--green);
}

#answerStatus.bad {
  color: #180207;
  background: var(--red);
}

#correctAnswer {
  color: var(--amber);
  overflow-wrap: anywhere;
}

#explanationText {
  margin: 0;
  color: #d8e2f1;
  line-height: 1.65;
}

.jump-panel {
  position: sticky;
  top: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  height: calc(100vh - 52px);
  max-height: calc(100vh - 52px);
  min-height: 0;
  overflow: hidden;
  padding: 16px;
  border-radius: var(--radius);
  z-index: 4;
}

.jump-title {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 800;
}

.jump-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.jump-filter {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(152, 166, 187, 0.18);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.jump-filter:hover {
  transform: translateY(-1px);
  border-color: rgba(82, 244, 255, 0.42);
  color: var(--text);
}

.jump-filter.is-active {
  color: #041016;
  border-color: transparent;
  background: var(--cyan);
}

.question-rail {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 3px 2px 0;
  scrollbar-color: rgba(82, 244, 255, 0.42) rgba(255, 255, 255, 0.05);
  scrollbar-width: thin;
}

.question-rail::-webkit-scrollbar {
  width: 8px;
}

.question-rail::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

.question-rail::-webkit-scrollbar-thumb {
  background: rgba(82, 244, 255, 0.42);
  border-radius: 999px;
}

.rail-button {
  position: relative;
  min-height: 40px;
  border: 1px solid rgba(152, 166, 187, 0.18);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.rail-button:hover {
  transform: translateY(-1px);
  border-color: rgba(82, 244, 255, 0.44);
  color: var(--text);
}

.rail-button.is-current {
  color: #041016;
  border-color: transparent;
  background: var(--cyan);
}

.rail-button.is-correct {
  color: #06130b;
  border-color: transparent;
  background: var(--green);
}

.rail-button.is-wrong {
  color: #19040a;
  border-color: transparent;
  background: var(--red);
}

.rail-button.is-marked::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.7);
}

.nav-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
}

.nav-button {
  min-height: 56px;
  padding: 0 18px;
  font-weight: 900;
}

.nav-button.primary {
  color: #031013;
  border-color: transparent;
  background: linear-gradient(135deg, var(--cyan), var(--pink), var(--amber));
  box-shadow: 0 0 26px rgba(255, 77, 196, 0.18);
}

.nav-button.primary.is-finish {
  background: linear-gradient(135deg, var(--green), var(--cyan), var(--amber));
  box-shadow: 0 0 30px rgba(68, 242, 143, 0.28);
}

.nav-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(82, 244, 255, 0.32);
  border-radius: 7px;
  color: var(--text);
  background: rgba(5, 9, 18, 0.94);
  box-shadow: var(--shadow);
  transform: translateY(22px);
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms ease, opacity 220ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.chat-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 28;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(82, 244, 255, 0.55);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.52), transparent 16%),
    linear-gradient(135deg, var(--cyan), var(--pink));
  box-shadow: 0 0 26px rgba(82, 244, 255, 0.32), var(--shadow);
  cursor: pointer;
}

.chat-fab span {
  position: relative;
  width: 27px;
  height: 20px;
  border-radius: 7px;
  background: #061019;
}

.chat-fab span::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: -5px;
  width: 9px;
  height: 9px;
  background: #061019;
  transform: rotate(45deg);
}

.chat-panel {
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 29;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(390px, calc(100vw - 28px));
  height: min(520px, calc(100vh - 116px));
  overflow: hidden;
  border: 1px solid rgba(82, 244, 255, 0.3);
  border-radius: var(--radius);
  background: rgba(7, 12, 23, 0.96);
  box-shadow: var(--shadow), 0 0 36px rgba(82, 244, 255, 0.16);
  backdrop-filter: blur(18px);
  animation: dialog-in 180ms ease both;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(82, 244, 255, 0.18);
}

.chat-head strong,
.chat-head span {
  display: block;
}

.chat-head strong {
  font-size: 1rem;
}

.chat-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

#chatCloseButton {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(152, 166, 187, 0.22);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-weight: 900;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid rgba(152, 166, 187, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.chat-message.user {
  justify-self: end;
  border-color: rgba(82, 244, 255, 0.28);
  background: rgba(82, 244, 255, 0.09);
}

.chat-message.bot {
  justify-self: start;
  border-color: rgba(255, 209, 102, 0.22);
}

.chat-message p {
  margin: 0;
  color: #dfe8f4;
  line-height: 1.45;
}

.chat-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chat-choice,
.chat-form button {
  min-height: 36px;
  border: 1px solid rgba(82, 244, 255, 0.3);
  border-radius: 7px;
  color: #031013;
  background: var(--cyan);
  cursor: pointer;
  font-weight: 900;
}

.chat-choice {
  padding: 0 18px;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(82, 244, 255, 0.18);
}

.chat-form input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(82, 244, 255, 0.22);
  border-radius: 7px;
  outline: 0;
  padding: 0 12px;
  color: var(--text);
  background: rgba(2, 6, 14, 0.78);
}

.chat-form input:focus {
  border-color: rgba(82, 244, 255, 0.62);
  box-shadow: 0 0 18px rgba(82, 244, 255, 0.14);
}

.chat-form button {
  padding: 0 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(1, 4, 10, 0.72);
  backdrop-filter: blur(12px);
}

.reset-dialog {
  position: relative;
  width: min(470px, 100%);
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(255, 76, 106, 0.46);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(13, 18, 31, 0.98), rgba(26, 15, 32, 0.96));
  box-shadow: var(--shadow), 0 0 42px rgba(255, 76, 106, 0.18);
  animation: dialog-in 220ms ease both;
}

.dialog-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent, rgba(255, 76, 106, 0.16), transparent);
  transform: translateX(-120%);
  animation: sheen 4s ease-in-out infinite;
}

.reset-dialog h2,
.reset-dialog p,
.confirm-field,
.dialog-actions {
  position: relative;
  z-index: 1;
}

.reset-dialog h2 {
  margin: 0 0 10px;
  font-size: 1.45rem;
}

.reset-dialog p {
  margin: 0 0 18px;
  color: #d8e2f1;
  line-height: 1.55;
}

.reset-dialog strong {
  color: var(--red);
}

.confirm-field {
  display: grid;
  gap: 8px;
}

.confirm-field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.confirm-field input {
  min-height: 48px;
  width: 100%;
  border: 1px solid rgba(255, 76, 106, 0.3);
  border-radius: 7px;
  outline: 0;
  padding: 0 14px;
  color: var(--text);
  background: rgba(2, 6, 14, 0.7);
}

.confirm-field input:focus {
  border-color: rgba(82, 244, 255, 0.62);
  box-shadow: 0 0 20px rgba(82, 244, 255, 0.16);
}

.test-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.dialog-button {
  min-height: 48px;
  border: 1px solid rgba(152, 166, 187, 0.24);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.dialog-button:hover {
  transform: translateY(-1px);
  border-color: rgba(82, 244, 255, 0.45);
  box-shadow: 0 0 20px rgba(82, 244, 255, 0.14);
}

.dialog-button.yes {
  color: #180207;
  border-color: transparent;
  background: var(--red);
}

.dialog-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.celebration-backdrop {
  background:
    radial-gradient(circle at 50% 28%, rgba(82, 244, 255, 0.18), transparent 34%),
    rgba(1, 4, 10, 0.78);
}

.completion-dialog {
  position: relative;
  width: min(620px, 100%);
  overflow: hidden;
  padding: 28px;
  border: 1px solid rgba(82, 244, 255, 0.5);
  border-radius: var(--radius);
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(68, 242, 143, 0.16), transparent 32%),
    linear-gradient(145deg, rgba(9, 15, 28, 0.98), rgba(20, 16, 34, 0.96));
  box-shadow: var(--shadow), 0 0 54px rgba(82, 244, 255, 0.22);
  animation: completion-pop 360ms ease both;
}

.celebration-aura {
  position: absolute;
  inset: -80px;
  opacity: 0.26;
  background: conic-gradient(from 0deg, var(--cyan), var(--pink), var(--amber), var(--green), var(--cyan));
  animation: spin-ring 8s linear infinite;
}

.completion-badge,
.completion-dialog h2,
.completion-dialog p,
.completion-stats,
.completion-actions {
  position: relative;
  z-index: 1;
}

.completion-badge {
  display: inline-grid;
  width: 74px;
  height: 74px;
  place-items: center;
  margin-bottom: 16px;
  border: 1px solid rgba(82, 244, 255, 0.6);
  border-radius: 50%;
  color: #031013;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 28px rgba(82, 244, 255, 0.36);
  font-weight: 1000;
}

.completion-dialog h2 {
  margin: 0 0 10px;
  font-size: 2rem;
  line-height: 1.12;
}

.completion-dialog p {
  max-width: 470px;
  margin: 0 auto 20px;
  color: #d8e2f1;
  line-height: 1.55;
}

.completion-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.completion-stats div {
  min-height: 78px;
  padding: 12px;
  border: 1px solid rgba(82, 244, 255, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
}

.completion-stats strong,
.completion-stats span {
  display: block;
}

.completion-stats strong {
  color: var(--cyan);
  font-size: 1.45rem;
  line-height: 1.1;
}

.completion-stats span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.completion-actions {
  grid-template-columns: repeat(4, 1fr);
}

.redo-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.redo-choice {
  display: grid;
  gap: 6px;
  min-height: 94px;
  align-content: center;
  border: 1px solid rgba(82, 244, 255, 0.24);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.redo-choice:hover {
  transform: translateY(-2px);
  border-color: rgba(82, 244, 255, 0.55);
  box-shadow: 0 0 22px rgba(82, 244, 255, 0.16);
}

.redo-choice strong,
.redo-choice span {
  display: block;
}

.redo-choice strong {
  color: var(--cyan);
  font-size: 1.1rem;
}

.redo-choice span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.redo-choice:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.celebration-piece {
  position: fixed;
  top: -18px;
  z-index: 31;
  width: 8px;
  height: 16px;
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 12px currentColor;
  animation: celebration-fall 2.55s ease-in forwards;
}

.spark {
  position: fixed;
  z-index: 19;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  pointer-events: none;
  animation: spark-flight 700ms ease-out forwards;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@keyframes grid-rush {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 48px, 48px 0; }
}

@keyframes star-drift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  to { background-position: 240px 220px, -320px 260px, 280px -300px, -360px -240px, 260px 340px; }
}

@keyframes scan {
  0%, 100% { transform: translateY(-35vh); }
  50% { transform: translateY(115vh); }
}

@keyframes sheen {
  0%, 52% { transform: translateX(-120%); }
  68%, 100% { transform: translateX(120%); }
}

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

@keyframes platform-pulse {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(0.92); }
  50% { opacity: 0.95; transform: translateX(-50%) scale(1.08); }
}

@keyframes book-float {
  0%, 100% { transform: translateY(4px); }
  50% { transform: translateY(-8px); }
}

@keyframes book-yaw {
  0%, 100% { transform: rotateX(58deg) rotateZ(-8deg) rotateY(-8deg); }
  50% { transform: rotateX(58deg) rotateZ(-8deg) rotateY(8deg); }
}

@keyframes left-page-breathe {
  0%, 100% { transform: rotateY(32deg); }
  50% { transform: rotateY(42deg); }
}

@keyframes right-page-breathe {
  0%, 100% { transform: rotateY(-32deg); }
  50% { transform: rotateY(-42deg); }
}

@keyframes text-glow {
  0%, 100% { opacity: 0.42; transform: scaleX(0.82); }
  50% { opacity: 1; transform: scaleX(1); }
}

@keyframes ring-spin {
  to { transform: translateX(-50%) rotateX(72deg) rotateZ(360deg); }
}

@keyframes data-rise {
  0% { opacity: 0; transform: translateY(16px) scaleY(0.4); }
  45% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-58px) scaleY(1); }
}

@keyframes chip-flicker {
  0%, 88%, 100% { opacity: 1; }
  90% { opacity: 0.55; }
  92% { opacity: 1; }
}

@keyframes progress-flow {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(55deg); }
}

@keyframes card-in {
  from { transform: translateY(14px) scale(0.992); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes option-rise {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes explanation-open {
  from { transform: scaleY(0.88); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes answer-good {
  0%, 100% { box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.025); }
  40% { box-shadow: var(--shadow), 0 0 44px rgba(68, 242, 143, 0.32), inset 0 0 40px rgba(68, 242, 143, 0.12); }
}

@keyframes answer-bad {
  0%, 100% { box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.025); }
  40% { box-shadow: var(--shadow), 0 0 44px rgba(255, 76, 106, 0.32), inset 0 0 40px rgba(255, 76, 106, 0.1); }
}

@keyframes spark-flight {
  to {
    transform: translate(var(--spark-x), var(--spark-y)) scale(0);
    opacity: 0;
  }
}

@keyframes dialog-in {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes completion-pop {
  from { transform: translateY(18px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes celebration-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -20px, 0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--fall-x), 112vh, 0) rotate(var(--spin));
  }
}

@media (max-width: 980px) {
  .topbar,
  .quiz-stage {
    grid-template-columns: 1fr;
  }

  .card-topline {
    grid-template-columns: 1fr;
  }

  .live-meters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .holo-book-panel {
    width: 100%;
    min-height: 126px;
  }

  .jump-panel {
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .question-rail {
    grid-template-columns: repeat(10, minmax(40px, 1fr));
    max-height: 188px;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 1240px);
    padding-top: 14px;
  }

  h1 {
    font-size: 2rem;
  }

  .brand-block,
  .question-card {
    padding: 18px;
  }

  .options-grid,
  .nav-row {
    grid-template-columns: 1fr;
  }

  .subject-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tab-button {
    width: 100%;
    min-height: 48px;
    padding: 8px 10px;
  }

  .tool-row {
    grid-template-columns: 1fr;
  }

  .test-grid {
    grid-template-columns: 1fr;
  }

  .completion-stats,
  .completion-actions,
  .redo-grid {
    grid-template-columns: 1fr;
  }

  .completion-dialog h2 {
    font-size: 1.55rem;
  }

  .holo-book-panel {
    min-height: 118px;
  }

  .option-button {
    min-height: 76px;
  }

  .live-meters {
    grid-template-columns: 1fr;
  }

  .live-meter {
    min-height: 56px;
  }

  .chat-fab {
    right: 14px;
    bottom: 14px;
  }

  .chat-panel {
    right: 14px;
    bottom: 84px;
    height: min(500px, calc(100vh - 104px));
  }

  #questionText {
    min-height: 0;
    font-size: 1.22rem;
  }
}

/* Energy flicker effect on spine (suggests active power) */
.book-spine {
  animation: spine-flicker 0.08s steps(2, end) infinite, book-spine-energy 2.8s ease-in-out infinite;
}
@keyframes spine-flicker { 0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 0.95; } 20%, 24%, 55% { opacity: 0.75; } }
@keyframes book-spine-energy { 0%, 100% { filter: drop-shadow(0 0 18px rgba(82,244,255,0.7)); } 50% { filter: drop-shadow(0 0 32px rgba(255,77,196,0.5)); } }

/* Enhance chromatic aberration: subtle triple-layer effect */
.book-scene { filter: drop-shadow(2px 0 4px rgba(255,77,196,0.08)) drop-shadow(-2px 0 4px rgba(82,244,255,0.08)); }

/* Glow on pages for inner luminosity */
.book-pages span { animation: text-glow 2.4s ease-in-out infinite, text-shimmer 3.2s ease-in-out infinite; }
@keyframes text-shimmer { 0% { opacity: 0.4; } 50% { opacity: 0.8; } 100% { opacity: 0.4; } }

/* Ring glow pulses */
.holo-ring { animation: ring-glow-pulse 3.4s ease-in-out infinite; }
@keyframes ring-glow-pulse { 0%, 100% { filter: drop-shadow(0 0 8px rgba(82,244,255,0.24)); } 50% { filter: drop-shadow(0 0 24px rgba(82,244,255,0.42)); } }

/* Increased bloom on data-lines */
.data-lines span { filter: drop-shadow(0 0 16px rgba(82,244,255,0.65)) drop-shadow(0 4px 12px rgba(82,244,255,0.35)); }

/* Toggle Animation Button */
.toggle-animation-button {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--cyan);
  border-radius: 4px;
  cursor: pointer;
  transition: all 180ms ease;
  backdrop-filter: blur(8px);
}

.toggle-animation-button:hover {
  background: rgba(82, 244, 255, 0.12);
  box-shadow: 0 0 16px rgba(82, 244, 255, 0.32), inset 0 0 8px rgba(82, 244, 255, 0.08);
}

.toggle-animation-button:active {
  transform: scale(0.98);
}

.toggle-animation-button.is-disabled {
  color: var(--red);
  border-color: var(--red);
}

.toggle-animation-button.is-disabled:hover {
  background: rgba(255, 76, 106, 0.12);
  box-shadow: 0 0 16px rgba(255, 76, 106, 0.32), inset 0 0 8px rgba(255, 76, 106, 0.08);
}

/* Disable all animations */
body.no-animations,
body.no-animations * {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

body.no-animations *::before,
body.no-animations *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
