* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f6f8; color: #222; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #fff; border-bottom: 1px solid #e8e8e8; }
.brand { font-weight: 600; }
.account { display: flex; gap: 10px; align-items: center; font-size: 14px; }
main { max-width: 1500px; margin: 16px auto; padding: 0 16px; }
.card { background: #fff; border: 1px solid #e8e8e8; border-radius: 12px; padding: 14px 16px; }
.login { max-width: 360px; margin: 60px auto; display: flex; flex-direction: column; gap: 10px; }

/* 三栏工作台（仿三笙：左输入 / 中场景风格 / 右结果 + 底部配置） */
.workspace { display: flex; flex-direction: column; gap: 14px; }
.ws-topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: #fff; border: 1px solid #e8e8e8; border-radius: 12px; padding: 12px 18px; }
.ws-topbar label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.ws-topbar select { width: auto; min-width: 160px; }
.ws-topbar .ws-tip { color: #999; font-size: 13px; }
.ws-cols { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 12px;
  grid-template-areas: "input scene results" "config config results"; }
.col-input textarea { min-height: 64px; }
.col-scene { display: flex; flex-direction: column; }
.col-scene .style-chips { min-height: 0; }
.ws-cols > * { min-width: 0; }
.col-input { grid-area: input; }
.col-scene { grid-area: scene; }
.col-results { grid-area: results; position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow-y: auto; }
.ws-config { grid-area: config; }
.config-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 6px; }
.config-foot .cost { margin: 0; }
.config-go { display: flex; flex-direction: column; align-items: stretch; min-width: 240px; }
.config-go .primary { margin-top: 0; }
@media (max-width: 900px) {
  .ws-cols { grid-template-columns: 1fr; grid-template-areas: "input" "scene" "config" "results"; }
  .col-results { position: static; max-height: none; }
}
h2, h3 { margin: 6px 0; font-weight: 600; }
h3 { font-size: 14px; margin-top: 12px; }
.col h3:first-child, .ws-config h3:first-child { margin-top: 2px; }
input, textarea, button { font: inherit; }
input, textarea { width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 8px; }
textarea { min-height: 64px; resize: vertical; }
.row { display: flex; gap: 8px; }
button { padding: 9px 14px; border: 1px solid #ddd; border-radius: 8px; background: #fff; cursor: pointer; }
button.primary { background: #1668dc; border-color: #1668dc; color: #fff; width: 100%; margin-top: 10px; font-weight: 500; border-radius: 10px; padding: 11px 14px; }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }
button.ghost { border: none; background: none; color: #888; cursor: default; font-size: 13px; }
.muted { color: #9aa0a8; font-size: 12px; margin: 3px 0; }
.sub { color: #aab0b8; }
.dropzone { border: 1.5px dashed #c9c9c9; border-radius: 10px; padding: 16px; text-align: center; color: #aaa; cursor: pointer; font-size: 13px; transition: border-color .15s; }
.dropzone:hover { border-color: #1668dc; color: #1668dc; }
.dropzone.drag { border-color: #1668dc; color: #1668dc; }
.dropzone.small { padding: 16px; margin-top: 6px; }
.dropzone.compact { padding: 7px 12px; font-size: 13px; color: #1668dc; border-style: solid; border-color: #d6e4ff; background: #f7faff; }
.scene-inline { background: #f4f8ff; border: 1px solid #d6e4ff; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.scene-inline .dropzone { background: #fff; }
.style-block { margin-top: 12px; font-size: 14px; }
.style-block summary { color: #666; cursor: pointer; }
.thumbs.recent img { cursor: copy; }
.plan { margin-top: 10px; font-size: 13px; }
.plan summary { color: #1668dc; cursor: pointer; }
.plan ul { margin: 8px 0 0; padding-left: 18px; color: #555; }
.plan li { margin-bottom: 5px; }
.plan .copy { color: #b06a00; margin-left: 6px; }
select { width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 8px; background: #fff; font: inherit; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid #eee; }
/* 上传图自适应：1 张大、2 张中、3 张以上小（＋方块不参与） */
.thumbs.n-1 .thumb:not(.add-tile) img { width: 180px; height: 180px; }
.thumbs.n-2 .thumb:not(.add-tile) img { width: 110px; height: 110px; }
/* 加图小方块（仿三笙"继续上传"小方块） */
.add-tile { width: 64px; height: 64px; border: 1.5px dashed #c9c9c9; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #b5bbc4; font-size: 22px; cursor: pointer; }
.add-tile:hover { border-color: #1668dc; color: #1668dc; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.presets button { padding: 5px 12px; font-size: 12px; border-radius: 999px; border-color: #e6e6e6; color: #666; }
.presets button.active { border-color: #1668dc; background: #f0f6ff; color: #1668dc; }
/* 套图配置：横排卡片一字排开（压在左两栏下方），紧凑不留多余空白 */
/* 苹果极简：无方框，控件小而轻，留白说话 */
#typeRows { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px 4px; margin-top: 8px; }
.type-row { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 8px 4px; border: none; background: none; font-size: 12px; }
.type-row .type-name { font-weight: 500; font-size: 13px; color: #333; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 24px; height: 24px; padding: 0; border-radius: 6px; line-height: 1; font-size: 14px; color: #555; border-color: #e2e2e2; }
.stepper .count { min-width: 16px; text-align: center; font-size: 14px; font-weight: 500; }
.qtoggle { display: inline-flex; background: #f0f1f3; border-radius: 7px; padding: 2px; }
.qtoggle button { padding: 3px 11px; border: none; border-radius: 5px; background: none; color: #999; font-size: 12px; }
.qtoggle button.active { background: #fff; color: #1668dc; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.cost { font-size: 13px; font-weight: 500; color: #1668dc; margin: 10px 0 0; }
.use-summary { font-size: 12px; color: #888; background: #f7f8fa; border: none; border-radius: 8px; padding: 7px 10px; margin: 8px 0 0; }
.use-summary .us-tip { color: #999; margin-left: 6px; }
.set { background: #fff; border: 1px solid #e8e8e8; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.set-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.set-head .status { font-size: 13px; color: #1668dc; }
.set-head .status.failed { color: #d4380d; }
.group-label { font-size: 13px; color: #888; margin: 10px 0 6px; }
/* 历史单：收成一行小条，点开看图 */
.set-collapsed { background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; margin-bottom: 8px; padding: 0; }
.set-collapsed > summary { list-style: none; cursor: pointer; padding: 10px 14px; }
.set-collapsed > summary::-webkit-details-marker { display: none; }
.set-collapsed > summary::before { content: "▸ "; color: #aaa; }
.set-collapsed[open] > summary::before { content: "▾ "; }
.set-collapsed > summary .set-head { display: inline-flex; }
.set-collapsed[open] { padding: 0 14px 12px; }
.set-collapsed .group-label { margin-top: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cell { position: relative; aspect-ratio: 1; border-radius: 8px; background: #f2f3f5; display: flex; align-items: center; justify-content: center; overflow: hidden; color: #aaa; font-size: 12px; }
.cell.portrait { aspect-ratio: 2 / 3; }
.cell.cell-wait { border: 1.5px dashed #d8dce2; background: #fafbfc; color: #b5bbc4; font-size: 12px; }
.preview-box { border: 1px dashed #d6e4ff; background: #f7faff; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.preview-box > p { margin: 0 0 6px; }
.history-all { margin-top: 6px; }
.history-all > summary { cursor: pointer; list-style: none; font-size: 14px; color: #1668dc; background: #f4f6f8; border: 1px solid #e3e6ea; border-radius: 10px; padding: 10px 14px; }
.history-all > summary::-webkit-details-marker { display: none; }
.history-all > summary::before { content: "▸ "; }
.history-all[open] > summary::before { content: "▾ "; }
.history-all[open] > summary { margin-bottom: 8px; }
.cell img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.cell .spin { width: 18px; height: 18px; border: 2px solid #d0d0d0; border-top-color: #1668dc; border-radius: 50%; animation: spin 0.9s linear infinite; }
.cell .regen { position: absolute; right: 4px; bottom: 4px; font-size: 11px; padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,0.92); opacity: 0; transition: opacity 0.15s; }
.cell .copybtn { position: absolute; left: 4px; bottom: 4px; font-size: 11px; padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,0.92); opacity: 0; transition: opacity 0.15s; }
.cell:hover .regen, .cell-failed .regen, .cell:hover .copybtn { opacity: 1; }
/* 精简版：小粘贴按钮、ℹ折叠帮助、紧凑最近用过、标题标签 */
.zone-tools { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.paste-btn { padding: 3px 8px; font-size: 12px; color: #1668dc; border: none; background: none; }
.paste-btn i { font-style: normal; margin-right: 3px; }
.help { font-size: 12px; }
.help summary { color: #1668dc; cursor: pointer; list-style: none; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "ℹ "; }
.help[open] { color: #888; line-height: 1.6; margin-top: 4px; }
.sub { margin: 2px 0 6px; }
h3 .req { font-size: 11px; color: #d4380d; font-weight: 400; margin-left: 6px; }
h3 .opt { font-size: 12px; color: #aaa; font-weight: 400; margin-left: 6px; }
.recent-strip { margin-top: 8px; }
.recent-strip > summary { font-size: 12px; color: #999; cursor: pointer; list-style: none; }
.recent-strip > summary::-webkit-details-marker { display: none; }
.recent-strip > summary::before { content: "▸ "; }
.recent-strip[open] > summary::before { content: "▾ "; }
.recent-strip .thumbs { margin-top: 6px; }
.recent-strip .thumbs img { width: 40px; height: 40px; }
.recent-strip .thumb .rm { width: 16px; height: 16px; font-size: 11px; line-height: 16px; top: -5px; right: -5px; }
.thumb { position: relative; display: inline-block; }
.thumb .rm { position: absolute; top: -7px; right: -7px; width: 19px; height: 19px; padding: 0; border: none; border-radius: 50%; background: #5f6368; color: #fff; font-size: 13px; line-height: 19px; cursor: pointer; }
.thumb .rm:hover { background: #d4380d; }
.viewer-copy { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px; border: none; background: #fff; font-size: 14px; cursor: pointer; }
.skipline { display: block; margin-top: 8px; font-size: 13px; cursor: pointer; }
.hint-box { background: #fff8e6; border: 1px solid #ffe6a8; border-radius: 8px; padding: 8px 10px; margin: 8px 0; line-height: 1.6; }
.style-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.style-chips .chip { padding: 6px 11px; font-size: 13px; border-radius: 999px; }
.style-chips .chip.active { border-color: #1668dc; background: #f0f6ff; color: #1668dc; }
.style-chips .chip .del { color: #bbb; margin-left: 3px; padding: 0 2px; }
.style-chips .chip .del:hover { color: #d4380d; }
.style-sub { margin-top: 6px; }
.style-sub > summary { font-size: 13px; color: #888; }
.cell .flag { position: absolute; left: 4px; top: 4px; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(255,193,7,0.92); color: #5a4500; }
.input-hint { background: #fff8e6; border: 1px solid #ffe08a; color: #8a6d1a; border-radius: 8px; padding: 8px 12px; font-size: 13px; line-height: 1.5; margin: 0 0 10px; }
.confirm-row { display: grid; grid-template-columns: 84px 1fr; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed #eee; }
.confirm-row .role { font-size: 13px; color: #1668dc; background: #f0f6ff; border-radius: 6px; padding: 3px 6px; text-align: center; }
.confirm-row .copy-edit { padding: 7px 10px; }
.confirm-row .scene-text { grid-column: 2; margin: 0; font-size: 12px; }
.confirm-ops { display: flex; gap: 10px; margin-top: 12px; }
.confirm-ops .primary { width: auto; margin-top: 0; }
.cell-failed { flex-direction: column; gap: 6px; color: #d4380d; }
@keyframes spin { to { transform: rotate(360deg); } }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out; }
.viewer img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* 管理后台 */
.admin-link { color: #1668dc; text-decoration: none; font-size: 14px; }
.admin-main { max-width: 1200px; }
.admin-login { max-width: 420px; margin: 60px auto; display: flex; flex-direction: column; gap: 10px; }
.admin-workspace { display: flex; flex-direction: column; gap: 14px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.admin-row { display: grid; grid-template-columns: 1fr 130px; gap: 8px; margin: 8px 0; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.admin-stats div { background: #f7f8fa; border-radius: 8px; padding: 10px; }
.admin-stats b { display: block; font-size: 22px; color: #1668dc; }
.admin-stats span { color: #888; font-size: 12px; }
.admin-section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-search { display: flex; gap: 8px; min-width: 280px; }
.admin-search button { white-space: nowrap; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { border-bottom: 1px solid #eef0f2; padding: 9px 8px; text-align: left; vertical-align: top; }
.admin-table th { color: #888; font-weight: 500; background: #fafbfc; }
.admin-error { color: #d4380d; font-size: 12px; }
.admin-actions { white-space: nowrap; }
.admin-actions button { padding: 4px 8px; font-size: 12px; margin-right: 4px; }
@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-row { grid-template-columns: 1fr; }
  .admin-search { width: 100%; min-width: 0; }
}
