:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(17, 24, 39, 0.88);
  --panel-border: rgba(148, 163, 184, 0.18);
  --text: #e5eefc;
  --muted: #8da2c0;
  --accent: #6d7cff;
  --accent-2: #8b5cf6;
  --success: #34d399;
  --danger: #fb7185;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(109, 124, 255, 0.22), transparent 22%),
    radial-gradient(circle at top right, rgba(139, 92, 246, 0.18), transparent 24%),
    linear-gradient(180deg, #08101f 0%, #0f172a 100%);
  overflow: hidden;
}

body.auth-locked {
  overflow: auto;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 24px auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #9db2ff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 720px;
  line-height: 1.6;
}

.status-chip {
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  color: #c7d2fe;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.page-link:hover {
  border-color: rgba(109, 124, 255, 0.5);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1.2fr 360px;
  gap: 18px;
}

.video-workspace {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.video-main-column {
  display: grid;
  min-height: 0;
  grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 12px;
}

.enhance-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.enhance-preview-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-center {
  min-width: 0;
}

.panel-title h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.panel-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  color: #d8e4ff;
  font-size: 12px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input[type="file"] {
  padding: 8px 10px;
  color: #dbeafe;
}

.field input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #eff6ff;
  padding: 8px 12px;
  cursor: pointer;
}

.field input[type="file"]::-webkit-file-upload-button {
  margin-right: 10px;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #eff6ff;
  padding: 8px 12px;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button:hover,
.field input[type="file"]::-webkit-file-upload-button:hover {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(109, 124, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(109, 124, 255, 0.16);
}

.field textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.45;
}

.grow {
  flex: 1;
}

.grid {
  display: grid;
  gap: 10px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-row,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-row label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  min-width: 104px;
}

.ghost-button {
  background: rgba(30, 41, 59, 0.85);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.preview-card,
.task-box,
.progress-card,
.note-box,
.log-box,
.history-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.72);
}

.preview-card {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  min-height: 132px;
  padding: 10px;
  overflow: hidden;
}

.preview-card img,
.preview-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#resultVideo {
  object-fit: contain;
  background: #020617;
}

.generation-overlay {
  position: absolute;
  inset: 10px;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(125, 145, 255, 0.24);
  border-radius: 16px;
  background:
    radial-gradient(circle at 24% 18%, rgba(109, 124, 255, 0.28), transparent 24%),
    radial-gradient(circle at 76% 72%, rgba(139, 92, 246, 0.24), transparent 26%),
    linear-gradient(135deg, rgba(2, 6, 23, 0.92), rgba(15, 23, 42, 0.9));
  box-shadow: inset 0 0 42px rgba(99, 102, 241, 0.16);
  text-align: center;
}

.generation-overlay::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.16) 48%, transparent 58%);
  animation: generation-scan 3.8s linear infinite;
}

.generation-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle, black 0%, transparent 72%);
}

.generation-orbit {
  position: relative;
  z-index: 1;
  width: 82px;
  height: 82px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  animation: generation-spin 4.4s linear infinite;
}

.generation-orbit span {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #93c5fd, #a78bfa);
  box-shadow: 0 0 22px rgba(129, 140, 248, 0.85);
}

.generation-orbit span:nth-child(1) {
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
}

.generation-orbit span:nth-child(2) {
  right: 4px;
  bottom: 10px;
  animation: generation-pulse 1.8s ease-in-out infinite;
}

.generation-orbit span:nth-child(3) {
  left: 4px;
  bottom: 10px;
  animation: generation-pulse 1.8s ease-in-out infinite 0.4s;
}

.generation-copy {
  position: relative;
  z-index: 1;
}

.generation-copy strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.generation-copy p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.generation-wave {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
  height: 34px;
}

.generation-wave span {
  width: 7px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #a5b4fc, #6d7cff);
  animation: generation-wave 1s ease-in-out infinite;
}

.generation-wave span:nth-child(2) {
  animation-delay: 0.12s;
}

.generation-wave span:nth-child(3) {
  animation-delay: 0.24s;
}

