:root {
  --page-bg: #f4f6f8;
  --frame-bg: #18202a;
  --focus: #2f6fed;
  --zone: #ff6709;
  --text: #17202a;
}

* {
  box-sizing: border-box;
}

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

button {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.app-layout.manager-open {
  grid-template-columns: 360px minmax(0, 1fr);
}

.prototype-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
}

.demo-stage {
  width: min(100%, 1180px);
}

.desktop-frame {
  overflow: hidden;
  width: 100%;
  border: 1px solid #c6ced8;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgb(24 34 45 / 16%);
}

.window-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-bottom: 1px solid #d8dee7;
  background: #f7f9fb;
}

.window-toolbar span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #cbd5df;
}

.window-toolbar span:first-child {
  background: #ff6058;
}

.window-toolbar span:nth-child(2) {
  background: #ffbd2e;
}

.window-toolbar span:nth-child(3) {
  background: #28c840;
}

.screen-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 1440 / 900;
  background: #fff;
}

.screen-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: var(--zoom-origin-x, 50%) var(--zoom-origin-y, 50%);
  transform: scale(var(--zoom-scale, 1));
  transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), filter 360ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  transform-origin: var(--zoom-origin-x, 50%) var(--zoom-origin-y, 50%);
  transform: scale(var(--zoom-scale, 1));
  transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease;
}

.screen-canvas.is-jumping-zoom .screen-image,
.screen-canvas.is-jumping-zoom .hotspot-layer {
  transition: none;
}

.hotspot {
  position: absolute;
  padding: 0;
  border: 2px solid rgb(255 103 9 / 72%);
  border-radius: 8px;
  background: rgb(255 103 9 / 12%);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 64%),
    0 0 0 3px rgb(255 103 9 / 10%),
    0 10px 26px rgb(255 103 9 / 10%);
  cursor: pointer;
  opacity: 0.72;
  transition:
    transform 180ms ease,
    opacity 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
  animation: hotspot-pulse 2.8s ease-in-out infinite;
  animation-delay: var(--hotspot-delay, 0ms);
}

body.zone-editing .hotspot {
  cursor: move;
}

.hotspot.is-selected {
  border-color: var(--zone);
  background: rgb(255 103 9 / 10%);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 80%),
    0 0 0 5px rgb(255 103 9 / 14%),
    0 14px 34px rgb(255 103 9 / 16%);
  opacity: 1;
}

.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--zone);
  box-shadow: 0 4px 12px rgb(17 24 39 / 20%);
  cursor: nwse-resize;
}

body:not(.zone-editing) .resize-handle {
  display: none;
}

.hotspot-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 2;
  max-width: 220px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 150ms ease, transform 150ms ease;
  white-space: nowrap;
}

.hotspot-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: #111827;
  transform: translateX(-50%);
}

.hotspot:hover .hotspot-tooltip,
.hotspot:focus-visible .hotspot-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hotspot:hover {
  border-color: var(--zone);
  background: rgb(255 103 9 / 18%);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 72%),
    0 0 0 6px rgb(255 103 9 / 14%),
    0 14px 34px rgb(255 103 9 / 18%);
  opacity: 1;
  transform: translateY(-1px);
}

.hotspot:focus-visible {
  outline: 3px solid var(--zone);
  outline-offset: 2px;
  background: rgb(255 103 9 / 18%);
  opacity: 1;
}

.hotspot::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--zone);
  box-shadow: 0 0 0 5px rgb(255 103 9 / 20%);
  opacity: 0.86;
  transform: scale(0.9);
  animation: hotspot-dot 2.8s ease-in-out infinite;
  animation-delay: var(--hotspot-delay, 0ms);
}

.hotspot:hover::after,
.hotspot:focus-visible::after {
  opacity: 1;
  transform: scale(1);
}

@keyframes hotspot-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgb(255 255 255 / 64%),
      0 0 0 3px rgb(255 103 9 / 10%),
      0 10px 26px rgb(255 103 9 / 10%);
  }

  52% {
    box-shadow:
      inset 0 0 0 1px rgb(255 255 255 / 78%),
      0 0 0 8px rgb(255 103 9 / 14%),
      0 12px 34px rgb(255 103 9 / 16%);
  }
}

