@import url('./selection.css');

html, body.workspace {
  height: 100%;
  overflow: hidden;
}

.workspace {
  --glass-bg: rgba(22, 24, 30, 0.58);
  --glass-bg-strong: rgba(18, 20, 26, 0.78);
  --glass-border: rgba(255, 255, 255, 0.13);
  --glass-border-hover: rgba(255, 255, 255, 0.26);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 10px 32px rgba(0, 0, 0, 0.38), var(--glass-highlight);
  --glass-blur: blur(24px) saturate(160%);
  --cta-bg: rgba(246, 247, 250, 0.95);
  --cta-ink: #0c0d11;
  --bg: #0c0d10;
}

/* Minimal top header */
.workspace-header {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 54px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 13, 16, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.workspace-header .brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.workspace-header .brand i {
  width: 17px;
  height: 17px;
  border-radius: 5px;
}
.workspace-header nav {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
}
.workspace-header nav a {
  display: flex;
  align-items: center;
  height: 100%;
  color: #8c8f9b;
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s ease;
}
.workspace-header nav a:hover {
  color: #d8dae2;
}
.workspace-header nav a.selected {
  color: #f5f6f8;
  border-color: rgba(255, 255, 255, 0.85);
}
.owner-link {
  color: #8c8f9b;
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s ease;
}
.owner-link:hover {
  color: #f5f6f8;
}

/* Single full-bleed 3D viewport */
.workspace-layout {
  display: block;
  height: calc(100dvh - 54px);
}
#viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(95% 85% at 50% 38%, #1c1e26 0%, #0d0e12 74%);
}
#view {
  position: absolute;
  inset: 0;
}
#view canvas {
  position: absolute;
  inset: 0;
  display: block;
}
#studioFrame {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  transition: opacity 0.25s ease;
}
#studioFrame.loading {
  opacity: 0;
  pointer-events: none;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Kept in DOM (not display:none) so iOS Safari opens the native file picker reliably */
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  left: 0;
  top: 0;
}

/* Base typography & buttons inside workspace */
.fine {
  color: #9498a6;
  font-size: 11px;
  line-height: 1.55;
}
.inline-error {
  color: #ff9a9a;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.inline-error:empty {
  display: none;
}

.workspace button,
.workspace .btn {
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  padding: 8px 15px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #ebedf2;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-highlight);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, opacity 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.workspace button:hover:not(:disabled),
.workspace .btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--glass-border-hover);
}
.workspace button:active:not(:disabled),
.workspace .btn:active {
  transform: scale(0.97);
}
.workspace button.primary,
.workspace .btn.primary,
.glass-cta {
  background: var(--cta-bg) !important;
  color: var(--cta-ink) !important;
  border: 1px solid rgba(255, 255, 255, 0.75) !important;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.42), inset 0 1px 0 #ffffff;
}
.workspace button.primary:hover:not(:disabled),
.workspace .btn.primary:hover,
.glass-cta:hover:not(:disabled) {
  background: #ffffff !important;
}

/* ---- Top Floating Liquid Glass Bar ------------------------------------------------ */
.viewport-bar {
  position: absolute;
  z-index: 20;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.viewport-left,
.viewport-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  pointer-events: auto;
}

/* Liquid Glass Segmented Capsules (Face | Body, Solid | Material | Wire) */
.viewport-bar .seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.viewport-bar .seg button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: #b7bac6;
  font-size: 11.5px;
  padding: 5px 12px;
  min-height: 28px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.viewport-bar .seg button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}
.viewport-bar .seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.viewport-bar .seg .shading-icon {
  width: 30px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

/* Liquid Glass Menus (Characters, More ...) */
.menu {
  position: relative;
}
.menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass-bg);
  color: #e9ebf0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.menu > summary::-webkit-details-marker {
  display: none;
}
.menu > summary:hover {
  border-color: var(--glass-border-hover);
  background: rgba(34, 37, 46, 0.72);
}
.menu[open] > summary {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(38, 41, 52, 0.84);
}
.menu .caret {
  opacity: 0.68;
  transition: transform 0.16s ease;
}
.menu[open] .caret {
  transform: rotate(180deg);
}
.project-menu > summary svg:first-child {
  color: #e9ebf0;
  opacity: 0.9;
}
.project-menu #modelLabel {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #eef0f5;
  font-size: 12px;
}