.generation-wave span:nth-child(4) {
  animation-delay: 0.36s;
}

.generation-steps {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.generation-steps span {
  padding: 5px 9px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #c7d2fe;
  font-size: 11px;
  animation: generation-step-glow 2.8s ease-in-out infinite;
}

.generation-steps span:nth-child(2) {
  animation-delay: 0.35s;
}

.generation-steps span:nth-child(3) {
  animation-delay: 0.7s;
}

.generation-steps span:nth-child(4) {
  animation-delay: 1.05s;
}

.image-generation-overlay {
  inset: 8px;
}

@keyframes generation-scan {
  from {
    transform: translateX(-35%) rotate(0deg);
  }
  to {
    transform: translateX(35%) rotate(0deg);
  }
}

@keyframes generation-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes generation-pulse {
  0%, 100% {
    opacity: 0.5;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.18);
  }
}

@keyframes generation-wave {
  0%, 100% {
    height: 12px;
    opacity: 0.55;
  }
  50% {
    height: 34px;
    opacity: 1;
  }
}

@keyframes generation-step-glow {
  0%, 100% {
    border-color: rgba(148, 163, 184, 0.16);
    color: #94a3b8;
  }
  50% {
    border-color: rgba(129, 140, 248, 0.55);
    color: #eef2ff;
    box-shadow: 0 0 18px rgba(99, 102, 241, 0.22);
  }
}

.preview-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.compact-preview-card .preview-grid {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.preview-item {
  position: relative;
  overflow: hidden;
  min-height: 88px;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.55);
}

.preview-item img,
.preview-item video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 88px;
  object-fit: cover;
}

.preview-item img {
  cursor: zoom-in;
}

.reference-placeholder-button {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  border: 1px solid rgba(191, 219, 254, 0.56);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.82);
  color: #dbeafe;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.28);
}

.reference-placeholder-button:hover {
  border-color: rgba(129, 140, 248, 0.92);
  background: rgba(79, 70, 229, 0.9);
  color: #fff;
}

.reference-image-delete-button {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(254, 202, 202, 0.58);
  border-radius: 999px;
  background: rgba(127, 29, 29, 0.86);
  color: #fee2e2;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.3);
}

.reference-image-delete-button:hover {
  border-color: rgba(248, 113, 113, 0.92);
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
}

.reference-placeholder-picker {
  position: absolute;
  z-index: 80;
  display: grid;
  gap: 4px;
  max-height: 360px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid rgba(129, 140, 248, 0.42);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 18px 42px rgba(2, 6, 23, 0.42);
}

.reference-placeholder-picker[hidden] {
  display: none !important;
}

.reference-placeholder-picker button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 8px 10px;
  background: transparent;
  color: #e5e7eb;
  text-align: left;
  cursor: pointer;
}

.reference-placeholder-picker button:disabled {
  cursor: default;
  opacity: 0.72;
}

.reference-placeholder-picker button:hover,
.reference-placeholder-picker button.active {
  background: rgba(79, 70, 229, 0.48);
}

.reference-placeholder-option-content {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.reference-placeholder-option-content strong,
.reference-placeholder-option-content span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-placeholder-picker .reference-placeholder-option-content span {
  color: var(--muted);
  font-size: 12px;
}

.asset-placeholder-option {
  min-height: 58px;
}

.asset-placeholder-thumb {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.52);
  color: var(--muted);
}

.asset-placeholder-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item audio {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
}

.preview-large {
  min-height: 280px;
}

.preview-stage {
  min-height: 300px;
  flex: 1;
}

.result-meta {
  flex: 0 0 auto;
  max-height: 168px;
  min-height: 72px;
  overflow: auto;
  color: #dbeafe;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result-meta.status-danger {
  color: #ffe4e6;
  background: rgba(127, 29, 29, 0.32);
  border-color: rgba(251, 113, 133, 0.42);
}

.compact-preview-card {
  min-height: 96px;
}

