/* Unified studio layout — shared by Digital Human, Character Mix, and similar workspace pages. */
.studio-tool-layout {
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr) 36px;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr) minmax(238px, 280px);
  grid-template-areas:
    "toolstrip toolstrip toolstrip"
    "left canvas right"
    "status status status";
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-base);
}

.studio-tool-layout--no-left {
  grid-template-columns: minmax(0, 1fr) minmax(238px, 280px);
  grid-template-areas:
    "toolstrip toolstrip"
    "canvas right"
    "status status";
}

.studio-tool-layout--no-right {
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  grid-template-areas:
    "toolstrip toolstrip"
    "left canvas"
    "status status";
}

.studio-tool-layout--no-left.studio-tool-layout--no-right {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "toolstrip"
    "canvas"
    "status";
}

.studio-tool-layout--no-top {
  grid-template-rows: minmax(0, 1fr) 36px;
  grid-template-areas:
    "left canvas right"
    "status status status";
}

.studio-tool-layout--no-top.studio-tool-layout--no-left {
  grid-template-areas:
    "canvas right"
    "status status";
}

.studio-tool-layout--no-top.studio-tool-layout--no-right {
  grid-template-areas:
    "left canvas"
    "status status";
}

.studio-tool-layout--no-top.studio-tool-layout--no-left.studio-tool-layout--no-right {
  grid-template-areas:
    "canvas"
    "status";
}

.studio-toolstrip {
  grid-area: toolstrip;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-weak);
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.14), transparent 48%),
    var(--bg-panel);
}

.studio-toolstrip__left {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.studio-toolstrip__breadcrumb {
  color: var(--fg-body);
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
}

.studio-toolstrip__divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
}

.studio-segmented {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
}

.studio-segmented__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.studio-segmented__btn:hover {
  background: var(--bg-hover);
  color: var(--fg-body);
}

.studio-segmented__btn.is-active {
  border-color: rgba(var(--accent-rgb), 0.38);
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent);
}

/* Panels */
.studio-panel {
  grid-area: left;
  display: grid;
  align-content: start;
  min-width: 0;
  min-height: 0;
  gap: 0;
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid var(--border-weak);
  background: var(--bg-panel);
  scrollbar-color: rgba(var(--accent-rgb), 0.34) transparent;
}

.studio-panel--right {
  grid-area: right;
  border-right: 0;
  border-left: 1px solid var(--border-weak);
}

.studio-panel__section {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-weak);
}

.studio-panel__section:first-child {
  padding-top: 0;
}

.studio-panel__section:last-child {
  border-bottom: 0;
}

.studio-panel__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 10px;
}

.studio-panel__section-title {
  color: var(--fg-body);
  font-size: 13px;
  font-weight: 750;
}

.studio-panel__section-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.studio-panel__section-chip--waiting {
  background: var(--bg-inset);
  color: var(--fg-muted);
}

.studio-panel__section-chip--ready {
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent);
}

/* Upload slots */
.studio-upload-slot--empty,
.studio-upload-slot--filled {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 100px;
  padding: 16px;
  border: 1px dashed rgba(var(--accent-rgb), 0.36);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.06), transparent),
    var(--bg-inset);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.studio-upload-slot--empty:hover,
.studio-upload-slot--filled:hover {
  border-color: rgba(var(--accent-rgb), 0.56);
  background: var(--bg-hover);
}

.studio-upload-slot--filled {
  border-style: solid;
  border-color: rgba(var(--accent-rgb), 0.28);
}

.studio-upload-slot--empty input[type="file"],
.studio-upload-slot--filled input[type="file"] {
  display: none;
}

.studio-upload-slot--empty__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent);
  font-size: 24px;
}

.studio-upload-slot--filled__thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}

.studio-upload-slot--filled__info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.studio-upload-slot--filled__info strong {
  color: var(--fg-body);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-upload-slot--filled__info small {
  color: var(--fg-muted);
  font-size: 11px;
}

/* Canvas */
.studio-canvas {
  grid-area: canvas;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background:
    radial-gradient(circle, rgba(var(--accent-rgb), 0.12) 1px, transparent 1.4px),
    var(--bg-inset);
  background-size: 22px 22px;
}

.studio-canvas-ghost {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s ease, outline 0.18s ease, transform 0.18s ease;
}

.studio-canvas-ghost:hover {
  background: rgba(var(--accent-rgb), 0.05);
  outline: 1px dashed rgba(var(--accent-rgb), 0.25);
}

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

.studio-canvas-ghost.is-dragging {
  background: rgba(var(--accent-rgb), 0.1);
  outline: 2px dashed var(--accent);
  transform: scale(1.02);
}

.studio-canvas-ghost__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.22);
  color: var(--accent);
  font-size: 26px;
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.08);
}

