/* Page, agent layer and canvas world. Paper's own tokens live in paper-ui.css (--pui-*). */

:root {
  color-scheme: light;
  --page: lab(94.2188% -1.42306 5.34524);
  --page-plane: lab(91.6% -1.6 5.6);
  --page-line: lab(84% -1.5 5);
  --page-ink: #1d1d1b;
  --page-ink-2: #77756e;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --mono: "Geist Mono", ui-monospace, monospace;
  --deck-h: 92px;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  overflow: hidden;
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
}

/* ---------- Page ---------- */
.pd-backdrop { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pd-stage { position: fixed; inset: 0 0 var(--deck-h) 0; }
body.is-clean .pd-stage { bottom: 0; }
/* Centred absolutely so the window stays centred even when the frame is narrower than 1322px */
.pd-fit { position: absolute; left: 50%; top: 50%; width: 1322px; height: 720px; transform: translate(-50%, -50%) scale(var(--fit, 1)); transform-origin: center; }
.hero-image { width: 1322px !important; height: 720px; aspect-ratio: auto !important; }
.pui { color-scheme: light; }
#pd-app { isolation: isolate; }

/* ---------- Right column: tabs ---------- */
.pd-tabs {
  display: flex;
  align-items: stretch;
  gap: 16px;
  height: 32px;
  flex-shrink: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--pui-hairline);
}
.pd-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--pui-text-tertiary);
  cursor: default;
  transition: color 150ms;
}
.pd-tab[aria-selected="true"] { color: var(--pui-text); }
.pd-tab:hover { color: var(--pui-text-secondary); }
.pd-tab[aria-selected="true"]:hover { color: var(--pui-text); }
.pd-tab:focus-visible { outline: 2px solid var(--pui-agent); outline-offset: 2px; border-radius: 3px; }
.pd-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: clip; }
#pd-agent { display: none; }
#pd-app[data-mode="agent"] #pd-inspector { display: none; }
#pd-app[data-mode="agent"] #pd-agent { display: flex; }

/* ---------- Switch placements (one visible at a time) ---------- */
.pd-sw { display: none; }
#pd-app[data-switch="1"] .pd-sw[data-variant="1"],
#pd-app[data-switch="2"] .pd-sw[data-variant="2"],
#pd-app[data-switch="3"] .pd-sw[data-variant="3"],
#pd-app[data-switch="5"] .pd-sw[data-variant="5"] { display: flex; }
#pd-app[data-switch="4"] .pd-sw[data-variant="4"] { display: flex; }

/* shared run badge: crew dots, thinking, waiting on you */
.pd-sw-badge { display: inline-flex; align-items: center; }
.pd-sw-badge:empty { display: none; }
.pd-sw-badge i {
  width: 7px; height: 7px;
  border-radius: 99px;
  background: var(--c);
  box-shadow: 0 0 0 1.5px var(--pui-chrome);
  margin-left: -2px;
  animation: pd-pop 300ms var(--ease-spring) both;
}
.pd-sw-badge i:first-child { margin-left: 0; }
.pd-sw-badge b { width: 6px; height: 6px; border-radius: 99px; background: var(--pui-agent); }
.pd-sw-badge b.is-think { animation: pd-think 1.2s ease-in-out infinite; }
.pd-sw-badge b.is-alert { background: #e3871c; animation: pd-ring 1.4s ease-out infinite; --c: #e3871c; }
@keyframes pd-think { 50% { opacity: 0.3; } }

/* 2 + 3: segmented pills */
.pd-sw-pill {
  align-items: center;
  gap: 0;
  height: 26px;
  padding: 2px;
  border-radius: 7px;
  corner-shape: superellipse(1.3);
  background: var(--pui-track);
}
.pd-sw-pill .pd-sw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 22px; min-width: 64px; padding: 0 10px;
  border: 0; border-radius: 5px; corner-shape: superellipse(1.3);
  background: none;
  font: inherit; font-weight: 500; letter-spacing: -0.084px;
  color: var(--pui-text-tertiary);
  transition: color 150ms, background 150ms, box-shadow 150ms;
}
.pd-sw-pill .pd-sw-btn[data-active="true"] { background: var(--pui-segment-active); box-shadow: var(--pui-shadow-thumb); color: var(--pui-text); }
.pd-sw-pill .pd-sw-btn:focus-visible { outline: 2px solid var(--pui-agent); outline-offset: 1px; }
.pd-sw-float {
  position: absolute; z-index: 25; top: 12px; left: 50%;
  transform: translateX(-50%);
  background: var(--pui-chrome);
  box-shadow: 0 0 0 1px #0000000d, 0 1px 2px #0000000f, 0 6px 16px -8px #00000026;
}
.pd-sw-top { margin-left: auto; }

