:root {
  color-scheme: dark;
  --panel: rgba(15, 17, 18, 0.86);
  --panel-strong: rgba(6, 7, 8, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f7f3e8;
  --muted: #b7b0a4;
  --accent: #28d2a4;
  --accent-strong: #10b887;
  --warm: #ffbd59;
  --danger: #ff6b6b;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.38);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

body {
  color: var(--text);
}

a-scene {
  width: 100%;
  height: 100%;
}

.app-shell {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.control-panel,
.panel-toggle,
.loading-overlay,
.progress-panel,
.toast {
  pointer-events: auto;
}

.control-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: min(440px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.app-shell.is-panel-hidden .control-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 24px));
}

.panel-toggle {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.panel-show-button {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 12;
  min-width: 64px;
  padding: 0 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel-hide-button {
  min-width: 48px;
  padding: 0 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.brand-row > div:first-child {
  min-width: 0;
}

.brand-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.brand-row h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.source-chip {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 6px 9px;
  border: 1px solid rgba(40, 210, 164, 0.42);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  text-align: center;
}

.source-form {
  display: grid;
  gap: 10px;
}

.workspace-panel {
  display: grid;
  gap: 12px;
}

.load-button,
.ghost-button,
.icon-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.field-grid.is-hidden {
  display: none;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

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

.field input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  padding: 0 10px;
}

.field input:focus {
  border-color: rgba(40, 210, 164, 0.8);
  box-shadow: 0 0 0 3px rgba(40, 210, 164, 0.16);
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.load-button {
  min-width: 116px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #061210;
  font-weight: 700;
}

.load-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.danger-button {
  border-color: rgba(255, 107, 107, 0.44);
  background: rgba(255, 107, 107, 0.12);
  color: #ffd8d8;
}

.ghost-button {
  min-width: 104px;
  padding: 0 14px;
}

.icon-button {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.task-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.file-field input {
  padding-top: 8px;
}

.upload-meter {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.task-list {
  display: grid;
  max-height: min(48vh, 460px);
  overflow: auto;
  gap: 9px;
  padding-right: 3px;
}

.task-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.task-item.is-completed {
  border-color: rgba(40, 210, 164, 0.38);
}

.task-item.is-failed {
  border-color: rgba(255, 107, 107, 0.46);
}

.task-header,
.task-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-title {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.task-title strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title span,
.task-footer span,
.empty-state,
.task-error {
  color: var(--muted);
  font-size: 12px;
}

.task-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.task-progress div {
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: transform 180ms ease;
}

.task-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-error {
  margin: 0;
  color: #ffd8d8;
}

.empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.64);
  opacity: 0;
  transition: opacity 360ms ease;
}

.loading-overlay.is-visible {
  opacity: 1;
}

.progress-panel {
  width: min(560px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 360ms ease,
    transform 360ms ease;
}

.loading-overlay.is-visible .progress-panel {
  opacity: 1;
  transform: translateY(0);
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.progress-copy strong {
  font-size: 13px;
}

.progress-copy span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-bar {
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: transform 160ms ease;
}

.progress-track.is-indeterminate .progress-bar {
  width: 42%;
  transform: translateX(-120%);
  animation: indeterminate 1.1s ease-in-out infinite;
}

.toast {
  position: absolute;
  left: 16px;
  bottom: 20px;
  width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 107, 0.44);
  border-radius: 8px;
  background: rgba(34, 10, 12, 0.92);
  color: #ffd8d8;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@keyframes indeterminate {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(260%);
  }
}

@media (max-width: 720px) {
  .control-panel {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .brand-row {
    align-items: flex-start;
  }

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

  .toast {
    left: 10px;
    bottom: 92px;
    width: calc(100vw - 20px);
  }

  .panel-show-button {
    top: 10px;
    right: 10px;
  }
}
