/* 漫画工作台：暖纸色底、墨线边框和硬阴影、朱红点缀。颜色、间距、字号都在变量里，深色模式只换变量 */
:root {
  --paper: #f3efe6; --card: #fffdf8; --ink: #1a1a1a; --ink-soft: #5f5a52;
  --line: #1a1a1a; --line-soft: #d9d2c4;
  --accent: #d7392b; --accent-ink: #fff; --accent-bg: #fbe1dd;
  --ok: #2e7d32; --warn: #b26a00; --err: #c62828;
  --ok-bg: #e4f1e5; --warn-bg: #fdf0d8; --err-bg: #fbe3e1; --muted-bg: #ebe6db;
  --shadow: 4px 4px 0 var(--ink); --shadow-sm: 2px 2px 0 var(--ink);
  --radius: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 40px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1917; --card: #262321; --ink: #ece7dc; --ink-soft: #a8a198;
    --line: #ece7dc; --line-soft: #3a3632;
    --accent: #ef5a4c; --accent-ink: #1b1917; --accent-bg: #44201e;
    --ok: #6cc070; --warn: #e0a040; --err: #ef6b6b;
    --ok-bg: #203a22; --warn-bg: #3d2d12; --err-bg: #44201e; --muted-bg: #33302c;
  }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink);
       font: 15px/1.6 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
main { max-width: 1160px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); }
main.has-sticky { padding-bottom: 140px; }  /* 底部有固定操作条的页面：留出空白，最后几行不被盖住 */
h1 { font-size: 28px; font-weight: 800; line-height: 1.25; margin: 0 0 var(--s3);
     display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
h2 { font-size: 20px; font-weight: 800; margin: var(--s6) 0 var(--s3); }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 var(--s2); }
.card > h2:first-child, .card > h3:first-child, main > h2:first-child, section > h2:first-child { margin-top: 0; }
p { margin: 0 0 var(--s3); }
a { color: var(--accent); text-underline-offset: 2px; }
.muted { color: var(--ink-soft); font-size: 13px; }
.error { color: var(--err); white-space: pre-wrap; overflow-wrap: anywhere; }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 0; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s4); }
.tag { display: inline-block; padding: 0 10px; border-radius: 999px; background: var(--muted-bg); color: var(--ink-soft);
       font-size: 12px; font-weight: 600; line-height: 1.8; white-space: nowrap; }

/* ---------- 页头 ---------- */
header { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); border-bottom: 2px solid var(--ink); }
header .brand { display: inline-flex; align-items: center; gap: var(--s2); color: var(--ink); text-decoration: none;
                font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
header .brand .logo { display: block; flex: none; }
header .brand em { font-style: normal; color: var(--accent); }
header .brand .brand-cn { font-size: 12px; font-weight: 700; color: var(--ink-soft); border: 1.5px solid var(--line);
                          border-radius: 3px; padding: 0 4px; line-height: 18px; }
header .crumb { color: var(--ink-soft); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .crumb a { color: var(--ink); font-weight: 600; }
header .nav { margin-left: auto; color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
header .nav:hover, header .nav[aria-current] { color: var(--accent); }
header .user-nav { display: inline-flex; align-items: center; gap: var(--s2); font-size: 14px; white-space: nowrap; }
header .user-nav.push { margin-left: auto; }
header .user-nav .who { color: var(--ink-soft); }
header .user-nav .credits { font-weight: 600; }
header .user-nav .credits.low { color: var(--err); }
header .user-nav a { color: var(--ink); font-weight: 600; text-decoration: none; }
header .user-nav a:hover { color: var(--accent); }

/* ---------- 登录、用户管理 ---------- */
main.login { max-width: 420px; padding-top: var(--s6); }
main.users-page { max-width: 960px; }
.scroll-x { overflow-x: auto; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { padding: var(--s2); border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
table.users td input, table.users td select { min-width: 110px; }
table.users td.actions { white-space: nowrap; display: flex; gap: var(--s1); }
table.users tr.disabled td { color: var(--ink-soft); }

h1 .rename { font-size: 13px; color: var(--ink-soft); }
h1 .title-input { width: min(420px, 100%); font-size: 20px; font-weight: 700; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: var(--s4); margin-bottom: var(--s4); }
a.card { display: block; color: inherit; text-decoration: none; transition: transform .1s, box-shadow .1s; }
a.card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }

/* ---------- 按钮和表单 ---------- */
button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px;
                   border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--card); color: var(--ink);
                   font: inherit; font-size: 14px; font-weight: 600; line-height: 1.3; cursor: pointer; text-decoration: none;
                   white-space: nowrap; transition: transform .08s, box-shadow .08s; }
button:hover:not(:disabled), a.button:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
button:active:not(:disabled) { transform: none; box-shadow: none; }
button.primary, a.button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--err); border-color: var(--err); }
button.small { padding: 3px 10px; font-size: 13px; font-weight: 500; }
button.ghost { border-color: transparent; background: transparent; font-weight: 500; }
button:disabled { opacity: .45; cursor: default; }
label { display: block; margin: var(--s3) 0 var(--s1); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
input, select, textarea { width: 100%; padding: 7px 10px; border: 1.5px solid var(--line-soft); border-radius: var(--radius);
                          font: inherit; font-size: 14px; background: var(--card); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }
textarea { min-height: 64px; resize: vertical; line-height: 1.5; }
input[type=radio], input[type=checkbox] { width: auto; accent-color: var(--accent); margin: 0; }
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field > label { margin: 0; }
.choice { display: flex; gap: var(--s4); margin-top: var(--s3); }
.choice label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; color: var(--ink); cursor: pointer; }

