/* Live demos. Each demo page sets its own brand on .demo (--b, --b2, --bg, --sf, --ink, --mut, --ln, --onb, --font)
   so every made-up business looks like itself. Everything is scoped to .demo / .d-app. */
.demo { --b: #c5050c; --b2: #111; --bg: #f5f6f8; --sf: #fff; --ink: #1d1d1f; --mut: #61656b; --ln: #e2e4e8; --onb: #fff; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --r: 14px; }
.demo-shell { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.d-app { position: relative; display: flex; flex-direction: column; height: min(880px, calc(100vh - 110px)); min-height: 560px; background: var(--bg); color: var(--ink); font-family: var(--font); border: 1px solid rgba(0, 0, 0, .12); border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .18); }
.d-app.full, .d-app.is-full { height: 100vh; min-height: 0; border-radius: 0; border: 0; }
.d-app.is-full { position: fixed; inset: 0; z-index: 1000; }
html.d-lock, html.d-lock body { overflow: hidden; }
.d-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: #1d1f23; color: #c9cdd3; font: 500 .82rem/1.2 system-ui, sans-serif; }
.d-dots { display: flex; gap: 6px; } .d-dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; } .d-dots i:nth-child(2) { background: #febc2e; } .d-dots i:nth-child(3) { background: #28c840; }
.d-url { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 8px; background: #2b2e34; color: #d8dbe0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-url::before { content: "🔒 "; }
.d-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.d-tool { padding: 6px 10px; border-radius: 8px; border: 1px solid #3a3e45; background: #2b2e34; color: #f1f3f5; font: 600 .78rem/1 system-ui, sans-serif; cursor: pointer; }
.d-tool:hover, .d-tool[aria-pressed="true"] { background: #f1f3f5; color: #1d1f23; }
.d-fs { background: #fff; color: #1d1f23; }
.d-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; }
.with-log .d-body { grid-template-columns: minmax(0, 1fr) 330px; }
.d-main { min-height: 0; overflow: auto; padding: clamp(14px, 2.4vw, 28px); }
.d-log { min-height: 0; overflow: auto; background: #111317; color: #d7dbe0; border-left: 1px solid #262a30; font: .82rem/1.45 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; }
.d-log-head { position: sticky; top: 0; padding: 12px 14px; background: #111317; border-bottom: 1px solid #262a30; font-family: system-ui, sans-serif; }
.d-log-head strong { display: block; color: #fff; font-size: .95rem; } .d-log-head small { color: #8b929b; }
.d-log ol { list-style: none; margin: 0; padding: 6px 10px 14px; }
.d-log li { padding: 8px 4px; border-bottom: 1px solid #22262c; animation: d-in .35s ease; }
.d-log li.d-empty { color: #8b929b; border: 0; font-family: system-ui, sans-serif; }
.d-log time { color: #6f7781; margin-right: 6px; font-size: .74rem; }
.d-log b { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; background: #2b2f36; color: #fff; }
.d-log span { display: block; margin-top: 3px; color: #e6e8eb; }
.d-log code { color: #9fe0ff; }
.k-ai { background: #6d28d9 !important; } .k-pay { background: #635bff !important; } .k-crm { background: #0f766e !important; } .k-sms { background: #16a34a !important; } .k-mail { background: #2563eb !important; } .k-books { background: #2ca01c !important; } .k-ship { background: #b45309 !important; } .k-alert { background: #dc2626 !important; } .k-mcp { background: #0891b2 !important; } .k-cal { background: #7c3aed !important; } .k-plc { background: #475569 !important; } .k-cam { background: #be185d !important; }
@keyframes d-in { from { opacity: 0; transform: translateY(-6px); } }
.d-toasts { position: absolute; top: 56px; right: 14px; z-index: 30; display: grid; gap: 8px; width: min(320px, calc(100% - 28px)); pointer-events: none; }
.d-toast { padding: 10px 12px; border-radius: 14px; background: rgba(28, 28, 30, .94); color: #fff; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); font: .88rem/1.35 system-ui, sans-serif; animation: d-in .3s ease; }
.d-toast b { display: block; font-size: .75rem; color: #9fe8b0; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.d-toast.k-mail b { color: #9cc3ff; } .d-toast.k-alert b { color: #ffb4b4; } .d-toast.k-ai b { color: #d9c2ff; }
.d-modal { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .45); }
.d-modal-box { position: relative; width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--sf); color: var(--ink); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.d-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: var(--mut); cursor: pointer; }

/* Shared building blocks */
.d-main h2, .d-main h3, .d-main h4 { font-family: var(--font); color: var(--ink); margin: 0 0 8px; }
.d-main p { margin: 0 0 10px; }
.d-main label { color: var(--ink); }
.d-main input, .d-main select, .d-main textarea { border-color: var(--ln); background: var(--sf); color: var(--ink); font-family: inherit; }
.d-main input:focus, .d-main select:focus, .d-main textarea:focus { outline: 3px solid color-mix(in srgb, var(--b) 30%, transparent); border-color: var(--b); }
.d-main button { font: inherit; cursor: pointer; }
.d-main button:disabled { cursor: not-allowed; opacity: .5; }
.d-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: var(--r); border: 2px solid var(--b); background: var(--b); color: var(--onb); font-weight: 700; text-decoration: none; }
.d-btn:hover { filter: brightness(1.08); }
.d-btn.ghost { background: transparent; color: var(--b); }
.d-btn.sm { padding: 6px 12px; font-size: .88rem; }
.d-btn.block { width: 100%; }
.d-link { background: none; border: 0; padding: 6px; color: var(--mut); text-decoration: underline; }
.d-card { background: var(--sf); border: 1px solid var(--ln); border-radius: var(--r); padding: 16px; }
.d-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.d-grid2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.d-grid3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.d-split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.d-chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--b); background: var(--sf); color: var(--b); font-size: .86rem; font-weight: 600; }
.d-chip.on, .d-chip:hover { background: var(--b); color: var(--onb); }
.d-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.d-opt { padding: 10px 14px; border: 1px solid var(--ln); border-radius: 10px; background: var(--sf); color: var(--ink); text-align: left; }
.d-opt small { display: block; color: var(--mut); font-size: .8rem; }
.d-opt.on { border-color: var(--b); box-shadow: inset 0 0 0 1px var(--b); background: color-mix(in srgb, var(--b) 9%, var(--sf)); }
.d-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); font-size: .78rem; font-weight: 700; }
.d-tag.ok { background: #dcfce7; color: #166534; } .d-tag.warn { background: #fef3c7; color: #92400e; } .d-tag.bad { background: #fee2e2; color: #991b1b; } .d-tag.ai { background: #ede9fe; color: #5b21b6; }
.d-muted { color: var(--mut); font-size: .9rem; }
.d-note { color: var(--mut); font-size: .82rem; margin-top: 8px; }
.d-ok { width: 58px; height: 58px; border-radius: 50%; background: #16a34a; color: #fff; display: grid; place-items: center; font-size: 30px; margin: 6px auto 10px; animation: d-pop .4s ease; }
@keyframes d-pop { 0% { transform: scale(.4); } 70% { transform: scale(1.12); } }
.d-center { text-align: center; }
.d-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.d-table th, .d-table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--ln); vertical-align: middle; }
.d-table th { color: var(--mut); font-weight: 600; font-size: .82rem; }
.d-kpis { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.d-kpi { background: var(--sf); border: 1px solid var(--ln); border-radius: 12px; padding: 12px; }
.d-kpi span { display: block; color: var(--mut); font-size: .8rem; } .d-kpi strong { font-size: 1.35rem; } .d-kpi em { display: block; font-style: normal; font-size: .78rem; color: #15803d; }
.d-bars { display: grid; gap: 6px; }
.d-bars div { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: center; font-size: .86rem; }
.d-bars i { height: 10px; border-radius: 0 5px 5px 0; background: var(--b); }
.d-phone { width: 270px; max-width: 100%; margin: 0 auto; padding: 14px 10px; border-radius: 30px; background: #111; box-shadow: 0 16px 40px rgba(0, 0, 0, .3); }
.d-phone-screen { border-radius: 22px; background: #fff; padding: 12px; min-height: 200px; font: .88rem/1.4 system-ui, sans-serif; color: #111; }
.d-sms { max-width: 85%; padding: 9px 12px; border-radius: 18px; background: #e9e9eb; margin: 6px 0; animation: d-in .3s ease; }
.d-sms.me { margin-left: auto; background: #0b84ff; color: #fff; }
.d-msg { max-width: 85%; padding: 10px 12px; border-radius: 14px; line-height: 1.45; animation: d-in .3s ease; }
.d-msg.bot { align-self: flex-start; background: var(--sf); border: 1px solid var(--ln); border-bottom-left-radius: 4px; }
.d-msg.me { align-self: flex-end; background: var(--b); color: var(--onb); border-bottom-right-radius: 4px; }
.d-msg small { display: block; margin-top: 4px; font-size: .75rem; opacity: .75; }
.d-typing i { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--mut); animation: d-blink 1s infinite; }
.d-typing i:nth-child(2) { animation-delay: .15s; } .d-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes d-blink { 50% { opacity: .2; } }
.d-pulse { animation: d-throb 1.4s ease-in-out infinite; }
@keyframes d-throb { 50% { transform: scale(1.06); opacity: .75; } }
.d-spin { width: 46px; height: 46px; margin: 18px auto; border-radius: 50%; border: 5px solid var(--ln); border-top-color: var(--b); animation: d-rot .9s linear infinite; }
@keyframes d-rot { to { transform: rotate(360deg); } }
.d-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.d-flash { animation: d-flash 1.2s ease; }
@keyframes d-flash { 0% { background: color-mix(in srgb, var(--b) 35%, transparent); } }

/* Demo page around the app */
.demo-top { padding: 18px 0 14px; }
.demo-top .eyebrow { margin-bottom: 4px; }
.demo-top h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 3vw, 2.4rem); }
.demo-top .lead { margin: 0 0 12px; max-width: 70ch; }
.demo-wow { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--tint); color: var(--red-d); font-weight: 700; font-size: .9rem; margin-bottom: 10px; }
.demo-stage-wrap { padding: 4px 0 30px; }
.demo-tries { counter-reset: t; list-style: none; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.demo-tries li { counter-increment: t; position: relative; padding: 14px 14px 14px 52px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.demo-tries li::before { content: counter(t); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font-weight: 800; }
.demo-note { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }

@media (max-width: 1000px) {
  .with-log .d-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 210px; }
  .d-log { border-left: 0; border-top: 1px solid #262a30; }
  .d-split, .d-grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .d-app { height: auto; min-height: 78vh; }
  .d-app.full, .d-app.is-full { height: 100vh; }
  .d-dots { display: none; }
  .d-tool[data-restart] { display: none; }
  .d-kpis, .d-grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .d-bars div { grid-template-columns: 90px 1fr auto; }
}
@media (prefers-reduced-motion: reduce) {
  .d-pulse, .d-spin, .d-typing i, .d-log li, .d-toast, .d-ok { animation: none; }
}