.file-dropzone {
  cursor: pointer;
  border-style: dashed;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.file-dropzone.drag-over {
  border-color: rgba(129, 140, 248, 0.86);
  background: rgba(79, 70, 229, 0.16);
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.38), 0 0 24px rgba(99, 102, 241, 0.22);
}

.empty-state {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.45;
}

.task-box {
  padding: 10px 12px;
}

.progress-card,
.history-card {
  padding: 10px 12px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.85);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.progress-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.task-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.task-row:last-child {
  border-bottom: 0;
}

.task-row span {
  color: var(--muted);
}

.task-row code,
.task-row a {
  color: #cbd5ff;
  word-break: break-all;
  text-align: right;
}

.task-row a {
  text-decoration: none;
}

.note-box,
.log-box {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.preview-panel,
.history-strip-panel,
.video-side-panel {
  min-height: 0;
}

.history-strip-panel {
  overflow: hidden;
}

.enhance-task-panel,
.enhance-preview-panel {
  min-height: 0;
}

.enhance-task-panel {
  overflow: hidden;
}

.enhance-preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.enhance-preview-panel .preview-stage {
  min-height: 0;
  flex: 1 1 auto;
}

.video-shot-workspace {
  grid-template-columns: 300px minmax(0, 1fr);
}

.video-shot-preview-column {
  grid-template-rows: minmax(0, 1fr) minmax(0, 2fr);
}

.video-shot-task-panel,
.video-shot-preview-panel {
  min-height: 0;
}

.video-shot-result-stage {
  justify-content: flex-start;
  align-items: stretch;
}

.image-workspace {
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
}

.image-main-column {
  grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

.image-preview-panel {
  overflow: hidden;
}

.image-preview-split {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  min-height: 0;
  flex: 1 1 auto;
}

.image-preview-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.image-preview-block-primary {
  min-width: 0;
}

.image-preview-header {
  color: #d8e4ff;
  font-size: 12px;
}

.image-preview-stage {
  justify-content: flex-start;
  align-items: stretch;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}

.image-result-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: minmax(160px, 1fr);
  align-content: start;
}

.image-reference-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  grid-auto-rows: minmax(120px, 1fr);
  align-content: start;
}

.image-preview-stage .preview-grid.single-image-grid {
  height: 100%;
  min-height: 100%;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
}

.image-preview-stage .preview-grid.single-image-grid .preview-item {
  height: 100%;
  min-height: 100%;
}

.image-preview-stage .preview-grid.single-image-grid img {
  object-fit: contain;
  background: rgba(2, 6, 23, 0.7);
}

.image-preview-stage .preview-grid.multi-image-grid img {
  object-fit: cover;
}

.image-history-grid {
  min-height: 170px;
}

.image-side-panel {
  gap: 14px;
}

.video-empty-create-entry,
.image-empty-create-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  margin-top: 10px;
  border: 1px dashed rgba(99, 102, 241, 0.72);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.24), rgba(30, 41, 59, 0.42));
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.video-empty-create-entry:hover,
.image-empty-create-entry:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 140, 248, 0.92);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.34), rgba(67, 56, 202, 0.3));
  box-shadow: 0 18px 44px rgba(59, 130, 246, 0.18);
}

.video-empty-create-icon,
.image-empty-create-icon {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.34);
  color: #e0e7ff;
  font-size: 42px;
  line-height: 1;
}

.video-empty-create-entry strong,
.image-empty-create-entry strong {
  font-size: 24px;
  line-height: 1.2;
}

