@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Sans+TC:wght@400;500;600;700;800&family=Noto+Serif+TC:wght@600;700&display=swap");

:root {
  --ink: #102a43;
  --ink-soft: #486581;
  --navy: #102f4f;
  --navy-deep: #071d31;
  --paper: #f3efe5;
  --paper-bright: #fbfaf6;
  --panel: #e9f0ef;
  --blue: #3f83a3;
  --blue-light: #8fc3d4;
  --yellow: #f1b94b;
  --red: #d8664d;
  --line: rgba(16, 42, 67, 0.17);
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Noto Sans TC", system-ui, sans-serif;
  --serif: "Noto Serif TC", serif;
  --shadow: 0 24px 70px rgba(16, 42, 67, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(16, 42, 67, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 42, 67, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: var(--sans);
  line-height: 1.65;
  transition: color 220ms ease, background-color 220ms ease;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  border-radius: 4px;
  color: #fff;
  background: var(--navy-deep);
  transform: translateY(-200%);
}

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

.site-header {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(1500px, calc(100% - 72px));
  min-height: 88px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.25;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--mono);
  font-size: 0.83rem;
  letter-spacing: 0.13em;
}

.brand small {
  margin-top: -2px;
  color: var(--ink-soft);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: clamp(22px, 3vw, 50px);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.site-header nav a {
  position: relative;
  padding: 31px 0;
  text-decoration: none;
}

.site-header nav a::after {
  position: absolute;
  right: 50%;
  bottom: -1px;
  left: 50%;
  height: 2px;
  background: var(--red);
  content: "";
  transition: right 180ms ease, left 180ms ease;
}

.site-header nav a:hover::after,
.site-header nav a:focus-visible::after {
  right: 0;
  left: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 4px;
}

.utility-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.utility-button:hover,
.utility-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.38);
}

.utility-button {
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.language-toggle {
  width: auto;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.65rem;
}

.language-toggle i {
  width: 1px;
  height: 14px;
  background: var(--line);
  transform: rotate(16deg);
}

.language-toggle .language-current {
  color: var(--red);
  font-weight: 700;
}

.language-toggle .language-next {
  color: var(--ink-soft);
}

.theme-toggle svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: block;
}

.icon-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.6;
}

.icon-button span {
  font-size: 0.78rem;
  font-weight: 600;
}

main {
  overflow: hidden;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  align-items: end;
  width: min(1320px, calc(100% - 72px));
  margin: 0 auto;
  padding: clamp(64px, 8vw, 118px) 0 54px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 22px;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.73rem;
  letter-spacing: 0.17em;
}

.eyebrow b,
.live-badge b,
.drag-hint b,
.model-panel > footer b,
.switch b,
.site-footer b,
.topology-totals b {
  font: inherit;
}

.eyebrow span {
  width: 30px;
  height: 1px;
  background: currentColor;
}

.intro h1 {
  max-width: 860px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.9rem, 5.7vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1.16;
}

.intro h1 em {
  color: var(--red);
  font-style: normal;
}

.intro-copy > p {
  max-width: 680px;
  margin: 28px 0 0;
  color: var(--ink-soft);
  font-size: clamp(0.96rem, 1.25vw, 1.08rem);
}

.intro-note {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-self: end;
  width: min(100%, 395px);
  padding: 22px 0 22px 26px;
  border-left: 1px solid var(--line);
}

.note-index {
  color: var(--yellow);
  font-family: var(--serif);
  font-size: 3.6rem;
  line-height: 1;
}

.intro-note div > * {
  display: block;
}

.intro-note small,
.section-heading p,
.duality-copy > p:first-of-type,
.dialog-kicker {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.17em;
}

.intro-note strong {
  margin: 4px 0;
  font-size: 0.9rem;
}

.intro-note div > span {
  color: var(--red);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.experiment-shell {
  position: relative;
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto clamp(84px, 10vw, 150px);
  padding: clamp(26px, 4vw, 54px);
  border: 1px solid rgba(16, 42, 67, 0.12);
  background: rgba(251, 250, 246, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.experiment-shell::before,
.experiment-shell::after {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--red);
  content: "";
  pointer-events: none;
}

.experiment-shell::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.experiment-shell::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 32px;
}

.section-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 18px;
}

