/* /demo only (src/http/demo.js). Loaded after /site.css and /connect.css and uses their tokens
   (--bg --panel --ink --muted --line --brand --accent --teal), so light and dark follow them. The
   chips mirror the webmail's (/console.css .chip). No inline styles: the page CSP is style-src
   'self'. Panels stack on phones. Motion is opacity/transform only and off under reduced motion. */
:root { --d-ok: #15803d; --d-ok-soft: #e7f6ec; --d-warn: #a15c07; --d-warn-soft: #fdf3e1; --d-bad: #b4232a; --d-bad-soft: #fdecec; --d-info: #1d4ed8; --d-info-soft: #e8efff; --d-soft: #efeef6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { --d-ok: #4ade80; --d-ok-soft: #10301f; --d-warn: #f6c453; --d-warn-soft: #30260f; --d-bad: #ff8a8a; --d-bad-soft: #3a1518; --d-info: #93c5fd; --d-info-soft: #12203a; --d-soft: #1b1a33; } }
:root[data-theme=dark] { --d-ok: #4ade80; --d-ok-soft: #10301f; --d-warn: #f6c453; --d-warn-soft: #30260f; --d-bad: #ff8a8a; --d-bad-soft: #3a1518; --d-info: #93c5fd; --d-info-soft: #12203a; --d-soft: #1b1a33; }

.demo-page { overflow-x: hidden; }
.demo-banner { background: var(--d-warn-soft); color: var(--d-warn); border-bottom: 1px solid var(--line); text-align: center; padding: 8px 16px; font-weight: 650; font-size: .92rem; }
.demo-head { padding: 28px 0 8px; }
.demo-head h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); letter-spacing: -.03em; margin: 4px 0 8px; }
.demo-head .lead { max-width: 46em; margin: 0; }
.demo-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; padding: 16px 0 8px; }
.dpanel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--cx-shadow, none); min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.dpanel-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dpanel-h h2 { margin: 0; font-size: 1rem; flex: 1; min-width: 0; }
.dsub { margin: 0; font-size: .8rem; color: var(--muted); }

.dscope-row, .dtabs { display: flex; gap: 6px; padding: 10px 14px 6px; overflow-x: auto; scrollbar-width: thin; }
.dtabs { padding-top: 4px; border-bottom: 1px solid var(--line); }
.dscope, .dtab, .dprompt, .dbtn { font: inherit; cursor: pointer; }
.dscope { flex: none; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: .82rem; white-space: nowrap; }
.dscope.on { background: color-mix(in srgb, var(--brand) 14%, var(--panel)); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); font-weight: 650; }
.dtab { min-height: 40px; padding: 4px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: .9rem; }
.dtab.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 650; }
.dcount { display: inline-block; min-width: 1.5em; text-align: center; border-radius: 999px; background: var(--d-soft); font-size: .75rem; padding: 0 6px; }
.dstatus { padding: 6px 14px; font-size: .78rem; color: var(--muted); }

