/* Super Admin Studio: Claude-style anatomy with TMC workbench controls. */

.studio-body {
  --canvas: #faf9f4;
  --surface: #fffef9;
  --surface-muted: #f4f0e7;
  --studio-line: #e7e2d7;
  --studio-line-strong: #cfc6b6;
  --studio-user-card: #efe9dc;
  --studio-ink: #21201c;
  --studio-muted: #57534a;
  --studio-subtle: #736d61;
  --font-prose: "Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  /* Motion. One curve and three durations, so every effect feels like the same product. */
  --studio-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --studio-dur-fast: 160ms;
  --studio-dur: 260ms;
  --studio-dur-slow: 900ms;
  /* A soft band of the brand green, swept across work that is in progress. */
  --studio-sheen: linear-gradient(
    100deg,
    transparent 20%,
    color-mix(in srgb, var(--accent) 12%, transparent) 50%,
    transparent 80%
  );
  color: var(--studio-ink);
  background: var(--canvas);
}

.studio-body .topbar {
  background: color-mix(in srgb, var(--canvas) 88%, white);
  border-block-end-color: var(--studio-line);
}

.brand-mark-link {
  color: #ffffff;
  text-decoration: none;
}

.studio-disabled {
  display: grid;
  place-items: center;
  min-block-size: calc(100vh - var(--topbar-height));
  padding: 24px;
}

.studio-disabled-card {
  max-inline-size: 560px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.studio-disabled-card h2 {
  margin: 4px 0 10px;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.04em;
}

.studio-disabled-card p {
  color: var(--studio-muted);
  line-height: 1.55;
}

.studio-shell {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) minmax(0, 0fr);
  min-block-size: calc(100vh - var(--topbar-height));
  overflow: hidden;
  background: var(--canvas);
}

.studio-shell.draft-open {
  grid-template-columns: 16rem minmax(0, 3fr) minmax(22rem, 2fr);
}

.studio-rail {
  min-block-size: 0;
  overflow: auto;
  padding: 16px 12px;
  background: color-mix(in srgb, var(--canvas) 72%, #ede6d7);
  border-inline-end: 1px solid var(--studio-line);
}

.studio-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block-end: 14px;
}

.area-list {
  display: grid;
  gap: 12px;
}

.area-card {
  display: grid;
  gap: 6px;
}

