:root {
  --ink: #1d2b3a;
  --ink-2: #3c4a5a;
  --muted: #6d7682;
  --paper: #faf7f1;
  --paper-2: #f2ede3;
  --card: #ffffff;
  --line: #e3ddd1;
  --accent: #b5843a;
  --accent-2: #8f6527;
  --ok: #2f7d4f;
  --err: #b4412f;
  --radius: 10px;
  --serif: "EB Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 14px; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }
h2 { font-size: 26px; margin: 0 0 4px; }
h3 { font-size: 18px; margin: 26px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
a { color: var(--accent-2); }

/* top bar */
.topbar { height: 54px; display: flex; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 22px; color: var(--ink); text-decoration: none; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 18px; }
.project-title { flex: 1; font-family: var(--serif); font-size: 17px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--paper-2); color: var(--muted); }
.pill.paid { background: #e3f1e8; color: var(--ok); }

/* buttons & forms */
.btn { font: inherit; font-weight: 500; border-radius: 8px; padding: 9px 16px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:hover { background: #2a3b4e; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink-2); background: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.link { background: none; border: 0; color: var(--err); padding: 4px; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 12px; }
label output { float: right; font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=range]):not([type=color]), select, textarea { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 14px; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; }
textarea { resize: vertical; line-height: 1.45; font-family: var(--serif); font-size: 15px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(181,132,58,.35); border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); margin-top: 8px; }
input[type=color] { display: block; width: 100%; height: 36px; margin-top: 5px; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: #fff; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); }
label.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 10px; }
.span2 { grid-column: span 2; }
.row { display: flex; gap: 10px; }
.error { color: var(--err); }
.warn { background: #fdf3e2; border: 1px solid #efd9b0; color: #7a5518; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 12px 0; }

/* landing */
.landing { max-width: 1180px; margin: 0 auto; padding: 0 28px 80px; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; align-items: center; padding: 64px 0 40px; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; color: var(--accent-2); font-weight: 600; margin: 0 0 14px; }
.hero h1 { font-size: 58px; line-height: 1.02; margin: 0 0 20px; font-weight: 500; }
.lede { font-size: 16.5px; line-height: 1.6; color: var(--ink-2); margin: 0 0 28px; max-width: 560px; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 30px; border: 1.5px dashed #cbbfa8; border-radius: 14px; background: #fff; cursor: pointer; font-size: 15px; font-weight: 400; color: var(--ink); transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #fffaf1; }
.dropzone .dz-icon { color: var(--accent); }
.dropzone.busy { pointer-events: none; opacity: .7; }
.resume { margin-top: 16px; font-size: 13.5px; }
.hero-art { display: flex; justify-content: center; }
.book-spread { display: flex; filter: drop-shadow(0 20px 40px rgba(29,43,58,.18)); transform: rotate(-2deg); }
.book-spread .page { width: 210px; height: 315px; background: #fffdf8; padding: 34px 26px; position: relative; font-family: var(--serif); }
.book-spread .left { border-right: 1px solid #eee5d5; border-radius: 4px 0 0 4px; }
.book-spread .right { border-radius: 0 4px 4px 0; }
.book-spread .rh { text-align: center; font-size: 8px; letter-spacing: .2em; text-transform: uppercase; color: #777; margin-bottom: 16px; }
.book-spread .folio { position: absolute; top: 34px; left: 26px; font-size: 8px; color: #777; }
.book-spread .lines i { display: block; height: 4px; background: #d9d2c4; margin: 0 0 8.5px; border-radius: 2px; }
.book-spread .lines i:nth-child(5n) { width: 70%; }
.book-spread .ch-l { text-align: center; font-size: 8px; letter-spacing: .3em; margin-top: 60px; color: #555; }
.book-spread .ch-t { text-align: center; font-size: 20px; font-style: italic; margin: 6px 0 2px; }
.book-spread .orn { text-align: center; font-size: 12px; margin-bottom: 20px; }
.book-spread .first { position: relative; padding-left: 26px; }
.book-spread .first b { position: absolute; left: 0; top: -6px; font-size: 34px; font-weight: 400; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; padding: 30px 0; border-top: 1px solid var(--line); }
.how .num { font-family: var(--serif); font-size: 15px; width: 28px; height: 28px; border: 1px solid var(--accent); color: var(--accent-2); border-radius: 50%; display: inline-grid; place-items: center; }
.how h3 { border: 0; padding: 0; margin: 10px 0 6px; font-size: 21px; }
.how p { color: var(--ink-2); line-height: 1.55; margin: 0; }
.platforms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding-top: 18px; }
.platforms .pf { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.platforms .pf strong { font-family: var(--serif); font-size: 17px; font-weight: 500; display: block; }
.platforms .pf span { font-size: 12px; color: var(--muted); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; background: #e3f1e8; color: var(--ok); margin-left: 6px; vertical-align: 2px; }

/* workspace */
.workspace { display: grid; grid-template-columns: 76px 400px 1fr; height: calc(100vh - 54px); }
.rail { border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 10px 0; gap: 2px; background: var(--paper); }
.rail button { background: none; border: 0; font: inherit; font-size: 11.5px; color: var(--muted); padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; border-left: 2px solid transparent; }
.rail button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rail button:hover { color: var(--ink); }
.rail button.active { color: var(--ink); border-left-color: var(--accent); background: var(--paper-2); }
.panel { overflow-y: auto; padding: 22px 22px 60px; border-right: 1px solid var(--line); background: var(--paper); }
.preview { display: flex; flex-direction: column; min-width: 0; background: #e8e6e1; }
.ptools { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ptools select { width: auto; margin: 0; padding: 6px 8px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-size: 12.5px; border: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: #fff; }
.tcheck { display: flex; align-items: center; gap: 5px; margin: 0; font-weight: 400; font-size: 12.5px; }
.zoom { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; }
.zoom button { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.zoom span { min-width: 38px; text-align: center; }
.pcount { margin-left: auto; font-size: 12.5px; color: var(--ink-2); }
.pframe { flex: 1; position: relative; }
.pframe iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #e8e6e1; }
.loading { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 2; background: var(--ink); color: #fff; padding: 7px 14px 7px 10px; border-radius: 99px; font-size: 12.5px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* structure */
.stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin: 10px 0 14px; }
.stats b { color: var(--ink); font-weight: 600; }
.sections { list-style: none; margin: 0; padding: 0; }
.sections li { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; margin-bottom: 7px; }
.sections li.part { background: var(--paper-2); }
.sections .srow { display: flex; gap: 7px; align-items: center; }
.sections .sno { font-family: var(--serif); color: var(--muted); width: 22px; text-align: right; flex: none; font-size: 13px; }
.sections input { margin: 0 !important; padding: 5px 8px !important; font-size: 13.5px !important; }
.sections select { width: 112px !important; flex: none; margin: 0 !important; padding: 5px 6px !important; font-size: 12.5px !important; }
.sections .smeta { display: flex; align-items: center; gap: 4px; margin: 6px 0 0 29px; font-size: 11.5px; color: var(--muted); }
.sections .smeta .grow { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--serif); font-size: 12.5px; font-style: italic; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 3px 5px; border-radius: 5px; font-size: 12px; }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--err); }

/* design */
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.theme { border: 1.5px solid var(--line); border-radius: 9px; padding: 12px 12px 10px; cursor: pointer; background: #fff; text-align: left; font: inherit; }
.theme:hover { border-color: #cbbfa8; }
.theme.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181,132,58,.15); }
.theme .tl { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.theme .tt { font-size: 21px; margin: 3px 0 4px; line-height: 1.1; }
.theme .td { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.geom { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.geom b { font-weight: 600; }
.geom .adj { color: #7a5518; }

/* cover */
.art-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }

/* publish */
.pubs { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 18px; }
.pub { display: flex; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; cursor: pointer; margin: 0; font-weight: 400; }
.pub input { accent-color: var(--accent); width: 16px; height: 16px; margin-top: 2px; flex: none; }
.pub strong { font-family: var(--serif); font-size: 16.5px; font-weight: 500; }
.pub .pf { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pub .api { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; line-height: 1.4; }
.paybox { background: var(--ink); color: #fff; border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.paybox .price { font-family: var(--serif); font-size: 34px; }
.paybox p { color: #c9d1da; margin: 4px 0 14px; font-size: 13px; line-height: 1.5; }
.paybox.paid { background: #e3f1e8; color: var(--ok); }
.paybox.paid p { color: #3e6b50; margin-bottom: 0; }
.demo-note { font-size: 11.5px; color: #c9d1da; margin-top: 8px; }
.progress .bar { height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; margin: 14px 0 8px; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.progress .log { font-size: 12px; color: var(--muted); max-height: 110px; overflow: auto; }
.downloads { list-style: none; padding: 0; margin: 14px 0; }
.downloads li a { display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; }
.downloads li a:hover { border-color: var(--accent); }
.downloads li.all a { background: var(--paper-2); font-weight: 600; }
.downloads .sz { color: var(--muted); font-size: 12px; }
.lulubox { border-top: 1px solid var(--line); margin-top: 10px; }
.lulu-out { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap; max-height: 240px; overflow: auto; }
.reimport { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* editor */
.editor { width: min(820px, 94vw); height: 86vh; border: 0; border-radius: 14px; padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.editor::backdrop { background: rgba(29,43,58,.45); }
.editor[open] { display: flex; flex-direction: column; }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.ed-head strong { font-family: var(--serif); font-size: 18px; font-weight: 500; flex: 1; }
.ed-tools { display: flex; gap: 4px; }
.ed-tools button { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.ed-body { flex: 1; overflow: auto; padding: 30px 60px; font-family: var(--serif); font-size: 18px; line-height: 1.6; outline: none; }
.ed-body p { margin: 0; text-indent: 1.5em; }
.ed-body hr { border: 0; text-align: center; margin: 14px 0; }
.ed-body hr::after { content: "⁂"; color: var(--muted); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--err); }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 64px 340px 1fr; }
  .hero { grid-template-columns: 1fr; } .hero-art { display: none; }
  .platforms { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .rail { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview { height: 80vh; }
  .how { grid-template-columns: 1fr; }
  .hero h1 { font-size: 40px; }
  .landing { padding: 0 16px 60px; }
}
