*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--body);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.5;
}

/* Toolbar */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brandmark { display: flex; align-items: baseline; gap: 10px; }
.brandmark b {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.brandmark span { font-size: 12px; color: var(--muted); font-weight: 500; }
.toolbar .spacer { flex: 1; }
.seg {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: 0.16s;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-ambient);
}
.toolbar select {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.toolbar kbd {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--cobalt-50);
  color: var(--cobalt);
  border: 1px solid rgba(35, 72, 230, 0.15);
}
#presenterBtn.on {
  background: var(--cobalt) !important;
  color: #fff !important;
  box-shadow: var(--shadow-btn);
}

/* Main layout */
.main-wrap {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 56px);
}
.main-wrap.presenter-on { align-items: flex-start; }

/* Canvas */
.canvas {
  flex: 1;
  padding: 32px 22px 24px;
  transition: flex 0.3s var(--ease-out);
}
.canvas.mode-proto {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.canvas.mode-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, 184px);
  gap: 28px 20px;
  justify-content: center;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}
.flow-head { display: none; }
.mode-board .flow-head {
  display: block;
  grid-column: 1 / -1;
  margin: 18px 0 4px;
}
.mode-board .flow-head:first-child { margin-top: 0; }
.flow-head b {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
}
.flow-head span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

/* Presenter panel */
.presenter-panel {
  display: none;
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 24px 20px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.presenter-on .presenter-panel { display: block; }
.presenter-on .device-stage { width: 420px; height: 906px; }
.presenter-on .frame { width: 420px; height: 906px; border-radius: 60px; }
.presenter-panel h2 {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 6px;
}
.presenter-panel .screen-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cobalt);
  margin-bottom: 16px;
}
.presenter-panel .note {
  font-size: 14px;
  line-height: 1.55;
  color: var(--body);
  padding: 14px 16px;
  background: var(--cobalt-50);
  border-radius: var(--radius-md);
  border: 1px solid rgba(35, 72, 230, 0.12);
  margin-bottom: 16px;
}
.presenter-panel .mvp-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}
.presenter-panel .mvp-tag.launch { background: var(--success-soft); color: var(--success); }
.presenter-panel .mvp-tag.vision { background: var(--warn-soft); color: #9A7A20; }
.presenter-panel .talking {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.presenter-panel .talking li { margin: 8px 0 8px 18px; }
.presenter-panel .arc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}
.presenter-panel .script-line {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  font-style: italic;
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 3px solid var(--cobalt);
  line-height: 1.45;
}

/* Staggered screen content (proto mode only) */
.mode-proto .device.is-active .view > *:not(.sticky-cta),
.mode-proto .device.is-active .body > *,
.mode-proto .device.is-active .result-footer,
.mode-proto .device.is-active .splash > *,
.mode-proto .device.is-active .ready > * {
  animation: contentRise 0.45s both cubic-bezier(0.22, 1, 0.36, 1);
}
.mode-proto .device.is-active .view > *:nth-child(1),
.mode-proto .device.is-active .body > *:nth-child(1) { animation-delay: 0.04s; }
.mode-proto .device.is-active .view > *:nth-child(2),
.mode-proto .device.is-active .body > *:nth-child(2) { animation-delay: 0.08s; }
.mode-proto .device.is-active .view > *:nth-child(3),
.mode-proto .device.is-active .body > *:nth-child(3) { animation-delay: 0.12s; }
.mode-proto .device.is-active .view > *:nth-child(4),
.mode-proto .device.is-active .body > *:nth-child(4) { animation-delay: 0.16s; }
.mode-proto .device.is-active .view > *:nth-child(n+5),
.mode-proto .device.is-active .body > *:nth-child(n+5) { animation-delay: 0.2s; }

/* Device frame */
.device {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.mode-proto .device { display: none; }
.mode-proto .device.is-active { display: flex; }
.mode-proto .device.is-active.nav-fwd .frame {
  animation: screenIn var(--dur-screen) var(--ease-out) both;
}
.mode-proto .device.is-active.nav-back .frame {
  animation: screenBack var(--dur-screen) var(--ease-out) both;
}
.device-tag { display: none; }
.mode-board .device-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.mode-board .device-tag i {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--cobalt);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.device-stage { width: 392px; height: 846px; }
.mode-board .device-stage {
  width: 184px;
  height: 397px;
  overflow: hidden;
  cursor: pointer;
}
.frame {
  width: 392px;
  height: 846px;
  background: linear-gradient(160deg, #23262f, #0a0c12);
  border-radius: 56px;
  padding: 13px;
  box-shadow:
    0 2px 3px rgba(255, 255, 255, 0.15) inset,
    0 0 0 2px #2c303c,
    0 60px 120px -30px rgba(14, 18, 46, 0.55);
  position: relative;
}
.mode-board .frame {
  transform: scale(0.4694);
  transform-origin: top left;
}
.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--paper);
  border-radius: 44px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  opacity: 0.45;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
.island {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 118px;
  height: 34px;
  background: #000;
  border-radius: 20px;
  z-index: 30;
}
.statusbar {
  height: 54px;
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 28px 9px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  position: relative;
  z-index: 12;
  font-variant-numeric: tabular-nums;
}
.statusbar.on-light-scan { color: var(--ink); }
.statusbar .icns { display: flex; gap: 7px; align-items: center; }
.statusbar .icns svg { width: 18px; height: 13px; }
.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 10;
}
.view::-webkit-scrollbar { width: 0; }
.homebar {
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  z-index: 12;
}
.homebar::after {
  content: "";
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: var(--ink);
  opacity: 0.75;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.mode-board .controls { display: none; }
.ctrl-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--cobalt-50);
  color: var(--cobalt);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.15s;
}
.ctrl-btn:hover { background: #dde4fc; }
.ctrl-btn:disabled { opacity: 0.35; cursor: default; }
.ctrl-btn svg { width: 20px; height: 20px; }
.cprog { width: 180px; }
.cprog .cbarwrap {
  height: 6px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.cprog .cbarwrap i {
  display: block;
  height: 100%;
  background: var(--cobalt);
  border-radius: 4px;
  transition: width 0.35s var(--ease-out);
}
.cprog .clab {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
}
.restart {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
}
.restart:hover { color: var(--ink); background: var(--paper); }
.hint-banner {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 14px auto 0;
  max-width: 640px;
  line-height: 1.55;
}

/* Client mode — hide dev chrome, vignette spotlight */
body.client-mode .toolbar,
body.client-mode .hint-banner,
body.client-mode #ctrlHost {
  display: none !important;
}
body.client-mode {
  background: radial-gradient(ellipse 80% 60% at 50% 45%, #2a2d38 0%, #0a0c12 100%);
}
body.client-mode .main-wrap {
  min-height: 100vh;
  justify-content: center;
  align-items: center;
}
body.client-mode .canvas.mode-proto {
  padding: 48px 22px;
}
body.client-mode .device.is-active .frame {
  box-shadow:
    0 2px 3px rgba(255, 255, 255, 0.15) inset,
    0 0 0 2px #2c303c,
    0 80px 160px -20px rgba(0, 0, 0, 0.65),
    0 0 120px rgba(35, 72, 230, 0.08);
}
body.client-mode .device.is-active .device-stage {
  animation: clientFloat 6s ease-in-out infinite;
}
body.client-mode .presenter-panel {
  display: none !important;
}
.client-badge {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9998;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(35, 72, 230, 0.92);
  color: #fff;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.client-badge.is-on {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  body.client-mode .device.is-active .device-stage {
    animation: none;
  }
}