.studio-rail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.area-button,
.thread-button,
.suggestion-card {
  inline-size: 100%;
  color: var(--studio-ink);
  text-align: start;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

.area-button {
  padding: 10px;
}

.area-button:hover,
.thread-button:hover,
.suggestion-card:hover {
  background: #fffdf7;
  border-color: var(--studio-line);
}

.area-button[aria-current="true"],
.thread-button[aria-current="true"] {
  background: #ffffff;
  border-color: var(--studio-line-strong);
  box-shadow: var(--shadow-sm);
}

.area-title {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.area-meta,
.thread-meta {
  display: block;
  margin-block-start: 2px;
  color: var(--studio-muted);
  font-size: 12px;
}

.thread-list {
  display: grid;
  gap: 2px;
  padding-inline-start: 10px;
  border-inline-start: 1px solid var(--studio-line);
}

.thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px;
}

.thread-button {
  padding: 8px 10px;
  font-size: 13px;
}

.thread-delete {
  min-block-size: 32px;
  padding: 6px 8px;
  color: var(--studio-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.thread-delete:hover {
  color: #8c1d18;
  border-color: #b64943;
}

.thread-delete:focus-visible {
  outline: 2px solid var(--studio-accent);
  outline-offset: 2px;
}

.rail-toggle {
  position: fixed;
  display: none;
  inset-block-start: calc(var(--topbar-height) + 10px);
  inset-inline-start: 10px;
  z-index: 45;
}

.studio-thread {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-inline-size: 0;
  min-block-size: 0;
}

.thread-scroll {
  min-block-size: 0;
  overflow: auto;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  padding: 24px 18px 18px;
}

.thread-col {
  display: grid;
  gap: 20px;
  max-inline-size: 48rem;
  min-block-size: 100%;
  margin-inline: auto;
  align-content: start;
}

.empty-state,
.loading-state,
.error-state {
  align-self: center;
  justify-self: center;
  max-inline-size: 40rem;
  padding: 34px 20px;
  text-align: center;
}

.empty-state h2,
.loading-state h2,
.error-state h2 {
  margin: 0 0 10px;
  font-family: var(--font-prose);
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.empty-state p,
.loading-state p,
.error-state p {
  margin: 0;
  color: var(--studio-muted);
  line-height: 1.6;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-block-start: 24px;
}

.suggestion-card {
  padding: 14px;
  background: #fffdf8;
  border-color: var(--studio-line);
  line-height: 1.35;
}

.msg {
  min-inline-size: 0;
}

.msg-user {
  justify-self: end;
  max-inline-size: min(82%, 38rem);
  padding: 12px 14px;
  color: var(--studio-ink);
  background: var(--studio-user-card);
  border: 1px solid #dfd4c2;
  border-radius: 16px 16px 4px 16px;
  font-size: 14px;
  line-height: 1.55;
}

.msg-assistant {
  justify-self: stretch;
  max-inline-size: 100%;
}

.msg-body {
  color: var(--studio-ink);
  font-family: var(--font-prose);
  font-size: 16px;
  line-height: 1.65;
}

.msg-body p,
.msg-body ul,
.msg-body ol,
.msg-body pre,
.msg-body table {
  margin-block: 0 14px;
}

.msg-body p:last-child,
.msg-body ul:last-child,
.msg-body ol:last-child,
.msg-body pre:last-child,
.msg-body table:last-child {
  margin-block-end: 0;
}

.msg-body code {
  font-family: var(--font-data);
  font-size: 0.88em;
  background: #eee8dc;
  border: 1px solid #ded6c8;
  border-radius: var(--radius-xs);
  padding: 0.08em 0.28em;
}

.msg-body pre {
  overflow: auto;
  padding: 12px;
  background: #26231e;
  border-radius: var(--radius-sm);
}

.msg-body pre code {
  color: #fff8e8;
  background: transparent;
  border: 0;
  padding: 0;
}

.msg-body table {
  inline-size: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 13px;
}

.msg-body th,
.msg-body td {
  padding: 7px 8px;
  border-block-end: 1px solid var(--studio-line);
  text-align: start;
}

.word-fade {
  display: inline;
}

.run-trace {
  margin-block-end: 10px;
  color: var(--studio-muted);
  font-family: var(--font-ui);
  font-size: 12px;
}

.run-trace summary {
  cursor: pointer;
  font-weight: 800;
}

.run-steps {
  display: grid;
  gap: 6px;
  margin-block-start: 8px;
}

.run-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  background: #fffdf8;
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.thinking {
  color: var(--studio-muted);
  font-weight: 800;
}

.streaming .msg-body::after {
  content: "";
  display: inline-block;
  inline-size: 0.48em;
  block-size: 1.08em;
  margin-inline-start: 3px;
  vertical-align: -0.18em;
  background: var(--studio-ink);
}

.msg-actions {
  min-block-size: 28px;
  margin-block-start: 6px;
  opacity: 0;
}

.msg-assistant:hover .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
}

.proposal-card {
  padding: 14px;
  background: #fffdf8;
  border: 1px solid var(--studio-line-strong);
  border-radius: var(--radius-md);
}

.proposal-detail {
  margin-block: 10px;
}

.proposal-detail summary {
  cursor: pointer;
  font-weight: 800;
}

.proposal-changes {
  display: grid;
  gap: 8px;
  max-height: 320px;
  margin: 8px 0 0;
  padding-inline-start: 18px;
  overflow-y: auto;
}

.proposal-change {
  display: block;
  overflow-wrap: anywhere;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px;
}

.proposal-change-where {
  display: block;
  color: var(--studio-muted);
  font-size: 12px;
}

.proposal-card-approved {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--studio-line));
}

.proposal-card-rejected,
.proposal-card-superseded {
  background: #f5efe4;
}

.jump-pill {
  position: absolute;
  inset-inline: 50% auto;
  inset-block-end: 104px;
  z-index: 4;
  padding: 7px 12px;
  color: #ffffff;
  background: #26231e;
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}

.composer {
  max-inline-size: 48rem;
  inline-size: calc(100% - 36px);
  margin: 0 auto 18px;
  padding: 10px;
  background: #fffef9;
  border: 1px solid var(--studio-line-strong);
  border-radius: 18px;
  box-shadow: 0 14px 36px rgb(41 36 26 / 0.12);
}

.composer textarea {
  display: block;
  inline-size: 100%;
  max-block-size: 180px;
  resize: none;
  padding: 8px 8px 2px;
  color: var(--studio-ink);
  background: transparent;
  border: 0;
  font: inherit;
  line-height: 1.5;
}

.composer textarea:focus-visible {
  outline: 0;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block-start: 8px;
}

.composer-foot-left {
  display: flex;
  align-items: center;
  min-inline-size: 0;
  gap: 8px;
}

.composer-hint {
  overflow: hidden;
  color: var(--studio-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-icon-button {
  inline-size: 32px;
  min-inline-size: 32px;
  padding-inline: 0;
}

.composer-icon-button svg,
.composer-send svg {
  inline-size: 16px;
  block-size: 16px;
}

.composer-proceed {
  margin-inline-start: auto;
  border-radius: 999px;
}

.composer-send {
  inline-size: 34px;
  min-inline-size: 34px;
  border-radius: 999px;
}

.icon-stop,
.composer-send[data-mode="stop"] .icon-send {
  display: none;
}

.composer-send[data-mode="stop"] .icon-stop {
  display: block;
}

.attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 6px 8px;
}

.attach-chip,
.revision-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-block-size: 26px;
  padding-inline: 9px;
  color: var(--studio-muted);
  background: #f5efe4;
  border: 1px solid var(--studio-line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.draft-panel {
  min-inline-size: 0;
  min-block-size: 0;
  overflow: auto;
  background: #fffef9;
  border-inline-start: 1px solid var(--studio-line);
}

.draft-panel-head {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: #fffef9;
  border-block-end: 1px solid var(--studio-line);
}

.draft-panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.draft-panel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.draft-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-block-end: 1px solid var(--studio-line);
}

.draft-tab {
  min-block-size: 34px;
  padding-inline: 12px;
  color: var(--studio-muted);
  background: transparent;
  border: 1px solid transparent;
  border-block-end: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-weight: 800;
}

.draft-tab[aria-selected="true"] {
  color: var(--studio-ink);
  background: var(--canvas);
  border-color: var(--studio-line);
}

.draft-tabpanel {
  padding: 16px;
}

.draft-empty,
.panel-list {
  display: grid;
  gap: 10px;
}

.panel-card {
  padding: 12px;
  background: var(--canvas);
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.panel-card h3 {
  margin: 2px 0 8px;
  color: var(--studio-ink);
  font-family: var(--font-prose);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 12px;
}

.summary-block,
.file-list,
.history-list {
  display: grid;
  gap: 10px;
  margin-block-start: 14px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-block-start: 12px;
}

.onboarding-guidance,
.lifecycle-card,
.output-summary-card {
  margin-block: 10px 12px;
  padding: 10px;
  background: #fffdf8;
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.onboarding-guidance p:last-child {
  margin-block-end: 0;
  color: var(--studio-muted);
  font-size: 13px;
  line-height: 1.45;
}

.lifecycle-card {
  display: grid;
  gap: 8px;
}

.lifecycle-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--studio-muted);
}

.lifecycle-dot {
  inline-size: 10px;
  block-size: 10px;
  margin-block-start: 4px;
  background: var(--studio-line-strong);
  border: 2px solid #fffdf8;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--studio-line-strong);
}

.lifecycle-step strong,
.lifecycle-step span {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

.lifecycle-step strong {
  color: var(--studio-ink);
}

.lifecycle-step[data-state="current"] .lifecycle-dot,
.lifecycle-step[data-state="done"] .lifecycle-dot {
  background: var(--studio-ink);
  box-shadow: 0 0 0 1px var(--studio-ink);
}

.lifecycle-step[data-state="blocked"] .lifecycle-dot {
  background: #b91c1c;
  box-shadow: 0 0 0 1px #b91c1c;
}

.output-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.output-summary-grid span {
  padding: 7px 8px;
  color: var(--studio-ink);
  background: var(--canvas);
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 1.35;
}

.recovery-actions {
  margin-block: 10px 0;
}

.setup-grid span {
  padding: 7px 8px;
  color: var(--studio-ink);
  background: #fffef9;
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 1.35;
}

.output-details {
  background: #fffef9;
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.output-details summary {
  cursor: pointer;
  padding: 9px 10px;
  color: var(--studio-ink);
  font-weight: 800;
}

.column-list {
  display: grid;
  gap: 1px;
  padding: 0 10px 10px;
}

.column-row,
.file-row,
.revision-row {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-block-start: 1px solid var(--studio-line);
}

.column-row {
  grid-template-columns: minmax(8rem, 1fr) minmax(0, 1.4fr) auto;
  align-items: center;
}

.column-row code {
  overflow: hidden;
  color: var(--studio-ink);
  font-family: var(--font-data);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-row em {
  color: #7c2d12;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.file-row .file-remove {
  justify-self: start;
}

.file-row strong,
.revision-row strong {
  color: var(--studio-ink);
}

.file-row span,
.revision-row span {
  color: var(--studio-muted);
  font-size: 12px;
}

.revision-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.publication-row {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-block-start: 1px solid var(--studio-line);
}

.publication-row strong {
  color: var(--studio-ink);
}

.publication-row span {
  color: var(--studio-muted);
  font-size: 12px;
}

/* The live row is the answer; superseded rows are context. */
.publication-row[data-live="true"] {
  padding-inline-start: 8px;
  border-inline-start: 3px solid var(--success, #1d6a43);
}

.publication-chain-broken,
.publish-blocked {
  color: #7c2d12;
  font-weight: 700;
}

.publish-confirm {
  color: var(--studio-ink);
  font-weight: 700;
}

.next-step-card {
  margin-block: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--studio-line-strong);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-sm);
}

.next-step-card h3 {
  margin: 2px 0 6px;
  font-family: var(--font-prose);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.needs-review-card {
  border-inline-start: 4px solid var(--accent);
}

.needs-review-card h3 {
  margin: 2px 0 6px;
  font-family: var(--font-prose);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.needs-review-card .column-list {
  padding-inline: 0;
}

.needs-review-details {
  margin-block-start: 12px;
  background: #fffef9;
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.needs-review-details summary {
  cursor: pointer;
  padding: 9px 10px;
  color: var(--studio-ink);
  font-size: 12px;
  font-weight: 800;
}

.secondary-actions {
  margin-block-start: 12px;
}

.secondary-actions > summary {
  color: var(--studio-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.secondary-actions[open] > summary {
  color: var(--studio-ink);
}

.stage-rail {
  display: grid;
  gap: 8px;
  margin-block: 12px;
}

.stage-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) auto;
  gap: 4px 10px;
  padding: 9px 10px;
  background: #fffef9;
  border: 1px solid var(--studio-line);
  border-inline-start: 4px solid var(--studio-line-strong);
  border-radius: var(--radius-sm);
}

.stage-row strong {
  color: var(--studio-ink);
  font-size: 12px;
}

.stage-row span {
  color: var(--studio-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.stage-row p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--studio-muted);
  font-size: 12px;
}

.stage-downloads {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 6px;
  margin-block-start: 4px;
}

.stage-downloads .button {
  overflow-wrap: anywhere;
  text-align: start;
}

.stage-extras {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
}

.charge-chooser {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--studio-line);
  border-radius: 8px;
  background: var(--studio-paper, transparent);
}

.charge-choice-row {
  display: grid;
  gap: 4px;
}

.charge-choice-row label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  font-size: 12px;
}

.charge-choice-value {
  overflow-wrap: anywhere;
  color: var(--studio-ink);
  font-family: var(--font-mono, ui-monospace, monospace);
}

.charge-choice-meta {
  color: var(--studio-muted);
}

.charge-choice {
  width: 100%;
  min-height: 34px;
}

.charge-chooser .button {
  justify-self: start;
}

.stage-breakdown {
  grid-column: 1 / -1;
  max-width: 100%;
  overflow-x: auto;
  font-size: 12px;
}

.stage-breakdown summary {
  cursor: pointer;
  color: var(--studio-ink);
  font-weight: 800;
}

.stage-breakdown .difference-column {
  margin-block: 4px;
  padding-inline-start: 10px;
}

.stage-breakdown .difference-column summary {
  font-weight: 600;
}

.stage-row .breakdown-heading {
  margin-block: 10px 4px;
  color: var(--studio-ink);
  font-weight: 800;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.breakdown-table th,
.breakdown-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--studio-line);
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.breakdown-table th {
  color: var(--studio-muted);
  font-weight: 800;
}

.stage-row[data-status="passed"] {
  border-inline-start-color: var(--accent);
}

.stage-row[data-status="failed"],
.stage-row[data-status="error"] {
  border-inline-start-color: #b91c1c;
}

.stage-row[data-status="draft"] {
  border-inline-start-color: #92400e;
}

.import-form {
  display: grid;
  gap: 8px;
  margin-block-start: 12px;
}

.import-form input {
  min-block-size: 36px;
  padding: 8px 10px;
  color: var(--studio-ink);
  background: #fffef9;
  border: 1px solid var(--studio-line-strong);
  border-radius: var(--radius-sm);
}

.studio-dialog {
  inline-size: min(560px, calc(100vw - 32px));
  padding: 0;
  color: var(--studio-ink);
  background: #fffef9;
  border: 1px solid var(--studio-line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.studio-dialog::backdrop {
  background: rgb(33 32 28 / 0.32);
}

.studio-dialog form {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.studio-dialog h2 {
  margin: 0 0 6px;
}

.studio-dialog input,
.studio-dialog select,
.studio-dialog textarea {
  min-block-size: 38px;
  padding-inline: 10px;
  color: var(--studio-ink);
  background: white;
  border: 1px solid var(--studio-line-strong);
  border-radius: var(--radius-xs);
}

.studio-dialog select {
  padding-inline-end: 32px;
}

.studio-dialog textarea {
  padding-block: 9px;
  resize: vertical;
}

.studio-dialog .field-hint {
  margin-block: -2px 0;
  color: var(--studio-subtle);
  font-size: 12px;
  line-height: 1.4;
}

.inline-create {
  padding: 10px;
  background: var(--canvas);
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.inline-create summary {
  cursor: pointer;
  font-weight: 800;
}

.inline-create[open] {
  display: grid;
  gap: 8px;
}

.studio-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-block-start: 10px;
}

/* Access grants ---------------------------------------------------------------
   Wider than the onboarding dialog because each row carries an email address and a
   client company name side by side, and truncating either is the one thing this screen
   must not do: both are how an administrator identifies what they are about to revoke. */

.access-dialog {
  inline-size: min(680px, calc(100vw - 32px));
  max-block-size: min(88vh, 820px);
}

.access-heading {
  margin-block: 8px 0;
  padding-block-start: 12px;
  border-block-start: 1px solid var(--studio-line);
}

/* The list scrolls rather than the dialog, so the grant form and its actions stay in
   view however many people hold access. Focusable because a scrollable region must be
   reachable by keyboard. */
.access-list {
  display: grid;
  gap: 6px;
  max-block-size: 244px;
  overflow-y: auto;
}

.access-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  background: var(--canvas);
  border: 1px solid var(--studio-line);
  border-radius: var(--radius-sm);
}

.access-row-who {
  display: grid;
  gap: 2px;
  flex: 1 1 220px;
  min-inline-size: 0;
}

.access-row-email {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.access-row-meta {
  color: var(--studio-subtle);
  font-size: 12px;
  line-height: 1.4;
}

/* The status device is the app's existing neutral chip with a coloured dot, and it
   always carries words as well as the dot: "Lapsed" must survive greyscale, forced
   colours and colour blindness, because it is the difference between someone having
   access to a client company and not. */
.access-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-block-size: 26px;
  padding-inline: 9px;
  color: var(--studio-muted);
  background: var(--surface);
  border: 1px solid var(--studio-line-strong);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.access-status::before {
  content: "";
  inline-size: 7px;
  block-size: 7px;
  background: var(--success);
  border-radius: 999px;
}

.access-status[data-state="expiring"]::before {
  background: var(--warning);
}

/* A lapsed grant is inert, so it reads as inert: the row recedes rather than shouting
   in red, because nothing is wrong with it and no action is needed. */
.access-row[data-state="lapsed"] {
  background: transparent;
}

.access-row[data-state="lapsed"] .access-row-email {
  color: var(--studio-subtle);
  font-weight: 600;
}

.access-status[data-state="lapsed"]::before {
  background: var(--studio-line-strong);
}

.access-revoke:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
}

.access-empty {
  padding: 14px 12px;
  color: var(--studio-subtle);
  background: var(--canvas);
  border: 1px dashed var(--studio-line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.studio-dialog input[type="date"] {
  padding-inline-end: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  .studio-shell {
    transition: grid-template-columns 300ms cubic-bezier(0.32, 0.72, 0, 1);
  }

  .msg,
  .proposal-card {
    animation: msg-enter 200ms ease-out both;
  }

  .thinking {
    background: linear-gradient(90deg, var(--studio-muted), var(--studio-ink), var(--studio-muted));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 2s linear infinite;
  }

  .word-fade {
    animation: word-fade 150ms ease-out both;
  }

  .streaming .msg-body::after {
    animation: caret-blink 1s step-end infinite;
  }

  .jump-pill {
    transition: opacity 200ms ease, transform 200ms ease;
  }

  .composer-send:active:not(:disabled) {
    transform: scale(0.95);
  }

  .next-step-action {
    animation: next-step-guidance 1.8s ease-out 2;
  }
}

/* Joyful, but only at moments that mean something: work in progress sweeps, a finished
   step pops its status, a change the operator made settles into place, and an all-green
   run gets one flourish. Nothing loops once the work it describes is done. */
@media (prefers-reduced-motion: no-preference) {
  /* Work in progress: a tool step running, checks queued, files uploading. */
  .run-step[data-state="running"] > span:first-child {
    background: linear-gradient(90deg, var(--studio-muted), var(--studio-ink), var(--studio-muted));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 2s linear infinite;
  }

  .run-step[data-state="done"] > span:last-child,
  .run-step[data-state="error"] > span:last-child {
    animation: status-pop var(--studio-dur) var(--studio-ease) both;
  }

  .stage-rail[data-running="true"] .stage-row[data-status="pending"],
  .attach-chip-pending {
    position: relative;
    overflow: hidden;
  }

  .stage-rail[data-running="true"] .stage-row[data-status="pending"]::after,
  .attach-chip-pending::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--studio-sheen);
    transform: translateX(-100%);
    animation: sheen-sweep 1.6s var(--studio-ease) infinite;
    animation-delay: calc(var(--i, 0) * 90ms);
    pointer-events: none;
  }

  /* A check that changed status while the operator watched. */
  .stage-row {
    transition-property: border-color, background-color;
    transition-duration: var(--studio-dur);
    transition-timing-function: var(--studio-ease);
  }

  .stage-row[data-changed="true"] > span {
    animation: status-pop var(--studio-dur) var(--studio-ease) both;
  }

  .stage-row[data-changed="true"][data-status="passed"] {
    animation: passed-glow var(--studio-dur-slow) var(--studio-ease) both;
  }

  /* Every check green: the rows light up in order, and one sheen crosses the card. */
  .checks-celebrate {
    position: relative;
    overflow: hidden;
  }

  .checks-celebrate::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--studio-sheen);
    transform: translateX(-100%);
    animation: sheen-sweep 1.2s var(--studio-ease) 1 both;
    pointer-events: none;
  }

  .checks-celebrate .stage-row[data-status="passed"] {
    animation: passed-glow var(--studio-dur-slow) var(--studio-ease) both;
    animation-delay: calc(var(--i, 0) * 70ms);
  }

  /* A proposal the operator approved. */
  .proposal-celebrate {
    position: relative;
    overflow: hidden;
    animation: passed-glow var(--studio-dur-slow) var(--studio-ease) both;
  }

  .proposal-celebrate::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--studio-sheen);
    transform: translateX(-100%);
    animation: sheen-sweep 1s var(--studio-ease) 1 both;
    pointer-events: none;
  }

  .decision-stamp {
    animation: status-pop var(--studio-dur) var(--studio-ease) both;
  }

  /* The agent has stopped and is waiting: one sheen points at Proceed, then it rests. */
  .composer-proceed.proceed-nudge:not(:disabled) {
    position: relative;
    overflow: hidden;
  }

  .composer-proceed.proceed-nudge:not(:disabled)::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--studio-sheen);
    transform: translateX(-100%);
    animation: sheen-sweep 1.1s var(--studio-ease) 2 both;
    pointer-events: none;
  }

  .composer-proceed:active:not(:disabled) {
    transform: scale(0.97);
  }

  /* Revealed detail settles in rather than snapping. */
  .stage-breakdown[open] > :not(summary),
  .proposal-detail[open] > :not(summary) {
    animation: msg-enter var(--studio-dur) var(--studio-ease) both;
  }

  .file-row-leaving {
    animation: row-leave 220ms var(--studio-ease) both;
  }

  /* Toasts rise into place and show how long they will stay. */
  .toast.toast-enter {
    overflow: hidden;
    animation: toast-rise var(--studio-dur) var(--studio-ease) both;
  }

  .toast.toast-enter::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    block-size: 3px;
    background: currentColor;
    opacity: 0.45;
    transform-origin: left center;
    animation: toast-timer var(--toast-ms, 3200ms) linear both;
  }
}