.section-number {
  display: inline-grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.section-heading p,
.duality-copy > p:first-of-type {
  margin: 0 0 3px;
}

.section-heading h2,
.duality-copy h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.65rem, 2.5vw, 2.55rem);
  line-height: 1.3;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.1em;
}

.live-badge span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4d9b75;
  box-shadow: 0 0 0 5px rgba(77, 155, 117, 0.12);
  animation: live-pulse 2s infinite;
}

@keyframes live-pulse {
  50% { box-shadow: 0 0 0 9px rgba(77, 155, 117, 0); }
}

.model-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px minmax(0, 1fr);
  align-items: stretch;
}

.model-panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.model-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  padding: 16px 23px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
}

.model-kicker {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.13em;
}

.model-panel h3 {
  margin: 1px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.18rem, 2vw, 1.5rem);
}

.model-symbol {
  color: var(--blue);
  font-size: 2.1rem;
  line-height: 1;
}

.model-symbol.triangle {
  color: var(--yellow);
}

.canvas-frame {
  position: relative;
  height: clamp(370px, 35vw, 520px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.76), transparent 50%),
    #dfeae9;
}

.canvas-frame canvas,
.canvas-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.canvas-frame canvas {
  z-index: 2;
  cursor: grab;
  outline: none;
  touch-action: none;
}

.canvas-frame canvas:active {
  cursor: grabbing;
}

.canvas-frame canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--red);
}