/* 4: the agent as a tool in the left rail */
.pd-sw-rail { flex-direction: column; align-items: center; }
.pd-rail-div { width: 16px; height: 1px; margin: 6px 0; background: var(--pui-rail-divider); }
.pd-rail-btn {
  position: relative; isolation: isolate;
  display: grid; place-items: center;
  width: 40px; height: 36px; padding: 0;
  border: 0; background: none;
}
.pd-rail-hi { position: absolute; left: 4px; right: 4px; top: 2px; bottom: 2px; border-radius: 7.5px; z-index: -1; background: var(--pui-tool-active); box-shadow: var(--pui-shadow-control); opacity: 0; transition: opacity 150ms; }
.pd-rail-btn[data-active="true"] .pd-rail-hi { opacity: 1; }
.pd-rail-btn:focus-visible { outline: 2px solid var(--pui-agent); outline-offset: -3px; border-radius: 8px; }
.pd-rail-btn .pd-sw-badge { position: absolute; top: 5px; right: 6px; }
.pd-rail-btn .pd-sw-badge i { width: 6px; height: 6px; margin-left: -3px; }
#pd-app[data-switch="4"][data-mode="agent"] .pd-select-hi { opacity: 0; }
.pd-select-hi { transition: opacity 150ms; }

/* 5: a dock on the canvas that narrates the run */
.pd-sw-dock {
  position: absolute; z-index: 25; bottom: 14px; left: 50%;
  transform: translateX(-50%);
  align-items: center; gap: 2px;
  height: 36px; padding: 3px;
  border-radius: 10px; corner-shape: superellipse(1.3);
  background: var(--pui-chrome);
  box-shadow: 0 0 0 1px #0000000d, 0 1px 2px #0000000f, 0 10px 24px -10px #00000033;
}
.pd-sw-dock .pd-sw-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 0; border-radius: 7px; corner-shape: superellipse(1.3);
  background: none;
  font: inherit; font-weight: 500;
  color: var(--pui-text-tertiary);
  transition: color 150ms, background 150ms, box-shadow 150ms;
}
.pd-sw-dock .pd-sw-btn[data-active="true"] { background: var(--pui-segment-active); box-shadow: var(--pui-shadow-thumb); color: var(--pui-text); }
.pd-sw-dock .pd-sw-btn:focus-visible { outline: 2px solid var(--pui-agent); outline-offset: 1px; }
.pd-dock-status {
  display: inline-block;
  max-width: 0; overflow: hidden; white-space: nowrap;
  color: var(--pui-text-tertiary); font-weight: 400;
  transition: max-width 400ms var(--ease-out);
}
.pd-dock-status.is-on { max-width: 120px; }
.pd-dock-status.is-on::before { content: "·"; margin-right: 6px; color: var(--pui-text-prefix); }

/* ---------- Faces: the dots ---------- */
.pd-face {
  --s: 16px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--s) * 0.16);
  flex-shrink: 0;
  width: var(--s);
  height: var(--s);
  border-radius: 99px;
  /* soft 3D: lit from the top left, shaded underneath, coloured shadow below */
  background: radial-gradient(120% 120% at 30% 22%,
    color-mix(in oklab, white 50%, var(--c)) 0%,
    var(--c) 46%,
    color-mix(in oklab, black 24%, var(--c)) 100%);
  box-shadow:
    inset 0 calc(var(--s) * -0.07) calc(var(--s) * 0.14) color-mix(in oklab, black 28%, var(--c)),
    inset 0 calc(var(--s) * 0.04) calc(var(--s) * 0.05) #ffffffa6,
    0 calc(var(--s) * 0.05) calc(var(--s) * 0.08) #00000024,
    0 calc(var(--s) * 0.2) calc(var(--s) * 0.42) calc(var(--s) * -0.1) color-mix(in oklab, var(--c) 60%, transparent);
  transition: transform 300ms var(--ease-spring), opacity 200ms;
}
.pd-face::before {
  content: "";
  position: absolute;
  left: 18%; top: 10%;
  width: 38%; height: 24%;
  border-radius: 50%;
  background: #fff;
  opacity: 0.5;
  filter: blur(calc(var(--s) * 0.035));
  rotate: -24deg;
  pointer-events: none;
}
.pd-face i {
  position: relative;
  box-shadow: 0 calc(var(--s) * 0.02) calc(var(--s) * 0.04) #0000002e;
  width: calc(var(--s) * 0.13);
  height: calc(var(--s) * 0.24);
  min-width: 2px;
  border-radius: 2px;
  background: #fff;
  transform-origin: center;
  transition: transform 200ms var(--ease-out), height 200ms, border-radius 200ms;
  animation: pd-blink 5.2s infinite;
  animation-delay: var(--blink, -1.3s);
}
@keyframes pd-blink { 0%, 94%, 100% { scale: 1 1; } 96% { scale: 1 0.15; } }
.pd-face[data-mood="work"] { animation: pd-hop 640ms var(--ease-out) infinite; }
.pd-face[data-mood="work"] i { transform: translateX(calc(var(--s) * 0.04)); }
.pd-face[data-mood="wait"] i { transform: translate(calc(var(--s) * -0.05), calc(var(--s) * -0.06)); }
.pd-face[data-mood="wait"] { animation: pd-breathe 2.4s ease-in-out infinite; }
.pd-face[data-mood="ask"] { transform: rotate(-12deg); }
.pd-face[data-mood="blocked"] i { scale: 1 0.3; animation: none; }
.pd-face[data-mood="blocked"] { animation: pd-shake 420ms ease-out 1; }
.pd-face[data-mood="happy"] i {
  height: calc(var(--s) * 0.14);
  background: transparent;
  border: 1.5px solid #fff;
  border-bottom: 0;
  border-radius: 99px 99px 0 0;
  width: calc(var(--s) * 0.22);
  animation: none;
}
.pd-face[data-mood="think"] i { transform: translate(calc(var(--s) * 0.06), calc(var(--s) * -0.06)); }
@keyframes pd-hop { 0%, 100% { translate: 0 0; } 40% { translate: 0 -18%; } }
@keyframes pd-breathe { 50% { scale: 0.92; } }
@keyframes pd-shake { 20% { translate: -2px 0; } 40% { translate: 2px 0; } 60% { translate: -1px 0; } 80% { translate: 1px 0; } }
@keyframes pd-pop { from { scale: 0.4; opacity: 0; } }

