:root {
  --color-bg: #0f0a1a;
  --color-surface: #1a1228;
  --color-surface-2: #231a38;
  --color-border: #2e2050;
  --color-accent: #a78bfa;
  --color-accent-bright: #c4b5fd;
  --color-accent-deep: #7c3aed;
  --color-success: #34d399;
  --color-error: #f87171;
  --color-text-primary: #f5f3ff;
  --color-text-secondary: #d6bcfa;
  --color-text-muted: #9ca3af;
  --gradient-hero: linear-gradient(135deg, #0f0a1a 0%, #1e1040 50%, #0f0a1a 100%);
  --shadow-soft: 0 24px 60px rgba(3, 0, 12, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  color: var(--color-text-primary);
  background:
    radial-gradient(circle at top, rgba(167, 139, 250, 0.18), transparent 30%),
    radial-gradient(circle at 85% 20%, rgba(124, 58, 237, 0.16), transparent 20%),
    var(--gradient-hero);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar,
.dashboard-header,
.workspace-header,
.cta-row,
.card-footer-row,
.upload-row,
.workspace-meta,
.composer-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar,
.dashboard-header,
.workspace-header {
  justify-content: space-between;
}

.topbar {
  margin-bottom: 28px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-mark strong {
  display: block;
  font-family: "Cinzel", serif;
  letter-spacing: 0.04em;
}

.brand-mark small {
  color: var(--color-text-muted);
}

.brand-mark__glyph {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--color-accent-deep), var(--color-accent));
  box-shadow: 0 16px 40px rgba(124, 58, 237, 0.32);
  font-family: "Cinzel", serif;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav form {
  margin: 0;
}

.content-frame,
.stage-card-list,
.dashboard-side-column,
.stack-form,
.chat-thread,
.workspace-actions,
.rail-list {
  display: grid;
  gap: 18px;
}

.hero-grid,
.dashboard-grid,
.workspace-shell,
.documents-grid {
  display: grid;
  gap: 24px;
}

.hero-grid {
  grid-template-columns: 1.4fr 1fr;
  align-items: stretch;
  min-height: 72vh;
}

.dashboard-grid,
.documents-grid {
  grid-template-columns: 1.5fr 1fr;
}

.workspace-shell {
  grid-template-columns: 320px 1fr;
  align-items: start;
}

.workspace-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 24px;
  min-width: 0;
}

.glass-panel {
  background: rgba(26, 18, 40, 0.86);
  border: 1px solid var(--color-border);
  border-radius: 28px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  padding: 28px;
}

.hero-copy h1,
.dashboard-header h1,
.center-card h1,
.completion-panel h1 {
  margin: 0 0 16px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 1.05;
  font-family: "Cinzel", serif;
}

.stage-panel h1 {
  margin: 0 0 12px;
  font-size: clamp(1.55rem, 2.3vw, 2.5rem);
  line-height: 1.18;
  font-family: "Cinzel", serif;
  max-width: 18ch;
}

.hero-copy p,
.dashboard-header p,
.stage-panel p,
.center-card p,
.muted-copy,
.stage-card p {
  color: var(--color-text-secondary);
  line-height: 1.75;
}

.eyebrow,
.section-heading,
.chat-role {
  display: block;
  color: var(--color-accent-bright);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  margin-bottom: 12px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--color-accent-deep), var(--color-accent));
  color: white;
  box-shadow: 0 12px 32px rgba(109, 40, 217, 0.35);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.feature-list,
.simple-list,
.rail-list,
.document-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li,
.simple-list li,
.document-list li {
  padding: 14px 0;
  border-bottom: 1px solid rgba(167, 139, 250, 0.12);
}

.simple-list li,
.document-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.simple-list strong,
.document-list strong,
.rail-item strong {
  display: block;
  color: var(--color-text-primary);
}

.simple-list span,
.document-list span,
.rail-item small {
  color: var(--color-text-muted);
}

.stack-form label,
.stack-form span {
  display: grid;
  gap: 8px;
}

.app-input,
.app-textarea {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(167, 139, 250, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-primary);
  padding: 14px 16px;
}

.app-textarea {
  min-height: 120px;
  resize: vertical;
}

.inline-code-block {
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--color-accent-bright);
  font-family: "JetBrains Mono", monospace;
  overflow-wrap: anywhere;
}

.stage-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(167, 139, 250, 0.12);
}

.stage-card--locked {
  opacity: 0.6;
}

.status-chip,
.stat-pill,
.doc-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(167, 139, 250, 0.18);
  color: var(--color-text-secondary);
}

.status-chip--accent {
  border-color: rgba(167, 139, 250, 0.45);
  color: var(--color-accent-bright);
}

.status-chip--success {
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--color-success);
}

.stage-rail {
  position: sticky;
  top: 18px;
}

.canvas-panel {
  position: sticky;
  top: 18px;
  min-width: 0;
}

.canvas-copy {
  margin-top: 0;
  margin-bottom: 18px;
}

.live-canvas-frame {
  width: 100%;
  min-height: 78vh;
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-radius: 22px;
  background: white;
}

.rail-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  opacity: 0.72;
}

.rail-item--active {
  opacity: 1;
}

.rail-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: 5px;
  background: rgba(255, 255, 255, 0.15);
}

.rail-dot--active {
  background: var(--color-accent);
  box-shadow: 0 0 18px rgba(167, 139, 250, 0.85);
}

.rail-dot--success {
  background: var(--color-success);
}

.document-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.chat-thread {
  min-height: 360px;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 18px;
}

.chat-bubble {
  max-width: 78%;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(167, 139, 250, 0.12);
}

.chat-bubble--assistant {
  background: rgba(255, 255, 255, 0.03);
}

.chat-bubble--user {
  justify-self: end;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.45), rgba(167, 139, 250, 0.24));
}

.chat-content {
  white-space: pre-wrap;
  line-height: 1.75;
}

.composer-textarea {
  min-height: 88px;
}

.upload-row {
  flex-wrap: wrap;
}

.status-banner {
  margin: 12px 0 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

.artifact-frame {
  width: 100%;
  min-height: 520px;
  margin-top: 24px;
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-radius: 22px;
  background: white;
}

.field-validation-error {
  color: var(--color-error);
  font-size: 0.85rem;
}

.thinking::after {
  content: "...";
  animation: pulse-dots 1.1s infinite ease-in-out;
}

@keyframes pulse-dots {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

@media (max-width: 960px) {
  .hero-grid,
  .dashboard-grid,
  .workspace-shell,
  .workspace-main,
  .documents-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .dashboard-header,
  .workspace-header,
  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-bubble {
    max-width: 100%;
  }

  .stage-rail,
  .canvas-panel {
    position: static;
  }

  .live-canvas-frame {
    min-height: 60vh;
  }
}