.video-empty-create-entry span:last-child,
.image-empty-create-entry span:last-child {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.video-task-form-section,
.image-task-form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.video-compute-estimate,
.image-compute-estimate {
  border: 1px solid rgba(139, 92, 246, 0.46);
  border-radius: 14px;
  padding: 12px 14px;
  color: #f8fbff;
  background: linear-gradient(135deg, rgba(109, 124, 255, 0.28), rgba(139, 92, 246, 0.22));
  box-shadow: 0 16px 36px rgba(109, 124, 255, 0.16);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}

.history-thumb-media img {
  width: 100%;
  height: 102px;
  object-fit: cover;
}

.image-thumb-media {
  min-height: 110px;
}

.image-thumb-title {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-preview-item {
  min-height: 140px;
}

.image-preview-load-error {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fecaca;
  font-size: 12px;
  background: rgba(127, 29, 29, 0.24);
}

.enhance-task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.enhance-task-card {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.45);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.enhance-task-card:hover,
.enhance-task-card.selected {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(59, 130, 246, 0.16);
}

.enhance-task-create {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  gap: 6px;
  border-style: dashed;
}

.enhance-task-create strong {
  font-size: 13px;
}

.enhance-task-create span {
  color: var(--muted);
  font-size: 11px;
}

.enhance-task-create-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.22);
  color: #dbe4ff;
  font-size: 22px;
  line-height: 1;
}

.enhance-task-media {
  flex: 0 0 104px;
  width: 104px;
  min-height: 84px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.enhance-task-media video,
.enhance-task-media img,
.enhance-task-media-empty {
  display: block;
  width: 100%;
  height: 100%;
}

.enhance-task-media video,
.enhance-task-media img {
  object-fit: cover;
}

.enhance-task-media-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}

.enhance-task-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.enhance-task-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.enhance-task-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.enhance-task-body strong {
  display: block;
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enhance-task-body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}

.enhance-task-body span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.video-side-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.history-thumbnail-grid {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  padding: 0 4px 4px 0;
}

.history-thumb-card {
  position: relative;
  flex: 0 0 150px;
  width: 150px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.45);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.history-thumb-card:hover,
.history-thumb-card.selected {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(59, 130, 246, 0.16);
}

.history-thumb-create {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 152px;
  border-style: dashed;
}

.history-thumb-create-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: 14px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.22);
  color: #dbe4ff;
  font-size: 24px;
  line-height: 1;
}

.history-thumb-toolbar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-status-badge,
.history-thumb-tags span {
  padding: 3px 7px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.76);
  color: var(--muted);
  font-size: 11px;
}

.history-delete-button {
  border: 1px solid rgba(251, 113, 133, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  color: #fecdd3;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.history-delete-button:hover {
  background: rgba(127, 29, 29, 0.38);
}

.history-thumb-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 102px;
  background: rgba(15, 23, 42, 0.92);
}

.history-thumb-media video {
  width: 100%;
  height: 102px;
  object-fit: cover;
}

.history-thumb-media img {
  width: 100%;
  height: 102px;
  object-fit: cover;
}

.history-thumb-content {
  padding: 8px 10px 10px;
}

.history-thumb-placeholder {
  color: var(--muted);
  font-size: 12px;
}

.history-thumb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-success {
  color: #d1fae5;
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.3);
}

.status-danger {
  color: #ffe4e6;
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.32);
}

.status-warning {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.3);
}

.status-neutral {
  color: #dbe4ff;
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.24);
}

.log-box {
  white-space: pre-wrap;
  min-height: 160px;
  max-height: 300px;
  overflow: auto;
}

.success {
  color: var(--success);
}

.danger {
  color: var(--danger);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .video-workspace {
    grid-template-columns: 1fr;
  }

  .enhance-workspace {
    grid-template-columns: 1fr;
  }

  .video-shot-workspace {
    grid-template-columns: 1fr;
  }

  .enhance-preview-column {
    grid-template-rows: auto auto;
  }

  .video-shot-preview-column {
    grid-template-rows: auto auto;
  }

  .video-main-column {
    grid-template-rows: auto auto;
  }

  .image-preview-split {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .app-header {
    flex-direction: column;
  }

  .video-side-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .history-strip-panel {
    overflow: visible;
  }

  .history-thumbnail-grid {
    min-height: auto;
    overflow-x: auto;
    overflow-y: hidden;
  }
}

.platform-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 220px minmax(0, 1fr);
}

.admin-shell {
  display: grid;
  height: 100vh;
  min-height: 100vh;
  grid-template-columns: 240px minmax(0, 1fr);
  overflow: hidden;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(18px);
  min-height: 0;
  overflow-y: auto;
}

