:root {
  --asd-bg: #f5f0e8;
  --asd-surface: #fffdf8;
  --asd-border: #e8dfd0;
  --asd-text: #2c2419;
  --asd-muted: #7a6f62;
  --asd-accent: #b91c1c;
  --asd-accent-soft: #fef2f2;
  --asd-ok: #047857;
  --asd-radius: 10px;
  --asd-font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--asd-bg); color: var(--asd-text); font-family: var(--asd-font); font-size: 14px; line-height: 1.55; }
.asd-app { min-height: 100vh; display: flex; flex-direction: column; }
.asd-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; background: var(--asd-surface); border-bottom: 1px solid var(--asd-border); }
.asd-logo {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  text-decoration: none;
  background: transparent;
}
.asd-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.asd-brand { font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; }
.asd-brand a.asd-logo:hover { text-decoration: none; }
.asd-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.asd-nav button, .asd-btn { border: 1px solid var(--asd-border); background: var(--asd-surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.asd-nav button.active { background: var(--asd-accent-soft); border-color: #fca5a5; color: var(--asd-accent); }
.asd-btn-primary { background: var(--asd-accent); color: #fff; border-color: var(--asd-accent); }
.asd-btn-primary:hover { filter: brightness(1.05); }
.asd-btn-danger { color: var(--asd-accent); border-color: #fca5a5; }
.asd-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.asd-main { flex: 1; padding: 16px; max-width: 1280px; margin: 0 auto; width: 100%; }
.asd-panel { background: var(--asd-surface); border: 1px solid var(--asd-border); border-radius: var(--asd-radius); padding: 16px 18px; }
.asd-hint { color: var(--asd-muted); font-size: 13px; }
.asd-hidden { display: none !important; }
.asd-gate { max-width: 520px; margin: 40px auto; }
.asd-preview-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.asd-preview-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.asd-preview-banner-text { margin: 0; font-size: 13px; line-height: 1.5; flex: 1; min-width: 200px; }
.asd-preview-banner-actions { margin: 0; }
.asd-preview-mode .asd-btn[data-ai],
.asd-preview-mode #btnSaveApi,
.asd-preview-mode #btnTestText,
.asd-preview-mode #btnTestImage,
.asd-preview-mode #btnTestVideo,
.asd-preview-mode #btnClearApi,
.asd-preview-mode #btnRerunHere,
.asd-preview-mode #btnRegenStep,
.asd-preview-mode #btnRegenStepInline,
.asd-preview-mode #btnReviewFix,
.asd-preview-mode #btnRerunForDuration,
.asd-preview-mode #btnGenVideosPlan,
.asd-preview-mode #btnExportTxt,
.asd-preview-mode #btnExportJson,
.asd-preview-mode #btnExportZip,
.asd-preview-mode #btnExportZipStudio,
.asd-preview-mode #btnRestore,
.asd-preview-mode #btnUploadTxt,
.asd-preview-mode #btnImportNovel,
.asd-preview-mode #btnAddRef,
.asd-preview-mode .asd-nav button[data-view="settings"] {
  opacity: 0.72;
}
.asd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.asd-card { position: relative; border: 1px solid var(--asd-border); border-radius: 10px; padding: 14px; cursor: pointer; background: #fff; }
.asd-card:hover { border-color: #fca5a5; }
.asd-card-del { position: absolute; top: 6px; right: 8px; border: none; background: transparent; color: var(--asd-muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 6px; }
.asd-card-del:hover { color: var(--asd-accent); }
.asd-ref-list { margin: 8px 0; }
.asd-ref-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.asd-ref-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--asd-border); }
.asd-ref-item button { margin-left: auto; font-size: 11px; padding: 2px 8px; border: 1px solid var(--asd-border); background: #fff; border-radius: 6px; cursor: pointer; }
.asd-tagline { color: var(--asd-muted); margin: 8px 0 14px; }
.asd-pipeline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.asd-step-chip { border: 1px solid var(--asd-border); border-radius: 8px; padding: 8px 10px; cursor: pointer; min-width: 132px; background: #fff; text-align: left; position: relative; }
.asd-step-chip.active { border-color: var(--asd-accent); box-shadow: 0 0 0 1px var(--asd-accent); }
.asd-step-chip .st { font-size: 11px; color: var(--asd-muted); }
.asd-step-chip.done { border-color: #86efac; }
.asd-step-chip.running { border-color: #3b82f6; box-shadow: 0 0 0 1px #93c5fd; }
.asd-step-chip.running .st { color: #1d4ed8; font-weight: 600; }
.asd-step-chip-regen {
  margin-top: 6px;
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--asd-border);
  background: #fff;
  color: var(--asd-accent);
  cursor: pointer;
  line-height: 1.3;
}
.asd-step-chip-regen:hover { background: var(--asd-accent-soft); border-color: #fca5a5; }
.asd-step-chip-regen:disabled { opacity: 0.45; cursor: not-allowed; }
.asd-step-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.asd-step-title-row h3 { margin: 0; }
.asd-btn-regen { font-size: 12px; padding: 4px 10px; color: var(--asd-accent); border-color: #fca5a5; }
.asd-review-panel {
  margin: 12px 0 4px;
  padding: 12px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
}
.asd-review-title { margin: 0 0 8px; font-size: 14px; color: var(--asd-ok); }
.asd-review-report {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  color: var(--asd-text);
  max-height: 220px;
  overflow: auto;
}
.asd-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.asd-tabs button { border: none; background: transparent; padding: 6px 10px; cursor: pointer; border-bottom: 2px solid transparent; }
.asd-tabs button.active { border-bottom-color: var(--asd-accent); color: var(--asd-accent); font-weight: 650; }
.asd-studio-grid { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
@media (max-width: 900px) { .asd-studio-grid { grid-template-columns: 1fr; } }
.asd-editor, .asd-style { width: 100%; min-height: 320px; border: 1px solid var(--asd-border); border-radius: 8px; padding: 12px; font-family: inherit; resize: vertical; }
.asd-style { min-height: 100px; }
.asd-title-input { border: none; font-size: 18px; font-weight: 650; width: 100%; max-width: 280px; background: transparent; }
.asd-studio-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.asd-form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.asd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 28px; align-items: flex-start; }
.asd-chips button { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--asd-border); background: #fff; cursor: pointer; }
.asd-chips button.active { background: var(--asd-accent-soft); border-color: #fca5a5; color: var(--asd-accent); font-weight: 600; }
.asd-api-block { border: 1px dashed var(--asd-border); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.asd-api-block label { display: block; margin: 8px 0 4px; font-size: 12px; color: var(--asd-muted); }
.asd-api-block input, .asd-api-block select { width: 100%; max-width: 480px; padding: 8px; border: 1px solid var(--asd-border); border-radius: 6px; }
.asd-aspect-select { width: 100%; max-width: 100%; padding: 8px; border: 1px solid var(--asd-border); border-radius: 8px; font-size: 13px; background: #fff; margin: 6px 0 4px; }
.asd-check { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.asd-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.asd-media-grid img { width: 100%; border-radius: 8px; border: 1px solid var(--asd-border); }
.asd-media-grid figure { margin: 0; }
.asd-media-grid figcaption { font-size: 11px; color: var(--asd-muted); margin-top: 4px; }
.asd-media-export { margin-top: 14px; padding: 12px; border: 1px solid #fde68a; border-radius: 8px; background: #fffbeb; }
.asd-media-export .asd-hint { margin-bottom: 10px; color: #92400e; }
.asd-media-grid { margin-top: 12px; }
.asd-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; max-width: 90vw; }
.asd-toast.show { opacity: 1; pointer-events: auto; }
.asd-toast.ok { background: var(--asd-ok); }
.asd-toast.err { background: var(--asd-accent); }
.asd-toast.warn { background: #b45309; }
.asd-duration-panel { border: 1px dashed var(--asd-border); border-radius: 8px; padding: 14px; margin-top: 8px; background: #fff; }
.asd-duration-label { display: block; margin: 10px 0 6px; font-size: 13px; color: var(--asd-muted); }
.asd-duration-input { width: 120px; padding: 8px; border: 1px solid var(--asd-border); border-radius: 6px; font-size: 15px; }
.asd-gen-bar { position: fixed; bottom: 16px; right: 16px; width: min(420px, calc(100vw - 32px)); background: #1f2937; color: #f9fafb; padding: 12px 14px; border-radius: 10px; z-index: 98; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.asd-gen-bar.asd-gen-bar-queue { background: #422006; border: 1px solid #f59e0b; }
.asd-gen-bar.asd-gen-bar-err { background: #450a0a; border: 1px solid #f87171; }
.asd-duration-diff { font-weight: 600; color: var(--asd-accent); }
.asd-duration-diff.ok { color: var(--asd-ok); }
.asd-step-view-hint { margin-top: 6px; padding: 8px 10px; background: #fffbeb; border-radius: 6px; border: 1px solid #fde68a; font-size: 12px; }
.asd-gen-bar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.asd-gen-bar-close { border: none; background: transparent; color: #d1d5db; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
.asd-gen-bar-close:hover { color: #fff; }
.asd-gen-track { height: 6px; background: #374151; border-radius: 999px; overflow: hidden; }
.asd-gen-fill { height: 100%; background: linear-gradient(90deg, #34d399, #10b981); transition: width .35s ease; }
.asd-gen-bar-queue .asd-gen-fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.asd-gen-bar-err .asd-gen-fill { background: linear-gradient(90deg, #f87171, #ef4444); }
.asd-gen-bar-msg { margin: 8px 0 0; font-size: 12px; color: #d1d5db; line-height: 1.45; max-height: 4.5em; overflow-y: auto; }
.asd-editor[readonly] { background: #f8fafc; cursor: default; }
.asd-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eee; }
.asd-badge.warn { background: #fef3c7; }
