/* ---------- plue studio: one mac window, a real 1280px page, five agents ----------
   Loaded before studio.js. Every rule is scoped to .cv-win / .ag / .ag-sel (and the studio-only
   helpers inside them), so nothing here can reach the lab shell. The rules are written a notch
   more specific than the shell's old try.css window so the studio wins where they overlap.
   House style: near-black chrome, hairline edges, mono for chrome, one violet glow in the dark.
   Nothing bounces, nothing overshoots, nothing scales from zero; every transition is under 240ms
   except the cursor travel (which is a rAF lerp, not a transition). */

/* ---------- the frame ---------- */
/* --s is written by studio.js from the free space in #studio-canvas: s = min(w/1280, h/800) */
.cv-win {
  --s: .6;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: var(--font-sans, "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif);
  --bar: 32px;
  --foot: 26px;
  position: relative;
  flex: none;
  align-self: center;
  width: calc(1280px * var(--s));
  border-radius: 12px;
  overflow: hidden;
  background: #0a0a0b;
  box-shadow: 0 0 0 1px #ffffff1f, 0 26px 70px -28px #000, 0 0 110px -48px #8657e7;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .5s ease, transform .6s cubic-bezier(.22, 1, .36, 1), box-shadow .4s ease, visibility 0s .5s;
}
.cv-win, .cv-win *, .cv-win *::before, .cv-win *::after { box-sizing: border-box; }
.cv-win.is-in { opacity: 1; visibility: visible; transform: none; transition: opacity .45s ease, transform .55s cubic-bezier(.22, 1, .36, 1), box-shadow .4s ease; }
.cv-win.is-done { box-shadow: 0 0 0 1px #ffffff2b, 0 26px 70px -28px #000, 0 0 130px -40px #a855f7; }
.cv-win.is-error { box-shadow: 0 0 0 1px #f8717199, 0 26px 70px -28px #000, 0 0 100px -50px #f87171; }

/* ---------- title bar ---------- */
.cv-win .cv-win__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--bar);
  padding: 0 10px 0 12px;
  background: #141416;
  box-shadow: inset 0 -1px 0 #ffffff0f;
}
.cv-win .cv-win__bar > i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #2c2c31; box-shadow: inset 0 0 0 1px #ffffff14; }
.cv-win .cv-win__bar > i:nth-child(1) { background: #f65f57; }
.cv-win .cv-win__bar > i:nth-child(2) { background: #f7bd45; }
.cv-win .cv-win__bar > i:nth-child(3) { background: #2ac63f; }
.cv-win .cv-win__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font: 500 11.5px/1 var(--mono);
  letter-spacing: .01em;
  color: #ffffff8c;
}
.cv-win .cv-win__badge {
  flex: none;
  height: 18px;
  padding: 0 7px;
  border-radius: 5px;
  background: #ffffff0f;
  box-shadow: inset 0 0 0 1px #ffffff1a;
  font: 500 9.5px/18px var(--mono);
  letter-spacing: .03em;
  color: #a7f3c4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: color .2s ease, background .2s ease;
}
.cv-win .cv-win__badge.is-warn { color: #fbbf24; background: #fbbf2414; }

/* ---------- the page, at 1280 x 800, scaled to fit ---------- */
.cv-win .cv-win__view {
  position: relative;
  overflow: hidden;
  width: calc(1280px * var(--s));
  height: calc(800px * var(--s));
  background: #0a0a0b;
  contain: layout paint;
}
.cv-win .cv-win__scroll {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cv-win .cv-win__scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
.cv-win .page {
  --g: #0d0f12;
  --ink: #f2f4f7;
  --acc: #e8562a;
  --font-d: "Instrument Sans", system-ui, sans-serif;
  --r-md: 10px;
  position: relative;
  width: 1280px;
  min-height: 800px;
  margin: 0;
  /* the page is laid out unscaled and then scaled: the negative bottom margin takes the same
     800 * (1 - s) pixels back off the scroller, so the scroll range matches what is on screen */
  margin-bottom: calc(-800px * (1 - var(--s)));
  transform: scale(var(--s));
  transform-origin: 0 0;
  background: var(--g);
  color: var(--ink);
  font-family: var(--font-d), var(--sans);
  font-size: 16px;
  line-height: 1.5;
  transition: background-color .22s ease, color .22s ease;
  will-change: transform;
}
.cv-win .page img, .cv-win .page svg, .cv-win .page canvas, .cv-win .page video { max-width: 100%; }
.cv-win .page :focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* the agents' layer: clipped by the window, never in the way of the pointer */
.cv-win .cv-win__fx { position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }

/* ---------- the foot: presence, the action line, the MCP hint ---------- */
.cv-win .cv-win__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--foot);
  padding: 0 10px;
  background: #101012;
  box-shadow: inset 0 1px 0 #ffffff0d;
  font: 500 10px/1 var(--mono);
  color: #ffffff59;
}
.cv-win .cv-win__who { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cv-win .cv-win__dots { display: flex; flex: none; padding-left: 2px; }
.cv-win .cv-win__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1.5px #101012;
  opacity: .38;
  transition: opacity .2s ease, transform .2s ease;
}
.cv-win .cv-win__dot + .cv-win__dot { margin-left: -2px; }
.cv-win .cv-win__dot.is-on { opacity: 1; transform: translateY(-.5px); }
.cv-win .cv-win__do {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff80;
  opacity: 1;
  transition: opacity .16s ease;
}
.cv-win .cv-win__do.is-out { opacity: 0; }
.cv-win .cv-win__qa { display: flex; flex: none; gap: 6px; overflow: hidden; }
.cv-win .cv-win__check { font: 500 9px/1 var(--mono); color: #4ade80; white-space: nowrap; letter-spacing: .02em; }
.cv-win .cv-win__check.is-warn { color: #fbbf24; }
.cv-win .cv-win__mcp { display: flex; flex: none; align-items: center; gap: 7px; color: #ffffff42; }
.cv-win .cv-win__mcp-t { white-space: nowrap; }
.cv-win .cv-win__copy {
  flex: none;
  height: 16px;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  background: #ffffff0f;
  box-shadow: inset 0 0 0 1px #ffffff1a;
  font: 500 9px/16px var(--mono);
  letter-spacing: .03em;
  color: #ffffff8c;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.cv-win .cv-win__copy:hover { background: #ffffff1f; color: #fff; }
.cv-win .cv-win__copy:focus-visible { outline: 2px solid #b18cff; outline-offset: 2px; }
.cv-win .cv-win__copy.is-ok { color: #4ade80; }

/* ---------- the hint, before the first build ---------- */
.cv-win .cv-win__hint {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: var(--bar);
  height: calc(800px * var(--s));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  text-align: center;
  font: 500 12px/1.6 var(--mono);
  color: #ffffff40;
  pointer-events: none;
  transition: opacity .3s ease, visibility 0s .3s;
}
.cv-win.is-in .cv-win__hint { opacity: 0; visibility: hidden; }

/* ---------- the plan strip ---------- */
.cv-win .cv-win__plan {
  position: absolute;
  z-index: 6;
  left: 10px;
  bottom: calc(var(--foot) + 10px);
  width: max-content;
  max-width: calc(100% - 20px);
  padding: 8px 11px 9px;
  border-radius: 10px;
  background: #0b0b0df2;
  box-shadow: inset 0 0 0 1px #ffffff1a, 0 18px 44px -22px #000;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font: 500 10.5px/1.45 var(--mono);
  color: #ffffff99;
  transition: padding .2s ease;
}
.cv-win .cv-win__plan[hidden] { display: none; }
.cv-win .cv-win__plan-line {
  display: flex;
  gap: 5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s ease, transform .22s ease;
}
.cv-win .cv-win__plan-line.is-in { opacity: 1; transform: none; }
.cv-win .cv-win__plan-line b { flex: none; font-weight: 500; color: #b39bff; }
.cv-win .cv-win__plan-line span { overflow: hidden; text-overflow: ellipsis; }
.cv-win .cv-win__dials { display: flex; gap: 10px; margin-top: 7px; padding-top: 7px; box-shadow: inset 0 1px 0 #ffffff12; }
.cv-win .cv-win__dial { display: flex; align-items: center; gap: 5px; font: 500 9px/1 var(--mono); color: #ffffff59; }
.cv-win .cv-win__dial i { display: flex; gap: 1.5px; }
.cv-win .cv-win__dial em { width: 3px; height: 7px; border-radius: 1px; background: #ffffff1a; }
.cv-win .cv-win__dial em.is-on { background: #a78bfa; }
.cv-win .cv-win__plan.is-done { padding: 6px 10px 7px; color: #ffffff80; }

/* ---------- the agents ---------- */
/* one .ag per designer: the /teams Figma arrow (16x20 path, 18x22, white 1.4 stroke) and a pill */
.cv-win .ag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  opacity: 0;
  transition: opacity .2s ease;
  will-change: transform;
  pointer-events: none;
}
.cv-win .ag.is-in { opacity: 1; }
.cv-win .ag svg { display: block; width: 18px; height: 22px; filter: drop-shadow(0 1px 1.5px #00000066); }
.cv-win .ag__name {
  margin-top: 16px;
  margin-left: 1px;
  padding: 0 7px;
  height: 16px;
  border-radius: 99px;
  background: var(--c);
  color: #fff;
  font: 500 11px/16px var(--sans);
  letter-spacing: -.01em;
  box-shadow: 0 2px 8px -2px #000000a6, inset 0 0 0 1px #ffffff24;
  white-space: nowrap;
}

/* ---------- the selection box ---------- */
.cv-win .ag-sel {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 7;
  border: 1.5px solid var(--c);
  border-radius: 2px;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
  will-change: transform;
}
.cv-win .ag-sel.is-on { opacity: 1; }
.cv-win .ag-sel.is-off { opacity: 0; }
.cv-win .ag-sel > i {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fff;
  border: 1.5px solid var(--c);
  border-radius: 1px;
  box-shadow: 0 1px 2px #00000040;
}
.cv-win .ag-sel > i:nth-child(1) { left: -4.5px; top: -4.5px; }
.cv-win .ag-sel > i:nth-child(2) { right: -4.5px; top: -4.5px; }
.cv-win .ag-sel > i:nth-child(3) { left: -4.5px; bottom: -4.5px; }
.cv-win .ag-sel > i:nth-child(4) { right: -4.5px; bottom: -4.5px; }
.cv-win .ag-sel__tag {
  position: absolute;
  left: -1.5px;
  bottom: calc(100% + 5px);
  max-width: 220px;
  padding: 0 5px;
  height: 15px;
  border-radius: 3px;
  background: var(--c);
  color: #fff;
  font: 500 9.5px/15px var(--mono);
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 8px -3px #000000a6;
}
.cv-win .ag-sel__tag:empty { display: none; }
.cv-win .ag-sel__dim {
  position: absolute;
  left: 50%;
  bottom: -19px;
  transform: translateX(-50%);
  padding: 0 4px;
  height: 14px;
  border-radius: 3px;
  background: var(--c);
  color: #fff;
  font: 500 9px/14px var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  white-space: nowrap;
  box-shadow: 0 2px 8px -3px #000000a6;
}
.cv-win .ag-sel.is-flip .ag-sel__tag { bottom: auto; top: calc(100% + 5px); }
.cv-win .ag-sel.is-low .ag-sel__dim { bottom: auto; top: calc(100% + 5px); }

/* ---------- what the agents touch ---------- */
/* non-destructive: an inset ring in the agent's colour, drawn as an outline so no page rule loses
   its own box-shadow while a designer is holding the element */
.cv-win .page .ag-target,
.cv-win .page.ag-target { outline: 1.5px solid var(--ag-c, #fff); outline-offset: -1.5px; }
.cv-win .page .is-fresh,
.cv-win .page.is-fresh { animation: cv-fresh .7s ease-out both; }
@keyframes cv-fresh {
  0% { filter: brightness(1.2) saturate(1.06); }
  100% { filter: none; }
}

/* the QA pass: a guide at the simulated viewport width, purely cosmetic (no reflow) */
.cv-win .page.qa-narrow::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background:
    linear-gradient(90deg,
      transparent 0 calc(var(--qa-w, 100%) - 1.5px),
      #0d99ffb3 calc(var(--qa-w, 100%) - 1.5px) var(--qa-w, 100%),
      #00000047 var(--qa-w, 100%) 100%);
}

/* ---------- narrow screens: the chrome gives up its least important parts first ---------- */
@media (max-width: 760px) {
  .cv-win .cv-win__mcp-t { display: none; }
  .cv-win .cv-win__qa { display: none; }
  .cv-win .cv-win__foot { gap: 7px; }
}
@media (max-width: 480px) {
  .cv-win .cv-win__badge { display: none; }
}

/* ---------- reduced motion: nothing moves that does not have to ---------- */
@media (prefers-reduced-motion: reduce) {
  .cv-win, .cv-win.is-in, .cv-win .cv-win__hint, .cv-win .cv-win__do,
  .cv-win .ag, .cv-win .ag-sel, .cv-win .cv-win__plan, .cv-win .cv-win__plan-line,
  .cv-win .cv-win__dot, .cv-win .cv-win__copy, .cv-win .cv-win__badge,
  .cv-win .page { transition: none; }
  .cv-win .page .is-fresh { animation: none; }
  .cv-win .cv-win__plan-line { transform: none; }
}
