.demo { padding-bottom: 56px; }
.demo-head { padding: 36px 0 4px; }
.demo-title { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 14px; }
.note {
  font-size: 0.9rem; color: var(--muted); margin: 0; max-width: 60em;
  border-left: 3px solid var(--accent); padding: 8px 14px;
  background: rgba(61, 220, 151, 0.05); border-radius: 0 8px 8px 0;
}

.steps-bar { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 22px 0 12px; }
.steps-bar li { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.steps-bar li.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.steps-bar li.done { color: var(--text); border-color: rgba(61, 220, 151, 0.4); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center;
}
.panel .hint { flex-basis: 100%; margin: 0; color: var(--text); }
.group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.group.end { margin-left: auto; }
[hidden] { display: none !important; }

button.b {
  font: inherit; font-size: 0.95rem; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text); cursor: pointer;
}
button.b:hover:not(:disabled) { border-color: rgba(190, 230, 215, 0.45); }
button.b.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.b.primary:hover:not(:disabled) { background: #5be6a9; }
button.b:disabled { opacity: 0.45; cursor: not-allowed; }
button.b[aria-pressed="true"], button.b[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.ctl { display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; color: var(--muted); }
.ctl b { color: var(--text); font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { width: 110px; accent-color: var(--accent); }
.ctl input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; }
.ctl output { color: var(--text); min-width: 3.2em; font-variant-numeric: tabular-nums; }

.result { flex-basis: 100%; }
.result h3 { font-size: 1.25rem; margin: 0 0 6px; }
.result p { margin: 0 0 12px; color: var(--muted); }
.result.ok h3 { color: var(--accent); }
.result.bad h3 { color: var(--alarm); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stats div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stats small { display: block; color: var(--muted); font-size: 0.8rem; }
.stats b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.tabs { display: none; }
.views { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; position: relative; align-items: start; }
.view { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-width: 0; transition: border-color .2s, box-shadow .2s; }
.view.scan { background: #071012; }
.view-head { display: flex; align-items: baseline; gap: 4px 10px; padding: 2px 6px 8px; flex-wrap: wrap; }
.view-head span { color: var(--muted); font-size: 0.86rem; }
.view svg { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.view svg text { font-family: var(--sans); }
.pill { margin-left: auto; border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 0.8rem !important; }
.pill.alarm { color: #fff !important; background: var(--alarm); border-color: var(--alarm); font-weight: 700; }
.pill.live { color: var(--accent) !important; border-color: rgba(61, 220, 151, 0.5); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.8rem; color: var(--muted); padding: 8px 6px 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend i.sq { border-radius: 2px; border: 1.5px dashed var(--accent); width: 11px; height: 9px; }

.views.alarm .view { border-color: var(--alarm); box-shadow: 0 0 0 2px rgba(255, 93, 79, 0.35); }
.banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--alarm); color: #fff; font-weight: 800; letter-spacing: 0.04em;
  padding: 6px 18px; border-radius: 999px; box-shadow: 0 6px 24px rgba(255, 93, 79, 0.45);
  animation: pulse 1s ease-in-out infinite; white-space: nowrap;
}
@keyframes pulse { 50% { opacity: 0.75; } }

@media (max-width: 900px) {
  .views { grid-template-columns: 1fr; }
  .tabs { display: flex; gap: 8px; margin-top: 14px; }
  .views[data-tab="top"] #viewScan, .views[data-tab="scan"] #viewTop { display: none; }
  .group.end { margin-left: 0; }
}

.logbox { margin-top: 20px; }
.logtitle { font-size: 1.1rem; margin: 0 0 8px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.log li { padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 0.92rem; display: flex; gap: 12px; }
.log li:last-child { border-bottom: none; }
.log li.empty { color: var(--muted); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.8em; }
.log .detect { color: var(--accent); }
.log .ghost { color: #f2b84b; }
.log .alarm { color: var(--alarm); font-weight: 700; }

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  background: #14222a; border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px;
  padding: 10px 14px; font-size: 0.93rem; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); animation: tin .2s ease-out;
}
.toast.detect { border-left-color: var(--accent); }
.toast.ghost { border-left-color: #f2b84b; }
.toast.alarm { background: #3a1512; border-color: var(--alarm); border-left-color: var(--alarm); font-weight: 700; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast, .banner { animation: none; } }

.zoom { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.pill + .zoom { margin-left: 8px; }
.zoom .zoomLevel { min-width: 2.6em; text-align: center; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
button.b.sm { padding: 3px 10px; font-size: 0.85rem; min-height: 30px; }
.legend i.bld { border-radius: 2px; background: #26323a; border: 2px solid #c3ced4; width: 13px; height: 10px; }
.view-head span span { font-size: inherit; }
.legend i.msk { border-radius: 50%; border: 1.5px dashed #9fb2ab; background: rgba(159,178,171,0.15); width: 11px; height: 11px; }
.log .learn { color: #7cc4ff; }
.log .mask { color: #9fb2ab; font-style: italic; }
.toast.learn { border-left-color: #7cc4ff; }
button.b.learn { border-color: rgba(124, 196, 255, 0.5); color: #9fd2ff; }
button.b.learn.busy { background: rgba(124, 196, 255, 0.15); }
#selRot, #selSize { gap: 8px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
