/* كتب الصفوف الثانويه — RTL design system: light / dark / warm-reading themes */
@font-face { font-family: 'Cairo'; src: url('../fonts/Cairo-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../fonts/Cairo-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../fonts/Cairo-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../fonts/Cairo-900.woff2') format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Amiri'; src: url('../fonts/Amiri-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Amiri'; src: url('../fonts/Amiri-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'NotoNaskh'; src: url('../fonts/NotoNaskh-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'NotoNaskh'; src: url('../fonts/NotoNaskh-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Scheherazade'; src: url('../fonts/Scheherazade-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Scheherazade'; src: url('../fonts/Scheherazade-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Almarai'; src: url('../fonts/Almarai-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Almarai'; src: url('../fonts/Almarai-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Changa'; src: url('../fonts/Changa-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Changa'; src: url('../fonts/Changa-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'ElMessiri'; src: url('../fonts/ElMessiri-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'ElMessiri'; src: url('../fonts/ElMessiri-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

/* 8 selectable Arabic reading fonts (all vendored locally — work offline) */
[data-font="cairo"] { --font-body: 'Cairo', 'Tajawal', system-ui, sans-serif; }
[data-font="tajawal"] { --font-body: 'Tajawal', 'Cairo', system-ui, sans-serif; }
[data-font="amiri"] { --font-body: 'Amiri', 'Cairo', serif; }
[data-font="notonaskh"] { --font-body: 'NotoNaskh', 'Amiri', serif; }
[data-font="scheherazade"] { --font-body: 'Scheherazade', 'Amiri', serif; }
[data-font="almarai"] { --font-body: 'Almarai', 'Cairo', sans-serif; }
[data-font="changa"] { --font-body: 'Changa', 'Cairo', sans-serif; }
[data-font="elmessiri"] { --font-body: 'ElMessiri', 'Cairo', sans-serif; }
.font-option { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; margin-bottom: 8px; transition: border-color .15s, background .15s; }
.font-option:hover { border-color: var(--primary); }
.font-option.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.font-option .fo-name { font-size: 12px; color: var(--muted); }

:root {
  --font-head: 'Cairo', 'Tajawal', system-ui, sans-serif;
  --font-body: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --bg: #f6f7fb; --bg-soft: #ffffff; --card: #ffffff; --text: #0f172a; --muted: #64748b;
  --primary: #4f46e5; --primary-2: #7c3aed; --accent: #f59e0b; --ok: #10b981; --danger: #ef4444;
  --border: #e2e8f0; --shadow: 0 6px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .16);
  --radius: 18px; --radius-sm: 12px;
}
[data-theme="dark"] {
  --bg: #0b1220; --bg-soft: #111a2e; --card: #16203a; --text: #e8eefc; --muted: #94a3b8;
  --border: #243252; --shadow: 0 6px 24px rgba(0, 0, 0, .4); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
}
[data-theme="warm"] {
  --bg: #f7f1e6; --bg-soft: #fdf9f0; --card: #fffaf0; --text: #3f3222; --muted: #8a7a5f;
  --primary: #b45309; --primary-2: #d97706; --border: #eadfc8;
  --shadow: 0 6px 24px rgba(120, 90, 40, .10); --shadow-lg: 0 18px 48px rgba(120, 90, 40, .2);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body); background: var(--bg); color: var(--text);
  min-height: 100vh; min-height: 100dvh; transition: background .35s, color .35s;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { font-family: var(--font-head); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
::selection { background: rgba(79, 70, 229, .25); }

/* ---------- boot splash ---------- */
.boot-splash { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; height: 100dvh; gap: 14px; background: linear-gradient(160deg, #0f172a, #312e81); color: #fff; }
.boot-logo { font-size: 56px; animation: float 2.2s ease-in-out infinite; }
.boot-name { font-family: var(--font-head); font-weight: 800; font-size: 22px; }
.boot-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- layout ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 0 16px 170px; animation: fadeUp .45s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: 12px 4px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 800; font-size: 17px; cursor: pointer; }
.brand-badge { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: var(--shadow); }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  display: grid; place-items: center; font-size: 18px; cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.icon-btn:active { transform: scale(.94); }

/* ---------- hero ---------- */
.hero {
  margin-top: 18px; border-radius: 26px; padding: 30px 22px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 55%, #7c3aed 100%);
  box-shadow: var(--shadow-lg);
}
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; }
.hero::before { width: 220px; height: 220px; background: #f59e0b; top: -80px; inset-inline-start: -60px; }
.hero::after { width: 260px; height: 260px; background: #22d3ee; bottom: -120px; inset-inline-end: -70px; }
.hero h1 { font-size: clamp(22px, 5.4vw, 34px); font-weight: 900; position: relative; z-index: 1; }
.hero p { margin-top: 8px; opacity: .88; font-size: clamp(13px, 3.4vw, 16px); position: relative; z-index: 1; max-width: 520px; }
.hero .hero-books { position: absolute; inset-inline-end: 18px; top: 50%; transform: translateY(-50%); font-size: 64px; opacity: .9; z-index: 0; animation: float 3.4s ease-in-out infinite; }

/* ---------- search ---------- */
.searchbar { display: flex; gap: 8px; margin-top: 18px; position: relative; z-index: 1; }
.searchbar input {
  flex: 1; border: none; border-radius: 16px; padding: 14px 18px; font-size: 15px; background: rgba(255,255,255,.96);
  color: #0f172a; outline: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}
.searchbar input:focus { box-shadow: inset 0 0 0 2px #fbbf24; }
.searchbar button {
  border: none; border-radius: 16px; padding: 0 20px; font-weight: 700; cursor: pointer;
  background: #fbbf24; color: #1e1b4b; transition: transform .15s;
}
.searchbar button:active { transform: scale(.95); }

/* ---------- sections ---------- */
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 2px 14px; font-size: 19px; font-weight: 800; }
.section-title .bar { width: 5px; height: 22px; border-radius: 4px; background: linear-gradient(var(--primary), var(--primary-2)); }
.section-title .more { margin-inline-start: auto; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }

/* ---------- library cards ---------- */
.libs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 10px; }
.lib-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 8px; text-align: center; cursor: pointer; transition: transform .18s, box-shadow .18s; }
.lib-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.lib-card .l-icon { font-size: 28px; }
.lib-card .l-name { font-weight: 800; font-size: 13px; margin-top: 7px; font-family: var(--font-head); }
.lib-card .l-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.grade-chips { display: flex; gap: 8px; margin: 16px 0 4px; flex-wrap: wrap; }
.grade-chip { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 7px 16px; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: all .2s; }
.grade-chip.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }

/* ---------- grade cards ---------- */
.grades-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.grade-card {
  border-radius: var(--radius); padding: 22px 16px; color: #fff; cursor: pointer; position: relative; overflow: hidden;
  min-height: 132px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  transition: transform .2s, box-shadow .2s; box-shadow: var(--shadow);
}
.grade-card:hover { transform: translateY(-4px) scale(1.015); box-shadow: var(--shadow-lg); }
.grade-card:active { transform: scale(.97); }
.grade-card .g-emoji { font-size: 34px; position: absolute; top: 14px; inset-inline-start: 16px; }
.grade-card .g-name { font-family: var(--font-head); font-weight: 800; font-size: 17px; }
.grade-card .g-meta { font-size: 12px; opacity: .85; }
.grade-card::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120px 120px at 85% 15%, rgba(255,255,255,.28), transparent 70%); }
.g1 { background: linear-gradient(150deg, #0ea5e9, #2563eb); }
.g2 { background: linear-gradient(150deg, #8b5cf6, #6d28d9); }
.g3 { background: linear-gradient(150deg, #f59e0b, #ea580c); }

/* ---------- book cards ---------- */
.books-row { display: grid; grid-auto-flow: column; grid-auto-columns: 156px; gap: 13px; overflow-x: auto; padding: 6px 2px 16px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.books-row::-webkit-scrollbar { display: none; }
.book-card { scroll-snap-align: start; background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; cursor: pointer; transition: transform .18s, box-shadow .18s; box-shadow: 0 4px 14px rgba(15,23,42,.07); }
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.book-cover { height: 190px; display: grid; place-items: center; font-size: 40px; color: #fff; position: relative; background: #1e293b; }
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.book-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(2,6,23,.45)); pointer-events: none; }
.book-cover .kind-chip { z-index: 2; }
.book-cover .cover-ic { z-index: 1; }
.book-cover .kind-chip { position: absolute; top: 8px; inset-inline-start: 8px; font-size: 10px; font-weight: 700; background: rgba(0,0,0,.32); padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px); }
.book-info { padding: 10px 12px 12px; }
.book-title { font-size: 13px; font-weight: 700; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 39px; }
.book-sub { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }
.stars { color: var(--accent); font-size: 12px; letter-spacing: 1px; }

/* ---------- subjects / tabs ---------- */
.tabs { display: flex; gap: 8px; margin: 18px 0 4px; background: var(--bg-soft); border: 1px solid var(--border); padding: 5px; border-radius: 14px; }
.tab { flex: 1; text-align: center; padding: 9px 4px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); transition: all .2s; border: none; background: transparent; }
.tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: var(--shadow); }
.subjects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.subject-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; cursor: pointer; transition: transform .18s, box-shadow .18s; display: flex; align-items: center; gap: 12px; }
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.subject-card .s-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 23px; background: color-mix(in srgb, var(--primary) 12%, transparent); }
.subject-card .s-name { font-weight: 700; font-size: 14px; }
.subject-card .s-count { font-size: 11px; color: var(--muted); margin-top: 3px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.list-item:hover { transform: translateX(-3px); box-shadow: var(--shadow); }
.list-item .li-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; color: #fff; flex-shrink: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; font-size: 14px; }
.list-item .li-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.list-item .li-meta { font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 14px; padding: 13px 20px; font-weight: 700; font-size: 14px; cursor: pointer; transition: transform .15s, box-shadow .15s, opacity .15s; }
.btn:active { transform: scale(.96); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: var(--shadow); }
.btn-ghost { background: var(--card); border: 1px solid var(--border); }
.btn-danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }

/* ---------- book details ---------- */
.details-head { display: flex; gap: 18px; margin-top: 20px; }
.details-cover { width: 140px; height: 196px; border-radius: 14px; display: grid; place-items: center; font-size: 52px; color: #fff; flex-shrink: 0; box-shadow: var(--shadow-lg); overflow: hidden; position: relative; }
.details-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.details-head h2 { font-size: 20px; margin-bottom: 6px; }
.details-meta { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.details-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.progress-track { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ok), #34d399); transition: width .2s; }
.dl-row { display: flex; align-items: center; gap: 10px; }
.dl-row .progress-track { flex: 1; }
.dl-row .pct { font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; }

/* ---------- reader ---------- */
.reader-wrap { position: fixed; inset: 0; background: #0b1220; z-index: 100; display: flex; flex-direction: column; }
.reader-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: #111a2e; color: #e8eefc; flex-wrap: wrap; }
.reader-toolbar .rt-title { flex: 1; min-width: 120px; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-toolbar button { background: #1e293b; color: #e8eefc; border: 1px solid #334155; border-radius: 10px; padding: 7px 11px; font-size: 13px; cursor: pointer; }
.reader-toolbar button.active { background: var(--primary); border-color: var(--primary); }
.reader-toolbar input[type="text"], .reader-toolbar input[type="number"] { background: #0f172a; border: 1px solid #334155; color: #e8eefc; border-radius: 10px; padding: 7px 10px; font-size: 13px; width: 130px; }
.reader-stage { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 14px 8px 24px; gap: 10px; }
.reader-stage canvas { max-width: 100%; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; }
.reader-stage.eye-comfort canvas { filter: sepia(.35) brightness(.92); }
.reader-stage.night canvas { filter: invert(.92) hue-rotate(180deg) brightness(.9); }
.reader-footer { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #111a2e; color: #cbd5e1; font-size: 12px; }
.reader-footer input[type="range"] { flex: 1; accent-color: var(--primary); }
.mark-pop { position: fixed; bottom: 84px; inset-inline: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; z-index: 110; box-shadow: var(--shadow-lg); }
.mark-pop textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px; background: var(--bg-soft); resize: vertical; min-height: 60px; }

/* ---------- offline library ---------- */
.storage-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state .e-emoji { font-size: 52px; margin-bottom: 12px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

/* ---------- forms / modal ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea { border: 1px solid var(--border); background: var(--bg-soft); border-radius: 12px; padding: 11px 14px; outline: none; transition: box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 45%, transparent); }
.modal-back { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); backdrop-filter: blur(3px); z-index: 200; display: grid; place-items: center; padding: 18px; animation: fadeUp .25s ease both; }
.modal { background: var(--card); border-radius: 20px; padding: 22px; width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 14px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 60; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); cursor: pointer; padding: 4px 12px; border-radius: 12px; transition: color .2s, transform .15s; border: none; background: none; }
.nav-item .n-icon { font-size: 21px; transition: transform .2s; }
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-item.active .n-icon { transform: translateY(-2px) scale(1.12); }

/* ---------- WhatsApp floating button ---------- */
.wa-fab-wrap { position: fixed; bottom: calc(78px + env(safe-area-inset-bottom)); inset-inline-end: 12px; z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.wa-credit { font-size: 10.5px; font-weight: 700; color: var(--muted); background: color-mix(in srgb, var(--card) 90%, transparent); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(6px); direction: ltr; }
.wa-fab { width: 56px; height: 56px; border-radius: 50%; background: #25d366; display: grid; place-items: center; box-shadow: 0 10px 26px rgba(37, 211, 102, .45); cursor: pointer; transition: transform .18s; border: none; }
.wa-fab:hover { transform: scale(1.08) rotate(6deg); }
.wa-fab svg { width: 30px; height: 30px; fill: #fff; }

/* ---------- toast ---------- */
.toast { position: fixed; top: 14px; inset-inline: 16px; margin: 0 auto; max-width: 420px; background: #0f172a; color: #fff; border-radius: 14px; padding: 12px 18px; font-size: 14px; z-index: 300; box-shadow: var(--shadow-lg); animation: toastIn .3s ease both; text-align: center; }
.toast.ok { background: linear-gradient(135deg, #059669, #10b981); }
.toast.err { background: linear-gradient(135deg, #dc2626, #ef4444); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

/* ---------- skeletons ---------- */
.skel { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--border) 25%, var(--bg-soft) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- admin table ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: start; }
.admin-table th { color: var(--muted); font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card .num { font-size: 26px; font-weight: 900; font-family: var(--font-head); color: var(--primary); }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

.badge-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }
.offline-banner { background: linear-gradient(135deg, #b45309, #d97706); color: #fff; text-align: center; font-size: 12.5px; font-weight: 700; padding: 7px 12px; border-radius: 12px; margin-top: 10px; }

@media (min-width: 720px) {
  .details-actions { flex-direction: row; }
  .hero .hero-books { font-size: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Library visual revision: editorial header, compact subject tiles, quiet surfaces. */
:root { --primary:#226555; --primary-2:#174f44; --bg:#f5f4ef; --border:#e4e5df; --radius:20px; }
.hero { background:#183e35; padding:30px 26px 24px; border-radius:24px; box-shadow:none; margin-top:20px; }
.hero::before { background:#c7b98a; opacity:.15; filter:none; width:280px; height:280px; top:-80px; inset-inline-start:-150px; }
.hero::after { background:transparent; border:1px solid #ffffff26; filter:none; width:310px; height:310px; inset-inline-end:-100px; bottom:-190px; }
.hero h1 { font-size:38px; line-height:1.45; max-width:80%; }
.hero p { font-size:14px; max-width:75%; line-height:1.9; color:#d4e1d8; }
.hero .hero-books { inset-inline-end:24px; top:38%; color:#d5bf82; opacity:.8; animation:none; }
.hero-kicker { position:absolute; top:28px; inset-inline-end:25px; font-size:11px; letter-spacing:2px; opacity:.65; direction:ltr; }
.hero-offline { font-size:11px; color:#d6c48e; margin-top:22px; border-top:1px solid #ffffff22; padding-top:15px; }
.section-title { margin-top:28px; font-size:18px; }
.libs-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.lib-card { text-align:start; padding:17px 14px; min-height:104px; position:relative; border-radius:16px; box-shadow:none; }
.lib-card .l-icon { color:#226555; margin-bottom:10px; }
.lib-card .l-icon svg { width:24px; height:24px; }
.lib-card .l-name { font-size:13px; margin-top:3px; }
.lib-card .l-meta { font-size:10px; line-height:1.6; }
.grade-card { min-height:112px; border-radius:16px; box-shadow:none; }
.g1 { background:#226555; }.g2 { background:#6d775c; }.g3 { background:#b08a4c; }
.g-name { z-index:1; }.grade-card .g-emoji { opacity:.35; }
.wa-fab-wrap { position:static; margin:22px auto 100px; width:max-content; }
.reading-pdf .wa-fab-wrap,.reading-pdf .bottom-nav { display:none; }
@media(min-width:720px){ .libs-grid{grid-template-columns:repeat(4,minmax(0,1fr));} .hero h1{font-size:46px;} }
@media(max-width:450px){.brand{font-size:14px;gap:7px;white-space:nowrap}.topbar{gap:7px}.topbar .icon-btn{width:36px;height:36px;flex-shrink:0}}
.app {padding-bottom:24px;}
.wa-fab-wrap {margin:24px auto 96px;}
@media(min-width:720px){
 .bottom-nav{bottom:auto;top:18px;left:24px;right:auto;inset-inline:auto;position:fixed;flex-direction:column;border:1px solid var(--border);border-radius:18px;padding:10px 4px;background:var(--card);width:76px;gap:12px;}
 .nav-item{padding:8px 4px;}
 .app{max-width:1080px;padding-inline:24px;margin-left:max(110px,calc((100vw - 1080px)/2));}
 .wa-fab-wrap{margin:24px auto 40px;}
}
