:root {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
  color: #0f172a;
  background-color: #f7f9ff;
  --gradient-start: #f4f5ff;
  --gradient-end: #e0f3ff;
  --primary: #635bff;
  --primary-dark: #5044ff;
  --primary-soft: rgba(99, 91, 255, 0.12);
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --surface: rgba(255, 255, 255, 0.95);
  --surface-strong: rgba(255, 255, 255, 0.75);
  --border: rgba(99, 102, 241, 0.18);
  --shadow: 0 30px 60px rgba(15, 23, 42, 0.12);
  --text-muted: #475569;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--gradient-start), var(--gradient-end));
  position: relative;
  color: inherit;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.18), transparent 55%),
    radial-gradient(circle at top right, rgba(16, 185, 129, 0.15), transparent 45%),
    radial-gradient(circle at bottom, rgba(14, 165, 233, 0.18), transparent 50%);
  z-index: -2;
}

.app-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  width: 420px;
  height: 420px;
  filter: blur(60px);
  opacity: 0.55;
}

.orb-one {
  top: -140px;
  left: -120px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.8), transparent 70%);
}

.orb-two {
  bottom: -180px;
  right: -120px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.75), transparent 65%);
}

.orb-three {
  top: 50%;
  left: 55%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(14, 165, 233, 0.8), transparent 70%);
}

.hidden {
  display: none !important;
}

button {
  font: inherit;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  padding: 0.7rem 1.4rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease,
    color 0.15s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 12px 30px rgba(99, 91, 255, 0.3);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 45px rgba(99, 91, 255, 0.35);
}

button.ghost {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid rgba(99, 91, 255, 0.2);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--primary-soft);
}

.ghost.danger {
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

.ghost.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.login-wrapper {
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vw, 6rem) 1.5rem;
}

.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 1.8rem;
  padding: clamp(2rem, 5vw, 3rem);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.login-heading h1 {
  margin: 0.35rem 0 0.75rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
}

.login-heading p {
  margin: 0;
  color: var(--text-muted);
}

.login-form {
  display: grid;
  gap: 1.1rem;
  margin-top: 1.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--text-muted);
}

input,
select,
textarea {
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.75rem 1rem;
  font: inherit;
  background: white;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(99, 91, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.12);
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

.login-hint {
  margin-top: 1.25rem;
  color: var(--text-muted);
  text-align: center;
}

code {
  background: rgba(15, 23, 42, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: 0.45rem;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.85rem;
}

#app-shell {
  padding: 1.5rem clamp(1.5rem, 5vw, 3rem) 4rem;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: 1.6rem;
  padding: 1rem 1.4rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: clamp(2rem, 6vw, 3rem);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  background: transparent;
  border: none;
  padding: 0.4rem 0.9rem;
  color: #111827;
  text-align: left;
}

.brand-title {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

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

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-menu {
  position: relative;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--surface-strong);
  padding: 0.4rem 0.8rem 0.4rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(99, 91, 255, 0.18);
}

.user-trigger svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px rgba(99, 91, 255, 0.4);
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  background: white;
  border-radius: 1rem;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(99, 91, 255, 0.18);
  padding: 0.4rem;
  min-width: 160px;
  display: grid;
  gap: 0.25rem;
  z-index: 10;
}

.menu-item {
  background: transparent;
  border-radius: 0.8rem;
  padding: 0.55rem 0.75rem;
  justify-content: flex-start;
  display: flex;
  gap: 0.5rem;
  color: #0f172a;
}

.menu-item:hover {
  background: var(--primary-soft);
}

#content {
  display: grid;
  gap: clamp(2rem, 5vw, 3rem);
}

.view {
  background: var(--surface);
  border-radius: 2rem;
  padding: clamp(2rem, 5vw, 3rem);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.landing-hero {
  display: grid;
  gap: clamp(2rem, 4vw, 3rem);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: stretch;
}

.hero-copy h2 {
  margin: 0.4rem 0 1rem;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.hero-copy p {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  max-width: 50ch;
}

.cta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}


.hero-card {
  background: linear-gradient(160deg, rgba(99, 91, 255, 0.2), rgba(14, 165, 233, 0.2));
  border-radius: 1.6rem;
  padding: 1.6rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(99, 91, 255, 0.25);
  display: grid;
  gap: 1rem;
}

.hero-card-header h3 {
  margin: 0;
}

.hero-card-body {
  display: grid;
  gap: 0.5rem;
}

.hero-build-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.hero-build-meta {
  margin: 0;
  color: var(--text-muted);
}

.hero-card-body .hint {
  margin: 0;
}

.landing-builds {
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  display: grid;
  gap: 1.5rem;
}

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

.landing-build-grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.landing-build-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(99, 91, 255, 0.14);
  border-radius: 1.25rem;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
}

