@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  color-scheme: light;
  --page: #f5f7f6;
  --surface: #ffffff;
  --ink: #202b29;
  --muted: #64736d;
  --line: #dce4df;
  --accent: #126a52;
  --accent-soft: #e4f2eb;
  --dot: #d9e2dd;
  --error: #b13d32;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  background: var(--page);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #141918;
  --surface: #1c2321;
  --ink: #e7efeb;
  --muted: #a4b4ac;
  --line: #37433d;
  --accent: #88d9b4;
  --accent-soft: #273f34;
  --dot: #303c35;
  --error: #ffa49a;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input { font: inherit; }
button, a, summary, input { -webkit-tap-highlight-color: transparent; }
button, a, summary { touch-action: manipulation; }
button { cursor: pointer; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
button:hover:not(:disabled) { background: var(--accent-soft); }
button:disabled { cursor: default; opacity: .4; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
.header, main, footer { width: min(1440px, calc(100% - 80px)); margin-inline: auto; }
.header { display: flex; align-items: center; justify-content: space-between; padding-block: 30px; gap: 20px; }
.header-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.get-started { padding: 9px 14px; color: var(--accent); background: var(--accent-soft); font-size: 13px; white-space: nowrap; }
.brand { position: relative; display: flex; align-items: center; gap: 15px; }
.brand-trigger { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; color: transparent; background: transparent; }
.brand-trigger:hover:not(:disabled) { background: transparent; }
.brand-mark { font: 500 26px 'IBM Plex Mono', monospace; color: var(--accent); border-left: 3px solid #df795d; padding-left: 12px; }
h1 { margin: 0; font-size: 25px; font-weight: 700; }
.brand-highlight { color: var(--accent); }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.theme-switch { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.theme-switch input { appearance: none; width: 32px; height: 19px; margin: 0; border-radius: 20px; border: 1px solid var(--muted); background: var(--line); position: relative; cursor: pointer; flex: none; }
.theme-switch input::after { content: ''; position: absolute; width: 11px; height: 11px; border-radius: 50%; left: 3px; top: 3px; background: var(--muted); transition: transform .18s ease; }
.theme-switch input:checked { background: var(--accent-soft); border-color: var(--accent); }
.theme-switch input:checked::after { background: var(--accent); transform: translateX(13px); }
.viewer-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.viewer-content { min-width: 0; }
.sidebar { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.sidebar > details > summary { font-size: 13px; font-weight: 600; padding: 14px 8px; }
#navigation-status { padding: 0 8px; color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.workflow-tree, .workflow-tree ul { list-style: none; margin: 0; padding: 0; }
.workflow-tree ul { margin-left: 16px; padding-left: 10px; border-left: 1px solid var(--line); }
.workflow-tree li { margin-block: 4px; min-width: 0; }
.workflow-tree a { display: block; padding: 9px 10px; border-radius: 4px; color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.workflow-tree a:hover { background: var(--accent-soft); text-decoration: none; }
.workflow-tree a[aria-current='page'] { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 2px 0 var(--accent); }
.workflow-tree summary { display: flex; align-items: center; padding: 0; list-style: none; }
.workflow-tree summary::-webkit-details-marker { display: none; }
.workflow-tree summary::before { content: '\25B8'; width: 18px; flex: none; color: var(--muted); font-size: 14px; }
.workflow-tree details[open] > summary::before { content: '\25BE'; }
.workflow-tree summary a { flex: 1; min-width: 0; }
.workspace { border-block: 1px solid var(--line); background: var(--surface); }
.toolbar { min-height: 66px; display: flex; align-items: center; justify-content: flex-end; gap: 20px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.file-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; font-size: 13px; }
.file-actions a, .file-actions button { white-space: nowrap; }
.copy-ai { padding: 9px 12px; min-width: 150px; color: var(--accent); background: var(--accent-soft); }
.download { padding: 9px 14px; }
.download span { margin-right: 6px; }
.breadcrumbs { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 24px 0; font-size: 12px; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; min-width: 0; }
.breadcrumbs li { overflow-wrap: anywhere; min-width: 0; }
.breadcrumbs li + li::before { content: '/'; color: var(--muted); margin-right: 8px; }
.breadcrumbs [aria-current] { color: var(--muted); }
.viewer-mode { color: var(--muted); white-space: nowrap; }
.diagram-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 24px; }
h2 { font: 500 13px 'IBM Plex Mono', monospace; overflow-wrap: anywhere; margin: 0; }
h2 span { color: var(--muted); font-weight: 400; }
#status { color: var(--muted); font-size: 12px; flex: none; }
.viewport { height: clamp(460px, 67vh, 880px); position: relative; overflow: hidden; background: radial-gradient(circle, var(--dot) 1px, transparent 1px); background-size: 20px 20px; cursor: grab; touch-action: none; }
.viewport.dragging { cursor: grabbing; }
.diagram { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.diagram svg { display: block; max-width: none !important; }
.diagram .flow-link, .diagram .flow-link .node, .diagram .context-link, .diagram .context-link .node { cursor: pointer; }
.diagram .flow-link .label { text-decoration: underline; text-underline-offset: 3px; }
.diagram .flow-link:hover .node > :first-child, .diagram .flow-link:focus-visible .node > :first-child, .diagram .context-link:hover .node > :first-child, .diagram .context-link:focus-visible .node > :first-child { stroke-width: 3px; }
.zoom-controls { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 3px 14px #0000000c; cursor: default; }
.zoom-controls button { width: 34px; height: 34px; border: 0; font-size: 22px; }
.zoom-controls output { width: 55px; text-align: center; font: 12px 'IBM Plex Mono', monospace; }
.divider { height: 18px; border-left: 1px solid var(--line); margin-inline: 5px; }
.message { position: absolute; inset: 30px 24px auto; max-width: 640px; margin-inline: auto; padding: 18px; border: 1px solid var(--error); border-radius: 5px; background: var(--surface); color: var(--error); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; cursor: default; }
.source-panel { border-bottom: 1px solid var(--line); margin-top: 20px; }
summary { padding: 18px 0; cursor: pointer; font-size: 14px; }
.source-extension { color: var(--muted); font: 11px 'IBM Plex Mono', monospace; margin-left: 12px; }
.source-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); font: 12px 'IBM Plex Mono', monospace; }
#source-name { overflow-wrap: anywhere; min-width: 0; }
.source-toolbar button { padding: 7px 10px; white-space: nowrap; font-size: 12px; }
pre { margin: 0; padding: 22px 16px; background: var(--surface); overflow: auto; max-height: 480px; border-inline: 1px solid var(--line); }
code { font: 12px/1.8 'IBM Plex Mono', monospace; }
.ai-context { color: var(--muted); font-size: 13px; line-height: 1.7; }
.ai-context p { margin: 0 0 12px; }
.ai-context a { display: block; margin-bottom: 12px; overflow-wrap: anywhere; }
.ai-context code { overflow-wrap: anywhere; }
body:has(dialog[open]) { overflow: hidden; }
dialog { width: min(740px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: #00000080; }
.dialog-content { padding: 26px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-header h2 { font: 600 22px 'DM Sans', sans-serif; }
.close-dialog { width: 34px; height: 34px; font-size: 24px; }
.context-eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.node-context-content { color: var(--muted); font-size: 14px; line-height: 1.7; }
.node-context-content h3 { margin: 18px 0 7px; color: var(--ink); font-size: 16px; }
.node-context-content p { margin: 0 0 12px; }
.node-context-content ul { margin: 0 0 14px; padding-left: 22px; }
.node-context-content code { padding: 1px 4px; background: var(--accent-soft); border-radius: 3px; }
.context-subflow { display: inline-flex; gap: 7px; margin-top: 16px; padding: 9px 12px; border-radius: 5px; background: var(--accent-soft); font-size: 13px; font-weight: 600; }
dialog h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 20px 0 10px; }
.reference-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-block: 20px 12px; }
.reference-heading h3 { margin: 0; }
dialog pre { border: 1px solid var(--line); border-radius: 4px; background: var(--page); max-height: 320px; }
#ai-copy-status { color: var(--muted); font-size: 12px; line-height: 1.6; }
#ai-reference { white-space: pre-wrap; overflow-wrap: anywhere; }
#jumpstart-prompt { white-space: pre-wrap; overflow-wrap: anywhere; }
#jumpstart-copy-status { color: var(--muted); font-size: 12px; line-height: 1.6; }
#jumpstart-copy-status:empty { display: none; }
#ai-copy-status:empty { display: none; }
footer { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); padding-block: 25px; font-size: 11px; }
.footer-dot { color: #b55e47; padding-inline: 8px; }
@media (max-width: 800px) {
  .viewer-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .sidebar nav { max-height: 240px; overflow: auto; }
}
@media (max-width: 640px) {
  .header, main, footer { width: calc(100% - 28px); }
  .header { padding-block: 22px; flex-wrap: wrap; }
  .header-actions { gap: 16px; margin-left: auto; }
  .dialog-content { padding: 18px; }
  .brand { gap: 10px; }
  .brand-mark { font-size: 21px; padding-left: 8px; }
  h1 { font-size: 22px; }
  .brand { min-width: 0; }
  .brand h1 { font-size: 20px; }
  .brand p { font-size: 10px; }
  .theme-switch { font-size: 12px; }
  .toolbar { padding: 16px 12px; flex-wrap: wrap; gap: 14px; }
  .file-actions { width: 100%; justify-content: space-between; }
  .breadcrumbs { padding: 14px 12px 0; }
  .diagram-heading { padding: 16px 12px; align-items: flex-start; }
  .viewport { height: 65svh; min-height: 420px; }
  footer { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .theme-switch input::after { transition: none; } }
#welcome-dialog { width: min(560px, calc(100% - 32px)); }
#welcome-dialog p { color: var(--muted); font-size: 14px; line-height: 1.7; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.welcome-actions button { padding: 10px 14px; }

.beta-badge { display: inline-block; vertical-align: middle; padding: 3px 7px; border: 1px solid var(--accent); border-radius: 4px; color: var(--accent); font: 600 11px 'DM Sans', sans-serif; }
.ai-context ol { padding-left: 22px; }
.ai-context li { margin-bottom: 12px; }
.ai-context li a { display: inline; margin: 0; }

.agent-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink); }
.agent-choice select { max-width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); font: inherit; }
