/* Живая мастерская команды: одна спокойная редакционная сцена, а не сетка карточек. */
.team-studio {
  --studio-wall: color-mix(in srgb, var(--panel) 88%, var(--agent-soft));
  --studio-floor: color-mix(in srgb, var(--bg) 82%, var(--human-soft));
  --studio-line: color-mix(in srgb, var(--line) 76%, var(--agent));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
  color: var(--ink);
}

.agents-page {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.team-technical {
  margin-top: 26px;
  border-top: 1px solid var(--line);
}

.team-technical > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  color: var(--ink-3);
  cursor: pointer;
}

.team-technical > summary:focus-visible {
  outline: 3px solid var(--agent);
  outline-offset: 3px;
}

.team-technical-body {
  min-width: 0;
  padding-top: 14px;
}

.team-technical-intro {
  margin-bottom: 12px;
}

.studio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 2px 18px;
  border-bottom: 1px solid var(--line);
}

.studio-summary {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: baseline;
  gap: 10px 22px;
  flex-wrap: wrap;
}

.studio-summary h1,
.studio-summary h2,
.studio-summary p {
  margin: 0;
}

.studio-summary p {
  max-width: 66ch;
  color: var(--ink-2);
}

.studio-live-note {
  flex: 0 1 330px;
  min-width: 220px;
  padding: 8px 0 8px 13px;
  border-left: 3px solid var(--agent);
  color: var(--agent-ink);
  font-size: 12px;
  line-height: 1.45;
}

.studio-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 294px);
  align-items: stretch;
  width: 100%;
  min-width: 0;
  min-height: 520px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--studio-line);
  border-radius: 16px;
  background: var(--studio-wall);
}

/* Непрерывная «стена» и линия пола объединяют всю сцену. */
.studio-stage::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, transparent 0 68%, var(--studio-line) 68%, var(--studio-line) calc(68% + 1px), transparent calc(68% + 1px)),
    linear-gradient(to bottom, transparent 0 68%, color-mix(in srgb, var(--studio-floor) 78%, transparent) 68% 100%);
}

