:root {
  color-scheme: dark;
  --bg: #06070b;
  --bg-soft: #0d1018;
  --panel: rgba(13, 17, 27, 0.82);
  --panel-strong: rgba(17, 22, 34, 0.92);
  --line: rgba(190, 205, 255, 0.16);
  --line-strong: rgba(190, 205, 255, 0.28);
  --text: #f6f7fb;
  --muted: rgba(230, 236, 255, 0.68);
  --accent: #89f0ff;
  --accent-2: #ffae70;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(82, 180, 255, 0.14), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(255, 153, 71, 0.16), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(61, 98, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #04050a 0%, #070910 48%, #04050a 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero-panel,
.toolbar-panel,
.showcase-panel,
.viewer-preview,
.viewer-code-panel {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel,
.toolbar-panel,
.showcase-panel {
  overflow: hidden;
}

.hero-panel::before,
.toolbar-panel::before,
.showcase-panel::before,
.viewer-preview::before,
.viewer-code-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 28%);
}

.hero-panel {
  padding: 48px 28px;
  border-radius: 30px;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.hero-copy-centered {
  max-width: 960px;
  margin: 0 auto;
  text-align: center;
}

.section-kicker,
.viewer-tag,
.viewer-code-label,
.filter-chip {
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-kicker,
.viewer-tag,
.viewer-code-label {
  margin: 0 0 12px;
  font-size: 11px;
  color: var(--accent);
}

.hero-title,
.section-title,
.viewer-title {
  margin: 0;
  line-height: 1.02;
}

.hero-title {
  max-width: none;
  font-size: clamp(3rem, 7vw, 6.3rem);
  font-weight: 700;
  letter-spacing: -0.05em;
}

.hero-lead {
  max-width: 64ch;
  margin: 18px auto 0;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--muted);
}

.toolbar-panel,
.showcase-panel {
  margin-top: 22px;
  padding: 24px 26px;
  border-radius: 28px;
}

.toolbar-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.toolbar-copy,
.gallery-head {
  position: relative;
  z-index: 1;
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 650;
}

.family-filters {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.filter-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 10px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.filter-chip:hover,
.filter-chip.is-active {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: linear-gradient(135deg, rgba(137, 240, 255, 0.18), rgba(255, 174, 112, 0.12));
  color: var(--text);
}

.gallery-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.gallery-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.curve-card {
  position: relative;
  display: grid;
  gap: 14px;
  min-height: 100%;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.09), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    rgba(10, 13, 20, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.curve-card:hover,
.curve-card.is-active {
  transform: translateY(-4px);
  border-color: rgba(137, 240, 255, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.28);
}

.curve-card[hidden] {
  display: none;
}

.curve-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.curve-family,
.curve-index {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 11px;
}

.curve-family {
  background: rgba(137, 240, 255, 0.1);
  color: var(--accent);
}

.curve-index {
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.curve-frame {
  display: grid;
  place-items: center;
  min-height: 210px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 35%, rgba(137, 240, 255, 0.13), transparent 34%),
    radial-gradient(circle at 70% 70%, rgba(255, 174, 112, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
    #080b12;
}

.curve-svg {
  width: 132px;
  height: 132px;
  overflow: visible;
}

.curve-meta {
  display: grid;
  gap: 8px;
}

.curve-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.curve-tag {
  color: rgba(255, 230, 210, 0.78);
  font-size: 0.84rem;
}

.curve-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.82);
  backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 220ms ease;
}

.viewer-modal.is-open,
.viewer-modal.is-entering {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 220ms ease, visibility 0s linear 0s;
}

.viewer-modal.is-open .viewer-backdrop,
.viewer-modal.is-entering .viewer-backdrop {
  opacity: 1;
}

.viewer {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  gap: 16px;
  opacity: 0;
  transform-origin: top left;
  transform:
    translate(var(--viewer-translate-x, 0), var(--viewer-translate-y, 0))
    scale(var(--viewer-scale, 0.92));
  transition:
    transform 340ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 220ms ease;
}

.viewer-modal.is-open .viewer {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.viewer-preview,
.viewer-code-panel {
  min-height: 0;
  border-radius: 28px;
}

.viewer-preview {
  padding: 22px;
}

.viewer-stage {
  display: grid;
  place-items: center;
  min-height: 360px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 35% 30%, rgba(137, 240, 255, 0.16), transparent 28%),
    radial-gradient(circle at 70% 70%, rgba(255, 174, 112, 0.12), transparent 26%),
    rgba(7, 9, 14, 0.92);
}

.viewer-svg {
  width: min(100%, 300px);
  height: auto;
  aspect-ratio: 1;
  overflow: visible;
}

.viewer-copy {
  margin-top: 18px;
}

.viewer-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
}

.viewer-desc {
  margin: 12px 0 0;
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.75;
}

.viewer-controls-block,
.viewer-formula-block {
  margin-top: 22px;
}

.viewer-section-head,
.viewer-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.viewer-section-head {
  margin-bottom: 12px;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.viewer-action {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(137, 240, 255, 0.18), rgba(255, 174, 112, 0.14));
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.viewer-action.secondary {
  background: rgba(255, 255, 255, 0.05);
}

.viewer-action:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

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

.viewer-control {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

.viewer-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.viewer-control-label,
.viewer-control-value {
  font-size: 0.82rem;
}

.viewer-control-label {
  color: var(--muted);
}

.viewer-control-value {
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
}

.viewer-control input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
}

.viewer-code-panel {
  padding: 18px;
  overflow: auto;
}

.viewer-code {
  margin: 12px 0 0;
  min-height: 220px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(3, 4, 8, 0.96);
  color: #f8f8fc;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.viewer-formula {
  margin: 10px 0 0;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(246, 247, 251, 0.92);
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

@media (max-width: 1080px) {
  .hero-panel,
  .toolbar-panel,
  .gallery-head,
  .viewer {
    grid-template-columns: 1fr;
  }

  .toolbar-panel,
  .gallery-head {
    display: grid;
  }

  .family-filters {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1380px);
    padding: 14px 0 24px;
  }

  .hero-panel,
  .toolbar-panel,
  .showcase-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .hero-title {
    font-size: clamp(2.3rem, 13vw, 4.2rem);
  }

  .viewer-controls,
  .gallery {
    grid-template-columns: 1fr;
  }

  .curve-frame {
    min-height: 180px;
  }

  .viewer-stage {
    min-height: 260px;
  }

  .viewer {
    width: min(100vw - 20px, 1280px);
  }

  .viewer-preview,
  .viewer-code-panel {
    border-radius: 22px;
  }

  .viewer-code-head,
  .viewer-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .viewer-actions {
    justify-content: flex-start;
  }
}
