:root {
  --paper: #F3F5F9;
  --surface: #FFFFFF;
  --ink: #172036;
  --muted: #66708A;
  --line: #DCE1EA;
  --cobalt: #2A4FD6;
  --ok: #13895F;
  --warn: #B7791F;
  --rose: #E0547E;
  --term: #121A2E;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: #0d1222; overflow: hidden; overscroll-behavior: none; }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; }

#viewport { position: fixed; inset: 0; }
#stage {
  position: absolute; left: 50%; top: 50%; width: 1600px; height: 900px;
  background: var(--paper); display: grid; grid-template-columns: 232px 1fr;
  transform-origin: center center; overflow: hidden;
  transform: translate(-50%, -50%);
}
.mono { font-family: var(--mono); font-size: 0.92em; }

/* Sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 24px 18px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.org { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: #E6EBFB; color: var(--cobalt); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { font-size: 15px; padding: 9px 10px; border-radius: 6px; color: #3d465c; }
nav a.active { background: #E9EEFC; color: var(--cobalt); font-weight: 600; }
.sidebar-foot { margin-top: auto; font-size: 13px; color: var(--muted); }

/* Main */
main { padding: 28px 40px; display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.crumbs { font-size: 15px; color: var(--muted); }
.crumbs b { color: var(--ink); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-left: 4px; }
.cluster-meta { margin-top: 6px; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sep { width: 3px; height: 3px; border-radius: 50%; background: #b4bccc; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px #13895f22; }
.dot.pending { background: var(--warn); box-shadow: 0 0 0 3px #b7791f26; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px #b7791f00; } }

.btn-primary {
  font: 600 16px var(--sans); color: #fff; background: var(--cobalt); border: 0;
  padding: 12px 22px; border-radius: 8px; cursor: pointer;
  box-shadow: inset 0 -2px 0 #0003;
}
.btn-primary:hover { background: #2344c0; }
.btn-primary:focus-visible { outline: 3px solid #2a4fd655; outline-offset: 2px; }
.btn-primary[disabled] { background: #9aa7d4; cursor: default; }

/* Replicas: the one bold moment */
.replicas-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.replicas-head h2 { font-size: 18px; font-weight: 650; }
.replica-count { font-size: 15px; color: var(--muted); }
.replica-count #count { font: 700 34px var(--sans); color: var(--ink); margin-right: 6px; font-variant-numeric: tabular-nums; display: inline-block; }
.replica-count #count.bump { animation: bump .6s ease; color: var(--rose); }
@keyframes bump { 40% { transform: scale(1.5); } }

.nodes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.node { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; height: 168px; display: flex; flex-direction: column; gap: 10px; }
.node-top { display: flex; justify-content: space-between; align-items: center; }
.node-name { font: 600 17px var(--mono); }
.node-state { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.node-stats { display: flex; gap: 22px; font-size: 13px; color: var(--muted); }
.node-stats b { display: block; color: var(--ink); font-size: 18px; font-variant-numeric: tabular-nums; }
.node canvas { width: 100%; height: 40px; margin-top: auto; }

.node.slot { border: 1.5px dashed #c5ccda; background: transparent; justify-content: center; align-items: center; color: #9aa3b6; font-size: 14px; }
.node.baby { border: 2px solid var(--rose); background: #FFF6F9; position: relative; }
.node.baby.enter { animation: grow .9s cubic-bezier(.2,1.4,.4,1); }
@keyframes grow { from { transform: scale(.6); opacity: 0; } }
.node.baby .node-name { color: var(--rose); }
.node.baby .eta { font-size: 22px; font-weight: 700; margin-top: auto; }
.node.baby .eta small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }

/* Lower panels */
.lower { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; }
.panel h3 { font-size: 16px; font-weight: 650; margin-bottom: 12px; }
.deploys { width: 100%; border-collapse: collapse; font-size: 14px; }
.deploys th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.deploys td { padding: 11px 6px; border-bottom: 1px solid #eef1f5; }
.deploys tr:last-child td { border-bottom: 0; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.pill.ok { background: #E3F4EC; color: var(--ok); }
.pill.muted { background: #EEF0F4; color: var(--muted); }
.pill.rose { background: #FCE6EE; color: var(--rose); }
#load { width: 100%; height: 190px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.sw { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.sw.a { background: var(--cobalt); } .sw.b { background: #8FA3E8; }

/* Terminal */
.terminal {
  position: absolute; left: 232px; right: 0; bottom: 0; height: 440px;
  background: var(--term); color: #d5dcef; font-family: var(--mono); font-size: 18px;
  transform: translateY(100%); transition: transform .5s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -12px 40px #0d122233; display: flex; flex-direction: column;
}
.terminal.open { transform: none; }
.terminal.compact { height: 300px; }
.term-bar { display: flex; justify-content: space-between; padding: 12px 40px; font-size: 14px; color: #8d97b3; border-bottom: 1px solid #ffffff14; font-family: var(--sans); }
.term-bar b { color: #fff; font-weight: 600; }
.term-status { color: #f0c36a; }
.term-status.done { color: #6fd3a5; }
.term-body { padding: 18px 40px; overflow: hidden; display: flex; flex-direction: column; gap: 7px; justify-content: flex-end; flex: 1; }
.line { white-space: pre; }
.line.cmd { color: #fff; }
.line.ok { color: #6fd3a5; }
.line.warn { color: #f0c36a; }
.line.info { color: #9db4ff; }
.line.dim { color: #6d7792; }
.line .cursor { display: inline-block; width: .6em; background: #d5dcef; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.layer { display: grid; grid-template-columns: 110px 380px 1fr 70px; gap: 16px; align-items: center; color: #aeb7cf; }
.bar { height: 8px; background: #ffffff14; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: #9db4ff; transition: width .15s linear; }
.layer.done .bar i { background: #6fd3a5; }

/* Inspector */
.inspector {
  position: absolute; top: 24px; right: 32px; width: 600px;
  background: var(--surface); border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 30px 80px #0d122240; padding: 22px;
  transform: translateX(120%); transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.inspector.open { transform: none; }
.insp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.insp-title { font-weight: 650; font-size: 17px; }
.insp-ref { color: var(--muted); margin-top: 2px; }
.photo-frame { position: relative; aspect-ratio: 4/3; background: #000; border-radius: 8px; overflow: hidden; }
.photo-frame img { width: 100%; height: 100%; object-fit: contain; clip-path: inset(0 0 100% 0); }
.photo-frame.reveal img { animation: wipe 3.2s cubic-bezier(.4,0,.2,1) forwards; }
.photo-frame .scan { position: absolute; left: 0; right: 0; height: 3px; top: 0; background: #9db4ff; box-shadow: 0 0 18px 4px #9db4ffaa; opacity: 0; }
.photo-frame.reveal .scan { animation: scan 3.2s cubic-bezier(.4,0,.2,1) forwards; }
.photo-frame.shown img { clip-path: none; animation: none; }
@keyframes wipe { to { clip-path: inset(0 0 0 0); } }
@keyframes scan { 0% { top: 0; opacity: 1; } 95% { opacity: 1; } 100% { top: 100%; opacity: 0; } }
.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.meta dt { font-size: 12px; color: var(--muted); }
.meta dd { font-weight: 600; font-size: 15px; margin-top: 2px; }

/* Finale */
.finale { position: absolute; inset: 0; display: grid; place-items: center; background: #172036cc; opacity: 0; pointer-events: none; transition: opacity .8s ease; }
.finale.open { opacity: 1; }
.finale-card { display: flex; align-items: center; gap: 56px; background: var(--surface); border-radius: 20px; padding: 48px 56px 48px 72px; text-align: left; border-top: 6px solid var(--rose); transform: translateY(20px); transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.finale.open .finale-card { transform: none; }
.finale-kicker { font: 500 16px var(--mono); color: var(--muted); }
.finale h1 { font-size: 84px; line-height: 1.02; letter-spacing: -0.035em; font-weight: 800; margin: 14px 0 22px; }
.finale-eta { font-size: 28px; color: var(--muted); }
.finale-eta b { color: var(--rose); }
.finale-photo { width: 360px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: #000; flex: none; }
#confetti { position: absolute; inset: 0; pointer-events: none; }

.stepdot { position: absolute; right: 8px; bottom: 6px; font: 10px var(--mono); color: #0002; }
.stepdot.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Phone: portrait hint, only before the demo starts */
.rotate { display: none; position: fixed; inset: 0; z-index: 10; background: #0d1222; color: #fff; place-items: center; text-align: center; font: 600 22px var(--sans); padding: 24px; }
.rotate small { display: block; margin-top: 10px; font-weight: 400; font-size: 15px; color: #8d97b3; }
@media (orientation: portrait) and (pointer: coarse) {
  body.at-start .rotate { display: grid; }
}

/* Welcome + product tour */
.welcome { position: absolute; inset: 0; display: grid; place-items: center; background: #17203680; opacity: 0; pointer-events: none; transition: opacity .4s ease; }
.welcome.open { opacity: 1; pointer-events: auto; }
.welcome-card { width: 620px; background: var(--surface); border-radius: 18px; padding: 44px 48px; box-shadow: 0 30px 80px #0d122240; }
.welcome-card h2 { font-size: 34px; letter-spacing: -0.02em; margin: 22px 0 12px; }
.welcome-card p { font-size: 19px; line-height: 1.5; color: #3d465c; margin-bottom: 28px; }
.tour { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease; }
.tour.open { opacity: 1; }
.tour.open .tip { pointer-events: auto; }
.spot { position: absolute; border-radius: 14px; box-shadow: 0 0 0 4px #2A4FD6, 0 0 0 3000px #17203699; transition: all .5s cubic-bezier(.2,.8,.2,1); }
.tip { position: absolute; width: 420px; background: var(--surface); border-radius: 14px; padding: 22px 24px; box-shadow: 0 20px 60px #0d122250; transition: left .5s cubic-bezier(.2,.8,.2,1), top .5s cubic-bezier(.2,.8,.2,1); }
.tip.pop { animation: tip-in .35s ease; }
@keyframes tip-in { from { opacity: 0; transform: translateY(6px); } }
.tip-count { font-size: 13px; color: var(--cobalt); font-weight: 600; }
.tip h4 { font-size: 21px; margin: 6px 0 8px; letter-spacing: -0.01em; }
.tip p { font-size: 17px; line-height: 1.5; color: #3d465c; }
.btn-small { font-size: 14px; padding: 8px 16px; margin-top: 16px; }

/* Song tile in the finale */
.nowplaying { position: absolute; right: 28px; bottom: 28px; background: var(--surface); border-radius: 12px; padding: 10px; box-shadow: 0 20px 50px #0d122260; opacity: 0; transform: translateY(12px); transition: opacity .6s ease .8s, transform .6s ease .8s; pointer-events: none; }
.nowplaying.open { opacity: 1; transform: none; }
.np-label { font-size: 12px; color: var(--muted); margin: 0 2px 8px; }
.nowplaying iframe { display: block; border-radius: 6px; }