@keyframes hotspot-dot {
  0%,
  100% {
    box-shadow: 0 0 0 5px rgb(255 103 9 / 20%);
  }

  52% {
    box-shadow: 0 0 0 10px rgb(255 103 9 / 0%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen-image,
  .hotspot-layer,
  .hotspot,
  .hotspot::after,
  .resize-handle,
  .prototype-controls button {
    transition: none;
    animation: none;
  }
}

.manager-toggle {
  position: fixed;
  z-index: 30;
  top: 16px;
  left: 16px;
  min-height: 38px;
  border: 1px solid #cfd7df;
  border-radius: 999px;
  padding: 0 15px;
  background: #fff;
  color: #17202a;
  box-shadow: 0 12px 32px rgb(24 34 45 / 14%);
  cursor: pointer;
}

body.is-editing .manager-toggle {
  display: none;
}

.manager-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid #d8dee7;
  background: #fff;
  box-shadow: 12px 0 40px rgb(24 34 45 / 8%);
}

.manager-panel[hidden] {
  display: none;
}

.manager-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #edf1f5;
}

.manager-header-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.manager-eyebrow {
  margin: 0 0 3px;
  color: #6b7888;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.manager-header h1 {
  margin: 0;
  color: #111827;
  font-size: 22px;
  line-height: 1.1;
}

.manager-header button,
.section-heading button,
.manager-actions button,
.small-button {
  min-height: 32px;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: #26323f;
  cursor: pointer;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid #cfd7df;
  border-radius: 999px;
  background: #f7f9fb;
}

.mode-switch button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0 11px;
  background: transparent;
  color: #52606f;
}

.mode-switch button[aria-pressed="true"] {
  background: #2f6fed;
  color: #fff;
  box-shadow: 0 4px 14px rgb(47 111 237 / 18%);
}

.manager-header button:hover,
.section-heading button:hover,
.manager-actions button:hover,
.small-button:hover {
  border-color: var(--focus);
  color: var(--focus);
}

.mode-switch button[aria-pressed="true"]:hover {
  color: #fff;
}

.manager-scroll {
  height: calc(100vh - 76px);
  overflow: auto;
  padding: 16px;
}

.manager-section {
  padding: 0 0 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
  color: #17202a;
  font-size: 15px;
}

.section-heading span {
  color: #6b7888;
  font-size: 12px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.screen-list,
.hotspot-list,
.hotspot-editor,
.screen-editor {
  display: grid;
  gap: 8px;
}

.screen-editor {
  margin-top: 8px;
}

.screen-item,
.zone-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #dce3ec;
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.screen-item .small-button,
.zone-item .small-button {
  width: 100%;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.screen-item.is-active,
.zone-item.is-selected {
  border-color: var(--focus);
  background: #f3f7ff;
}

.screen-title,
.zone-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #17202a;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-meta,
.zone-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #6b7888;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 4px;
}

.icon-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #cfd7df;
  border-radius: 7px;
  padding: 0;
  background: #fff;
  color: #26323f;
  cursor: pointer;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border: 1px solid #dce3ec;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.field-grid label {
  display: grid;
  gap: 5px;
  color: #52606f;
  font-size: 12px;
  font-weight: 700;
}

.field-grid label.full {
  grid-column: 1 / -1;
}

.field-grid input,
.field-grid select,
#configData {
  width: 100%;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  padding: 8px 9px;
  background: #fff;
  color: #17202a;
  font: inherit;
  font-size: 13px;
}

.field-note {
  margin: -2px 0 0;
  color: #6b7888;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

.field-note.full {
  grid-column: 1 / -1;
}

.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field-actions button {
  min-height: 32px;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: #26323f;
  cursor: pointer;
}

.field-actions button:hover {
  border-color: var(--focus);
  color: var(--focus);
}

.field-grid input:focus,
.field-grid select:focus,
#configData:focus {
  border-color: var(--focus);
  outline: 3px solid rgb(47 111 237 / 16%);
}

#configData {
  min-height: 150px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.manager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.manager-status {
  min-height: 18px;
  margin: 8px 0 0;
  color: #52606f;
  font-size: 12px;
}

.prototype-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
}

.prototype-controls button {
  width: 9px;
  height: 9px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: #aab5c2;
  color: #26323f;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease;
}

.prototype-controls button:hover,
.prototype-controls button[aria-current="page"] {
  background: var(--focus);
  transform: scale(1.45);
}

.prototype-controls button:focus-visible {
  outline: 3px solid rgb(47 111 237 / 28%);
  outline-offset: 4px;
}

@media (max-width: 480px) {
  .app-layout.manager-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .manager-panel {
    position: fixed;
    z-index: 25;
    inset: 0 auto 0 0;
    width: min(92vw, 360px);
  }

  .prototype-shell {
    padding: 10px;
  }

  .desktop-frame {
    border-radius: 9px;
  }

  .window-toolbar {
    height: 28px;
    padding-inline: 10px;
  }

  .window-toolbar span {
    width: 8px;
    height: 8px;
  }
}
