:root {
  color-scheme: light;
  --bg-surface: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-panel-subtle: #eef1f4;
  --stroke: #d0d5dd;
  --text-primary: #1d2939;
  --text-secondary: #475467;
  --accent: #1f6dbb;
  --accent-soft: #e1ecfa;
  --accent-strong: #114b84;
  --success: #12a36e;
  --danger: #d92d20;
  --border-radius: 10px;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --chip-country: #e7f2ef;
  --chip-disease: #f8ece8;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  opacity: 0;
  transform: translateY(16px);
  animation: fade-in-up 0.5s ease forwards;
  animation-delay: var(--fade-delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in-up {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-surface);
  color: var(--text-primary);
}

#app {
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.top-bar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 400;
  font-size: 18px;
  color: var(--text-primary);
  text-decoration: none;
}

.top-bar .brand:hover {
  color: var(--accent-strong);
}

.brand-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.main-nav {
  display: flex;
  gap: 12px;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(208, 213, 221, 0.8);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-toggle:hover {
  background: var(--bg-panel-subtle);
    border-color: rgba(31, 109, 187, 0.3);
}

.nav-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0;
  background: var(--text-primary);
  border-radius: 999px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.main-nav a .external-icon {
  width: 14px;
  height: 14px;
  margin-left: 6px;
  opacity: 0.85;
  vertical-align: -2px;
}

.main-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(31, 109, 187, 0.24);
}

.main-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(31, 109, 187, 0.32);
  font-weight: 600;
}

@media (max-width: 640px) {
  .page {
    padding: 24px 18px 40px;
  }

  .top-bar {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    /* Anchor the mobile dropdown menu */
    position: relative;
  }

  .top-bar .brand {
    flex: 1;
    justify-content: center;
    text-align: center;
    font-size: 16px;
  }

  .brand-logo {
    width: 24px;
    height: 24px;
  }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    align-items: center;
    margin-left: auto;
    width: 44px;
    height: 36px;
    border: none;
    background: transparent;
  }

  .nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-of-type(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-of-type(2) {
    opacity: 0;
  }

  .nav-toggle[aria-expanded='true'] .nav-toggle__bar:nth-of-type(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Mobile dropdown menu: compact panel with subtle background */
  .main-nav {
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(130%) blur(6px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(208, 213, 221, 0.6);
    border-radius: 10px;
    z-index: 30;
    display: none;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .main-nav--open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
  }

  .main-nav a {
    display: block;
    text-align: right;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
  }

  .main-nav a {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .main-nav--open a {
    opacity: 1;
    transform: translateY(0);
  }

  .chat-hero {
    padding: 48px 12px 72px;
  }

  .chat-inline-input {
    width: 100%;
    padding: 32px 12px 18px;
    align-items: stretch;
    justify-content: flex-start;
  }

  .chat-inline-input__field,
  .chat-inline-highlight {
    text-align: left;
  }

  /*
    Ensure the editable layer and the underline overlay share
    identical padding on small screens. Adding horizontal padding
    here caused a 12px mismatch with `.chat-inline-highlight`,
    which led to visible misalignment between text and underlines.
    We rely on the container's horizontal padding instead.
  */
  .chat-inline-input__field {
    padding: 0;
    box-sizing: border-box;
  }

  .chat-inline-highlight {
    padding: 32px 12px 18px;
    box-sizing: border-box;
  }

  .chat-cue,
  .chat-cue--visible {
    display: none !important;
  }
}

.page-chat {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  padding: 72px 24px 96px;
}

.chat-hero-copy h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 600;
}

.chat-inline-input {
  width: min(780px, 92vw);
  border-bottom: 1px solid rgba(208, 213, 221, 0.5);
  padding: 44px 0 28px;
  display: flex;
  justify-content: center;
  position: relative;
}

.chat-inline-input__field {
  outline: none;
  border: none;
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  min-height: 48px;
  line-height: 1.4;
  width: 100%;
  text-align: left;
  caret-color: var(--accent-strong);
  white-space: pre-wrap;
  position: relative;
  z-index: 2;
}

.chat-inline-input__field:empty::before {
  content: attr(data-placeholder);
  color: var(--text-secondary);
  opacity: 0.45;
}

.chat-inline-highlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 44px 0 28px;
  box-sizing: border-box;
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: pre-wrap;
  color: transparent;
  font-family: inherit;
  z-index: 1;
}

.chat-inline-highlight mark {
  color: transparent;
  background: none;
  text-decoration: underline;
  text-decoration-color: rgba(31, 109, 187, 0.5);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.2em;
}

.chat-cue {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.chat-cue--visible {
  opacity: 1;
  transform: translateY(0);
}

.chat-cue kbd {
  background: var(--bg-panel);
  border: 1px solid rgba(208, 213, 221, 0.7);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-secondary);
}

.chat-toast {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translate(-50%, -12px);
  background: rgba(29, 41, 57, 0.94);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
}

.chat-toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.chat-toast--error {
  background: var(--danger);
}

.chat-toast--saved {
  background: var(--accent-strong);
}

.chat-hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.chat-hero-actions .chat-overview-button {
  border-radius: 999px;
}

.chat-templates {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0 0;
}

.chat-template-pill--surprise {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(31, 109, 187, 0.32);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent-strong);
}

