:root {
  color-scheme: dark;
  --background: #0b1020;
  --background-glow: radial-gradient(circle at top, rgba(82, 117, 255, 0.2), transparent 42%);
  --panel: rgba(15, 22, 40, 0.86);
  --panel-strong: rgba(20, 29, 52, 0.96);
  --panel-border: rgba(153, 176, 255, 0.18);
  --panel-border-strong: rgba(153, 176, 255, 0.3);
  --primary: #81a6ff;
  --primary-strong: #99b5ff;
  --primary-soft: rgba(129, 166, 255, 0.16);
  --success: #4fd1a7;
  --warning: #f6c351;
  --danger: #ff7272;
  --text: #eef3ff;
  --muted: #c0c9e5;
  --subtle: #8f9ab8;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background-glow), linear-gradient(180deg, #111830 0%, #090d18 100%);
  color: var(--text);
  font: 500 15px/1.55 "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
  color: var(--primary-strong);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #6f96ff, #8d7bff);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-shadow: 0 10px 22px rgba(111, 150, 255, 0.24);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.modal-open {
  overflow: hidden;
}

.page {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 10px;
}

.auth-text {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.auth-mode-button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.auth-mode-button.active {
  background: linear-gradient(135deg, rgba(110, 168, 254, 0.32), rgba(142, 125, 255, 0.36));
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-error {
  margin: 0;
  color: var(--danger);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  transition: padding 0.2s ease;
}

.hero.compact {
  padding-block: 14px;
}

.hero-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.hero-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hero h1,
.results h2,
.panel h2 {
  margin: 0;
  font-size: 1.48rem;
}

.hero-text,
.panel-tip,
.task-summary {
  margin: 0;
  color: var(--muted);
}

.hero.compact .hero-text {
  display: none;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  min-width: 300px;
}

.hero-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-card {
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
}

.sidebar,
.panel,
.results {
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 18px;
  position: sticky;
  top: 18px;
  align-self: start;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-group-title {
  margin: 0 0 2px;
  color: var(--subtle);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-divider {
  height: 1px;
  margin: 14px 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

.tab-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  box-shadow: none;
  border: 1px solid transparent;
  position: relative;
  padding-right: 36px;
}

.tab-button.active {
  background: linear-gradient(135deg, rgba(111, 150, 255, 0.2), rgba(141, 123, 255, 0.2));
  border-color: var(--panel-border-strong);
}

.tab-icon {
  width: 22px;
  text-align: center;
}

.tab-label {
  flex: 1;
  text-align: left;
}

.tab-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ff5d6d;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 0 0 rgba(255, 93, 109, 0.6);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 93, 109, 0.56);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 93, 109, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 93, 109, 0);
  }
}

.content {
  min-width: 0;
}

.panel {
  display: none;
  padding: 24px;
}

.panel.active {
  display: block;
}

.generator-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label > span:first-child {
  font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: rgba(6, 10, 20, 0.62);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(129, 166, 255, 0.26);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(129, 166, 255, 0.14);
}

textarea {
  resize: vertical;
  min-height: 112px;
}

small,
.model-info,
.form-hint,
.duration-values,
.file-zone-hint,
.file-meta,
.empty-upload,
.prompt-counter,
.checkbox small {
  color: var(--muted);
}

.checkbox {
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.checkbox input {
  width: auto;
  margin-right: 8px;
}

.checkbox-help span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-message {
  margin: -4px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.form-message.error {
  border-color: rgba(255, 114, 114, 0.42);
  background: rgba(255, 114, 114, 0.08);
  color: #ffd1d1;
}

.form-message.success {
  border-color: rgba(79, 209, 167, 0.3);
  background: rgba(79, 209, 167, 0.08);
  color: #ccfff0;
}

.field-error {
  border-color: rgba(255, 114, 114, 0.7) !important;
  box-shadow: 0 0 0 3px rgba(255, 114, 114, 0.12) !important;
}

.field-error-message {
  color: #ffd1d1;
}

.model-info {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.prompt-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -2px 0 6px;
}

.prompt-tool-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-tool-button {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.92rem;
}

.prompt-counter {
  min-width: 66px;
  text-align: right;
  font-size: 0.88rem;
}

.prompt-popover {
  position: fixed;
  z-index: 40;
  max-width: 340px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--panel-border-strong);
  background: rgba(12, 18, 33, 0.96);
  box-shadow: var(--shadow);
}

.prompt-popover-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.prompt-popover-list {
  display: grid;
  gap: 8px;
}

.prompt-popover-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
  text-align: left;
}

