:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #fbfcfd;
  --text: #202532;
  --muted: #687080;
  --line: #dfe4ec;
  --accent: #d71920;
  --accent-dark: #ad1118;
  --accent-soft: #fff0f1;
  --green: #108a52;
  --blue: #2d63c8;
  --shadow: 0 18px 48px rgba(31, 38, 52, 0.08);
  --shadow-soft: 0 8px 24px rgba(31, 38, 52, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 42%, #f2f4f7 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
}

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.control-panel {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(223, 228, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

.mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(215, 25, 32, 0.22);
}

.brand-block p,
.hint,
#statusText,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.brand-block p {
  margin-top: 8px;
  max-width: 620px;
  font-size: 14px;
}

.panel-section {
  width: min(360px, 36%);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.panel-section h2 {
  margin-bottom: 6px;
}

.workspace {
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px 0;
}

.topbar h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  white-space: nowrap;
  border-radius: 999px;
  padding: 5px 11px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.ai {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.local {
  background: #e9f7f1;
  color: var(--green);
}

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

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(31, 38, 52, 0.035);
}

.step span {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #edf1f6;
  color: var(--muted);
  font-size: 12px;
}

.step.done,
.step.active {
  border-color: rgba(215, 25, 32, 0.28);
  color: var(--accent);
  background: var(--accent-soft);
}

.step.done span,
.step.active span {
  background: var(--accent);
  color: #fff;
}

.workflow-card,
.parse-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.workflow-card {
  scroll-margin-top: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin-bottom: 4px;
  font-size: 17px;
}

.section-head.compact {
  align-items: center;
  margin-bottom: 10px;
}

.preview-title h2 {
  margin-bottom: 0;
  font-size: 14px;
}

.field-label {
  display: block;
  margin: 10px 0 8px;
  font-size: 13px;
  font-weight: 800;
}

.file-input {
  width: 100%;
  padding: 10px;
  border: 1px dashed #bdc6d3;
  border-radius: 8px;
  background: var(--surface);
}

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline: none;
  color: var(--text);
  background: #fff;
  line-height: 1.55;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.12);
}

button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

button:hover,
.download:hover {
  transform: translateY(-1px);
  border-color: #c8d0dc;
  box-shadow: 0 9px 20px rgba(31, 38, 52, 0.08);
}

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

button.primary:hover,
.download:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
  box-shadow: none;
}

.download.disabled {
  pointer-events: none;
  opacity: 0.42;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.inline-actions .primary {
  min-width: 88px;
}

.parse-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(420px, 1.22fr);
  gap: 16px;
  align-items: stretch;
}

.input-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.upload-box {
  gap: 4px;
}

.parse-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.output-type-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.radio-option:has(input:checked) {
  background: var(--accent-soft);
  color: var(--accent);
}

.radio-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.parse-action {
  min-width: 160px;
}

.prompt-preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.96fr) minmax(400px, 1.04fr);
  gap: 16px;
  align-items: start;
}

.prompt-box {
  min-height: 320px;
}

.feedback {
  margin-top: 10px;
}

.task-box {
  position: relative;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.preview-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.ppt-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px);
  gap: 16px;
  align-items: stretch;
}

.download-box {
  padding: 2px 0 0;
}

.download-box .download {
  width: min(220px, 100%);
  margin-top: 18px;
}

.loading-cover {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  text-align: center;
  backdrop-filter: blur(2px);
}

.loading-cover[hidden] {
  display: none;
}

.loading-cover small {
  max-width: 280px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #ffd9dc;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.download-actions {
  display: flex;
  gap: 10px;
}

.download.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.divider-label {
  position: relative;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.divider-label::before,
.divider-label::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--line);
}

.divider-label::before {
  left: 0;
}

.divider-label::after {
  right: 0;
}

.checkbox-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 12px 0 8px;
  font-size: 13px;
  color: var(--text);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(640px, 1.45fr) minmax(420px, 0.85fr);
  gap: 16px;
}

.preview-panel,
.inspector-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.small-action {
  width: 100%;
  margin-top: 10px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 480px;
  overflow: auto;
}

.qa-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  padding: 8px;
  border-radius: 8px;
  background: #f5f6f8;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.json-view,
.json-block {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.stat b {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 22px;
}

.asset-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-soft);
}

.asset-thumb {
  display: grid;
  height: 68px;
  place-items: center;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #eef1f5 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(45deg, transparent 75%, #eef1f5 75%) 0 0 / 12px 12px,
    #fff;
}

.asset-thumb img {
  max-width: 100%;
  max-height: 64px;
}

.asset-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qa-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.qa-row.pass strong {
  color: var(--green);
}

.qa-row.fail strong {
  color: var(--accent);
}

.modal {
  width: min(540px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(22, 25, 32, 0.46);
}

.modal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 24px 80px rgba(22, 25, 32, 0.26);
}

.modal-card h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

.modal-card textarea {
  min-height: 120px;
}

.modal-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 28px, 760px);
    padding: 18px 0 32px;
  }

  .control-panel,
  .topbar,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-section {
    width: 100%;
  }

  .stepper,
  .parse-grid,
  .prompt-preview-grid,
  .ppt-grid {
    grid-template-columns: 1fr;
  }

  .inline-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  .brand-block {
    align-items: flex-start;
  }

  .mark {
    width: 46px;
    height: 46px;
    font-size: 16px;
  }

  .workflow-card,
  .control-panel {
    padding: 14px;
  }

  .modal-actions,
  .inline-actions,
  .parse-actions,
  .output-type-group {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-actions button,
  .inline-actions button,
  .parse-actions button {
    width: 100%;
  }
}