.canvas-grid {
  opacity: 0.48;
  background-image:
    linear-gradient(rgba(16, 42, 67, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 42, 67, 0.07) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(circle, #000 0%, transparent 68%);
}

.drag-hint,
.cut-status {
  position: absolute;
  z-index: 3;
  bottom: 18px;
  pointer-events: none;
}

.drag-hint {
  left: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.06em;
}

.drag-hint svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.cut-status {
  right: 18px;
  padding: 5px 9px;
  border: 1px solid rgba(16, 42, 67, 0.2);
  border-radius: 2px;
  color: var(--ink-soft);
  background: rgba(251, 250, 246, 0.66);
  font-size: 0.68rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.model-panel > footer {
  display: flex;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 24px);
  padding: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.model-panel > footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.original { background: var(--blue); }
.legend-dot.new { background: var(--yellow); }
.legend-dot.removed { background: var(--red); }

.dual-bridge {
  position: relative;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
}

.dual-bridge .bridge-line {
  width: 1px;
  height: 33%;
  background: var(--line);
}

.dual-bridge button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 76px;
  padding: 12px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-bright);
  box-shadow: 0 8px 25px rgba(16, 42, 67, 0.08);
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.dual-bridge button:hover,
.dual-bridge button:focus-visible {
  transform: scale(1.04);
}

.dual-bridge button[aria-pressed="true"] {
  color: #fff;
  background: var(--red);
}

.dual-bridge button svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.dual-bridge button span,
.dual-bridge strong {
  font-size: 0.61rem;
  line-height: 1.35;
}

.dual-bridge strong {
  position: absolute;
  top: calc(50% + 70px);
  width: 105px;
  color: transparent;
  text-align: center;
  transition: color 180ms ease;
}

body.dual-active .dual-bridge strong {
  color: var(--red);
}

body.dual-active .model-panel {
  box-shadow: inset 0 0 0 2px rgba(216, 102, 77, 0.36);
}

body.dual-active .canvas-frame::after {
  position: absolute;
  z-index: 1;
  inset: 10%;
  border: 1px dashed rgba(216, 102, 77, 0.4);
  border-radius: 50%;
  content: "";
  animation: orbit-ring 12s linear infinite;
}

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

.control-deck {
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--paper-bright);
}

.depth-control {
  padding: clamp(20px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
}

.control-label {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.control-label span,
.mode-controls legend span {
  display: block;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.13em;
}

.control-label label,
.mode-controls legend {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 700;
}

.mode-controls legend b {
  font: inherit;
}

.control-label output {
  color: var(--red);
  font-family: var(--mono);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.range-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-top: 21px;
}

.play-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--navy);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.play-button:hover,
.play-button:focus-visible {
  background: var(--red);
  transform: scale(1.05);
}

.play-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.play-button .play-icon {
  fill: currentColor;
  stroke: none;
}

.play-button .pause-icon,
.play-button.playing .play-icon {
  display: none;
}

.play-button.playing .pause-icon {
  display: block;
}

.range-wrap {
  position: relative;
  min-width: 0;
}

.range-wrap::after {
  position: absolute;
  top: 8px;
  left: 66%;
  width: 1px;
  height: 9px;
  background: var(--yellow);
  content: "";
  pointer-events: none;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--red) var(--range-progress, 0%), #cad4d3 var(--range-progress, 0%));
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 99px;
  background: #cad4d3;
}

input[type="range"]::-moz-range-progress {
  height: 3px;
  background: var(--red);
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7.5px;
  appearance: none;
  border: 4px solid var(--paper-bright);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 1px var(--red), 0 2px 8px rgba(16, 42, 67, 0.25);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid var(--paper-bright);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 4px;
}

.range-ticks {
  position: relative;
  height: 17px;
  margin-top: 4px;
  color: #748b9b;
  font-family: var(--mono);
  font-size: 0.58rem;
}

.range-ticks span {
  position: absolute;
  top: 0;
  white-space: nowrap;
}

.range-ticks span:first-child {
  left: 0;
}

.range-ticks span:nth-child(2) {
  left: 66%;
  color: #b47b1d;
  transform: translateX(-100%);
}

.range-ticks span:last-child {
  right: 0;
}

.reset-button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.reset-button:hover,
.reset-button:focus-visible {
  border-color: var(--ink);
  background: var(--paper);
}

.mode-controls {
  display: grid;
  grid-template-columns: 1.25fr 1fr auto;
  gap: clamp(26px, 4vw, 62px);
  padding: clamp(22px, 3vw, 32px);
}

.mode-controls fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-controls legend {
  width: 100%;
  margin-bottom: 13px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.segmented-control label {
  position: relative;
  min-width: 0;
}

.segmented-control label + label {
  border-left: 1px solid var(--line);
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: block;
  padding: 9px 5px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented-control input:checked + span {
  color: #fff;
  background: var(--navy);
}

.segmented-control input:focus-visible + span {
  box-shadow: inset 0 0 0 2px var(--yellow);
}

.switches {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 10px 18px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch > span {
  position: relative;
  width: 31px;
  height: 17px;
  border-radius: 99px;
  background: #c5cecc;
  transition: background 160ms ease;
}

.switch > span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--red);
}

.switch input:checked + span::after {
  transform: translateX(14px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.advanced-slot {
  align-self: end;
}

.advanced-slot .lil-gui.root {
  --background-color: var(--paper);
  --text-color: var(--ink);
  --title-background-color: var(--navy);
  --widget-color: #d9dfdd;
  --hover-color: #cdd7d5;
  --focus-color: var(--yellow);
  --number-color: var(--red);
  --string-color: var(--blue);
  width: 210px;
  border: 1px solid var(--line);
  font-family: var(--sans);
}

.topology-section {
  padding: clamp(70px, 9vw, 130px) max(36px, calc((100vw - 1320px) / 2));
  color: #e9f0ef;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--navy-deep);
  background-size: 34px 34px;
}

.section-heading.dark {
  align-items: center;
}

.section-heading.dark .section-number {
  color: var(--yellow);
}

.section-heading.dark p {
  color: var(--blue-light);
}

.section-description {
  max-width: 470px;
  color: #a9bcc7 !important;
  font-family: var(--sans) !important;
  font-size: 0.84rem !important;
  letter-spacing: 0 !important;
}

.section-description strong {
  color: var(--yellow);
  font-family: var(--mono);
}

.topology-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr);
  align-items: stretch;
  margin-top: 48px;
}

.topology-card {
  border: 1px solid rgba(233, 240, 239, 0.16);
  background: rgba(12, 41, 64, 0.8);
}

.topology-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid rgba(233, 240, 239, 0.13);
}

.topology-card header span {
  color: var(--blue-light);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.15em;
}

.topology-card h3 {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-size: 1.25rem;
}

.euler-badge {
  padding: 7px 10px;
  border: 1px solid rgba(241, 185, 75, 0.4);
  border-radius: 2px;
  color: #a9bcc7;
  font-family: var(--mono);
  font-size: 0.62rem;
}

.euler-badge strong {
  color: var(--yellow);
  font-size: 0.9rem;
}

.face-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 118px;
  border-bottom: 1px solid rgba(233, 240, 239, 0.13);
}

