* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: #fafafa;
    color: #18181b;
}
button, input { font: inherit; }
button { cursor: pointer; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 1px solid #e4e4e7;
}
.topbar-inner, .wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.topbar-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 20px; margin: 0; }
.logo {
    width: 40px; height: 40px; border-radius: 8px;
    background: #4f46e5; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.who { color: #71717a; font-size: 14px; }
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid #d4d4d8; background: #fff; color: #3f3f46;
    border-radius: 8px; padding: 8px 14px; text-decoration: none;
}
.btn:hover { background: #fafafa; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-danger { background: #fef2f2; border-color: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; }
.btn-soft { background: #eef2ff; border-color: #e0e7ff; color: #4f46e5; }
.btn-lg { padding: 12px 20px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.wrap { padding-top: 28px; padding-bottom: 48px; }
.poster {
    display: grid;
    grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 0.9fr);
    gap: 32px;
    align-items: center;
    min-height: calc(100vh - 140px);
}
.poster-art { width: 100%; height: auto; max-height: calc(100vh - 160px); }
.poster-copy h2 { font-size: clamp(32px, 4vw, 56px); line-height: 1.05; margin: 0 0 12px; letter-spacing: -0.03em; }
.eyebrow { margin: 0 0 8px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #4f46e5; font-size: 13px; }
.lede { font-size: 18px; max-width: 36ch; }
.hint { color: #71717a; font-size: 14px; margin-top: 0; }
.page-list {
    display: flex; flex-wrap: wrap; gap: 16px;
    background: #f4f4f5; border-radius: 12px; min-height: 300px; padding: 16px;
}
.page-list.empty { display: block; }
.empty-msg, #emptyList { color: #71717a; text-align: center; padding: 80px 16px; margin: 0; }
.start-wrap { text-align: center; margin-top: 24px; }
.card {
    position: relative; width: 144px; background: #fff; border: 1px solid #e4e4e7;
    border-radius: 8px; padding: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card.dragging { opacity: 0.45; }
.thumb {
    width: 128px; height: 160px; background: #fafafa; border-radius: 4px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.thumb img { max-width: 100%; max-height: 100%; }
.card-tools {
    position: absolute; top: 8px; right: 8px; display: none; flex-direction: column; gap: 4px;
}
.card:hover .card-tools { display: flex; }
.card-tools button, .icon-btn {
    border: 0; background: rgba(255,255,255,.92); border-radius: 6px; padding: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.page-no {
    position: absolute; left: 8px; bottom: 8px;
    background: rgba(0,0,0,.5); color: #fff; font-size: 12px;
    border-radius: 4px; padding: 1px 6px;
}
.toast {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    background: #18181b; color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 80;
}
.toast.error { background: #b91c1c; }
.modal {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden], [hidden] { display: none !important; }
.dialog { background: #fff; border-radius: 16px; width: 100%; max-width: 440px; padding: 0 0 16px; }
.dialog-head, .dialog form, .dialog > p { padding: 16px 20px 0; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f4f4f5; padding-bottom: 12px; }
.dialog-head h3 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 0; }
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=password] {
    width: 100%; border: 1px solid #d4d4d8; border-radius: 8px; padding: 8px 10px;
}
.form-error { color: #dc2626; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check small { display: block; color: #71717a; }
.note { background: #eef2ff; color: #4338ca; border: 1px solid #e0e7ff; border-radius: 6px; padding: 8px; font-size: 12px; }
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f4f4f5; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.lede { color: #71717a; }
.preview { background: rgba(0,0,0,.9); display: block; }
.preview-bar {
    position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; align-items: center;
    background: rgba(255,255,255,.12); padding: 8px; border-radius: 16px; z-index: 2;
}
.preview-bar span { color: #fff; width: 48px; text-align: center; font-size: 14px; }
.icon-btn.light { background: transparent; color: #fff; box-shadow: none; }
.nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%); left: 16px;
    width: 56px; height: 56px; border-radius: 50%; border: 0; color: #fff; font-size: 32px;
    background: rgba(255,255,255,.12);
}
.nav-btn.next { left: auto; right: 16px; }
.preview-stage { height: 100%; overflow: auto; text-align: center; padding: 80px 16px; }
#previewCanvas { max-width: none; box-shadow: 0 10px 40px rgba(0,0,0,.4); vertical-align: middle; background: #fff; }
@media (max-width: 720px) {
    .topbar-inner { height: auto; padding-top: 10px; padding-bottom: 10px; align-items: flex-start; flex-direction: column; }
    .poster { grid-template-columns: 1fr; min-height: 0; }
    .poster-art { max-height: 360px; }
}
