:root {
  color-scheme: light dark;
  --paper: #f7f1e4;
  --paper-2: #efe6d3;
  --card: #fffdf8;
  --ink: #1d2a29;
  --muted: #5f6b68;
  --line: #d9cfba;
  --teal: #0f4f4b;
  --teal-2: #0b3936;
  --gold: #d99a26;
  --danger: #a93226;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141c1b;
    --paper-2: #1b2524;
    --card: #1e2a29;
    --ink: #f1ebdd;
    --muted: #a7b2ae;
    --line: #33423f;
    --teal: #57c4b6;
    --teal-2: #3aa596;
    --gold: #e8b04a;
    --danger: #ff9c8f;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; font-weight: 600; }
a { color: var(--teal); }
img { max-width: 100%; }
code { font: 0.9em ui-monospace, Consolas, monospace; background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
pre { font: 13.5px/1.5 ui-monospace, Consolas, monospace; background: var(--paper-2); border: 1px solid var(--line); padding: 14px; border-radius: 10px; overflow-x: auto; }
.wrap { width: min(1120px, 100%); margin: 0 auto; padding: 0 20px; }
.narrow { width: min(460px, 100%); padding: 20px; }
.muted { color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.warn { color: var(--danger); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.center-page { min-height: 100vh; display: grid; place-items: center; text-align: center; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; flex-wrap: wrap; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--ink); }
.brand { font: 700 22px var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--gold); }
.brand.small { font-size: 17px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: 600 15px var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--teal); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .linklike:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--paper); }
.btn.primary:hover { background: var(--teal-2); }
.btn.ghost { background: transparent; }
.btn.large { padding: 14px 24px; font-size: 17px; border-radius: 12px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1503; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 6px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.danger { color: var(--danger); }
.linklike { background: none; border: 0; padding: 0; color: var(--teal); font: inherit; text-decoration: underline; cursor: pointer; }

input:not([type="checkbox"]):not([type="color"]):not([type="file"]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; font-size: 14.5px;
}
input[type="number"] { width: 76px; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; padding-top: 34px; padding-bottom: 58px; }
.hero h1 { font-size: clamp(38px, 6vw, 66px); margin: 0 0 16px; letter-spacing: -.02em; }
.hero h1 em { color: var(--gold); font-style: italic; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 24px; max-width: 34em; }
.drop { border: 2px dashed var(--line); border-radius: 16px; background: var(--card); padding: 26px; text-align: center; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--gold); background: var(--paper-2); }
#drop-idle { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#drop-idle[hidden], #drop-busy[hidden] { display: none; }
#drop-busy { display: grid; gap: 12px; justify-items: center; }
.progress { width: 100%; height: 10px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .15s; }