.face-breakdown > div {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 24px;
}

.face-breakdown > div + div {
  border-left: 1px solid rgba(233, 240, 239, 0.13);
}

.face-breakdown > div[hidden] {
  display: none;
}

.face-icon {
  display: inline-block;
  width: 27px;
  height: 27px;
  background: var(--blue);
  clip-path: polygon(50% 0%, 98% 38%, 80% 100%, 20% 100%, 2% 38%);
}

.face-icon.triangle {
  background: var(--yellow);
  clip-path: polygon(50% 2%, 98% 95%, 2% 95%);
}

.face-icon.hexagon {
  background: var(--blue);
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%);
}

.face-icon.decagon {
  background: var(--blue);
  clip-path: polygon(50% 0%, 79% 10%, 98% 35%, 98% 65%, 79% 90%, 50% 100%, 21% 90%, 2% 65%, 2% 35%, 21% 10%);
}

.face-breakdown span {
  color: #a9bcc7;
  font-size: 0.75rem;
}

.face-breakdown strong {
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 1.8rem;
}

.topology-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
}

.topology-totals > div {
  padding: 24px;
}

.topology-totals > div + div {
  border-left: 1px solid rgba(233, 240, 239, 0.13);
}

.topology-totals dt {
  color: #a9bcc7;
  font-size: 0.7rem;
}

.topology-totals dt small {
  display: block;
  margin-top: 2px;
  color: #5d8198;
  font-family: var(--mono);
  font-size: 0.53rem;
  letter-spacing: 0.1em;
}

.topology-totals dd {
  margin: 9px 0 0;
  font-family: var(--mono);
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 1;
}

.equation-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.equation-column > span {
  width: 1px;
  flex: 1;
  background: rgba(233, 240, 239, 0.16);
}

.equation-column div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  text-align: center;
}

.equation-column small {
  color: #7391a4;
  font-size: 0.6rem;
}

.equation-column strong {
  margin: 3px 0;
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.equation-column em {
  color: #53758b;
  font-family: var(--mono);
  font-size: 0.57rem;
  font-style: normal;
}

.duality-section {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(370px, 0.95fr);
  min-height: 750px;
}

.duality-visual {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 90px 1fr;
  align-items: center;
  padding: clamp(40px, 5vw, 80px);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 35%, rgba(63, 131, 163, 0.24), transparent 32%),
    radial-gradient(circle at 80% 65%, rgba(241, 185, 75, 0.18), transparent 31%),
    #dfeae9;
}

.duality-visual::before {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(16, 42, 67, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 42, 67, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  content: "";
}

.dual-shape,
.duality-arrow {
  position: relative;
  z-index: 1;
}

.dual-shape svg {
  width: 100%;
  max-width: 300px;
  overflow: visible;
  fill: rgba(63, 131, 163, 0.09);
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.3;
  filter: drop-shadow(0 20px 20px rgba(16, 42, 67, 0.13));
  animation: shape-float 7s ease-in-out infinite;
}

.icosa-wire svg {
  fill: rgba(241, 185, 75, 0.1);
  stroke: #c58a24;
  animation-delay: -3.5s;
}

.dual-shape circle {
  fill: var(--red);
  stroke: var(--paper-bright);
  stroke-width: 2;
}

@keyframes shape-float {
  50% { transform: translateY(-15px) rotate(2deg); }
}

.duality-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--red);
}

.duality-arrow i {
  width: 1px;
  height: 70px;
  background: currentColor;
}

.duality-arrow strong {
  font-size: 2rem;
}

.duality-arrow span {
  font-family: var(--mono);
  font-size: 0.54rem;
  letter-spacing: 0.1em;
  writing-mode: vertical-rl;
}

.duality-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(56px, 7vw, 112px);
  background: var(--paper-bright);
}

.duality-copy .section-number {
  margin-bottom: 28px;
  color: var(--red);
}

.duality-copy h2 {
  margin-bottom: 25px;
  font-size: clamp(2rem, 4vw, 3.8rem);
}

