/* المحرر */
.editor { padding: 4px 24px calc(160px + var(--safe-b)); }
.title-input, .sh-in, .heading-in {
  display: block; width: 100%; border: 0; outline: 0; background: transparent; resize: none; overflow: hidden; padding: 0;
  font-family: var(--poem-font); color: var(--text); caret-color: var(--primary); line-height: var(--lh);
}
.title-input { text-align: center; font-size: calc(var(--poem-size) * 1.35); font-weight: 700; padding: 12px 0 4px; }
::placeholder { color: var(--placeholder); opacity: 1; }
.meta-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin: 6px 0 10px; font-size: .85rem; color: var(--text-muted); }
.ornament-head { margin: 4px 0 22px; }

.blocks { counter-reset: v; }
.blk { position: relative; margin-bottom: var(--verse-gap); border-radius: 16px; transition: background var(--t); }
.blk:focus-within { background: var(--surface-bright); }
.blocks { margin-inline: -10px; padding-inline: 10px; }
html[data-numbers="1"] .blocks { padding-inline-start: 30px; }
html[data-numbers="1"] .blk.numbered { counter-increment: v; }
html[data-numbers="1"] .blk.numbered::before {
  content: counter(v, arabic-indic); position: absolute; inset-inline-start: -22px; top: .55em; font-family: var(--ui-font); font-size: .6rem; color: var(--primary); width: 20px; text-align: center;
}
html[data-ornament="1"] .blk.numbered:not(:last-of-type)::after { content: none; }
.sh-in { font-size: var(--poem-size); }
.blk-verse .sh-in { width: 90%; }
.blk-verse .sadr-in { margin-inline-end: auto; }
.blk-verse .ajz-in { margin-inline-start: auto; margin-top: var(--shatr-gap); }
html[data-ajz="facing"] .blk-verse { display: flex; gap: 1.2em; align-items: flex-start; }
html[data-ajz="facing"] .blk-verse .sh-in { width: 50%; margin: 0; flex: 1 1 0; }
html[data-ajz="facing"] .blk-verse .sh-in { font-size: calc(var(--poem-size) * var(--ed-k, 1)); white-space: nowrap; }
@media (max-width: 479px) {
  .editor { padding-inline: 14px; }
  html[data-ajz="facing"] .blk-verse { gap: .6em; }
}
.blk-line .sh-in { width: 100%; }
.blk-line { margin-bottom: calc(var(--verse-gap) * .3); }
.heading-in { text-align: center; font-weight: 700; color: var(--primary); font-size: calc(var(--poem-size) * .95); }
.blk-divider { text-align: center; color: var(--primary); letter-spacing: .6em; padding: 6px 0; user-select: none; opacity: .85; }
.blk-more {
  position: absolute; top: -6px; inset-inline-end: -8px; width: 34px; height: 34px; opacity: 0; pointer-events: none; z-index: 2; background: var(--surface); border: 1px solid var(--border); border-radius: 50%; display: grid; place-items: center; color: var(--text-muted); padding: 0;
}
.blk-more .ic { width: 20px; height: 20px; }
.blk:focus-within .blk-more, .blk:hover .blk-more { opacity: 1; pointer-events: auto; }
@media (hover: none) { .blk:hover:not(:focus-within) .blk-more { opacity: 0; pointer-events: none; } }

.btn-add {
  display: flex; margin: 8px auto 0; align-items: center; gap: 6px; padding: 10px 22px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--primary); font-weight: 600;
}
.save-state { text-align: center; font-size: .75rem; color: var(--text-muted); height: 1.2em; margin-top: 14px; opacity: .8; }

/* وضع القراءة */
.read-view { padding: 8px 0 0; }
.read-view .poem-body { padding-inline: 8px; }
body.reading .title-input, body.reading #blocks, body.reading #add-verse, body.reading #btn-mic, body.reading #btn-attach, body.reading #harakat { display: none !important; }
.read-title { font-family: var(--poem-font); text-align: center; font-size: calc(var(--poem-size) * 1.35); font-weight: 700; margin: 12px 0 4px; display: none; }
body.reading .read-title { display: block; }
.read-view .verse { margin-bottom: var(--verse-gap); }
.read-view .poem-body .verse { margin-bottom: 0; }

/* شريط التشكيل */
.harakat-bar {
  position: fixed; z-index: 40; inset-inline: 0; margin-inline: auto; max-width: var(--maxw); bottom: 0; display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: var(--appbar);
  border-top: 1px solid var(--border); scrollbar-width: none;
}
.harakat-bar::-webkit-scrollbar { display: none; }
.hk { flex: none; min-width: 46px; height: 42px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); font-family: var(--poem-font); font-size: 1.5rem; line-height: 1; touch-action: manipulation; }
.hk:active { background: var(--primary); color: var(--on-primary); }
.hk small { font-size: .65rem; font-family: var(--ui-font); display: block; color: var(--text-muted); margin-top: -2px; }

/* بطاقة الصوت */
.audio-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; }
.play-btn { width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.audio-mid { flex: 1; min-width: 0; display: grid; gap: 4px; }
.audio-title { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wave { width: 100%; height: 36px; display: block; cursor: pointer; touch-action: none; direction: ltr; }
.audio-time { font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; }

/* لوحة التسجيل */
.rec { display: grid; justify-items: center; gap: 14px; padding-bottom: 6px; }
.rec-canvas { width: 100%; height: 72px; border-radius: 16px; background: var(--surface-2); direction: ltr; }
.rec-timer { font-size: 1.05rem; color: var(--text-muted); font-variant-numeric: tabular-nums; min-height: 1.6em; }
.rec-timer.is-live { color: var(--danger); }
.rec-controls { display: flex; align-items: center; gap: 22px; }
.rec-btn { width: 78px; height: 78px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 18%, transparent); transition: all var(--t); }
.rec-btn .ic { width: 38px; height: 38px; }
.rec-btn.is-rec { background: var(--danger); box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 22%, transparent); animation: rec-pulse 1.4s ease-in-out infinite; }
@keyframes rec-pulse { 50% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--danger) 8%, transparent); } }
.rec-side { width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface-2); display: grid; place-items: center; color: var(--text); }
.rec-side[disabled] { opacity: .35; }
.rec-name { width: 100%; }

/* معاينة صورة المشاركة */
.share-preview { max-width: 100%; max-height: 52vh; display: block; margin: 12px auto; border-radius: 16px; border: 1px solid var(--border); }
