:root {
  --bg: #0b1f33;
  --surface-1: #122a4a;
  --surface-2: #1a3a63;
  --text: #eaf2fb;
  --text-muted: #93aac4;
  --accent: #7dd3fc;
  --accent-support: #fbbf24;
  --success: #34d399;
  --danger: #f87171;

  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-6: 48px;
  --space-8: 64px;

  --radius: 4px;
  --glow: 0 0 24px rgba(125, 211, 252, 0.25);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
}

.grid-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(
      rgba(125, 211, 252, 0.08) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(125, 211, 252, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: drift 60s linear infinite;
}

@keyframes drift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 32px 64px;
  }
}

.site-header {
  padding: var(--space-4) var(--space-4) var(--space-2);
  text-align: center;
}

.wordmark {
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.02em;
  margin: 0;
}

.wordmark__bond {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  vertical-align: -0.12em;
  position: relative;
}

.wordmark__bond::before,
.wordmark__bond::after {
  content: "";
  position: absolute;
  left: 0.08em;
  width: 0.4em;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  animation: bond-pulse 2.4s var(--ease) 1;
}

.wordmark__bond::before {
  top: 0.4em;
}

.wordmark__bond::after {
  top: 0.62em;
}

@keyframes bond-pulse {
  0% {
    box-shadow: 0 0 0 rgba(125, 211, 252, 0);
  }
  30% {
    box-shadow: 0 0 10px rgba(125, 211, 252, 0.9);
  }
  100% {
    box-shadow: 0 0 0 rgba(125, 211, 252, 0);
  }
}

.tagline {
  color: var(--text-muted);
  margin: var(--space-1) 0 0;
  font-size: 0.9rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-8);
}

.input-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-1);
  border: 1px dashed rgba(125, 211, 252, 0.35);
  border-radius: var(--radius);
  padding: var(--space-2);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.input-strip.is-valid {
  border-style: solid;
  border-color: var(--success);
}

.input-strip.is-invalid {
  border-style: solid;
  border-color: var(--danger);
  animation: shake 150ms 2;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.input-strip__label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

#smiles-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-2);
  font-family: inherit;
  font-size: 1rem;
}

#smiles-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.copy-button {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease),
    color 160ms var(--ease), border-color 160ms var(--ease);
}

.copy-button:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.copy-button:active {
  transform: scale(0.9);
}

.copy-button:focus-visible {
  outline: 2px solid var(--accent-support);
  outline-offset: 2px;
}

.copy-button.is-copied {
  color: var(--success);
  border-color: var(--success);
}

.render-button {
  background: var(--accent);
  color: #06263d;
  border: none;
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-3);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}

.render-button:hover {
  box-shadow: var(--glow);
}

.render-button:active {
  transform: scale(0.96);
}

.render-button:focus-visible {
  outline: 2px solid var(--accent-support);
  outline-offset: 2px;
}

.render-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.chip {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-2);
  min-height: 44px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease),
    color 160ms var(--ease), border-color 160ms var(--ease);
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.chip:active {
  transform: scale(0.96);
}

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

.parse-status {
  min-height: 1.25rem;
  margin: var(--space-1) 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.parse-status[data-state="error"] {
  color: var(--danger);
}

.parse-status[data-state="ok"] {
  color: var(--success);
}

.stage {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.panel {
  flex: 1;
  min-width: 0;
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: var(--space-2);
  height: 65vh;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  position: relative;
}

@keyframes panel-fresh {
  0% {
    opacity: 0.4;
    transform: scale(0.98);
    box-shadow: 0 0 0 rgba(125, 211, 252, 0);
  }
  30% {
    box-shadow: var(--glow);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 rgba(125, 211, 252, 0);
  }
}

.panel.is-fresh {
  animation: panel-fresh 400ms var(--ease);
}

.panel__label {
  margin: 0 0 var(--space-1);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.panel--2d,
.panel--3d {
  overflow: hidden;
}

#canvas-2d {
  flex: 1;
  width: 100%;
  height: 100%;
  display: block;
}

#viewer-3d {
  flex: 1;
  width: 100%;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.spin-toggle {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 44px;
  height: 44px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 31, 51, 0.85);
  color: var(--text);
  border: 1px solid var(--accent-support);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}

.spin-toggle:hover {
  box-shadow: var(--glow);
}

.spin-toggle:active {
  transform: scale(0.9);
}

.spin-toggle:focus-visible {
  outline: 2px solid var(--accent-support);
  outline-offset: 2px;
}

.spin-toggle[aria-pressed="false"] {
  color: var(--text-muted);
  border-color: var(--text-muted);
}

.readout {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  background: rgba(11, 31, 51, 0.85);
  border: 1px solid var(--accent-support);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
}

.readout .copy-button {
  background: transparent;
}

.readout__formula {
  color: var(--accent-support);
  font-weight: 700;
}

.readout__weight {
  color: var(--text-muted);
}

.app-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 160ms var(--ease);
}

.app-footer a:hover,
.app-footer a:focus-visible {
  color: var(--accent);
}

@media (max-width: 768px) {
  .stage {
    flex-direction: column;
  }

  .panel {
    height: 40vh;
    min-height: 280px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grid-backdrop {
    animation: none;
  }

  .wordmark__bond::before,
  .wordmark__bond::after {
    animation: none;
  }

  .input-strip.is-invalid {
    animation: none;
  }

  .panel,
  .panel.is-fresh {
    opacity: 1;
    transform: none;
    animation: none;
    box-shadow: none;
  }
}
