:root {
  color-scheme: light;
  --bg-1: #0c1324;
  --bg-2: #141c33;
  --panel: rgba(14, 20, 36, 0.82);
  --panel-border: rgba(150, 175, 210, 0.2);
  --text: #e8edf6;
  --muted: #9fb0cc;
  --accent: #ff7a4a;
  --accent-2: #36c9c6;
  --shadow: 0 20px 60px rgba(10, 14, 24, 0.45);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: radial-gradient(circle at top left, #1f2f4c, transparent 55%),
    radial-gradient(circle at 10% 20%, #2a3857, transparent 35%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0) 60%
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 24px
    );
  pointer-events: none;
  z-index: 0;
}

.error-flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 46, 46, 0.65);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

.error-flash.is-active {
  animation: errorFlash 0.55s ease-in-out;
}

.site {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 48px;
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tagline {
  color: var(--muted);
  font-size: 0.95rem;
}

.hero {
  max-width: 780px;
  margin-bottom: 32px;
}

.hero h1 {
  font-size: clamp(2rem, 2.6vw, 2.8rem);
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero p {
  color: var(--muted);
  font-size: 1.05rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.35fr);
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
}

textarea {
  min-height: 140px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 10, 20, 0.7);
  color: var(--text);
  padding: 12px;
  font-family: "IBM Plex Mono", "Space Grotesk", monospace;
  font-size: 0.85rem;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(54, 201, 198, 0.2);
}

.toggles {
  display: grid;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.toggle input {
  accent-color: var(--accent);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.btn.primary {
  background: linear-gradient(130deg, var(--accent), #ffb06f);
  color: #1a1310;
  box-shadow: 0 12px 30px rgba(255, 122, 74, 0.3);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
}

.stats {
  font-size: 0.9rem;
  color: var(--muted);
}

.status {
  font-size: 0.85rem;
  color: var(--accent-2);
}

.status.error {
  color: #ffb7b0;
}

.viewer {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.viewer-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.viewer-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.viewer-frame {
  position: relative;
  border-radius: 16px;
  background: rgba(9, 12, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 420px;
  overflow: hidden;
}

.viewer-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
}

.viewer-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 1rem;
  pointer-events: none;
  z-index: 2;
}

.site-footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 0.9rem;
}

[data-animate] {
  opacity: 0;
  transform: translateY(16px);
  animation: rise 0.7s ease forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes errorFlash {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 0.45;
  }
  60% {
    opacity: 0.25;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

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

@media (max-width: 600px) {
  .site {
    padding: 28px 18px 36px;
  }

  .panel {
    padding: 18px;
  }

  .viewer-frame {
    min-height: 320px;
  }
}