.menu-pop {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  min-width: 244px;
  max-width: min(340px, calc(100vw - 28px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 6px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), var(--glass-highlight);
  animation: menu-in 0.15s ease-out;
}
.menu-pop.right {
  left: auto;
  right: 0;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-5px) scale(0.98); }
}
.menu-head {
  padding: 6px 10px 4px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b8f9e;
}
.menu-head span {
  color: #cfd2dc;
}
.menu-sep {
  height: 1px;
  margin: 6px 6px;
  background: rgba(255, 255, 255, 0.08);
}
.workspace .menu-item {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #dcdfe8;
  font-size: 12px;
  text-decoration: none;
  text-align: left;
  box-shadow: none;
  backdrop-filter: none;
}
.workspace .menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.workspace .menu-new {
  color: #ffffff;
  font-weight: 600;
}
.menu-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: #c5c8d4;
}
#navigationPreset {
  height: 28px;
  width: auto;
  min-width: 104px;
  padding: 2px 8px;
  font-size: 11.5px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ebedf2;
}
.menu-note {
  margin: 4px 10px 6px;
}
.menu-note:empty {
  display: none;
}
.menu-empty {
  margin: 4px 10px 6px;
}
#recentlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}
.workspace #recentlist .jobrow {
  justify-content: flex-start;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 6px 9px;
  border-radius: 11px;
  text-align: left;
  font-size: 11.5px;
  box-shadow: none;
  backdrop-filter: none;
}
.workspace #recentlist .jobrow:hover {
  background: rgba(255, 255, 255, 0.09);
}
.workspace #recentlist .jobrow.current {
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 2px 0 0 #ffffff;
}
.jobrow img {
  width: 32px;
  height: 38px;
  object-fit: cover;
  border-radius: 6px;
}
.jobrow > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.jobrow > span > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jobrow small {
  font-size: 10px;
  color: #9397a5;
}

/* Result actions (Download + More ...): ONLY visible when rig is done */
#result {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  margin: 0;
}
#result #download {
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 12px;
}
#more > summary {
  width: 34px;
  padding: 0;
  justify-content: center;
}

/* ---- Empty Stage (Liquid Glass Drop Card) ----------------------------------------- */
.viewport-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  text-align: center;
  pointer-events: none;
}
.empty-glass-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 340px;
  width: 100%;
  padding: 34px 28px 30px;
  background: rgba(22, 24, 31, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 26px;
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e9ebf2;
}
.viewport-empty h2 {
  font-size: 17px;
  font-weight: 500;
  color: #f2f3f7;
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}
.viewport-empty p {
  font-size: 12px;
  color: #8f93a2;
  margin: 0 0 22px;
}
.viewport-empty label.btn {
  pointer-events: auto;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 12.5px;
}

.file-drag-over #viewport:after {
  content: "Drop 3D model";
  position: absolute;
  inset: 14px;
  z-index: 100;
  display: grid;
  place-items: center;
  border: 1.5px dashed rgba(255, 255, 255, 0.55);
  border-radius: 22px;
  background: rgba(16, 18, 24, 0.76);
  backdrop-filter: blur(16px);
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  pointer-events: none;
}

