:root {
  --ink: #1b1620;
  --paper: #f6f1e7;
  --paper-edge: #e9e1d2;
  --muted: #8b8293;
  --chrome: #0b0810;
  --chrome-2: #161120;
  --chrome-line: #2a2235;
  --text: #efe9f5;
  --purple: #660099;
  --magenta: #cc3380;
  --orange: #ff8000;
  --gold: #ffbf4d;
  --gradient: linear-gradient(120deg, var(--purple), var(--magenta) 40%, var(--orange) 75%, var(--gold));
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--chrome);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; margin: 6px 0 0; }

.wordmark {
  font-family: var(--serif);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 34px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark span { font-weight: 400; font-style: italic; letter-spacing: 0; }
.wordmark.small { font-size: 20px; }

button { font: inherit; cursor: pointer; border-radius: 999px; border: 0; }
button.primary {
  background: var(--gradient);
  color: white;
  font-weight: 700;
  padding: 13px 22px;
  width: 100%;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--chrome-line);
  padding: 8px 14px;
}

/* ---------- Sign in ---------- */
.signin {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(60% 50% at 50% 0%, rgba(204, 51, 128, 0.18), transparent), var(--chrome);
}
.signin-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 32px 24px;
  border: 1px solid var(--chrome-line);
  border-radius: 28px;
  background: var(--chrome-2);
}
.lede { color: var(--muted); margin: 8px 0 22px; }
.qr-wrap {
  display: inline-block;
  padding: 16px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 0 0 3px transparent, 0 12px 40px rgba(204, 51, 128, 0.25);
}
#qr img, #qr canvas { display: block; width: 220px; height: 220px; }
.steps { text-align: left; color: var(--text); line-height: 1.6; margin: 22px auto 10px; padding-left: 20px; max-width: 320px; font-size: 14px; }

/* ---------- Studio ---------- */
.studio { display: flex; flex-direction: column; height: 100%; }
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--chrome-line);
}
.bar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.panes { flex: 1; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; min-height: 0; }
.editor {
  overflow-y: auto;
  padding: 18px;
  border-right: 1px solid var(--chrome-line);
  display: flex; flex-direction: column; gap: 12px;
}
.editor label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.editor input, .editor textarea {
  font: 15px/1.5 var(--sans);
  color: var(--text);
  background: var(--chrome-2);
  border: 1px solid var(--chrome-line);
  border-radius: 12px;
  padding: 10px 12px;
  text-transform: none; letter-spacing: 0;
}
.editor input:focus, .editor textarea:focus { outline: 2px solid var(--magenta); outline-offset: -1px; }
.editor textarea { min-height: 340px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.toolbar { display: flex; gap: 6px; align-items: center; }
.toolbar button {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--chrome-2); color: var(--text); border: 1px solid var(--chrome-line);
}
.toolbar .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.touches summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.touches label { margin-top: 10px; }
.price .switch { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 500; }
.price-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.price-row input { flex: 1; accent-color: var(--magenta); }
#price-label { font-weight: 700; min-width: 70px; text-align: right; }