/* ---------- 状态印章 ---------- */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border: 1.5px solid currentColor; border-radius: 4px;
         font-size: 12px; font-weight: 700; line-height: 1.5; color: var(--ink-soft); background: var(--muted-bg); white-space: nowrap; }
.badge.approved, .badge.done { color: var(--ok); background: var(--ok-bg); }
.badge.draft, .badge.characters_pending, .badge.storyboard_pending { color: var(--warn); background: var(--warn-bg); }
.badge.failed { color: var(--err); background: var(--err-bg); }
.badge.rendering { color: var(--accent); background: var(--accent-bg); }

/* ---------- 首页：作品书架 ---------- */
h1 .muted { font-size: 15px; font-weight: 500; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s5) var(--s4); }
.book { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); overflow: hidden; color: var(--ink); text-decoration: none; transition: transform .1s, box-shadow .1s; }
.book:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.book-cover { position: relative; aspect-ratio: 3 / 4; background: var(--muted-bg); border-bottom: 2px solid var(--line); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.book-flag { position: absolute; top: var(--s2); left: var(--s2); padding: 0 8px; background: var(--card); border: 1.5px solid var(--ink);
             border-radius: 4px; font-size: 12px; font-weight: 700; transform: rotate(-4deg); }
.book-info { padding: var(--s2) var(--s3) var(--s3); }
.book-info strong { display: block; font-size: 16px; margin-bottom: var(--s1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-new { flex-direction: column; gap: var(--s2); min-height: 280px; border: 2px dashed var(--ink-soft); background: transparent;
             color: var(--ink-soft); font-size: 16px; font-weight: 700; }
.shelf-new .plus { font-size: 56px; font-weight: 300; line-height: 1; }
.shelf-new:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); box-shadow: none; }

/* 没有作品时的分格海报：左边标语，右边四种画风的样图拼成一页漫画 */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s6); align-items: center; padding: var(--s5) 0; }
.hero-copy h1 { display: block; font-size: 48px; line-height: 1.15; letter-spacing: -.02em; margin-bottom: var(--s4); }
.hero-copy mark { background: linear-gradient(transparent 55%, var(--accent-bg) 55%); color: var(--accent); padding: 0 2px; }
.hero-copy p { color: var(--ink-soft); font-size: 16px; }
.hero-copy ol { counter-reset: step; list-style: none; padding: 0; margin: var(--s4) 0 var(--s5); }
.hero-copy li { counter-increment: step; display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0; font-weight: 600; }
.hero-copy li::before { content: counter(step); flex: 0 0 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--ink);
                        border-radius: 50%; background: var(--card); font-weight: 800; }
button.big { padding: 12px 28px; font-size: 17px; box-shadow: var(--shadow); }
.hero-art { position: relative; display: grid; grid-template-columns: 1.1fr 1fr; grid-template-rows: repeat(3, 1fr); gap: 10px;
            grid-template-areas: "a b" "a c" "d c"; height: 480px; transform: rotate(-1.5deg); }
