/* LineKeeper live simulator — /demo page styles.
   Site tokens come from /styles.css (:root). The dark cards reuse the
   showcase palette (--card-ink) so the machine, the ladder and the device
   read as one workbench on the white page. */

.demo-page { --dk-bg: #0c0f14; --dk-panel: #151922; --dk-border: #242a35; --dk-muted: #6b7688;
             --dk-text: #d7dde8; --dk-ok: #36c98b; --dk-bad: #e5484d; --dk-warn: #f5a623; --dk-accent: #4d8dff; }

/* ── hero: the site's hero, tightened ──────────────────────────────── */
.demo-hero.hero { padding: 44px 0 36px; }
.demo-hero h1 { font-size: clamp(38px, 5.4vw, 66px); }
.demo-hero .hero-sub { max-width: 720px; margin: 20px 0 22px; }
.demo-hero .hero-sub b { color: var(--ink); }
.demo-trust { margin: 0; }

/* ── control bar under the machine: where to look, how it starts ─── */
.demo-bar {
    position: sticky; top: 76px; z-index: 40;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 22px;
    margin: 2px 0 18px; padding: 8px 10px 8px 20px;
    background: #fff;
    border: 1px solid var(--line-2); border-radius: 22px; box-shadow: 0 10px 30px rgba(18,19,23,.08);
}
/* Safari: a blurred sticky bar over a diagram that repaints every frame
   jitters until the next scroll, so the demo page uses opaque bars and
   keeps the animated scene on its own compositing layer. */
/* Safari's scroll anchoring chases the live blocks on this page (they
   repaint and resize every tick) and walks the window 1 px per frame, then
   snaps back — the page visibly jumps until the visitor scrolls. Nothing
   above the fold changes height on its own, so anchoring buys nothing here. */
html:has(body.demo-page), body.demo-page { overflow-anchor: none; }
.demo-page .nav { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
.demo-scene svg { transform: translateZ(0); will-change: transform; }
.demo-bar-status { display: inline-flex; align-items: center; gap: 9px 12px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.demo-bar-status .dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa1ad; flex: none; transition: background .2s; }
.demo-bar-status .dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(30,169,102,.15); }
.demo-bar-status .dot.bad { background: var(--bad); box-shadow: 0 0 0 4px rgba(229,72,77,.15); animation: strip-blink 1s steps(2) infinite; }
.demo-bar-status .dot.warn { background: var(--warn); }
@keyframes strip-blink { 50% { opacity: .35; } }
.strip-name { font-weight: 600; color: var(--ink); }
.strip-state { font-weight: 600; letter-spacing: .04em; }
.strip-fault { color: var(--bad); }
.strip-metrics { display: inline-flex; gap: 14px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-right: auto; }
.strip-metric b { color: var(--ink); font-weight: 500; }
.seg { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface); border-radius: 100px; justify-self: end; }
.strip-tab { border: 0; background: transparent; color: var(--ink-2); border-radius: 100px; padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s; }
.strip-tab:hover { color: var(--ink); }
.strip-tab.active { background: var(--ink); color: #fff; }
.strip-tab-mobile { display: none; }
.strip-tab .tab-s { display: none; }
/* the setup row lives here on phones (demo.js moves it out of the sticky bar) */
.demo-bar-more { display: none; }
.demo-bar-more:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: -8px 0 16px; padding: 0 6px; }
.demo-bar-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--line); }
.strip-setup { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.strip-setup select { font: inherit; font-size: 13px; padding: 8px 12px; border-radius: 100px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); }
.btn-xs { padding: 5px 10px; font-size: 12px; }

