:root {
  --bg: #faf6ee;
  --card: #ffffff;
  --ink: #2b2418;
  --muted: #7a6f5d;
  --line: #e8dfcd;
  --accent: #c2701a;
  --accent-ink: #ffffff;
  --ok: #2f8a4c;
  --warn: #b7791f;
  --err: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 6px 20px rgba(60, 40, 10, .06);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.top .brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--ink); }
header.top .meta { color: var(--muted); font-size: 13px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } main { padding: 16px; } }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); background: #fffdf8;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f0c48a; border-color: var(--accent); }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.small, .btn.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1ead9; color: var(--muted); }
.chip.done { background: #e3f3e8; color: var(--ok); }
.chip.running, .chip.queued { background: #fdf0d9; color: var(--warn); }
.chip.error { background: #fbe4e1; color: var(--err); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); font-size: 13px; white-space: pre-wrap; }
.thumb { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f3ecdc; position: relative; }
.thumb img { display: block; width: 100%; height: auto; }
.thumb.selectable { cursor: pointer; }
.hero-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 16px; align-items: start; }
.hero-row #heroes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hero-edit { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fffaf0; }
.hero-edit textarea { width: 100%; margin-top: 8px; }
@media (max-width: 760px) { .hero-row { grid-template-columns: 1fr; } }
.thumb.selected { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb .badge { position: absolute; top: 8px; left: 8px; }
.placeholder { aspect-ratio: 2/1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.placeholder.square { aspect-ratio: 1/1; }
.placeholder.portrait { aspect-ratio: 3/4; }
.spinner { width: 18px; height: 18px; border: 2px solid #ead9b8; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; background: #f1ead9; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.spread-edit { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.spread-edit:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-decoration: none; color: var(--ink); }
.list-item:hover { border-color: var(--accent); }
.list-item img, .list-item .ph { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #f1ead9; flex: none; }
.notice { padding: 10px 14px; border-radius: 10px; background: #fdf0d9; color: #7a4b0b; font-size: 13px; margin-bottom: 14px; }
.extra-hero { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.book { max-width: 980px; margin: 0 auto; }
.book img { width: 100%; border-radius: 6px; box-shadow: var(--shadow); display: block; }
.book .cover { max-width: 520px; margin: 0 auto; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 16px 0; }
input[type=file] { max-width: 100%; font-size: 13px; }

.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 760px) { .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pick { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fffdf8; transition: border-color .15s, box-shadow .15s; position: relative; }
.pick:hover { border-color: var(--accent); }
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 2px #f0c48a; background: #fff7ea; }
.pick .emoji { font-size: 28px; line-height: 1; }
.pick .t { font-weight: 600; margin: 6px 0 2px; }
.pick .d { font-size: 12px; color: var(--muted); }
.pick img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; display: block; }
.pick.comp { text-align: center; padding: 10px; }
.pick.comp .emoji { font-size: 40px; padding: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
h2 { flex-wrap: wrap; } h2 .muted { font-weight: 400; }
.q { display: flex; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.qn { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.qb { flex: 1; min-width: 0; }
.qb h3 { font-size: 16px; margin: 4px 0 10px; }
.fb { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fffdf8; }
.stage { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0 18px; }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.storytext { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 12px; white-space: pre-wrap; font-size: 16px; line-height: 1.6; }

body.client .op-only { display: none !important; }
body.client .client-only { display: inline !important; }
body.client #layout { grid-template-columns: 1fr !important; max-width: 760px; margin: 0 auto; }

details.drop { border: 1px solid var(--line); border-radius: 12px; background: #fffdf8; padding: 0 14px; }
details.drop > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; cursor: pointer; font-weight: 600; color: var(--ink); font-size: 15px; }
details.drop > summary::-webkit-details-marker { display: none; }
details.drop[open] { padding-bottom: 14px; }
details.drop[open] > summary { border-bottom: 1px solid var(--line); }
.dlg-wrap { position: fixed; inset: 0; background: rgba(30, 20, 5, .35); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.dlg { background: #fff; border-radius: 14px; padding: 20px; width: min(520px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.dlg-t { font-weight: 600; margin-bottom: 10px; }