.hero-art img { width: 100%; height: 100%; min-height: 0; object-fit: cover; border: 3px solid var(--ink); background: var(--card); }
.hero-art img:nth-child(1) { grid-area: a; } .hero-art img:nth-child(2) { grid-area: b; }
.hero-art img:nth-child(3) { grid-area: c; } .hero-art img:nth-child(4) { grid-area: d; }
.hero-sticker { position: absolute; right: -10px; top: -14px; padding: 4px 12px; background: var(--accent); color: var(--accent-ink);
                border: 2px solid var(--ink); border-radius: 4px; font-weight: 800; transform: rotate(6deg); box-shadow: var(--shadow-sm); }

/* 新建作品弹窗 */
.new-work-dialog { width: min(980px, 95vw); max-height: 92vh; }
.new-work { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s4) var(--s5); }
.new-work > div > label:first-child { margin-top: 0; }
.nw-preview .style-preview { position: sticky; top: 0; margin-top: 0; }
.nw-foot { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); padding-top: var(--s3); }
.style-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--s2); }
.style-tile { flex-direction: column; gap: 0; padding: 0; border: 2px solid var(--line-soft); overflow: hidden; font-size: 13px; }
.style-tile img, .style-tile .noimg { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--muted-bg); }
.style-tile .noimg { display: grid; place-items: center; color: var(--ink-soft); font-size: 12px; font-weight: 500; }
.style-tile span { width: 100%; padding: 3px 4px; overflow: hidden; text-overflow: ellipsis; }
.style-tile.on { border-color: var(--accent); box-shadow: 3px 3px 0 var(--accent); }
.style-tile.on span { background: var(--accent); color: var(--accent-ink); }

/* ---------- 作品页 ---------- */
.chapter-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s2);
               background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); }
.chapter-row a { font-weight: 700; color: var(--ink); text-decoration: none; }
.chapter-row a:hover { color: var(--accent); }
.chapter-row .err { flex: 1 1 0; min-width: 0; color: var(--err); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.work-head { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--s5); align-items: center; margin-bottom: var(--s2); }
.work-cover { aspect-ratio: 3 / 4; background: var(--muted-bg); border: 2px solid var(--line); border-radius: var(--radius);
              box-shadow: var(--shadow); overflow: hidden; transform: rotate(-2deg); }
.work-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.work-meta h1 { margin-bottom: var(--s2); }
.work-meta p { margin: var(--s3) 0 var(--s4); max-width: 720px; }
.book-blank { height: 100%; display: grid; place-items: center; font-size: 22px; font-weight: 800; color: var(--ink-soft);
              background: repeating-linear-gradient(-45deg, transparent 0 10px, var(--line-soft) 10px 11px); }
.book-status { position: absolute; top: var(--s2); left: var(--s2); }
.book-info .err { color: var(--err); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite { padding: var(--s5); text-align: center; border-style: dashed; box-shadow: none; }
.invite p { max-width: 460px; margin: 0 auto var(--s4); }
.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.cast-card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cast-card img, .cast-blank { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: var(--muted-bg);
                              border-bottom: 2px solid var(--line); }
.cast-blank { display: grid; place-items: center; color: var(--ink-soft); font-size: 13px; }
.cast-pic { position: relative; }
.cast-card img.cast-ref { position: absolute; right: var(--s2); bottom: var(--s2); width: 40px; height: 40px; aspect-ratio: 1;
                         object-fit: cover; border: 2px solid var(--ink); border-radius: 4px; box-shadow: var(--shadow-sm);
                         background: var(--card); }
/* 重画设定图中：盖在图上 */
.char-drawing { position: absolute; inset: 0; display: flex; flex-direction: column; gap: var(--s2); align-items: center;
                justify-content: center; background: color-mix(in srgb, var(--card) 82%, transparent); font-weight: 700; }
.char-drawing .ink-loader { width: 48px; height: 62px; }
/* 角色编辑弹窗 */
.char-edit { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s5); align-items: start; }
.char-sheet { position: relative; border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--muted-bg); }
.char-sheet img, .char-sheet .cast-blank { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
.char-body label:first-of-type { margin-top: var(--s2); }
.char-redraw { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); padding-top: var(--s3);
               border-top: 1px dashed var(--line-soft); }