.admin-brand h1 {
  margin: 4px 0 8px;
  font-size: 24px;
}

.admin-brand p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.admin-nav-item {
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.58);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.admin-nav-item:hover,
.admin-nav-item.active {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(59, 130, 246, 0.16);
  transform: translateY(-1px);
}

.admin-sidebar-footer {
  display: flex;
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-page {
  display: none;
  flex: 1;
  min-height: 0;
}

.admin-page.active {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.admin-placeholder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: var(--shadow);
}

.admin-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-panel-header h3 {
  margin: 0;
  font-size: 20px;
}

.admin-panel-header .subtitle {
  max-width: 280px;
  margin-top: 2px;
}

.admin-account-list-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.admin-task-list-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

body.admin-page-body {
  height: 100vh;
  overflow: hidden;
}

.admin-account-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(160px, 220px));
  gap: 10px;
}

.admin-task-filters {
  grid-template-columns: minmax(320px, 1.8fr) repeat(2, minmax(160px, 220px));
}

.admin-account-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-account-summary-item {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #dbeafe;
}

.admin-account-grid {
  display: block;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.admin-account-table {
  min-width: 1420px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.55);
}

.admin-account-row {
  display: grid;
  grid-template-columns: 180px 96px 96px 88px 150px 150px minmax(220px, 1fr) 88px 150px 280px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.admin-account-row:last-child {
  border-bottom: none;
}

.admin-account-row-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 23, 42, 0.96);
}

.admin-account-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 12px;
  border-right: 1px solid rgba(148, 163, 184, 0.08);
  word-break: break-word;
  line-height: 1.5;
}

.admin-account-row-head .admin-account-cell {
  color: #cbd5f5;
  font-size: 12px;
  font-weight: 600;
}

.admin-account-row .admin-account-cell:last-child {
  border-right: none;
}

.admin-account-user-cell {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.admin-account-user-cell strong {
  font-size: 14px;
}

.admin-account-user-cell span {
  color: var(--muted);
  font-size: 12px;
}

.admin-account-actions {
  justify-content: flex-start;
}

.admin-account-actions-cell {
  align-items: flex-start;
}

.admin-account-row-selected {
  background: rgba(59, 130, 246, 0.14);
}

.admin-compute-table {
  min-width: 1080px;
}

.admin-compute-table .admin-account-row {
  grid-template-columns: 180px 110px 96px 120px 160px 160px 260px;
}

.admin-compute-ledger-table {
  min-width: 980px;
}

.admin-compute-ledger-table .admin-account-row {
  grid-template-columns: 180px 130px 110px 130px minmax(300px, 1fr);
}

.admin-task-table {
  min-width: 1820px;
}

.admin-task-table .admin-account-row {
  grid-template-columns: 180px 110px 100px minmax(220px, 1.2fr) 180px 180px 90px 160px 160px minmax(280px, 1fr) 140px;
}

.admin-task-title-cell,
.admin-task-id-cell {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.admin-task-title-cell {
  font-family: inherit;
  font-size: 14px;
}

.admin-ledger-description-cell {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.admin-ledger-description-main {
  color: var(--text);
}

.admin-ledger-description-meta {
  color: var(--muted);
  font-size: 12px;
}

.admin-danger-button {
  border-color: rgba(251, 113, 133, 0.26);
  color: #ffe4e6;
  background: rgba(251, 113, 133, 0.12);
}

.admin-delete-button {
  border-color: rgba(248, 113, 113, 0.28);
  color: #ffe4e6;
  background: rgba(127, 29, 29, 0.24);
}

.admin-account-modal-card {
  width: min(100%, 520px);
}

.admin-task-modal-card {
  width: min(100%, 1200px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-task-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-task-detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.35);
}

.admin-task-detail-label {
  color: #cbd5f5;
  font-size: 12px;
}

.admin-task-detail-value {
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.admin-task-raw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
  flex: 1;
}

.admin-task-raw-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.48);
}

.admin-task-raw-header {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.admin-json-block {
  margin: 0;
  padding: 14px;
  min-height: 240px;
  overflow: auto;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-account-modal-card .auth-form-fields {
  gap: 12px;
}

@media (max-width: 980px) {
  .admin-account-filters {
    grid-template-columns: 1fr;
  }

  .admin-task-detail-grid,
  .admin-task-raw-grid {
    grid-template-columns: 1fr;
  }
}

.admin-debug-page {
  min-height: 0;
}

.admin-debug-frame {
  width: 100%;
  flex: 1;
  min-height: 640px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.82);
}

body.auth-locked .platform-shell {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 420px);
  gap: 24px;
  align-items: stretch;
  padding: 32px;
}

.auth-screen[hidden] {
  display: none !important;
}

.auth-screen-panel {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 24px;
  background: rgba(7, 17, 31, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-screen-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 36px;
}

.auth-screen-brand h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
}

.auth-screen-copy {
  margin: 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.auth-screen-highlights {
  display: grid;
  gap: 14px;
}

.auth-highlight-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.62);
}