.landing-build-main {
  display: grid;
  gap: 0.35rem;
}

.landing-build-card .build-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.landing-build-card .build-meta,
.landing-build-card .build-created {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.landing-build-actions {
  display: flex;
  gap: 0.6rem;
}

.landing-build-card button {
  flex: 1 1 auto;
}

.landing-build-card button[data-action="delete-build"] {
  border-color: rgba(239, 68, 68, 0.3);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-weight: 700;
}


.view-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 2rem;
}

.view-header h2 {
  margin: 0.4rem 0 0.6rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.view-header .hint {
  margin: 0;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.active-build-pill {
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #047857;
  font-weight: 600;
}

.workspace-stack {
  display: grid;
  gap: 1.5rem;
}

.card {
  background: white;
  border-radius: 1.6rem;
  padding: clamp(1.5rem, 4vw, 2rem);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.1);
}

.card h3 {
  margin: 0 0 0.75rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card-header h3 {
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

fieldset {
  border: 1px dashed rgba(99, 91, 255, 0.25);
  border-radius: 1.2rem;
  padding: 1.25rem;
  margin: 1.75rem 0;
  background: rgba(255, 255, 255, 0.7);
}

#stage-one.collapsed {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
}

.stage-details {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
  margin-top: 1.5rem;
}

.stage-details fieldset {
  margin: 0;
}

.variables-columns {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
}

.stage-one-body {
  display: grid;
  gap: 1rem;
}

.stage-one-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

.stage-one-summary-text {
  font-weight: 600;
  color: var(--text-muted);
}

.stage-trigger {
  margin-top: 1rem;
  align-self: flex-start;
}

button.small {
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
}

legend {
  font-weight: 700;
  padding: 0 0.35rem;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.status {
  margin-top: 0.85rem;
  min-height: 1.4rem;
  font-weight: 600;
}

.status.error {
  color: #dc2626;
}

.status.success {
  color: #059669;
}

.inline-status {
  margin: 0;
  font-size: 0.95rem;
}

.ai-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.35rem 0 0.65rem;
}

.icon-button {
  padding: 0.45rem 0.85rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 0.8rem;
  font-size: 1.2rem;
}

.icon-button:hover {
  color: var(--primary);
  border-color: rgba(99, 91, 255, 0.25);
}

.config-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  margin-bottom: 0.75rem;
}

.build-list {
  display: grid;
  gap: 1.1rem;
}

.variable-type-group {
  display: grid;
  gap: 0.9rem;
  padding: 0.75rem 0;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.variable-type-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.variable-type-heading {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--text-muted);
}

.build-card {
  background: rgba(248, 250, 252, 0.9);
  border-radius: 1.2rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  display: grid;
  gap: 0.75rem;
}

.build-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.build-card-header h4 {
  margin: 0 0 0.35rem;
}

.build-meta,
.build-created {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.variable-card {
  background: white;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.variable-card[open] {
  border-color: rgba(99, 102, 241, 0.28);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.variable-card summary {
  list-style: none;
}

.variable-card-summary {
  margin: 0;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: inherit;
  background: transparent;
  transition: background-color 0.2s ease;
}

.variable-card-summary::-webkit-details-marker {
  display: none;
}

.variable-card-summary::after {
  content: "\203A";
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.variable-card[open] .variable-card-summary::after {
  transform: rotate(90deg);
}

.variable-card-summary:hover,
.variable-card-summary:focus-visible {
  background: rgba(99, 102, 241, 0.08);
  outline: none;
}

.variable-name {
  font-size: 1rem;
}

.variable-card-body {
  display: grid;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.02);
}

.variable-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.variable-description {
  margin: 0;
  color: var(--text-muted);
}

.variable-config {
  margin: 0;
  background: rgba(15, 23, 42, 0.06);
  padding: 0.8rem;
  border-radius: 0.8rem;
  font-size: 0.85rem;
  overflow-x: auto;
}

@media (max-width: 720px) {
  .top-nav {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .nav-actions {
    justify-content: space-between;
  }

  .menu {
    right: 50%;
    transform: translateX(50%);
  }

  .config-row {
    grid-template-columns: 1fr;
  }
}