.char-redraw button { align-self: flex-start; }
.char-versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s3); }
.char-version { border: 2px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; background: var(--card); font-size: 13px; }
.char-version.on { border-color: var(--ok); }
.char-version img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: var(--muted-bg); }
.char-version .row { padding: var(--s1) var(--s2); }
.char-version .row button { margin-left: auto; }
.cast-info { padding: var(--s2) var(--s3) var(--s3); }
.cast-info .row { margin-bottom: var(--s1); }
.new-chapter-dialog { width: min(760px, 95vw); max-height: 92vh; }
.sheet { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: var(--muted-bg); border-radius: 4px; }
.style-preview { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; margin: var(--s2) 0; background: var(--muted-bg); border-radius: 4px; }
.style-preview.empty { display: flex; align-items: center; justify-content: center; padding: var(--s3); text-align: center; font-size: 13px; }
details.settings > summary { list-style: none; cursor: pointer; font-size: 20px; font-weight: 800; margin: var(--s6) 0 var(--s3); }
details.settings > summary::-webkit-details-marker { display: none; }
details.settings > summary::after { content: " ▾"; color: var(--ink-soft); }
details.settings[open] > summary::after { content: " ▴"; }
details.settings .count { font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-left: var(--s2); }

/* ---------- 章节页：步骤条、进度、花费 ---------- */
.steps { display: flex; list-style: none; margin: var(--s2) 0 var(--s3); padding: 0; overflow-x: auto; }
.step { flex: 1 1 0; min-width: 68px; position: relative; padding-top: 22px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.step::before { content: ""; position: absolute; top: 8px; left: 0; right: 0; height: 2px; background: var(--line-soft); }
.step:first-child::before { left: 50%; }
.step:last-child::before { right: 50%; }
.step .dot { position: absolute; top: 2px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
             border: 2px solid var(--line-soft); background: var(--paper); z-index: 1; display: flex; align-items: center;
             justify-content: center; font-size: 9px; font-weight: 800; line-height: 1; }
.step.done { color: var(--ink); }
.step.done::before { background: var(--ink); }
.step.done .dot { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.step.done .dot::after { content: "✓"; }
.step.current { color: var(--accent); font-weight: 700; }
.step.current .dot { border-color: var(--accent); background: var(--accent); animation: breathe 1.4s ease-in-out infinite; }
.step.current.paused .dot { animation: none; background: var(--paper); }
.step.failed { color: var(--err); font-weight: 700; }
.step.failed .dot { border-color: var(--err); background: var(--err); color: #fff; }
.step.failed .dot::after { content: "!"; }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(215, 57, 43, .45); } 50% { box-shadow: 0 0 0 7px rgba(215, 57, 43, 0); } }
.bar { height: 10px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
#step-progress:not(:empty) { margin-bottom: var(--s4); }
.spend { margin-bottom: var(--s4); font-size: 13px; color: var(--ink-soft); }
.spend summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); align-items: baseline; }
.spend summary::-webkit-details-marker { display: none; }
.spend strong { color: var(--ink); font-size: 15px; }
.spend .more { color: var(--accent); font-weight: 600; margin-left: auto; }
.spend .more::after { content: " ▾"; }
.spend[open] .more::after { content: " ▴"; }
.spend table { width: 100%; margin-top: var(--s3); border-collapse: collapse; background: var(--card); border: 1.5px solid var(--ink); }
.spend th, .spend td { padding: 4px 8px; border-bottom: 1px solid var(--line-soft); text-align: right; }
.spend th { color: var(--ink); background: var(--muted-bg); }
.spend th:nth-child(-n+3), .spend td:nth-child(-n+3) { text-align: left; }

/* ---------- 分镜确认 ---------- */
.board { display: grid; grid-template-columns: 1fr; gap: var(--s4); align-items: start; }
.outline { display: none; position: sticky; top: var(--s4); max-height: calc(100vh - 180px); overflow: auto; padding: var(--s2); }
.outline a { display: flex; align-items: center; gap: var(--s2); padding: 6px 8px; border-radius: var(--radius);
             color: var(--ink); text-decoration: none; font-size: 13px; }
.outline a:hover { background: var(--muted-bg); }
.outline a.active { background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.outline-cover { display: grid; place-items: center; width: 32px; height: 49px; flex: none; border: 1.5px solid var(--ink);
                 background: var(--card); color: var(--ink-soft); font-size: 12px; font-weight: 700; }
@media (min-width: 1000px) {
  .board { grid-template-columns: 180px minmax(0, 1fr); }
  .outline { display: block; }
}
.layout-thumb { position: relative; flex: none; border: 1.5px solid var(--ink); background: var(--card); }
.layout-thumb i { position: absolute; display: grid; place-items: center; border: 1px solid var(--ink-soft); font-style: normal;
                  font-size: 9px; line-height: 1.2; color: var(--ink-soft); text-align: center; transition: background .15s; }
.layout-thumb i.on { background: var(--accent-bg); color: var(--accent); }
/* 每页一张卡：页头（页码、版式说明、版式缩略图选择、删除），下面左边版式图、右边各格 */
.page { padding: 0; overflow: hidden; scroll-margin-top: var(--s4); }
.page-head { display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s4);
             background: var(--muted-bg); border-bottom: 2px solid var(--line); }
