:root {
  color-scheme: light;
  --background: #ffffff;
  --surface: #f8faf9;
  --surface-raised: #f2f5f3;
  --text: #171a18;
  --muted: #59635f;
  --line: #d7deda;
  --control-line: #87928d;
  --accent: #006f63;
  --content: 1120px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration-color: var(--line);
  text-underline-offset: 0.22em;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.55rem 0.8rem;
  background: var(--text);
  color: var(--background);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--background);
}

.header-inner {
  width: min(calc(100% - 2rem), var(--content));
  min-height: 4rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.site-name {
  font-weight: 650;
  text-decoration: none;
  letter-spacing: -0.01em;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem 1.1rem;
  font-size: 0.86rem;
  color: var(--muted);
}

main {
  width: min(calc(100% - 2rem), var(--content));
  margin: 0 auto;
}

.introduction {
  max-width: 860px;
  padding: clamp(3.5rem, 8vw, 7rem) 0 clamp(3rem, 6vw, 5rem);
}

.overline,
.index,
figcaption {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.overline { margin: 0 0 1rem; }

h1,
h2,
p { margin-top: 0; }

h1 {
  margin-bottom: 1.25rem;
  max-width: 820px;
  font-size: clamp(2.35rem, 5.5vw, 4.35rem);
  font-weight: 570;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.lead {
  max-width: 780px;
  margin-bottom: 1.25rem;
  color: #37413d;
  font-size: clamp(1.03rem, 1.7vw, 1.2rem);
}

.scope-statement {
  max-width: 780px;
  margin-bottom: 2rem;
  color: #37413d;
  font-size: 0.98rem;
}

.notation-legend {
  max-width: 780px;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.inline-math { white-space: normal; }

.no-break-math,
.no-break-math mjx-container {
  display: inline-block;
  white-space: nowrap;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: var(--accent);
}

.catalog-meta {
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.catalog-meta p {
  max-width: 570px;
  margin-bottom: 0;
}

.motion-toggle {
  position: fixed;
  z-index: 9;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  max-width: calc(100vw - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right));
  min-height: 2.5rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--control-line);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  white-space: nowrap;
}

.motion-toggle[hidden] { display: none; }

.motion-toggle:hover { border-color: var(--accent); }

.motion-icon {
  display: inline-block;
  width: 1.2rem;
  color: var(--accent);
}

.paper-context {
  max-width: 800px;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0;
  border-top: 1px solid var(--line);
}

.paper-context h2 { margin-bottom: 1rem; }

.paper-context p {
  max-width: 740px;
  margin-bottom: 1rem;
  color: #37413d;
}

.paper-context .overline { color: var(--muted); }

.paper-context .paper-caveat {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.symmetry-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.symmetry-list > li { border-bottom: 1px solid var(--line); }

.symmetry {
  padding: clamp(2.5rem, 6vw, 5rem) 0;
}

.symmetry > header {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: start;
  gap: 1rem 1.5rem;
  margin-bottom: 1.6rem;
}

.symmetry > header > * { min-width: 0; }

.index {
  margin: 0.35rem 0 0;
  font-variant-numeric: tabular-nums;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  font-weight: 580;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.symmetry header p:not(.index) {
  max-width: 570px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.symmetry header p.paper-status {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.paper-status strong {
  color: var(--text);
  font-weight: 620;
}

.symmetry-math {
  width: 100%;
  min-width: 0;
  display: grid;
  justify-items: end;
  gap: 0.2rem;
}

.orbifold {
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
  text-align: right;
}

.symmetry header p.orbifold {
  color: var(--text);
  font-size: 1rem;
}

.formula {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--accent);
  scrollbar-width: thin;
}

.orbifold mjx-container {
  max-width: 100%;
  margin: 0 !important;
}

.formula mjx-container[display="true"] {
  max-width: 100%;
  margin: 0.15rem 0 0.45rem !important;
  text-align: right !important;
}

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

figure { margin: 0; }

.media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--surface-raised);
}

.media img,
.media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media img[hidden],
.media video[hidden] {
  display: none;
}

figcaption { margin-top: 0.55rem; }

.animation-controls {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(4rem, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.animation-toggle {
  min-height: 2.75rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--control-line);
  border-radius: 3px;
  background: var(--background);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
}

.animation-toggle:hover { border-color: var(--accent); }

.animation-icon {
  width: 0.9rem;
  color: var(--accent);
  text-align: center;
}

.phase-slider {
  width: 100%;
  min-width: 0;
  height: 2.75rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.phase-output {
  min-width: 3.25rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.animation-controls[data-state="error"] {
  opacity: 0.68;
}

.animation-toggle:disabled,
.phase-slider:disabled {
  cursor: not-allowed;
}

footer {
  padding: 3rem 0 4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

footer p { margin-bottom: 0.45rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 800px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
  }

  nav { justify-content: flex-start; }

  .symmetry > header {
    grid-template-columns: 2rem 1fr;
  }

  .symmetry-math {
    grid-column: 2;
    justify-items: start;
  }

  .orbifold { text-align: left; }

  .formula mjx-container[display="true"] { text-align: left !important; }

  .motif-strip { margin-left: 3rem; }
}

@media (min-width: 621px) and (max-width: 800px) {
  .animation-toggle {
    width: 2.75rem;
    padding-inline: 0;
  }

  .animation-label { display: none; }
}

@media (max-width: 620px) {
  main,
  .header-inner { width: min(calc(100% - 1.25rem), var(--content)); }

  .introduction { padding-top: 3.5rem; }

  .symmetry > header {
    grid-template-columns: 1.7rem 1fr;
    gap: 0.7rem;
  }

  .motif-strip {
    grid-template-columns: 1fr;
    margin-left: 2.4rem;
  }

  .media { max-width: 520px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