/* buttons that live on the black cards */
.dk-btn {
    font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
    padding: 7px 14px; border-radius: 100px; cursor: pointer;
    background: #1e2430; color: #e7eaf0; border: 1px solid #3b4657;
    transition: background .15s, border-color .15s, color .15s;
}
.dk-btn:hover { background: #2a3140; border-color: #4d8dff; color: #fff; }
.dk-btn.danger { background: #3a1416; border-color: #7a2a2e; color: #ffd6d7; }
.dk-btn.danger:hover { background: #5a1e22; border-color: #e5484d; color: #fff; }

/* ── cards ───────────────────────────────────────────────────────── */
.demo-work { padding: 18px 0 10px; }
.demo-card {
    background: var(--dk-bg); color: var(--dk-text);
    border-radius: var(--r-lg); box-shadow: var(--shadow);
    padding: 16px 18px 14px; margin-bottom: 18px;
    border: 1px solid #1a1f29;
}
.demo-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; margin-bottom: 10px; }
.demo-card-title { font-family: var(--display); font-size: 17px; font-weight: 500; color: #fff; margin-right: 10px; }
.demo-card-sub { font-family: var(--mono); font-size: 11.5px; color: var(--dk-muted); }
.demo-card-note { font-size: 12.5px; color: #8e99ab; }
.demo-card-actions { display: flex; gap: 6px; }
.demo-card .btn-ghost { color: #aab4c4; border-color: #2a3140; }
.demo-card .btn-ghost:hover { color: #fff; border-color: #4d8dff; }
.muted-dark { color: var(--dk-muted); font-size: 12px; }

/* ── machine scene ───────────────────────────────────────────────── */
.demo-scene svg { width: 100%; height: auto; display: block; }
.scene-label { font-family: var(--mono); font-size: 10.5px; fill: var(--dk-muted); letter-spacing: .05em; }
.scene-label-xs { font-size: 8.5px; }
.scene-label-lk { fill: #9db9f5; }
.scene-mono { font-family: var(--mono); font-size: 10.5px; fill: #e7eaf0; }
.scene-mono-dim { fill: #8e99ab; }
.scene-warn { font-family: var(--mono); font-size: 8.5px; fill: var(--dk-bad); letter-spacing: .1em; font-weight: 600; }
.scene-dead { font-family: var(--mono); font-size: 11px; fill: #3b4657; letter-spacing: .2em; font-weight: 600; }
.scene-toast { font-family: var(--mono); font-size: 12px; fill: #f5a623; transition: opacity .3s; }
.scene-act { cursor: pointer; }
.scene-act:hover rect, .scene-act:hover circle:not(.led) { filter: brightness(1.25); }
.scene-act:focus { outline: none; }
.scene-act:focus-visible rect { stroke: var(--dk-accent); }
.scene-pb.pressed circle { filter: brightness(1.6); transform: scale(.92); transform-origin: center; transform-box: fill-box; }
.scene-estop.tripped circle:nth-child(3) { fill: #ff2d2d; transform: scale(.85); transform-box: fill-box; transform-origin: center; }
.scene-cable { animation: lk-cable 1.2s linear infinite; }
@keyframes lk-cable { from { stroke-dashoffset: 26; } to { stroke-dashoffset: 0; } }
.scene-lk-led { animation: lk-pulse 2.2s ease-in-out infinite; }
@keyframes lk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.demo-scene.is-loading { opacity: .5; }

.scene-swipe-hint { display: none; font-family: var(--mono); font-size: 11px; color: var(--dk-muted); letter-spacing: .04em; text-align: center; padding: 8px 0 0; }
.scene-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 12px 2px 2px; }
.scene-controls-label { font-family: var(--mono); font-size: 11px; color: var(--dk-muted); letter-spacing: .06em; margin-right: 2px; }
.scene-controls-sep { width: 1px; height: 22px; background: var(--dk-border); margin: 0 6px; }
.pb {
    font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
    padding: 6px 12px; border-radius: 100px; cursor: pointer;
    background: #1c2230; color: #d7dde8; border: 1px solid #2f3846;
    transition: background .15s, transform .08s, border-color .15s;
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.pb:hover { border-color: #4d8dff; color: #fff; }
.pb:active, .pb.pressed { transform: translateY(1px); background: #2a3140; }
.pb-green { background: #1a7f4b; border-color: #36c98b; color: #fff; }
.pb-red { background: #8f2a2e; border-color: #e5484d; color: #fff; }
.pb-amber { background: #7a5b12; border-color: #f5a623; color: #fff; }
.pb-estop { background: #3a1416; border-color: #e5484d; color: #ffb4b6; }
.pb.on { background: #3a1416; border-color: #e5484d; color: #ffb4b6; box-shadow: inset 0 0 0 1px #e5484d; }
.pb.on::before { content: '● '; color: #e5484d; }

/* ── app + device row ─────────────────────────────────────────────── */
.demo-tools { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 18px; }
.demo-phone-card, .demo-device-card, .demo-hmi-card { margin-bottom: 0; }
.demo-device-card { grid-column: 1 / -1; }
.demo-card.is-hidden { display: none; }

/* iPhone 16 Pro Max frame: 430 × 932 logical points, scaled to the column */
.phone-stage { display: block; position: relative; overflow: hidden; }
.iphone {
    position: relative; flex: none; width: 430px; height: 932px; min-width: 430px; transform-origin: top left;
    background: #000; border-radius: 62px; box-shadow: 0 0 0 10px #1c1c1e, 0 0 0 12px #3a3a3c, 0 24px 50px rgba(0,0,0,.6);
    overflow: hidden;
}
.iphone-island { position: absolute; top: 14px; left: 50%; width: 126px; height: 36px; margin-left: -63px; background: #000; border-radius: 22px; z-index: 5; }
.iphone-home { position: absolute; bottom: 8px; left: 50%; width: 140px; height: 5px; margin-left: -70px; background: rgba(255,255,255,.5); border-radius: 3px; z-index: 5; }
.iphone-screen { position: absolute; inset: 0; background: #0b0d12; color: #f2f3f5; font-family: -apple-system, 'SF Pro Text', var(--font); font-size: 17px; overflow: hidden; display: flex; flex-direction: column; }

/* original HMI (PanelView-style) */
.hmi-bezel { background: #1a1d24; border-radius: 12px; padding: 14px 14px 6px; border: 1px solid #2a3140; }
.hmi-screen { position: relative; background: #0d1a33; border-radius: 4px; padding: 0 0 12px; font-family: var(--mono); color: #e7eaf0; min-height: 420px; overflow: hidden; }
.hmi-top { display: flex; justify-content: space-between; background: #1d4ed8; color: #fff; font-size: 12px; letter-spacing: .12em; padding: 6px 12px; font-weight: 600; }
.hmi-status { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 14px; letter-spacing: .06em; }
.hmi-lamp { width: 14px; height: 14px; border-radius: 50%; background: #4a5568; flex: none; }
.hmi-lamp.ok { background: #36c98b; box-shadow: 0 0 8px #36c98b; } .hmi-lamp.bad { background: #e5484d; box-shadow: 0 0 8px #e5484d; animation: strip-blink 1s steps(2) infinite; } .hmi-lamp.warn { background: #f5a623; }
.hmi-state { font-weight: 700; } .hmi-fault { color: #ffb4b6; font-size: 12px; }
.hmi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 12px; }
.hmi-sec { grid-column: 1 / -1; font-size: 10px; letter-spacing: .16em; color: #7f93b8; padding-top: 6px; border-top: 1px solid #1e2f52; }
.hmi-btn { font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .06em; line-height: 1.25; min-height: 52px; border-radius: 4px; cursor: pointer;
  background: linear-gradient(#5b6b85, #3b4657); color: #fff; border: 1px solid #1e2430; box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 2px 0 #12161d; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.hmi-btn:active, .hmi-btn.pressed { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); filter: brightness(1.2); }
.hmi-btn-blue { background: linear-gradient(#3b82f6, #1d4ed8); }
.hmi-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.hmi-tgl-lbl { font-size: 10px; color: #d7dde8; }
.hmi-tgl-val { font-size: 12px; padding: 1px 8px; border-radius: 3px; background: #14352a; color: #36c98b; }
.hmi-tgl-val.off { background: #3a1416; color: #ffb4b6; }
.hmi-sp { grid-column: span 2; display: flex; align-items: center; gap: 6px; background: #0a1326; border: 1px solid #1e2f52; border-radius: 4px; padding: 6px 8px; }
.hmi-sp-lbl { font-size: 10px; color: #7f93b8; flex: 1; letter-spacing: .08em; }
.hmi-sp-val { font-size: 16px; color: #fff; min-width: 54px; text-align: center; }
.hmi-mini { font: inherit; font-size: 16px; width: 30px; height: 30px; border-radius: 4px; border: 1px solid #1e2430; background: linear-gradient(#5b6b85, #3b4657); color: #fff; cursor: pointer; }
.hmi-mini:active { filter: brightness(1.2); }
.hmi-ro { grid-column: span 2; display: flex; align-items: baseline; gap: 8px; background: #0a1326; border: 1px solid #1e2f52; border-radius: 4px; padding: 6px 10px; }
.hmi-ro span { font-size: 10px; color: #7f93b8; flex: 1; letter-spacing: .08em; }
.hmi-ro b { font-size: 18px; font-weight: 500; color: #fff; } .hmi-ro i { font-size: 10px; color: #7f93b8; font-style: normal; }
.hmi-dead-overlay { position: absolute; inset: 0; background: #000; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #3b4657; letter-spacing: .3em; font-size: 16px; font-weight: 700; }
.hmi-dead-overlay small { letter-spacing: 0; font-size: 11px; color: #2f3846; font-family: var(--font); }
.hmi-screen.dead .hmi-dead-overlay { display: flex; }
.hmi-bezel-bottom { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 0 2px; font-family: var(--mono); font-size: 11px; color: var(--dk-muted); letter-spacing: .08em; }
.hmi-led { width: 7px; height: 7px; border-radius: 50%; background: #36c98b; box-shadow: 0 0 6px #36c98b; }
.hmi-led.off { background: #3b4657; box-shadow: none; }

/* device bezel, 1024 × 600 UI */
.device-bezel { background: #111418; border-radius: 14px; padding: 12px 12px 6px; border: 1px solid #2a3140; }
.device-scale-wrap { position: relative; overflow: hidden; border-radius: 6px; background: #0c0f14; }
.device-scale-wrap iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #0c0f14; }
.device-bezel-bottom { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 0 2px; font-family: var(--mono); font-size: 11px; color: var(--dk-muted); letter-spacing: .08em; }
.device-led { width: 7px; height: 7px; border-radius: 50%; background: #36c98b; box-shadow: 0 0 6px #36c98b; }

/* ── phone app UI (rendered by phone.js) ─────────────────────────── */
.ph-status { height: 58px; flex: none; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 30px 6px; font-size: 16px; font-weight: 600; }
.ph-status .ph-sig { font-size: 13px; letter-spacing: .04em; }
.ph-head { flex: none; padding: 6px 20px 10px; display: flex; align-items: center; gap: 10px; }
.ph-head h2 { font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -.02em; color: #fff; flex: 1; }
.ph-head .ph-sub { font-size: 13px; color: #8e99ab; display: block; margin-top: 2px; }
.ph-back { background: none; border: 0; color: var(--dk-accent); font: inherit; font-size: 17px; cursor: pointer; padding: 6px 0; }
.ph-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }
.ph-body::-webkit-scrollbar { width: 0; }
.ph-tabs { flex: none; display: flex; justify-content: space-around; padding: 10px 6px 26px; border-top: 1px solid #1e2430; background: #0f1219; }
.ph-tab { background: none; border: 0; color: #6b7688; font: inherit; font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; padding: 2px 6px; }
.ph-tab svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ph-tab.active { color: var(--dk-accent); }
.ph-banner { flex: none; margin: 0 16px 10px; padding: 10px 14px; border-radius: 14px; background: #3a1416; border: 1px solid #7a2a2e; color: #ffd6d7; font-size: 14px; line-height: 1.35; }
.ph-banner b { color: #fff; }
.ph-banner.warn { background: #3a2f10; border-color: #7a5b12; color: #ffe7b3; }
.ph-card { background: #171b24; border-radius: 18px; padding: 14px 16px; margin-bottom: 12px; }
.ph-card h3 { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 6px; }
.ph-card p { font-size: 14px; color: #aab4c4; line-height: 1.45; }
.ph-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 16px; font-weight: 600; padding: 13px 18px; border-radius: 14px; border: 0; cursor: pointer; background: #2e6be6; color: #fff; }
.ph-btn.wide { width: 100%; }
.ph-btn.ghost { background: #1e2430; color: #d7dde8; }
.ph-btn.small { font-size: 13px; padding: 8px 12px; border-radius: 10px; }
.ph-btn.ok { background: #1a7f4b; }
.ph-btn.bad { background: #8f2a2e; }
.ph-btn:disabled { opacity: .5; cursor: default; }
.ph-btn:active { filter: brightness(1.2); }
.ph-row { display: flex; align-items: center; gap: 10px; }
.ph-row.between { justify-content: space-between; }
.ph-search { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 11px 14px; border-radius: 12px; border: 0; background: #1e2430; color: #fff; margin-bottom: 10px; }
.ph-search::placeholder { color: #6b7688; }
.ph-list { list-style: none; margin: 0; padding: 0; }
.ph-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; cursor: pointer; }
.ph-item:hover { background: #171b24; }
.ph-item + .ph-item { border-top: 1px solid #161a22; }
.ph-item .nm { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13.5px; color: #e7eaf0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-item .nm small { display: block; font-family: var(--font); font-size: 11.5px; color: #6b7688; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-item .ty { font-family: var(--mono); font-size: 10px; color: #8e99ab; background: #1e2430; border-radius: 6px; padding: 2px 6px; flex: none; }
.ph-item .val { font-family: var(--mono); font-size: 14px; color: #fff; flex: none; min-width: 52px; text-align: right; }
.ph-item .val.on { color: var(--dk-ok); }
.ph-item .val.off { color: #6b7688; }
.ph-group { font-size: 12px; color: #6b7688; letter-spacing: .06em; text-transform: uppercase; padding: 14px 12px 6px; }
.ph-dev { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: #171b24; margin-bottom: 8px; cursor: pointer; }
.ph-dev .ic { width: 40px; height: 40px; border-radius: 10px; background: #1e2430; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; color: #9db9f5; flex: none; }
.ph-dev .tx { flex: 1; min-width: 0; }
.ph-dev .tx b { display: block; font-size: 15px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-dev .tx span { font-size: 12.5px; color: #8e99ab; }
.ph-dev .chip { font-size: 11px; padding: 3px 8px; border-radius: 100px; background: #1e2430; color: #aab4c4; flex: none; }
.ph-dev .chip.ok { background: #14352a; color: #36c98b; }
.ph-progress { height: 6px; border-radius: 3px; background: #1e2430; overflow: hidden; margin: 10px 0; }
.ph-progress i { display: block; height: 100%; background: var(--dk-accent); width: 0; transition: width .2s linear; }
.ph-sheet { position: absolute; left: 0; right: 0; bottom: 0; background: #171b24; border-radius: 26px 26px 0 0; padding: 14px 20px 40px; box-shadow: 0 -10px 40px rgba(0,0,0,.5); z-index: 8; max-height: 78%; overflow-y: auto; }
.ph-sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: #3b4657; margin: 0 auto 12px; }
.ph-sheet h3 { font-family: var(--mono); font-size: 16px; color: #fff; word-break: break-all; }
.ph-sheet .desc { font-size: 13.5px; color: #aab4c4; margin: 6px 0 10px; line-height: 1.4; }
.ph-sheet .big { font-family: var(--mono); font-size: 34px; color: #fff; margin: 6px 0 12px; }
.ph-sheet .big.on { color: var(--dk-ok); }
.ph-sheet .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ph-input { font: inherit; font-size: 18px; font-family: var(--mono); padding: 10px 12px; border-radius: 12px; border: 1px solid #2f3846; background: #0f1219; color: #fff; width: 100%; box-sizing: border-box; }
.ph-select { font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 12px; border: 1px solid #2f3846; background: #0f1219; color: #fff; width: 100%; box-sizing: border-box; }
.ph-label { display: block; font-size: 12.5px; color: #8e99ab; margin: 10px 0 4px; }
.ph-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 7; }
.ph-toast { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); background: #fff; color: #111; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: 100px; z-index: 9; box-shadow: 0 8px 24px rgba(0,0,0,.4); white-space: nowrap; animation: ph-toast .25s ease-out; }
@keyframes ph-toast { from { opacity: 0; transform: translate(-50%, 10px); } }

/* panel widgets */
.ph-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph-w { position: relative; border-radius: 16px; background: #171b24; padding: 12px; min-height: 84px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; text-align: center; }
.ph-w.section { grid-column: 1 / -1; min-height: 0; padding: 6px 4px 0; background: none; align-items: flex-start; font-size: 12px; color: #6b7688; letter-spacing: .06em; text-transform: uppercase; }
.ph-w .lbl { font-size: 12px; color: #aab4c4; letter-spacing: .04em; text-transform: uppercase; }
.ph-w .pbtn { width: 100%; font: inherit; font-size: 17px; font-weight: 700; padding: 18px 8px; border-radius: 14px; border: 0; cursor: pointer; color: #fff; background: #2e6be6; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.ph-w .pbtn.green { background: #1a7f4b; }
.ph-w .pbtn.red { background: #8f2a2e; }
.ph-w .pbtn.amber { background: #7a5b12; }
.ph-w .pbtn:active, .ph-w .pbtn.held { filter: brightness(1.35); transform: scale(.97); }
.ph-w .pbtn.latched { box-shadow: inset 0 0 0 3px #fff; }
.ph-w .ind { width: 34px; height: 34px; border-radius: 50%; background: #2a3140; box-shadow: inset 0 0 0 3px #1e2430; }
.ph-w .ind.on { background: var(--dk-ok); box-shadow: 0 0 14px var(--dk-ok); }
.ph-w .ind.on.red { background: var(--dk-bad); box-shadow: 0 0 14px var(--dk-bad); }
.ph-w .num { font-family: var(--mono); font-size: 26px; color: #fff; }
.ph-w .num small { font-size: 12px; color: #8e99ab; margin-left: 4px; }
.ph-w .ph-input { font-size: 20px; text-align: center; padding: 8px; }
.ph-w .rm { position: absolute; top: 6px; right: 8px; background: #3a1416; color: #ffb4b6; border: 0; border-radius: 50%; width: 22px; height: 22px; font-size: 13px; cursor: pointer; }
.ph-w .ptag { font-family: var(--mono); font-size: 10px; color: #6b7688; }

/* dashboard tiles */
.ph-dash { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph-tile { border-radius: 16px; background: #171b24; padding: 12px 14px; min-height: 96px; }
.ph-tile.wide { grid-column: 1 / -1; }
.ph-tile .t { font-size: 12px; color: #8e99ab; letter-spacing: .04em; text-transform: uppercase; }
.ph-tile .v { font-family: var(--mono); font-size: 28px; color: #fff; margin-top: 4px; }
.ph-tile .v small { font-size: 12px; color: #8e99ab; margin-left: 4px; }
.ph-tile .v.ok { color: var(--dk-ok); } .ph-tile .v.bad { color: var(--dk-bad); } .ph-tile .v.warn { color: var(--dk-warn); }
.ph-tile svg { width: 100%; height: 44px; display: block; margin-top: 6px; }
.ph-tile .bar { height: 10px; border-radius: 5px; background: #1e2430; margin-top: 12px; overflow: hidden; }
.ph-tile .bar i { display: block; height: 100%; background: #3b82f6; }
.ph-tile .gauge { position: relative; height: 60px; }
.ph-tile .gauge svg { height: 60px; }

/* find-by-action */
.ph-phase { font-size: 15px; color: #fff; font-weight: 600; margin-bottom: 4px; }
.ph-hint { font-size: 13.5px; color: #aab4c4; line-height: 1.45; }
.ph-big-timer { font-family: var(--mono); font-size: 44px; color: #fff; text-align: center; margin: 10px 0; }
.ph-result { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #14352a; margin-bottom: 6px; }
.ph-result .nm { flex: 1; font-family: var(--mono); font-size: 13.5px; color: #fff; word-break: break-all; }
.ph-result .ty { font-family: var(--mono); font-size: 10px; color: #8e99ab; }

/* ── ladder pane ───────────────────────────────────────────────── */
.ladder-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.ladder-bar select, .ladder-bar input[type=search] {
    font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 10px;
    background: #151922; color: #e7eaf0; border: 1px solid #2a3140;
}
.ladder-bar input[type=search] { min-width: 220px; flex: 1; max-width: 360px; }
.ladder-follow { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #aab4c4; cursor: pointer; }
.ladder-dl { margin-left: auto; font-family: var(--mono); font-size: 12px; color: #9db9f5; }
.ladder-dl:hover { color: #fff; }
/* the whole routine is laid out on the page — no inner scroll box */
.ladder-body { border-top: 1px solid #1e2430; position: relative; }
.ladder-rung { border-bottom: 1px solid #161a22; padding: 8px 0 4px; min-height: 60px; border-left: 3px solid transparent; transition: border-color .2s, background .6s; }
.ladder-rung.rung-live { border-left-color: var(--dk-ok); }
.ladder-rung.ladder-jump { background: rgba(77,141,255,.14); }
.ladder-rung-head { display: flex; gap: 10px; align-items: baseline; padding: 0 8px 2px; }
.ladder-rung-no { font-family: var(--mono); font-size: 11px; color: var(--dk-muted); min-width: 22px; }
.ladder-rung-comment { font-size: 12.5px; color: #aab4c4; white-space: pre-wrap; line-height: 1.4; }
.ladder-rung-canvas { overflow-x: auto; padding-left: 18px; }
.ladder-raw { font-family: var(--mono); font-size: 12px; color: #e7eaf0; padding: 8px; }
.ladder-svg { display: block; }
.ladder-svg .lk-wire, .ladder-svg .lk-rail { stroke: #3b4657; stroke-width: 1.6; }
.ladder-svg .lk-rail { stroke-width: 2.2; }
.ladder-svg .lk-sym { stroke: #d7dde8; stroke-width: 2; }
.ladder-svg .lk-box { stroke: #8e99ab; stroke-width: 1.4; }
.ladder-svg .lk-lbl { fill: #e7eaf0; font-size: 11px; font-family: var(--mono); cursor: pointer; }
.ladder-svg .lk-lbl:hover { fill: var(--dk-accent); }
.ladder-svg .lk-op { fill: #fff; font-size: 12px; font-weight: 700; }
.ladder-svg .lk-arg { fill: #aab4c4; font-size: 11px; font-family: var(--mono); }
.ladder-svg .lk-arg[data-tag] { cursor: pointer; }
.ladder-svg .lk-arg[data-tag]:hover { fill: var(--dk-accent); }
.ladder-svg .lk-val { fill: var(--dk-accent); font-size: 11px; font-family: var(--mono); cursor: pointer; }
.ladder-svg .lk-coil-letter { fill: #fff; font-size: 10px; font-weight: 700; }
.ladder-svg .lk-on .lk-sym { stroke: var(--dk-ok); stroke-width: 2.8; }
.ladder-svg .lk-on .lk-box { stroke: var(--dk-ok); stroke-width: 2; }
.ladder-svg .lk-on .lk-lbl { fill: var(--dk-ok); }
.ladder-svg .lk-unk .lk-sym { stroke: #3b4657; }
.ladder-svg .lk-unk .lk-lbl { fill: #6b7688; }
.ladder-svg .lk-forced .lk-lbl { fill: var(--dk-warn); }
.ladder-info {
    position: sticky; bottom: 8px; margin: 8px; padding: 12px 14px;
    background: #171b24; border: 1px solid #2e6be6; border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.5); z-index: 5; font-size: 13.5px;
}
.ladder-info-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 14px; color: #fff; }
.ladder-info-head button { background: #1e2430; border: 0; color: #d7dde8; border-radius: 8px; padding: 4px 9px; cursor: pointer; font: inherit; }
.ladder-info .desc { color: #aab4c4; margin: 4px 0 8px; }
.ladder-info .val { font-family: var(--mono); color: #fff; }
.ladder-info .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.ladder-info .acts input { font: inherit; font-family: var(--mono); font-size: 13px; padding: 5px 8px; border-radius: 8px; background: #0f1219; color: #fff; border: 1px solid #2f3846; width: 110px; }
.ladder-info .lbtn { font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 100px; border: 1px solid #2f3846; background: #1e2430; color: #e7eaf0; cursor: pointer; }
.ladder-info .lbtn:hover { border-color: var(--dk-accent); }
.ladder-info .lbtn.warn { border-color: #7a5b12; color: #ffe7b3; }
.ladder-uses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
/* program analysis overlay (Buttons & setpoints) */
.ladder-an-btn { font-size: 12.5px; padding: 6px 11px; }
.ladder-an-btn.active { border-color: var(--dk-accent); color: #fff; }
.ladder-body.is-analysis > :not(.ladder-analysis) { display: none; }
.ladder-analysis { position: relative; background: #10141b; z-index: 6; padding: 12px 14px 16px; font-size: 13.5px; }
.an-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; color: #fff; }
.an-head button { background: #1e2430; border: 0; color: #d7dde8; border-radius: 8px; padding: 4px 9px; cursor: pointer; font: inherit; flex: none; }
.an-intro { color: #aab4c4; margin: 6px 0 10px; line-height: 1.45; font-size: 13px; }
.ladder-analysis h4 { font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--dk-muted); margin: 16px 0 6px; font-weight: 600; }
.ladder-analysis h4 span { color: #fff; margin-left: 6px; }
.an-row { border: 1px solid #242a35; border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; background: #151922; }
.an-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.an-name { background: none; border: 0; color: #fff; font-family: var(--mono); font-size: 13px; cursor: pointer; padding: 0; }
.an-name:hover { color: var(--dk-accent); }
.an-kind { font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 100px; background: #1e2430; color: #d7dde8; }
.an-kind-button { background: #1f3b2c; color: #9fe3c0; }
.an-kind-switch { background: #1c2e4d; color: #9db9f5; }
.an-kind-setpoint { background: #3a2e12; color: #ffe7b3; }
.an-kind-preset { background: #2a2340; color: #d3c4ff; }
.an-lvl { font-family: var(--mono); font-size: 10.5px; color: var(--dk-muted); }
.an-high { color: var(--dk-ok); } .an-medium { color: var(--dk-warn); } .an-low { color: var(--dk-bad); }
.an-val { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: #fff; display: inline-flex; align-items: center; gap: 6px; }
.an-dot { width: 9px; height: 9px; border-radius: 50%; background: #2a3140; display: inline-block; }
.an-dot.on { background: var(--dk-ok); box-shadow: 0 0 8px var(--dk-ok); }
.an-desc { color: #aab4c4; font-size: 12.5px; margin-top: 3px; line-height: 1.4; }
.an-desc code { font-family: var(--mono); color: #d7dde8; }
.an-meta { color: #d7dde8; font-size: 12px; margin-top: 3px; }
.an-why { color: var(--dk-muted); font-size: 12px; margin-top: 3px; line-height: 1.4; }
.an-uses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.ladder-use.an-w { color: #ffd6a0; }
.an-caveats { color: var(--dk-muted); font-size: 12px; margin: 14px 0 0; padding-left: 18px; line-height: 1.45; }
.an-caveats li { margin: 2px 0; }
.ladder-use { font: inherit; font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 8px; border: 1px solid #2a3140; background: #0f1219; color: #9db9f5; cursor: pointer; }
.ladder-use:hover { border-color: var(--dk-accent); color: #fff; }

/* ── things to try ─────────────────────────────────────────────── */
.try-card {
    position: fixed; left: 18px; bottom: 18px; z-index: 60; width: 340px; max-width: calc(100vw - 36px);
    background: #0f1420; color: #e7eaf0; border: 1px solid #2e6be6; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(10,11,13,.4); overflow: hidden;
}
.try-head { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; font: inherit; font-weight: 600; font-size: 14px; padding: 12px 14px; cursor: pointer; text-align: left; }
.try-head span:first-child { flex: 1; }
.try-count { font-family: var(--mono); font-size: 12px; color: #9db9f5; }
.try-chev { transition: transform .2s; }
.try-card.collapsed .try-chev { transform: rotate(180deg); }
.try-card.collapsed .try-list { display: none; }
.try-list { margin: 0; padding: 0 14px 12px 30px; font-size: 13px; line-height: 1.45; color: #c9d1de; max-height: 46vh; overflow-y: auto; }
.try-list li { margin-bottom: 8px; padding-left: 2px; }
.try-list li b { color: #fff; font-weight: 600; }
.try-list li i { color: #9db9f5; font-style: normal; }
.try-list li code { font-family: var(--mono); font-size: 12px; color: #ffe7b3; }
.try-list li.done { color: #6b7688; text-decoration: line-through; }
.try-list li.done b { color: #6b7688; }
.try-list li.done::marker { color: var(--dk-ok); }

/* ── misc ─────────────────────────────────────────────────────── */
.demo-hints { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 4px 0 8px; }
.demo-note { font-size: 12.5px; color: var(--muted); }
.demo-contact { margin-top: 36px; }
.demo-cta-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 22px; }

/* ── responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .demo-tools { grid-template-columns: 320px minmax(0, 1fr); }
    .hmi-grid { grid-template-columns: repeat(2, 1fr); }
    .hmi-sp, .hmi-ro { grid-column: span 2; }
}
@media (max-width: 900px) {
    .demo-hero.hero { padding: 28px 0 24px; }
    /* sticky bar: one status line + one row of tabs. The setup row moves
       below it (demo.js), otherwise the bar eats half the screen. */
    .demo-bar { top: 64px; border-radius: 18px; padding: 8px 12px 10px; gap: 8px; margin-bottom: 14px; }
    .demo-bar { grid-template-columns: 1fr; }
    .demo-bar-status { font-size: 12px; gap: 6px 8px; }
    .strip-metrics { display: none; }
    .strip-tab-mobile { display: inline-block; }
    .strip-tab .tab-l { display: none; }
    .strip-tab .tab-s { display: inline; }
    .seg { justify-self: stretch; width: 100%; }
    .seg .strip-tab { flex: 1; padding: 8px 4px; font-size: 13px; white-space: nowrap; }
    .demo-bar-actions { grid-column: auto; padding-top: 8px; }
    .demo-bar-more .demo-bar-actions { border-top: 0; padding-top: 0; }
    .demo-tools { display: block; }
    .demo-card { padding: 12px 12px 10px; border-radius: var(--r); }
    .demo-card-note { display: none; }
    /* windows become tabs; the machine stays on top */
    .demo-page .demo-card[data-views] { display: none; }
    .demo-page .demo-card[data-views].active { display: block; margin-bottom: 18px; }
    .hmi-grid { grid-template-columns: repeat(2, 1fr); }
    .scene-controls .pb { font-size: 11.5px; padding: 6px 10px; }
    /* the device UI is 1024 px wide; demo.js keeps it at ≥ 60 % and the
       bezel scrolls sideways instead of shrinking it to a postage stamp */
    .device-scale-wrap { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
    .ladder-bar input[type=search] { min-width: 140px; }
    .ladder-dl { display: none; }
    .try-card { left: 10px; bottom: 10px; width: 300px; }
    .try-list { max-height: 34vh; }
}
@media (max-width: 640px) {
    /* the line is 1000 units wide: keep it legible and let it scroll sideways */
    .demo-scene { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; margin: 0 -4px; padding: 0 4px; }
    .demo-scene svg { width: 880px; max-width: none; }
    .scene-swipe-hint { display: block; }
}
@media (max-width: 520px) {
    .demo-hero h1 { font-size: 30px; }
    .demo-bar-status { font-size: 12px; }
    .try-card { left: 10px; width: auto; }
}

/* ── narrow screens: a note instead of the simulator (index.html loads none of its scripts there) ── */
.demo-stub { display: none; padding: 4px 0 30px; }
.demo-stub h2 { font-size: clamp(26px, 6vw, 34px); margin: 0 0 12px; }
.demo-stub p { color: var(--muted); max-width: 560px; margin: 0 0 12px; }
.demo-stub p b { color: var(--ink); }
.demo-stub .demo-cta-row { justify-content: flex-start; margin: 18px 0 0; }
@media (max-width: 899px) {
    .demo-stub { display: block; }
    .demo-work, .try-card { display: none; }
}