.page-head .n { font-size: 18px; font-weight: 800; }
.page-head .danger { margin-left: auto; }
.layout-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.layout-pick button { padding: 3px; border-color: transparent; background: transparent; }
.layout-pick button.on { border-color: var(--accent); background: var(--accent-bg); }
.layout-pick button:hover:not(.on) { border-color: var(--line-soft); box-shadow: none; transform: none; }
.layout-pick .layout-thumb { border-width: 1px; }
.page-body { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--s4); padding: var(--s4); align-items: start; }
.page-map { position: sticky; top: var(--s4); display: flex; justify-content: center; }
.page-map .layout-thumb { border-width: 2px; box-shadow: var(--shadow-sm); }
.page-map .layout-thumb i { font-size: 18px; font-weight: 800; }
.page-panels { display: flex; flex-direction: column; gap: var(--s3); }
.cover-text { display: grid; gap: var(--s3); padding: var(--s4) var(--s4) 0; }
#board-cover > .panel { margin: var(--s4); }
/* 一格：编号 + 景别机位场景角色一行，画面描述，台词，表情 */
.panel { border: 1.5px solid var(--line-soft); border-radius: var(--radius); background: var(--card); padding: var(--s3); }
.panel:focus-within { border-color: var(--ink); }
.panel-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.panel-no { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--ink);
            color: var(--card); font-size: 14px; font-weight: 800; }
.panel-label { flex-basis: calc(100% - 40px); font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.panel-meta { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: 76px 76px minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
.panel-meta select { padding: 5px 6px; }
.panel-meta .pre { display: flex; align-items: stretch; margin: 0; min-width: 0; }
.panel-meta .pre span { display: grid; place-items: center; padding: 0 8px; border: 1.5px solid var(--line-soft); border-right: 0;
                        border-radius: var(--radius) 0 0 var(--radius); background: var(--muted-bg); font-size: 12px; white-space: nowrap; }
.panel-meta .pre input { min-width: 0; border-radius: 0 var(--radius) var(--radius) 0; padding: 5px 8px; }
.panel-action { min-height: 56px; }
.lines { margin-top: var(--s3); }
.lines-title { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 2px; }
.lines-title span { font-weight: 400; margin-left: var(--s1); }
.line { display: grid; grid-template-columns: 72px 110px 1fr 30px; gap: var(--s2); align-items: center; margin-top: var(--s1); }
.line.face { grid-template-columns: 110px 1fr 30px; }  /* 表情：角色、表情、删除 */
.line input, .line select { padding: 5px 8px; }
.line .ghost { padding: 3px 0; color: var(--ink-soft); }
.line select.kind { font-size: 13px; font-weight: 700; border-left-width: 4px; }
.line select.kind.say { border-left-color: var(--ink); }
.line select.kind.think { border-left-color: var(--accent); }
.line select.kind.narrate { border-left-color: var(--warn); }
.panel-add { display: flex; gap: var(--s2); margin-top: var(--s3); }
.sticky { position: sticky; bottom: var(--s3); z-index: 5; display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center;
          margin-top: var(--s4); padding: var(--s3) var(--s4); background: var(--card); border: 2px solid var(--ink);
          border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- 设定页 ---------- */
main.settings { max-width: 760px; }
.setting h2 { margin: 0; }
.setting-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); margin-bottom: var(--s3); }
.setting .field { margin-top: var(--s3); }
.setting .field label .muted { font-weight: 400; margin-left: var(--s1); }
.setting .field.changed label { color: var(--accent); }
.setting .field.changed label::after { content: " · 已改"; font-weight: 400; }
.model-meta { margin-top: var(--s2); font-size: 13px; display: grid; gap: 2px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); align-items: end; }
.notice { padding: var(--s2) var(--s3); margin-bottom: var(--s3); border: 1.5px solid currentColor; border-radius: var(--radius);
          font-size: 14px; background: var(--card); }