/* ---- Bottom Primary Actions (Instant 0ms Upload / Rig Character) ------------------ */
#viewportActions {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 5px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  pointer-events: auto;
}
#viewportActions [hidden] {
  display: none !important;
}
#viewportActions .glass-secondary {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #dfe2ec;
  font-size: 12.5px;
  cursor: pointer;
}
#viewportActions .glass-secondary:hover {
  background: rgba(255, 255, 255, 0.13);
  color: #ffffff;
}
#viewportActions .wide {
  width: auto;
  min-width: 176px;
  height: 40px;
  margin: 0;
  padding: 0 24px;
  font-size: 13px;
  border-radius: 999px;
  pointer-events: auto;
}
#viewportActions .actions-note {
  flex-basis: 100%;
  margin: 2px 0 0;
  text-align: center;
  color: #9397a5;
  pointer-events: none;
}

/* ---- Building Progress Capsule ---------------------------------------------------- */
.build-status {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 13px;
  width: min(380px, calc(100% - 28px));
  padding: 12px 16px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  box-shadow: var(--glass-shadow);
  pointer-events: none;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.build-meter {
  position: relative;
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
}
.build-meter svg {
  position: absolute;
  inset: 0;
  width: 42px;
  height: 42px;
  transform: rotate(-90deg);
}
.build-meter circle {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}
.build-track {
  stroke: rgba(255, 255, 255, 0.14);
}
#buildRing {
  stroke: #f5f6f8;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
  transition: stroke-dashoffset 0.3s ease;
}
.build-meter span {
  font-size: 10px;
  color: #f5f6f8;
  font-variant-numeric: tabular-nums;
}
.build-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.build-copy strong {
  font-size: 12px;
  font-weight: 600;
  color: #f3f4f8;
}
.build-copy span,
.build-copy small {
  font-size: 10.5px;
  color: #a2a6b4;
  overflow-wrap: anywhere;
}
.build-copy small {
  color: #cfd2de;
  font-variant-numeric: tabular-nums;
}
.build-copy small:empty {
  display: none;
}
.build-more {
  pointer-events: auto;
  width: 28px;
  height: 28px;
  flex: none;
  margin-left: auto;
  padding: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #c2c6d4;
}
.waiting .build-meter svg {
  animation: build-wait 1.8s linear infinite;
}
.waiting #buildRing {
  stroke-dasharray: 28 85;
  stroke-dashoffset: 0 !important;
}
@keyframes build-wait {
  to { transform: rotate(270deg); }
}

/* ---- Part-Marking Stage Floating Liquid Glass Dock -------------------------------- */
#viewport #mark {
  position: absolute;
  z-index: 13;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
}
#viewport #mark[hidden] {
  display: none !important;
}
#viewport #mark .roles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin: 0;
}
#viewport #mark .role {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  transition: border-color 0.15s ease, background 0.15s ease;
}
#viewport #mark .role.on {
  border-color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.14);
}
#viewport #mark .role .pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 6px 10px;
  border-radius: 0;
  background: transparent;
  font-size: 11px;
  box-shadow: none;
  backdrop-filter: none;
}
#viewport #mark .role .sw {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
#viewport #mark .role .eye {
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  padding: 6px 7px;
  background: transparent;
  color: #c5c8d4;
  box-shadow: none;
  backdrop-filter: none;
}
#viewport #mark .role .eye.off {
  opacity: 0.35;
}
#viewport #mark .role .n {
  display: none;
}

/* Compact Rigid & Facial Guides Popovers inside #mark */
.hard-pop,
#viewport #mark #wrapGuides {
  position: relative;
}
.hard-pop > summary,
#viewport #mark #wrapGuides > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #dcdfe8;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.hard-pop > summary::-webkit-details-marker,
#viewport #mark #wrapGuides > summary::-webkit-details-marker {
  display: none;
}
.hard-pop[open] > summary,
#viewport #mark #wrapGuides[open] > summary {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
}
.hard-badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.hard-pop-card {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 25;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), var(--glass-highlight);
}
.hard-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.hard-tools #hardParts {
  flex: 1;
  padding: 6px 10px;
  font-size: 11px;
}
.hard-tools #hardParts[aria-pressed="true"] {
  border-color: #6ee7cf;
  color: #6ee7cf;
  background: rgba(110, 231, 207, 0.12);
}
.hard-tools #clearHard {
  padding: 6px 10px;
  font-size: 11px;
}
#metalRigid {
  width: 100%;
  padding: 6px 10px;
  font-size: 11px;
}

