:root {
  --bg-1: #eef6ff;
  --bg-2: #d9e8f7;
  --ink: #14263d;
  --muted: #50627a;
  --line: rgba(29, 71, 115, 0.14);
  --card: rgba(251, 253, 255, 0.82);
  --card-strong: #f7fbff;
  --accent: #2f6fed;
  --accent-2: #1d8fbd;
  --shadow: 0 24px 70px rgba(20, 38, 61, 0.14);
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Avenir Next", "Noto Sans SC", "PingFang SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.8),
      transparent 38%
    ),
    radial-gradient(
      circle at 85% 18%,
      rgba(47, 111, 237, 0.16),
      transparent 22%
    ),
    radial-gradient(
      circle at 18% 82%,
      rgba(29, 143, 189, 0.15),
      transparent 26%
    ),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(20, 38, 61, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 38, 61, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 85%);
}

.deck {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.deck-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.24);
  z-index: 12;
}

.deck-progress-bar {
  width: 25%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #5ca9ff);
  transition: width 220ms ease;
}

.slides {
  position: relative;
  flex: 1;
  overflow: hidden;
  container-type: size;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.slide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100cqw, calc(100cqh * 16 / 9));
  max-height: 100cqh;
  aspect-ratio: 16 / 9;
  padding: clamp(28px, 3cqh, 60px) clamp(32px, 3.2cqw, 72px);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.82),
      rgba(245, 250, 255, 0.72)
    ),
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.55),
      rgba(255, 255, 255, 0.16)
    );
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.985);
  transition:
    opacity 260ms ease,
    transform 260ms ease;
  pointer-events: none;
  display: grid;
  align-content: center;
  gap: 1.25rem;
  overflow: hidden;
}

.slide::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(
      circle at top right,
      rgba(47, 111, 237, 0.16),
      transparent 30%
    ),
    radial-gradient(
      circle at bottom left,
      rgba(29, 143, 189, 0.14),
      transparent 34%
    );
}

.slide > * {
  position: relative;
  z-index: 1;
}

.slide.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.slide-cover {
  align-content: space-between;
}

.slide-closing {
  justify-items: center;
  text-align: center;
}

.slide-kicker,
.tag {
  width: fit-content;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(29, 71, 115, 0.16);
  background: rgba(247, 251, 255, 0.8);
  color: var(--muted);
  letter-spacing: 0.04em;
  font-size: 0.82rem;
  text-transform: uppercase;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 4.5cqw, 4.7rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

h2 {
  max-width: 40ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3.2cqw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

h3 {
  font-size: clamp(1rem, 1.35cqw, 1.24rem);
  line-height: 1.2;
}

p,
li {
  color: var(--muted);
  font-size: clamp(0.98rem, 1.25cqw, 1.22rem);
  line-height: 1.6;
}

.lead {
  max-width: 42rem;
  color: #38506d;
  font-size: clamp(1.08rem, 1.55cqw, 1.45rem);
}

code {
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", monospace;
  font-size: 0.86em;
  padding: 0.14em 0.42em;
  border-radius: 999px;
  border: 1px solid rgba(29, 71, 115, 0.12);
  background: rgba(255, 255, 255, 0.7);
  color: #173a61;
}

.meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.meta-card,
.panel,
.card,
.quote-band {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 10px 30px rgba(54, 40, 26, 0.06);
}

.formula-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
  align-items: start;
}

.formula-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1.3rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(250, 253, 255, 0.82);
  box-shadow: 0 10px 30px rgba(54, 40, 26, 0.06);
}

.formula-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.2rem 0;
}

.formula-block {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(29, 71, 115, 0.1);
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    rgba(47, 111, 237, 0.08),
    rgba(255, 255, 255, 0.9)
  );
  overflow-x: auto;
}

.formula-note {
  color: #38506d;
  font-size: 0.92rem;
  line-height: 1.5;
}

.formula-code {
  display: block;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 16px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.formula-rendered {
  border: 1px solid rgba(29, 71, 115, 0.1);
  background: rgba(255, 255, 255, 0.72);
}

.formula-rendered .katex-display {
  margin: 0;
}

.formula-source {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px dashed rgba(29, 71, 115, 0.18);
  border-radius: 16px;
  background: rgba(244, 249, 255, 0.86);
  color: #31506f;
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
}

.formula-panel .katex-display {
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.formula-panel .katex {
  font-size: 1.08em;
}

.formula-panel p > .katex {
  font-size: 1em;
}

.meta-card {
  display: grid;
  gap: 0.45rem;
  padding: 1rem 1.1rem;
}

.meta-card strong {
  font-size: 1.05rem;
}

.meta-label {
  color: #6c7f96;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.split-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
}

.panel {
  padding: 1.35rem;
  display: grid;
  gap: 0.8rem;
}

.soft-panel {
  background: linear-gradient(
    180deg,
    rgba(250, 253, 255, 0.88),
    rgba(241, 247, 255, 0.8)
  );
}

.accent-panel {
  background: linear-gradient(
    160deg,
    rgba(29, 143, 189, 0.12),
    rgba(255, 255, 255, 0.78)
  );
}

.clean-list {
  padding-left: 1.15rem;
}

.clean-list li + li {
  margin-top: 0.45rem;
}

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

.card {
  position: relative;
  min-height: 13rem;
  padding: 1.25rem;
  display: grid;
  align-content: start;
  gap: 0.8rem;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.88),
    rgba(243, 248, 255, 0.78)
  );
}