.notice.warn { background: var(--warn-bg); }
.notice.error { background: var(--err-bg); }

/* ---------- 阅读页 ---------- */
.reader-head { display: flex; gap: var(--s5); align-items: center; }
.reader-head h2 { margin: 0 0 var(--s2); font-size: 22px; }
.reader-head .row { margin-bottom: var(--s2); }
.reader-head .warn, .reader-head .muted { margin-top: var(--s1); }
.reader-cover { flex: 0 0 auto; width: 96px; border: 2px solid var(--ink); border-radius: 3px; box-shadow: var(--shadow-sm);
                transform: rotate(-2deg); cursor: pointer; }
/* 贴顶工具条：阅读 / 总览、页码、预览和发布，往下滚时一直在 */
.reader-bar { position: sticky; top: 0; z-index: 6; display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center;
              margin: 0 calc(-1 * var(--s2)) var(--s5); padding: var(--s2); background: var(--paper);
              border-bottom: 2px solid var(--ink); }
.reader-bar .actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-left: auto; }
a.button.small { padding: 3px 10px; font-size: 13px; font-weight: 500; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 14px; font-size: 13px; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button:hover:not(:disabled) { transform: none; box-shadow: none; }
/* 阅读：每页放大一栏往下读，左边页面导航 */
.reader { display: grid; grid-template-columns: 84px minmax(0, 720px); justify-content: center; gap: var(--s5); align-items: start; }
.reader-nav { position: sticky; top: 64px; display: flex; flex-direction: column; gap: var(--s2); max-height: calc(100vh - 80px);
              overflow-y: auto; padding: 2px 4px 4px 2px; scrollbar-width: thin; }
.reader-nav button { flex-direction: column; gap: 2px; padding: 3px; border: 2px solid var(--line-soft); font-size: 12px; }
.reader-nav button img { width: 100%; display: block; border-radius: 2px; }
.reader-nav button.on { border-color: var(--accent); box-shadow: 2px 2px 0 var(--accent); color: var(--accent); }
.pages.read { display: flex; flex-direction: column; gap: var(--s6); }
/* 总览：封面和各页横着排，排满一行就换行；每页至少 200 宽 */
.pages.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s5) var(--s4);
              align-items: start; }
.page-block { min-width: 0; }
button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }  /* 开关按下 */
.page-wrap { position: relative; width: 100%; }
.page-img { display: block; width: 100%; background: #fff; border: 2px solid var(--ink); box-shadow: var(--shadow); }
.page-cap { margin-top: var(--s2); text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.hit { position: absolute; cursor: pointer; border: 3px solid transparent; }
.hit:hover { border-color: var(--accent); background: rgba(215, 57, 43, .1); }
.hit.flagged { border-color: #f5b400; background: rgba(245, 180, 0, .14); }
.hit.missing { border: 3px dashed var(--err); }
.pages.busy .hit { pointer-events: none; }

/* ---------- 弹窗 ---------- */
dialog { border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card);
         color: var(--ink); padding: var(--s4) var(--s5); }
dialog::backdrop { background: rgba(26, 26, 26, .55); }
.panel-dialog { width: min(1040px, 95vw); max-height: 92vh; }
.publish-dialog { width: min(560px, 95vw); }
.dialog-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); padding-bottom: var(--s2);
               border-bottom: 2px solid var(--ink); }
.dialog-head h2 { flex: 1; margin: 0; font-size: 18px; }
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: var(--s4); align-items: start; }
.viewer .big img { display: block; width: 100%; max-height: 60vh; object-fit: contain; background: var(--muted-bg);
                   border: 1.5px solid var(--ink); }
.attempt-list { display: flex; flex-direction: column; gap: var(--s2); max-height: 60vh; overflow: auto; }
.attempt { display: flex; gap: var(--s2); align-items: center; padding: 6px; border: 1.5px solid var(--line-soft);
           border-radius: var(--radius); cursor: pointer; }
.attempt:hover { border-color: var(--ink); }
.attempt.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.attempt img, .attempt-empty { flex: none; width: 64px; height: 64px; object-fit: cover; background: var(--muted-bg); border-radius: 4px;
                               display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--ink-soft); }
.attempt-empty.tall { width: 100%; height: 240px; font-size: 14px; }
.attempt .info { min-width: 0; font-size: 12px; line-height: 1.4; }
.sau-log { max-height: 240px; overflow: auto; background: var(--muted-bg); padding: var(--s2); font-size: 12px;
           white-space: pre-wrap; overflow-wrap: anywhere; }
