:root {
  --bg: #f3f6f8;
  --panel: rgba(255,255,255,.92);
  --ink: #13212a;
  --muted: #607381;
  --line: #dce8ee;
  --accent: #2f80ed;
  --accent-2: #28b487;
  --warn: #d97706;
  --bad: #d14343;
  --ok: #1f9d62;
  --shadow: 0 20px 55px rgba(16, 28, 38, 0.08);
  font-family: "SF Pro Text", "PingFang SC", "Hiragino Sans GB", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(47,128,237,.11), transparent 30%),
    radial-gradient(circle at top right, rgba(40,180,135,.10), transparent 28%),
    linear-gradient(180deg, #f8fbfd, var(--bg));
}
.shell {
  max-width: 1420px;
  margin: 0 auto;
  padding: 28px 18px 72px;
}
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 13px;
}
h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 60px);
  line-height: .95;
  letter-spacing: -.04em;
}
h2 {
  margin: 0 0 10px;
  font-size: 24px;
}
.sub, .hint {
  color: var(--muted);
  line-height: 1.65;
}
.sub { margin: 10px 0 0; max-width: 840px; }
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}
.mode-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 8px;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow);
}
.mode-tab {
  min-width: 136px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.mode-tab.active {
  background: linear-gradient(135deg, var(--accent), #56a0ff);
  color: #fff;
  box-shadow: 0 10px 20px rgba(47,128,237,.22);
}
.key-panel {
  margin-bottom: 18px;
}
.key-panel .field {
  margin-bottom: 0;
}
.manual-character-panel {
  margin-bottom: 18px;
}
.manual-character-panel details {
  display: grid;
  gap: 14px;
}
.manual-character-panel summary {
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
}
.manual-character-panel summary::marker {
  color: var(--accent);
}
.manual-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.manual-upload-row .hint {
  flex: 1;
  min-width: 180px;
}
.hidden {
  display: none !important;
}
.mode-layout.hidden {
  display: none;
}
.banner {
  display: none;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 14px;
}
.banner.show { display: block; }
.banner.info { background: #eaf4ff; color: #1754aa; }
.banner.error { background: #fff2f1; color: var(--bad); }
.banner.success { background: #eafaf2; color: var(--ok); }
.layout {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.config, .generate, .tasks, .assets, .library, .common-assets-panel, .asset-export-panel { grid-column: 1 / -1; }
.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.field label {
  font-size: 14px;
  color: var(--muted);
}
.grid {
  display: grid;
  gap: 14px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
input, textarea, select, button {
  font: inherit;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 14px 16px;
}
textarea {
  resize: vertical;
  min-height: 110px;
}
button {
  border: none;
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}
.primary {
  background: linear-gradient(135deg, var(--accent), #56a0ff);
  color: #fff;
}
.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.ghost {
  background: #eef6fb;
  color: var(--ink);
}
.inline {
  display: flex;
  gap: 10px;
  align-items: center;
}
.inline > *:first-child { flex: 1; }
.slider-labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.slider-labels strong { color: var(--accent); }
.estimate {
  margin: -2px 0 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #edf7ff;
  color: #1754aa;
  font-weight: 700;
  border: 1px solid #cfe4ff;
}
.web-extract-preview {
  margin: 0 0 16px;
}
.extract-empty {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  background: #f8fbfd;
  color: var(--muted);
  line-height: 1.6;
}
.extract-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid #cfe4ff;
  background: linear-gradient(135deg, #f6fbff, #fff);
  display: grid;
  gap: 10px;
}
.extract-card h3 {
  margin: 0;
  font-size: 20px;
}
.extract-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}
.extract-condensed {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef8ff;
  color: #2c6fbd;
  font-size: 13px;
  font-weight: 800;
}
.extract-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
}
.extract-safety {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #dce9f4;
  background: #f7fbff;
  color: var(--muted);
  line-height: 1.5;
}
.extract-safety strong {
  color: var(--ink);
}
.extract-safety.warn {
  border-color: #ffd3bf;
  background: #fff7f1;
}
.extract-safety.warn strong {
  color: #c4512a;
}
.extract-safety.ok {
  border-color: #cceedd;
  background: #f1fff7;
}
.extract-safety.ok strong {
  color: #267448;
}
.extract-page-advice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #cfe4ff;
  background: #f2f8ff;
  color: var(--muted);
  line-height: 1.5;
}
.extract-page-advice div {
  display: grid;
  gap: 4px;
}
.extract-page-advice strong {
  color: var(--ink);
}
.extract-page-advice.warn {
  border-color: #ffd7a8;
  background: #fff9ee;
}
.extract-page-advice.warn strong {
  color: #a85b12;
}
.extract-page-advice.ok {
  border-color: #cceedd;
  background: #f1fff7;
}
.extract-page-advice.ok strong {
  color: #267448;
}
.extract-page-advice button {
  flex: 0 0 auto;
}
.extract-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}
.extract-actions.standalone {
  justify-content: flex-start;
}
.extract-headings {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.extract-headings span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eaf4ff;
  color: #1754aa;
  font-size: 13px;
  font-weight: 700;
}
.extract-card pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.55;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.extract-image-section {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}
.extract-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.extract-image-card {
  display: grid;
  gap: 8px;
  position: relative;
  padding: 9px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: #fff;
  box-shadow: 0 8px 18px rgba(16, 28, 38, .08);
  cursor: pointer;
}
.extract-image-card.selected {
  border-color: var(--accent);
  background: #f2f8ff;
}
.extract-image-card input {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
.extract-image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  background: #e8f0f7;
}
.extract-image-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.toggle-field {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 4px 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, #f7fbff, #f0fff9);
  cursor: pointer;
}
.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-switch {
  position: relative;
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: #cad7df;
  box-shadow: inset 0 0 0 1px rgba(19,33,42,.08);
  transition: background .16s ease;
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(16, 28, 38, 0.22);
  transition: transform .16s ease;
}
.toggle-field input:checked + .toggle-switch {
  background: linear-gradient(135deg, var(--accent), #58a6ff);
}
.toggle-field input:checked + .toggle-switch::after {
  transform: translateX(22px);
}
.toggle-field strong {
  display: block;
  margin-bottom: 4px;
}
.toggle-field small {
  display: block;
  color: var(--muted);
  line-height: 1.55;
}
.upload-actions, .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f0f7ff, #ecfff8);
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 600;
}
.route-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}
.route-grid {
  min-height: 100px;
  border-radius: 22px;
  transition: background .15s ease, outline-color .15s ease;
}
.route-grid.empty::before,
.library-grid.empty::before,
.common-assets-grid.empty::before,
.asset-export-result.empty::before,
.task-list.empty::before {
  content: "还没有内容";
  display: block;
  padding: 26px 18px;
  border-radius: 20px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255,255,255,.72);
}
.route-grid.empty::before {
  content: "拖拽图片到这里，或点击上方按钮选择";
  grid-column: 1 / -1;
  min-height: 76px;
  display: flex;
  align-items: center;
}
.common-assets-panel.is-drop-target,
.asset-export-drop.is-drop-target,
.route-grid.is-drop-target {
  outline: 3px dashed var(--accent);
  outline-offset: 4px;
  background: rgba(47, 128, 237, .08);
}
.route-card {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  border: 2px solid transparent;
  box-shadow: 0 10px 24px rgba(16, 28, 38, 0.08);
  min-height: 100px;
  max-height: 100px;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
}
.route-card.dragging {
  opacity: .52;
}
.route-card img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
  background: #edf3f8;
}
.route-meta {
  min-width: 0;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-content: center;
}
.route-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-meta .hint {
  text-align: right;
  white-space: nowrap;
}
.route-meta .mini-actions {
  align-self: end;
  justify-content: flex-end;
}
.route-note-input {
  grid-column: 1 / -1;
  min-height: 42px;
  max-height: 46px;
  padding: 7px 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fbfdff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  resize: none;
}
.route-order {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.route-card .mini-actions {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 2;
}
.task-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.task-actions button {
  padding: 10px 14px;
  border-radius: 14px;
}
.mini-actions button {
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.library-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}
.library-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: stretch;
}
.library-grid.collapsed {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.character-card {
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  border: 2px solid transparent;
  box-shadow: 0 10px 24px rgba(16, 28, 38, 0.08);
  cursor: pointer;
}
.library-grid.compact .character-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  min-height: 118px;
}
.character-card.active {
  border-color: var(--accent);
  box-shadow: 0 18px 32px rgba(47,128,237,.18);
}
.character-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #edf3f8;
}
.library-grid.compact .character-card img {
  height: 118px;
  aspect-ratio: auto;
}
.character-meta {
  padding: 12px;
  display: grid;
  gap: 6px;
}
.library-grid.compact .character-meta {
  gap: 4px;
  min-width: 0;
}
.library-grid.compact .character-meta strong,
.library-grid.compact .character-meta .hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-drawer-toggle {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 2px;
  background: #eef6fb;
  color: var(--ink);
  border: 1px solid var(--line);
}
.character-view-select,
.view-picker {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fbfdff;
  color: var(--ink);
  font-size: 14px;
}
.character-view-select {
  margin-top: 4px;
}
.selected-character {
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: grid;
  gap: 6px;
}
.selected-character strong { color: var(--ink); }
.selected-count {
  color: var(--accent);
  font-weight: 800;
}
.selected-character-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.selected-character-item:first-of-type {
  border-top: none;
}
.selected-character-item .view-picker-label,
.selected-character-item .view-picker {
  grid-column: 1 / -1;
}
.mini-remove {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}
.selected-view-summary {
  color: var(--accent);
  font-weight: 600;
}
.view-picker-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}
.common-assets-panel summary,
.manual-character-panel summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}
.common-assets-panel summary small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 500;
}
.common-assets-upload {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.1fr .7fr 1.3fr auto auto;
  gap: 12px;
  align-items: end;
}
.common-assets-upload .field {
  margin-bottom: 0;
}
.common-assets-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.common-asset-card {
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(16, 28, 38, 0.08);
}
.common-asset-card img {
  width: 100%;
  height: 130px;
  object-fit: contain;
  display: block;
  background: linear-gradient(135deg, #f8fbfd, #edf5fb);
}
.common-asset-meta {
  padding: 12px;
  display: grid;
  gap: 8px;
}
.common-asset-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.asset-export-drop {
  margin-top: 16px;
  min-height: 220px;
  padding: 22px;
  border-radius: 28px;
  border: 1px dashed var(--line);
  background:
    linear-gradient(135deg, rgba(47,128,237,.08), rgba(40,180,135,.06)),
    rgba(255,255,255,.78);
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  transition: background .15s ease, outline-color .15s ease;
}
.asset-export-drop strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}
.asset-export-drop img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(16, 28, 38, .12);
}
.asset-export-drop:not(.has-image) img {
  display: none;
}
.asset-export-result {
  display: grid;
  gap: 22px;
}
.asset-export-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.asset-export-summary > div {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  gap: 4px;
}
.asset-export-summary strong {
  display: block;
  font-size: 22px;
}
.asset-export-summary span,
.asset-export-section-head span {
  color: var(--muted);
  font-size: 13px;
}
.asset-export-section {
  display: grid;
  gap: 14px;
}
.asset-export-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.asset-export-section-head h3 {
  margin: 0;
  font-size: 20px;
}
.asset-export-redraw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid #b9d7ff;
  background: linear-gradient(135deg, #eef7ff 0%, #fff8e8 100%);
  box-shadow: 0 16px 36px rgba(37, 99, 235, .10);
}
.asset-export-redraw h3 {
  margin: 0 0 6px;
  font-size: 20px;
}
.asset-export-redraw p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}
.asset-export-redraw button {
  flex-shrink: 0;
}
.asset-export-vector {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #f7fbff 0%, #eef2ff 100%);
}
.asset-export-vector-controls {
  min-width: 220px;
  display: grid;
  gap: 6px;
}
.asset-export-vector-controls label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.asset-export-vector-controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 11px 14px;
  font-size: 15px;
  color: var(--ink);
}
.asset-export-vector-controls small {
  color: var(--muted);
  line-height: 1.45;
}
.asset-export-feature-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.asset-export-feature-actions button {
  flex-shrink: 0;
}
.asset-export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.asset-export-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 30px rgba(16, 28, 38, .08);
}
.asset-export-thumb {
  height: 170px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    repeating-conic-gradient(#f6f8fa 0% 25%, #e9eef2 0% 50%) 50% / 24px 24px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.asset-export-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.asset-export-card-meta {
  display: grid;
  gap: 4px;
}
.asset-export-card-meta span {
  color: var(--muted);
  font-size: 13px;
}
.asset-export-all-text {
  width: 100%;
  min-height: 160px;
}
.asset-export-text-list {
  display: grid;
  gap: 12px;
}
.asset-export-text-block {
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}
.asset-export-text-block > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.asset-export-text-block textarea {
  width: 100%;
  min-height: 88px;
}
.inline-warning {
  display: block;
  margin: 0;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}
.task-list {
  display: grid;
  gap: 14px;
}
.task-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.task-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.task-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.task-status.pending,
.task-status.openai_processing,
.task-status.cancel_requested { background: #fff6ea; color: var(--warn); }
.task-status.completed { background: #eafaf2; color: var(--ok); }
.task-status.failed,
.task-status.timeout_unknown,
.task-status.cancelled { background: #fff2f1; color: var(--bad); }
.task-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.variant-result {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8fbfd;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.variant-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-weight: 800;
}
.variant-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.page-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.result-card {
  border-radius: 18px;
  overflow: hidden;
  background: #f7fbff;
  border: 1px solid var(--line);
}
.result-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.result-meta {
  padding: 10px 12px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.result-actions button {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}
.result-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.danger-lite {
  background: #fff2f1;
  color: var(--bad);
  border: 1px solid #ffd7d2;
}
.editor-layout {
  grid-template-columns: 1fr;
}
.editor-panel {
  grid-column: 1 / -1;
}
.editor-actions,
.editor-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.compact-select {
  display: inline-grid;
  gap: 4px;
  min-width: 190px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.compact-select select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
}
.font-install-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.font-upload-btn {
  padding: 10px 12px;
  border-radius: 14px;
}
.small-hint {
  margin: -2px 0 0;
  font-size: 13px;
}
.editor-toolbar {
  margin: 18px 0;
}
.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.editor-canvas-wrap {
  min-width: 0;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(47,128,237,.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(47,128,237,.06) 25%, transparent 25%),
    #f8fbfd;
  background-size: 28px 28px;
}
.editor-stage {
  position: relative;
  width: 100%;
  min-height: 520px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #eaf1f6;
  box-shadow: inset 0 0 0 1px rgba(19,33,42,.08);
}
.editor-stage.has-image {
  min-height: 0;
}
.editor-stage img {
  display: none;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}
.editor-overlay-layer {
  position: absolute;
  inset: 0;
}
.editor-empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.editor-sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 32px rgba(16, 28, 38, 0.07);
}
.editor-sidebar h3 {
  margin: 0;
  font-size: 20px;
}
.editor-box {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--box-bg, #fff);
  border: 3px solid #111;
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.editor-box.selected {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
.editor-box:not(.selected) .editor-resize {
  display: none;
}
.editor-box-text {
  position: relative;
  z-index: 2;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  white-space: pre-wrap;
  text-align: center;
  line-height: 1.25;
  font-weight: 800;
  word-break: break-word;
}
.editor-text-vertical .editor-box-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  line-height: 1.12;
  letter-spacing: .04em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.editor-bubble-left,
.editor-bubble-right,
.editor-bubble-round,
.editor-thought-left,
.editor-thought-right {
  border-radius: 999px;
}
.editor-bubble-left,
.editor-bubble-right {
  padding: 12px 16px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.editor-bubble-shape {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.16));
}
.editor-bubble-left .editor-box-text,
.editor-bubble-right .editor-box-text {
  position: absolute;
  left: 0;
  top: var(--bubble-text-top, 0%);
  width: 100%;
  height: var(--bubble-text-height, 82%);
  padding: 12px 16px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.editor-bubble-round {
  border-radius: 50% / 46%;
}
.editor-thought-left,
.editor-thought-right {
  border-radius: 50% / 45%;
}
.editor-thought-left::before,
.editor-thought-right::before,
.editor-thought-left::after,
.editor-thought-right::after {
  content: "";
  position: absolute;
  z-index: 1;
  border: 3px solid #111;
  border-radius: 999px;
  background: var(--box-bg, #fff);
  pointer-events: none;
}
.editor-thought-left::before {
  left: 18%;
  bottom: -22px;
  width: 18px;
  height: 18px;
}
.editor-thought-left::after {
  left: 8%;
  bottom: -42px;
  width: 10px;
  height: 10px;
  box-shadow: -18px 18px 0 -2px var(--box-bg, #fff), -18px 18px 0 1px #111;
}
.editor-thought-right::before {
  right: 18%;
  bottom: -22px;
  width: 18px;
  height: 18px;
}
.editor-thought-right::after {
  right: 8%;
  bottom: -42px;
  width: 10px;
  height: 10px;
  box-shadow: 18px 18px 0 -2px var(--box-bg, #fff), 18px 18px 0 1px #111;
}
.editor-tail-top.editor-thought-left::before {
  top: -22px;
  bottom: auto;
}
.editor-tail-top.editor-thought-left::after {
  top: -42px;
  bottom: auto;
  box-shadow: -18px -18px 0 -2px var(--box-bg, #fff), -18px -18px 0 1px #111;
}
.editor-tail-top.editor-thought-right::before {
  top: -22px;
  bottom: auto;
}
.editor-tail-top.editor-thought-right::after {
  top: -42px;
  bottom: auto;
  box-shadow: 18px -18px 0 -2px var(--box-bg, #fff), 18px -18px 0 1px #111;
}
.editor-caption {
  border-radius: var(--box-radius, 8px);
}
.editor-note {
  border-radius: var(--box-radius, 14px);
  background: var(--box-bg, #fff6d8);
}
.editor-resize {
  position: absolute;
  right: -9px;
  bottom: -9px;
  z-index: 4;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
  cursor: nwse-resize;
}
.editor-saved-panel {
  margin-top: 18px;
}
.editor-saved-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.editor-saved-list.empty::before {
  content: "还没有保存的漫画";
  display: block;
  grid-column: 1 / -1;
  padding: 24px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255,255,255,.72);
  font-weight: 700;
  text-align: center;
}
.editor-saved-card {
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(16, 28, 38, 0.06);
}
.editor-saved-card.active {
  border-color: var(--accent);
  box-shadow: 0 16px 30px rgba(47, 128, 237, 0.14);
}
.editor-saved-card img,
.editor-saved-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #eef5fb;
}
.editor-saved-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}
.editor-saved-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}
.editor-saved-body strong {
  font-size: 16px;
  line-height: 1.35;
}
.editor-saved-body span {
  color: var(--muted);
  font-size: 13px;
}
.editor-saved-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.editor-saved-actions button {
  padding: 8px 10px;
  min-height: 0;
  border-radius: 12px;
  font-size: 13px;
}
.composer-panel {
  margin-top: 18px;
}
.composer-shell {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(420px, 1.08fr);
  gap: 18px;
  align-items: start;
}
.composer-source-panel,
.composer-output-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.composer-source-panel h3,
.composer-output-panel h3 {
  margin: 0;
  font-size: 20px;
}
.panel-head.compact {
  align-items: flex-start;
}
.composer-source-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.composer-source-list.empty::before {
  content: "还没有来源漫画";
  display: block;
  grid-column: 1 / -1;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255,255,255,.72);
}
.composer-source-thumb {
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: 16px;
  background: #edf3f8;
}
.composer-source-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(47,128,237,.18);
}
.composer-source-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.composer-source-thumb span {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-weight: 800;
}
.composer-crop-stage {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: #eaf1f6;
  cursor: crosshair;
}
.composer-crop-stage.has-image {
  min-height: 0;
}
.composer-crop-stage img {
  display: none;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}
.composer-crop-box {
  position: absolute;
  z-index: 2;
  border: 4px solid #2f80ed;
  background: rgba(47,128,237,.14);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
  pointer-events: none;
}
.composer-page-wrap {
  padding: 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(47,128,237,.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(47,128,237,.05) 25%, transparent 25%),
    #f8fbfd;
  background-size: 28px 28px;
}
.composer-rebuild-results {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}
.composer-page {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 2 / 3;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 12px;
  border: 5px solid #111;
  background: #fff;
  box-shadow: 0 16px 32px rgba(16, 28, 38, 0.12);
}
.composer-panel-layer {
  position: absolute;
  inset: 0;
}
.composer-panel-slot {
  position: absolute;
  overflow: hidden;
  border: 4px solid #111;
  background: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.composer-panel-slot.selected {
  outline: 4px solid var(--accent);
  outline-offset: -8px;
}
.composer-panel-slot img {
  position: absolute;
  display: block;
  user-select: none;
  pointer-events: none;
}
.composer-panel-index {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0,0,0,.76);
  font-weight: 800;
}
@media (max-width: 1120px) {
  .layout,
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }
  .common-assets-upload {
    grid-template-columns: 1fr 1fr;
  }
  .route-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .editor-saved-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .editor-shell {
    grid-template-columns: 1fr;
  }
  .composer-shell {
    grid-template-columns: 1fr;
  }
  .editor-sidebar {
    position: static;
  }
}
@media (max-width: 760px) {
  .shell { padding: 20px 12px 48px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .route-grid,
  .library-grid,
  .result-grid,
  .page-result-grid,
  .editor-saved-list {
    grid-template-columns: 1fr;
  }
  .inline,
  .panel-head,
  .upload-actions,
  .editor-actions,
  .editor-toolbar,
  .font-install-row,
  .common-assets-upload {
    flex-direction: column;
    align-items: stretch;
  }
  .common-assets-upload {
    display: grid;
    grid-template-columns: 1fr;
  }
  .asset-export-redraw {
    flex-direction: column;
    align-items: stretch;
  }
  .asset-export-feature-actions {
    justify-content: flex-start;
  }
  .asset-export-drop {
    grid-template-columns: 1fr;
  }
  .mode-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
  .mode-tab {
    width: 100%;
  }
  .editor-stage {
    min-height: 360px;
  }
  .composer-source-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .composer-crop-stage {
    min-height: 300px;
  }
}
