:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --panel: #050505;
  --surface: #171717;
  --surface-strong: #212121;
  --surface-muted: #292929;
  --text: #f3f3f3;
  --muted: #929292;
  --muted-strong: #b1b1b1;
  --line: #282828;
  --accent: #00c4e8;
  --accent-soft: #06262c;
  --danger: #d84a43;
  --success: #5ac48d;
  --radius: 8px;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.48);
  font-family: "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
.auth-tab {
  border: 0;
  cursor: pointer;
}

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

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  border-bottom: 1px solid #1b1b1b;
  background: rgba(13, 13, 13, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #f4f4f4;
  color: #131313;
  font-size: 12px;
  font-weight: 800;
}

.account-area,
.dialog-head,
.queue-header,
.task-line,
.task-meta {
  display: flex;
  align-items: center;
}

.account-area {
  gap: 10px;
}

.account-name {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  width: min(1720px, calc(100% - 64px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.composer {
  min-width: 0;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.product-label,
h1,
h2,
p {
  margin-top: 0;
}

.product-label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.temporary-note {
  margin-bottom: 2px;
  color: #707070;
  font-size: 12px;
  line-height: 1.5;
}

.reference-strip {
  min-height: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 8px 12px;
}

@media (min-width: 681px) {
  .workspace:has(.file-meta:not([hidden])) {
    padding-top: 14px;
  }

  .composer:has(.file-meta:not([hidden])) .intro {
    display: none;
  }
}

.file-meta {
  width: 96px;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.reference-frame {
  position: relative;
  width: 96px;
  height: 94px;
}

#image-preview {
  width: 96px;
  height: 94px;
  display: block;
  border: 1px solid #3a3a3a;
  border-radius: 14px;
  background: #181818;
  object-fit: cover;
}

.reference-remove {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: #972722;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 6px 16px rgba(151, 39, 34, 0.28);
}

.reference-remove:hover:not(:disabled) {
  background: #b5332d;
}

.reference-label {
  min-width: 72px;
  padding: 6px 12px;
  border-radius: 15px;
  background: #242424;
  color: #e3e3e3;
  font-size: 14px;
  line-height: 1;
  text-align: center;
}

.creator-panel {
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: 0 28px 48px rgba(0, 0, 0, 0.28);
}

.prompt-row {
  min-height: 120px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 180px;
  align-items: center;
  gap: 16px;
  padding: 23px 24px;
}

.upload-zone {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 14px;
  background: #222;
  color: #aaa;
  font-size: 30px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.upload-zone:hover:not(:disabled),
.upload-zone.is-dragging {
  background: #2b2b2b;
  color: #fff;
}

.upload-zone:disabled {
  cursor: pointer;
  opacity: 0.64;
}

.upload-empty {
  display: grid;
  place-items: center;
}

.prompt-field {
  position: relative;
  min-width: 0;
  display: block;
}

#prompt {
  width: 100%;
  height: 72px;
  min-height: 72px;
  max-height: 96px;
  display: block;
  resize: none;
  padding: 19px 60px 10px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
}

#prompt::placeholder,
input::placeholder {
  color: #d3d3d3;
  opacity: 1;
}

.prompt-count {
  position: absolute;
  right: 0;
  bottom: 8px;
  color: #5d5d5d;
  font-size: 11px;
}

.generate-button {
  position: relative;
  isolation: isolate;
  width: 180px;
  height: 72px;
  padding: 0 24px;
  border-radius: 20px;
  background: #f7f7f7;
  color: #242424;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.generate-button::before {
  content: "";
  position: absolute;
  z-index: -1;
  right: 2px;
  bottom: -3px;
  left: 2px;
  height: 5px;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(90deg, #ff6a91, #f5c865, #7add86, #66d5f0);
  filter: blur(5px);
  opacity: 0.82;
}

.generate-button:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
}

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

.field-error,
.submit-feedback {
  min-height: 0;
  margin: 0;
  padding: 0 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-error:not([hidden]),
.submit-feedback:not(:empty) {
  padding-bottom: 12px;
}

.field-error,
.submit-feedback.is-error {
  color: #ff8b83;
}

.submit-feedback.is-success {
  color: var(--success);
}

.tool-row {
  min-height: 100px;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  margin: 0 24px;
  border-top: 2px solid #202020;
  scrollbar-width: none;
}

.tool-row::-webkit-scrollbar {
  display: none;
}

.tool-option {
  flex: 0 0 auto;
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: #9b9b9b;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}

button.tool-option {
  border: 0;
  background: transparent;
  cursor: pointer;
}

button.tool-option:hover {
  color: #d7d7d7;
}

.tool-option > i:first-child {
  font-size: 22px;
}

.tool-option > i:last-child {
  color: #555;
  font-size: 14px;
}

.tool-option.is-active {
  min-height: 64px;
  padding: 0 20px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
}

.model-option > i:first-child {
  color: #ff3c63;
}

.output-option > i:first-child {
  color: #9f9f9f;
}

.video-settings-dialog {
  width: min(930px, calc(100% - 36px));
  max-height: min(760px, calc(100dvh - 36px));
  padding: 30px 32px 32px;
  overflow-y: auto;
  border: 1px solid #2c2c2c;
  border-radius: 24px;
  background: #0c0c0c;
  color: var(--text);
  box-shadow: var(--shadow);
}

.video-settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(3px);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.settings-head h2 {
  margin-bottom: 0;
  font-size: 21px;
}

.settings-section + .settings-section {
  margin-top: 34px;
}

.settings-section h3 {
  margin: 0 0 16px;
  color: #aaa;
  font-size: 18px;
  font-weight: 650;
}

.ratio-options,
.segmented-options {
  display: grid;
  padding: 8px;
  border-radius: 26px;
  background: #202020;
}

.ratio-options {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.segmented-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.setting-option {
  min-width: 0;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: #9c9c9c;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}

.ratio-option {
  min-height: 112px;
  flex-direction: column;
  gap: 14px;
}

.setting-option:hover {
  color: #ddd;
}

.setting-option.is-selected,
.setting-option[aria-pressed="true"] {
  background: #030303;
  color: #fff;
}

.setting-option:disabled {
  color: #5f5f5f;
  cursor: not-allowed;
  opacity: 0.65;
}

.setting-option:disabled:hover {
  color: #5f5f5f;
}

.ratio-shape {
  display: block;
  border: 2px solid currentColor;
  border-radius: 4px;
  color: #686868;
}

.setting-option[aria-pressed="true"] .ratio-shape {
  color: #fff;
}

.ratio-square {
  width: 24px;
  height: 24px;
}

.ratio-portrait {
  width: 18px;
  height: 24px;
}

.ratio-landscape {
  width: 26px;
  height: 20px;
}

.ratio-tall {
  width: 17px;
  height: 30px;
}

.ratio-wide {
  width: 32px;
  height: 18px;
}

.ratio-cinema {
  width: 36px;
  height: 15px;
}

.login-prompt {
  width: 100%;
  margin-top: 12px;
  padding: 5px;
  background: transparent;
  color: #777;
  font-size: 12px;
  text-align: center;
}

.login-prompt:hover {
  color: var(--text);
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border-radius: var(--radius);
  font-weight: 650;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.button-primary {
  background: #f3f3f3;
  color: #171717;
}

.button-primary:hover:not(:disabled) {
  background: #fff;
}

.button-secondary {
  min-height: 36px;
  border: 1px solid #363636;
  background: #1d1d1d;
  color: var(--text);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.icon-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-strong);
  color: var(--text);
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.auth-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.queue-panel {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid #242424;
}

.queue-header {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}

.queue-header h2 {
  margin-bottom: 5px;
  font-size: 18px;
}

.queue-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.queue-header strong {
  color: var(--text);
}

.queue-message {
  padding: 32px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.task-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid #2c2c2c;
  border-radius: var(--radius);
  background: #141414;
}

.task-thumb {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  background: var(--surface-muted);
  object-fit: cover;
}

.task-body {
  min-width: 0;
}

.task-line {
  justify-content: space-between;
  gap: 8px;
}

.task-line strong {
  font-size: 13px;
}

.task-status {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.task-prompt {
  overflow: hidden;
  margin: 7px 0;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  flex-wrap: wrap;
  gap: 8px;
  color: #6f6f6f;
  font-size: 10px;
}

.task-result {
  display: inline-block;
  margin-top: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.task-result:hover {
  text-decoration: underline;
}

.login-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #363636;
  border-radius: var(--radius);
  background: #171717;
  color: var(--text);
  box-shadow: var(--shadow);
}

.login-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.dialog-head {
  justify-content: space-between;
  padding: 22px 24px 16px;
}

.dialog-head h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.dialog-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 24px;
  padding: 4px;
  border-radius: var(--radius);
  background: #242424;
}

.auth-tab {
  min-height: 34px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.auth-tab.is-active {
  background: #363636;
  color: var(--text);
}

#login-form {
  display: grid;
  gap: 16px;
  padding: 22px 24px 26px;
}

.auth-field {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
}

.auth-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #393939;
  border-radius: var(--radius);
  background: #0f0f0f;
  color: var(--text);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 15px;
  border: 1px solid #353535;
  border-radius: var(--radius);
  background: #222;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 980px) {
  .workspace {
    width: min(100% - 40px, 900px);
  }

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

  .prompt-row {
    grid-template-columns: 64px minmax(0, 1fr) 148px;
    gap: 14px;
  }

  .upload-zone {
    width: 64px;
    height: 64px;
  }

  .generate-button {
    width: 148px;
  }
}

@media (max-width: 680px) {
  .topbar {
    height: 60px;
    padding: 0 16px;
  }

  .workspace {
    width: calc(100% - 28px);
    padding: 28px 0 48px;
  }

  .intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
  }

  h1 {
    font-size: 22px;
  }

  .creator-panel {
    border-radius: 24px;
  }

  .prompt-row {
    min-height: 0;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 18px;
  }

  .upload-zone {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    font-size: 26px;
  }

  #prompt {
    height: 66px;
    min-height: 66px;
    padding-top: 13px;
    padding-right: 42px;
    font-size: 16px;
  }

  .generate-button {
    width: 100%;
    height: 56px;
    grid-column: 1 / -1;
    border-radius: 16px;
    font-size: 17px;
  }

  .tool-row {
    min-height: 76px;
    gap: 8px;
    margin: 0 18px;
  }

  .tool-option,
  .tool-option.is-active {
    min-height: 50px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 14px;
  }

  .queue-panel {
    margin-top: 44px;
  }

  .task-list {
    grid-template-columns: 1fr;
  }

  .video-settings-dialog {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 28px);
    margin: auto 0 0;
    padding: 22px 16px calc(24px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
  }

  .settings-head {
    margin-bottom: 20px;
  }

  .settings-section + .settings-section {
    margin-top: 26px;
  }

  .settings-section h3 {
    margin-bottom: 12px;
    font-size: 16px;
  }

  .ratio-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: 20px;
  }

  .segmented-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 20px;
  }

  .setting-option,
  .ratio-option {
    min-height: 66px;
    border-radius: 15px;
    font-size: 15px;
  }

  .ratio-option {
    min-height: 82px;
    gap: 10px;
  }
}

@media (max-width: 420px) {
  .brand > span:last-child,
  .account-name {
    display: none;
  }

  .temporary-note {
    max-width: 310px;
  }

  .reference-frame,
  #image-preview {
    width: 88px;
    height: 86px;
  }

  .file-meta {
    width: 88px;
  }
}