.warn pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; margin: 6px 0 0; }
.qr { display: block; width: 240px; height: 240px; margin: var(--s3) 0 var(--s2); image-rendering: pixelated;
      border: 2px solid var(--ink); background: #fff; }
dialog ul { padding-left: 20px; }

/* ---------- 提示条 ---------- */
.toasts { position: fixed; top: var(--s4); right: var(--s4); z-index: 100; display: flex; flex-direction: column; gap: var(--s2);
          width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4); background: var(--card);
         border: 2px solid var(--ink); border-left-width: 6px; border-radius: var(--radius); box-shadow: var(--shadow);
         font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; animation: slide-in .15s ease-out; }
.toast.error { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast.info { border-left-color: var(--accent); }
.toast button { flex: none; padding: 0 4px; border: none; background: none; font-size: 18px; line-height: 1; }
.toast button:hover { transform: none; box-shadow: none; color: var(--accent); }
@keyframes slide-in { from { transform: translateX(16px); opacity: 0; } }

/* ---------- 预览 ---------- */
.preview-dialog { width: auto; margin: auto; }  /* 屏幕正中 */
/* 手机屏幕大小 390×844，窗口放不下时按比例缩小；不显示滚动条 */
.dy-track { display: flex; height: min(844px, calc(100vh - 160px)); aspect-ratio: 390 / 844; margin: 0 auto;
            overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
            background: #000; cursor: grab; user-select: none; }
.dy-track::-webkit-scrollbar { display: none; }
.dy-track.dragging { scroll-snap-type: none; cursor: grabbing; }
.dy-slide { flex: 0 0 100%; scroll-snap-align: center; display: flex; align-items: center; }
.dy-slide img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.dy-count { text-align: center; margin-top: var(--s2); }

/* ---------- 章节页：生成中 ---------- */
.working { display: flex; gap: var(--s5); align-items: center; padding: var(--s5); }
.working h2 { margin: 0 0 var(--s3); font-size: 26px; }
.working p { margin: var(--s2) 0 0; }
/* 墨线动画：三格漫画轮流落墨 */
.ink-loader { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 5px;
              width: 72px; height: 92px; transform: rotate(-4deg); }
.ink-loader i { border: 2.5px solid var(--ink); border-radius: 3px; background: var(--card); animation: ink 1.8s infinite; }
.ink-loader i:first-child { grid-row: span 2; }
.ink-loader i:nth-child(2) { animation-delay: .6s; }
.ink-loader i:nth-child(3) { animation-delay: 1.2s; }
@keyframes ink { 0%, 100% { background: var(--card); } 30%, 55% { background: var(--ink); } }
@media (prefers-reduced-motion: reduce) { .ink-loader i { animation: none; } }
.live-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s5) var(--s4); }
.live-page { margin: 0; }
.live-page figcaption { text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-top: var(--s2); }
.live-sheet { position: relative; background: var(--card); border: 2px solid var(--line); border-radius: 3px; box-shadow: var(--shadow); }
.live-slot { position: absolute; padding: 3px; }
.live-slot img, .live-slot span { display: block; width: 100%; height: 100%; border-radius: 2px; }
.live-slot img { object-fit: cover; border: 1.5px solid var(--ink); animation: pop .4s ease-out; }
.live-slot span { border: 1.5px dashed var(--ink-soft); padding: 4px; overflow: hidden; color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
/* 刚画好的格子：从模糊、发灰变清晰 */
.live-slot img.reveal { animation: reveal 1.6s ease-out; }
@keyframes reveal { from { filter: blur(14px) grayscale(1) contrast(.7); opacity: .5; transform: scale(1.04); } }
/* 正在画的格子：铅笔草稿线来回扫 */
.live-slot span.sketching { display: grid; place-items: center; border-style: solid; border-color: var(--ink); color: var(--ink);
  font-size: 12px; font-weight: 700;
  background: repeating-linear-gradient(-35deg, transparent 0 9px, var(--line-soft) 9px 10px) 0 0 / 200% 200% var(--card);
  animation: sketch 2.4s linear infinite; }
@keyframes sketch { to { background-position: 100% 100%; } }
/* 排版：对白气泡一个个弹出来，排好的页淡入盖上去 */
.live-bubble { position: absolute; max-width: 70%; padding: 2px 6px; background: #fff; color: #1a1a1a; border: 1.5px solid #1a1a1a;
               border-radius: 10px; font-size: 10px; font-weight: 600; line-height: 1.35; overflow: hidden;
               display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
               animation: bubble .35s ease-out backwards; }
.live-bubble.at-0 { top: 8px; right: 8px; }
.live-bubble.at-1 { bottom: 8px; left: 8px; }
@keyframes bubble { from { opacity: 0; transform: scale(.4); } 70% { transform: scale(1.08); } }
.live-done { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fadein .8s ease-out backwards; }
@keyframes fadein { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .live-slot img.reveal, .live-slot span.sketching, .live-bubble, .live-done, .live-slot img { animation: none; }
}

/* ---------- 章节页：确认角色 ---------- */
.review-list { display: flex; flex-direction: column; gap: var(--s4); }
.review-card { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); background: var(--card); border: 2px solid var(--line);
               border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.review-img { display: block; padding: 0; border: 0; border-right: 2px solid var(--line); border-radius: 0; background: var(--muted-bg);
              cursor: zoom-in; }
.review-img:hover:not(:disabled) { transform: none; box-shadow: none; }
.review-img img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
div.review-img { display: grid; place-items: center; padding: var(--s4); aspect-ratio: 3 / 2; cursor: default; }
.review-body { padding: var(--s4); display: flex; flex-direction: column; }
.review-body h3 { font-size: 22px; margin: 0; }
.review-body textarea { flex: 1; }
.look-ref { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s2); }
.look-ref img { width: 44px; height: 44px; object-fit: cover; border: 1.5px solid var(--ink); border-radius: 4px; }
.look-ref .muted { min-width: 160px; }
.decide { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s3); }
.decide button { padding: 10px; font-size: 15px; border-width: 2px; }
.decide button.on { background: var(--ink); color: var(--paper); }
.decide button.on:first-child { background: var(--ok); border-color: var(--ok); color: #fff; }
.cast-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
.cast-mini .cast-card { box-shadow: var(--shadow-sm); }
.zoom-img { display: block; max-width: min(1100px, 90vw); max-height: 78vh; }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: var(--s5); padding-top: 0; }
  .hero-copy h1 { font-size: 36px; }
  .hero-art { height: 340px; }
}
@media (max-width: 800px) {
  .viewer { grid-template-columns: 1fr; }
  .attempt-list { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .new-work { grid-template-columns: 1fr; }
  .nw-preview .style-preview { position: static; width: min(260px, 100%); margin: 0 auto; }
  .panel-dialog, .publish-dialog, .new-work-dialog, .new-chapter-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0;
                                   border-radius: 0; border-width: 0; }
}
@media (max-width: 720px) {
  main { padding: var(--s4) var(--s3) var(--s6); }
  header { padding: var(--s2) var(--s3); }
  h1 { font-size: 24px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s3); }
  .shelf-new { min-height: 200px; }
  .style-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .working { flex-direction: column; align-items: flex-start; padding: var(--s4); }
  .live-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-card { grid-template-columns: 1fr; }
  .review-img { border-right: 0; border-bottom: 2px solid var(--line); }
  .char-edit { grid-template-columns: 1fr; }
  .work-head { grid-template-columns: 96px minmax(0, 1fr); gap: var(--s4); align-items: start; }
  .work-meta button.big { padding: 9px 18px; font-size: 15px; }
  .panel-meta { flex-basis: 100%; grid-template-columns: 1fr 1fr; }
  .page-body { grid-template-columns: 1fr; padding: var(--s3); }
  .page-map { display: none; }
  .line { grid-template-columns: 72px 1fr 30px; }  /* 类型、说话人、删除一行，台词单独占一行 */
  .line input.text { grid-column: 1 / -1; order: 1; }  /* 排到最后，删除按钮才留在第一行 */
  .reader-bar { position: static; }  /* 手机上按钮会折成好几行，贴顶太占地方 */
  .reader-bar .actions { margin-left: 0; }
  .reader { grid-template-columns: minmax(0, 1fr); }
  .reader-nav { display: none; }
  .reader-head { gap: var(--s3); align-items: flex-start; }
  .reader-cover { width: 64px; }
  .sticky .grow { flex-basis: 100%; }  /* 费用说明占一整行，按钮在下面 */
  .fields-2 { grid-template-columns: 1fr; }
}