.duality-copy > p:not(:first-of-type) {
  max-width: 610px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.fact-row {
  display: flex;
  width: 100%;
  margin: 35px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fact-row > div {
  display: flex;
  flex: 1;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 18px 8px;
}

.fact-row > div + div {
  border-left: 1px solid var(--line);
}

.fact-row strong {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 1.6rem;
}

.fact-row span {
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.fact-row i {
  margin: 0 5px;
  color: var(--red);
  font-style: normal;
}

.duality-copy aside {
  display: flex;
  gap: 13px;
  padding: 16px;
  border-left: 3px solid var(--yellow);
  background: #f4eddc;
}

.duality-copy aside svg {
  flex: 0 0 auto;
  width: 22px;
  margin-top: 2px;
  fill: none;
  stroke: #b97d17;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.duality-copy aside p {
  margin: 0;
  color: #705c37;
  font-size: 0.75rem;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 120px;
  padding: 28px max(36px, calc((100vw - 1320px) / 2));
  color: #c6d3da;
  background: var(--navy-deep);
}

.site-footer strong,
.site-footer span {
  display: block;
}

.site-footer strong {
  color: #fff;
  font-family: var(--mono);
  font-size: 0.77rem;
  letter-spacing: 0.14em;
}

.site-footer div > span {
  margin-top: 4px;
  font-size: 0.7rem;
}

.site-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  text-decoration: none;
}

.site-footer a span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

dialog {
  width: min(560px, calc(100% - 32px));
  padding: 38px;
  border: 0;
  color: var(--ink);
  background: var(--paper-bright);
  box-shadow: 0 30px 100px rgba(7, 29, 49, 0.36);
}

dialog::backdrop {
  background: rgba(7, 29, 49, 0.72);
  backdrop-filter: blur(5px);
}

dialog h2 {
  margin: 6px 0 24px;
  font-family: var(--serif);
  font-size: 2rem;
}

.dialog-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
}

dialog ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

dialog li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

dialog li > span {
  color: var(--red);
  font-family: var(--mono);
}

dialog li p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.83rem;
}

dialog li strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

noscript {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  padding: 15px;
  color: #fff;
  background: var(--red);
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8f0f3;
  --ink-soft: #a9bdc8;
  --paper: #071d31;
  --paper-bright: #0c2940;
  --panel: #102f45;
  --line: rgba(220, 234, 240, 0.17);
  --shadow: 0 28px 85px rgba(0, 0, 0, 0.33);
}

