:root {
  --bg: #fff9d6;
  --surface: #fffdf2;
  --surface-strong: #ffef5a;
  --ink: #111111;
  --muted: #5b5540;
  --line: rgba(17, 17, 17, 0.12);
  --purple: #4a2acb;
  --purple-dark: #2e0f94;
  --danger: #c8372d;
  --success: #138a4b;
  --shadow: 0 14px 40px rgba(17, 17, 17, 0.08);
  --radius: 22px;
  --font-display: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(74, 42, 203, 0.12), transparent 28%),
    linear-gradient(180deg, #fffce8 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

a {
  color: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.24s ease;
}

.sidebar {
  padding: 32px 22px;
  background: var(--purple-dark);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.24s ease, opacity 0.24s ease;
  z-index: 20;
}

body.sidebar-hidden .shell {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-hidden .sidebar {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-strong);
  color: var(--purple-dark);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.brand strong,
.login-brand strong {
  display: block;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.brand small,
.login-brand small,
.user-card small {
  opacity: 0.78;
}

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

.nav-link {
  padding: 14px 16px;
  border-radius: 18px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.is-active {
  background: var(--surface-strong);
  color: var(--purple-dark);
  font-weight: 700;
}

.logout-form {
  margin-top: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.topbar-left,
.topbar-actions,
.panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-copy {
  display: grid;
  gap: 4px;
}

.topbar-copy .eyebrow {
  margin-bottom: 0;
}

.menu-button {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 0 14px;
  cursor: pointer;
}

.menu-button span {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: var(--purple-dark);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(17, 17, 17, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}

.user-card {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.main {
  padding: 32px;
}

.client-focus {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 10px;
}

.client-focus-actions {
  display: grid;
  gap: 8px;
}

.client-focus .ghost-button {
  justify-self: stretch;
}

.integration-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 10px;
}

.integration-card strong {
  display: block;
}

.integration-card small {
  opacity: 0.84;
}

.integration-card-actions {
  display: grid;
  gap: 8px;
}

.integration-card .ghost-button {
  justify-self: stretch;
}

.page-header,
.run-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.section-stack {
  display: grid;
  gap: 18px;
  margin-bottom: 28px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
}

.run-hero {
  background: linear-gradient(135deg, var(--surface-strong), #fff3a5);
  border-radius: 28px;
  padding: 26px 28px;
  box-shadow: var(--shadow);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  margin: 0 0 10px;
  color: var(--purple-dark);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1.1rem;
}

.hero-copy,
.muted {
  color: var(--muted);
}

.header-meta {
  background: rgba(74, 42, 203, 0.08);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
}

.banner {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.banner.is-notice {
  border-color: rgba(74, 42, 203, 0.18);
}

.banner.is-error {
  background: #fff1ef;
  border-color: rgba(200, 55, 45, 0.2);
  color: var(--danger);
}

.card-grid,
.step-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.feature-card,
.list-card,
.step-card,
.rail-card,
.panel,
.empty-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.feature-card,
.step-card,
.panel,
.empty-card {
  padding: 22px;
}

.panel-compact {
  padding: 18px 20px;
}

.list-card {
  padding: 20px 22px;
}

.list-card.compact {
  padding: 16px 18px;
}

.feature-card.is-selected {
  border-color: rgba(74, 42, 203, 0.34);
  box-shadow: 0 18px 44px rgba(74, 42, 203, 0.16);
}

.card-topline,
.list-card-main,
.card-footer,
.detail-list-inline,
.checkbox-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.detail-list span {
  color: var(--muted);
}

.detail-pill-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.detail-pill {
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(74, 42, 203, 0.12);
  background: rgba(74, 42, 203, 0.04);
  display: grid;
  gap: 6px;
}

.detail-pill span {
  color: var(--purple-dark);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-pill strong {
  font-size: 1rem;
  line-height: 1.35;
}

.compact-note {
  margin: 0;
}

.card-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button {
  background: var(--purple);
  color: #ffffff;
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  border: 1px solid rgba(74, 42, 203, 0.2);
  color: var(--purple-dark);
}

.ghost-button--light {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
}

.review-gates-strip {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 24px;
}

.dashboard-metrics {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 26px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}

.metric-card strong {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 2rem);
  line-height: 1;
}

.metric-card.tone-done {
  background: linear-gradient(180deg, #fffdf2 0%, #f2fff8 100%);
}

.metric-card.tone-waiting,
.metric-card.tone-active {
  background: linear-gradient(180deg, #fffdf2 0%, #fff8ca 100%);
}

.metric-card.tone-blocked {
  background: linear-gradient(180deg, #fffdf2 0%, #fff1ef 100%);
}

.review-gate-chip {
  background: linear-gradient(135deg, rgba(74, 42, 203, 0.08), rgba(255, 238, 0, 0.34));
  padding: 18px;
  border-radius: 22px;
  text-decoration: none;
  border: 1px solid rgba(74, 42, 203, 0.14);
  display: grid;
  gap: 6px;
}

.review-gate-chip strong,
.status-pill {
  text-transform: lowercase;
}

.status-pill,
.meta-label,
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill,
.meta-label {
  background: rgba(74, 42, 203, 0.1);
  color: var(--purple-dark);
}

.status-pill.is-success {
  background: rgba(19, 138, 75, 0.14);
  color: var(--success);
}

.step-number {
  background: var(--surface-strong);
}

.board-layout,
.workspace-grid {
  display: grid;
  gap: 22px;
}

.board-layout {
  grid-template-columns: minmax(0, 1.9fr) minmax(280px, 0.9fr);
}

.workspace-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-tall {
  min-height: 360px;
}

.board-main,
.stack-list {
  display: grid;
  gap: 18px;
}

.asset-layout {
  display: grid;
  gap: 24px;
}

.prompt-detail-stack {
  display: grid;
  gap: 18px;
  margin-bottom: 28px;
}

.prompt-live-card {
  display: grid;
  gap: 16px;
}

.output-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.asset-bundle-list {
  display: grid;
  gap: 10px;
}

.asset-bundle-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(74, 42, 203, 0.04);
  border: 1px solid rgba(74, 42, 203, 0.08);
}

.asset-bundle-copy {
  display: grid;
  gap: 4px;
}

.asset-bundle-copy small {
  color: var(--muted);
}

.asset-bundle-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.flow-section {
  display: grid;
  gap: 14px;
}

.flow-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.flow-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
}

.flow-rail {
  display: grid;
  justify-items: center;
  grid-template-rows: auto 1fr;
}

.flow-marker {
  width: 42px;
  min-height: 42px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid rgba(74, 42, 203, 0.12);
  box-shadow: var(--shadow);
  font-weight: 800;
  color: var(--purple-dark);
}

.flow-line {
  width: 2px;
  min-height: 100%;
  background: linear-gradient(180deg, rgba(74, 42, 203, 0.22), rgba(74, 42, 203, 0.08));
  margin-top: 8px;
}

.flow-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.flow-card-collapsible {
  overflow: hidden;
}

.flow-card-collapsible > summary {
  list-style: none;
  cursor: pointer;
}

.flow-card-collapsible > summary::-webkit-details-marker {
  display: none;
}

.flow-card-summary {
  display: grid;
  gap: 10px;
}

.flow-card-summary-copy {
  margin: 0;
}

.flow-card-body {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.flow-item.tone-done .flow-card {
  background: linear-gradient(180deg, #fffdf2 0%, #f2fff8 100%);
}

.flow-item.tone-active .flow-card {
  background: linear-gradient(180deg, #fffdf2 0%, #fff8ca 100%);
}

.flow-item.tone-waiting .flow-card {
  background: linear-gradient(180deg, #fffdf2 0%, #f3eefe 100%);
}

.flow-item.tone-blocked .flow-card {
  background: linear-gradient(180deg, #fffdf2 0%, #fff1ef 100%);
}

.flow-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.flow-meta {
  display: grid;
  gap: 10px;
}

.flow-meta-block {
  display: grid;
  gap: 8px;
}

.flow-meta-block a {
  text-decoration: none;
}

.flow-artifact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.flow-artifact-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(74, 42, 203, 0.08);
  text-decoration: none;
}

.compact-dashboard-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.activity-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.activity-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.output-item {
  text-decoration: none;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(74, 42, 203, 0.04);
  border-radius: 18px;
  border: 1px solid rgba(74, 42, 203, 0.08);
}

.output-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.phase-block {
  display: grid;
  gap: 16px;
}

.board-rail {
  display: grid;
  gap: 18px;
}

.rail-card {
  padding: 18px;
}

.rail-link {
  display: block;
  padding: 10px 0;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.rail-link:last-child {
  border-bottom: 0;
}

.stack-form,
.form-grid {
  display: grid;
  gap: 14px;
}

.collapsible-panel,
.collapsible-section {
  overflow: hidden;
}

.collapsible-panel > summary,
.collapsible-section > summary {
  list-style: none;
  cursor: pointer;
}

.collapsible-panel > summary::-webkit-details-marker,
.collapsible-section > summary::-webkit-details-marker {
  display: none;
}

.collapsible-trigger {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.collapsible-trigger-section {
  margin-bottom: 0;
}

details[open] > .collapsible-trigger-section {
  margin-bottom: 18px;
}

.collapsible-copy {
  display: grid;
  gap: 4px;
}

.collapsible-copy .eyebrow {
  margin: 0;
}

.collapsible-copy strong {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.9rem);
  line-height: 1.08;
}

.collapsible-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(74, 42, 203, 0.08);
  color: var(--purple-dark);
  font-weight: 700;
  white-space: nowrap;
}

.collapsible-indicator::before {
  content: "Collapse";
}

.collapsible-indicator::after {
  content: "▾";
  font-size: 0.95rem;
}

details:not([open]) > summary .collapsible-indicator::before {
  content: "Expand";
}

details:not([open]) > summary .collapsible-indicator::after {
  content: "▸";
}

.collapsible-body {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.prompt-toolbar {
  justify-content: flex-end;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 18px;
  padding: 12px 14px;
  background: #ffffff;
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

.code-block {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  font: 0.95rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.code-block-compact {
  max-height: 240px;
  overflow: auto;
}

.prompt-viewer {
  min-height: 360px;
  max-height: min(76vh, 1120px);
  overflow: auto;
}

.prompt-document {
  font: 1rem/1.72 var(--font-body);
}

.prompt-preview {
  margin-top: 16px;
}

.prompt-preview summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--purple-dark);
  margin-bottom: 10px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(1080px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 24px;
}

.login-hero,
.login-card {
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.login-hero {
  background: linear-gradient(135deg, var(--surface-strong), #fff3a5 60%, #ffffff 100%);
  padding: 38px;
}

.login-card {
  background: var(--surface);
  padding: 32px;
  border: 1px solid var(--line);
}

.login-button-link {
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-local-fallback {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.login-local-fallback summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--purple-dark);
}

.login-local-fallback[open] form {
  margin-top: 18px;
}

.artifact-line {
  margin: 14px 0 10px;
}

.state-ready {
  background: linear-gradient(180deg, #fffdf2 0%, #fff8ca 100%);
}

.state-in_progress {
  background: linear-gradient(180deg, #fffdf2 0%, #f3eefe 100%);
}

.state-waiting_review {
  background: linear-gradient(180deg, #fff8ca 0%, #fff1a3 100%);
}

.state-done {
  background: linear-gradient(180deg, #fffdf2 0%, #f2fff8 100%);
}

.state-blocked {
  background: linear-gradient(180deg, #fffdf2 0%, #fff1ef 100%);
}

@media (max-width: 1100px) {
  .shell,
  .login-shell,
  .board-layout,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .review-gates-strip,
  .dashboard-metrics,
  .compact-dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding-bottom: 18px;
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    min-height: 100vh;
    height: 100vh;
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-hidden .shell {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 22px 18px 28px;
  }

  .topbar {
    align-items: flex-start;
  }

  .run-hero,
  .flow-card-top,
  .asset-bundle-item {
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .asset-bundle-actions {
    justify-content: flex-start;
  }

  .flow-item {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .flow-marker {
    width: 36px;
    min-height: 36px;
    border-radius: 14px;
    font-size: 0.86rem;
  }

  .collapsible-trigger {
    flex-direction: column;
    align-items: stretch;
  }

  .collapsible-indicator {
    align-self: flex-start;
  }
}
