.demo-page { background: var(--paper-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.demo-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1.5rem;
  padding: 1.5rem 0 2.5rem;
  align-items: start;
}
@media (max-width: 980px) { .demo-shell { grid-template-columns: 1fr; } }

.chat {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 64px - 4rem);
}
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.3rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.chat-head h1 { font-size: 1.5rem; margin: 0 0 0.2rem; }
.chat-head p { color: var(--text-2); margin: 0; font-size: 0.95rem; }

.messages { flex: 1; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.3rem; }

.msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0.8rem; align-items: start; }
.msg.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.msg.user .avatar { display: none; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 800;
  color: var(--ink);
  background: linear-gradient(135deg, #2dd4bf, #a78bfa);
}
.bubble {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 1rem 1.15rem;
  min-width: 0;
  max-width: 100%;
}
.bubble > :last-child { margin-bottom: 0; }
.msg.user .bubble {
  background: var(--ink);
  color: var(--on-dark);
  border-color: var(--ink);
  border-radius: var(--radius) 4px var(--radius) var(--radius);
  white-space: pre-wrap;
  max-width: min(640px, 100%);
  font-size: 0.95rem;
}
.bubble.error { background: var(--fail-soft); border-color: #fecaca; color: #7f1d1d; }

.examples { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.chip {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent-strong); }

.thinking { display: flex; align-items: center; gap: 0.7rem; color: var(--text-2); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Scenario card */
.scenario-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.9rem 0 0.4rem; }
.scenario-title h3 { margin: 0; font-size: 1.05rem; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.pill.ok { background: var(--pass-soft); color: #166534; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--fail-soft); color: #991b1b; }
.pill.info { background: var(--accent-soft); color: var(--accent-strong); }
.summary { color: var(--text-2); }

.code {
  position: relative;
  background: var(--ink);
  border-radius: 12px;
  margin: 0.8rem 0;
}
.code pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  color: var(--on-dark);
  font-size: 0.84rem;
  line-height: 1.6;
}
.code .copy {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  font: inherit; font-size: 0.75rem; font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--line-dark);
  background: var(--ink-3);
  color: var(--on-dark-2);
  cursor: pointer;
}
.code .copy:hover { color: var(--on-dark); }

details.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); margin: 0.6rem 0; }
details.panel summary { cursor: pointer; padding: 0.65rem 0.9rem; font-weight: 650; font-size: 0.92rem; }
details.panel[open] summary { border-bottom: 1px solid var(--line); }
details.panel .panel-body { padding: 0.8rem 0.9rem; overflow-x: auto; }
.mapping { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.mapping th, .mapping td { text-align: left; vertical-align: top; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
.mapping th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.mapping td code { display: block; font-size: 0.8rem; white-space: pre-wrap; }
.mapping tr:last-child td { border-bottom: 0; }
.assumptions { margin: 0; padding-left: 1.2rem; font-size: 0.92rem; color: var(--text-2); }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.9rem; }
.note { font-size: 0.88rem; color: var(--text-3); }
.inline-code-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.inline-code-form input { flex: 1; min-width: 160px; }

/* Run card */
.run-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.run-head h3 { margin: 0; font-size: 1.05rem; }
.timer { font-family: var(--mono); font-size: 0.85rem; color: var(--text-3); }
.progress { list-style: none; margin: 0.9rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.progress li { display: flex; align-items: center; gap: 0.6rem; font-size: 0.92rem; color: var(--text-3); }
.progress li::before {
  content: "";
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex: none;
}
.progress li.done { color: var(--text-2); }
.progress li.done::before { border-color: var(--pass); background: var(--pass); }
.progress li.active { color: var(--text); font-weight: 600; }
.progress li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.verdict { display: flex; align-items: center; gap: 0.7rem; padding: 0.8rem 1rem; border-radius: 10px; font-weight: 700; margin: 0.8rem 0; }
.verdict.passed { background: var(--pass-soft); color: #166534; }
.verdict.failed, .verdict.error { background: var(--fail-soft); color: #991b1b; }
.verdict.invalid { background: var(--warn-soft); color: var(--warn); }
.verdict span { font-weight: 500; }

.step-results { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.step-results li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.step-results li:last-child { border-bottom: 0; }
.step-results li.heading { grid-template-columns: 1fr; font-weight: 700; color: var(--text-2); padding-top: 0.7rem; }
.step-results .mark { font-weight: 800; }
.step-results .SUCCESS .mark { color: var(--pass); }
.step-results .FAILURE .mark, .step-results .ERROR .mark, .step-results .COMPROMISED .mark { color: var(--fail); }
.step-results .SKIPPED .mark, .step-results .IGNORED .mark, .step-results .PENDING .mark, .step-results .UNDEFINED .mark { color: var(--text-3); }
.step-results .text { font-family: var(--mono); font-size: 0.8rem; overflow-wrap: anywhere; }
.step-results .dur { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; }
.step-error { grid-column: 2 / -1; background: var(--fail-soft); color: #7f1d1d; border-radius: 8px; padding: 0.5rem 0.7rem; font-family: var(--mono); font-size: 0.78rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.log { background: var(--ink); color: var(--on-dark); border-radius: 10px; padding: 0.8rem 1rem; font-size: 0.78rem; white-space: pre-wrap; overflow-x: auto; max-height: 280px; }

/* Composer */
.composer { border-top: 1px solid var(--line); padding: 1rem 1.5rem 1.2rem; position: sticky; bottom: 0; background: var(--paper); border-radius: 0 0 var(--radius) var(--radius); }
.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  max-height: 50vh;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  color: var(--text);
}
.composer textarea:focus { outline: none; border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px rgb(20 184 166 / 18%); }
.composer-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 0.7rem; }
.hint { font-size: 0.8rem; color: var(--text-3); }
@media (max-width: 600px) {
  .hint { display: none; }
  .composer-bar { justify-content: flex-end; }
  .messages, .chat-head, .composer { padding-left: 1rem; padding-right: 1rem; }
  .msg { grid-template-columns: minmax(0, 1fr); }
  .msg .avatar { display: none; }
}

/* Side panel */
.side { display: grid; gap: 1rem; position: sticky; top: 80px; }
@media (max-width: 980px) { .side { position: static; } }
.side-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; font-size: 0.92rem; }
.side-card h2 { font-size: 1rem; margin-bottom: 0.6rem; letter-spacing: -0.01em; }
.side-card p { color: var(--text-2); }
.side-card p:last-child { margin-bottom: 0; }
.side-card code { font-size: 0.82rem; background: var(--paper-2); padding: 0.05rem 0.3rem; border-radius: 4px; }
.muted { color: var(--text-3) !important; font-size: 0.86rem; }
.mini-steps { margin: 0 0 0.8rem; padding-left: 1.2rem; color: var(--text-2); }
.mini-steps li { margin-bottom: 0.3rem; }
.code-form { display: flex; gap: 0.5rem; }
input[type="password"], input[type="text"] {
  font: inherit; font-size: 0.92rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  flex: 1;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(20 184 166 / 18%); }
.code-status { margin: 0.5rem 0 0; font-size: 0.85rem; }
.code-status.ok { color: var(--pass); }
.accent-card { background: var(--ink); border-color: var(--ink); color: var(--on-dark); }
.accent-card h2 { color: var(--on-dark); }
.accent-card p { color: var(--on-dark-2); }
