:root {
  --bg: #f6f8fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #101828;
  --muted: #5b667a;
  --line: rgba(16, 24, 40, 0.12);
  --accent: #ff5a5f;
  --accent-2: #2563eb;
  --accent-3: #00a878;
  --shadow: 0 22px 70px rgba(16, 24, 40, 0.1);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08) 0%, rgba(255, 255, 255, 0) 42%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(16, 24, 40, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 24, 40, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.62), transparent 82%);
}

a {
  color: inherit;
}

.site-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 80px;
}

.hero,
.section {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.hero {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.topbar-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.topbar-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.hero-grid {
  display: grid;
  gap: 22px;
  padding-top: 52px;
}

.hero-copy h1,
.section-heading h2 {
  margin: 0;
  line-height: 0.98;
  font-weight: 700;
}

.hero-copy h1 {
  width: 100%;
  max-width: none;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
}

.teaser-figure {
  width: min(62.5%, 700px);
  margin: 30px auto 0;
}

.teaser-figure img {
  display: block;
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: 0 16px 45px rgba(16, 24, 40, 0.12);
}

.teaser-figure figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent-2);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 28px;
}

.hero-actions:empty {
  display: none;
}

.button,
.button-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.button:hover,
.button-ghost:hover {
  transform: translateY(-2px);
}

.button {
  background: var(--text);
  color: #ffffff;
}

.button-ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.overview-card,
.design-card,
.model-card,
.ready-model-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section {
  margin-top: 22px;
  padding: 30px;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 24px;
}

#editor .section-heading {
  max-width: none;
}

#editor .section-heading h2 {
  white-space: nowrap;
}

.section-heading h2 {
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  line-height: 1.25;
}

.overview-grid,
.design-grid,
.model-grid {
  display: grid;
  gap: 18px;
}

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

.overview-card,
.design-card,
.model-card,
.ready-model-card {
  padding: 22px;
}

.overview-card p,
.design-card p,
.model-meta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.overview-card.accent {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(0, 168, 120, 0.1)),
    var(--surface);
}

.design-card h3,
.model-meta h3,
.ready-model-meta h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.3;
}

.metric,
.model-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent-2);
  font-size: 0.78rem;
  margin-top: 16px;
}

.design-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.design-card {
  display: grid;
  gap: 18px;
}

.metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metric {
  margin-top: 0;
  background: rgba(255, 90, 95, 0.1);
  color: var(--accent);
}

.model-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.model-card,
.ready-model-card {
  display: grid;
  gap: 18px;
}

.model-frame {
  min-height: 360px;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(0, 168, 120, 0.08)),
    #f9fafb;
  border: 1px solid var(--line);
}

model-viewer {
  width: 100%;
  height: 360px;
  --progress-bar-color: var(--accent);
  background: transparent;
}

.model-empty {
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.model-meta {
  display: grid;
  gap: 12px;
}

.ready-model-card {
  padding: 14px;
  gap: 14px;
}

.model-stiffness-note {
  margin: -8px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.ready-model-frame {
  position: relative;
  min-height: 210px;
  height: 210px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(0, 168, 120, 0.06)),
    #f9fafb;
}

.ready-model-frame canvas {
  display: block;
  width: 100%;
  height: 210px;
}

.ready-model-meta {
  display: grid;
  gap: 12px;
}

.ready-model-header {
  display: grid;
  gap: 4px;
}

.stiffness-badge {
  display: inline-flex;
  width: max-content;
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(0, 168, 120, 0.11);
  color: #027a55;
  font-size: 0.72rem;
  font-weight: 700;
}

.stiffness-scale {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(0, 168, 120, 0.22), rgba(255, 90, 95, 0.18));
}

.stiffness-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-3), var(--accent));
}

.stiffness-ticks {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.ready-model-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.model-actions {
  position: absolute;
  right: 10px;
  z-index: 2;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-actions-top {
  top: 10px;
}

.model-actions-bottom {
  bottom: 10px;
}

.model-actions .button,
.model-actions .button-ghost {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
}

.source-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.source-section .section-heading {
  margin-bottom: 0;
}

.source-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-downloads {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-label,
.profile-empty {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.source-section .button,
.source-section .button-ghost {
  border: 0;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

.source-section .button-ghost {
  border: 1px solid var(--line);
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
  align-items: stretch;
}

.editor-controls,
.editor-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 22px;
}

.editor-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.04);
}

.editor-tab {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.editor-tab.is-active {
  background: var(--text);
  color: #ffffff;
}

.parameter-panels {
  margin-top: 22px;
}

.parameter-panel {
  display: none;
}

.parameter-panel.is-active {
  display: block;
}

.parameter-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 22px;
}

.advanced-fields {
  display: none;
}

.advanced-fields.is-active {
  display: grid;
}

.parameter-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 120px);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.parameter-field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.parameter-field input:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.55);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.editor-actions .button,
.editor-actions .button-ghost {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.editor-actions .button-ghost {
  border: 1px solid var(--line);
}

.editor-actions .button:disabled,
.editor-actions .button-ghost:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.editor-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.rotation-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.rotation-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rotation-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.18);
  transition: background-color 180ms ease;
}

.rotation-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.22);
  transition: transform 180ms ease;
}

.rotation-control input:checked + .rotation-switch {
  background: var(--accent-2);
}

.rotation-control input:checked + .rotation-switch::after {
  transform: translateX(20px);
}

.rotation-control input:focus-visible + .rotation-switch {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 3px;
}

.editor-preview {
  min-height: 500px;
}

.editor-preview-frame {
  position: relative;
  width: 100%;
  min-height: 500px;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fafb;
}

#editor-preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.preview-loading {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(4px);
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.preview-loading.is-active {
  display: grid;
}

.preview-spinner {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border: 5px solid rgba(37, 99, 235, 0.16);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.parameter-hover-image {
  position: absolute;
  z-index: 30;
  width: min(220px, calc(100vw - 36px));
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.parameter-hover-image.is-visible {
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

code {
  font-family: inherit;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.08);
  color: var(--text);
}

@media (max-width: 1024px) {
  .hero-grid,
  .overview-grid,
  .design-grid,
  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .site-shell {
    width: min(100% - 20px, 1180px);
  }

  .hero,
  .section {
    padding: 20px;
  }

  .topbar,
  .hero-grid,
  .overview-grid,
  .design-grid,
  .model-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar-links {
    gap: 12px;
  }

  .editor-controls {
    padding: 18px;
  }

  .editor-shell {
    grid-template-columns: 1fr;
  }

  .editor-tabs,
  .editor-actions {
    width: 100%;
  }

  .editor-tab {
    flex: 1;
  }

  .parameter-field,
  .parameter-fields {
    grid-template-columns: 1fr;
  }

  .editor-actions .button {
    width: 100%;
  }

  .editor-actions .button-ghost {
    width: 100%;
  }

  #editor .section-heading h2 {
    white-space: normal;
  }

  .editor-preview,
  .editor-preview-frame {
    min-height: 360px;
  }

  .source-section {
    align-items: stretch;
    flex-direction: column;
  }

  .source-section .button {
    width: 100%;
  }

  .source-actions,
  .profile-downloads,
  .source-section .button-ghost {
    width: 100%;
  }

  .hero-grid {
    min-height: auto;
    padding-top: 28px;
  }

  .teaser-figure {
    width: 100%;
  }

  .model-frame,
  .model-empty,
  model-viewer {
    min-height: 300px;
    height: 300px;
  }
}
