:root {
  --bg: #05070b;
  --panel: rgba(12, 18, 28, 0.78);
  --panel-strong: rgba(18, 27, 40, 0.92);
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f7fb;
  --muted: #aeb8c8;
  --dim: #738095;
  --cyan: #54d6ff;
  --green: #67e8a5;
  --amber: #f8c76a;
  --red: #ff6f8e;
  --violet: #b68cff;
  --blue: #6ca8ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(8, 12, 18, 0.4), rgba(5, 7, 11, 1) 44rem),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 96px),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 96px),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: 0.9rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(5, 7, 11, 0.74);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(84, 214, 255, 0.24), rgba(248, 199, 106, 0.18));
  box-shadow: inset 0 0 16px rgba(84, 214, 255, 0.16);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  border-color: var(--line);
  color: var(--text);
  outline: none;
  background: rgba(255, 255, 255, 0.05);
}

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  align-items: end;
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: 9rem clamp(1rem, 5vw, 5rem) 4rem;
  overflow: hidden;
}

#story-canvas,
.hero-shade {
  position: absolute;
  inset: 0;
}

#story-canvas {
  width: 100%;
  height: 100%;
}

.hero-shade {
  background:
    linear-gradient(90deg, rgba(5, 7, 11, 0.96) 0%, rgba(5, 7, 11, 0.72) 36%, rgba(5, 7, 11, 0.3) 100%),
    linear-gradient(180deg, rgba(5, 7, 11, 0.05), rgba(5, 7, 11, 0.92) 92%);
}

.hero-copy,
.hero-console {
  position: relative;
  z-index: 1;
}

.hero-copy {
  max-width: 850px;
  padding-bottom: 2rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 1rem;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 840px;
  margin-bottom: 1.25rem;
  font-size: clamp(3.1rem, 8vw, 7.6rem);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: 0;
}

.hero-lead {
  max-width: 760px;
  margin-bottom: 1.8rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.btn.primary {
  border-color: rgba(84, 214, 255, 0.42);
  background: linear-gradient(135deg, rgba(84, 214, 255, 0.96), rgba(103, 232, 165, 0.86));
  color: #031016;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.hero-console {
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 12, 19, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.console-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.live-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px rgba(103, 232, 165, 0.9);
}

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

.metric-grid > div {
  min-height: 8.5rem;
  padding: 1.15rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-grid > div:nth-child(2n) {
  border-right: none;
}

.metric-grid > div:nth-last-child(-n + 2) {
  border-bottom: none;
}

.metric-grid strong {
  display: block;
  color: var(--text);
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
}

.metric-grid span {
  display: block;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.run-log {
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.run-log p {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.75rem;
  margin: 0;
  padding: 0.45rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.run-log span {
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.overview,
.section,
.footer {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: -2.5rem;
  position: relative;
  z-index: 3;
  border: 1px solid var(--line);
  background: var(--line);
  box-shadow: var(--shadow);
}

.stat-tile {
  min-height: 12rem;
  padding: 1.25rem;
  background: rgba(10, 15, 23, 0.94);
}

.stat-tile span {
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 800;
}

.stat-tile strong {
  display: block;
  margin: 0.65rem 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.stat-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.stat-tile.accent-amber span {
  color: var(--amber);
}

.stat-tile.accent-green span {
  color: var(--green);
}

.stat-tile.accent-red span {
  color: var(--red);
}

.section {
  padding: clamp(4rem, 8vw, 7rem) 0 0;
}

.section-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.55fr);
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.6rem;
}

.section-title-row h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.section-title-row p {
  margin-bottom: 0.3rem;
  color: var(--muted);
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--line);
  gap: 1px;
}

.pipe-step {
  min-height: 18rem;
  padding: 1.1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015)),
    rgba(9, 14, 21, 0.96);
}

.pipe-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 1.2rem;
  border: 1px solid rgba(84, 214, 255, 0.4);
  border-radius: 8px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
}

.pipe-step h3,
.mind-panel h3 {
  margin-bottom: 0.7rem;
  font-size: 1.18rem;
}

.pipe-step p,
.mind-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.mind-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.mind-panel {
  min-height: 13rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 17, 26, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mind-panel.large {
  grid-row: span 2;
  min-height: 27rem;
  background:
    linear-gradient(135deg, rgba(84, 214, 255, 0.13), rgba(248, 199, 106, 0.08)),
    rgba(11, 17, 26, 0.9);
}

.signal-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.55rem;
  align-items: end;
  height: 12rem;
  margin-top: 2rem;
}

.signal-bars span {
  height: var(--h);
  border: 1px solid rgba(84, 214, 255, 0.25);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, rgba(103, 232, 165, 0.86), rgba(84, 214, 255, 0.18));
}

.story-showcase {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.story-feature {
  min-height: 21rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(84, 214, 255, 0.1), rgba(255, 255, 255, 0.02) 46%, rgba(248, 199, 106, 0.08)),
    rgba(11, 17, 26, 0.9);
}

.story-meta span {
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 900;
}

.story-meta strong {
  display: block;
  margin-top: 0.7rem;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 1.12;
}

.story-hook {
  color: var(--text);
  font-size: 1.05rem;
}

.story-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.story-stats span {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.constellation-wrap {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.92);
  overflow: hidden;
}

.constellation-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.constellation-head h3,
.constellation-head p {
  margin: 0;
}

.constellation-head p {
  max-width: 620px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.node-map {
  position: relative;
  height: 36rem;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 80px);
}