@keyframes sheen-sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes status-pop {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  60% {
    opacity: 1;
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes passed-glow {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
  }
  35% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

@keyframes row-leave {
  to {
    opacity: 0;
    transform: translateX(12px);
  }
}

@keyframes toast-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-timer {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@keyframes next-step-guidance {
  0%, 100% {
    box-shadow: none;
  }
  45% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  }
}

@keyframes msg-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@keyframes word-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .studio-shell,
  .msg,
  .proposal-card,
  .word-fade,
  .jump-pill,
  .next-step-action,
  .streaming .msg-body::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 960px) {
  .studio-shell,
  .studio-shell.draft-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio-rail {
    position: fixed;
    inset-block: var(--topbar-height) 0;
    inset-inline-start: 0;
    z-index: 40;
    inline-size: min(18rem, 84vw);
    box-shadow: var(--shadow-md);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .studio-rail[data-open="true"] {
    transform: translateX(0);
  }

  .rail-toggle {
    display: inline-flex;
    inset-block-start: 122px;
    inset-inline-start: 12px;
    background: #fffdf8;
  }

  .thread-scroll {
    padding-block-start: 88px;
  }

  .draft-panel {
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    z-index: 35;
    box-shadow: var(--shadow-md);
  }

  .lifecycle-card,
  .output-summary-card {
    margin-block: 10px;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
  }

  .composer-hint {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar-meta .version-chip {
    display: none;
  }

  .thread-scroll {
    padding-inline: 12px;
  }

  .composer {
    inline-size: calc(100% - 24px);
    margin-block-end: 12px;
  }

  .msg-user {
    max-inline-size: 92%;
  }

  .draft-tabs {
    overflow-x: auto;
    scrollbar-gutter: stable;
  }

  .draft-tab {
    white-space: nowrap;
  }

  .setup-grid,
  .output-summary-grid {
    grid-template-columns: 1fr;
  }

  .studio-dialog {
    inline-size: calc(100vw - 20px);
  }

  /* One scrolling region on a phone, not two. At this width the dialog already scrolls,
     and a nested scroller clips the third grant against the form below it with no clue
     that more rows exist. */
  .access-list {
    max-block-size: none;
    overflow-y: visible;
  }

  .studio-dialog form {
    padding: 16px;
  }
}