/* ---------- The paper preview ---------- */
.preview {
  overflow: auto;
  padding: 28px;
  background: radial-gradient(80% 60% at 50% 0%, rgba(102, 0, 153, 0.25), transparent), #120d18;
}
.spread {
  display: flex; gap: 0;
  margin: 0 auto;
  width: fit-content;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.page {
  position: relative;
  width: 380px; min-height: 560px;
  padding: 38px 34px 46px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.5), transparent 60%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.012) 0 1px, transparent 1px 3px),
    var(--paper);
  font-family: var(--serif);
}
.page + .page { box-shadow: inset 18px 0 22px -18px rgba(0, 0, 0, 0.35); }
.page:first-child { box-shadow: inset -18px 0 22px -18px rgba(0, 0, 0, 0.25); }
.page .folio {
  position: absolute; bottom: 16px; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 34px;
  font: 600 10px/1 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: #9c9286;
}
.cover { display: flex; flex-direction: column; }
.cover .masthead {
  font: 800 13px/1 var(--sans); letter-spacing: 0.3em; text-transform: uppercase;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
  border-bottom: 1px solid #d8cfbf; padding-bottom: 10px;
}
.cover .art { flex: 1; min-height: 170px; margin: 18px 0; border-radius: 4px; position: relative; overflow: hidden; }
.cover h1 { font-size: 38px; line-height: 1.02; margin: 0 0 10px; font-weight: 800; letter-spacing: -0.01em; }
.cover .dek { font-style: italic; font-size: 17px; color: #4c4350; margin: 0 0 14px; }
.cover .byline { font: 600 11px/1.4 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: #7a6f80; }
.cover .touches-line { font: 400 12px/1.5 var(--sans); color: #7a6f80; margin-top: 8px; }
.body-page { font-size: 15.5px; line-height: 1.62; }
.body-page p { margin: 0 0 12px; text-align: justify; hyphens: auto; }
.body-page p.lead::first-letter {
  float: left; font-size: 58px; line-height: 0.85; font-weight: 800; padding: 6px 8px 0 0;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.body-page h2 { font-size: 22px; margin: 18px 0 8px; }
.body-page blockquote {
  margin: 16px 0; padding: 0; font-size: 23px; line-height: 1.25; font-style: italic; font-weight: 600;
  border-top: 2px solid var(--magenta); border-bottom: 2px solid var(--magenta); padding: 12px 0;
}
.body-page ul { padding-left: 18px; margin: 0 0 12px; }
.body-page .section-break { text-align: center; color: var(--magenta); letter-spacing: 0.6em; margin: 16px 0; }
.body-page a { color: var(--purple); }
.body-page .flagged { background: rgba(255, 64, 64, 0.18); outline: 2px solid rgba(220, 40, 40, 0.6); border-radius: 3px; }
.paywall {
  margin-top: 14px; padding: 14px; border: 1px dashed #c9bda9; border-radius: 10px;
  font: 600 13px/1.4 var(--sans); color: #6b5f73; text-align: center;
}

/* ---------- Overlay ---------- */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 3, 8, 0.72); backdrop-filter: blur(8px);
}
.sheet {
  width: min(460px, 100%); text-align: center;
  background: var(--chrome-2); border: 1px solid var(--chrome-line); border-radius: 26px; padding: 28px 24px;
}
.sheet h2 { font-family: var(--serif); font-size: 26px; margin: 10px 0 6px; }
.ov-list { text-align: left; color: var(--text); font-size: 14px; line-height: 1.5; padding-left: 18px; }
.ov-actions { display: flex; gap: 10px; margin-top: 18px; }
.ov-actions button { flex: 1; }

/* The little printing press */
.press { position: relative; height: 90px; width: 180px; margin: 0 auto; }
.roller {
  position: absolute; left: 30px; right: 30px; top: 18px; height: 16px; border-radius: 8px;
  background: var(--gradient); animation: spin 0.6s linear infinite; background-size: 200% 100%;
}
.roller.r2 { top: 40px; animation-direction: reverse; opacity: 0.8; }
.paper-slip {
  position: absolute; left: 50%; width: 70px; height: 50px; margin-left: -35px; top: 30px;
  background: var(--paper); border-radius: 3px; animation: feed 1.4s ease-in-out infinite;
}
@keyframes spin { to { background-position: 200% 0; } }
@keyframes feed { 0% { transform: translateY(-30px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(40px); opacity: 0; } }

@media (max-width: 860px) {
  .panes { grid-template-columns: 1fr; }
  .editor { border-right: 0; border-bottom: 1px solid var(--chrome-line); }
  .preview { padding: 16px; }
  .spread { flex-direction: column; width: 100%; }
  .page { width: 100%; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .roller, .paper-slip { animation: none; }
}