.prompt-popover-item strong,
.prompt-popover-item span {
  display: block;
}

.prompt-popover-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.duration-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duration-range {
  width: 100%;
  accent-color: var(--primary);
}

.duration-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}

.file-native-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-zone {
  position: relative;
  border: 1px dashed rgba(129, 166, 255, 0.36);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.file-zone.dragover {
  border-color: var(--primary);
  background: rgba(129, 166, 255, 0.1);
  transform: translateY(-1px);
}

.file-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.file-zone-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-zone-copy strong {
  font-size: 0.96rem;
}

.file-zone-browse {
  padding: 9px 12px;
  box-shadow: none;
}

.file-preview-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.file-preview-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.file-preview-thumb,
.file-preview-icon {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.file-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-remove {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  padding: 0;
  background: rgba(255, 114, 114, 0.14);
  color: #ffd6d6;
  border: 1px solid rgba(255, 114, 114, 0.22);
  box-shadow: none;
}

.empty-upload {
  margin-top: 12px;
  font-size: 0.92rem;
}

.results {
  margin-top: 22px;
  padding: 22px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.result-list {
  display: grid;
  gap: 16px;
}

.result-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.result-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.result-card-header h3 {
  margin: 0 0 4px;
  font-size: 1.04rem;
}

.result-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.task-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.task-badge.status-pending,
.task-badge.status-running,
.task-badge.status-uploading {
  color: #d6e2ff;
}

.task-badge.status-succeeded {
  color: #c7ffe8;
  background: rgba(79, 209, 167, 0.12);
}

.task-badge.status-failed,
.task-badge.status-unknown {
  color: #ffd1d1;
  background: rgba(255, 114, 114, 0.12);
}

.task-runtime {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
}

.task-progress {
  height: 10px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.task-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6f96ff, #8d7bff);
  transition: width 0.3s ease;
}

.task-text {
  margin: 12px 0 0;
  color: var(--muted);
}

.task-asset-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.result-image {
  width: min(480px, 100%);
  border-radius: 18px;
  display: block;
  cursor: zoom-in;
}

.result-video {
  width: min(560px, 100%);
  border-radius: 18px;
  background: #000000;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.task-action {
  padding: 9px 12px;
  border-radius: 12px;
  box-shadow: none;
}

.empty-state {
  padding: 26px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  text-align: center;
}

.submit-loading {
  position: relative;
  padding-left: 40px;
}

.submit-loading::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.prompt-muted,
.task-copy-prompt {
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.84);
}

.lightbox img {
  max-width: min(1200px, calc(100vw - 56px));
  max-height: calc(100vh - 120px);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.lightbox-close {
  position: absolute;
  top: 22px;
  right: 22px;
  box-shadow: none;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: flex;
    gap: 16px;
    overflow-x: auto;
  }

  .nav-group {
    min-width: max-content;
  }

  .nav-divider {
    width: 1px;
    height: auto;
    margin: 0;
  }
}

@media (max-width: 980px) {
  .hero {
    flex-direction: column;
  }

  .hero-actions,
  .hero-toolbar {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .hero-card {
    min-width: 0;
    width: 100%;
  }

  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .page {
    width: min(100%, calc(100% - 20px));
    padding-top: 14px;
  }

  .hero,
  .panel,
  .results,
  .sidebar,
  .auth-card {
    border-radius: 18px;
  }

  .hero-title-row,
  .results-header,
  .result-card-header,
  .file-zone-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .grid.two,
  .grid.three,
  .auth-mode-switch {
    grid-template-columns: 1fr;
  }

  .file-preview-card {
    grid-template-columns: 54px minmax(0, 1fr) auto;
  }

  .tab-button {
    min-width: 170px;
  }
}