/* Collaborator stack: the lead + helpers join */
/* Paper's robot avatar is replaced by our agents, who join the stack when they work */
.pd-agent-slot { display: none; }
.pd-crew-av { width: 0; flex-shrink: 0; transition: width 400ms var(--ease-out); }
.pd-crew-av.is-in { width: 18px; }
.pd-crew-av .pd-face { --s: 22px; margin-left: -4px; outline: 2px solid var(--pui-chrome); opacity: 0; scale: 0.6; transition: opacity 300ms, scale 400ms var(--ease-spring); }
.pd-crew-av.is-in .pd-face { opacity: 1; scale: 1; }

/* ---------- Thread ---------- */
.pd-thread {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px);
}
.pd-thread-inner {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 12px 4px;
}
.pd-enter { animation: pd-enter 420ms var(--ease-out) both; }
@keyframes pd-enter { from { opacity: 0; translate: 0 6px; filter: blur(3px); } }

/* Idle: the lead introduces itself, then suggestions for the selection */
.pd-idle { display: flex; flex-direction: column; padding: 0 2px 10px; }
.pd-idle-intro { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; padding: 6px 0 28px; }
.pd-face-hero { grid-row: span 1; }
.pd-face-hero::after {
  /* contact shadow on the panel */
  content: "";
  position: absolute;
  left: 14%; right: 14%; bottom: -16%;
  height: 16%;
  border-radius: 50%;
  background: color-mix(in oklab, var(--c) 45%, transparent);
  filter: blur(3px);
  z-index: -1;
}
.pd-idle-intro { isolation: isolate; }
.pd-idle-name { display: flex; flex-direction: column; gap: 1px; }
.pd-idle-name b { font-weight: 500; font-size: 13px; line-height: 16px; }
.pd-idle-name span { font-size: 11px; line-height: 14px; color: var(--pui-text-tertiary); }
.pd-idle-copy { grid-column: 1 / -1; margin: 16px 0 0; color: var(--pui-text-secondary); line-height: 18px; text-wrap: pretty; }
.pd-idle-label { display: flex; align-items: center; gap: 5px; padding-bottom: 8px; color: var(--pui-text-prefix); }
.pd-sel { display: inline-flex; align-items: center; gap: 4px; color: var(--pui-text-tertiary); }
.pd-runs { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 2px; }
.pd-run {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--pui-text-secondary);
  cursor: default;
  transition: background 120ms, color 120ms;
}
.pd-run:hover { background: var(--pui-track); color: var(--pui-text); }
.pd-run:focus-visible { outline: 2px solid var(--pui-agent); outline-offset: -2px; }
.pd-run-ic { flex-shrink: 0; fill: none; stroke: var(--pui-icon-muted); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; transition: stroke 120ms; }
.pd-run:hover .pd-run-ic { stroke: var(--pui-agent); }
.pd-run span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-run em { font-style: normal; font-size: 11px; color: var(--pui-text-prefix); flex-shrink: 0; opacity: 0; translate: 4px 0; transition: opacity 150ms, translate 200ms var(--ease-out); }
.pd-run:hover em, .pd-run:focus-visible em { opacity: 1; translate: 0 0; }
.pd-run-extra { display: none; }
.pd-runs.is-more .pd-run-extra { display: block; }
.pd-more .pd-run { color: var(--pui-text-tertiary); }
.pd-more .pd-run-ic { transition: rotate 200ms var(--ease-out), stroke 120ms; }
.pd-runs.is-more .pd-more .pd-run-ic { rotate: 180deg; }

