:root {
  color-scheme: dark;
  --page-bg: #09090b;
  --surface: #18181b;
  --surface-raised: #242428;
  --pill-bg: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --border: #3f3f46;
  --teal: #2dd4bf;
  --blue: #60a5fa;
  --green: #34d399;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --rail-bg: #0c0c0e;
  --rail-border: #3f3f46;
  --preview-w: 1200px;
  --preview-h: 900px;
  --preview-ratio-w: 1200;
  --preview-ratio-h: 900;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button {
  font: inherit;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(288px, 320px) 1fr;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 100vh;
  overflow-y: auto;
  padding: 20px 14px 24px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  margin: -20px -14px 0 -16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand__logo {
  display: block;
  width: 200px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.prototype-disclaimer {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.state-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.flow-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.flow-nav__group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.flow-nav__group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.flow-nav__group-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  overflow: visible;
}

.flow-nav__pills {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flow-pill {
  appearance: none;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--pill-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.flow-pill:hover {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(96, 165, 250, 0.12);
}

.flow-pill:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.flow-pill.is-active {
  border-color: var(--group-color, var(--blue));
  background: var(--group-color, var(--blue));
  color: #fff;
}

.flow-nav__group--utility {
  --group-color: var(--blue);
  color: var(--blue);
}

.flow-nav__group--main {
  --group-color: var(--teal);
  color: var(--teal);
}

.flow-nav__group--project {
  --group-color: var(--violet);
  color: var(--violet);
}

.flow-nav__group--success {
  --group-color: var(--green);
  color: var(--green);
}

.flow-nav__group--mapping {
  --group-color: var(--amber);
  color: var(--amber);
}

.stage-column {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  align-items: stretch;
}

.stage-body {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 20px 16px 28px;
}

.stage-rail {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 52px;
  padding: 16px 0;
  background: var(--rail-bg);
  border-left: 1px solid var(--rail-border);
}

.scale-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.scale-toggle:hover,
.scale-toggle[aria-pressed="true"] {
  border-color: var(--blue);
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
}

.scale-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.scale-toggle__label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: uppercase;
}

.device-frame {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(165deg, #27272a 0%, #18181b 100%);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.45),
    0 24px 48px rgba(0, 0, 0, 0.35);
}

.device-screen {
  position: relative;
  width: var(--preview-w);
  height: var(--preview-h);
  margin: 0 auto;
  overflow: hidden;
  border-radius: 16px;
  background: #0f172a;
}

.stage.fit-mode .device-frame {
  max-width: 100%;
}

.stage.fit-mode .device-screen {
  width: auto;
  height: min(var(--preview-h), calc(100dvh - 104px));
  max-width: 100%;
  aspect-ratio: var(--preview-ratio-w) / var(--preview-ratio-h);
}

.screen-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 180ms ease-out;
}

.screen-image.is-fading-out,
.screen-image.is-fading-in,
.content-view.is-fading-out,
.content-view.is-fading-in {
  opacity: 0;
}

.screen-image.is-fading-out,
.content-view.is-fading-out {
  transition-duration: 140ms;
  transition-timing-function: ease-in;
}

.content-view {
  position: absolute;
  inset: 0;
  overflow: auto;
  background:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.14), transparent 34%),
    linear-gradient(135deg, #101827 0%, #09090b 100%);
  opacity: 1;
  transition: opacity 180ms ease-out;
}

.hits-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hit {
  position: absolute;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hits-layer.reveal-hints .hit {
  overflow: hidden;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.22);
  animation: hit-visibility 1.8s ease-out forwards;
}

.hits-layer.reveal-hints .hit::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(59, 130, 246, 0.06) 20%,
    rgba(147, 197, 253, 0.35) 50%,
    rgba(59, 130, 246, 0.06) 80%,
    transparent 100%
  );
  background-size: 240% 100%;
  animation: hit-shimmer 2.5s ease-in-out infinite;
}

@keyframes hit-shimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@keyframes hit-visibility {
  0%,
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.hit:focus {
  outline: none;
}

.hit:focus-visible {
  border-radius: 4px;
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  background: rgba(59, 130, 246, 0.14);
}

.doc-page {
  min-height: 100%;
  padding: 48px;
  color: var(--text);
}

.doc-page__eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.doc-page h2 {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.doc-page__lede {
  max-width: 780px;
  margin: 16px 0 28px;
  color: #d4d4d8;
  font-size: 17px;
  line-height: 1.6;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.doc-card,
.flow-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
}

.doc-card {
  padding: 20px;
}

.doc-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.doc-card p,
.doc-card li {
  color: #d4d4d8;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.doc-card ul,
.doc-card ol {
  margin: 0;
  padding-left: 18px;
}

.flow-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.flow-card {
  padding: 20px;
}

.flow-card h3 {
  margin: 0 0 16px;
  color: #f8fafc;
  font-size: 16px;
}

.flow-step {
  position: relative;
  padding: 12px 14px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.76);
  color: #dbeafe;
  font-size: 13px;
  font-weight: 700;
}

.flow-step + .flow-step {
  margin-top: 22px;
}

.flow-step + .flow-step::before {
  content: "";
  position: absolute;
  left: 22px;
  top: -18px;
  width: 2px;
  height: 14px;
  background: rgba(96, 165, 250, 0.6);
}

.flow-step small {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .screen-image,
  .content-view {
    transition: none;
  }

  .hits-layer.reveal-hints .hit::after {
    animation: none;
    background: rgba(59, 130, 246, 0.12);
    opacity: 0.85;
  }

  .hits-layer.reveal-hints .hit {
    animation: none;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .flow-nav__pills {
    flex-flow: row wrap;
  }

  .flow-pill {
    width: auto;
    min-width: min(100%, 150px);
    flex: 1 1 auto;
  }

  .stage-column {
    flex-direction: column;
  }

  .stage-rail {
    order: -1;
    flex-direction: row;
    justify-content: flex-end;
    width: 100%;
    padding: 10px 16px;
    border-left: none;
    border-bottom: 1px solid var(--rail-border);
  }

  .stage {
    padding-top: 12px;
    min-height: auto;
  }

  .doc-grid,
  .flow-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1320px) {
  .stage:not(.fit-mode) .device-screen {
    width: min(100%, var(--preview-w));
    height: auto;
    aspect-ratio: var(--preview-ratio-w) / var(--preview-ratio-h);
  }
}