.auth-highlight-card strong {
  font-size: 15px;
}

.auth-highlight-card span {
  color: var(--muted);
  line-height: 1.6;
}

.auth-screen-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  width: min(100%, 420px);
  min-height: 100%;
  margin-left: auto;
  padding: 28px;
}

.auth-form-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form-fields[hidden] {
  display: none !important;
}

.auth-form-fields .button-row {
  margin-top: 4px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(18px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.sidebar-brand h1 {
  margin: 4px 0 8px;
  font-size: 22px;
}

.sidebar-brand p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-title {
  margin: 0;
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  padding: 9px 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.58);
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(59, 130, 246, 0.16);
  transform: translateY(-1px);
}

.platform-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  padding: 16px;
  overflow: hidden;
}

.platform-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.account-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.7);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-account-card {
  min-width: 0;
}

.sidebar-account-card .button-row {
  flex-direction: column;
}

.account-main strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.account-main p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.account-balance {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 10px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.62);
}

.account-balance span {
  color: var(--muted);
}

.account-balance strong {
  font-size: 20px;
}

.content-page {
  display: none;
}

.content-page.active {
  display: flex;
  flex: 1;
  min-height: 0;
}

.placeholder-page {
  min-height: calc(100vh - 170px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-card {
  max-width: 680px;
  padding: 20px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.72);
}

.placeholder-card h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.placeholder-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(100%, 460px);
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  background: #07111f;
  box-shadow: var(--shadow);
}

.history-modal-card {
  width: min(100%, 760px);
}

.image-preview-modal-card {
  width: min(100%, 960px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-preview-modal-stage {
  min-height: 240px;
  flex: 1 1 auto;
  max-height: calc(100vh - 180px);
  padding: 12px;
  background: rgba(2, 6, 23, 0.9);
  overflow: auto;
  cursor: zoom-in;
}

.image-preview-modal-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  margin: auto;
  transition: width 0.12s ease;
  cursor: inherit;
}

.image-preview-modal-card .modal-header,
.image-preview-modal-card .button-row {
  flex: 0 0 auto;
  margin: 0;
}

.history-preview-card {
  min-height: 260px;
  margin-bottom: 16px;
}

.history-preview-card video {
  max-height: 360px;
  border-radius: 14px;
}

#enhanceSourceVideo,
#enhanceResultVideo,
#enhanceVideoInputPreview,
#videoShotSourceVideo,
#videoShotInputPreview {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #020617;
}

.history-modal-list {
  max-height: min(70vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.72);
}

.segment-button {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment-button.active {
  background: rgba(99, 102, 241, 0.22);
  color: var(--text);
}

.package-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0;
}

.package-card {
  padding: 16px 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
  cursor: pointer;
}

.package-card.active {
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(99, 102, 241, 0.18);
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .auth-screen {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .auth-screen-card {
    width: 100%;
    margin-left: 0;
  }

  .platform-shell {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  }

  .admin-placeholder-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    overflow-y: visible;
  }

  .platform-topbar {
    flex-direction: column;
  }

  .platform-main {
    height: auto;
    overflow: visible;
  }

  .content-page.active {
    display: block;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
  }

  .account-card {
    width: 100%;
    min-width: 0;
  }
}