/* Messages */
.pd-msg { display: flex; gap: 8px; align-items: flex-start; }
.pd-msg img { width: 16px; height: 16px; border-radius: 99px; flex-shrink: 0; }
.pd-msg p { margin: 0; color: var(--pui-text); text-wrap: pretty; }
.pd-lead { display: flex; gap: 8px; align-items: flex-start; }
.pd-lead .pd-face { --s: 16px; }
.pd-lead-body { min-width: 0; display: flex; flex-direction: column; }
.pd-lead-body b { font-weight: 500; }
.pd-lead-status { color: var(--pui-text-tertiary); text-wrap: pretty; }
.pd-shimmer {
  background: linear-gradient(90deg, var(--pui-text-tertiary) 0 40%, var(--pui-text) 50%, var(--pui-text-tertiary) 60% 100%) 0 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pd-shimmer 2.2s linear infinite;
}
@keyframes pd-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Plan card */
.pd-card {
  border-radius: 8px;
  corner-shape: superellipse(1.3);
  background: var(--pui-control);
  box-shadow: var(--pui-shadow-control);
}
.pd-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 10px 6px; }
.pd-card-head b { font-weight: 500; }
.pd-card-head span { color: var(--pui-text-tertiary); white-space: nowrap; }
.pd-tasks { list-style: none; margin: 0; padding: 0 0 4px; }
.pd-task {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  column-gap: 8px;
  align-items: center;
  padding: 5px 10px;
}
.pd-task .pd-face { --s: 14px; z-index: 1; }
.pd-task-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-task-title small { font-size: 11px; color: var(--pui-text-tertiary); margin-left: 4px; }
.pd-task-tick {
  grid-column: 2 / 4;
  height: 0;
  overflow: hidden;
  font: 10.5px/14px var(--mono);
  color: var(--pui-text-tertiary);
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: height 300ms var(--ease-out);
}
.pd-task.has-tick .pd-task-tick { height: 14px; }
.pd-tick-text { display: inline-block; animation: pd-enter 300ms var(--ease-out) both; }
/* dependency rail between consecutive rows */
.pd-task[data-dep]::before {
  content: "";
  position: absolute;
  left: 16.5px;
  top: -12px;
  height: 22px;
  width: 0;
  border-left: 1px dashed var(--pui-mark-outline);
}
.pd-task[data-dep].is-unblocked::before { border-left-style: solid; border-color: var(--c); }
.pd-packet { position: absolute; left: 14.5px; width: 5px; height: 5px; border-radius: 99px; background: var(--c); z-index: 2; pointer-events: none; }

.pd-st { display: inline-flex; align-items: center; gap: 5px; color: var(--pui-text-tertiary); white-space: nowrap; }
.pd-st svg { flex-shrink: 0; }
.pd-st[data-s="work"] { color: var(--pui-text-secondary); }
.pd-st[data-s="ask"], .pd-st[data-s="blocked"] { color: var(--pui-text); font-weight: 500; }
.pd-st[data-s="accepted"] { color: var(--pui-text-secondary); }
.pd-spin { display: inline-flex; gap: 2px; }
.pd-spin i { width: 3px; height: 3px; border-radius: 99px; background: var(--c); animation: pd-spin 900ms ease-in-out infinite; }
.pd-spin i:nth-child(2) { animation-delay: 150ms; }
.pd-spin i:nth-child(3) { animation-delay: 300ms; }
@keyframes pd-spin { 0%, 100% { opacity: .25; translate: 0 0; } 40% { opacity: 1; translate: 0 -2px; } }
.pd-pulse { width: 7px; height: 7px; border-radius: 99px; background: var(--c); box-shadow: 0 0 0 0 var(--c); animation: pd-ring 1.4s ease-out infinite; }
@keyframes pd-ring { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--c) 60%, transparent); } 100% { box-shadow: 0 0 0 6px transparent; } }