#viewport #mark #wrapGuides[open] {
  flex-basis: 100%;
  max-width: 360px;
  max-height: 32vh;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
}
#wrapGuides label {
  display: block;
  margin: 7px 0;
}
#wrapGuides select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 5px 8px;
  font-size: 11px;
}
#wrapGuides .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 7px 0;
}

#viewport #mark #neckrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}
#viewport #mark #neckrow[hidden] {
  display: none !important;
}
#viewport #mark #neckrow .field-label {
  margin: 0;
  font-size: 11px;
  color: #b7bac6;
}
#neck {
  width: 110px;
}
#viewport #mark #markHelp {
  flex-basis: 100%;
  order: 9;
  margin: 1px 0 0;
  text-align: center;
  font-size: 10.5px;
}
#viewport #mark #markerr {
  flex-basis: 100%;
  order: 10;
  margin: 0;
  text-align: center;
}

/* ---- Status Pills, Hints & Processing Details Modal ------------------------------- */
#viewportStatus {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 7px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  font-size: 11.5px;
  color: #d5d8e2;
  white-space: nowrap;
  pointer-events: none;
}
.viewport-hint {
  position: absolute;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  max-width: 85%;
  font-size: 11.5px;
  color: #cfd2de;
  margin: 0;
  text-align: center;
  pointer-events: none;
}
.viewport-controls {
  position: absolute;
  bottom: 16px;
  right: 18px;
  color: rgba(190, 194, 208, 0.52);
  font-size: 10.5px;
  margin: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.viewport-toast {
  position: absolute;
  z-index: 25;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(500px, calc(100% - 28px));
  margin: 0;
  padding: 10px 16px;
  background: rgba(58, 24, 26, 0.86);
  border: 1px solid rgba(240, 128, 128, 0.42);
  border-radius: 14px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #ffdada;
}

.job-card {
  position: absolute;
  z-index: 24;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 28px));
  padding: 20px 20px 18px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), var(--glass-highlight);
  display: none;
}
body[data-stage="failed"] .job-card,
body[data-workspace-state="failed"] .job-card,
.job-card.show {
  display: block;
}
.job-state {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.job-state b {
  font-size: 13.5px;
  font-weight: 600;
}
#job.failed .job-state b {
  color: #ff9a9a;
}
.job-state small {
  font-size: 11.5px;
  color: #a3a7b5;
  overflow-wrap: anywhere;
}
.progress-track {
  display: none;
}
.job-timing {
  font-size: 11px;
  line-height: 1.6;
  color: #b9bcc8;
  font-variant-numeric: tabular-nums;
  margin: 10px 0 0;
}
#jobDetails summary {
  color: #a2a6b4;
  font-size: 11.5px;
  cursor: pointer;
  margin-top: 10px;
}
#log {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 10.5px;
  line-height: 1.6;
  max-height: 240px;
  overflow-y: auto;
  color: #b4b8c6;
  margin-top: 8px;
}
.job-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9ba0ae;
  display: grid;
  place-items: center;
  box-shadow: none;
}
body[data-stage="failed"] .job-close,
body[data-workspace-state="failed"] .job-close {
  display: none;
}
.job-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.job-actions:empty {
  display: none;
}

/* ============================================================================
   STAGE-CONTEXTUAL VISIBILITY (Apple Liquid Glass Minimalist Principle:
   Only show controls that can actually be used in the current stage)
   ============================================================================ */

/* Hide Characters switcher on empty screen when there are 0 saved rigs */
body[data-stage="empty"] #recent[data-has-jobs="0"] {
  display: none !important;
}

/* 1. EMPTY STAGE: Clean drop card only. No framing, no shading, no download, no action bar */
body[data-stage="empty"] #frameTools,
body[data-stage="empty"] #lookTools,
body[data-stage="empty"] #result,
body[data-stage="empty"] #viewportActions,
body[data-stage="empty"] #orbitHint {
  display: none !important;
}