.card-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #6bb6ff);
  color: #f6fbff;
  font-weight: 700;
  font-size: 0.9rem;
}

.quote-band {
  margin-top: 0.2rem;
  padding: 1rem 1.15rem;
  background: linear-gradient(
    90deg,
    rgba(47, 111, 237, 0.1),
    rgba(255, 255, 255, 0.76)
  );
}

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

.symbol-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(20, 38, 61, 0.05);
}

.symbol-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 800;
  color: #f6fbff;
  background: linear-gradient(135deg, var(--accent), #6bb6ff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.symbol-card-note .symbol-badge {
  background: linear-gradient(135deg, #3979f2, #70b5ff);
}

.symbol-card-tip .symbol-badge {
  background: linear-gradient(135deg, #1d8fbd, #58c5e8);
}

.symbol-card-alert .symbol-badge {
  background: linear-gradient(135deg, #1c63c7, #4f8fff);
}

.symbol-card-star .symbol-badge {
  background: linear-gradient(135deg, #2f6fed, #7bc0ff);
}

.micro-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1rem;
  align-items: stretch;
}

.mini-callout {
  display: grid;
  gap: 0.55rem;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(47, 111, 237, 0.14);
  border-radius: 20px;
  background: linear-gradient(
    135deg,
    rgba(47, 111, 237, 0.1),
    rgba(255, 255, 255, 0.82)
  );
}

.mini-label {
  width: fit-content;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(47, 111, 237, 0.14);
  color: #2754a8;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.step-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.step-chip {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  padding: 0.95rem 0.75rem;
  border: 1px solid rgba(29, 71, 115, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  text-align: center;
}

.step-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.1);
  color: #2754a8;
  font-weight: 800;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.45rem 0.7rem 0.55rem;
  background: rgba(247, 251, 255, 0.76);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(29, 71, 115, 0.08);
}

.left,
.right,
.counter-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.counter-wrap {
  flex-direction: column;
  gap: 0.2rem;
}

button,
.jump-input {
  height: 2.1rem;
  border-radius: 999px;
  font: inherit;
}

button {
  border: 1px solid rgba(29, 71, 115, 0.1);
  padding: 0 0.8rem;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
  font-size: 0.9rem;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(47, 111, 237, 0.24);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

#nextBtn,
#fullscreenBtn {
  background: linear-gradient(135deg, var(--accent), #6bb6ff);
  color: #f6fbff;
  border-color: transparent;
}

#nextBtn:hover,
#fullscreenBtn:hover {
  background: linear-gradient(135deg, #245dd0, #51a0f1);
}

.counter {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
}

.jump-input {
  width: 3.6rem;
  border: 1px solid rgba(29, 71, 115, 0.12);
  padding: 0 0.7rem;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-size: 0.9rem;
}

.jump-input:focus {
  outline: 2px solid rgba(47, 111, 237, 0.3);
  outline-offset: 2px;
}

.help-panel {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 11;
  width: min(21rem, calc(100vw - 2rem));
  padding: 1rem 1.1rem;
  border: 1px solid rgba(29, 71, 115, 0.1);
  border-radius: 22px;
  background: rgba(247, 251, 255, 0.94);
  box-shadow: 0 20px 60px rgba(20, 38, 61, 0.16);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.help-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.help-panel h3 {
  margin-bottom: 0.75rem;
}

@media (max-width: 900px) {
  .slides {
    padding: 0.5rem;
  }

  .meta-row,
  .split-layout,
  .grid,
  .formula-layout,
  .symbol-grid,
  .micro-layout,
  .step-row {
    grid-template-columns: 1fr;
  }

  .slide {
    padding: 1.2rem;
    border-radius: 20px;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .counter-wrap {
    order: 3;
    width: 100%;
  }

  .right {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 0;
  }

  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body,
  .deck,
  .slides {
    height: auto;
    background: #ffffff;
  }

  body::before,
  .deck-progress,
  .help-panel,
  .controls {
    display: none !important;
  }

  .deck {
    display: block;
  }

  .slides {
    position: static;
    display: block;
    overflow: visible;
    container-type: normal;
    padding: 0;
  }

  .slide {
    position: static;
    width: auto;
    max-height: none;
    min-height: 100vh;
    aspect-ratio: auto;
    top: auto;
    left: auto;
    page-break-after: always;
    break-after: page;
    opacity: 1 !important;
    transform: none !important;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    background: #ffffff;
    padding: 1cm 1.25cm;
    overflow: visible;
  }

  .slide::before {
    display: none;
  }

  .meta-row,
  .split-layout,
  .grid,
  .formula-layout,
  .symbol-grid,
  .micro-layout,
  .step-row {
    gap: 0.5cm;
  }

  .meta-card,
  .panel,
  .card,
  .quote-band,
  .formula-panel,
  .symbol-card,
  .mini-callout,
  .step-chip {
    border: 1px solid #d6d0c6;
    background: #ffffff;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .card-index,
  .symbol-badge,
  .step-chip span {
    color: #ffffff !important;
    background: #2f6fed !important;
  }

  .mini-label,
  .tag,
  .slide-kicker,
  code {
    border-color: #c9d7ea;
    background: #f3f8ff;
  }
}
