/* Unified Models catalog toolbar & card polish */
.preview-models .um-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
}
.preview-models .um-header-copy h1 { margin: 0 0 6px; }
.preview-models .um-header-copy p { margin: 0; }
.preview-models .um-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.preview-models .um-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--night-border, #e2e4e8);
  border-radius: 10px;
  background: var(--night-surface, #f6f7f9);
}
.preview-models .um-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--night-muted, #62666d);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.preview-models .um-filter-pill:hover { color: inherit; }
.preview-models .um-filter-pill.is-active {
  background: var(--night-text, #141518);
  color: var(--night-canvas, #ffffff);
}
.preview-models .um-filter-count {
  font-size: 11px;
  opacity: .72;
  font-variant-numeric: tabular-nums;
}
.preview-models .um-search input {
  min-height: 38px;
  width: min(210px, 100%);
  padding: 0 12px;
  border: 1px solid var(--night-border, #e2e4e8);
  border-radius: 10px;
  background: var(--night-canvas, #fff);
  color: inherit;
  font: inherit;
  font-size: 13px;
}
.preview-models .um-search input:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.preview-models .st-feature-image {
  position: relative;
}
.preview-models .st-feature-image::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(8, 10, 14, .54) 0%, rgba(8, 10, 14, .18) 45%, rgba(8, 10, 14, .68) 100%);
  pointer-events: none;
}
.preview-models .st-feature-image .st-feature-name,
.preview-models .st-feature-image .hm-capabilities,
.preview-models .st-feature-image .hm-overlay-price {
  z-index: 2;
}
.preview-models .st-feature-card {
  display: flex;
  flex-direction: column;
}
.preview-models .st-feature-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
.preview-models .st-card-actions {
  margin-top: auto;
}
.preview-models .st-card-action-full {
  width: 100%;
  justify-content: center;
}
.preview-models .um-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--night-muted, #62666d);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Unified Studio Playground */
.upg-shell {
  --upg-border: var(--night-border, #e2e4e8);
  --upg-muted: var(--night-muted, #62666d);
  --upg-surface: var(--night-surface, #ffffff);
  --upg-subtle: var(--night-inset, #f6f7f9);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.upg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.upg-topbar-left,
.upg-topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.upg-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}
.upg-switcher select {
  min-height: 36px;
  max-width: min(320px, 72vw);
  padding: 0 32px 0 12px;
  border: 1px solid var(--upg-border);
  border-radius: 8px;
  background: var(--upg-surface);
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.upg-balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--upg-border);
  border-radius: 999px;
  background: var(--upg-surface);
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.upg-balance-pill:hover { border-color: currentColor; }
.upg-balance-label { color: var(--upg-muted); }
.upg-balance-pill strong { font-variant-numeric: tabular-nums; font-weight: 600; }
.upg-balance-topup { color: var(--upg-muted); font-size: 12px; }

.upg-workspace {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.upg-output-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.upg-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--upg-border);
  border-radius: 14px;
  background: var(--upg-surface);
}
.upg-model-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.upg-model-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
}
.upg-model-head h1 {
  margin: 0;
  font-size: 20px !important;
  line-height: 1.25 !important;
  font-weight: 600 !important;
}
.upg-model-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--upg-muted);
}

.upg-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upg-label,
.upg-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
}
.upg-hint {
  font-size: 12px;
  color: var(--upg-muted);
  font-weight: 400;
}
.upg-prompt-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--upg-border);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
.upg-prompt-field textarea:focus-visible,
.upg-shell :is(button, a, select):focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.upg-specs {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.upg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.upg-pill {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--upg-border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.upg-pill.is-selected {
  background: var(--night-text, #141518);
  border-color: var(--night-text, #141518);
  color: var(--night-canvas, #ffffff);
  font-weight: 500;
}
.upg-pill:disabled { opacity: .55; cursor: not-allowed; }

.upg-cost-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--upg-border);
  border-radius: 10px;
  background: var(--upg-subtle);
}
.upg-cost-box.is-warn {
  border-color: #d97706;
}
.upg-cost-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.upg-cost-label {
  font-size: 13px;
  color: var(--upg-muted);
}
.upg-cost-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.upg-cost-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--upg-muted);
}
.upg-topup-inline {
  align-self: flex-start;
  margin-top: 4px;
  min-height: 32px;
}
.upg-submit-row {
  display: flex;
}
.upg-submit-btn {
  width: 100%;
  min-height: 42px;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.upg-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.upg-panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.upg-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--upg-border);
  font-size: 12px;
  color: var(--upg-muted);
  white-space: nowrap;
}
.upg-status-chip.is-succeeded { color: #16a34a; border-color: rgba(22, 163, 74, .35); }
.upg-status-chip.is-failed,
.upg-status-chip.is-expired { color: #dc2626; border-color: rgba(220, 38, 38, .35); }
.upg-status-chip.is-running,
.upg-status-chip.is-queued { color: #2563eb; border-color: rgba(37, 99, 235, .35); }

.upg-alert {
  padding: 10px 12px;
  border: 1px solid rgba(220, 38, 38, .35);
  border-radius: 10px;
  color: #dc2626;
  font-size: 13px;
  line-height: 1.5;
}
.upg-progress-stage,
.upg-empty-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  padding: 24px;
  border: 1px dashed var(--upg-border);
  border-radius: 12px;
  text-align: center;
  color: var(--upg-muted);
}
.upg-elapsed { font-size: 12px; font-variant-numeric: tabular-nums; }
.upg-cancel-btn { margin-top: 6px; min-height: 34px; }
.upg-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--upg-border);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: upg-spin .8s linear infinite;
}
@keyframes upg-spin { to { transform: rotate(360deg); } }

