/* الديوان كتاباً: صفحات بنسبة A5 وتقليب أفقي (العمود الفقري يمين) */
.book-wrap { padding: 8px 12px calc(24px + var(--safe-b)); display: grid; justify-items: center; gap: 10px; }
.book { position: relative; width: min(100%, 520px); aspect-ratio: 1 / 1.4142; perspective: 1800px; margin-inline: auto; touch-action: pan-y; user-select: none; }
.book-nav { display: flex; align-items: center; gap: 18px; }

.pg {
  position: absolute; inset: 0; overflow: hidden; border-radius: 6px 14px 14px 6px; background: var(--surface); color: var(--ink, var(--text));
  box-shadow: 0 6px 22px color-mix(in srgb, #000 22%, transparent), inset -7px 0 12px -8px rgb(0 0 0 / .25);
  transform-origin: right center; transition: transform .7s cubic-bezier(.5, .1, .25, 1), opacity .5s, box-shadow .7s; backface-visibility: hidden;
}
.pg.is-past { transform: rotateY(100deg); opacity: 0; pointer-events: none; box-shadow: none; }
.pg.is-next { z-index: 1; }
.pg.is-cur { z-index: 3; }
.pg.is-far { opacity: 0; pointer-events: none; }
.pg-bg, .pg-veil, .pg-frame { position: absolute; inset: 0; pointer-events: none; }
.pg-bg { background-size: cover; background-position: center; }
.pg-frame { inset: 4.5%; }
.pg[data-template="frame"] .pg-frame, .pg[data-template="ornate"] .pg-frame { border: 1.5px solid var(--accent); border-radius: 6px; opacity: .85; }
.pg[data-template="frame"] .pg-frame::after, .pg[data-template="ornate"] .pg-frame::after { content: ""; position: absolute; inset: 5px; border: 1px solid var(--accent); border-radius: 3px; opacity: .55; }
.pg[data-template="ornate"] .pg-frame::before { content: "❖"; position: absolute; top: -.7em; inset-inline: 0; text-align: center; color: var(--accent); background: none; font-size: calc(var(--u) * 14px); line-height: 1; }

.pg-body { position: absolute; inset: 9% 11% 11%; display: flex; flex-direction: column; overflow: hidden; }
.pg-title { font-family: var(--poem-font); color: var(--accent); text-align: center; font-weight: 700; font-size: calc(var(--pg-size, 20px) * 1.35); line-height: 1.5; }
.pg-orn { margin: calc(var(--u) * 6px) 0 calc(var(--u) * 12px); color: var(--accent); }
.pg-orn svg { width: 60%; height: calc(var(--u) * 18px); }
.pg-items { display: flex; flex-direction: column; }
.pg .verse { --orn: var(--accent, currentColor); font-size: var(--pg-size, 18px); color: var(--ink); margin-bottom: var(--pg-vgap, 10px); }
.pg .heading-line { color: var(--accent); font-size: calc(var(--pg-size, 18px) * .95); margin-bottom: var(--pg-vgap, 10px); }
.pg .divider-line { color: var(--accent); margin-bottom: var(--pg-vgap, 10px); }
.pg-num { position: absolute; bottom: 5.2%; inset-inline: 0; text-align: center; font-size: calc(var(--u) * 11px); color: var(--ink); opacity: .7; }

/* الغلاف */
.pg[data-kind="cover"] .pg-body { align-items: center; justify-content: center; text-align: center; gap: calc(var(--u) * 12px); inset: 9% 10%; }
.cv-title { font-family: 'F-aref', 'Aref Ruqaa', serif; color: var(--accent); font-weight: 700; font-size: calc(var(--u) * 40px * var(--sz, 1)); line-height: 1.4; }
.cv-sub { font-family: var(--poem-font); font-size: calc(var(--u) * 17px * var(--sz, 1)); opacity: .9; }
.cv-author { font-size: calc(var(--u) * 14px * var(--sz, 1)); color: var(--accent); }
.cv-photo { width: calc(var(--u) * 120px); height: calc(var(--u) * 120px); border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); }

/* الفهرس */
.toc-list { display: flex; flex-direction: column; gap: calc(var(--u) * 9px); margin-top: calc(var(--u) * 6px); }
.toc-row { display: flex; align-items: baseline; gap: 6px; font-family: var(--poem-font); font-size: calc(var(--u) * 16px); background: none; border: 0; color: var(--ink); text-align: start; padding: 0; width: 100%; }
.toc-row i { flex: 1; border-bottom: 1.5px dotted var(--ink); opacity: .35; transform: translateY(-3px); }
.toc-row b { font-family: var(--ui-font); font-size: .8em; color: var(--accent); }

.book-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-muted); padding: 24px; }

/* لوحة التخصيص */
.opt-row { display: grid; gap: 8px; margin-bottom: 16px; }
.opt-row > label, .opt-row > .lbl { font-size: .88rem; color: var(--text-muted); }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--border); padding: 0; }
.swatch.is-on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.opt-field { width: 100%; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); outline: 0; }
.hint { font-size: .8rem; color: var(--text-muted); line-height: 1.7; }
.prompt-box { width: 100%; min-height: 110px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); direction: ltr; text-align: left; font-size: .85rem; }
.order-row .row-title { font-family: var(--poem-font); }
.order-row.is-hidden { opacity: .45; }

@media print {
  .appbar, .book-nav, #layer { display: none !important; }
}

.tabs { margin-bottom: 14px; position: sticky; top: 0; z-index: 2; }
.tabs button { font-size: .8rem; padding-inline: 4px; }
.color-in { width: 38px; height: 38px; border: 2px solid var(--border); border-radius: 50%; padding: 0; background: none; cursor: pointer; }
.opt-row .row-head input[type=range] { flex: 1; }
.cv-title { font-family: var(--tfont, 'F-aref', 'Aref Ruqaa', serif); }