.studio-canvas-ghost__title {
  color: var(--fg-body);
  font-size: 15px;
  font-weight: 700;
}

.studio-canvas-ghost__hint {
  max-width: 320px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.5;
}

.studio-canvas-image {
  display: grid;
  place-items: center;
}

.studio-canvas-image img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.studio-canvas-video {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
}

.studio-canvas-video video {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.studio-result-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--fg-muted);
  font-size: 12px;
}

.studio-result-caption strong {
  color: var(--accent);
  font-weight: 750;
}

.studio-result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.studio-result-actions button {
  display: inline-flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
  color: var(--fg-body);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.studio-result-actions button:hover:not(:disabled) {
  border-color: rgba(var(--accent-rgb), 0.42);
  background: rgba(var(--accent-rgb), 0.11);
  color: var(--accent);
}

.studio-result-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.studio-canvas-pip {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border: 2px solid rgba(var(--accent-rgb), 0.42);
  border-radius: var(--radius-xs);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.studio-canvas-pip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Controls: toggles, generate button, audio preview */
.studio-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 12px;
  padding: 10px 0;
}

.studio-toggle-row__copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.studio-toggle-row__title {
  color: var(--fg-body);
  font-size: 13px;
  font-weight: 700;
}

.studio-toggle-row__desc {
  color: var(--fg-muted);
  font-size: 11px;
}

.studio-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-inset);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.studio-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fg-muted);
  transition: transform 140ms ease, background 140ms ease;
}

.studio-toggle.is-on {
  border-color: rgba(var(--accent-rgb), 0.42);
  background: rgba(var(--accent-rgb), 0.13);
}

.studio-toggle.is-on .studio-toggle__thumb {
  background: var(--accent);
  transform: translateX(18px);
}

.studio-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #061014;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: opacity 140ms ease, transform 140ms ease;
}

.studio-generate-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.studio-generate-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.studio-audio-preview {
  width: 100%;
  height: 36px;
  margin-top: 8px;
  border-radius: var(--radius-xs);
}

/* Debug panel */
.studio-debug-panel__clear {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-inset);
  color: var(--fg-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  cursor: pointer;
}

.studio-debug-panel__clear:hover {
  color: var(--fg-body);
  border-color: rgba(var(--accent-rgb), 0.36);
}

.studio-debug-panel__list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}

.studio-debug-panel__item {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid rgba(var(--accent-rgb), 0.42);
  border-radius: var(--radius-xs);
  background: var(--bg-inset);
}

.studio-debug-panel__item--success {
  border-left-color: var(--accent);
}

.studio-debug-panel__item--error {
  border-left-color: #ff5c7a;
}

.studio-debug-panel__item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 8px;
}

.studio-debug-panel__item-head strong {
  color: var(--fg-body);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-debug-panel__item-head span,
.studio-debug-panel__empty {
  color: var(--fg-muted);
  font-size: 11px;
}

.studio-debug-panel__item p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.45;
  word-break: break-all;
}

/* Status bar */
.studio-status-bar {
  grid-area: status;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 0 16px;
  border-top: 1px solid var(--border-weak);
  background: var(--bg-panel);
}

.studio-status-bar__badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.studio-status-bar__badge--idle {
  background: var(--bg-inset);
  color: var(--fg-muted);
}

.studio-status-bar__badge--running {
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent);
}

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

.studio-status-bar__meta {
  margin-left: auto;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 1080px) {
  .studio-tool-layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    grid-template-areas:
      "toolstrip toolstrip"
      "left canvas"
      "status status";
  }

  .studio-panel--right {
    display: none;
  }
}

@media (max-width: 720px) {
  .studio-tool-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 46px auto minmax(260px, 1fr) 36px;
    grid-template-areas:
      "toolstrip"
      "left"
      "canvas"
      "status";
  }

  .studio-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border-weak);
    max-height: 320px;
  }
}