/* 2. PREVIEW STAGE (model chosen, ready to upload):
      Upload / Continue upload button appears INSTANTLY (0ms).
      Framing & shading fade in only after 3D preview finishes parsing. */
body[data-stage="preview"] #result,
body[data-stage="preview"] #mark,
body[data-stage="preview"] #rig,
body[data-stage="preview"] #orbitHint {
  display: none !important;
}
body[data-stage="preview"][data-preview-loaded="0"] #frameTools,
body[data-stage="preview"][data-preview-loaded="0"] #lookTools {
  opacity: 0;
  pointer-events: none;
}

/* 3. BUILDING STAGE (uploading / analyzing / rigging):
      Only the clean progress capsule; hide unusable buttons */
body[data-stage="building"] #viewportActions,
body[data-stage="building"] #result,
body[data-stage="building"] #mark,
body[data-stage="building"] #frameTools,
body[data-stage="building"] #lookTools,
body[data-stage="building"] #orbitHint {
  display: none !important;
}

/* 4. MARKING STAGE (checking parts):
      Role pills + Wireframe + Face/Body + Rig character.
      Hide Solid/Material buttons (disabled during role painting) and Download. */
body[data-stage="marking"] #result,
body[data-stage="marking"] #go,
body[data-stage="marking"] #reselect,
body[data-stage="marking"] #clayPreview,
body[data-stage="marking"] #materialPreview,
body[data-stage="marking"] #orbitHint {
  display: none !important;
}
body[data-stage="marking"] #hoverinfo {
  bottom: auto;
  top: 60px;
}

/* 5. DONE STAGE (finished rig in interactive 3D Studio):
      Show Face/Body, Solid/Material/Wire, Download + More (...).
      Hide bottom upload/rig action pill and duplicate studio item. */
body[data-stage="done"] #viewportActions,
body[data-stage="done"] #mark,
body[data-stage="done"] #orbitHint,
body:has(#studioFrame:not([hidden])) #studio {
  display: none !important;
}

/* 6. FAILED STAGE */
body[data-stage="failed"] #viewportActions,
body[data-stage="failed"] #result,
body[data-stage="failed"] #frameTools,
body[data-stage="failed"] #lookTools,
body[data-stage="failed"] #orbitHint {
  display: none !important;
}

/* Responsive mobile / iPhone refinement */
@media (max-width: 700px) {
  .workspace-header {
    height: 50px;
    gap: 14px;
    padding: 0 12px;
  }
  .workspace-header .brand span {
    display: none;
  }
  .workspace-header nav {
    gap: 16px;
  }
  .workspace-header nav a {
    font-size: 12px;
  }
  .workspace-layout {
    height: calc(100dvh - 50px);
  }
  .viewport-bar {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 6px;
  }
  #viewportActions {
    bottom: 14px;
  }
  .build-status {
    bottom: 14px;
    padding: 10px 14px;
  }
  #viewport #mark {
    bottom: 70px;
    padding: 7px 8px;
  }
}

@media (max-width: 520px) {
  .viewport-bar {
    flex-wrap: nowrap;
  }
  .viewport-left,
  .viewport-right {
    gap: 5px;
  }
  .project-menu > summary {
    padding: 0 10px;
    gap: 5px;
  }
  .project-menu #modelLabel {
    display: none;
  }
  .viewport-bar .seg button {
    padding: 5px 9px;
    font-size: 11px;
  }
  .viewport-bar .seg .shading-icon {
    width: 27px;
    height: 26px;
  }
  .dl-text {
    display: none;
  }
  #result #download {
    width: 34px;
    padding: 0;
  }
  #more .menu-pop,
  .project-menu .menu-pop {
    position: fixed;
    left: 10px;
    right: 10px;
    top: 98px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .waiting .build-meter svg {
    animation: none;
  }
  #buildRing {
    transition: none;
  }
}