.studio-stage > * {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.studio-floor {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-content: end;
  align-items: end;
  gap: 22px 12px;
  min-width: 0;
  min-height: 518px;
  padding: 54px 26px 38px;
}

.studio-zone {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 208px;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 28px 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
}

.studio-zone::before {
  content: attr(aria-label);
  position: absolute;
  top: 0;
  left: 6px;
  max-width: calc(100% - 12px);
  overflow: hidden;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.studio-agent {
  appearance: none;
  position: relative;
  display: grid;
  width: min(100%, 164px);
  min-width: 0;
  min-height: 180px;
  grid-template-rows: 100px auto auto auto;
  justify-items: center;
  align-content: end;
  gap: 3px;
  padding: 10px 8px 12px;
  overflow: visible;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.studio-agent:hover {
  background: color-mix(in srgb, var(--agent-soft) 52%, transparent);
}

.studio-agent:focus-visible,
.studio-approver:focus-visible,
.review-sheet:focus-visible,
.replay-controls button:focus-visible,
.studio-inspector button:focus-visible,
.studio-inspector a:focus-visible {
  outline: 3px solid var(--agent);
  outline-offset: 3px;
}

.team-studio button,
.team-studio select {
  min-height: 44px;
}

.team-studio button:focus-visible,
.team-studio select:focus-visible,
.team-studio a:focus-visible,
.team-studio [tabindex]:focus-visible {
  outline: 3px solid var(--agent);
  outline-offset: 3px;
}

.studio-agent[disabled],
.studio-agent.state-disabled {
  cursor: default;
  opacity: 0.58;
}

.agent-figure {
  display: block;
  align-self: end;
  width: min(96px, 100%);
  height: 100px;
  max-width: 100%;
  overflow: visible;
  color: var(--ink-2);
}

.agent-figure [fill="currentColor"] {
  color: inherit;
}

.agent-tool {
  transform-box: fill-box;
  transform-origin: center;
}

.agent-name {
  max-width: 100%;
  overflow: hidden;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.agent-purpose {
  max-width: 100%;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.3;
}

.agent-state {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.25;
}

.agent-state::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-3);
}

.studio-agent.state-working .agent-figure,
.studio-agent.state-working .agent-state {
  color: var(--agent-ink);
}

.studio-agent.state-working .agent-state::before {
  background: var(--agent);
}

.studio-agent.state-working .agent-tool {
  animation: studio-tool-work 1.25s ease-in-out infinite alternate;
}

.studio-agent.state-waiting .agent-state,
.studio-agent.state-waiting-approval .agent-state {
  color: var(--human-ink);
}

.studio-agent.state-waiting .agent-state::before,
.studio-agent.state-waiting-approval .agent-state::before {
  background: var(--human);
}

.studio-agent.state-error .agent-state,
.studio-agent.state-blocked .agent-state {
  color: var(--err);
}

.studio-agent.state-error .agent-state::before,
.studio-agent.state-blocked .agent-state::before {
  background: var(--err);
}

.studio-agent.state-complete .agent-state {
  color: var(--ok);
}

.studio-agent.state-complete .agent-state::before {
  background: var(--ok);
}

.studio-approver {
  appearance: none;
  display: grid;
  min-width: 0;
  min-height: 132px;
  place-items: center;
  align-self: end;
  gap: 5px;
  padding: 16px 12px;
  border: 1px dashed var(--human);
  border-radius: 48% 48% 12px 12px / 22% 22% 12px 12px;
  background: color-mix(in srgb, var(--human-soft) 68%, var(--panel));
  color: var(--human-ink);
  text-align: center;
}

button.studio-approver {
  cursor: pointer;
}

.review-tray {
  align-self: stretch;
  min-width: 0;
  padding: 38px 24px 30px;
  border-left: 1px solid var(--studio-line);
  background: color-mix(in srgb, var(--panel) 76%, transparent);
}

.review-tray > h2,
.review-tray > h3,
.review-tray > p {
  margin: 0 0 12px;
}

.review-sheet {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 92px;
  margin-top: 10px;
  padding: 14px 14px 16px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-top: 3px solid var(--human);
  border-radius: 2px 2px 8px 8px;
  background: var(--panel);
  box-shadow: 5px 6px 0 color-mix(in srgb, var(--line-2) 78%, transparent);
  color: var(--ink);
}

button.review-sheet {
  min-height: 92px;
  text-align: left;
  cursor: pointer;
}

.review-sheet + .review-sheet {
  margin-top: 16px;
  margin-left: min(8px, 3%);
  width: calc(100% - min(8px, 3%));
}

.studio-inspector {
  display: grid;
  grid-template-columns: minmax(150px, 0.32fr) minmax(0, 1fr);
  gap: 16px 28px;
  min-width: 0;
  margin-top: 14px;
  padding: 18px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.studio-inspector h2,
.studio-inspector h3,
.studio-inspector p {
  margin-top: 0;
}

.studio-replay {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 14px 2px 2px;
}

.replay-controls {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.replay-controls button {
  min-width: 44px;
  min-height: 44px;
}

.replay-status {
  min-width: 0;
  color: var(--ink-3);
  font: 12px/1.4 var(--font-mono);
  overflow-wrap: anywhere;
}

.handoff-token {
  position: absolute;
  z-index: 8;
  left: var(--handoff-from-x, 50%);
  top: var(--handoff-from-y, 50%);
  display: grid;
  width: 28px;
  height: 22px;
  place-items: center;
  pointer-events: none;
  border: 1px solid var(--agent);
  border-radius: 3px;
  background: var(--panel);
  color: var(--agent-ink);
  box-shadow: 2px 3px 0 var(--agent-soft);
  font: 700 10px/1 var(--font-mono);
  opacity: 0;
}

.team-studio.replay-active .handoff-token,
.studio-floor.replay-active .handoff-token,
.handoff-token.is-moving {
  animation: studio-handoff 900ms cubic-bezier(0.28, 0.72, 0.28, 1) both;
}

.studio-agent.replay-from,
.studio-agent.replay-to,
.replay-from .agent-figure,
.replay-to .agent-figure {
  animation: studio-replay-highlight 900ms ease-out both;
}

@keyframes studio-tool-work {
  from { transform: translateY(1px) rotate(-2deg); }
  to { transform: translateY(-3px) rotate(3deg); }
}

@keyframes studio-arm-work {
  from { transform: rotate(-2deg); }
  to { transform: rotate(5deg); }
}

@keyframes studio-handoff {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
  }
  14%, 82% { opacity: 1; }
  100% {
    left: var(--handoff-to-x, 50%);
    top: var(--handoff-to-y, 50%);
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes studio-replay-highlight {
  0%, 100% { background: transparent; box-shadow: none; }
  35% { background: var(--agent-soft); box-shadow: inset 0 0 0 2px var(--agent); }
}

/*
 * Совместимость с разметкой компонента team-studio.ts. Компонент использует
 * BEM-имена, а публичный контракт стилей выше оставлен доступным для экранов.
 */
.team-studio__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  min-width: 0;
  padding: 2px 2px 18px;
  border-bottom: 1px solid var(--line);
}

.team-studio__heading {
  flex: 1 1 420px;
  min-width: 0;
}

.team-studio__heading h1,
.team-studio__heading p {
  margin: 0;
}

.team-studio__summary {
  max-width: 70ch;
  margin-top: 7px !important;
  color: var(--ink-2);
}

.team-studio__controls {
  display: flex;
  flex: 0 1 520px;
  min-width: 0;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.team-studio__task-field {
  display: grid;
  flex: 1 1 230px;
  min-width: 180px;
  gap: 4px;
  color: var(--ink-3);
  font-size: 11px;
}

.team-studio__task-select {
  width: 100%;
  max-width: 330px;
  min-width: 0;
  padding: 8px 34px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.team-studio__replay-button {
  flex: 0 0 auto;
}

.team-studio__replay-status {
  flex: 1 0 100%;
  min-width: 0;
  padding: 7px 0 0 12px;
  border-left: 3px solid var(--agent);
  color: var(--agent-ink);
  font: 11px/1.4 var(--font-mono);
  overflow-wrap: anywhere;
}

.team-studio__replay-status[hidden] {
  display: none;
}

.team-studio__scene {
  position: relative;
  width: calc(100% - 286px);
  max-width: 100%;
  min-width: 0;
  min-height: 680px;
  margin-top: 18px;
  overflow: visible;
  border: 1px solid var(--studio-line);
  border-radius: 16px;
  background:
    linear-gradient(to bottom, transparent 0 70%, var(--studio-line) 70%, var(--studio-line) calc(70% + 1px), transparent calc(70% + 1px)),
    linear-gradient(to bottom, var(--studio-wall) 0 70%, var(--studio-floor) 70% 100%);
}

.team-studio__scene::before,
.team-studio__scene::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.team-studio__scene::before {
  top: 34px;
  left: 50%;
  width: 116px;
  height: 70px;
  margin-left: -58px;
  border: 1px solid var(--line);
  border-bottom-width: 5px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(180deg, var(--agent-soft), color-mix(in srgb, var(--panel) 60%, var(--agent-soft)));
}

.team-studio__scene::after {
  right: 12%;
  bottom: 23%;
  width: 82px;
  height: 28px;
  border-top: 2px solid var(--studio-line);
  border-bottom: 2px solid var(--studio-line);
}

.team-studio__station {
  appearance: none;
  position: absolute;
  z-index: 3;
  left: var(--team-studio-x, 50%);
  top: var(--team-studio-y, 50%);
  display: grid;
  width: 148px;
  min-width: 0;
  min-height: 158px;
  margin-top: -74px;
  margin-left: -74px;
  grid-template-rows: 82px auto;
  gap: 2px;
  justify-items: center;
  padding: 5px 7px 9px;
  overflow: visible;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.team-studio__station:hover,
.team-studio__station.is-selected {
  border-color: color-mix(in srgb, var(--agent) 42%, transparent);
  background: color-mix(in srgb, var(--agent-soft) 64%, transparent);
}

.team-studio__station.is-selected {
  box-shadow: inset 0 0 0 1px var(--agent);
}

.team-studio__station.state-disabled {
  cursor: default;
  opacity: 0.58;
}

.team-studio__figure {
  display: block;
  width: 80px;
  height: 80px;
  overflow: visible;
  color: var(--ink-2);
}

.team-studio__head {
  fill: var(--panel);
  stroke: currentColor;
  stroke-width: 1.5;
}

.team-studio__body {
  fill: var(--agent-soft);
  stroke: currentColor;
  stroke-width: 1.5;
}

.team-studio__arm,
.team-studio__tool,
.team-studio__desk {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.team-studio__tool {
  transform-box: fill-box;
  transform-origin: center;
}

.team-studio__station-copy {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 2px;
  align-content: start;
}

.team-studio__station-name,
.team-studio__station-purpose,
.team-studio__station-state {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.team-studio__station-name {
  min-height: 30px;
  font-size: 12px;
  line-height: 1.2;
}

.team-studio__station-purpose {
  min-height: 28px;
  color: var(--ink-3);
  font-size: 10.5px;
  line-height: 1.25;
}

.team-studio__station-state {
  min-height: 17px;
  color: var(--ink-2);
  font-size: 10px;
  line-height: 1.25;
}

.team-studio__station.state-working .team-studio__figure,
.team-studio__station.state-working .team-studio__station-state {
  color: var(--agent-ink);
}

.team-studio__station.state-working .team-studio__tool {
  animation: studio-tool-work 1.25s ease-in-out infinite alternate;
}

.team-studio__station.state-working .team-studio__arm--working {
  transform-box: fill-box;
  transform-origin: left center;
  animation: studio-arm-work 0.7s ease-in-out infinite alternate;
}

.team-studio__station.state-received .team-studio__station-state {
  color: var(--agent-ink);
}

.team-studio__station.state-blocked .team-studio__station-state,
.team-studio__station.state-error .team-studio__station-state {
  color: var(--err);
}

.team-studio__station.state-blocked .team-studio__body,
.team-studio__station.state-error .team-studio__body {
  fill: var(--err-soft);
}

.team-studio__approval-tray {
  position: absolute;
  z-index: 4;
  top: 76px;
  left: calc(100% + 20px);
  display: flex;
  width: 266px;
  min-width: 0;
  min-height: 500px;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px;
  border-left: 1px solid var(--studio-line);
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.team-studio__approver {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 11px;
  padding-bottom: 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--human) 52%, var(--line));
  color: var(--human-ink);
}

.team-studio__approver-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: none;
  place-items: center;
  border: 1px solid var(--human);
  border-radius: 50%;
  background: var(--human-soft);
}

.team-studio__approver span {
  display: block;
  font-size: 11px;
}

.team-studio__review-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}

.team-studio__review-sheet {
  appearance: none;
  width: calc(100% - (var(--review-index, 0) * 5px));
  min-width: 0;
  min-height: 86px;
  margin-left: calc(var(--review-index, 0) * 5px);
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--human);
  border-radius: 2px 2px 8px 8px;
  background: var(--panel);
  box-shadow: 4px 5px 0 var(--line-2);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.team-studio__review-sheet span,
.team-studio__review-sheet time {
  display: block;
}

.team-studio__review-sheet span {
  font-weight: 600;
}

.team-studio__review-sheet time,
.team-studio__review-more,
.team-studio__review-empty {
  margin-top: 5px;
  color: var(--ink-3);
  font: 10px/1.35 var(--font-mono);
}

.team-studio__review-action {
  width: 100%;
  margin-top: auto;
  justify-content: center;
}

.team-studio__replay-line {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.team-studio__last-line {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.team-studio__last-line line {
  stroke: var(--human);
  stroke-width: 1.5;
  stroke-dasharray: 3 7;
  opacity: 0;
}

.team-studio.has-last-route:not(.is-replaying) .team-studio__last-line line {
  opacity: 0.42;
}

.team-studio__last-token {
  position: absolute;
  z-index: 3;
  display: block;
  width: 22px;
  height: 17px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--human);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: 2px 2px 0 var(--human-soft);
  pointer-events: none;
}

.team-studio__last-token::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-top: 1px solid var(--human);
  border-bottom: 1px solid var(--human);
}

.team-studio__last-token[hidden],
.team-studio.is-replaying .team-studio__last-token {
  display: none;
}

.team-studio__replay-line line {
  stroke: var(--agent);
  stroke-width: 2;
  stroke-dasharray: 6 8;
  opacity: 0;
}

.team-studio.is-replaying .team-studio__replay-line line {
  opacity: 0.65;
}

.team-studio__document-token {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  display: grid;
  width: 28px;
  height: 22px;
  place-items: center;
  pointer-events: none;
  border: 1px solid var(--agent);
  border-radius: 3px;
  background: var(--panel);
  box-shadow: 2px 3px 0 var(--agent-soft);
}

.team-studio__document-token[hidden] {
  display: none;
}

.team-studio__document-token::before {
  content: "";
  width: 13px;
  height: 8px;
  border-top: 1px solid var(--agent);
  border-bottom: 1px solid var(--agent);
}

.team-studio__station.is-replay-from,
.team-studio__station.is-replay-to,
.team-studio__approval-tray.is-replay-from,
.team-studio__approval-tray.is-replay-to {
  animation: studio-replay-highlight 900ms ease-out both;
}

.team-studio__note-host {
  position: absolute;
  z-index: 2;
  top: 33%;
  left: 50%;
  width: min(46%, 460px);
  min-width: 330px;
  margin: 0;
  transform: translateX(-50%) rotate(-0.35deg);
  border: 1px solid color-mix(in srgb, var(--agent) 34%, var(--line));
  border-radius: 4px 14px 9px 5px;
  background: color-mix(in srgb, var(--panel) 84%, transparent);
  box-shadow: 8px 10px 0 color-mix(in srgb, var(--agent-soft) 70%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.team-studio__agent-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  min-width: 0;
  padding: 18px 20px 20px;
  overflow-wrap: anywhere;
}

.team-studio__note-heading {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  grid-row: auto;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.team-studio__note-heading h2,
.team-studio__note-heading p,
.team-studio__agent-note > p {
  margin: 0;
}

.team-studio__note-purpose,
.team-studio__note-detail,
.team-studio__note-task span,
.team-studio__note-next span,
.team-studio__note-last span,
.team-studio__note-last time {
  color: var(--ink-3);
  font-size: 11px;
}

.team-studio__note-state {
  flex: none;
  color: var(--agent-ink);
  font-size: 11px;
}

.team-studio__agent-note.state-error .team-studio__note-state,
.team-studio__agent-note.state-blocked .team-studio__note-state,
.team-studio__note-error {
  color: var(--err);
}

.team-studio__note-task,
.team-studio__note-next,
.team-studio__note-last {
  display: grid;
  grid-template-columns: minmax(140px, 0.32fr) minmax(0, 1fr);
  gap: 12px;
}

.team-studio__note-last time {
  grid-column: 2;
}

.team-studio__latest {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 5px;
  margin: 12px 0 0;
  color: var(--ink-3);
  font-size: 11px;
  overflow-wrap: anywhere;
  flex-wrap: wrap;
}

@media (max-width: 1024px) {
  .studio-stage {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 250px);
  }

  .studio-floor {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 18px 8px;
    padding-inline: 18px;
  }

  .studio-agent {
    width: min(100%, 150px);
  }

  .review-tray {
    padding-inline: 18px;
  }
}

@media (max-width: 760px) {
  .team-studio {
    overflow-x: hidden;
  }

  .studio-head,
  .studio-replay {
    align-items: stretch;
    flex-direction: column;
  }

  .studio-live-note {
    flex-basis: auto;
    width: 100%;
    min-width: 0;
  }

  .studio-stage {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .studio-stage::before {
    background:
      linear-gradient(to bottom, transparent 0 72%, var(--studio-line) 72%, var(--studio-line) calc(72% + 1px), transparent calc(72% + 1px)),
      linear-gradient(to bottom, transparent 0 72%, color-mix(in srgb, var(--studio-floor) 78%, transparent) 72% 100%);
  }

  .studio-floor {
    min-height: 420px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 42px 14px 28px;
  }

  .studio-zone {
    min-height: 186px;
  }

  .review-tray {
    border-top: 1px solid var(--studio-line);
    border-left: 0;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
  }

  .studio-inspector {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .replay-status {
    order: -1;
  }
}

@media (max-width: 390px) {
  .studio-head {
    gap: 14px;
  }

  .studio-summary {
    display: grid;
    gap: 6px;
  }

  .studio-stage {
    border-radius: 12px;
  }

  .studio-floor {
    display: flex;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 28px 10px 24px;
  }

  .studio-zone {
    display: block;
    min-height: 0;
    padding: 30px 0 8px;
  }

  .studio-agent {
    width: 100%;
    min-height: 108px;
    grid-template-columns: 82px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    justify-items: start;
    align-content: center;
    column-gap: 10px;
    padding: 8px 10px;
    text-align: left;
  }

  .agent-figure {
    width: 78px;
    height: 92px;
    grid-row: 1 / -1;
  }

  .agent-name,
  .agent-purpose,
  .agent-state {
    grid-column: 2;
  }

  .studio-approver {
    width: 100%;
    min-height: 96px;
    border-radius: 12px;
  }

  .review-tray {
    padding: 22px 14px;
  }

  .review-sheet + .review-sheet {
    width: 100%;
    margin-left: 0;
  }

  .replay-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .replay-controls button {
    width: 100%;
  }
}

@media (max-width: 1024px) {
  .team-studio__header {
    flex-wrap: wrap;
  }

  .team-studio__controls {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .team-studio__scene {
    width: calc(100% - 236px);
  }

  .team-studio__station {
    width: 120px;
    margin-left: -60px;
  }

  .team-studio__approval-tray {
    left: calc(100% + 16px);
    width: 220px;
    padding-inline: 14px;
  }

  .team-studio__agent-note {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .team-studio__header {
    flex-direction: column;
    gap: 14px;
  }

  .team-studio__heading,
  .team-studio__controls {
    width: 100%;
    flex-basis: auto;
  }

  .team-studio__task-field {
    min-width: min(100%, 210px);
  }

  .team-studio__task-select {
    max-width: none;
  }

  .team-studio__scene {
    display: grid;
    width: 100%;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 40px 12px 18px;
    overflow: hidden;
  }

  .team-studio__scene::before {
    top: 16px;
    width: 88px;
    height: 46px;
    margin-left: -44px;
    opacity: 0.55;
  }

  .team-studio__scene::after {
    display: none;
  }

  .team-studio__last-line,
  .team-studio__last-token {
    display: none !important;
  }

  .team-studio__station {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    min-height: 148px;
    margin: 0;
  }

  .team-studio__approval-tray {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    min-height: 0;
    grid-column: 1 / -1;
    margin-top: 10px;
    padding: 18px 14px;
    border-top: 1px solid var(--studio-line);
    border-left: 0;
    background: color-mix(in srgb, var(--panel) 86%, transparent);
  }

  .team-studio__note-host {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
    margin-top: 10px;
    transform: none;
  }

  .team-studio__review-action {
    margin-top: 6px;
  }

  .team-studio__agent-note {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .team-studio__note-heading {
    grid-row: auto;
  }

  .team-studio__note-task,
  .team-studio__note-next,
  .team-studio__note-last {
    grid-template-columns: minmax(120px, 0.36fr) minmax(0, 1fr);
  }
}

@media (max-width: 390px) {
  .team-studio__controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .team-studio__task-field,
  .team-studio__replay-button {
    width: 100%;
  }

  .team-studio__scene {
    grid-template-columns: minmax(0, 1fr);
    padding: 28px 8px 14px;
  }

  .team-studio__station {
    min-height: 108px;
    grid-template-columns: 82px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
    justify-items: start;
    padding: 8px 10px;
    text-align: left;
  }

  .team-studio__figure {
    width: 76px;
    height: 82px;
  }

  .team-studio__station-copy {
    justify-items: start;
  }

  .team-studio__station-name,
  .team-studio__station-purpose {
    white-space: normal;
  }

  .team-studio__approval-tray {
    grid-column: auto;
    padding-inline: 10px;
  }

  .team-studio__review-sheet {
    width: 100%;
    margin-left: 0;
  }

  .team-studio__note-heading {
    flex-direction: column;
  }

  .team-studio__note-task,
  .team-studio__note-next,
  .team-studio__note-last {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .team-studio__note-last time {
    grid-column: auto;
  }
}

/* Уменьшение движения: информация сохраняется, декоративное движение исчезает. */
.reduce-motion .team-studio *,
.reduce-motion .team-studio *::before,
.reduce-motion .team-studio *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

.reduce-motion .team-studio .agent-tool,
.reduce-motion .team-studio .handoff-token,
.reduce-motion .team-studio .replay-from,
.reduce-motion .team-studio .replay-to,
.reduce-motion .team-studio .team-studio__tool,
.reduce-motion .team-studio .team-studio__document-token,
.reduce-motion .team-studio .is-replay-from,
.reduce-motion .team-studio .is-replay-to {
  transform: none !important;
}

.reduce-motion .team-studio .handoff-token,
.reduce-motion .team-studio .team-studio__document-token {
  display: none;
}

.reduce-motion .team-studio .studio-agent.replay-from,
.reduce-motion .team-studio .studio-agent.replay-to,
.reduce-motion .team-studio .team-studio__station.is-replay-from,
.reduce-motion .team-studio .team-studio__station.is-replay-to,
.reduce-motion .team-studio .team-studio__approval-tray.is-replay-from,
.reduce-motion .team-studio .team-studio__approval-tray.is-replay-to {
  background: var(--agent-soft);
  box-shadow: inset 0 0 0 2px var(--agent);
}

@media (prefers-reduced-motion: reduce) {
  .team-studio *,
  .team-studio *::before,
  .team-studio *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .team-studio .agent-tool,
  .team-studio .handoff-token,
  .team-studio .replay-from,
  .team-studio .replay-to,
  .team-studio .team-studio__tool,
  .team-studio .team-studio__document-token,
  .team-studio .is-replay-from,
  .team-studio .is-replay-to {
    transform: none !important;
  }

  .team-studio .handoff-token,
  .team-studio .team-studio__document-token {
    display: none;
  }

  .team-studio .studio-agent.replay-from,
  .team-studio .studio-agent.replay-to,
  .team-studio .team-studio__station.is-replay-from,
  .team-studio .team-studio__station.is-replay-to,
  .team-studio .team-studio__approval-tray.is-replay-from,
  .team-studio .team-studio__approval-tray.is-replay-to {
    background: var(--agent-soft);
    box-shadow: inset 0 0 0 2px var(--agent);
  }
}

/* ---------- Иерархическая сцена (2026-08-28): согласующая → Маркетинг-директор → команды ---------- */
.team-studio--tiers .team-studio__scene {
  display: grid;
  width: 100%;
  min-height: 0;
  gap: 0;
  padding: 20px 22px 18px;
  background: var(--studio-wall);
}
.team-studio--tiers .team-studio__scene::before,
.team-studio--tiers .team-studio__scene::after { display: none; }
.team-studio__tier { position: relative; display: grid; justify-items: center; gap: 6px; padding-bottom: 36px; }
.team-studio__tier--teams { padding-bottom: 0; }
/* Соединитель «сверху вниз»: линия и стрелка, без движения */
.team-studio__tier:not(.team-studio__tier--teams)::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 2px;
  height: 22px;
  margin-left: -1px;
  background: var(--line);
}
.team-studio__tier:not(.team-studio__tier--teams)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 0;
  height: 0;
  margin-left: -6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--line);
}
.team-studio__tier-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.team-studio__tier--human .team-studio__tier-label { color: var(--human-ink); }
.team-studio__how {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.team-studio__how li { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.team-studio__how li::before {
  counter-increment: step;
  content: counter(step);
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--agent-soft);
  color: var(--agent-ink);
  font-size: 11px;
  font-weight: 600;
}
.team-studio__how li.human::before { background: var(--human-soft); color: var(--human-ink); }
.team-studio__how li.human { color: var(--human-ink); font-weight: 600; }
/* Ярус 1: согласующая */
.team-studio--tiers .team-studio__approval-tray {
  position: static;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) auto;
  align-items: center;
  width: min(100%, 860px);
  min-height: 0;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--human) 45%, var(--line));
  border-radius: 14px;
  background: var(--human-soft);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.team-studio--tiers .team-studio__approver { min-height: 0; padding: 0; border-bottom: 0; }
.team-studio--tiers .team-studio__approver b { display: block; font-size: 17px; }
.team-studio--tiers .team-studio__approver span { font-size: 12px; }
.team-studio__approver-hint { color: var(--ink-3); margin-top: 3px; }
.team-studio--tiers .team-studio__review-stack { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.team-studio--tiers .team-studio__review-sheet { width: 200px; min-height: 0; margin-left: 0; padding: 8px 10px; font-size: 12px; }
.team-studio--tiers .team-studio__review-action { width: auto; margin: 0; }
.team-studio--tiers .team-studio__review-empty { margin: 0; }
/* Ярусы 2–3: станции в потоке, без абсолютных координат */
.team-studio--tiers .team-studio__station { position: static; width: 156px; min-height: 0; margin: 0; padding: 6px 8px 10px; grid-template-rows: 82px auto; }
.team-studio--tiers .team-studio__station-name { min-height: 0; font-size: 13px; }
.team-studio--tiers .team-studio__station-purpose { min-height: 0; font-size: 11.5px; line-height: 1.3; color: var(--ink-2); }
.team-studio--tiers .team-studio__station-state { min-height: 0; margin-top: 3px; font-size: 11px; }
.team-studio__tier--director .team-studio__station { width: 260px; border-color: color-mix(in srgb, var(--agent) 40%, var(--line)); background: color-mix(in srgb, var(--panel) 80%, transparent); }
.team-studio__tier--director .team-studio__station-purpose { font-size: 12px; }
.team-studio__groups { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; width: 100%; }
.team-studio__group { display: grid; align-content: start; gap: 4px; padding: 10px 8px 8px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--panel) 78%, transparent); }
.team-studio__group.team-content { grid-column: span 2; }
.team-studio__group-title { font-size: 13px; font-weight: 600; text-align: center; }
.team-studio__group-hint { font-size: 11.5px; color: var(--ink-3); text-align: center; min-height: 30px; }
.team-studio__group-body { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.team-studio__missing { font-size: 12px; color: var(--err); }
/* Записка — под ярусами, на всю ширину */
.team-studio--tiers .team-studio__note-host { position: static; width: 100%; min-width: 0; margin-top: 18px; transform: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--panel); }
.team-studio__who { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.team-studio__who span { color: var(--ink-3); font-style: normal; }
.team-studio__note-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.team-studio__note-hint { font-size: 11px; color: var(--ink-3); }
@media (max-width: 1100px) {
  .team-studio__groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-studio__group.team-content { grid-column: span 2; }
  .team-studio--tiers .team-studio__approval-tray { grid-template-columns: minmax(0, 1fr); justify-items: start; }
}
@media (max-width: 760px) {
  .team-studio__groups { grid-template-columns: minmax(0, 1fr); }
  .team-studio__group.team-content { grid-column: auto; }
  .team-studio--tiers .team-studio__scene { padding: 14px 12px; }
}
/* В ярусной сцене диагональный пунктир последней передачи мешает читать иерархию: остаётся подпись под сценой. */
.team-studio--tiers .team-studio__last-line,
.team-studio--tiers .team-studio__last-token { display: none; }
.team-studio--tiers .team-studio__scene { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; }
@media (max-width: 1100px) {
  .team-studio--tiers .team-studio__scene { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Карточки с портретами (2026-08-28, решение владельца после отклонения 3D-офиса) ---------- */
.team-studio__portrait { position: relative; display: block; width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: color-mix(in srgb, var(--shirt) 16%, var(--panel)); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.team-studio__portrait i { position: absolute; display: block; }
.team-studio__portrait .pt-shoulders { left: 6px; right: 6px; bottom: -14px; height: 34px; border-radius: 18px 18px 0 0; background: var(--shirt); }
.team-studio__portrait .pt-neck { left: 30px; top: 42px; width: 12px; height: 14px; background: color-mix(in srgb, var(--skin) 85%, #000); }
.team-studio__portrait .pt-head { left: 20px; top: 13px; width: 32px; height: 34px; border-radius: 12px 12px 14px 14px; background: var(--skin); }
.team-studio__portrait .pt-hair { left: -2px; top: -4px; width: 36px; height: 13px; border-radius: 14px 14px 4px 4px; background: var(--hair); }
.team-studio__portrait.hair-1 .pt-hair { height: 40px; border-radius: 14px 14px 8px 8px; clip-path: polygon(0 0, 100% 0, 100% 100%, 84% 100%, 84% 32%, 16% 32%, 16% 100%, 0 100%); }
.team-studio__portrait.hair-2 .pt-hair::after { content: ""; position: absolute; left: 11px; top: -7px; width: 14px; height: 10px; border-radius: 50%; background: inherit; }
.team-studio__portrait.hair-3 .pt-hair { left: -4px; width: 40px; height: 17px; border-radius: 16px 16px 6px 6px; }
.team-studio__portrait .pt-ear { top: 15px; width: 5px; height: 9px; border-radius: 3px; background: var(--skin); }
.team-studio__portrait .pt-ear--l { left: -3px; } .team-studio__portrait .pt-ear--r { right: -3px; }
.team-studio__portrait .pt-brow { top: 12px; width: 7px; height: 2px; border-radius: 1px; background: var(--hair); }
.team-studio__portrait .pt-brow--l { left: 7px; } .team-studio__portrait .pt-brow--r { right: 7px; }
.team-studio__portrait .pt-eye { top: 16px; width: 5px; height: 6px; border-radius: 3px; background: #2b2b2b; }
.team-studio__portrait .pt-eye::after { content: ""; position: absolute; left: 1px; top: 1px; width: 2px; height: 2px; border-radius: 50%; background: #fff; }
.team-studio__portrait .pt-eye--l { left: 8px; } .team-studio__portrait .pt-eye--r { right: 8px; }
.team-studio__portrait .pt-mouth { left: 12px; top: 25px; width: 8px; height: 3px; border-radius: 0 0 4px 4px; background: #b8735b; }
.team-studio__portrait .pt-glasses { left: 4px; top: 13px; width: 24px; height: 10px; border: 2px solid #3a3f4a; border-radius: 4px; box-sizing: border-box; background: rgba(223,243,255,0.45); }
.team-studio__portrait .pt-glasses::after { content: ""; position: absolute; left: 8px; top: 2px; width: 4px; height: 2px; background: #3a3f4a; }
.team-studio__portrait .pt-headset { left: -5px; top: 3px; width: 42px; height: 22px; border: 3px solid #2f3a4a; border-bottom: 0; border-radius: 20px 20px 0 0; box-sizing: border-box; }
.team-studio__portrait .pt-badge { right: 10px; top: 12px; width: 9px; height: 6px; border-radius: 1px; background: #d8b45a; }
.team-studio__portrait .pt-tie { left: 50%; top: 2px; width: 6px; height: 18px; margin-left: -3px; background: rgba(0,0,0,0.35); clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%); }
.team-studio__portrait .pt-pen { right: 12px; top: 6px; width: 3px; height: 11px; background: #1f2a44; }
.team-studio__portrait .pt-scarf { left: 12px; right: 12px; top: 0; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.4); }

/* Карточка роли: портрет сверху, имя, что делает, состояние. Никакого движения, кроме точки у «работает». */
.team-studio--cards .team-studio__station { width: 156px; padding: 14px 10px 12px; grid-template-rows: auto auto; gap: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 1px 2px rgba(20,30,50,0.05); transition: box-shadow 120ms ease, border-color 120ms ease; }
.team-studio--cards .team-studio__station:hover { border-color: color-mix(in srgb, var(--agent) 50%, var(--line)); background: var(--panel); box-shadow: 0 4px 14px rgba(20,30,50,0.10); }
.team-studio--cards .team-studio__station.is-selected { border-color: var(--agent); background: var(--panel); box-shadow: 0 0 0 2px color-mix(in srgb, var(--agent) 30%, transparent), 0 4px 14px rgba(20,30,50,0.10); }
.team-studio--cards .team-studio__station:focus-visible { outline: 2px solid var(--agent); outline-offset: 2px; }
.team-studio--cards .team-studio__station.state-disabled { opacity: 1; border-style: dashed; background: transparent; box-shadow: none; }
.team-studio--cards .team-studio__station.state-disabled .team-studio__portrait { opacity: 0.35; filter: grayscale(1); }
.team-studio--cards .team-studio__station-copy { gap: 4px; }
.team-studio--cards .team-studio__station-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.team-studio--cards .team-studio__station-purpose { font-size: 11.5px; line-height: 1.3; color: var(--ink-2); }
.team-studio--cards .team-studio__station-state { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); font-size: 11px; line-height: 1.2; justify-self: center; }
.team-studio--cards .team-studio__station-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.team-studio--cards .state-working .team-studio__station-state { background: var(--agent-soft); color: var(--agent-ink); font-weight: 600; }
.team-studio--cards .state-working .team-studio__station-state .dot { background: var(--agent); animation: studio-live-dot 1.2s ease-in-out infinite; }
.team-studio--cards .state-working .team-studio__portrait { box-shadow: 0 0 0 3px var(--agent); }
.team-studio--cards .state-received .team-studio__station-state { background: var(--agent-soft); color: var(--agent-ink); }
.team-studio--cards .state-received .team-studio__station-state .dot { background: var(--agent); }
.team-studio--cards .state-blocked .team-studio__station-state, .team-studio--cards .state-error .team-studio__station-state { background: var(--err-soft); color: var(--err); font-weight: 600; }
.team-studio--cards .state-blocked .team-studio__station-state .dot, .team-studio--cards .state-error .team-studio__station-state .dot { background: var(--err); }
.team-studio--cards .state-blocked .team-studio__portrait, .team-studio--cards .state-error .team-studio__portrait { box-shadow: 0 0 0 3px var(--err); }
@keyframes studio-live-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
/* Директор — широкая карточка с портретом слева */
.team-studio--cards .team-studio__tier--director .team-studio__station { width: min(100%, 380px); grid-template-columns: 72px minmax(0, 1fr); grid-template-rows: auto; align-items: center; justify-items: start; gap: 14px; padding: 12px 16px; text-align: left; }
.team-studio--cards .team-studio__tier--director .team-studio__station-state { justify-self: start; }
/* Согласующая — портрет слева от имени */
.team-studio--cards .team-studio__approver { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; }
.team-studio--cards .team-studio__approver-mark { display: block; width: 72px; height: 72px; margin: 0; padding: 0; border: 0; background: transparent; font-size: 0; line-height: 0; }
.team-studio--cards .team-studio__approver .team-studio__portrait { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), 0 0 0 3px var(--human); }
/* Группы команд — в ряд, по содержимому; переносятся на узком экране */
.team-studio--cards .team-studio__groups { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 12px; width: 100%; }
.team-studio--cards .team-studio__group { flex: 0 1 auto; grid-column: auto; gap: 6px; padding: 12px 12px 12px; background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.team-studio--cards .team-studio__group-title { font-size: 13.5px; }
.team-studio--cards .team-studio__group-hint { min-height: 0; margin-bottom: 4px; }
.team-studio--cards .team-studio__group-body { gap: 8px; }
.team-studio--cards.is-replaying .team-studio__station.is-replay-to { border-color: var(--human); }
@media (max-width: 760px) { .team-studio--cards .team-studio__station { width: 148px; } .team-studio--cards .team-studio__tier--director .team-studio__station { width: 100%; } }
