:root {
  color-scheme: dark;
  --page: #151917;
  --surface: #1c211e;
  --mat: #101412;
  --ink: #f3efe7;
  --muted: #b7bdb2;
  --line: #414841;
  --accent: #f0cdae;
  --accent-ink: #2a2019;
  --error: #ffc0b4;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--page);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, summary, a, .file-button { -webkit-tap-highlight-color: transparent; }
.topbar { border-bottom: 1px solid var(--line); background: var(--mat); }
.topbar-inner, main { max-width: 1160px; margin: auto; padding-inline: 24px; }
.topbar-inner { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand, .account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { font-weight: 600; letter-spacing: .02em; }
.brand-mark {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  transform: rotate(45deg);
  margin: 0 4px;
  flex-shrink: 0;
}
.online { font-size: 13px; color: var(--muted); white-space: nowrap; }
.online::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #afc7a6; vertical-align: middle; }
.online[data-offline]::before { background: var(--accent); }
main { padding-block: 24px 42px; }
h1 { font-size: clamp(21px, 2.8vw, 29px); font-weight: 620; letter-spacing: -.025em; line-height: 1.25; }
h2 { font-size: clamp(18px, 2.1vw, 23px); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
h3 { font-size: 17px; font-weight: 590; }
.muted, .notice { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.error, .notice.error { color: var(--error); }
.notice:empty { display: none; }
.button, .quiet {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: inherit;
  font-weight: 570;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  padding: 7px 13px;
}
.quiet { background: transparent; padding-inline: 6px; font-size: 13px; font-weight: 470; color: var(--muted); }
.quiet:hover { color: var(--ink); }
.outline { background: transparent; border-color: var(--line); }
.outline:hover { border-color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { filter: brightness(1.065); }
button:disabled, .file-button[aria-disabled="true"] { opacity: .52; cursor: default; }
.file-button { position: relative; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-button input:disabled { cursor: default; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }

.ingest, .task, .login-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.ingest-top, .task-bar { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ingest-top p, .task-heading p { margin-top: 4px; }
.ingest-actions, .option-row, .copy-actions, .review-buttons { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ingest-actions { flex: 0 0 auto; }
.transfer, .settings { padding: 13px 20px; border-top: 1px solid var(--line); }
.transfer progress, .waiting progress { display: block; accent-color: var(--accent); width: min(250px, 100%); margin-top: 6px; }
.transfer .button, .waiting .button { margin-top: 8px; }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.settings .option-row { margin-block: 12px; gap: 8px 20px; }
.settings .platform-settings { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 10px 0; }
.settings label, .review-fields label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.settings .option-row label, .settings .watermark-option { display: inline-flex; align-items: center; gap: 7px; min-height: 35px; }
.settings input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.settings input[type="text"], .settings select, .review-fields input, .review-fields textarea {
  width: 100%; min-width: 0; min-height: 44px; color: var(--ink); background: var(--mat);
  border: 1px solid var(--line); border-radius: 5px; padding: 7px 10px; font-size: 16px;
}
.platform-settings fieldset { display: grid; gap: 6px; min-width: 0; margin: 0; border: 0; border-top: 1px solid var(--line); padding: 6px 0 0; }
.platform-settings legend { padding: 0 6px 0 0; font-size: 14px; }

.task { margin-top: 17px; }
.task-heading { min-width: 0; }
.history { position: relative; }
.history > summary { list-style: none; }
.history > summary::-webkit-details-marker { display: none; }
.history ul {
  position: absolute; z-index: 6; inset-inline-end: 0; width: min(300px,80vw);
  max-height: 295px; overflow: auto; padding: 6px; margin: 7px 0 0;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 9px 24px #0005;
}
.history button { width: 100%; text-align: start; padding: 9px 10px; color: var(--ink); border: 0; background: none; min-height: 44px; overflow-wrap: anywhere; cursor: pointer; }
.history button[aria-current="true"] { background: var(--mat); }
.history button small { display: block; font-size: 12px; color: var(--muted); }
.waiting { border-top: 1px solid var(--line); padding: 28px 20px; min-height: 111px; }
.waiting p { color: var(--muted); }
.waiting p.error { color: var(--error); }
.version-tabs { display: flex; border-block: 1px solid var(--line); padding-inline: 12px; }
.version-tabs button {
  flex: 1 1 33%; min-width: 0; min-height: 49px; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 4px; color: var(--muted); border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer;
}
.version-tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 620; }
.version-tabs button small { color: var(--muted); font-weight: 450; font-size: 12px; white-space: nowrap; }
.review-body { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,.9fr); }
.stage { background: var(--mat); padding-top: 17px; display: grid; align-content: start; justify-items: center; }
.frame { width: min(234px,65%); aspect-ratio: 9/16; background: var(--page); }
.frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.stage figcaption { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.stage figcaption > span { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.review-fields { padding: 18px 20px; display: grid; align-content: start; gap: 13px; min-width: 0; }
.review-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.review-fields label { display: grid; gap: 4px; }
.review-fields textarea { resize: vertical; }
.copy-actions { gap: 5px 15px; }
.copy-actions .quiet:first-child { padding-inline-start: 0; }
.review-actions {
  border-top: 1px solid var(--line); padding: 12px 17px; background: var(--surface); border-radius: 0 0 8px 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; z-index: 4;
}
.review-progress { color: var(--muted); font-size: 13px; }
.review-buttons { justify-content: flex-end; }
.login-panel { max-width: 490px; padding: 25px; margin: 28px auto; }
.login-panel p { color: var(--muted); margin-top: 8px; }
.login-panel p.error { color: var(--error); }

@media (max-width: 650px) {
  .topbar-inner, main { padding-inline: max(12px, env(safe-area-inset-left)); }
  .topbar-inner { min-height: 54px; }
  .account { gap: 5px; }
  .brand, .online { font-size: 13px; }
  main { padding-block: 13px 15px; }
  .ingest-top, .task-bar { padding: 12px; flex-wrap: wrap; }
  .ingest-top { gap: 10px; }
  .ingest-actions { flex: 1 1 100%; }
  .ingest-actions .primary { flex: 1; }
  .transfer, .settings, .waiting { padding-inline: 12px; }
  .settings .platform-settings { grid-template-columns: minmax(0,1fr); }
  .task { margin-top: 11px; }
  .task-bar { gap: 8px; }
  .task-heading { flex: 1; }
  .version-tabs { padding-inline: 3px; }
  .version-tabs button { display: grid; align-content: center; gap: 0; font-size: 14px; }
  .review-body { grid-template-columns: minmax(0,1fr); }
  .stage { padding-top: 10px; }
  .frame { width: min(162px,60%); }
  .review-fields { padding: 13px 12px; gap: 8px; }
  .copy-actions { gap: 5px 9px; }
  .review-actions {
    position: sticky; bottom: 0; padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    gap: 6px; justify-content: space-between;
  }
  .review-progress { white-space: nowrap; }
  .review-buttons { gap: 5px; }
  .review-buttons .button { padding-inline: 9px; font-size: 13px; }
}

@media (max-width: 345px) {
  .account .quiet { padding-inline: 3px; }
  .online { font-size: 11px; }
  .brand { gap: 5px; letter-spacing: 0; }
  .review-progress { font-size: 12px; }
}