.dlist { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.drow { border-bottom: 1px solid var(--line); transition: opacity .35s var(--cx-ease, ease), transform .35s var(--cx-ease, ease); }
.drow.leaving { opacity: 0; transform: translateX(40px); }
.drow.is-quar { background: color-mix(in srgb, var(--d-bad-soft) 55%, transparent); }
.drow.is-open { background: color-mix(in srgb, var(--brand) 6%, var(--panel)); }
.dmsg { display: grid; gap: 3px; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; padding: 10px 14px; min-height: 64px; cursor: pointer; }
.dmsg:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.dmsg:focus-visible, .dscope:focus-visible, .dtab:focus-visible, .dprompt:focus-visible, .dbtn:focus-visible, #d-input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.dtop { display: flex; align-items: baseline; gap: 8px; }
.dfrom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtime { font-size: .75rem; color: var(--muted); flex: none; }
.dsubj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.dmeta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.dmb { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.dprio { flex: none; background: var(--brand); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 8px; }
.dchip { display: inline-flex; align-items: center; font-size: .72rem; font-weight: 650; padding: 1px 8px; border-radius: 999px; background: var(--d-soft); color: var(--muted); line-height: 1.5; white-space: nowrap; }
.dchip.ok { background: var(--d-ok-soft); color: var(--d-ok); } .dchip.warn { background: var(--d-warn-soft); color: var(--d-warn); }
.dchip.bad { background: var(--d-bad-soft); color: var(--d-bad); } .dchip.info { background: var(--d-info-soft); color: var(--d-info); }
.dchip.accent { background: color-mix(in srgb, var(--brand) 16%, var(--panel)); color: var(--brand); }
.dchip.ghost { background: none; border: 1px dashed var(--brand); color: var(--brand); }
.dbody { padding: 2px 14px 14px; font-size: .9rem; }
.dbody p { margin: 6px 0; } .dmuted { color: var(--muted); }
.ddraft, .ddraftcard pre { white-space: pre-wrap; font: inherit; font-size: .86rem; background: var(--d-soft); border-radius: 10px; padding: 10px 12px; margin: 4px 0; overflow-wrap: anywhere; }
.dempty { padding: 28px 14px; color: var(--muted); text-align: center; }

.dchat { position: sticky; top: 12px; }
.dlog { padding: 12px 14px; display: grid; gap: 12px; height: 440px; overflow-y: auto; align-content: start; }
.dwho { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 2px; }
.dmsgu { justify-self: end; max-width: 90%; background: color-mix(in srgb, var(--brand) 14%, var(--panel)); border-radius: 14px 14px 4px 14px; padding: 8px 12px; }
.dmsgu p, .dmsga p { margin: 0 0 6px; } .dmsga { animation: d-in .25s var(--cx-ease, ease) both; }
.dtool { border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; background: var(--bg); font-size: .78rem; overflow: hidden; }
.dtool-h { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.dtool-name { font-weight: 700; color: var(--brand); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dtool-st { font-size: .7rem; color: var(--muted); }
.dtool.is-running .dtool-st::after { content: '...'; }
.dtool.is-running .dtool-ic { animation: d-spin 1s linear infinite; display: inline-block; }
.dtool-args, .dtool-res { margin: 0; padding: 6px 10px; white-space: pre-wrap; overflow-wrap: anywhere; font: 500 .74rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: none; border: 0; border-top: 1px solid var(--line); color: var(--muted); }
.dtool-res { color: var(--ink); background: color-mix(in srgb, var(--d-ok-soft) 50%, transparent); }
.dans { margin: 4px 0 8px; padding-left: 1.2em; } .dans li { margin: 3px 0; }
.dnote { font-size: .82rem; color: var(--muted); }
.ddraftcard { margin: 6px 0; }
.dprompts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--line); }
.dprompt { min-height: 36px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); font-size: .8rem; text-align: left; }
.dprompt:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); background: color-mix(in srgb, var(--brand) 8%, var(--panel)); }
.dprompt:disabled, .dbtn:disabled { opacity: .5; cursor: default; }
.dconfirm { padding: 0 14px 8px; }
.dform { display: flex; gap: 8px; padding: 10px 14px 14px; }
#d-input { flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--cx-field, var(--panel)); color: var(--ink); }
.dbtn { min-height: 44px; padding: 6px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 650; }
.dbtn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.dbtn.small { min-height: 36px; padding: 2px 12px; font-size: .84rem; }
.demo-cta { text-align: center; padding: 40px 0 56px; }
.demo-cta h2 { margin: 0 0 8px; }
.demo-cta .cta { justify-content: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dnojs { padding: 14px; }
@keyframes d-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes d-spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) { .demo-grid { grid-template-columns: minmax(0, 1fr); } .dchat { position: static; } .dlist { max-height: 480px; } .dlog { height: 360px; } }
@media (prefers-reduced-motion: reduce) { .drow, .dmsga, .dtool.is-running .dtool-ic { animation: none; transition: none; } }