.chat-template-pill--surprise:hover {
  background: #d6e6fb;
}

.chat-overview-button {
  border: 1px solid rgba(31, 109, 187, 0.2);
  background: rgba(31, 109, 187, 0.08);
  color: var(--accent-strong);
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.1s ease;
}

.chat-overview-button:hover {
  border-color: rgba(31, 109, 187, 0.4);
  background: rgba(31, 109, 187, 0.16);
  transform: translateY(-1px);
}

.chat-template-pill {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(208, 213, 221, 0.8);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.chat-template-pill:hover {
  background: var(--bg-panel-subtle);
  color: var(--text-primary);
  border-color: rgba(208, 213, 221, 1);
}

@media (min-width: 641px) {
  .chat-inline-input {
    padding: 44px 0 28px;
  }

  .chat-inline-input__field,
  .chat-inline-highlight {
    text-align: center;
  }

  .chat-inline-input__field {
    padding: 0;
  }

  .chat-inline-highlight {
    padding: 44px 0 28px;
  }
}

button.primary,
.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(17, 75, 132, 0.25);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(17, 75, 132, 0.3);
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(208, 213, 221, 0.8);
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.ghost:hover {
  background: var(--bg-panel-subtle);
  color: var(--text-primary);
}

/* Overview page */
.page-overview .overview-summary {
  background: var(--bg-panel);
  border-radius: var(--border-radius);
  padding: 24px 28px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(208, 213, 221, 0.7);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.overview-summary h2 {
  margin: 0 0 8px;
}

.summary-subtitle {
  margin: 0 0 16px;
  color: var(--text-secondary);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 24px;
}

.summary-label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
}

.summary-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}

.summary-cta {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: flex-end;
  margin-left: auto;
  align-self: flex-end;
}

@media (max-width: 640px) {
  .summary-cta {
    width: 100%;
    justify-content: stretch;
    align-items: stretch;
    display: none;
  }
}

.overview-mobile-actions {
  display: none;
  gap: 10px;
  margin: 16px auto 12px;
  width: min(360px, 92vw);
}

.overview-mobile-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 600;
}

@media (max-width: 960px) {
  .overview-mobile-actions {
    display: flex;
    flex-direction: column;
  }
}

.overview-canvas {
  margin-top: 28px;
  background: var(--bg-panel);
  border-radius: var(--border-radius);
  position: relative;
  padding: 40px 12px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(208, 213, 221, 0.6);
  min-height: 520px;
}

.graph-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 18px;
  position: relative;
  z-index: 2;
}

.graph-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.column-label {
  text-transform: uppercase;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  padding: 0 12px;
}