.pd-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 34px; padding: 0 6px 0 10px; border-top: 1px solid var(--pui-hairline); color: var(--pui-text-tertiary); }
.pd-card-actions { display: flex; gap: 4px; }
.pd-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border: 0; border-radius: 5px; corner-shape: superellipse(1.3);
  background: transparent; color: var(--pui-text-secondary);
  font: inherit; font-weight: 500;
  transition: transform 150ms var(--ease-out), background 150ms;
}
.pd-btn:hover { background: var(--pui-track); }
.pd-btn-primary { background: var(--pui-text); color: #fff; }
.pd-btn-primary:hover { background: #000; }
.pd-btn.is-pressed { transform: scale(0.95); }
.pd-timer { font-variant-numeric: tabular-nums; }

/* Question card */
.pd-ask-card { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pd-ask-who { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.pd-ask-who .pd-face { --s: 14px; }
.pd-ask-who span { font-weight: 400; color: var(--pui-text-tertiary); }
.pd-ask-card p { margin: 0; color: var(--pui-text-secondary); text-wrap: pretty; }
.pd-opts { display: grid; gap: 4px; }
.pd-opt {
  display: flex; align-items: center; justify-content: space-between;
  height: 26px; padding: 0 8px;
  border: 0; border-radius: 5px; corner-shape: superellipse(1.3);
  background: var(--pui-chrome); box-shadow: inset 0 0 0 1px var(--pui-hairline);
  font: inherit; color: var(--pui-text); text-align: left;
  transition: background 150ms, box-shadow 150ms, transform 150ms var(--ease-out);
}
.pd-opt kbd { font: 10px/1 var(--mono); color: var(--pui-text-prefix); }
.pd-opt.is-hover { background: var(--pui-track); }
.pd-opt.is-chosen { box-shadow: inset 0 0 0 1.5px var(--c); }
.pd-opt.is-pressed { transform: scale(0.98); }
.pd-opts.is-done .pd-opt:not(.is-chosen) { opacity: 0.45; }

/* Inline notes (steer, scope) */
.pd-note { display: flex; gap: 8px; align-items: flex-start; color: var(--pui-text-secondary); }
.pd-note .pd-face { --s: 14px; margin-top: 1px; }
.pd-note b { font-weight: 500; color: var(--pui-text); }
.pd-note-mark { display: grid; place-items: center; width: 16px; height: 16px; flex-shrink: 0; color: var(--pui-text-tertiary); }

/* Summary */
.pd-summary { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.pd-summary b { font-weight: 500; }
.pd-summary span { color: var(--pui-text-tertiary); }

/* Composer */
.pd-composer { position: relative; padding: 18px 12px 12px; flex-shrink: 0; }
.pd-peek { position: absolute; right: 24px; top: 5px; height: 14px; width: 24px; display: flex; justify-content: center; overflow: hidden; }
.pd-peek .pd-face { translate: 0 3px; transition: translate 500ms var(--ease-out); }
.pd-composer.is-busy .pd-peek .pd-face { translate: 0 16px; }
.pd-composer:focus-within .pd-peek .pd-face { translate: 0 -1px; }
.pd-composer-box {
  position: relative;
  z-index: 1;
  border-radius: 8px;
  corner-shape: superellipse(1.3);
  background: var(--pui-control);
  box-shadow: var(--pui-shadow-control);
  padding: 8px 8px 6px 10px;
  transition: box-shadow 200ms;
}
.pd-composer-box textarea {
  display: block; width: 100%; resize: none; border: 0; outline: 0; padding: 0;
  background: transparent; color: var(--pui-text);
  font: inherit; font-size: 12px; line-height: 16px;
  user-select: text; -webkit-user-select: text;
}
.pd-composer-box textarea::placeholder { color: var(--pui-text-prefix); }
.pd-composer-box:focus-within, .pd-composer-box.is-focus { box-shadow: var(--pui-shadow-control), 0 0 0 2px color-mix(in oklab, var(--pui-agent) 35%, transparent); }
.pd-composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.pd-context { display: inline-flex; align-items: center; gap: 3px; color: var(--pui-text-tertiary); font-size: 11px; }
.pd-at { color: var(--pui-text-prefix); }
.pd-send {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border: 0; border-radius: 99px;
  background: var(--pui-text); color: #fff;
  transition: opacity 150ms, transform 150ms var(--ease-out);
}
.pd-send:disabled { opacity: 0.2; }
.pd-send.is-pressed { transform: scale(0.9); }
.pd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Canvas world ---------- */
.pd-camera { transform-origin: 0 0 !important; will-change: transform; }
.pd-section {
  position: absolute;
  border-radius: calc(10px * var(--inv, 1));
  background: #0000000a;
  box-shadow: inset 0 0 0 calc(1px * var(--inv, 1)) #0000000f;
  opacity: 0;
  transition: opacity 500ms;
}
.pd-section.is-on { opacity: 1; }
.pd-section-label {
  position: absolute;
  left: 0; bottom: 100%;
  transform: scale(var(--inv, 1));
  transform-origin: 0 100%;
  padding: 0 0 6px 2px;
  font: 500 12px/16px "Schibsted Grotesk", system-ui, sans-serif;
  color: var(--pui-text-secondary);
  white-space: nowrap;
}
.pd-board { position: absolute; }
.pd-board[data-state="hidden"] { display: none; }
.pd-board-label {
  position: absolute;
  left: 0; bottom: 100%;
  display: flex; align-items: center; gap: 6px;
  transform: scale(var(--inv, 1));
  transform-origin: 0 100%;
  padding-bottom: 4px;
  font: 400 11px/14px "Schibsted Grotesk", system-ui, sans-serif;
  color: var(--pui-text-tertiary);
  white-space: nowrap;
  max-width: calc(var(--bw) * 1px / var(--inv, 1));
}
.pd-board-label > span:not(.pd-board-chip) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pd-board-label canvas { display: none; width: 30px; height: 10px; }
.pd-board.is-live .pd-board-label canvas { display: block; }
.pd-board-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 16px; padding: 0 6px;
  border-radius: 99px;
  font-size: 10px; font-weight: 500;
  color: #fff;
  background: var(--c, var(--pui-agent));
  animation: pd-pop 300ms var(--ease-spring) both;
}
.pd-board-body {
  position: relative; width: 100%; height: 100%;
  transform: translateZ(0);
}
.pd-board:not([data-state="hidden"]) .pd-board-body { will-change: transform; }
.pd-board[data-state="ghost"] .pd-board-body,
.pd-board[data-state="building"] .pd-board-body { clip-path: inset(0 0 calc((1 - var(--p, 0)) * 100%) 0); }
.pd-board-ghost {
  position: absolute; inset: 0;
  border-radius: 2px;
  background: color-mix(in oklab, var(--c, #888) 5%, #fff 60%);
  outline: calc(1.25px * var(--inv, 1)) dashed color-mix(in oklab, var(--c, #888) 70%, transparent);
  opacity: 0;
  transition: opacity 300ms;
}
.pd-board[data-state="ghost"] .pd-board-ghost,
.pd-board[data-state="building"] .pd-board-ghost { opacity: 1; }
.pd-board[data-state="building"] .pd-board-body { z-index: 1; }
.pd-board-ring {
  position: absolute; inset: 0; z-index: 2;
  pointer-events: none;
  border-radius: 2px;
  box-shadow: 0 0 0 calc(1.5px * var(--inv, 1)) var(--ring, transparent);
  transition: box-shadow 300ms;
}
.pd-board-edge {
  position: absolute; left: 0; right: 0; z-index: 3;
  top: calc(var(--p, 0) * 100%);
  height: calc(2px * var(--inv, 1));
  background: var(--c);
  box-shadow: 0 0 calc(10px * var(--inv, 1)) calc(2px * var(--inv, 1)) color-mix(in oklab, var(--c) 45%, transparent);
  opacity: 0;
  transition: opacity 200ms;
}
.pd-board[data-state="building"] .pd-board-edge { opacity: 1; }
.pd-board.is-locked .pd-board-ring { box-shadow: 0 0 0 calc(1.5px * var(--inv, 1)) var(--c); }
.pd-board.is-wall .pd-board-ring { box-shadow: 0 0 0 calc(2px * var(--inv, 1)) #e5484d; animation: pd-wall 600ms ease-out 1; }
@keyframes pd-wall { 30% { box-shadow: 0 0 0 calc(6px * var(--inv, 1)) #e5484d44; } }
.pd-board.is-review .pd-board-ring { box-shadow: 0 0 0 calc(2px * var(--inv, 1)) var(--pui-agent); }

/* Race & pick: discarded takes fold into a stack */
.pd-board { transform-origin: 0 0; transition: transform 800ms var(--ease-out), opacity 500ms; }
.pd-board.is-discarded { transform: translate(calc(var(--dx) * 1px), calc(var(--dy) * 1px)) scale(0.42) rotate(var(--rot)); opacity: 0.7; }
.pd-board.is-discarded .pd-board-label { opacity: 0; }
.pd-board.is-discarded .pd-board-body { box-shadow: 0 calc(6px * var(--inv, 1)) calc(18px * var(--inv, 1)) -6px #0004; }
.pd-board.is-merged .pd-board-body { opacity: 0.45; transition: opacity 600ms; }

/* Branch & merge */
.pd-branch { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity 500ms; pointer-events: none; }
.pd-branch.is-on { opacity: 1; }
.pd-branch.is-merged { opacity: 0.45; }
.pd-branch svg { position: absolute; left: 0; top: 0; overflow: visible; }
.pd-branch path { fill: none; stroke: #4d94fb; stroke-width: 1.5; stroke-dasharray: 5 5; }
.pd-darknav { filter: invert(1) hue-rotate(180deg); transition: filter 700ms var(--ease-out); }
.pd-darknav img { filter: invert(1) hue-rotate(180deg); }
.pd-changes { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; color: var(--pui-text-secondary); }
.pd-changes li { display: flex; gap: 6px; }
.pd-changes li::before { content: "~"; font-family: var(--mono); color: #4d94fb; }
.pd-changes b { font-weight: 500; color: var(--pui-text); }
.pd-merge-actions { display: flex; justify-content: flex-end; gap: 4px; min-height: 22px; align-items: center; }
.pd-merged { display: inline-flex; align-items: center; gap: 4px; color: var(--pui-text-secondary); font-weight: 500; }

/* Critic loop: pins on the artboard */
.pd-pin { position: absolute; z-index: 4; display: flex; align-items: center; gap: 4px; transform: translate(-7px, -7px); pointer-events: none; animation: pd-pop 320ms var(--ease-spring) both; transition: opacity 300ms; }
.pd-pin i { display: grid; place-items: center; width: 14px; height: 14px; border-radius: 99px; background: #e5484d; color: #fff; font: 700 9px/1 Schibsted Grotesk, sans-serif; font-style: normal; box-shadow: 0 0 0 2px #fff, 0 2px 6px #0003; transition: background 300ms; }
.pd-pin span { padding: 2px 6px; border-radius: 6px; background: #e5484d; color: #fff; font: 600 10px/14px Schibsted Grotesk, sans-serif; white-space: nowrap; box-shadow: 0 2px 8px -2px #0004; transition: background 300ms; }
.pd-pin.is-ok i, .pd-pin.is-ok span { background: #1f9e74; }
.pd-pin.is-gone { opacity: 0; }

/* Watcher: what you selected by hand */
.pd-selected { outline: calc(1.5px * var(--inv, 1)) solid #4d94fb; outline-offset: 3px; border-radius: 2px; }

/* Dark variant: inverted clone, photos restored */
.pd-dark { filter: invert(1) hue-rotate(180deg) contrast(0.9); }
.pd-dark img { filter: invert(1) hue-rotate(180deg); }
.pd-ja, .pd-ja * { font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Schibsted Grotesk, sans-serif !important; }
.pd-caret::after { content: ""; display: inline-block; width: 2px; height: 0.9em; margin-left: 2px; vertical-align: -0.08em; background: var(--c); animation: pd-caret 900ms steps(1) infinite; }
@keyframes pd-caret { 50% { opacity: 0; } }

/* ---------- Overlay: cursors, wires, pointer ---------- */
.pd-overlay { position: absolute; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.pd-wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pd-wires path { fill: none; stroke-width: 1.25; stroke-linecap: round; stroke-dasharray: 2 5; animation: pd-flow 900ms linear infinite; }
@keyframes pd-flow { to { stroke-dashoffset: 7; } }
.pd-wires path.is-ask { stroke-dasharray: none; animation: pd-ask-wire 1.2s ease-in-out infinite; }
@keyframes pd-ask-wire { 50% { stroke-opacity: 0.25; } }
.pd-cur { position: absolute; left: 0; top: 0; will-change: transform; opacity: 0; transition: opacity 250ms; }
.pd-cur.is-on { opacity: 1; }
.pd-cur-tag { transition: opacity 200ms; }
.pd-cur.is-homing .pd-cur-tag { opacity: 0; }
.pd-cur .pd-face { --s: 18px; position: absolute; left: -9px; top: -9px; }
.pd-cur-tag {
  position: absolute; left: 13px; top: 6px;
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 7px;
  border-radius: 99px;
  background: var(--c);
  color: #fff;
  font-size: 11px; font-weight: 500; line-height: 18px;
  white-space: nowrap;
  box-shadow: 0 1px 2px #0002, 0 4px 10px -4px #0003;
}
.pd-cur-tag em { font-style: normal; opacity: 0.8; font-weight: 400; }
.pd-bubble {
  position: absolute; left: 12px; bottom: 12px;
  padding: 3px 7px;
  border-radius: 8px 8px 8px 2px;
  background: var(--pui-control);
  box-shadow: var(--pui-shadow-control), 0 6px 16px -6px #0003;
  color: var(--pui-text);
  font-size: 11px; line-height: 15px; font-weight: 500;
  white-space: nowrap;
  transform-origin: 0 100%;
  animation: pd-pop 300ms var(--ease-spring) both;
}
.pd-swatch-fly { position: absolute; left: 0; top: 0; width: 12px; height: 12px; margin: -6px; border-radius: 4px; box-shadow: 0 0 0 1.5px #fff, 0 2px 6px #0003; }
.pd-pointer { position: absolute; left: 0; top: 0; width: 20px; height: 20px; opacity: 0; transition: opacity 200ms; filter: drop-shadow(0 1px 1px #0003); }
.pd-pointer.is-on { opacity: 1; }
.pd-pointer svg { display: block; transition: transform 120ms var(--ease-out); transform-origin: 3px 3px; }
.pd-pointer.is-down svg { transform: scale(0.86); }
.pd-click { position: absolute; width: 26px; height: 26px; margin: -13px; border-radius: 99px; border: 1.5px solid var(--pui-agent); animation: pd-click 500ms var(--ease-out) forwards; }
@keyframes pd-click { from { scale: 0.3; opacity: 1; } to { scale: 1.3; opacity: 0; } }

/* ---------- Deck (outside the window) ---------- */
.pd-deck {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--deck-h);
  display: flex; align-items: center; justify-content: space-between; gap: 32px;
  padding: 0 max(24px, calc((100vw - 1322px * var(--fit, 1)) / 2));
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
  color: var(--page-ink);
  transition: opacity 300ms;
}
body.is-clean .pd-deck { opacity: 0; pointer-events: none; }
.pd-deck-copy { min-width: 0; flex: 1; }
.pd-deck-kicker { display: flex; align-items: baseline; gap: 10px; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.pd-deck-num { font: 500 12px/1 var(--mono); color: var(--page-ink-2); }
.pd-deck-caption { margin: 4px 0 0; font-size: 14px; line-height: 20px; color: var(--page-ink-2); max-width: 640px; min-height: 20px; }
.pd-deck-caption.pd-enter { animation-duration: 500ms; }
.pd-deck-controls { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.pd-chapters { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pd-chapter {
  display: flex; flex-direction: column; gap: 6px;
  width: 64px; padding: 0;
  border: 0; background: none;
  font: 500 10.5px/14px Schibsted Grotesk, sans-serif;
  color: var(--page-ink-2);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.pd-chapter[aria-current="step"] { color: var(--page-ink); }
.pd-chapter:focus-visible { outline: 2px solid var(--page-ink); outline-offset: 4px; border-radius: 2px; }
.pd-chapter > span { overflow: hidden; text-overflow: ellipsis; }
.pd-chapter-bar { position: relative; height: 3px; border-radius: 99px; background: #0000001a; overflow: hidden; }
.pd-chapter-bar i { position: absolute; inset: 0; transform-origin: 0 0; transform: scaleX(var(--prog, 0)); background: var(--page-ink); border-radius: inherit; }
.pd-play {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 0; border-radius: 99px;
  background: var(--page-ink); color: #fff;
  cursor: pointer;
  transition: transform 150ms var(--ease-out);
}
.pd-play:active { transform: scale(0.94); }
.pd-play .i-play { display: none; }
.pd-play.is-paused .i-play { display: block; }
.pd-play.is-paused .i-pause { display: none; }
body.is-paused * { animation-play-state: paused !important; }

/* ---------- States panel (outside the window) ---------- */
.pd-states-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 0; border-radius: 99px;
  background: #0000000d;
  color: var(--page-ink);
  font: 500 13px/1 Schibsted Grotesk, system-ui, sans-serif;
  cursor: pointer;
  transition: background 150ms;
}
.pd-states-btn:hover, .pd-states-btn[aria-expanded="true"] { background: #0000001a; }
.pd-states-btn:focus-visible, .pd-play:focus-visible { outline: 2px solid var(--page-ink); outline-offset: 2px; }
.pd-ctrl {
  position: fixed; z-index: 50;
  right: max(16px, calc((100vw - 1322px * var(--fit, 1)) / 2));
  bottom: calc(var(--deck-h) - 6px);
  width: 380px;
  padding: 4px 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 1px #0000000f, 0 1px 2px #0000000f, 0 18px 40px -16px #00000040;
  font: 12px/16px "Schibsted Grotesk", system-ui, sans-serif;
  color: #1d1d1b;
  animation: pd-enter 260ms var(--ease-out) both;
}
.pd-ctrl[hidden] { display: none; }
.pd-ctrl-sec { padding: 10px 14px; }
.pd-ctrl-sec + .pd-ctrl-sec { border-top: 1px solid #00000010; }
.pd-ctrl-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 500; color: #77756e; }
.pd-ctrl-now { font: 500 11px/16px var(--mono); color: #4d94fb; }
.pd-ctrl-switches { display: grid; gap: 2px; margin: 0 -6px; }
.pd-ctrl-switches button {
  display: grid; grid-template-columns: 12px 14px 1fr; align-items: center; gap: 8px;
  padding: 5px 6px;
  border: 0; border-radius: 6px; background: none;
  font: inherit; text-align: left; color: inherit;
  cursor: pointer;
}
.pd-ctrl-switches button:hover { background: #0000000a; }
.pd-ctrl-switches button:focus-visible { outline: 2px solid #4d94fb; outline-offset: -2px; }
.pd-ctrl-switches b { font: 500 11px/1 var(--mono); color: #a3a19a; }
.pd-sw-name { display: block; font-weight: 500; }
.pd-sw-note { display: block; color: #8b8981; font-size: 11px; }
.pd-radio { width: 12px; height: 12px; border-radius: 99px; box-shadow: inset 0 0 0 1px #00000033; transition: box-shadow 150ms; }
[aria-checked="true"] > .pd-radio { box-shadow: inset 0 0 0 4px #4d94fb; }
.pd-ctrl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pd-seg { display: inline-flex; padding: 2px; border-radius: 7px; background: #0000000d; }
.pd-seg button { height: 24px; padding: 0 12px; border: 0; border-radius: 5px; background: none; font: inherit; font-weight: 500; color: #77756e; cursor: pointer; }
.pd-seg button[aria-checked="true"] { background: #fff; color: #1d1d1b; box-shadow: 0 0 0 .5px #0000001a, 0 1px 2px #0000001a; }
.pd-next { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: #1d1d1b; color: #fff; font: inherit; font-weight: 500; cursor: pointer; transition: opacity 150ms, transform 150ms var(--ease-out); }
.pd-next:active { transform: scale(0.97); }
.pd-next:disabled { opacity: 0.25; cursor: default; }
.pd-next kbd { font: 10px/1 var(--mono); opacity: 0.6; }
.pd-graph svg { display: block; overflow: visible; }
.pd-graph line { stroke: #00000014; stroke-width: 1.5; }
.pd-graph line.is-seen { stroke: #4d94fb55; }
.pd-graph line.is-hot { stroke: #4d94fb; stroke-width: 2; }
.pd-node rect { fill: #fff; stroke: #0000001a; transition: fill 200ms, stroke 200ms; }
.pd-node text { font: 500 9px/1 var(--mono); fill: #a3a19a; text-anchor: middle; }
.pd-node.is-seen rect { stroke: #4d94fb66; }
.pd-node.is-seen text { fill: #4a4944; }
.pd-node.is-now rect { fill: #4d94fb; stroke: #4d94fb; }
.pd-node.is-now text { fill: #fff; }
.pd-loop { fill: none; stroke: #4d94fb; stroke-width: 1.5; animation: pd-think 900ms ease-in-out 2; }
.pd-log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; font: 11px/15px var(--mono); color: #8b8981; }
.pd-log li:first-child { color: #1d1d1b; }
.pd-log code { font: inherit; color: #4d94fb; }

@media (max-width: 900px) {
  :root { --deck-h: 132px; }
  .pd-deck { flex-direction: column; align-items: stretch; justify-content: center; gap: 12px; padding: 0 16px; }
  .pd-chapter { width: auto; flex: 1; }
  .pd-chapters { flex: 1; }
  .pd-chapter span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pd-face, .pd-face i, .pd-spin i, .pd-pulse, .pd-wires path, .pd-shimmer, .pd-enter, .pd-caret::after { animation: none !important; }
  .pd-shimmer { color: var(--pui-text-tertiary); background: none; }
}

/* ?bare: embedded in a page that draws its own frame */
body.is-bare { background: transparent; }
body.is-bare .pd-backdrop { display: none; }
body.is-bare .hero-image { box-shadow: none !important; border-radius: 0 !important; }