.upg-media-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.upg-media-stage video,
.upg-media-stage img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 10px;
  background: #0d1016;
}
.upg-receipt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding-top: 12px;
  border-top: 1px solid var(--upg-border);
}
.upg-receipt-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 13px;
  color: var(--upg-muted);
}
.upg-receipt-charge {
  color: inherit;
  font-variant-numeric: tabular-nums;
}
.upg-sandbox-pill {
  padding: 2px 7px;
  border: 1px solid var(--upg-border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--upg-muted);
}

.upg-recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upg-recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--upg-border);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.upg-recent-item:hover,
.upg-recent-item.is-active {
  border-color: currentColor;
  background: var(--upg-subtle);
}
.upg-recent-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.upg-recent-main strong { font-size: 13px; font-weight: 600; }
.upg-recent-prompt {
  font-size: 12px;
  color: var(--upg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upg-recent-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.upg-recent-cost {
  font-size: 12px;
  color: var(--upg-muted);
  font-variant-numeric: tabular-nums;
}
.upg-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--upg-muted);
}
.upg-state-error { color: #dc2626; }

@media (max-width: 980px) {
  .upg-workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .preview-models .um-toolbar { width: 100%; }
  .preview-models .um-search { flex: 1 1 180px; }
  .preview-models .um-search input { width: 100%; }
  .preview-models .st-feature-image { min-height: 148px; }
  .preview-models .st-feature-name { font-size: 15px; }
  .preview-models .st-card-actions .st-card-action {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }
  .upg-panel { padding: 16px; }
}

/* Router catalog skeleton loading & retry banner */
@keyframes um-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.preview-models .um-skeleton-card {
  pointer-events: none;
  user-select: none;
}
.preview-models .um-skeleton-media {
  background: linear-gradient(
    90deg,
    var(--night-inset, #f1f3f6) 25%,
    var(--night-border, #e5e7eb) 50%,
    var(--night-inset, #f1f3f6) 75%
  );
  background-size: 200% 100%;
  animation: um-shimmer 1.4s ease-in-out infinite;
}
.preview-models .um-skeleton-media::after {
  display: none;
}
.preview-models .um-skeleton-info {
  gap: 10px;
}
.preview-models .um-skeleton-line {
  display: block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--night-inset, #f1f3f6) 25%,
    var(--night-border, #e5e7eb) 50%,
    var(--night-inset, #f1f3f6) 75%
  );
  background-size: 200% 100%;
  animation: um-shimmer 1.4s ease-in-out infinite;
}
.preview-models .um-skeleton-line.is-category {
  width: 58%;
  height: 12px;
}
.preview-models .um-skeleton-line.is-price {
  width: 44%;
  height: 20px;
}
.preview-models .um-skeleton-line.is-button {
  width: 100%;
  height: 34px;
  margin-top: auto;
  border-radius: 8px;
}
.preview-models .um-load-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--night-border, #e2e4e8);
  border-radius: 10px;
  background: var(--night-surface, #f8f9fb);
  color: var(--night-muted, #62666d);
  font-size: 13px;
}
@media (prefers-reduced-motion: reduce) {
  .preview-models .um-skeleton-media,
  .preview-models .um-skeleton-line {
    animation: none;
  }
}
/* Dashboard v3: Full-width restrained Get Started strip (Light + Dark parity) */
#root .p-console.p-customer .studio-dashboard .hm-onboard {
  margin: 0 0 18px;
  border: 1px solid #e7e8ec;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(16, 18, 24, 0.03);
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid #eff0f3;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-title h2 {
  margin: 0 !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  letter-spacing: -0.01em;
  color: #18181b;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-progress {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 92px;
  padding: 14px 18px 15px;
  border-right: 1px solid #eff0f3;
  background: transparent;
  transition: background 140ms ease;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step:last-child {
  border-right: 0;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-clickable {
  cursor: pointer;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-clickable:hover {
  background: #f9fafb;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-active {
  background: #fafbfc;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step-top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-dot {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #d4d7de;
  background: transparent;
  color: #71717a;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-active .hm-onboard-dot {
  border-color: #18181b;
  background: #18181b;
  color: #ffffff;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-complete .hm-onboard-dot {
  border-color: #35a366;
  background: #35a366;
  color: #ffffff;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: #18181b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-complete .hm-onboard-label {
  color: #71717a;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-foot {
  display: flex;
  align-items: center;
  padding-left: 27px;
  min-height: 30px;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px !important;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent !important;
  color: #52525b !important;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 140ms ease;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-step:hover .hm-onboard-link,
#root .p-console.p-customer .studio-dashboard .hm-onboard-link:hover {
  color: #18181b !important;
}
#root .p-console.p-customer .studio-dashboard .hm-onboard-muted {
  font-size: 12px;
  color: #9ca3af;
}
#root .p-console.p-customer .studio-dashboard .hm-explore-wide {
  margin-top: 24px;
}
#root .p-console.p-customer .studio-dashboard .hm-explore-wide .hm-explore {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

/* Dark mode parity for Get Started strip */
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard {
  background: var(--night-surface) !important;
  border-color: var(--night-border) !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-head {
  border-bottom-color: var(--night-line) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-title h2 {
  color: var(--night-text) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-progress {
  background: var(--night-raised) !important;
  color: var(--night-muted) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step {
  border-right-color: var(--night-line) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-clickable:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-active {
  background: rgba(255, 255, 255, 0.025) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-dot {
  border-color: #46464f;
  color: var(--night-muted);
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-active .hm-onboard-dot {
  border-color: #ededf0;
  background: #ededf0;
  color: #171719;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-complete .hm-onboard-dot {
  border-color: #309459;
  background: #309459;
  color: #ffffff;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-label {
  color: var(--night-text) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step.is-complete .hm-onboard-label {
  color: var(--night-muted) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-link {
  color: var(--night-muted) !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step:hover .hm-onboard-link,
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-link:hover {
  color: #ffffff !important;
}
html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-muted {
  color: var(--night-subtle) !important;
}

@media (max-width: 960px) {
  #root .p-console.p-customer .studio-dashboard .hm-onboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #root .p-console.p-customer .studio-dashboard .hm-onboard-step {
    border-bottom: 1px solid #eff0f3;
  }
  #root .p-console.p-customer .studio-dashboard .hm-onboard-step:nth-child(2n) {
    border-right: 0;
  }
  #root .p-console.p-customer .studio-dashboard .hm-onboard-step:nth-last-child(-n+2) {
    border-bottom: 0;
  }
  html[data-preview-theme="dark"] #root .p-console.p-customer .studio-dashboard .hm-onboard-step {
    border-bottom-color: var(--night-line) !important;
  }
}

@media (max-width: 560px) {
  #root .p-console.p-customer .studio-dashboard .hm-onboard-grid {
    grid-template-columns: 1fr;
  }
  #root .p-console.p-customer .studio-dashboard .hm-onboard-step {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid #eff0f3;
  }
  #root .p-console.p-customer .studio-dashboard .hm-onboard-step:last-child {
    border-bottom: 0;
  }
}
