:root {
  color-scheme: dark;
  --bg: #1e2533;
  --bg-deep: #161c28;
  --surface: rgba(40, 48, 65, 0.9);
  --surface-strong: rgba(33, 40, 55, 0.96);
  --surface-soft: rgba(60, 69, 89, 0.78);
  --panel: rgba(255, 255, 255, 0.05);
  --panel-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(125, 211, 252, 0.28);
  --text: #f6f8fb;
  --text-dim: #b5bfd3;
  --text-soft: #8f9bb4;
  --accent: #7dd3fc;
  --accent-2: #86efac;
  --accent-3: #c084fc;
  --teal: #2dd4bf;
  --gold: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --purple: #c084fc;
  --radius: 24px;
  --radius-sm: 18px;
  --shadow: 0 24px 72px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.18);
  --font: "IBM Plex Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", "Fira Code", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(192, 132, 252, 0.14), transparent 24%),
    linear-gradient(180deg, #2a3243 0%, #232a39 36%, #171d29 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.flow-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 12%, rgba(134, 239, 172, 0.12), transparent 18%),
    radial-gradient(circle at 84% 16%, rgba(125, 211, 252, 0.14), transparent 20%);
}

.flow-shell {
  position: relative;
  z-index: 1;
  width: min(1520px, calc(100% - 28px));
  margin: 14px auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 28px);
}

.flow-sidebar,
.flow-topbar,
.environment-hero,
.surface-card,
.drawer__panel {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-strong) 100%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.flow-sidebar,
.flow-topbar,
.environment-hero,
.surface-card,
.drawer__panel {
  border-radius: var(--radius);
}

.flow-sidebar {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.flow-stage {
  display: grid;
  gap: 16px;
  align-content: start;
}

.focus-strip {
  display: grid;
  gap: 16px;
}

.focus-strip__cards,
.focus-strip__actions {
  display: grid;
  gap: 12px;
}

.focus-strip__cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.focus-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
}

.focus-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.focus-strip__actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sidebar-card,
.metric-card,
.connection-card,
.path-step,
.thread-card,
.pressure-card,
.watch-row,
.alignment-row {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
}

.sidebar-card {
  padding: 18px;
}

