:root {
  color-scheme: dark;
  --bg: #101112;
  --panel: #191b1f;
  --panel-strong: #22252b;
  --text: #f4f1eb;
  --muted: #a9a39a;
  --line: #343941;
  --gold: #d8ad55;
  --teal: #5fc6b5;
  --blue: #6ba7ff;
  --red: #f57575;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(95, 198, 181, 0.13), transparent 34%),
    linear-gradient(315deg, rgba(216, 173, 85, 0.13), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

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

.login-card {
  width: min(380px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 27, 31, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.app {
  min-height: 100vh;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.workspace {
  width: min(1380px, 100%);
  display: grid;
  grid-template-columns: minmax(540px, 0.95fr) minmax(430px, 0.82fr);
  gap: 14px;
}

.editor,
.preview,
.login-card {
  background: rgba(25, 27, 31, 0.93);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.title-row,
.preview-top,
.progress-label,
.actions,
.settings,
.history-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 32px);
}

h2 {
  font-size: 20px;
}

.model-pill,
.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  white-space: nowrap;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 13px;
}

.status.working {
  color: var(--gold);
  border-color: rgba(216, 173, 85, 0.55);
}

.status.done {
  color: var(--teal);
  border-color: rgba(95, 198, 181, 0.55);
}

.status.error {
  color: var(--red);
  border-color: rgba(245, 117, 117, 0.55);
}

label {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

textarea,
select,
input[type="password"],
input[type="number"] {
  width: 100%;
  margin-top: 8px;
  background: #101214;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  outline: none;
}

textarea {
  min-height: 230px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

select,
input[type="password"],
input[type="number"] {
  padding: 11px;
}

.top-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 10px;
}

.model-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.model-info span,
.model-info b {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #101214;
  font-weight: 600;
}

.model-info b {
  color: var(--teal);
}

.image-panel {
  margin-top: 4px;
}

.upload-box {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 10px;
  align-items: stretch;
  margin-top: 8px;
}

.upload-box input {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #101214;
  color: var(--muted);
}

.image-preview {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: #101214;
}

.image-preview img {
  width: 100%;
  height: 90px;
  object-fit: cover;
}

.settings {
  align-items: end;
  flex-wrap: wrap;
}

.duration-control {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 82px 28px;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.duration-control input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  margin-top: 12px;
}

.check-row input {
  accent-color: var(--gold);
}

button,
.download {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #101112;
  background: linear-gradient(135deg, var(--gold), #f1d18a);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button:disabled,
.download.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.secondary-button,
.icon-button {
  margin-top: 8px;
  color: var(--text);
  background: #101214;
  border: 1px solid var(--line);
}

.icon-button {
  width: 42px;
  padding: 0;
}

#generate {
  width: 100%;
  margin-top: 14px;
}

.video-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0b0c0e;
}

video,
.empty-state {
  width: 100%;
  height: 100%;
}

video {
  object-fit: contain;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.progress-wrap {
  margin-top: 12px;
}

.progress-label {
  color: var(--muted);
  font-size: 13px;
}

.progress-bar {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #101214;
}

#progressFill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 0.25s ease;
}

.actions {
  margin-top: 12px;
}

#log {
  max-height: 120px;
  margin: 12px 0 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #b9c5d6;
  background: #101214;
  font-size: 12px;
  white-space: pre-wrap;
}

.history-section {
  margin-top: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  margin-top: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101214;
}

.history-item p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.history-item small,
.history-empty,
.muted,
.login-error {
  color: var(--muted);
}

.history-item a {
  color: var(--gold);
  font-weight: 800;
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app {
    align-items: stretch;
  }

  .workspace,
  .top-grid {
    grid-template-columns: 1fr;
  }

  .upload-box {
    grid-template-columns: 1fr;
  }
}