.story-node {
  position: absolute;
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, var(--node-color), white 15%);
  border-radius: 50%;
  background: var(--node-color);
  box-shadow: 0 0 calc(var(--size) * 1.8) color-mix(in srgb, var(--node-color), transparent 30%);
  cursor: pointer;
}

.story-node::after {
  content: attr(data-title);
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  width: max-content;
  max-width: 12rem;
  transform: translateY(-50%);
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 7, 11, 0.92);
  color: var(--text);
  font-size: 0.76rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.story-node:hover,
.story-node:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  z-index: 4;
}

.story-node:hover::after,
.story-node:focus-visible::after {
  opacity: 1;
}

.matrix-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.42fr) minmax(0, 1fr);
  gap: 1rem;
}

.score-dial {
  position: relative;
  min-height: 24rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 15, 23, 0.94);
}

.score-dial svg {
  width: min(76%, 18rem);
}

.dial-bg,
.dial-fg {
  fill: none;
  stroke-width: 14;
}

.dial-bg {
  stroke: rgba(255, 255, 255, 0.08);
}

.dial-fg {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 329 440;
  transform: rotate(-90deg);
  transform-origin: 90px 90px;
  filter: drop-shadow(0 0 12px rgba(103, 232, 165, 0.48));
}

.score-dial div {
  position: absolute;
  text-align: center;
}

.score-dial strong {
  display: block;
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  line-height: 1;
}

.score-dial span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ranking {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(10, 15, 23, 0.94);
}

.rank-row {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 4.5rem 4.5rem 4.5rem;
  min-height: 3.75rem;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
}

.rank-row:last-child {
  border-bottom: none;
}

.rank-row.header {
  min-height: 3rem;
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.rank-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row em {
  color: var(--green);
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 4rem 0 2rem;
  color: var(--dim);
  font-size: 0.92rem;
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--cyan);
  text-decoration: none;
}

@media (max-width: 1050px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .hero-copy {
    padding-bottom: 0;
  }

  .hero-console {
    align-self: stretch;
  }

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

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

  .mind-grid,
  .story-showcase,
  .matrix-layout,
  .section-title-row {
    grid-template-columns: 1fr;
  }

  .mind-panel.large {
    grid-row: auto;
  }

  .constellation-head {
    align-items: start;
    flex-direction: column;
  }

  .constellation-head p {
    text-align: left;
  }
}

@media (max-width: 720px) {
  .topbar {
    position: absolute;
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .hero {
    min-height: auto;
    padding-top: 10.5rem;
  }

  .metric-grid,
  .overview,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .metric-grid > div,
  .metric-grid > div:nth-child(2n),
  .metric-grid > div:nth-last-child(-n + 2) {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .metric-grid > div:last-child {
    border-bottom: none;
  }

  .node-map {
    height: 28rem;
  }

  .rank-row {
    grid-template-columns: 3rem minmax(0, 1fr) 3.2rem;
  }

  .rank-row span:nth-child(4),
  .rank-row span:nth-child(5),
  .rank-row em:nth-child(4),
  .rank-row em:nth-child(5) {
    display: none;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ==========================================
   Live Scheduler Console & Monitor Styles
   ========================================== */
.live-writing-monitor {
  background: rgba(0, 0, 0, 0.35);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 110px;
}

.monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.agent-tag {
  font-size: 0.65rem;
  font-weight: 900;
  color: var(--cyan);
  background: rgba(84, 214, 255, 0.12);
  border: 1px solid rgba(84, 214, 255, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.active-agent-name {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 700;
  font-family: ui-sans-serif, system-ui;
}

.monitor-text-container {
  flex: 1;
  position: relative;
  display: inline-block;
  min-height: 52px;
}

.monitor-text {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: rgba(245, 247, 251, 0.9);
  line-height: 1.5;
  display: inline;
}

.monitor-cursor {
  display: inline-block;
  width: 6px;
  height: 13px;
  background-color: var(--cyan);
  vertical-align: middle;
  margin-left: 2px;
  animation: cursor-blink-terminal 0.8s infinite;
}

@keyframes cursor-blink-terminal {
  50% { opacity: 0; }
}

/* Logging layout adjustments */
.run-log {
  max-height: 125px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.run-log p {
  animation: log-fade-in 0.35s ease forwards;
}

@keyframes log-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dynamic counter metrics flash */
.metric-flash {
  animation: counter-glow 1.2s ease;
}

@keyframes counter-glow {
  0% {
    color: var(--cyan);
    text-shadow: 0 0 16px rgba(84, 214, 255, 0.8);
    transform: scale(1.05);
  }
  100% {
    color: var(--text);
    text-shadow: none;
    transform: scale(1);
  }
}

/* Active Constellation Star Node Pulse */
.story-node.active-pulse {
  outline: 2px solid #ffffff;
  z-index: 10 !important;
  animation: star-pulse 2s infinite;
}

@keyframes star-pulse {
  0% {
    box-shadow: 0 0 0px 0px color-mix(in srgb, var(--node-color), transparent 10%);
  }
  70% {
    box-shadow: 0 0 0px 16px color-mix(in srgb, var(--node-color), transparent 100%);
  }
  100% {
    box-shadow: 0 0 0px 0px color-mix(in srgb, var(--node-color), transparent 100%);
  }
}

/* Background Constellation Drawing Canvas */
#constellation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.story-node {
  z-index: 2;
}