[data-theme="dark"] body {
  background:
    linear-gradient(rgba(219, 235, 241, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(219, 235, 241, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

[data-theme="dark"] .site-header,
[data-theme="dark"] .intro,
[data-theme="dark"] .experiment-shell,
[data-theme="dark"] .duality-section {
  color: var(--ink);
}

[data-theme="dark"] .experiment-shell {
  background: rgba(8, 31, 49, 0.9);
}

[data-theme="dark"] .model-panel > header {
  background: rgba(255, 255, 255, 0.025);
}

[data-theme="dark"] .canvas-frame {
  background:
    radial-gradient(circle at 50% 45%, rgba(66, 115, 139, 0.25), transparent 52%),
    #0b263b;
}

[data-theme="dark"] .canvas-grid {
  opacity: 0.24;
}

[data-theme="dark"] .cut-status,
[data-theme="dark"] .dual-bridge button {
  background: rgba(7, 29, 49, 0.76);
}

[data-theme="dark"] body.dual-active .dual-bridge button,
[data-theme="dark"] .dual-bridge button[aria-pressed="true"] {
  background: var(--red);
}

[data-theme="dark"] .control-deck {
  background: #0a2439;
}

[data-theme="dark"] input[type="range"]::-webkit-slider-thumb {
  border-color: #0a2439;
}

[data-theme="dark"] .segmented-control input:checked + span,
[data-theme="dark"] .play-button {
  background: #367b9c;
}

[data-theme="dark"] .duality-visual {
  background:
    radial-gradient(circle at 20% 35%, rgba(63, 131, 163, 0.2), transparent 32%),
    radial-gradient(circle at 80% 65%, rgba(241, 185, 75, 0.14), transparent 31%),
    #0b263b;
}

[data-theme="dark"] .duality-copy {
  background: #0c2940;
}

[data-theme="dark"] .duality-copy aside {
  background: #332f25;
}

[data-theme="dark"] .duality-copy aside p {
  color: #d8c79f;
}

[data-theme="dark"] dialog {
  color: var(--ink);
  background: #0c2940;
}

[data-theme="dark"] .advanced-slot .lil-gui.root {
  --background-color: #0a2439;
  --text-color: #e8f0f3;
  --widget-color: #173a50;
  --hover-color: #21485f;
}

@media (max-width: 1080px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .site-header nav {
    display: none;
  }

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

  .intro-note {
    justify-self: start;
    margin-top: 38px;
  }

  .model-stage {
    grid-template-columns: minmax(0, 1fr) 74px minmax(0, 1fr);
  }

  .mode-controls {
    grid-template-columns: 1fr 1fr;
  }

  .advanced-slot {
    display: none;
  }

  .topology-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .equation-column {
    display: none;
  }

  .duality-section {
    grid-template-columns: 1fr;
  }

  .duality-visual {
    min-height: 560px;
  }
}

@media (max-width: 760px) {
  .site-header {
    width: calc(100% - 32px);
    min-height: 74px;
  }

  .brand small,
  .icon-button span,
  .language-toggle .language-next,
  .language-toggle i {
    display: none;
  }

  .language-toggle {
    width: 38px;
    padding: 0;
    border-radius: 50%;
  }

  .intro {
    width: calc(100% - 36px);
    padding-top: 54px;
  }

  .intro h1 {
    font-size: clamp(2.45rem, 12vw, 4.5rem);
  }

  .intro-note {
    padding-left: 18px;
  }

  .experiment-shell {
    width: calc(100% - 20px);
    padding: 14px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .live-badge {
    margin-top: 10px;
  }

  .model-stage {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .dual-bridge {
    flex-direction: row;
    min-height: 72px;
  }

  .dual-bridge .bridge-line {
    width: auto;
    height: 1px;
    flex: 1;
  }

  .dual-bridge button {
    flex-direction: row;
    width: auto;
    padding: 9px 14px;
  }

  .dual-bridge strong {
    top: auto;
    right: 0;
    bottom: -4px;
    left: 0;
    width: auto;
  }

  .canvas-frame {
    height: min(95vw, 430px);
  }

  .model-panel > footer {
    flex-wrap: wrap;
  }

  .range-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .reset-button {
    grid-column: 2;
    justify-self: end;
  }

  .mode-controls {
    grid-template-columns: 1fr;
  }

  .topology-section {
    padding-right: 18px;
    padding-left: 18px;
  }

  .section-heading.dark {
    display: block;
  }

  .section-description {
    margin-top: 22px !important;
  }

  .topology-card header {
    align-items: flex-start;
    padding: 18px;
  }

  .face-breakdown > div,
  .topology-totals > div {
    padding: 18px 12px;
  }

  .duality-visual {
    grid-template-columns: 1fr 52px 1fr;
    min-height: 420px;
    padding: 30px 14px;
  }

  .duality-arrow i {
    height: 46px;
  }

  .duality-copy {
    padding: 56px 24px;
  }

  .fact-row {
    flex-direction: column;
  }

  .fact-row > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 430px) {
  .brand strong {
    font-size: 0.72rem;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .section-number {
    width: 36px;
    height: 36px;
  }

  .section-heading h2 {
    font-size: 1.4rem;
  }

  .live-badge {
    display: none;
  }

  .model-panel > header {
    min-height: 76px;
    padding: 13px 16px;
  }

  .model-symbol {
    font-size: 1.7rem;
  }

  .segmented-control {
    grid-template-columns: repeat(2, 1fr);
  }

  .segmented-control label:nth-child(3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .segmented-control label:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .face-breakdown {
    grid-template-columns: 1fr;
  }

  .face-breakdown > div + div {
    border-top: 1px solid rgba(233, 240, 239, 0.13);
    border-left: 0;
  }

  .topology-totals dt small {
    display: none;
  }

  .topology-totals dd {
    font-size: 1.75rem;
  }

  dialog {
    padding: 30px 22px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
