:root {
  color-scheme: light;
  --bg: #edf1f5;
  --panel: #ffffff;
  --text: #182232;
  --muted: #657386;
  --line: #d9e1ea;
  --accent: #1264b8;
  --accent-dark: #0b4078;
  --ok: #087b54;
  --warn: #9b5d00;
  --danger: #a33b3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.shell {
  width: min(1160px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.section-head,
.actions,
.folder-row,
.schedule-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

.panel {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.section-head {
  justify-content: space-between;
}

.section-head p,
.folder-row + .field,
.video-main span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status {
  min-width: 130px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: #dfe9f4;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

.folder-row {
  align-items: center;
  margin: 14px 0;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mode-field {
  margin-top: 12px;
}

.mode-field select {
  max-width: 220px;
}

#workerField {
  flex: 1 1 320px;
  max-width: 420px;
}

#workerField select {
  width: 100%;
  max-width: none;
}

.hidden {
  display: none !important;
}

.account-tools {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) minmax(360px, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-actions button {
  white-space: nowrap;
}

.account-actions .inline-status {
  flex-basis: 100%;
}

.image-source-tools {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(180px, 260px) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.feishu-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.inline-status {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-row input {
  margin-top: 0;
}

.folder-row button {
  min-width: 96px;
  white-space: nowrap;
}

.field {
  display: block;
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.content-grid .full {
  grid-column: 1 / -1;
}

.batch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.batch-plan {
  min-height: 132px;
  max-height: 260px;
  margin-top: 14px;
}

.schedule-row {
  align-items: center;
  flex-wrap: wrap;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.switch input {
  width: auto;
  margin: 0;
}

.schedule-controls {
  display: flex;
  gap: 10px;
  min-width: 300px;
}

.schedule-controls input,
.schedule-controls select {
  margin-top: 0;
}

.schedule-controls.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.schedule-summary {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5f8fb;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.batch-window-summary {
  margin-top: 14px;
}

.video-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.video-item,
.empty {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.video-item.selected {
  box-shadow: inset 4px 0 0 var(--accent);
}

.video-item.done {
  border-color: #b8dccf;
  background: #f4fbf8;
}

.video-item.failed {
  border-color: #e1b4b4;
  background: #fff7f7;
}

.video-item.used {
  border-color: #efb3b3;
  background: #fff4f4;
}

.video-main {
  min-width: 0;
}

.video-main strong,
.video-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-main strong {
  margin-bottom: 4px;
}

.row-upload {
  min-width: 82px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-confirm {
  min-width: 104px;
  background: #f4d6d6;
  color: var(--danger);
}

.output-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

pre {
  min-height: 300px;
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #1c2f48;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.credential-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.2);
}

.credential-dialog::backdrop {
  background: rgba(28, 47, 72, 0.42);
}

.credential-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2,
.dialog-head p {
  margin: 0;
}

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

.dialog-head button[aria-label="关闭"] {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 20px, 1160px);
    padding: 12px 0;
  }

  .topbar,
  .section-head,
  .actions,
  .folder-row,
  .schedule-row {
    flex-direction: column;
    align-items: stretch;
  }

    .content-grid,
    .batch-grid,
    .account-tools,
    .image-source-tools,
  .output-grid,
  .video-item {
    grid-template-columns: 1fr;
  }

  .schedule-controls {
    min-width: 0;
  }
}