.sidebar-card--brand {
  background:
    radial-gradient(circle at top right, rgba(125, 211, 252, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(55, 65, 86, 0.88) 0%, rgba(33, 40, 55, 0.96) 100%);
}

.shell-eyebrow,
.hero-eyebrow,
.section-kicker,
.sidebar-label,
.metric-label,
.connection-label,
.meta-label {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar-card h1,
.environment-hero h2,
.section-head h3,
.drawer__header h2,
.thread-detail h4 {
  margin: 0;
  letter-spacing: -0.03em;
}

.sidebar-subtitle,
.sidebar-copy,
.topbar-line,
.hero-subtitle,
.hero-copy__body,
.drawer-copy,
.empty-state {
  color: var(--text-dim);
  line-height: 1.6;
}

.sidebar-subtitle {
  margin: 6px 0 0;
  font-weight: 600;
}

.sidebar-copy {
  margin: 10px 0 0;
}

.sidebar-nav,
.sidebar-stack {
  display: grid;
  gap: 8px;
}

.sidebar-link,
.sidebar-chip,
.icon-button,
.action-link {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-link {
  justify-content: flex-start;
}

.sidebar-chip {
  justify-content: flex-start;
}

.action-link {
  justify-content: center;
  font-weight: 600;
}

.action-link--button {
  cursor: pointer;
}

.flow-topbar {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-breadcrumb {
  margin: 0;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.topbar-line {
  margin: 6px 0 0;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-chip,
.status-pill,
.connection-status,
.pressure-badge,
.tag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-chip {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
}

.status-chip--active {
  color: var(--accent-2);
  border-color: rgba(134, 239, 172, 0.28);
  background: rgba(134, 239, 172, 0.12);
}

.status-pill--warn {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.12);
  cursor: pointer;
}

.environment-hero {
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.95fr);
  gap: 16px;
}

.hero-subtitle {
  margin: 8px 0 0;
  font-weight: 600;
}

.hero-copy__body {
  margin: 12px 0 0;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 14px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.08rem;
}

.flow-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.92fr);
  gap: 16px;
}

.flow-primary,
.flow-secondary {
  display: grid;
  gap: 16px;
}

.surface-card {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.connection-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.connection-card__top,
.thread-card__top,
.watch-row,
.alignment-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.connection-card strong,
.thread-card strong,
.path-step strong {
  display: block;
  margin-top: 4px;
}

.connection-role,
.connection-note,
.thread-card p,
.thread-detail p,
.watch-row p,
.alignment-row p {
  margin: 0;
  color: var(--text-dim);
  line-height: 1.55;
}

.connection-status--live,
.connection-status--native,
.connection-status--mapped {
  color: var(--accent-2);
  border-color: rgba(134, 239, 172, 0.28);
  background: rgba(134, 239, 172, 0.12);
}

.connection-status--partial,
.connection-status--offline {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.12);
}

.flow-path {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.path-step {
  padding: 14px;
  position: relative;
}

.path-step::after {
  content: "→";
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  font-family: var(--font-mono);
}

.path-step:last-child::after {
  display: none;
}

.path-step span {
  color: var(--text-dim);
  font-size: 0.86rem;
}

.thread-list,
.pressure-grid,
.watch-list,
.alignment-list,
.meta-list {
  display: grid;
  gap: 12px;
}

.thread-card {
  width: 100%;
  padding: 14px;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.thread-card.is-active {
  border-color: var(--border-strong);
  background: rgba(125, 211, 252, 0.12);
}

.thread-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.pressure-badge--flowing,
.pressure-card--flowing {
  color: var(--teal);
  border-color: rgba(45, 212, 191, 0.28);
  background: rgba(45, 212, 191, 0.12);
}

.pressure-badge--building,
.pressure-card--building {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.12);
}

.pressure-badge--blocked,
.pressure-card--blocked {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.12);
}

.pressure-badge--venting,
.pressure-card--venting {
  color: var(--blue);
  border-color: rgba(96, 165, 250, 0.28);
  background: rgba(96, 165, 250, 0.12);
}

.pressure-badge--archived-active,
.pressure-card--archived-active {
  color: var(--purple);
  border-color: rgba(192, 132, 252, 0.28);
  background: rgba(192, 132, 252, 0.12);
}

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

.pressure-card {
  padding: 14px;
}

.pressure-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.32rem;
}

.thread-detail {
  display: grid;
  gap: 16px;
}

.detail-block {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.detail-key {
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-value {
  margin: 0;
  font-weight: 600;
}

.dependency-list,
.reset-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.dependency-list li,
.reset-list li {
  color: var(--text-dim);
  line-height: 1.55;
}

.watch-row,
.alignment-row {
  padding: 14px;
}

.watch-meta,
.alignment-meta {
  display: grid;
  gap: 6px;
}

.watch-date {
  color: var(--text-soft);
  font-size: 0.84rem;
}

.tag-badge {
  min-height: 28px;
  font-size: 0.7rem;
}

.tag-badge--gov {
  color: var(--accent);
  border-color: rgba(125, 211, 252, 0.28);
  background: rgba(125, 211, 252, 0.12);
}

.tag-badge--pl {
  color: var(--purple);
  border-color: rgba(192, 132, 252, 0.28);
  background: rgba(192, 132, 252, 0.12);
}

.status-bar {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface-strong) 100%);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.status-bar__copy,
.status-bar__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-text {
  color: var(--text-dim);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 20, 0.66);
}

.drawer__panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100% - 32px));
  padding: 18px;
  overflow: auto;
}

.drawer__header,
.drawer__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer__summary {
  margin: 16px 0 18px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  flex-direction: column;
}

.drawer__section + .drawer__section {
  margin-top: 18px;
}

.touchpoint-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--text-dim);
}

.icon-button {
  cursor: pointer;
}

body.drawer-open {
  overflow: hidden;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

@media (max-width: 1220px) {
  .flow-shell,
  .flow-workspace,
  .environment-hero {
    grid-template-columns: 1fr;
  }

  .flow-sidebar {
    order: 2;
  }

  .flow-stage {
    order: 1;
  }
}

@media (max-width: 840px) {
  .flow-shell {
    width: min(100%, calc(100% - 16px));
    margin: 8px auto;
  }

  .flow-topbar,
  .environment-hero,
  .surface-card,
  .flow-sidebar,
  .drawer__panel {
    padding: 16px;
  }

  .connections-grid,
  .focus-strip__cards,
  .focus-strip__actions,
  .hero-metrics,
  .pressure-grid,
  .flow-path {
    grid-template-columns: 1fr;
  }

  .path-step::after {
    content: "↓";
    right: 50%;
    top: auto;
    bottom: -16px;
    transform: translateX(50%);
  }

  .path-step:last-child::after {
    display: none;
  }

  .flow-topbar,
  .status-bar {
    align-items: flex-start;
  }
}