/* ── Asset Library ──────────────────────────────────────────────────────────── */
.asset-lib-workspace {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 300px;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.asset-lib-left {
  display: grid;
  grid-template-rows: minmax(0, 1.4fr) minmax(0, 0.6fr);
  gap: 12px;
  min-height: 0;
}

.asset-lib-preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.asset-lib-tabs {
  width: fit-content;
  margin-bottom: 0;
}

.asset-lib-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.asset-lib-group-selector-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.asset-lib-group-select {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.asset-lib-group-select:focus {
  border-color: rgba(109, 124, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(109, 124, 255, 0.16);
}

.asset-lib-icon-btn {
  flex: 0 0 auto;
  min-width: 36px;
  padding: 8px 10px;
  font-size: 15px;
}

.asset-lib-preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.72);
  overflow: hidden;
}

.asset-lib-preview-stage img,
.asset-lib-preview-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.asset-lib-preview-stage audio {
  width: 90%;
}

.asset-lib-status-bar {
  flex: 0 0 auto;
}

.asset-lib-grid-panel {
  min-height: 0;
  overflow: hidden;
}

.asset-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}

.asset-thumb-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.55);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.asset-thumb-item:hover {
  border-color: rgba(109, 124, 255, 0.55);
  transform: translateY(-1px);
}

.asset-thumb-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(109, 124, 255, 0.3);
}

.asset-thumb-item img,
.asset-thumb-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 24px;
  color: var(--muted);
}

.asset-thumb-status {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 2px 5px;
  border-radius: 999px;
  font-size: 10px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--muted);
}

.asset-thumb-status.active {
  color: #d1fae5;
  background: rgba(16, 185, 129, 0.22);
}

.asset-thumb-status.failed {
  color: #ffe4e6;
  background: rgba(244, 63, 94, 0.22);
}

.asset-reference-selector-card {
  width: min(100%, 1020px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.asset-reference-selector-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.asset-reference-selector-tabs {
  width: fit-content;
  margin: 0;
}

.asset-reference-selector-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.asset-reference-selector-body {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.72);
}

.asset-reference-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  align-content: start;
  gap: 10px;
  width: 100%;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px;
}

.asset-reference-selector-item {
  min-height: 104px;
}

.asset-reference-selector-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 6px 6px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.9));
  color: #e5e7eb;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-lib-detail-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.asset-lib-group-info,
.asset-lib-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-lib-info-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 12px;
}

.asset-lib-info-row:last-of-type {
  border-bottom: none;
}

.asset-lib-info-row > span:first-child {
  color: var(--muted);
  flex: 0 0 70px;
}

.asset-lib-info-row code {
  color: #cbd5ff;
  font-size: 11px;
  word-break: break-all;
  text-align: right;
}

.asset-id-row {
  align-items: center;
}

.asset-lib-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.14);
  margin: 4px 0;
}

.asset-status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.72);
  color: var(--muted);
}

.asset-status-badge.active {
  color: #d1fae5;
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.3);
}

.asset-status-badge.processing {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.3);
}

.asset-status-badge.failed {
  color: #ffe4e6;
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.32);
}

.asset-lib-uri-btn {
  width: 100%;
  text-align: center;
  margin-top: 4px;
  border-color: rgba(109, 124, 255, 0.42);
  color: #c7d2fe;
}

.asset-lib-uri-btn:hover {
  border-color: var(--accent);
  background: rgba(109, 124, 255, 0.16);
}

@media (max-width: 1180px) {
  .asset-lib-workspace {
    grid-template-columns: 1fr;
  }

  .asset-lib-left {
    grid-template-rows: auto auto;
  }

  .asset-lib-detail-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* ── end Asset Library ──────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-screen-brand,
  .auth-screen-card {
    padding: 20px;
  }

  .platform-main {
    padding: 18px;
  }

  .package-grid {
    grid-template-columns: 1fr;
  }
}
