:root {
  color-scheme: light;
  --bg: #f7fbff;
  --bg-soft: #e8f4ff;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --line: rgba(37, 104, 176, 0.18);
  --line-bright: rgba(22, 132, 222, 0.42);
  --text: #102235;
  --muted: #51677f;
  --blue: #1677cf;
  --cyan: #1aa5ef;
  --green: #1bbf9a;
  --violet: #5f6fe8;
  --yellow: #b97706;
  --shadow: 0 26px 70px rgba(37, 89, 143, 0.16);
  --control-bg: rgba(255, 255, 255, 0.72);
  --control-soft: rgba(255, 255, 255, 0.58);
  --ink-on-accent: #062033;
  --serif: "Baskerville Old Face", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

:root[data-mode="night"] {
  color-scheme: dark;
  --bg: #0d1118;
  --bg-soft: #101827;
  --panel: rgba(8, 18, 29, 0.84);
  --panel-strong: rgba(10, 28, 42, 0.94);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.095);
  --line: rgba(145, 232, 255, 0.18);
  --line-bright: rgba(145, 239, 255, 0.38);
  --text: rgba(245, 249, 255, 0.95);
  --muted: rgba(216, 228, 240, 0.78);
  --blue: #7ab6ff;
  --cyan: #8defff;
  --green: #a4ffd7;
  --violet: #b3a6ff;
  --yellow: #ffe19b;
  --shadow: 0 26px 72px rgba(2, 9, 19, 0.48);
  --control-bg: rgba(0, 0, 0, 0.22);
  --control-soft: rgba(255, 255, 255, 0.07);
  --ink-on-accent: #06131c;
}

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

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 10%, rgba(80, 170, 255, 0.24), transparent 34%),
    radial-gradient(circle at 86% 4%, rgba(27, 191, 154, 0.14), transparent 30%),
    linear-gradient(135deg, #ffffff 0%, #f8fcff 38%, #e3f2ff 72%, #cfe7ff 100%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

body.playground-body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(232, 244, 255, 0.74)),
    var(--bg);
}

:root[data-mode="night"] body.playground-body {
  background:
    linear-gradient(180deg, rgba(5, 9, 20, 0.15), rgba(5, 9, 20, 0.72)),
    var(--bg);
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

#bubbles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.66;
  mix-blend-mode: multiply;
}

.circle-bubble {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.circle-bubble svg {
  display: block;
  width: 100vw;
  height: 100vh;
  overflow: visible;
  transform: scale(1.24);
  transform-origin: center;
}

.bubble-path {
  fill: none;
  stroke-width: 1.45;
  stroke-linecap: round;
  opacity: 0.78;
  filter:
    drop-shadow(0 10px 24px rgba(22, 132, 222, 0.16))
    drop-shadow(0 0 10px rgba(26, 165, 239, 0.16));
  transition: filter 180ms ease, stroke-width 180ms ease;
}

.active .bubble-path {
  stroke-width: 1.9;
  filter:
    drop-shadow(0 12px 30px rgba(22, 132, 222, 0.2))
    drop-shadow(0 0 18px rgba(27, 191, 154, 0.2));
}

:root[data-mode="night"] #bubbles {
  opacity: 0.52;
  mix-blend-mode: screen;
}

.playground-shell {
  position: relative;
  z-index: 2;
  width: min(1220px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.project-topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 42px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: 0;
}

.brand-orb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(66, 244, 255, 0.9), rgba(26, 165, 239, 0.55)),
    rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 38px rgba(66, 244, 255, 0.33), inset 0 -8px 16px rgba(0, 0, 0, 0.18);
  color: var(--ink-on-accent);
}

.project-nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button-link,
.mode-toggle,
.ghost-button,
.preset-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  backdrop-filter: blur(18px);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.button-link,
.mode-toggle,
.ghost-button,
.preset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.button-link,
.mode-toggle.is-night,
.preset-button.is-active {
  background: linear-gradient(135deg, rgba(66, 244, 255, 0.22), rgba(26, 165, 239, 0.14));
  border-color: var(--line-bright);
  box-shadow: 0 18px 46px rgba(26, 165, 239, 0.13);
}

.button-link:hover,
.mode-toggle:hover,
.ghost-button:hover,
.preset-button:hover,
.button-link:focus-visible,
.mode-toggle:focus-visible,
.ghost-button:focus-visible,
.preset-button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(123, 255, 203, 0.66);
  background: rgba(255, 255, 255, 0.105);
  outline: none;
}

.button-link:focus-visible,
.mode-toggle:focus-visible,
.ghost-button:focus-visible,
.preset-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(124, 231, 255, 0.74);
  outline-offset: 4px;
}

.playground-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.72fr);
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy,
.hero-facts,
.panel,
.control-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.hero-copy::before,
.hero-facts::before,
.panel::before,
.control-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.22), transparent 24%, transparent 72%, rgba(66, 244, 255, 0.12));
  opacity: 0.55;
}

.hero-copy,
.hero-facts {
  padding: clamp(24px, 4vw, 42px);
}

.project-kicker,
.spread-eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 850;
}

:root[data-mode="night"] .project-kicker,
:root[data-mode="night"] .spread-eyebrow {
  color: rgba(164, 224, 242, 0.72);
}

