:root {
  color-scheme: dark;
  --cabinet: oklch(0.145 0.01 215);
  --panel: oklch(0.205 0.012 215);
  --surface: oklch(0.265 0.014 215);
  --ink: oklch(0.95 0.006 200);
  --muted: oklch(0.72 0.018 205);
  --teal: oklch(0.65 0.112 195);
  --green: oklch(0.79 0.185 142);
  --amber: oklch(0.79 0.15 78);
  --line: oklch(0.39 0.018 210);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--cabinet); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--cabinet); font-family: Inter, "Segoe UI", Arial, sans-serif; }
button, a { font: inherit; }

.topbar { min-height: 72px; padding: 14px clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: oklch(0.12 0.008 215); }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--teal); color: var(--cabinet); border-radius: 7px; font-weight: 850; font-size: 20px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.read-only { color: var(--muted); font-size: 12px; display: inline-flex; gap: 8px; align-items: center; }
.read-only span { color: var(--teal); font-size: 9px; }

.layout { width: min(1500px, 100%); margin: 0 auto; padding: clamp(28px, 5vw, 64px) clamp(18px, 4vw, 56px) 36px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 34px; }
.hero-copy { max-width: 740px; }
.location { margin: 0 0 10px; color: var(--teal); font: 600 12px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .04em; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.06; letter-spacing: -.035em; text-wrap: balance; }
.intro { margin: 16px 0 0; color: var(--muted); max-width: 68ch; line-height: 1.55; }
.connection-summary { min-width: 205px; display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.connection-summary small, .connection-summary strong { display: block; }
.connection-summary small { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.connection-summary strong { font-size: 15px; }
.summary-light { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px oklch(0.72 0.018 205 / .1); transition: background .2s, box-shadow .2s; }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 355px); gap: 20px; align-items: stretch; }
.plc-stage, .status-panel { background: var(--panel); border-radius: 12px; }
.plc-stage { min-height: 570px; position: relative; display: grid; place-items: center; overflow: hidden; padding: 24px 24px 78px; background: radial-gradient(circle at 42% 30%, oklch(0.31 0.014 215), var(--panel) 70%); }
.plc { width: 100%; max-height: 560px; overflow: visible; }
.figure-caption { position: absolute; left: 24px; right: 24px; bottom: 20px; display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.figure-caption span, .figure-caption small { color: var(--muted); font-size: 11px; }
.figure-caption strong { font-size: 13px; }

.status-panel { padding: 24px; display: flex; flex-direction: column; }
.status-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.status-heading p { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.status-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.mode-tag { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font: 700 10px/1 ui-monospace, Consolas, monospace; }
.timeline { list-style: none; padding: 18px 0 8px; margin: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 0; color: var(--muted); transition: color .2s; }
.step-dot { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font: 700 10px/1 ui-monospace, Consolas, monospace; transition: .2s; }
.timeline strong, .timeline small { display: block; }
.timeline strong { font-size: 13px; line-height: 1.25; }
.timeline small { font-size: 11px; margin-top: 4px; color: inherit; opacity: .78; }
.timeline li.active { color: var(--ink); }
.timeline li.active .step-dot { background: var(--amber); color: var(--cabinet); border-color: transparent; }
.timeline li.done { color: var(--ink); }
.timeline li.done .step-dot { background: var(--green); color: var(--cabinet); border-color: transparent; }

.telemetry { margin: auto 0 18px; border-top: 1px solid var(--line); }
.telemetry div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.telemetry dt { color: var(--muted); }
.telemetry dd { margin: 0; text-align: right; font-family: ui-monospace, Consolas, monospace; }
.replay { width: 100%; padding: 11px 14px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink); background: var(--surface); border: 0; border-radius: 6px; cursor: pointer; transition: background .18s, transform .18s; font-size: 12px; font-weight: 650; }
.replay:hover { background: oklch(0.32 0.025 205); }
.replay:active { transform: translateY(1px); }
.replay:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.replay svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.demo-note { margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: center; }

.lower-cover { transform: translateY(0); transition: transform 700ms var(--ease); }
.ethernet-cable { transform: translateX(360px); transition: transform 900ms var(--ease); }
.link-led, .act-led { fill: #2a3230; transition: fill .2s; }
.power { fill: #70e84c; filter: url(#ledGlow); }
.plc-stage[data-state="prepare"] .lower-cover,
.plc-stage[data-state="cable"] .lower-cover,
.plc-stage[data-state="handshake"] .lower-cover,
.plc-stage[data-state="awaiting"] .lower-cover,
.plc-stage[data-state="online"] .lower-cover { transform: translateY(94px); }
.plc-stage[data-state="cable"] .ethernet-cable,
.plc-stage[data-state="handshake"] .ethernet-cable,
.plc-stage[data-state="awaiting"] .ethernet-cable,
.plc-stage[data-state="online"] .ethernet-cable { transform: translateX(-55px); }
.plc-stage[data-state="handshake"] .link-led { fill: var(--amber); filter: url(#ledGlow); }
.plc-stage[data-state="online"] .link-led,
.plc-stage[data-state="online"] .act-led { fill: var(--green); filter: url(#ledGlow); }
.plc-stage[data-state="online"] .act-led { animation: activity 1.15s steps(2, end) infinite; }
.plc-stage[data-state="online"] + .status-panel { --live: var(--green); }
body.online .summary-light { background: var(--green); box-shadow: 0 0 0 5px oklch(0.79 0.185 142 / .14), 0 0 18px oklch(0.79 0.185 142 / .35); }
body.connecting .summary-light { background: var(--amber); box-shadow: 0 0 0 5px oklch(0.79 0.15 78 / .14); }
@keyframes activity { 0%, 48% { opacity: 1; } 50%, 100% { opacity: .24; } }

footer { min-height: 52px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px clamp(18px, 4vw, 56px); color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }

@media (max-width: 980px) {
  .workbench { grid-template-columns: 1fr; }
  .status-panel { min-height: 480px; }
  .plc-stage { min-height: 480px; }
}

@media (max-width: 650px) {
  .topbar { min-height: 64px; }
  .read-only { font-size: 0; }
  .read-only span { font-size: 10px; }
  .hero { align-items: stretch; flex-direction: column; }
  .connection-summary { width: 100%; }
  .plc-stage { min-height: 340px; padding: 10px 4px 68px; }
  .figure-caption { grid-template-columns: 1fr; gap: 3px; left: 16px; right: 16px; }
  .figure-caption small { display: none; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
