:root {
  --text: rgba(0, 0, 0, 0.86);
  --muted: rgba(0, 0, 0, 0.62);
  --border: rgba(0, 0, 0, 0.12);
  --bg: #fff;
  --max: 900px;
  --link: #457b9d;
  --link-hover: #1d3557;
}

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

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

html,
body {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.55;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

header {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 6px;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

h2 {
  margin-top: 34px;
  font-size: 22px;
}

h3 {
  margin-top: 22px;
  font-size: 18px;
}

p {
  margin: 10px 0;
}

.theorem {
  border: 1px solid var(--border);
  border-left: 4px solid rgba(0, 0, 0, 0.55);
  padding: 14px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
}

.label {
  font-weight: 650;
}

code {
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 6px;
  border-radius: 6px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.canvas {
  display: block;
  width: 100%;
}

.canvas--hero {
  height: 420px;
}

.canvas--mid {
  height: 380px;
}

.caption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.widget-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 30px 0;
}

@media (max-width: 768px) {
  .widget-grid {
    grid-template-columns: 1fr;
  }
}


/* Navigation Container (Wrapper for Arrow & ToC) */
.nav-container {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 100;
  transition: transform 0.3s ease;
  /* Smooth slide up/down */
}

.nav-container.nav-hidden {
  transform: translateY(-150%);
  /* Slide out of view (upwards) */
}

/* Back Arrow Style */
.back-home {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-size: 20px;
  color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s, color 0.2s;
  cursor: pointer;
  margin-bottom: 8px;
  /* Space between arrow and toc button */
}

/* ToC Trigger Button style */
.toc-trigger {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-size: 20px;
  color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s, color 0.2s;
  cursor: pointer;
  margin-bottom: 12px;
  /* Space between button and dropdown */
}

/* ToC Wrapper - Constrains hover area */
.toc-wrapper {
  position: relative;
  width: fit-content;
}

/* Hover effect on the container triggers highlight */
.toc-wrapper:hover .toc-trigger,
.toc-trigger:hover {
  transform: translateX(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  color: var(--link);
}

/* Hover effect on the container triggers arrow highlight too */
.nav-container:hover .back-home,
.back-home:hover {
  transform: translateX(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  text-decoration: none;
  color: var(--link);
}

/* Table of Contents - Dropdown Style */
.toc {
  position: absolute;
  /* Take out of flow */
  top: 100%;
  /* Position below trigger */
  left: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  width: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* Initial hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Reveal ToC on hover */
.toc-wrapper:hover .toc {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toc h3 {
  margin-top: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin-bottom: 4px;
}

.toc a {
  display: block;
  font-size: 14px;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.toc a:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--link);
  text-decoration: none;
}

/* Blur Effect on Main Content */
.wrap {
  transition: filter 0.3s ease;
}

.toc-wrapper:hover~.wrap {
  filter: blur(4px);
}

/* Responsive Math - Shrink to fit */
/* Responsive Math - Auto-scaling handled by JS */
.katex-display {
  overflow-x: hidden;
  overflow-y: hidden;
  max-width: 100%;
}