@font-face { font-family: Nastaliq; src: url('./fonts/NotoNastaliqUrdu.ttf') format('truetype'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: Gulzar; src: url('./fonts/Gulzar-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: Naskh; src: url('./fonts/NotoNaskhArabic.ttf') format('truetype'); font-weight: 400 700; font-display: swap; }

:root {
  color-scheme: light;
  --green: #123f37; --green-deep: #0c2b26; --gold: #c39a55; --gold-soft: #f1e3c4; --paper: #fbf9f4; --ink: #1f2a27;
  --muted: #6b756f; --line: #dfe3dc; --surface: #eef1ec; --danger: #9b3930;
  --urdu: Nastaliq, 'Noto Nastaliq Urdu', serif; --ui: Naskh, 'Segoe UI', system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px); --safe-top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; max-width: 100%; overflow-x: hidden; }
body { font-family: var(--ui); font-size: 16px; color: var(--ink); background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ——— header ——— */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 6px; padding: calc(8px + var(--safe-top)) 10px 8px; background: var(--green); color: #f3f6f2; }
.top .icon { width: 42px; height: 42px; border: 0; border-radius: 12px; background: #ffffff14; color: inherit; font-size: 20px; flex: none; }
.top .icon:active { background: #ffffff2a; }
.title-wrap { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; border: 0; background: transparent; color: inherit; padding: 4px 2px; text-align: right; border-radius: 10px; }
.title-wrap:active { background: #ffffff14; }
.brand { font-family: var(--urdu); font-size: 22px; line-height: 1.2; color: #f3d9a3; flex: none; }
.doc-title { font-family: var(--urdu); font-size: 15px; line-height: 1.4; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { font-size: 11px; opacity: .6; white-space: nowrap; flex: none; }
.count::after { content: ' الفاظ'; font-family: var(--urdu); }
.engine-chip { border: 1px solid #ffffff33; background: #ffffff10; color: #e7efe9; border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.engine-chip.engine-device { border-color: #9fd7b3; color: #d6f5e0; }
.engine-chip.engine-server { border-color: #f3d9a3; color: #f7e6bd; }
.engine-chip.engine-none { border-color: #e0a5a0; color: #f4c8c4; }

/* ——— the page ——— */
.page { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 12px 24px; }
.blocks { max-width: 720px; margin: 0 auto; background: var(--paper); border-radius: 16px; padding: 14px 14px 10px; box-shadow: 0 1px 2px #0000000d, 0 8px 28px #12352e0f; min-height: 40vh; }
.block { position: relative; padding: 4px 0 6px; }
.block + .block { border-top: 1px solid #ebe6da; }
.block-label { font-size: 11px; color: var(--muted); letter-spacing: .2px; margin: 4px 0 -2px; }
.block textarea { display: block; width: 100%; border: 0; background: transparent; resize: none; outline: none; padding: 4px 2px; font-family: var(--urdu); font-size: 22px; line-height: 2.15; color: var(--ink); overflow: hidden; }
.block textarea::placeholder { color: #b7b0a2; }
.block textarea:focus { background: #fff; border-radius: 8px; box-shadow: inset 0 0 0 1.5px #c39a5566; }
.block-title textarea { font-size: 30px; text-align: center; line-height: 1.9; }
.block-subtitle textarea { font-size: 19px; text-align: center; color: #5c6a63; }
.block-heading textarea { font-size: 26px; line-height: 2; }
.block-sher textarea, .block-band textarea { text-align: center; }
.block-quote textarea[data-field="text"] { font-family: Naskh, serif; font-size: 24px; line-height: 2; text-align: center; background: #f6f2e8; border-radius: 10px; padding: 8px 10px; }
.block-quote textarea[data-field="sub"] { font-size: 19px; text-align: center; color: #3f4a45; }
.block-note textarea { font-size: 18px; color: #4e5853; border-top: 1px dashed #d9d2c2; }
/* a translated book in another language: its own typeface and proportions (the editor sets data-script) */
.blocks[data-script]:not([data-script="urdu"]) textarea { font-family: 'Noto Serif', Georgia, 'Times New Roman', serif; font-size: 19px; line-height: 1.65; }
.blocks[data-script="arab"] textarea { font-family: Naskh, 'Noto Naskh Arabic', serif; font-size: 21px; line-height: 1.95; }
.blocks[data-script="deva"] textarea { font-family: 'Noto Serif Devanagari', 'Noto Sans Devanagari', 'Nirmala UI', sans-serif; line-height: 1.8; }
.blocks[data-script="beng"] textarea { font-family: 'Noto Serif Bengali', 'Noto Sans Bengali', 'Nirmala UI', sans-serif; line-height: 1.8; }
.blocks[data-script="guru"] textarea { font-family: 'Noto Sans Gurmukhi', 'Nirmala UI', sans-serif; line-height: 1.8; }
.blocks[data-script="gujr"] textarea { font-family: 'Noto Sans Gujarati', 'Nirmala UI', sans-serif; line-height: 1.8; }
.blocks[data-script="taml"] textarea, .blocks[data-script="telu"] textarea, .blocks[data-script="knda"] textarea, .blocks[data-script="mlym"] textarea { font-family: 'Noto Sans Tamil', 'Noto Sans Telugu', 'Noto Sans Kannada', 'Noto Sans Malayalam', 'Nirmala UI', sans-serif; line-height: 1.85; }
.blocks[data-script="hans"] textarea, .blocks[data-script="jpan"] textarea, .blocks[data-script="kore"] textarea { font-family: 'Noto Serif CJK SC', 'Noto Sans CJK SC', 'Noto Sans CJK JP', 'Noto Sans CJK KR', sans-serif; line-height: 1.75; }
.blocks[data-script]:not([data-script="urdu"]) .block-title textarea { font-size: 26px; line-height: 1.4; font-weight: 700; }
.blocks[data-script]:not([data-script="urdu"]) .block-heading textarea { font-size: 22px; line-height: 1.45; font-weight: 700; }
.blocks[data-script]:not([data-script="urdu"]) .block-quote textarea[data-field="text"] { font-family: Naskh, serif; font-size: 22px; line-height: 2; }
.pagebreak-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 6px 0; }
.pagebreak-line::before, .pagebreak-line::after { content: ''; flex: 1; border-top: 1px dashed #c8c1b0; }
.pagebreak-remove { border: 0; background: transparent; color: var(--muted); font-size: 14px; }
.interim { max-width: 720px; margin: 12px auto 0; font-family: var(--urdu); font-size: 18px; line-height: 2; color: #6c7a72; padding: 6px 14px; }

/* ——— word alternatives ——— */
.alts { background: #fff; border-top: 1px solid var(--line); padding: 8px 12px 6px; box-shadow: 0 -6px 18px #0000000a; }
.alts-head { display: flex; align-items: center; gap: 10px; }
.alts-word { font-family: var(--urdu); font-size: 20px; line-height: 1.6; color: var(--green); }
.alts-hint { font-size: 12px; color: var(--muted); flex: 1; }
.alts-delete { border: 1px solid #e6c9c4; color: var(--danger); background: #fff5f3; border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.icon.small { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.alts-list { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.alts-list::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid #d5dbd5; background: #f6f8f5; border-radius: 999px; padding: 4px 14px; font-family: var(--urdu); font-size: 19px; line-height: 1.7; }
.chip:active { background: var(--gold-soft); }
.chip-learned { border-color: var(--gold); background: #fbf3e3; }
.chip-wait, .chip-none { color: var(--muted); font-family: var(--ui); font-size: 14px; }

/* ——— bottom bar ——— */
.bar { background: #fff; border-top: 1px solid var(--line); padding: 6px 10px calc(10px + var(--safe-bottom)); }
.block-tools { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; align-items: center; }
.block-tools::-webkit-scrollbar { display: none; }
.block-tools button { flex: none; border: 1px solid var(--line); background: #f7f9f6; border-radius: 999px; padding: 6px 13px; font-family: var(--urdu); font-size: 15px; line-height: 1.6; }
.block-tools button[aria-pressed="true"] { background: var(--green); color: #fff; border-color: var(--green); }
.block-tools #block-up, .block-tools #block-down, .block-tools #block-delete { font-family: var(--ui); width: 38px; padding: 6px 0; text-align: center; }
.block-tools .danger { color: var(--danger); }
.tools-gap { flex: 1; min-width: 6px; }
.mic-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
.side { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; }
.side:last-child { justify-content: flex-end; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: #f7f9f6; font-size: 20px; }
.round:disabled { opacity: .35; }
#word-button { font-family: var(--urdu); font-size: 16px; line-height: 1; }
.status { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mic-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.mic-level { position: absolute; top: 0; left: 50%; width: 84px; height: 84px; margin-left: -42px; border-radius: 50%; background: var(--gold); opacity: .25; transform: scale(calc(1 + var(--level, 0) * .5)); transition: transform .08s linear; pointer-events: none; }
.mic { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--green); color: #f3d9a3; box-shadow: 0 6px 20px #12352e40, inset 0 0 0 4px #ffffff22; touch-action: none; -webkit-user-select: none; user-select: none; }
.mic svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mic.listening { background: #b8412f; color: #fff; box-shadow: 0 6px 24px #b8412f66, inset 0 0 0 4px #ffffff33; }
.mic.busy { background: #6b7a72; }
.mic:disabled { background: #b8bfba; box-shadow: none; }
.mic.no-engine { background: #8a958f; }
.setup { max-width: 720px; margin: 0 auto 12px; background: #fff8e8; border: 1px solid #ecd9ac; border-radius: 16px; padding: 12px 16px 14px; }
.setup h2 { font-family: var(--urdu); font-weight: 400; font-size: 20px; line-height: 1.9; margin: 0; color: #5c4515; }
.setup p { font-family: var(--urdu); font-size: 15px; line-height: 2; margin: 2px 0 8px; color: #4d4a42; }
.setup progress { width: 100%; height: 8px; margin-bottom: 8px; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-actions .button { flex: 1 1 auto; }
.version { direction: ltr; text-align: left; margin-top: 12px; }
.mic-label { font-family: var(--urdu); font-size: 14px; line-height: 1.6; color: var(--muted); }

/* ——— sheets ——— */
dialog.sheet { border: 0; border-radius: 18px 18px 0 0; padding: 14px 16px calc(16px + var(--safe-bottom)); width: 100%; max-width: 100%; margin: auto 0 0; max-height: 88vh; overflow-y: auto; background: #fff; color: var(--ink); }
dialog.sheet.full { height: 92vh; max-height: 92vh; display: flex; flex-direction: column; }
dialog.sheet.full:not([open]) { display: none; }
dialog::backdrop { background: #12352e55; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-family: var(--urdu); font-weight: 400; font-size: 22px; margin: 0; line-height: 1.8; }
.sheet-head .icon { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--surface); font-size: 18px; }
.sheet h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }
.fine { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.fine a { color: var(--green); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 10px 0; }
.row label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
select, .field input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.field input { flex: 1; min-width: 0; }
.button { border: 1px solid var(--line); background: #f7f9f6; border-radius: 12px; padding: 10px 16px; font-size: 15px; }
.button.primary { background: var(--green); color: #fff; border-color: var(--green); }
.button.small { padding: 6px 12px; font-size: 13px; border-radius: 999px; }
.button:disabled { opacity: .5; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 8px; }
.actions .button { flex: 1 1 40%; }
#preview-frame { flex: 1; width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #d9d6cf; }

.layout-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.layout-choice { border: 1px solid var(--line); background: #f7f9f6; border-radius: 12px; padding: 10px; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.layout-choice strong { font-family: var(--urdu); font-weight: 400; font-size: 18px; line-height: 1.6; }
.layout-choice span { font-size: 12px; color: var(--muted); }
.docs-list { list-style: none; margin: 0; padding: 0; }
.docs-list li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.docs-list .empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.doc-item { flex: 1; border: 0; background: transparent; text-align: right; padding: 10px 4px; display: flex; flex-direction: column; gap: 2px; }
.doc-item strong { font-family: var(--urdu); font-weight: 400; font-size: 18px; line-height: 1.7; }
.doc-item span { font-size: 12px; color: var(--muted); }
.doc-remove { border: 0; background: transparent; font-size: 16px; padding: 8px; }

.layout-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.layout-card { position: relative; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.layout-card input { position: absolute; opacity: 0; }
.layout-card:has(input:checked) { border-color: var(--gold); background: #fdf8ee; }
.layout-card strong { font-family: var(--urdu); font-weight: 400; font-size: 16px; line-height: 1.6; }
.layout-card small { font-size: 11px; color: var(--muted); }
.layout-art { display: block; height: 70px; border-radius: 6px; background: #fff; border: 1px solid #e5e1d6; position: relative; overflow: hidden; }
.layout-art::before, .layout-art::after { content: ''; position: absolute; left: 12%; right: 12%; background: #c9c2b2; height: 2px; border-radius: 2px; box-shadow: 0 6px 0 #d9d3c4, 0 12px 0 #d9d3c4, 0 18px 0 #d9d3c4, 0 24px 0 #d9d3c4; top: 24px; }
.layout-art::after { top: 12px; height: 4px; background: #9a7b3c; box-shadow: none; left: 35%; right: 35%; }
.layout-art-nasr::before { left: 10%; right: 10%; }
.layout-art-shaer::before { left: 25%; right: 25%; box-shadow: 0 6px 0 #d9d3c4, 0 16px 0 #d9d3c4, 0 22px 0 #d9d3c4, 0 32px 0 #d9d3c4; }
.layout-art-deeni::after { background: #4f7f5c; height: 6px; left: 20%; right: 20%; }
.layout-art-sada::after { display: none; }

.radio-list label, .check-list label { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: 15px; }
.radio-list label small { margin-right: auto; color: var(--muted); font-size: 12px; }
.radio-list label.unavailable span { color: var(--muted); }
.radio-list.inline { display: flex; gap: 14px; }
.models { list-style: none; margin: 0; padding: 0; }
.model { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.model strong { display: block; font-size: 14px; }
.model-note { font-size: 12px; color: var(--muted); font-family: var(--urdu); }
.model progress { grid-column: 1 / -1; width: 100%; height: 6px; }
.help { padding-right: 18px; font-family: var(--urdu); font-size: 17px; line-height: 2.1; }
.help li { margin-bottom: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-bottom)); transform: translate(-50%, 20px); background: #1f2a27; color: #fff; padding: 10px 16px; border-radius: 12px; font-family: var(--urdu); font-size: 15px; line-height: 1.8; max-width: 92vw; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }


/* ——— the library ——— */
.library { background: linear-gradient(180deg, var(--green) 0, var(--green) 132px, var(--surface) 132px); overflow-y: auto; }
.lib-top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + var(--safe-top)) 16px 6px; color: #f3f6f2; }
.lib-top .icon { width: 42px; height: 42px; border: 0; border-radius: 12px; background: #ffffff14; color: inherit; font-size: 20px; }
.lib-brand { display: flex; align-items: center; gap: 10px; }
.lib-mark, .top-mark { width: 30px; height: 30px; border-radius: 9px; background: #0c2b26 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 108 108'%3E%3Cg transform='translate(54 54) scale(1.5) translate(-54 -54)'%3E%3Cg transform='translate(54 54) scale(.94) translate(-54 -56.75)'%3E %3Cpath d='M26 42V75c11-2 21-1 28 3.5C61 74 71 73 82 75V42z' fill='%23C39A55'/%3E %3Cpath d='M54 41c-7-5-16-6-25-4v34.5c9-1.5 18-.5 25 3.5z' fill='%23F6EBD3'/%3E %3Cpath d='M54 41c7-5 16-6 25-4v34.5c-9-1.5-18-.5-25 3.5z' fill='%23FBF4E4'/%3E %3Cpath d='M54 41v34' stroke='%23C39A55' stroke-width='1.4'/%3E %3Cg fill='none' stroke='%23123F37' stroke-width='2.6' stroke-linecap='round'%3E %3Cpath d='M74 47H60M74 53.5H60M74 60H64'/%3E %3Cpath d='M34.5 52v6M39 48v14M43.5 50v10M48 53v4'/%3E %3C/g%3E %3C/g%3E%3C/g%3E%3C/svg%3E") center / 84% no-repeat; box-shadow: inset 0 0 0 2px #e9c98855; flex: none; }
.top-mark { width: 26px; height: 26px; border-radius: 8px; align-self: center; }
.lib-brand .brand { font-size: 28px; }
.lib-tag { font-family: var(--urdu); font-size: 14px; line-height: 1.8; color: #cfe0d8; }
.lib-main { max-width: 760px; width: 100%; margin: 0 auto; padding: 8px 14px calc(28px + var(--safe-bottom)); }
.lib-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 20px; }
.lib-action { border: 0; border-radius: 18px; padding: 16px 14px 14px; text-align: right; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  background: linear-gradient(155deg, #ffffff 0%, #fbf6ea 100%); box-shadow: 0 1px 2px #0000000f, 0 10px 26px #12352e1f; }
.lib-action:active { transform: translateY(1px); box-shadow: 0 1px 2px #0000000f, 0 4px 12px #12352e1a; }
.lib-action-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #f3d9a3; margin-bottom: 8px; box-shadow: inset 0 0 0 3px #ffffff22; }
.lib-action.scan .lib-action-icon { background: #8a6a2f; color: #fff7e3; }
.lib-action-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lib-action strong { font-family: var(--urdu); font-weight: 400; font-size: 19px; line-height: 1.8; color: var(--ink); }
.lib-action small { font-size: 12.5px; color: var(--muted); }
.lib-shelf-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.lib-shelf-head h2 { font-family: var(--urdu); font-weight: 400; font-size: 20px; line-height: 1.8; margin: 0; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; padding: 4px 2px 8px; }
.shelf-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-family: var(--urdu); font-size: 15px; line-height: 2; padding: 24px 8px; border: 1.5px dashed #d3d9d2; border-radius: 16px; }
.shelf-item { position: relative; }
.book-cover { position: relative; width: 100%; aspect-ratio: 3 / 4; border: 0; border-radius: 4px 12px 12px 4px; padding: 0; cursor: pointer; overflow: hidden; display: block; color: #f6e7c1;
  background: var(--cover, #123f37); box-shadow: 0 2px 3px #00000022, 0 12px 24px #12352e33, inset -6px 0 10px #00000033; text-align: center; }
.book-cover::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #ffffff06 0 2px, transparent 2px 6px); pointer-events: none; }
.cover-spine { position: absolute; top: 0; bottom: 0; right: 0; width: 12px; background: linear-gradient(90deg, #00000022, #ffffff18 40%, #00000030); }
.cover-inner { position: absolute; inset: 12px 20px 30px 12px; border: 1.5px solid #e9c98899; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; }
.cover-orn { font-family: serif; color: #e9c988; font-size: 15px; letter-spacing: 3px; }
.cover-name { font-family: var(--urdu); font-weight: 400; font-size: 18px; line-height: 1.75; color: #f6e2ad; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cover-by { font-family: var(--urdu); font-size: 12px; line-height: 1.7; color: #e6dcc4cc; }
.cover-meta { position: absolute; left: 0; right: 12px; bottom: 7px; font-size: 11px; color: #f2e6c9b3; }
.book-cover.light { color: #3b3a33; }
.book-cover.light .cover-name { color: #3d3623; }
.book-cover.light .cover-by, .book-cover.light .cover-meta { color: #6b6553; }
.book-cover.light .cover-inner { border-color: #9a7b3c88; }
.book-cover.light .cover-orn { color: #9a7b3c; }
.cover-more { position: absolute; top: 6px; left: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #00000040; color: #fff; font-size: 16px; line-height: 1; }
.lib-note { text-align: center; margin-top: 18px; }

/* ——— scanning, in the book ——— */
.mic-row .side.end { justify-content: flex-end; }
.scan-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.scan-button { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 1.5px solid #c39a55; background: #fbf3e1; color: #7a5a22; box-shadow: 0 4px 14px #8a6a2f2e; }
.scan-button:active { background: var(--gold-soft); }
.scan-button svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scan-count { position: absolute; top: -4px; left: -4px; min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px; background: #b8412f; color: #fff; font-size: 12px; line-height: 22px; }
.scan-banner { max-width: 720px; margin: 0 auto 10px; display: flex; align-items: center; gap: 10px; background: #fff8e8; border: 1px solid #ecd9ac; border-radius: 14px; padding: 6px 12px; font-family: var(--urdu); font-size: 15px; line-height: 2; color: #5c4515; }
.scan-banner span { flex: 1; }
.scan-mark { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; padding: 6px 8px; border-radius: 12px; background: #f6f1e4; border: 1px solid #ebe1c9; cursor: pointer; }
.scan-mark img, .scan-mark .thumb { width: 34px; height: 46px; object-fit: cover; border-radius: 4px; background: #e8e1d0; box-shadow: 0 1px 3px #0003; flex: none; }
.scan-mark strong { font-family: var(--urdu); font-weight: 400; font-size: 15px; line-height: 1.8; color: #5c4515; }
.scan-mark .state { margin-right: auto; font-size: 12px; color: var(--muted); }
.scan-mark .state.done { color: #2f7a4d; }
.block + .scan-mark { margin-top: 18px; }
.scan-hint { font-family: var(--urdu); font-size: 15px; line-height: 2; color: #4d4a42; margin: 0 0 10px; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.scan-actions .button { flex: 1 1 auto; }
.button.big { padding: 14px 18px; font-size: 17px; border-radius: 14px; }
.scan-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.scan-item { border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.scan-item img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; background: #eee; }
.scan-item strong { font-family: var(--urdu); font-weight: 400; font-size: 14px; line-height: 1.7; }
.scan-item small { font-size: 11px; color: var(--muted); text-align: center; }
.scan-item.reading small, .scan-item.queued small { color: #8a6a2f; }
.scan-item.error small { color: var(--danger); }
.scan-item.reviewed small { color: #2f7a4d; }
.scan-item.reading img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ——— reviewing a page against its photo ——— */
dialog.review .sheet-head { gap: 8px; }
.review-nav { display: flex; gap: 6px; margin-right: auto; }
.review-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.review-photo { background: #2b2b28; border-radius: 12px; padding: 6px; overflow: auto; max-height: 46vh; flex: none; }
.review-photo img { display: block; width: 100%; height: auto; border-radius: 6px; cursor: zoom-in; }
.review-photo.zoomed img { width: 230%; max-width: none; cursor: zoom-out; }
.review-zoom { color: #c8c4b8; text-align: center; margin: 4px 0 0; }
.review-text .blocks { box-shadow: none; border: 1px solid var(--line); min-height: 0; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
.review-actions .button { flex: 1 1 auto; }
.button.danger-outline { color: var(--danger); border-color: #e6c9c4; background: #fff8f6; }

/* ——— print sheet, consent ——— */
.print-options label span { font-size: 14.5px; }
.consent-text { font-family: var(--urdu); font-size: 16px; line-height: 2.1; margin: 0 0 6px; }
.consent-points { font-family: var(--urdu); font-size: 14.5px; line-height: 2; color: #3f4a45; padding-right: 18px; margin: 0; }
#preview-status { margin-right: auto; margin-left: 10px; }

/* ——— the library: carry on with the last book ——— */
.continue { display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid #e6e0cf; border-radius: 18px; padding: 12px; margin: 4px 0 16px;
  box-shadow: 0 1px 2px #0000000a, 0 6px 18px #12352e0d; }
.continue-book { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 0; text-align: right; cursor: pointer; }
.continue-cover { width: 44px; height: 58px; flex: none; border-radius: 3px 8px 8px 3px; background: var(--cover, var(--green)); display: grid; place-items: center;
  box-shadow: inset 4px 0 0 #00000026, 0 2px 6px #0003; }
.continue-cover .cover-orn { color: #e9c988; font-size: 16px; }
.continue-info { display: flex; flex-direction: column; min-width: 0; }
.continue-info small { font-size: 12px; color: #8a6a2f; }
.continue-info strong { font-family: var(--urdu); font-weight: 400; font-size: 18px; line-height: 1.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-info span { font-size: 12.5px; color: var(--muted); }
.continue-actions { display: flex; gap: 8px; }
.continue-actions .button { flex: 1 1 0; }

/* ——— scanning: order, two pages to a photo ——— */
.order-toggle { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #3f4a45; margin: 10px 2px 0; }
.scan-item.repeated { border-color: #e2b45d; background: #fff9ec; }
.scan-item strong { text-align: center; }
.thumb { display: block; overflow: hidden; direction: ltr; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb.side-right img, .thumb.side-left img { width: 200%; max-width: none; }
.thumb.side-right img { margin-left: -100%; }
.scan-mark .thumb img { width: 100%; height: 100%; box-shadow: none; border-radius: 0; }
.scan-mark .thumb.side-right img, .scan-mark .thumb.side-left img { width: 200%; }

/* ——— reviewing: the page's half of the photo, its number, correcting by voice ——— */
.review-frame { direction: ltr; overflow: hidden; border-radius: 6px; }
.review-frame.side-right img, .review-frame.side-left img { width: 200%; max-width: none; }
.review-frame.side-right img { margin-left: -100%; }
.review-photo.zoomed .review-frame { overflow: visible; }
.review-photo.zoomed .review-frame img { width: 230%; margin-left: 0; }
.review-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; }
.review-number { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #3f4a45; }
.review-number input { width: 86px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font: inherit; font-size: 15px; text-align: center; background: #fff; }
.review-held { background: #fff8e8; border: 1px solid #ecd9ae; border-radius: 12px; padding: 8px 10px; margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.review-held p { flex: 1 1 220px; margin: 0; font-family: var(--urdu); font-size: 14px; line-height: 2; color: #5c4515; }
.review-voice { margin: 8px 0 0; font-family: var(--urdu); line-height: 2; }
.button.voice { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: #fff; border: 1.5px solid var(--green); color: var(--green);
  touch-action: none; -webkit-user-select: none; user-select: none; }
.button.voice svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.button.voice.listening { background: #b8412f; border-color: #b8412f; color: #fff; }
.button.voice.busy { background: #6b7a72; border-color: #6b7a72; color: #fff; }
.review-more { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
.review-more .button { flex: 1 1 auto; }

/* ——— the PDF sheet: one clear button, its progress, the file ——— */
.pdf-summary { font-family: var(--urdu); font-size: 14.5px; line-height: 2; color: #3f4a45; margin: 0 0 8px; }
.pdf-main { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 6px; }
.pdf-main > .button.big { width: 100%; }
.pdf-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.pdf-progress progress { flex: 1 1 100%; height: 6px; accent-color: var(--green); }
.pdf-progress span { flex: 1; font-size: 14px; }
.pdf-done { display: flex; flex-direction: column; gap: 8px; background: #eef7f0; border: 1px solid #cfe6d6; border-radius: 12px; padding: 10px 12px; }
.pdf-done strong { font-weight: 400; font-size: 14.5px; color: #24573b; line-height: 1.8; word-break: break-word; }
.pdf-done .row { margin: 0; gap: 8px; }
.actions.compact { margin: 8px 0; gap: 8px; }
.actions.compact .button { flex: 1 1 auto; }
.print-settings { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 4px; }
.print-settings summary { cursor: pointer; padding: 10px 2px; font-size: 15px; color: var(--ink); }
.print-settings summary small { color: #8a6a2f; font-size: 12px; margin-right: 6px; }

@media (min-width: 900px) {
  .page { padding: 24px; }
  .blocks { padding: 28px 32px 20px; }
  .block textarea { font-size: 24px; }
  .mic { width: 76px; height: 76px; }
  .mic-level { width: 76px; height: 76px; margin-left: -38px; }
  dialog.sheet { max-width: 640px; margin: auto; border-radius: 18px; }
  dialog.sheet.review { max-width: 1100px; }
  .review-body { flex-direction: row; }
  .review-photo { flex: 1 1 50%; max-height: none; }
  .review-text { flex: 1 1 50%; overflow-y: auto; }
  .lib-actions { gap: 16px; }
}

/* other files (Word, InPage, EPUB…) under the PDF, and the translation sheet */
.files { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 2px; }
.files h3 { margin-top: 12px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.file-button { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 6px; cursor: pointer; font: inherit; color: var(--ink); }
.file-button:hover, .file-button:focus-visible { border-color: var(--green); outline: none; }
.file-button strong { font-weight: 600; font-size: 14px; line-height: 1.5; }
.file-button small { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.files .field select { flex: 1; min-width: 0; }
.files .row { margin: 6px 0 0; gap: 8px; }
.translate-intro { font-family: var(--urdu); font-size: 15px; line-height: 2; color: #3f4a45; margin: 0 0 6px; }
#translate-dialog .button.big { width: 100%; margin-top: 6px; }
#translate-dialog .pdf-progress, #translate-dialog .pdf-done { margin-top: 10px; }
#translate-dialog select { flex: 1; min-width: 0; }
