:root {
  --burgundy: #850D3D;
  --burgundy-dark: #6B0A31;
  --magenta: #D91665;
  --toolbar: #202124;
  --bg: #FAFAFA;
  --list-bg: #E9E9EB;
  --text: #252525;
  --muted: #777777;
  --sep: #DDDDDD;
  --blank: #8A8A8A;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Didot", "Bodoni 72", "Bodoni MT", Georgia, "Times New Roman", serif;
  --bar-h: 48px;
  --tab-h: 52px;
  --reading-size: 1.3rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--toolbar);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  opacity: 0;
}
body.ready { opacity: 1; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 24px; height: 24px; display: block; }
:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }

/* ---------- layout ---------- */
.layout { display: flex; height: 100vh; height: 100dvh; }
#master, #detail { display: flex; flex-direction: column; min-width: 0; height: 100%; }
#master { flex: 1; background: var(--list-bg); }
#detail { flex: 1; background: var(--bg); display: none; }
body[data-view="reader"] #master, body[data-view="form"] #master { display: none; }
body[data-view="reader"] #detail, body[data-view="form"] #detail { display: flex; }
#reader, #form, #passage-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#reader[hidden], #form[hidden] { display: none; }

@media (min-width: 768px) {
  #master { flex: 0 0 320px; display: flex !important; border-right: 1px solid #c9c9cc; }
  #detail { display: flex !important; }
  #btn-back { visibility: hidden; }
}
@media (min-width: 1100px) { #master { flex-basis: 360px; } }

/* ---------- bars ---------- */
.bar {
  flex: 0 0 auto;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 6px 0;
}
.bar > :first-child { justify-self: start; }
.bar > :last-child { justify-self: end; }
.bar-brand { background: var(--burgundy); color: #fff; border-bottom: 1px solid var(--burgundy-dark); }
.bar-light { background: #F4F4F5; color: var(--text); border-bottom: 1px solid var(--sep); }
.bar-btn { padding: 10px 10px; font-size: 1rem; min-height: 44px; min-width: 44px; }
.bar-btn.strong { font-weight: 600; }
.bar-btn:disabled { opacity: .35; cursor: default; }
.bar-icon { display: grid; place-items: center; }
.bar-brand .bar-icon .icon { width: 18px; height: 18px; }
.logo {
  font-family: var(--serif); font-weight: 700; font-size: 34px; line-height: 1;
  letter-spacing: -1px; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.25);
  position: relative; user-select: none;
}
.logo::after { content: "\2019"; font-size: 14px; position: absolute; top: -1px; right: -7px; opacity: .8; }
.logo.ghost { color: rgba(0,0,0,.06); text-shadow: none; }
.logo.ghost::after { display: none; }
.vault-btn .icon { width: 22px; height: 22px; color: #555; }
.vault-btn[aria-pressed="true"] .icon { color: var(--magenta); }

/* ---------- search & list ---------- */
.search-wrap { padding: 8px; background: #D7D7DB; border-bottom: 1px solid #c4c4c8; }
#search {
  width: 100%; height: 32px; border: 1px solid #c2c2c6; border-radius: 16px;
  padding: 0 12px 0 30px; font-size: .95rem; background: #fff no-repeat 10px 50% / 13px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='6.5' cy='6.5' r='5' fill='none' stroke='%23999' stroke-width='2'/%3E%3Cpath d='M10.5 10.5L15 15' stroke='%23999' stroke-width='2'/%3E%3C/svg%3E");
  -webkit-appearance: none; appearance: none; outline: none;
}
#search:focus { border-color: var(--magenta); }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; background: var(--list-bg); }
.list:empty { flex: 0 0 auto; }
.row { display: flex; align-items: stretch; background: #F7F7F8; border-bottom: 1px solid var(--sep); }
.row.selected { background: #fff; box-shadow: inset 3px 0 0 var(--magenta); }
.row-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; column-gap: 8px; padding: 10px 10px 9px 14px; color: inherit; text-decoration: none; }
.row-main:active { background: #ececef; }
.preview {
  font-size: .95rem; line-height: 1.3; color: var(--text);
  white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.meta {
  grid-column: 1; margin-top: 3px; font-size: .66rem; letter-spacing: .02em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chev { grid-column: 2; grid-row: 1 / span 2; align-self: center; width: 8px; height: 13px; color: #c7c7cc; }
.row-minus, .row-confirm { display: none; }
.editing .row-minus {
  display: block; flex: 0 0 40px; position: relative;
}
.editing .row-minus::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border-radius: 50%; background: #E5342F; transition: transform .2s;
}
.editing .row-minus::after { content: ""; position: absolute; left: 17px; top: 50%; width: 12px; height: 2px; margin-top: -1px; background: #fff; transition: transform .2s; }
.editing .armed .row-minus::before, .editing .armed .row-minus::after { transform: rotate(-90deg); }
.editing .row .chev { visibility: hidden; }
.editing .armed .row-confirm { display: block; background: #E5342F; color: #fff; padding: 0 16px; font-size: .95rem; }
.editing .row-main { pointer-events: none; }
.list-empty { margin: 24px; color: var(--muted); font-size: .95rem; line-height: 1.4; text-align: center; }

.tabbar {
  flex: 0 0 auto; display: flex; background: var(--toolbar);
  min-height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #000;
}
.tabbar button { flex: 1; display: grid; place-items: center; color: #6e6e72; min-height: var(--tab-h); }
.tabbar button[aria-selected="true"] { color: var(--magenta); }
.tabbar .icon { width: 26px; height: 26px; }

/* ---------- empty detail ---------- */
.empty-detail { flex: 1; display: grid; place-items: center; color: rgba(0,0,0,.05); }
.empty-detail .icon { width: min(48%, 360px); height: auto; aspect-ratio: 1; }
.empty-detail[hidden] { display: none; }

/* ---------- reader ---------- */
.reader-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 18px 32px; }
.passage {
  max-width: 38em; margin: 0 auto;
  font-size: var(--reading-size); line-height: 1.55; letter-spacing: .005em;
  white-space: pre-wrap; overflow-wrap: break-word; color: var(--text);
}
@media (min-width: 768px) { .reader-scroll { padding: 36px 48px 48px; } .passage { font-size: calc(var(--reading-size) * 1.08); } }

/* concealed word: initial stays, remainder keeps its exact glyph width
   (transparent text) and is drawn as an underline blank — so no reflow. */
.w.h .r {
  color: transparent;
  text-decoration: underline; text-decoration-color: var(--blank);
  text-decoration-thickness: 1px; text-underline-offset: .18em; text-decoration-skip-ink: none;
  -webkit-user-select: none; user-select: none;
}
.w.h { cursor: pointer; }
.w.h.peek .r { color: var(--magenta); text-decoration-color: transparent; }
/* after a peek the word eases back into its blank instead of vanishing */
.w.h.unpeek .r { transition: color 1.4s ease, text-decoration-color 1.4s ease; }


.attribution { max-width: 38em; margin: 22px auto 0; font-size: .72rem; color: var(--muted); }
.attribution:not(:empty) { display: block; }
.attribution, .attribution a {
  display: table; padding: 3px 7px; border: 1px solid var(--sep); background: #f2f2f3; color: var(--muted); text-decoration: none;
}
.attribution a { padding: 0; border: 0; background: none; text-decoration: underline; text-decoration-color: #bbb; }
.attribution[hidden] { display: none; }

.toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--toolbar); color: #fff;
  min-height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 14px env(safe-area-inset-bottom) 6px;
}
.level { font-size: .8rem; color: #9a9aa0; min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

#slider {
  --pct: 0%;
  flex: 1; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
}
#slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--magenta) var(--pct), #4a4a4f var(--pct)); }
#slider::-moz-range-track { height: 4px; border-radius: 2px; background: #4a4a4f; }
#slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--magenta); }
#slider::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
#slider::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* ---------- form ---------- */
#form { background: #EFEFF1; }
.fields { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.fields input, .fields textarea {
  width: 100%; border: 1px solid #DADADD; background: #F9F9FA; padding: 11px 12px; font-size: 1rem; border-radius: 0; outline: none;
  -webkit-appearance: none; appearance: none;
}
.fields input:focus, .fields textarea:focus { border-color: #b9b9bd; background: #fff; }
.fields ::placeholder { color: #b0b0b4; }
.fields textarea { flex: 1 1 auto; min-height: 8em; resize: none; line-height: 1.45; font-size: 1.05rem; }
@media (min-width: 768px) { .fields { max-width: 46em; width: 100%; margin: 0 auto; padding: 20px; } }

/* ---------- vault flash ---------- */
.vault-flash { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(40,40,44,.55); z-index: 10; pointer-events: none; }
.vault-flash[hidden] { display: none; }
.vault-flash svg { width: min(62vw, 300px); height: min(62vw, 300px); color: var(--magenta); }
.vault-flash.run { animation: flash-bg 1.1s ease forwards; }
.vault-flash.run svg { animation: flash-safe 1.1s ease forwards; }
@keyframes flash-bg { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes flash-safe { 0% { transform: scale(.7); } 18% { transform: scale(1); } 70% { transform: scale(1); } 100% { transform: scale(.85); } }
@media (prefers-reduced-motion: reduce) { .vault-flash.run, .vault-flash.run svg { animation-duration: .6s; } }

/* ---------- scripts ---------- */
/* each paragraph takes its own direction, so Arabic/Urdu/Hebrew lines run right-to-left
   and mixed passages still lay out correctly */
.passage { unicode-bidi: plaintext; text-align: start; }
.preview { unicode-bidi: plaintext; text-align: start; }
:root { --arabic: "Noto Naskh Arabic", "Geeza Pro", "Damascus", "Segoe UI", "Tahoma", sans-serif;
        --urdu: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", var(--arabic);
        --hebrew: "Noto Serif Hebrew", "Noto Sans Hebrew", "Times New Roman", "Arial Hebrew", serif;
        --bengali: "Noto Serif Bengali", "Noto Sans Bengali", "Kohinoor Bangla", "Bangla Sangam MN", "Nirmala UI", sans-serif;
        --tamil: "Noto Serif Tamil", "Noto Sans Tamil", "Tamil Sangam MN", "Nirmala UI", sans-serif;
        --cjk: "Noto Serif TC", "Noto Serif SC", "Songti TC", "Songti SC", "PingFang TC", "PingFang SC", "Noto Serif CJK TC", "Noto Serif CJK SC", serif;
        --deva: "Noto Sans Devanagari", "Kohinoor Devanagari", "Devanagari Sangam MN", "Nirmala UI", sans-serif; }
[lang="ar"] { font-family: var(--arabic); }
[lang="ur"] { font-family: var(--urdu); }
[lang="hi"] { font-family: var(--deva); }
.passage[lang="ar"] { line-height: 1.9; }
.passage[lang="ur"] { line-height: 2.4; }
.passage[lang="hi"] { line-height: 1.8; }
.preview[lang="ur"] { line-height: 1.9; }
/* blanks sit a little lower under scripts with deep descenders */
.passage[lang="ar"] .w.h .r, .passage[lang="ur"] .w.h .r { text-underline-offset: .45em; }
.passage[lang="hi"] .w.h .r { text-underline-offset: .3em; }
#btn-save { grid-column: 3; }

/* ======================================================================
   Folio design (chosen 2026-12-03): the passage as a printed page —
   serif text, burgundy ink, controls pushed to the margins.
   ====================================================================== */

:root { --sans: "Inter", -apple-system, system-ui, sans-serif; --serif-text: "Literata", "New York", ui-serif, Georgia, serif; --burgundy:#7A1238; --bg:#F6F6F3; --list-bg:#F6F6F3; --sep:#E2E1DC; --text:#1D1C1A; --muted:#86847E; --toolbar:#F6F6F3; }
body { background:#F6F6F3; }
.bar-brand { background:#7A1238; border-bottom:0; min-height:calc(56px + env(safe-area-inset-top)); }
.bar-brand .logo { font-family: var(--serif-text); font-weight:600; font-size:30px; letter-spacing:0; }
.bar-brand .logo::after { display:none; }
.search-wrap { background:#F6F6F3; border-bottom:1px solid var(--sep); padding:12px 16px; }
#search { background-color:transparent; border:0; border-bottom:1px solid #CFCDC6; border-radius:0; padding-left:26px; background-position:2px 50%; }
.row { background:#F6F6F3; border-bottom:1px solid var(--sep); }
.row.selected { background:#EFEDE8; box-shadow:inset 3px 0 0 #7A1238; }
.row-main { padding:16px 16px 14px 18px; }
.preview { font-family: var(--serif-text); font-size:1.08rem; line-height:1.4; }
.meta { display:flex; gap:8px; font-size:.68rem; letter-spacing:.08em; color:#86847E; }
.chev { display:none; }
.tabbar { background:#F6F6F3; border-top:1px solid var(--sep); }
.tabbar button { color:#B3B1AA; }
.tabbar button[aria-selected="true"] { color:#7A1238; }
#detail { background:#F6F6F3; }
.bar-light { background:#F6F6F3; border-bottom:0; }
.bar-light .bar-btn { color:#7A1238; }
.logo.ghost { visibility:hidden; }
.reader-scroll { padding-top:28px; }
.passage { font-family: var(--serif-text); font-size:1.5rem; line-height:1.6; font-weight:400; color:#1D1C1A; }
.w.h .r { text-decoration-color:#7A1238; text-decoration-thickness:1px; text-underline-offset:.22em; }
.attribution, .attribution a { background:none; border:0; padding:0; font-family: var(--sans); font-size:.72rem; letter-spacing:.1em; text-transform:uppercase; color:#86847E; }
.attribution { border-top:1px solid #CFCDC6; padding-top:12px; margin-top:28px; display:block; }
.toolbar { background:#F6F6F3; color:#7A1238; border-top:1px solid var(--sep); gap:16px; }
.toolbar .bar-btn { color:#7A1238; }
#slider::-webkit-slider-runnable-track { height:1px; background:linear-gradient(to right, #7A1238 var(--pct), #CFCDC6 var(--pct)); }
#slider::-webkit-slider-thumb { width:18px; height:18px; margin-top:-9px; background:#7A1238; box-shadow:none; }
.level { font-family: var(--serif-text); font-size:1.4rem; color:#7A1238; min-width:2.8em; }
#form { background:#F6F6F3; }
.fields input, .fields textarea { background:transparent; border:0; border-bottom:1px solid #CFCDC6; }
.fields textarea { font-family: var(--serif-text); font-size:1.2rem; border:1px solid #E2E1DC; background:#FBFBF9; }
.fields input:focus { background:transparent; border-bottom-color:#7A1238; }

.empty-detail { color: rgba(122,18,56,.06); }
.editing .armed .row-confirm { background:#B3261E; }

/* keep script-specific faces under Folio's serif */
.passage[lang="ar"], .preview[lang="ar"] { font-family: var(--arabic); }
.passage[lang="ur"], .preview[lang="ur"] { font-family: var(--urdu); }
.passage[lang="hi"], .preview[lang="hi"] { font-family: var(--deva); }

.passage[lang="fa"], .preview[lang="fa"] { font-family: var(--arabic); }
.passage[lang="he"], .preview[lang="he"], .passage[lang="yi"], .preview[lang="yi"] { font-family: var(--hebrew); }
.passage[lang="bn"], .preview[lang="bn"] { font-family: var(--bengali); }
.passage[lang="ta"], .preview[lang="ta"] { font-family: var(--tamil); }
.passage[lang="zh"], .preview[lang="zh"], .passage[lang="ja"], .preview[lang="ja"] { font-family: var(--cjk); }
.passage[lang="fa"] { line-height: 2; }
.passage[lang="he"], .passage[lang="yi"] { line-height: 1.8; }
.passage[lang="bn"], .passage[lang="ta"] { line-height: 1.85; }
.passage[lang="zh"], .passage[lang="ja"] { line-height: 2; letter-spacing: .08em; }
.passage[lang="fa"] .w.h .r { text-underline-offset: .45em; }
.passage[lang="bn"] .w.h .r, .passage[lang="ta"] .w.h .r { text-underline-offset: .3em; }

/* ---------- font picker ---------- */
.bar-right { display: flex; align-items: center; gap: 2px; justify-self: end; }
.font-btn { font-family: var(--serif-text); font-size: 1.05rem; color: var(--burgundy, #7A1238); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(29,28,26,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: 100%; max-width: 520px; max-height: 80vh; overflow-y: auto; background: #F6F6F3; border-radius: 14px 14px 0 0;
  padding: 6px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.15); }
@media (min-width: 768px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 14px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #E2E1DC; }
.sheet-head h2 { margin: 0; font: 600 .78rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: #86847E; }
.sheet-head .bar-btn { color: #7A1238; font-weight: 600; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px; border-bottom: 1px solid #E2E1DC; }
.sheet-row[hidden] { display: none; }
.sheet-label { font: 500 .95rem var(--sans); color: #1D1C1A; }
.stepper { display: flex; align-items: center; border: 1px solid #CFCDC6; border-radius: 10px; overflow: hidden; }
.stepper button { width: 48px; height: 40px; font-family: var(--serif-text); color: #7A1238; font-size: 1.05rem; }
.stepper button:disabled { color: #CFCDC6; cursor: default; }
.stepper span#size-value { min-width: 4em; text-align: center; font: 500 .9rem var(--sans); font-variant-numeric: tabular-nums; border-inline: 1px solid #CFCDC6; line-height: 40px; }
.segmented { display: flex; border: 1px solid #CFCDC6; border-radius: 10px; overflow: hidden; }
.segmented button { display: grid; justify-items: center; padding: 4px 16px 6px; min-width: 92px; color: #1D1C1A; }
.segmented button + button { border-inline-start: 1px solid #CFCDC6; }
.segmented button span { font-size: 1.25rem; line-height: 2.3; }
.segmented button small { font: 500 .7rem var(--sans); letter-spacing: .04em; color: #86847E; }
.segmented button[aria-checked="true"] { background: #7A1238; color: #fff; }
.segmented button[aria-checked="true"] small { color: #F2D6E0; }

/* line height and blank position follow the chosen style of script */
.passage[data-font="naskh"] { line-height: 1.95; }
.passage[data-font="kufi"] { line-height: 1.9; }
.passage[data-font="nastaliq"] { line-height: 2.5; }
.passage[data-font="indic"] { line-height: 1.85; }
.passage[data-font="naskh"] .w.h .r, .passage[data-font="kufi"] .w.h .r { text-underline-offset: .45em; }
.passage[data-font="nastaliq"] .w.h .r { text-underline-offset: .6em; }
.preview[data-font="nastaliq"] { line-height: 2; }

/* text size: one setting for every passage, in every script */
:root { --text-scale: 1; }
.reader-scroll .passage { font-size: calc(1.5rem * var(--text-scale)); }
@media (min-width: 768px) { .reader-scroll .passage { font-size: calc(1.62rem * var(--text-scale)); } }

/* ---------- author and year on one row ---------- */
.field-row { display: flex; gap: 12px; }
.field-row #f-author { flex: 1 1 auto; min-width: 0; }
.field-row #f-year { flex: 0 0 7.5em; }

/* ---------- folders: a quiet chip row, shown only once a folder exists ---------- */
.folders { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; border-bottom: 1px solid var(--sep); background: #F6F6F3;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.folders::-webkit-scrollbar { display: none; }
.folders[hidden] { display: none; }
.folder-chip { flex: 0 0 auto; padding: 5px 12px; border: 1px solid #CFCDC6; border-radius: 999px; font: 500 .8rem var(--sans); color: #4A4844; background: transparent; white-space: nowrap; }
.folder-chip[aria-pressed="true"] { background: #7A1238; border-color: #7A1238; color: #fff; }

/* ---------- read aloud ---------- */
.speak-btn[aria-pressed="true"] { color: #fff; background: #7A1238; border-radius: 8px; }
.segmented.compact button { min-width: 76px; padding: 4px 14px; }
.segmented.compact button span { font: 500 .9rem var(--sans); line-height: 2.2; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; background: #1D1C1A; color: #fff; font: 500 .88rem/1.4 var(--sans); text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast[hidden] { display: none; }

/* ---------- voice picker and delete ---------- */
.voice-select { max-width: 58%; font: 500 .9rem var(--sans); color: #1D1C1A; padding: 8px 10px; border: 1px solid #CFCDC6; border-radius: 10px; background: #FBFBF9; }
.sheet-note { margin: 0; padding: 8px 2px 12px; font: .8rem/1.45 var(--sans); color: #86847E; border-bottom: 1px solid #E2E1DC; }
.sheet-note[hidden] { display: none; }
.delete-btn { align-self: center; margin-top: 4px; padding: 10px 18px; font: 500 .95rem var(--sans); color: #B3261E; border: 1px solid rgba(179,38,30,.35); border-radius: 10px; background: transparent; }
.delete-btn.armed { background: #B3261E; color: #fff; border-color: #B3261E; }
.delete-btn[hidden] { display: none; }

/* ---------- swipe to delete, hold to reorder ---------- */
.row { position: relative; overflow: hidden; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.row-main { position: relative; z-index: 1; background: inherit; cursor: pointer; will-change: transform; }
.row.selected { box-shadow: none; }
.row.selected .row-main { box-shadow: inset 3px 0 0 #7A1238; }
.swipe-actions { position: absolute; top: 0; bottom: 0; right: 0; display: flex; visibility: hidden; }
.row.swiping .swipe-actions { visibility: visible; }
.swipe-actions button { min-width: 84px; padding: 0 16px; color: #fff; font: 500 .92rem var(--sans); }
.swipe-delete { background: #B3261E; }
.swipe-unvault { background: #8E8C86; }
.editing .swipe-actions { display: none; }
.reordering .row { transition: transform .18s ease; }
.reordering .row.dragging { transition: none; z-index: 5; overflow: visible; box-shadow: 0 10px 28px rgba(0,0,0,.18); }
.row.dragging .row-main { background: #FFFFFF; }
.toast-undo { margin-inline-start: 10px; padding: 2px 4px; color: #F2B8CB; font: 600 .88rem var(--sans); text-decoration: underline; }

/* reorder mode: a banner over the list and a grip on every row, without moving any text */
.grip { display: none; position: absolute; top: 0; bottom: 0; right: 0; width: 64px; align-items: center; justify-content: flex-end; padding-right: 14px;
  color: #B3B1AA; background: linear-gradient(to right, rgba(246,246,243,0), #F6F6F3 45%); pointer-events: none; }
.grip .icon { width: 22px; height: 22px; }
.reordering .grip { display: flex; }
.row.dragging .grip { color: #7A1238; background: linear-gradient(to right, rgba(255,255,255,0), #fff 45%); }
.row.selected .grip { background: linear-gradient(to right, rgba(239,237,232,0), #EFEDE8 45%); }
.row.dragging .row-main { box-shadow: inset 3px 0 0 #7A1238; }
#master { position: relative; }
.reorder-banner { position: absolute; left: 50%; transform: translateX(-50%); z-index: 6; top: 8px; display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 10px; border-radius: 999px; background: #7A1238; color: #fff; font: 500 .82rem var(--sans); white-space: nowrap;
  box-shadow: 0 4px 14px rgba(122,18,56,.3); pointer-events: none; animation: banner-in .18s ease-out; }
.reorder-banner[hidden] { display: none; }
.reorder-banner .icon { width: 18px; height: 18px; }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .reorder-banner { animation: none; } }

/* ---------- word lookup ---------- */
.passage { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.word-sheet { max-height: 70vh; }
.word-title { margin: 14px 2px 2px; font: 400 2rem/1.3 var(--serif-text); color: #1D1C1A; }
.word-title[lang="ar"], .word-title[lang="fa"], .word-title[lang="ur"] { font-family: "MV Noto Naskh Arabic", var(--arabic), serif; line-height: 1.8; }
.word-title[lang="bn"] { font-family: "MV Noto Serif Bengali", var(--bengali), serif; }
.word-body { padding: 0 2px 6px; font: .95rem/1.5 var(--sans); color: #1D1C1A; }
.word-lang { margin: 0 0 8px; font: 500 .72rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: #86847E; }
.word-pos { margin: 12px 0 2px; font: italic 400 1rem var(--serif-text); color: #7A1238; }
.word-defs { margin: 0; padding-inline-start: 1.3em; }
.word-defs li { margin: 3px 0; }
.word-status { margin: 10px 0; color: #86847E; }
.word-foot { margin: 6px 2px 0; padding-top: 10px; border-top: 1px solid #E2E1DC; font: 500 .85rem var(--sans); }
.word-foot a { color: #7A1238; text-decoration: none; }

/* ---------- backup links at the foot of the Library ---------- */
.list-foot { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 22px 16px 28px; color: #B3B1AA; font: 500 .8rem var(--sans); }
.list-foot button { color: #7A1238; font: inherit; padding: 6px 2px; }