.column-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.graph-node {
  background: var(--bg-panel);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(208, 213, 221, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.graph-node h3 {
  margin: 0;
  font-size: 16px;
}

.node-meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.node-link {
  align-self: flex-start;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  padding: 6px 10px;
  background: var(--bg-panel-subtle);
  border: 1px solid rgba(208, 213, 221, 0.8);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.node-link:hover {
  background: var(--bg-panel);
  border-color: rgba(208, 213, 221, 1);
  color: var(--text-primary);
}

.graph-placeholder {
  background: var(--bg-panel-subtle);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.graph-connections {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.graph-connector {
  fill: none;
  stroke: rgba(31, 109, 187, 0.3);
  stroke-width: 2;
}

/* Run page */
.page-run .run-hero {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 96px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
}

.page-run .run-hero.run-hero--completed {
  gap: 12px;
}

.page-run .run-trigger {
  font-size: clamp(18px, 3vw, 22px);
  padding: 16px 34px;
}

.page-run .run-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-run .run-trigger .button-icon {
  width: 18px;
  height: 18px;
}

.run-trigger--hidden {
  display: none;
}


.run-title--completed {
  animation: run-title-fade 0.7s ease forwards;
}

@keyframes run-title-fade {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.run-follow-up {
  width: 100%;
  max-width: 720px;
  margin: 20px auto 0;
  padding: 0 24px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.run-follow-up--animate {
  animation: run-title-fade 0.7s ease forwards;
}

.run-follow-up h3 {
  margin: 0;
  font-size: 28px;
  color: var(--text-primary);
}

.run-follow-up p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 18px;
}

.run-follow-up ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 18px;
}

.run-follow-up li {
  margin: 0 0 6px 0;
}

.run-follow-up a {
  color: var(--accent-strong);
  text-decoration: underline;
}

.run-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 16px;
  color: var(--text-secondary);
}

.run-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-panel-subtle);
  border: 1px solid rgba(208, 213, 221, 0.8);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.run-copy:hover {
  background: var(--bg-panel);
  border-color: rgba(208, 213, 221, 1);
  color: var(--text-primary);
}

.run-copy img {
  width: 16px;
  height: 16px;
}

.run-copy--success {
  background: rgba(17, 107, 187, 0.12);
  border-color: rgba(17, 107, 187, 0.4);
  color: var(--accent-strong);
}

@media (max-width: 640px) {
  .run-follow-up {
    margin: 16px auto 0;
    padding: 0 18px;
    text-align: center;
    align-items: center;
    gap: 18px;
  }

  .run-follow-up h3 {
    font-size: 24px;
  }

  .run-follow-up p {
    font-size: 15px;
    line-height: 1.55;
  }

  .run-follow-up ul {
    font-size: 15px;
    line-height: 1.55;
    padding-left: 18px;
    text-align: left;
  }

  .run-follow-up li {
    margin: 0 0 6px 0;
  }

  .run-contact {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .run-copy {
    align-self: flex-start;
  }
}

.run-follow-up--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.page-run .run-hero h2 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 600;
}

.run-animation {
  width: 220px;
  height: 140px;
  position: relative;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.run-animation .orbit {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.run-animation .orbit span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(31, 109, 187, 0.2);
  transform: scale(0.6);
  transition: background 0.2s ease;
}

.run-animation .pulse {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(31, 109, 187, 0.14);
  top: calc(50% - 60px);
  left: calc(50% - 60px);
  scale: 0;
  opacity: 0;
}

.run-animation.active .pulse {
  animation: pulse 1.2s ease-in-out infinite;
}

.run-animation.is-visible {
  opacity: 1;
}

.run-animation.active .orbit span:nth-child(1) {
  animation: orbit 1.2s ease-in-out infinite;
}

.run-animation.active .orbit span:nth-child(2) {
  animation: orbit 1.2s ease-in-out infinite 0.2s;
}

.run-animation.active .orbit span:nth-child(3) {
  animation: orbit 1.2s ease-in-out infinite 0.4s;
}

@keyframes orbit {
  0% {
    transform: translateY(0) scale(0.7);
    background: rgba(31, 109, 187, 0.2);
  }
  50% {
    transform: translateY(-18px) scale(1);
    background: rgba(31, 109, 187, 0.45);
  }
  100% {
    transform: translateY(0) scale(0.7);
    background: rgba(31, 109, 187, 0.2);
  }
}

@keyframes pulse {
  0% {
    scale: 0;
    opacity: 0.6;
  }
  70% {
    scale: 1;
    opacity: 0;
  }
  100% {
    scale: 1;
    opacity: 0;
  }
}

/* Editor page */
.editor-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 0 0 16px;
  gap: 12px;
}

.editor-toolbar .editor-run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 600;
}

.editor-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
}

.editor-sidebar-toggle {
  display: none;
}

.editor-sidebar {
  background: var(--bg-panel);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(208, 213, 221, 0.7);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 32px;
  height: fit-content;
}

.editor-sidebar h2 {
  margin: 0;
}

.editor-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-nav-divider {
  height: 1px;
  background: rgba(15, 23, 42, 0.08);
  margin: 8px 0;
}

.editor-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
  font-size: 14px;
}