.hero-copy h1 {
  max-width: 9.5ch;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 7vw, 6.7rem);
  line-height: 0.89;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 64ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.16rem);
  line-height: 1.68;
}

.hero-facts dl {
  display: grid;
  gap: 18px;
  margin: 0;
}

.hero-facts div {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.hero-facts div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.hero-facts dt,
.readout-grid span,
.range-label span:last-child,
.preset-field legend {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 850;
}

.hero-facts dd {
  margin: 7px 0 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.playground-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.model-stage {
  position: relative;
  height: min(78vh, 760px);
  min-height: 680px;
  overflow: hidden;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 28%),
    radial-gradient(circle at 68% 24%, rgba(27, 191, 154, 0.2), transparent 30%),
    radial-gradient(circle at 26% 76%, rgba(22, 119, 207, 0.18), transparent 34%);
}

:root[data-mode="night"] .model-stage {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 28%),
    radial-gradient(circle at 68% 24%, rgba(164, 255, 215, 0.14), transparent 30%),
    radial-gradient(circle at 26% 76%, rgba(122, 182, 255, 0.12), transparent 34%);
}

.stage-header {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.stage-header .project-kicker {
  margin-top: 10px;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.ghost-button {
  min-height: 36px;
  padding-inline: 13px;
  background: var(--control-bg);
}

#leveler-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  outline: none;
  touch-action: none;
}

.stage-note {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 3;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.control-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 20px;
}

.control-heading h2,
.panel h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3vw, 3.1rem);
  line-height: 0.98;
}

.preset-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.preset-field legend {
  margin-bottom: 10px;
}

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

.preset-button {
  min-height: 42px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 0.72rem;
  line-height: 1.15;
  white-space: normal;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 8px;
}

.range-control {
  display: grid;
  gap: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--control-soft);
}

.range-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.range-label span:first-child,
.select-control span {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 820;
  line-height: 1.2;
}

.range-label output {
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
  cursor: pointer;
}

.select-control {
  display: grid;
  gap: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--control-soft);
}

.select-control select {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--control-bg);
  color: var(--text);
}

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

.readout-grid div {
  min-width: 0;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(26, 165, 239, 0.11), rgba(27, 191, 154, 0.08));
}

.readout-grid span,
.readout-grid strong {
  display: block;
}

.readout-grid strong {
  margin-top: 8px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.1;
}

.case-study-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  grid-column: span 4;
  min-height: 280px;
  padding: 28px 26px;
}

.spread-wide {
  grid-column: span 8;
}

.panel p,
.content-list li {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.66;
}

.content-list {
  margin: 20px 0 0;
  padding-left: 18px;
}

.scad-panel {
  grid-column: span 12;
}

.scad-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.scad-panel pre {
  max-height: 420px;
  margin: 22px 0 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--text);
  white-space: pre-wrap;
}

:root[data-mode="night"] .scad-panel pre {
  background: rgba(0, 0, 0, 0.28);
  color: rgba(246, 251, 255, 0.9);
}

.scad-panel code {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.58;
}

.footer-panel {
  position: relative;
  margin-top: 22px;
  padding: clamp(24px, 4vw, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid rgba(123, 255, 203, 0.24);
  border-radius: 32px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    linear-gradient(135deg, rgba(26, 165, 239, 0.16), rgba(95, 111, 232, 0.08)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  overflow: hidden;
}

.footer-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
}

.footer-panel strong {
  color: var(--text);
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-social-link {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(37, 104, 176, 0.18);
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  text-decoration: none;
  transition:
    color 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.footer-social-link:hover,
.footer-social-link:focus-visible {
  color: var(--blue);
  border-color: var(--line-bright);
  background: rgba(255, 255, 255, 0.86);
  transform: translateY(-1px);
  outline: none;
}

.footer-social-link:focus-visible {
  outline: 2px solid rgba(22, 132, 222, 0.42);
  outline-offset: 3px;
}

.footer-social-link svg {
  width: 18px;
  height: 18px;
  display: block;
}

@media (max-width: 1040px) {
  .playground-shell {
    width: min(100vw - 24px, 880px);
    padding: 18px 0 36px;
  }

  .project-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .project-nav-actions {
    justify-content: flex-start;
  }

  .playground-hero,
  .playground-workbench,
  .case-study-grid {
    grid-template-columns: 1fr;
  }

  .model-stage,
  #leveler-canvas {
    min-height: 560px;
  }

  .panel,
  .spread-wide,
  .scad-panel {
    grid-column: auto;
    min-height: unset;
  }
}

@media (max-width: 640px) {
  .hero-copy,
  .hero-facts,
  .control-panel,
  .panel {
    padding: 22px 18px;
  }

  .hero-copy h1 {
    font-size: clamp(2.7rem, 15vw, 4.4rem);
  }

  .model-stage,
  #leveler-canvas {
    min-height: 0;
  }

  .model-stage {
    height: auto;
  }

  #leveler-canvas {
    height: 480px;
  }

  .stage-header {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    padding: 16px 16px 0;
    pointer-events: auto;
  }

  .stage-note {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    padding: 0 16px 16px;
  }

  .preset-grid,
  .readout-grid {
    grid-template-columns: 1fr;
  }

  .scad-heading {
    display: grid;
  }

  .footer-panel {
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
