:root {
  --page: #eef2ff;
  --paper: #fffdf8;
  --ink: #0f172a;
  --muted: #475569;
  --line: #dbe3f0;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --emerald-soft: #dcfce7;
  --amber-soft: #fef3c7;
  --slate-soft: #e2e8f0;
  --indigo-soft: #e0e7ff;
  --firewall: #fee2e2;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.10), transparent 30%),
    linear-gradient(180deg, #f8fafc 0%, var(--page) 100%);
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 16px auto;
  padding: 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.eyebrow,
.rail-label,
.phase-kicker,
.drawer-label {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #334155;
}

.topbar h1 {
  margin: 10px 0 8px;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
}

.lede,
.scenario-summary,
.phase-narrative,
.review-note p,
.footer-note,
.compact-list,
.detail-list,
.artifact-card dd,
.artifact-section p,
.provider-card p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  font-weight: 600;
}

.site-boundary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 18px;
}

.site-boundary span,
.boundary-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.scenario-rail,
.main-panel,
.receipt-drawer {
  min-width: 0;
}

.rail-card,
.phase-panel,
.receipt-drawer,
.artifact-card,
.artifact-section,
.review-note,
.firewall-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.rail-card {
  padding: 18px;
  margin-bottom: 14px;
}

.scenario-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.scenario-button {
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #ffffff;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.scenario-button:hover,
.scenario-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(29, 78, 216, 0.12);
  border-color: #93c5fd;
}

.scenario-button.selected {
  background: var(--accent-soft);
  border-color: #60a5fa;
}

.scenario-button-tag,
.scenario-tag {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--indigo-soft);
  color: #3730a3;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.scenario-button strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 6px;
}

.scenario-button small {
  display: block;
  line-height: 1.45;
  color: var(--muted);
}

.compact-list,
.detail-list {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.55;
}

.main-panel {
  display: grid;
  gap: 16px;
}

.scenario-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 22px 24px 0;
}

.scenario-header h2 {
  margin: 8px 0 10px;
  font-size: clamp(1.6rem, 2vw, 2.3rem);
}

.drawer-toggle {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.authority-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 24px;
  padding: 14px 16px;
  border-radius: 18px;
  font-weight: 700;
}

.authority-amber {
  background: var(--amber-soft);
  color: #92400e;
}

.authority-green {
  background: var(--emerald-soft);
  color: #166534;
}

.authority-slate {
  background: var(--slate-soft);
  color: #334155;
}

.boundary-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px;
}

.phase-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 24px;
}

.phase-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.phase-tab.selected {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.phase-tab-number {
  display: inline-flex;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.08);
}

.phase-tab.selected .phase-tab-number {
  background: rgba(255, 255, 255, 0.2);
}

.phase-panel {
  padding: 24px;
}

.phase-copy h3 {
  margin: 8px 0 10px;
  font-size: 1.6rem;
}

.artifact-panel {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.artifact-card,
.artifact-section,
.review-note,
.firewall-card {
  padding: 18px;
}

.artifact-card h4,
.artifact-section h4,
.review-note h4,
.firewall-card h4 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.card-blue {
  background: #f8fbff;
}

.card-green {
  background: #f8fff9;
}

.card-indigo {
  background: #f7f6ff;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.detail-grid dt {
  font-size: 0.82rem;
  font-weight: 800;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.detail-grid dd {
  margin: 0;
  line-height: 1.45;
}

.edge-grid,
.provider-grid {
  display: grid;
  gap: 12px;
}

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

.edge-card,
.provider-card {
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.edge-open {
  background: #fffbeb;
  border-color: #fcd34d;
}

.edge-bounded {
  background: #f8fafc;
}

.edge-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.edge-head span {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #92400e;
}

.provider-role {
  margin: 0 0 8px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1d4ed8;
}

.firewall-card {
  background: #fff5f5;
  border-color: #fca5a5;
}

.receipt-drawer {
  padding: 18px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 68px);
  overflow: auto;
  transition: opacity 160ms ease, transform 160ms ease;
}

.hidden-drawer {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.drawer-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.artifact-type {
  margin: 8px 0 0;
  font-weight: 700;
}

.artifact-json {
  margin: 16px 0 0;
  padding: 16px;
  border-radius: 16px;
  background: #0f172a;
  color: #cbd5e1;
  overflow: auto;
  font-size: 0.84rem;
  line-height: 1.5;
}

.footer-note {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 0.92rem;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .receipt-drawer {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: calc(100vw - 18px);
    padding: 16px;
    border-radius: 20px;
  }

  .topbar,
  .scenario-header {
    flex-direction: column;
  }

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

  .detail-grid,
  .edge-grid {
    grid-template-columns: 1fr;
  }

  .authority-banner,
  .boundary-chip-row,
  .phase-tabs,
  .scenario-header {
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .phase-panel {
    padding: 18px;
  }
}