.hero-art { display: flex; justify-content: center; perspective: 1500px; }
.art-book { position: relative; width: min(440px, 100%); aspect-ratio: 1.42; display: flex; transform: rotateX(16deg) rotateZ(-5deg); transform-style: preserve-3d; filter: drop-shadow(0 28px 34px rgba(0,0,0,.28)); }
.art-page { flex: 1; background: #fffdf6; padding: 8% 6%; display: flex; flex-direction: column; gap: 7%; }
.art-left { border-radius: 8px 0 0 8px; background: linear-gradient(to left, #e7dfcb, #fffdf6 16%); }
.art-right { border-radius: 0 8px 8px 0; background: linear-gradient(to right, #e7dfcb, #fffdf6 16%); }
.art-page i { display: block; height: 7px; background: #c9c0ac; border-radius: 3px; }
.art-page i:nth-child(2) { width: 82%; }
.art-page b { display: block; flex: 1; background: #0f4f4b; border-radius: 4px; }
.art-page u { display: block; flex: 1; background: #d99a26; border-radius: 50% 50% 4px 4px; }
.art-turn { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; background: linear-gradient(to right, #d7ceb7, #fffdf6 30%, #efe7d2); transform-origin: left center; border-radius: 0 8px 8px 0; animation: art-flip 4.6s cubic-bezier(.45,.05,.55,.95) infinite; backface-visibility: visible; }
@keyframes art-flip { 0%, 18% { transform: rotateY(-4deg); } 58%, 100% { transform: rotateY(-176deg); } }

.home section h2 { font-size: clamp(26px, 4vw, 38px); margin: 0 0 12px; }
.explain, .demo, .steps-section, .uses, .faq { padding-bottom: 60px; }
.explain > p { max-width: 46em; color: var(--muted); font-size: 17px; margin: 0 0 20px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compare > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.compare > .good { border: 2px solid var(--teal); }
.compare h3 { margin: 0 0 8px; font-size: 21px; }
.compare ul { margin: 0; padding-left: 20px; color: var(--muted); }
.compare li { margin-bottom: 5px; }
.effect-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.pill { padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.pill.is-on { background: var(--teal); border-color: var(--teal); color: var(--paper); }
.pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.demo-frame { display: block; width: 100%; height: min(72vh, 640px); border: 0; border-radius: 14px; background: #20302f; box-shadow: 0 18px 44px rgba(0,0,0,.22); }
.use-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px 26px; }
.use-grid h3 { margin: 0 0 4px; font-size: 20px; }
.use-grid p { margin: 0; color: var(--muted); }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; max-width: 780px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { color: var(--muted); margin: 8px 0 0; }
.cta { background: var(--teal); color: var(--paper); text-align: center; padding: 54px 20px; margin-bottom: 28px; }
.cta h2 { margin: 0 0 8px; }
.cta p { margin: 0 0 18px; }
.cta .cta-fine { margin: 14px 0 0; }
.cta .cta-fine a { color: inherit; }
@media (prefers-color-scheme: dark) { .cta { color: #10201e; } }
@media (max-width: 700px) { .compare { grid-template-columns: 1fr; } }

/* ---------- Start page ---------- */
.start-main { max-width: 680px; padding-top: 18px; padding-bottom: 50px; }
.start-main h1 { font-size: clamp(30px, 5vw, 42px); margin: 0 0 8px; }
.start-main .drop { padding: 40px 26px; }
.url-form { margin-top: 18px; }
.url-form label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.row.nowrap { flex-wrap: nowrap; }

/* ---------- Plans ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; margin: 16px 0 24px; max-width: 760px; }
.plan { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.plan h2 { margin: 0 0 4px; font-size: 24px; }
.plan-price { font: 700 34px var(--serif); margin: 0; }
.plan-price small { font: 400 15px var(--sans); color: var(--muted); }
.plan-year { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.plan-year b { color: var(--teal); }
.plan.featured { border: 2px solid var(--teal); }
.plan-actions .btn { width: 100%; }
.status-banner { background: var(--paper-2); border: 1px solid var(--gold); padding: 10px 14px; border-radius: 10px; margin: 8px 0; font-size: 14.5px; }
.plan ul { margin: 0 0 14px; padding-left: 18px; color: var(--muted); font-size: 14.5px; flex: 1; }
.plan li { margin-bottom: 4px; }
.plan-actions { display: grid; gap: 8px; }
.plan-actions p { margin: 0; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.steps span { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: var(--paper); font-weight: 700; }
.steps h3 { margin: 10px 0 4px; font-size: 22px; }
.steps p { margin: 0; color: var(--muted); }
.features { padding-bottom: 60px; }
.features h2 { font-size: clamp(26px, 4vw, 38px); margin: 0 0 22px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.feature-grid article { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.feature-grid h3 { margin: 0 0 6px; font-size: 20px; }
.feature-grid p { margin: 0; color: var(--muted); font-size: 15px; }
.footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding-top: 18px; padding-bottom: 28px; border-top: 1px solid var(--line); }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 26px; padding-top: 12px; }
  .hero-art { order: -1; }
  .art-book { width: min(280px, 78%); }
  .steps { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .art-turn { animation: none; transform: rotateY(-30deg); } }

/* ---------- Dashboard ---------- */
.auth-card { width: min(420px, 100%); margin: 8px auto 34px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.auth-card h1 { margin: 0 0 12px; font-size: 26px; }
.auth-card label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dash-head h1 { font-size: 30px; margin: 10px 0; }
.notice { background: var(--paper-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; font-size: 14.5px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin: 14px 0 32px; }
.book-card { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.book-cover { flex: none; width: 96px; }
.book-cover img { width: 100%; display: block; border-radius: 3px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.book-meta { min-width: 0; flex: 1; }
.book-meta h3 { margin: 0 0 3px; font-size: 18px; overflow-wrap: anywhere; }
.book-meta p { margin: 0 0 6px; font-size: 13.5px; }
.tag { display: inline-block; font-size: 12px !important; padding: 1px 8px; border-radius: 99px; background: var(--paper-2); margin-right: 4px !important; }
.book-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.shelf-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 14px; }
#shelf-title { max-width: 280px; }
.dash-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.dash-tools input { max-width: 320px; }
.usage { font-size: 14px; color: var(--muted); }
.lead-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lead-table th, .lead-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.trash-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
#account-tools { padding-bottom: 40px; }
.stats-dialog { width: min(620px, calc(100vw - 24px)); background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stats-dialog::backdrop { background: rgba(0,0,0,.5); }
.stats-dialog form { float: right; }
.stats-dialog h2 { margin: 0 0 12px; }
.stats-dialog h3 { margin: 18px 0 6px; font-size: 18px; }
.stat-tiles { display: flex; gap: 12px; }
.stat-tiles div { flex: 1; background: var(--paper-2); padding: 12px; border-radius: 10px; }
.stat-tiles b { display: block; font: 700 30px var(--serif); }
.stat-tiles span { color: var(--muted); font-size: 13px; }
.stat-bars > div { display: grid; grid-template-columns: 30px 1fr 34px; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 3px; }
.stat-track { background: var(--paper-2); border-radius: 4px; height: 11px; overflow: hidden; }
.stat-track i { display: block; height: 100%; background: var(--teal); }
.stat-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.stat-list li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }

/* ---------- Shelf ---------- */
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 26px 20px; padding: 16px 0 50px; }
.shelf-card { display: grid; gap: 6px; text-decoration: none; color: var(--ink); align-content: start; }
.shelf-card img, .shelf-locked { width: 100%; aspect-ratio: .72; object-fit: cover; border-radius: 3px; box-shadow: 0 10px 22px rgba(0,0,0,.25); transition: transform .2s; }
.shelf-card:hover img { transform: translateY(-5px); }
.shelf-locked { display: grid; place-items: center; background: var(--paper-2); color: var(--muted); }
.shelf-card span { color: var(--muted); font-size: 13px; }

.consent { text-align: left; }
.consent h1 { margin-top: 12px; }
.consent ul { padding-left: 20px; }

/* ---------- Docs ---------- */
.docs { padding-bottom: 50px; max-width: 860px; }
.docs table { width: 100%; border-collapse: collapse; font-size: 14.5px; display: block; overflow-x: auto; }
.docs th, .docs td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---------- Editor ---------- */
.editor { height: 100vh; display: flex; flex-direction: column; }
.editor .topbar { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.ed-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr) 290px; }
.ed-side { overflow-y: auto; padding: 12px 14px; background: var(--card); }
.ed-side:first-child { border-right: 1px solid var(--line); }
.ed-layers { border-left: 1px solid var(--line); }
.ed-side h2 { margin: 2px 0 10px; font-size: 19px; }
.ed-side details { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.ed-side summary { font: 600 16px var(--serif); cursor: pointer; margin-bottom: 8px; }
.ed-side label:not(.check) { display: block; font-size: 13px; font-weight: 600; margin: 8px 0; }
.ed-side label.inline, .ed-tools label.inline { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
#s-qr { display: block; margin-top: 8px; background: #fff; padding: 4px; border-radius: 6px; }
.ed-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper-2); }
.ed-tools { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
.ed-tools input[type="number"] { width: 64px !important; padding: 5px 7px; }
.ed-hint { font-size: 13px; margin-left: auto; }
.ed-canvas-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ed-page { position: relative; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.ed-page canvas { width: 100%; height: 100%; display: block; }
.ed-overlay { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.ed-box { position: absolute; border: 2px solid var(--gold); background: rgba(217, 154, 38, .22); border-radius: 3px; cursor: move; touch-action: none; }
.ed-box.is-circle { border-radius: 50%; }
.ed-box.draft { border-style: dashed; pointer-events: none; }
.ed-box span { position: absolute; top: -2px; left: -2px; background: var(--gold); color: #1d1503; font: 700 11px var(--sans); padding: 0 5px; border-radius: 3px 0 3px 0; }
.ed-grip { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; background: #fff; border: 2px solid var(--gold); border-radius: 3px; cursor: nwse-resize; touch-action: none; }
.layer-clicks { font-size: 13px; color: var(--muted); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stat-table th, .stat-table td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.stat-table td.num, .stat-table th.num { text-align: right; white-space: nowrap; }
.layer-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 980px) {
  .editor { height: auto; }
  .ed-layout { grid-template-columns: 1fr; }
  .ed-main { order: -1; }
  .ed-canvas-wrap { height: 70vh; flex: none; }
  .ed-side:first-child { border-right: 0; }
  .ed-layers { border-left: 0; }
  .ed-hint { margin-left: 0; width: 100%; }
}

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 999; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
