:root {
  font-family: system-ui, sans-serif;
  color: #14223d;
  background: #f6f8fc;
  --blue: #164dc7;
  --ink: #14223d;
  --muted: #4c5d79;
  --line: #dce4f1;
  --radius: 22px;
  --turn-time: 620ms;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--blue); }
button, input, .button { font: inherit; }
button, .button { min-height: 44px; padding: 8px 15px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; text-decoration: none; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 3px solid #4379f7; outline-offset: 4px; }
.wrap { width: min(1180px, calc(100% - 36px)); margin-inline: auto; }
.top { background: #fff; border-bottom: 1px solid var(--line); }
.bar, .brand, .reader-header, .reader-footer, .reader-tools { display: flex; align-items: center; gap: 10px; }
.bar { min-height: 68px; justify-content: space-between; }
.brand { color: var(--ink); text-decoration: none; font-weight: 850; letter-spacing: .065em; }
.brand img { object-fit: contain; }
.bar .plain { min-height: 44px; display: inline-flex; align-items: center; }
.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  align-items: center;
  gap: clamp(32px, 6vw, 88px);
  min-height: min(700px, 80vh);
  padding-block: clamp(34px, 6vw, 80px);
}
.welcome-copy { max-width: 580px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 16px;
  padding: 6px 11px;
  border-radius: 999px;
  background: #e7efff;
  color: #174294;
  font-size: .74rem;
  letter-spacing: .12em;
  font-weight: 850;
}
h1 { margin: 0; font-size: clamp(2.15rem, 5.3vw, 4.2rem); line-height: 1.12; letter-spacing: -.025em; }
.intro { margin: 16px 0 22px; font-size: clamp(1.04rem, 1.5vw, 1.23rem); }
.intro, .note, small, .privacy-note { color: var(--muted); line-height: 1.65; }
.privacy-note { margin: 12px 0 0; font-size: .91rem; }
.upload {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 21px 14px;
  border: 1px dashed #7195db;
  background: #fff;
  border-radius: 16px;
  text-align: center;
}
.upload.is-dragging { border-color: var(--blue); background: #e7efff; }
.upload label { color: var(--muted); }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 750; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.sample-display {
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
  min-height: 430px;
  padding: 30px 24px 18px;
  border: 1px solid #dce6fa;
  border-radius: 36px;
  background: radial-gradient(ellipse at 48% 38%, #fff 0, #e9f0ff 55%, #dce8ff 100%);
}
.sample-book {
  position: relative;
  display: block;
  width: min(72%, 265px);
  min-width: 140px;
  padding: 0;
  border: 0;
  border-radius: 2px 7px 7px 2px;
  box-shadow: 6px 6px 0 #f0e9d8, 9px 9px 0 #c7bda8, 0 22px 38px #263b6650;
  transform: rotate(-3deg);
  transition: transform .22s ease;
}
.sample-book:hover { transform: rotate(0deg) translateY(-5px); }
.sample-book img { display: block; width: 100%; height: auto; border-radius: inherit; }
.sample-cta {
  position: absolute;
  inset-inline-start: 50%;
  inset-block-end: 14%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 16px);
  padding: 10px 13px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 18px #0d1d3940;
  font-size: .88rem;
  font-weight: 800;
}
[dir=rtl] .sample-cta { transform: translateX(50%); }
.sample-cta > span:first-child { color: var(--blue); }
.sample-caption { margin-block: 25px 2px; color: var(--muted); font-size: .87rem; }
.layout { display: grid; gap: 16px; padding-block: 22px 34px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 36px #15233f0b; min-width: 0; }
.reader-header, .reader-footer { padding: 11px 16px; justify-content: space-between; }
.reader-header { flex-wrap: wrap; }
.reader-header h2 { margin: 0; }
.reader-tools { flex-wrap: wrap; gap: 2px; }
.reader-footer button { min-width: 80px; }
.stage {
  --fit-height: max(230px, calc(100dvh - 310px));
  background: radial-gradient(ellipse at 50% 40%, #354464, #192339 78%);
  padding: clamp(12px, 3vw, 30px);
  min-height: 310px;
  max-height: min(74vh, 940px);
  overflow: auto;
  text-align: center;
  overscroll-behavior-inline: contain;
}
.empty { min-height: 270px; display: grid; place-content: center; justify-items: center; color: #e1eaff; }
.paper { position: relative; display: inline-block; width: min(100%, 410px); perspective: 1700px; vertical-align: top; --sheet-aspect: .75; --sheet-count: 1; }
.paper.double { width: min(100%, 810px); --sheet-count: 2; }
.paper.landscape { --sheet-aspect: 1.43; }
@media (min-width: 830px) {
  .stage:not(.zoom) .paper { max-width: calc(var(--fit-height) * var(--sheet-aspect) * var(--sheet-count)); }
}
.stage.zoom .paper { width: min(145%, 670px); }
.stage.zoom .paper.double { width: min(145%, 1220px); }
.book-frame {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  background: #f4eddd;
  box-shadow: 0 13px 34px #0007, 0 2px 5px #0009;
  touch-action: pan-y pinch-zoom;
}
.double .book-frame::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 50%;
  width: 12px;
  margin-inline-start: -6px;
  background: linear-gradient(to right, transparent, #27231d36 48%, #27231d15 62%, transparent);
  pointer-events: none;
}
.sheet { position: relative; min-width: 0; aspect-ratio: var(--sheet-aspect); display: grid; place-items: center; background: #faf7ee; overflow: hidden; }
.sheet canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.flip-leaf {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 100%;
  z-index: 2;
  pointer-events: none;
  transform-style: preserve-3d;
  animation: turn-leaf var(--turn-time) cubic-bezier(.45, .12, .18, 1) both;
  --angle: -180deg;
  transform-origin: left center;
}
.double .flip-leaf { width: 50%; }
.double .flip-leaf.forward { inset-inline-start: 50%; }
.cover-turn {
  position: relative;
  transform-style: preserve-3d;
  --cover-offset: -25%;
  --reading-direction: 1;
  animation: move-cover var(--turn-time) cubic-bezier(.45, .12, .18, 1) both;
}
.cover-turn.closing { animation-direction: reverse; }
.cover-turn.back-cover { --cover-offset: 25%; }
[dir=rtl] .cover-turn { --reading-direction: -1; }
.cover-turn .book-frame,
.cover-turn .book-frame .sheet:empty { background: transparent; box-shadow: none; }
.cover-turn .book-frame::after { display: none; }
.cover-turn .book-frame .sheet:not(:empty),
.cover-turn .leaf-face { box-shadow: 0 13px 34px #0007; }
.flip-leaf.backward { --angle: 180deg; transform-origin: right center; }
[dir=rtl] .flip-leaf.forward { --angle: 180deg; transform-origin: right center; }
[dir=rtl] .flip-leaf.backward { --angle: -180deg; transform-origin: left center; }
.leaf-face { position: absolute; inset: 0; backface-visibility: hidden; }
.leaf-face .sheet { height: 100%; aspect-ratio: auto; }
.leaf-back { transform: rotateY(180deg); }
.leaf-face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #030b2690, transparent 45%, #fff5 68%, #00112b35);
  animation: leaf-shade var(--turn-time) ease both;
}
@keyframes turn-leaf { to { transform: rotateY(var(--angle)); } }
@keyframes move-cover { from { transform: translateX(calc(var(--cover-offset) * var(--reading-direction))); } }
@keyframes leaf-shade { 0%, 100% { opacity: 0; } 48% { opacity: .7; } }
@media (prefers-reduced-motion: reduce) {
  .sample-book { transition: none; }
  .flip-leaf, .leaf-face::after, .cover-turn { animation: none; }
}
.workspace:fullscreen { border-radius: 0; display: flex; flex-direction: column; background: #fff; }
.workspace:fullscreen .stage { flex: 1; max-height: none; --fit-height: max(230px, calc(100dvh - 185px)); }
.count { font-weight: 800; font-variant-numeric: tabular-nums; }
.actions { padding: 16px 19px; }
.actions:not(:has(section:not([hidden]), details:not([hidden]), .status:not(:empty))) { display: none; }
h2 { font-size: 1.12rem; margin: 0 0 10px; }
.actions #publish-controls:not([hidden]) + #share, .actions details { margin-block-start: 14px; border-top: 1px solid var(--line); padding-block-start: 12px; }
.actions summary { cursor: pointer; padding-block: 10px; font-weight: 650; }
.actions label:not(.check) { display: block; font-weight: 650; margin-block: 10px 5px; }
.actions input:not([type=checkbox]) { display: block; min-height: 44px; width: min(100%, 620px); padding: 8px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; }
.actions button, .actions .button { display: inline-flex; align-items: center; justify-content: center; margin-block: 7px 1px; }
.check { display: flex; align-items: flex-start; gap: 7px; margin-block: 12px; }
.check input { accent-color: var(--blue); }
.danger { color: #9e2631; }
.plain { background: transparent; border: 0; color: var(--blue); }
.status { margin: 0; color: var(--muted); font-size: .91rem; line-height: 1.6; }
.status:not(:empty) { padding: 0 14px 10px; }
.actions .status:not(:empty), .welcome .status:not(:empty) { padding: 10px 0 0; }
.status[data-error] { color: #a32434; }
.footer { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-block: 15px 22px; color: var(--muted); font-size: .86rem; }
@media (max-width: 760px) {
  .welcome { grid-template-columns: 1fr; gap: 20px; }
  .sample-display { min-height: 0; padding: 22px 15px 13px; border-radius: 20px; }
  .sample-book { width: min(52%, 175px); }
  .stage { padding: 10px; min-height: 215px; }
  .empty { min-height: 195px; }
  .reader-header, .reader-footer { padding-inline: 10px; }
  .reader-tools button { padding-inline: 8px; }
}
