:root {
  --bg-start: #030610;
  --bg-end: #101633;
  --panel: rgba(12, 17, 41, 0.85);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f7f8ff;
  --text-muted: #c1c6ff;
  --accent: #00d6b8;
  --accent-dark: #00a48a;
  --danger: #ff7c7c;
  --surface-muted: rgba(0, 0, 0, 0.25);
  --chip-bg: rgba(255, 255, 255, 0.07);
  --ghost-border: rgba(255, 255, 255, 0.2);
  --radius: 18px;
  --shadow: 0 25px 80px rgba(3, 6, 16, 0.6);
}

:root[data-theme="light"] {
  --bg-start: #f7f9ff;
  --bg-end: #dfe8ff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(12, 17, 41, 0.08);
  --text-primary: #11142a;
  --text-muted: #505472;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #d50032;
  --surface-muted: rgba(17, 20, 40, 0.06);
  --chip-bg: rgba(17, 20, 40, 0.09);
  --ghost-border: rgba(12, 17, 41, 0.18);
  --shadow: 0 25px 60px rgba(15, 18, 40, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Helvetica Neue", sans-serif;
  background: radial-gradient(circle at top, var(--bg-start), var(--bg-end));
  color: var(--text-primary);
  line-height: 1.6;
  display: flex;
  justify-content: center;
  padding: 2.5rem 1.25rem 3rem;
  transition: background 0.45s ease, color 0.45s ease;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 20% 20%, rgba(0, 214, 184, 0.25), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(0, 117, 255, 0.25), transparent 50%),
    radial-gradient(circle at 30% 80%, rgba(255, 166, 0, 0.18), transparent 45%);
  filter: blur(60px);
  opacity: 0.9;
}

:root[data-theme="light"] .backdrop {
  background: radial-gradient(circle at 25% 25%, rgba(37, 99, 235, 0.25), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(249, 188, 73, 0.4), transparent 45%),
    radial-gradient(circle at 30% 80%, rgba(8, 148, 125, 0.2), transparent 45%);
  filter: blur(80px);
  opacity: 0.65;
}

.shell {
  position: relative;
  width: min(1120px, 100%);
  display: grid;
  gap: 1.5rem;
  z-index: 1;
}

.hero {
  text-align: left;
}


.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.hero h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.hero p {
  max-width: 720px;
  color: var(--text-muted);
}

.eyebrow {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  transition: background 0.35s ease, border 0.35s ease, box-shadow 0.35s ease;
}

form {
  display: grid;
  gap: 1.25rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-weight: 500;
}

input,
textarea,
select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease;
  resize: vertical;
}

textarea {
  overflow-y: hidden;
  resize: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 214, 184, 0.08);
}

select {
  appearance: none;
  cursor: pointer;
  resize: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-primary) 50%),
    linear-gradient(135deg, var(--text-primary) 50%, transparent 50%);
  background-position: calc(100% - 26px) calc(50% + 2px), calc(100% - 20px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}

/* Ensure dropdown text stays legible against system popup backgrounds */
select option,
select optgroup {
  color: var(--text-primary);
  background-color: var(--panel);
}

select optgroup {
  font-weight: 600;
}

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

.helper span {
  color: var(--accent);
}

button {
  border: none;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#generate-btn {
  background: linear-gradient(120deg, var(--accent), #01baf5);
  color: #031313;
  box-shadow: 0 12px 30px rgba(0, 214, 184, 0.35);
}

#generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

#generate-btn:not(:disabled):hover {
  transform: translateY(-2px);
}

.theme-btn {
  border-radius: 999px;
  font-size: 0.9rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--ghost-border);
  background: transparent;
  color: var(--text-primary);
  transition: border 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ghost-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--ghost-border);
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
}

.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.output-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.status[data-state="success"] {
  color: #9ff2c9;
}

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

.script-block {
  background: var(--surface-muted);
  border-radius: 14px;
  padding: 1.25rem;
  border: 1px solid var(--panel-border);
  white-space: pre-line;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.98rem;
  line-height: 1.8;
  min-height: 220px;
  transition: background 0.35s ease, border 0.35s ease, color 0.35s ease;
}

.time-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text-primary);
}

.time-badge.over-limit {
  background: rgba(255, 124, 124, 0.16);
  color: var(--danger);
}

@media (max-width: 720px) {
  body {
    padding: 1.5rem;
  }

  .panel {
    padding: 1.25rem;
  }

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

  .script-block {
    font-size: 0.92rem;
  }
}
