#head h1 a, #head h1 a:visited, #head .site-title a, #head .site-title a:visited { color: #111; }
#head h1 a:hover, #head .site-title a:hover { color: #d00; text-decoration: none; }

.crumb { font-size: 11px; color: #999; margin-bottom: 10px; }
.pagetitle { margin: 0 0 3px; font-size: 20px; letter-spacing: -0.5px; }
.subtitle { margin: 0 0 14px; font-size: 12px; color: #555; }
.subtitle b { color: #000; }

#cols { display: flex; gap: 16px; align-items: flex-start; }
#left { flex: 1 1 46%; min-width: 0; position: sticky; top: 16px; }
#right { flex: 1 1 54%; min-width: 0; }
.boxlabel { font-size: 11px; font-weight: normal; line-height: 1.5; color: #777; text-transform: lowercase; margin: 0 0 4px; }

.runtime { border: 1px solid #ccc; }
.runtime .rt-bar { background: #f4f4f4; border-bottom: 1px solid #ccc; padding: 4px 6px; font-size: 11px; color: #555; display: flex; align-items: center; gap: 6px; }
.runtime .rt-bar .spacer { flex: 1; }
.runtime button, .flat-button {
  font: 11px Verdana, Tahoma, sans-serif;
  border: 1px solid #bbb;
  background: #fff;
  padding: 2px 10px;
  cursor: pointer;
}
.runtime button:hover, .flat-button:hover { background: #eee; color: #d00; }
.runtime textarea { display: block; width: 100%; box-sizing: border-box; border: 0; border-bottom: 1px solid #ccc; padding: 8px; font: 12px/1.6 Consolas, "Courier New", monospace; resize: vertical; min-height: 230px; background: #fff; }
.runtime textarea:focus { outline: 0; background: #fffef5; }
.runtime .rt-out { padding: 8px; min-height: 90px; font: 12px/1.6 Consolas, "Courier New", monospace; color: #444; background: #fafafa; white-space: pre-wrap; overflow-wrap: anywhere; }
.runtime .rt-out .stub { color: #aaa; }

.runtime-stage { border-bottom: 1px solid #ccc; background: #fafafa; position: relative; overflow: hidden; contain: paint; }
.runtime-loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f4f4;
  color: #555;
  font: 11px/1.2 Consolas, "Courier New", monospace;
  letter-spacing: .04em;
}
.vibe-stage .runtime-loader { background: #111; color: #bdbdbd; }
.runtime-loader > span {
  min-width: 94px;
  box-sizing: border-box;
  padding: 5px 8px;
  text-align: center;
  background: #dedede;
  color: #222;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
}
.vibe-stage .runtime-loader > span { background: #222; color: #ddd; border-color: #555 #000 #000 #555; }
.runtime-stage.has-load-error .runtime-loader > span { color: #a00000; }
.loading-row td { height: 30px; color: #888; text-align: center !important; font: 11px Consolas, "Courier New", monospace; }
.circle-stage { min-height: 320px; display: flex; align-items: center; justify-content: center; padding: 12px; box-sizing: border-box; }
.circle-canvas-wrap { width: min(100%, 390px); aspect-ratio: 1; }
.circle-canvas-wrap canvas { width: 100%; height: 100%; display: block; border-radius: 50%; }
.vibe-stage { min-height: 214px; background: #111; display: flex; align-items: center; justify-content: center; }
.template-stage { min-height: 180px; }
.template-stage canvas { display: block; width: 100%; height: auto; }
.vibe-stage canvas { display: block; width: 100%; height: auto; }
.live-readout { min-height: 0 !important; }
.live-readout .running { color: #007000; font-weight: bold; }
.live-readout .error { color: #a00000; font-weight: bold; }
.live-line { display: block; }
.formula-label { color: #888; }

ul.subtabs { list-style: none; margin: 0 0 -1px; padding: 0; white-space: nowrap; overflow-x: auto; }
ul.subtabs li { display: inline-block; margin-right: 2px; }
ul.subtabs a { display: block; padding: 4px 9px; border: 1px solid #ccc; background: #f4f4f4; color: #444; font-size: 12px; }
ul.subtabs a:hover { background: #ececec; color: #d00; text-decoration: none; }
ul.subtabs a.on { background: #fff; border-bottom-color: #fff; color: #000; font-weight: bold; }

.project-sheet-handle { display: none; }

.subpanel { border: 1px solid #ccc; padding: 12px 14px; min-height: 280px; }
.subpanel h2, .subpanel h3 { font-size: 13px; margin: 0 0 6px; }
.subpanel h2.more, .subpanel h3.more { margin-top: 16px; }
.subpanel p { margin: 0 0 8px; }
.subpanel ul:not(.subtabs) { margin: 0 0 8px; padding-left: 18px; color: #333; }
.subpanel li { margin-bottom: 2px; }
.note, .cap { font-size: 11px; color: #888; }
.cap { margin: 6px 0 12px; }

.exbtn { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.exbtn button { font: 11px Verdana, Tahoma, sans-serif; padding: 4px 10px; cursor: pointer; text-align: left; }
.sty-a button { background: #dedede; color: #222; border: 2px solid; border-color: #fff #808080 #808080 #fff; }
.sty-a button:hover { background: #e8e8e8; color: #000; }
.sty-a button.on, .sty-a button:active { background: #cfcfcf; border-color: #808080 #fff #fff #808080; font-weight: bold; }

table.extable { border-collapse: collapse; width: 100%; font-size: 12px; margin-bottom: 10px; table-layout: fixed; }
table.extable th, table.extable td { border: 1px solid #ddd; padding: 4px 7px; text-align: left; vertical-align: middle; }
table.extable th { background: #f4f4f4; font-size: 11px; font-weight: bold; color: #666; }
table.extable th:first-child, table.extable td:first-child { width: 25%; }
table.extable th.source-col, table.extable td.source-cell { width: 13%; text-align: center; white-space: nowrap; }
table.extable th:last-child, table.extable td:last-child { width: 18%; white-space: nowrap; color: #666; font-size: 11px; }
table.extable tr[data-preset] { cursor: pointer; }
table.extable tr[data-preset]:hover td { background: #fafafa; }
table.extable tr.on td { background: #f2f2f2; }
table.extable tr.is-pending td { background: #fffef1; }
table.extable button.preset-name { width: 100%; font: 11px Verdana, Tahoma, sans-serif; padding: 4px 10px; cursor: pointer; text-align: left; }
.sty-a tr.on button.preset-name { background: #cfcfcf; border-color: #808080 #fff #fff #808080; font-weight: bold; }
.prompt-cell { min-width: 0; }
.prompt-summary { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #444; }
.source-link {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  width: 25px;
  height: 23px;
  overflow: hidden;
  background: #dcdcdc;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  font-size: 0;
  line-height: 1;
  vertical-align: middle;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
}
.source-link:hover { background: #e8e8e8; text-decoration: none; }
.source-link:active { border-color: #808080 #fff #fff #808080; }
.source-link::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 9px;
  height: 12px;
  background: #fff;
  border: 1px solid #333;
}
.source-link::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 7px;
  width: 5px;
  height: 1px;
  background: #555;
  box-shadow: 0 3px 0 #555, 0 6px 0 #555;
}

pre { margin: 0 0 10px; border: 1px solid #ddd; background: #fafafa; padding: 8px 10px; font: 12px/1.6 Consolas, "Courier New", monospace; overflow-x: auto; white-space: pre; }
code { font-family: Consolas, "Courier New", monospace; }
table.spec { border-collapse: collapse; font-size: 12px; margin-bottom: 10px; width: 100%; }
table.spec th, table.spec td { border: 1px solid #ddd; padding: 4px 7px; text-align: left; }
table.spec th { background: #f4f4f4; font-weight: bold; }
table.spec td code { color: #a800a8; }

.copy-line { display: flex; align-items: center; gap: 7px; margin: 8px 0 10px; }
.copy-button { font: 11px Verdana, Tahoma, sans-serif; border: 1px solid #bbb; background: #fff; padding: 3px 10px; cursor: pointer; }
.copy-button:hover { background: #eee; color: #d00; }
.prompt-wrap pre { max-height: 390px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

.demo-form label { display: block; margin-bottom: 4px; font-size: 11px; color: #666; }
.demo-form input, .demo-form textarea { display: block; box-sizing: border-box; width: 100%; border: 1px solid #bbb; background: #fff; color: #111; padding: 6px 7px; font: 12px/1.55 Consolas, "Courier New", monospace; margin: 0 0 8px; }
.demo-form input { font-family: Verdana, Tahoma, sans-serif; }
.demo-form textarea { min-height: 225px; resize: vertical; tab-size: 2; }
.demo-form input:focus, .demo-form textarea:focus { outline: 0; background: #fffef5; border-color: #888; }
.demo-guide { margin: 0 0 12px; }
.subpanel .demo-guide h3 { margin-bottom: 3px; }
.subpanel .demo-guide .demo-guide-lead { margin: 0 0 6px; padding: 3px 5px; color: #333; background: #e8e8e8; border: 1px solid; border-color: #808080 #fff #fff #808080; font: 10px/1.4 Consolas, "Courier New", monospace; }
.subpanel .demo-guide .demo-guide-lead::before { content: "FLOW: "; color: #555; font-weight: bold; }
.subpanel .demo-guide ol { counter-reset: demo-step; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; list-style: none; margin: 0 0 6px; padding: 6px; color: #333; background: #c0c0c0; border: 2px solid; border-color: #fff #404040 #404040 #fff; box-shadow: inset 1px 1px #dfdfdf, inset -1px -1px #808080; }
.subpanel .demo-guide li { counter-increment: demo-step; position: relative; min-width: 0; min-height: 66px; box-sizing: border-box; margin: 0; padding: 24px 7px 7px; background: #e7e7e7; border: 1px solid #808080; box-shadow: inset 1px 1px #fff, inset -1px -1px #aaa; font-size: 10px; line-height: 1.35; }
.subpanel .demo-guide li::before { content: "STEP " counter(demo-step, decimal-leading-zero); position: absolute; left: 2px; right: 2px; top: 2px; height: 15px; padding-left: 4px; color: #fff; background: #808080; font: bold 9px/15px Consolas, "Courier New", monospace; }
.subpanel .demo-guide li.is-key { border-color: #404040; }
.subpanel .demo-guide li.is-key::before { content: "STEP " counter(demo-step, decimal-leading-zero) " / LLM"; background: #000080; }
.subpanel .demo-guide li:not(:last-child)::after { content: ">>"; position: absolute; z-index: 1; right: -14px; top: 50%; width: 12px; transform: translateY(-50%); color: #333; background: #c0c0c0; text-align: center; font: bold 9px/1 Consolas, "Courier New", monospace; }
.subpanel .demo-guide b, .subpanel .demo-guide span { display: block; }
.subpanel .demo-guide b { margin-bottom: 2px; color: #111; font-size: 10px; text-transform: uppercase; }
.subpanel .demo-guide span { color: #666; }
.subpanel .demo-guide .note { margin-bottom: 0; font-family: Consolas, "Courier New", monospace; }
.subpanel .demo-guide .note::before { content: "TIP: "; color: #555; font-weight: bold; }
.demo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 10px; }
.demo-actions .state { font: 11px Consolas, "Courier New", monospace; color: #888; }
.demo-actions .state.good { color: #007000; }
.demo-actions .state.bad { color: #a00000; }

.theme-lab-cta { margin-top: 12px !important; }
.theme-lab-cta a {
  display: inline-block;
  padding: 5px 11px;
  background: #dedede;
  color: #111;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
  font-size: 11px;
  font-weight: bold;
  text-decoration: none;
}
.theme-lab-cta a:hover { background: #e8e8e8; color: #000; }
.theme-lab-cta a:active { background: #cfcfcf; border-color: #808080 #fff #fff #808080; }
.theme-lab-intro { border-bottom: 1px solid #bbb; padding-bottom: 12px; margin-bottom: 14px; }
.theme-lab-kicker { margin: 0 0 5px !important; color: #007000; font: bold 10px/1.3 Consolas, "Courier New", monospace; letter-spacing: .1em; }
.theme-lab-intro h2 { max-width: 34em; font-size: 16px; line-height: 1.3; }
.theme-lab-flow { counter-reset: theme-step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; list-style: none; padding: 0 !important; margin: 12px 0 0 !important; }
.theme-lab-flow li { counter-increment: theme-step; position: relative; min-height: 72px; box-sizing: border-box; border: 1px solid #ccc; background: #fafafa; padding: 8px 7px 7px 31px; }
.theme-lab-flow li::before { content: counter(theme-step); position: absolute; left: 8px; top: 8px; width: 15px; height: 15px; border: 1px solid #777; text-align: center; font: bold 10px/15px Consolas, "Courier New", monospace; }
.theme-lab-flow b, .theme-lab-flow span { display: block; }
.theme-lab-flow b { margin-bottom: 3px; font-size: 11px; }
.theme-lab-flow span { color: #666; font-size: 10px; line-height: 1.35; }
.theme-example-section { margin-bottom: 16px; }
.theme-example-section > p { color: #555; font-size: 11px; }
.theme-example-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.theme-example-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid #bbb; background: #fff; padding: 8px; }
.theme-example-card h4 { margin: 0 0 5px; color: #111; font: bold 11px/1.3 Consolas, "Courier New", monospace; }
.theme-example-card p { flex: 1; margin: 0 0 9px; color: #666; font-size: 10px; line-height: 1.4; }
.theme-example-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.theme-example-actions button { box-sizing: border-box; min-width: 0; padding: 3px 6px; font-size: 10px; }
.theme-lab-editor { border-top: 3px double #999; padding-top: 13px; }
.theme-lab-editor label { color: #222; font-weight: bold; }
.theme-lab-editor textarea { min-height: 285px; }
.theme-lab-note { color: #666; font-size: 11px; }

.dialog-backdrop { position: fixed; inset: 0; z-index: 99; background: rgba(255,255,255,0.48); }
.pop {
  position: fixed;
  top: 10vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(760px, calc(100vw - 36px));
  max-height: 80vh;
  background: #fff;
  border: 1px solid #808080;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.18);
  font-size: 12px;
  color: #111;
}
.pop .titlebar { display: flex; align-items: center; gap: 6px; background: #dcdcdc; border-bottom: 1px solid #aaa; padding: 3px 4px 3px 7px; font-size: 11px; font-weight: bold; color: #333; }
.pop .titlebar .spacer { flex: 1; }
.pop .titlebar button { font: bold 11px Verdana, Tahoma, sans-serif; line-height: 1; padding: 2px 6px; cursor: pointer; background: #dedede; color: #222; border: 2px solid; border-color: #fff #808080 #808080 #fff; }
.pop .titlebar button:active { border-color: #808080 #fff #fff #808080; }
.pop .body { padding: 10px 12px; line-height: 1.6; overflow: auto; max-height: calc(80vh - 30px); }
.pop .body pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pop .body textarea { display: block; box-sizing: border-box; width: 100%; min-height: 360px; resize: vertical; border: 1px solid #bbb; background: #fffef5; padding: 8px; font: 12px/1.6 Consolas, "Courier New", monospace; }

@media (max-width: 780px) {
  html { height: 100%; min-height: 100%; overflow: hidden; }
  body[data-project-shell] {
    --mobile-heading-height: 30px;
    --mobile-sheet-top: 50%;
    --mobile-sheet-edit-top: clamp(88px, 12%, 112px);
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto var(--mobile-heading-height) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    overflow-x: clip;
    padding: 8px 10px env(safe-area-inset-bottom, 0px);
    overscroll-behavior: none;
  }
  body[data-project-shell][data-sheet-state="edit"] { --mobile-sheet-top: var(--mobile-sheet-edit-top); }
  body[data-project-shell] > #head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 3px;
    margin-bottom: 6px;
  }
  body[data-project-shell] > #head .site-title { margin: 0; }
  body[data-project-shell] > #head .nav { white-space: nowrap; }
  body[data-project-shell] > .crumb { display: none; }
  body[data-project-shell] > .project-heading {
    position: relative;
    z-index: 30;
    box-sizing: border-box;
    height: var(--mobile-heading-height);
    background: #fff;
  }
  body[data-project-shell] > .project-heading .pagetitle { margin: 0; line-height: var(--mobile-heading-height); }
  body[data-project-shell] > .project-heading .subtitle { display: none; }
  body[data-project-shell] #cols {
    position: relative;
    min-height: 0;
    display: block;
    overflow: hidden;
  }
  body[data-project-shell] #left,
  body[data-project-shell] #right { min-height: 0; }
  body[data-project-shell] #left {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 20;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: var(--mobile-sheet-top);
    margin: 0;
    overflow: hidden;
    background: #fff;
    transition: height 160ms ease-out;
  }
  body[data-project-shell] #left > .boxlabel,
  body[data-project-shell] #left > .cap,
  body[data-project-shell] .runtime .rt-bar {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  body[data-project-shell] #left .runtime {
    position: relative;
    box-sizing: border-box;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }
  body[data-project-shell] .runtime-stage,
  body[data-project-shell] .circle-stage,
  body[data-project-shell] .vibe-stage { min-height: 0; }
  body[data-project-shell] .live-readout {
    max-height: 32%;
    overflow: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body[data-project-shell] .live-readout .runtime-summary,
  body[data-project-shell] .live-readout .runtime-debug { display: none; }
  body[data-project-shell] .runtime .rt-out { padding: 4px 6px; font-size: 11px; line-height: 1.4; }
  body[data-project-shell] .circle-stage {
    container-type: size;
    padding: 6px;
  }
  @supports (width: 1cqh) {
    body[data-project-shell] .circle-canvas-wrap { width: min(100%, 100cqh, 390px); }
  }
  body[data-project-shell] .vibe-stage canvas {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
  }
  body[data-project-shell] #right {
    position: absolute;
    inset: var(--mobile-sheet-top) 0 0;
    z-index: 25;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: 27px auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
    background: #fff;
    transition: top 160ms ease-out;
  }
  body[data-project-shell].is-sheet-dragging #left,
  body[data-project-shell].is-sheet-dragging #right {
    transition: none;
  }
  body[data-project-shell] .project-sheet-handle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    height: 27px;
    padding: 0;
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
    background: #dedede;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    color: #333;
    appearance: none;
  }
  body[data-project-shell] .project-sheet-handle:hover { background: #e8e8e8; }
  body[data-project-shell] .project-sheet-handle:active,
  body[data-project-shell].is-sheet-dragging .project-sheet-handle {
    background: #cfcfcf;
    border-color: #808080 #fff #fff #808080;
  }
  body[data-project-shell] .project-sheet-handle:focus-visible {
    outline: 1px dotted #111;
    outline-offset: -5px;
  }
  body[data-project-shell] .project-sheet-grip {
    display: block;
    width: 34px;
    height: 9px;
    background: repeating-linear-gradient(to bottom, #777 0, #777 1px, #fff 1px, #fff 2px, transparent 2px, transparent 4px);
  }
  body[data-project-shell] #right > .subtabs {
    position: static;
    z-index: 1;
    min-width: 0;
    background: #fff;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
  }
  body[data-project-shell] .subpanel {
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px;
  }
  .subpanel .demo-guide ol { grid-template-columns: 1fr; gap: 13px; }
  .subpanel .demo-guide li { min-height: 0; }
  .subpanel .demo-guide li:not(:last-child)::after { content: "V"; right: auto; top: auto; bottom: -11px; left: 50%; transform: translateX(-50%); }
  .theme-lab-flow, .theme-example-grid { grid-template-columns: 1fr; }
  .theme-lab-flow li { min-height: 0; }
  .theme-lab-editor textarea { min-height: 250px; }
  body[data-project-shell].is-runtime-compact .live-readout { display: none; }
  .pop .body textarea { min-height: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  body[data-project-shell] #left,
  body[data-project-shell] #right { transition: none !important; }
}