.editor-nav a:hover,
.editor-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.editor-main {
  background: var(--bg-panel);
  border-radius: var(--border-radius);
  padding: 32px;
  box-shadow: 0 2px 18px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(208, 213, 221, 0.6);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.editor-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.node-badge {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-panel-subtle);
  color: var(--text-secondary);
}

.badge-demographic {
  background: rgba(31, 109, 187, 0.16);
  color: var(--accent-strong);
}

.badge-risk {
  background: rgba(216, 91, 91, 0.12);
  color: #d85b5b;
}

.badge-program {
  background: rgba(31, 109, 187, 0.12);
  color: var(--accent-strong);
}

.badge-epidemiology {
  background: rgba(43, 163, 122, 0.14);
  color: var(--success);
}

.badge-intervention {
  background: rgba(178, 112, 255, 0.16);
  color: #8357d8;
}

.editor-node-summary {
  margin: 0 0 16px;
  color: var(--text-secondary);
}

.parameter-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.parameter-table th,
.parameter-table td {
  border-bottom: 1px solid rgba(208, 213, 221, 0.7);
  padding: 12px;
  text-align: left;
}

.parameter-table tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 640px) {
  .parameter-table th:nth-child(3),
  .parameter-table td:nth-child(3) {
    display: none;
  }
}

.editable {
  display: inline-block;
  min-width: 120px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-panel-subtle);
  outline: none;
  transition: background 0.2s ease, border 0.2s ease;
  border: 1px solid transparent;
}

.editable:focus {
  background: #d9e7f9;
  border-color: rgba(31, 109, 187, 0.4);
}

@media (max-width: 960px) {
  .page {
    padding: 24px 20px 48px;
  }

  .chat-hero {
    padding: 56px 16px 72px;
    gap: 16px;
  }

  .chat-inline-input {
    width: 100%;
    padding: 28px 0 18px;
  }

  .chat-inline-input__field {
    font-size: clamp(20px, 6vw, 32px);
  }

  /* Keep overlay perfectly in sync with the editable field */
  .chat-inline-highlight {
    padding: 28px 0 18px;
    font-size: clamp(20px, 6vw, 32px);
  }

  .overview-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-cta {
    justify-content: flex-end;
  }

  .graph-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

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

  .editor-sidebar {
    position: static;
  }

  .editor-main {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .main-nav {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .overview-canvas {
    padding: 28px 8px;
  }

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

  .chat-toast {
    top: 84px;
  }
}

@media (max-width: 960px) {
  .editor-toolbar {
    display: none;
  }

  .editor-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, 92vw);
    margin: 16px auto 12px;
  }

  .editor-mobile-actions .editor-mobile-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
  }

  .editor-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid rgba(208, 213, 221, 0.8);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    margin: 0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    width: 100%;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  }

  .editor-sidebar-toggle:hover {
    background: var(--bg-panel-subtle);
    border-color: rgba(31, 109, 187, 0.3);
  }

  .editor-sidebar {
    display: none;
    margin-bottom: 8px;
  }

  .editor-sidebar.editor-sidebar--open {
    display: block;
  }

  .editor-back-to-top {
    display: inline-flex;
  }
}

@media (min-width: 961px) {
  .editor-mobile-actions {
    display: none;
  }
}

.editor-back-to-top {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1px solid rgba(31, 109, 187, 0.28);
  background: rgba(31, 109, 187, 0.92);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(17, 75, 132, 0.28);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  pointer-events: none;
}

.editor-back-to-top--visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

@media (min-width: 961px) {
  .editor-back-to-top {
    display: none;
  }
}
