:root {
  --bg: #121317; --panel: #1c1e24; --panel2: #252831; --line: #2f323c; --text: #eceef3; --muted: #9aa0ad;
  --accent: #5ab8ff; --accent-ink: #04121f; --warn: #ff6b81; --ok: #4fd18b; --amber: #ffc861;
  --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 760px; margin: 0 auto; padding: calc(var(--safe-t) + 8px) 14px calc(var(--safe-b) + 32px); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 6px 0 2px; }
h2 { font-size: 16px; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.top .back { font-size: 15px; padding: 10px 8px 10px 0; }

button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 600; min-height: 44px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.danger { background: transparent; color: var(--warn); border-color: #5a2a33; }
.ghost { background: transparent; }
.block { width: 100%; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.chip.generating { color: var(--amber); } .chip.generated, .chip.picked { color: var(--accent); }
.chip.packed { color: var(--warn); } .chip.submitted { color: var(--ok); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 0; }
.card.link { display: block; color: var(--text); }
.card h3 { margin: 6px 0 8px; font-size: 16px; line-height: 1.4; }
.bar { height: 6px; background: var(--panel2); border-radius: 9px; overflow: hidden; margin: 8px 0 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.notice { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.notice time { color: var(--muted); margin-right: 6px; }
.banner { background: #1d2a38; border: 1px solid #2c4a66; border-radius: 14px; padding: 12px 14px; margin: 10px 0; font-size: 14px; }
.banner.warn { background: #3a1e25; border-color: #6b2c3a; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; }
input[type=text] { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; min-height: 44px; }
.copy { background: var(--panel2); border-radius: 12px; padding: 10px 12px; margin: 6px 0; }
.copy .lab { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.copy .lab button { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 9px; }
.copy .val { white-space: pre-wrap; word-break: break-word; font-size: 14px; margin-top: 4px; }
.copy .val.clip { max-height: 7.5em; overflow: hidden; }
.files { display: grid; gap: 8px; }
.cover { width: 100%; border-radius: 12px; display: block; }
details summary { cursor: pointer; padding: 8px 0; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%) translateY(20px);
  background: #000d; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; z-index: 50; }
#toast.on { opacity: 1; transform: translateX(-50%); }

/* 選別 */
.sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); margin: 0 -14px; padding: calc(var(--safe-t) + 4px) 14px 8px; border-bottom: 1px solid var(--line); }
.scene { padding: 12px 0 4px; border-bottom: 1px solid var(--line); content-visibility: auto; contain-intrinsic-size: auto 1400px; }
.scene .hd { font-size: 13px; color: var(--muted); }
.scene .desc { font-size: 14px; margin: 2px 0 6px; }
.heat { font-weight: 700; }
.heat.h1 { color: var(--amber); } .heat.h2, .heat.h3 { color: var(--warn); }
.slot { margin: 10px 0; }
.slot .line { font-size: 13px; color: var(--muted); margin-bottom: 4px; min-height: 1em; }
.cands { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.cand { position: relative; border-radius: 10px; overflow: hidden; border: 3px solid transparent; background: var(--panel2); aspect-ratio: 832 / 1216; padding: 0; min-height: 0; }
.cand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand.sel { border-color: var(--accent); }
.cand.dup img { opacity: .35; }
.cand .tag { position: absolute; left: 6px; top: 6px; font-size: 11px; background: #000b; padding: 1px 6px; border-radius: 6px; font-weight: 600; }
.cand .zoom { position: absolute; right: 4px; bottom: 4px; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 10px; background: #000a; border: 0; font-size: 18px; }
.cand .check { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 800; display: none; align-items: center; justify-content: center; }
.cand.sel .check { display: flex; }
.slot .acts { display: flex; gap: 6px; margin-top: 6px; }
.slot .acts button { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.slot .acts .on { background: var(--panel); border-color: var(--muted); }
.slot .acts .need { color: var(--warn); border-color: #6b2c3a; }
.slot .acts .done { color: var(--ok); }

/* 全画面（拡大・モザイク） */
.full { position: fixed; inset: 0; background: #000; z-index: 20; display: flex; flex-direction: column; }
.full .hd, .full .ft { padding: calc(var(--safe-t) + 6px) 12px 8px; display: flex; gap: 8px; align-items: center; background: #0d0e11; }
.full .ft { padding: 8px 12px calc(var(--safe-b) + 10px); flex-wrap: wrap; }
.full .ft .grow button { width: 100%; }
.stage { flex: 1; overflow: auto; display: flex; min-height: 0; -webkit-overflow-scrolling: touch; }
.stage img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.stage canvas { display: block; margin: auto; flex: none; touch-action: none; }
.stage.pan canvas { touch-action: pan-x pan-y; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 40px; padding: 8px 12px; background: var(--panel2); font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.tools { display: flex; gap: 8px; padding: 8px 12px; background: #0d0e11; overflow-x: auto; }
.tools button { min-height: 40px; padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.tools button.on { background: var(--accent); color: var(--accent-ink); }
.login { padding-top: 16vh; display: grid; gap: 14px; justify-items: center; }
.login img { width: 72px; height: 72px; border-radius: 18px; }
.login .block, .login input { width: 100%; max-width: 360px; }
.err { color: var(--warn); }
textarea { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; resize: vertical; }
.opts { display: grid; gap: 8px; margin-bottom: 16px; }
.opt { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; }
.opt input { width: 20px; height: 20px; accent-color: var(--accent); }
