/* مكتبتي v2 — نظام تصميم ورقي دافئ (فاتح/داكن) */
:root {
  --bg: #FFFBEB;
  --bg-soft: #FDF6E3;
  --surface: #FFFFFF;
  --surface-2: #FAF7EE;
  --ink: #1C1917;
  --ink-2: #44403C;
  --muted: #78716C;
  --border: #EAE3D2;
  --border-strong: #D6CBB3;
  --brand: #92400E;
  --brand-soft: #FDF0DC;
  --accent: #D97706;
  --accent-2: #B45309;
  --accent-ink: #FFFFFF;
  --green: #3F6212;
  --teal: #0F766E;
  --rose: #9F1239;
  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .06), 0 1px 3px rgba(28, 25, 23, .04);
  --shadow-md: 0 4px 10px -4px rgba(28, 25, 23, .10), 0 12px 28px -18px rgba(28, 25, 23, .18);
  --shadow-lg: 0 20px 50px -24px rgba(28, 25, 23, .30);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --font-ui: 'Noto Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'Noto Naskh Arabic', 'Noto Sans Arabic', Georgia, serif;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  --bg: #14110E;
  --bg-soft: #1A1613;
  --surface: #1E1A16;
  --surface-2: #241F1A;
  --ink: #F5EFE3;
  --ink-2: #D9D0C1;
  --muted: #A8A093;
  --border: #322B24;
  --border-strong: #453B31;
  --brand: #F0C088;
  --brand-soft: #2A2118;
  --accent: #F59E0B;
  --accent-2: #FBBF24;
  --accent-ink: #1C1206;
  --green: #A3C46A;
  --teal: #5CC8BE;
  --rose: #FCA5A5;
  --danger: #F87171;
  --danger-soft: #2A1614;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 24px 60px -30px rgba(0, 0, 0, .9);
}

/* أسماء توكنات قديمة — تُحلّ ديناميكيًا في المظهرين */
:root {
  --stone: var(--muted);
  --ink-soft: var(--muted);
  --line: var(--border);
  --brown: var(--brand);
  --accent-soft: var(--brand-soft);
  --paper: var(--bg);
  --paper-2: var(--surface);
  --r-pill: 999px;
  --shadow: var(--shadow-md);
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(60rem 30rem at 100% -10%, rgba(217, 119, 6, .07), transparent 60%),
    radial-gradient(40rem 24rem at 0% 0%, rgba(146, 64, 14, .06), transparent 60%);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.3; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(217, 119, 6, .25); }
.lucide { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- الهيكل العام ---------- */
.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
.skip {
  position: fixed; inset-inline-start: 50%; top: -60px; transform: translateX(50%);
  z-index: 60; background: var(--ink); color: var(--bg); padding: .6rem 1rem;
  border-radius: 0 0 10px 10px; transition: top .2s var(--ease);
}
.skip:focus { top: 0; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 1rem;
  min-height: 68px; padding-block: .55rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .65rem; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 13px; background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); box-shadow: var(--shadow-sm);
}
.brand-mark .lucide { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: .2px; }
.brand-text small { color: var(--muted); font-size: .76rem; margin-top: -.15rem; }

.tabs { display: flex; gap: .25rem; margin-inline: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .25rem; }
.tab {
  display: inline-flex; align-items: center; gap: .4rem; border: 0; background: transparent;
  color: var(--muted); padding: .45rem .85rem; border-radius: 999px; font-size: .88rem; font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tab[aria-current="page"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); font-weight: 600; }
.tab-count { font-style: normal; font-size: .72rem; background: var(--brand-soft); color: var(--brand); padding: 0 .38rem; border-radius: 999px; min-width: 1.3rem; text-align: center; }
[data-theme="dark"] .tab-count { background: #3A2C1C; color: var(--accent-2); }

.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: var(--border-strong); color: var(--accent-2); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border-radius: 11px; border: 1px solid transparent; padding: .6rem 1rem;
  font-size: .9rem; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-accent { background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: var(--accent-ink); box-shadow: 0 6px 16px -8px rgba(180, 83, 9, .7); }
.btn-accent:hover { box-shadow: 0 10px 24px -10px rgba(180, 83, 9, .8); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink-2); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--accent-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- الملخّص ---------- */
main { padding-block: 1.6rem 3rem; min-height: 55vh; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: .75rem; margin-bottom: 1.4rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: .85rem .95rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 100%; height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .0; transition: opacity .25s var(--ease); }
.stat:hover::after { opacity: .8; }
.stat span { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .78rem; }
.stat span .lucide { width: 15px; height: 15px; }
.stat strong { display: block; font-family: var(--font-display); font-size: 1.75rem; line-height: 1.2; margin-top: .15rem; }
.stat.done strong { color: var(--green); }
.stat.rated strong { color: var(--accent-2); }
.stat.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* ---------- شريط الأدوات ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1.1rem; }
.search {
  position: relative; display: flex; align-items: center; gap: .5rem; flex: 1 1 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: .55rem .8rem; box-shadow: var(--shadow-sm); transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search .lucide { color: var(--muted); }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: .92rem; min-width: 0; }
.search-clear { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 999px; width: 24px; height: 24px; display: grid; place-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .38rem .7rem; font-size: .82rem; display: inline-flex; align-items: center; gap: .35rem;
  transition: all .18s var(--ease);
}
.chip em { font-style: normal; font-size: .72rem; opacity: .75; }
.chip:hover { color: var(--ink); border-color: var(--border-strong); transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .chip[aria-pressed="true"] { color: #1C1206; }

.toolbar-right { display: flex; align-items: center; gap: .45rem; margin-inline-start: auto; flex-wrap: wrap; }
select, .field input, .field textarea, .cover-controls input[type="file"] {
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: .52rem .7rem; font-size: .86rem; color: var(--ink-2); box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
select:hover, .field input:hover, .field textarea:hover { border-color: var(--border-strong); }
select:focus-visible, .field input:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: .38rem .55rem; display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; transition: all .18s var(--ease); }
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.seg-wide { width: 100%; }
.seg-wide .seg-btn { flex: 1; justify-content: center; }

.grid-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.grid-head h2 { font-size: 1.45rem; }
.count-pill { font-size: .8rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .2rem .7rem; }

/* ---------- بطاقات الكتب ---------- */
.shelf { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); align-items: start; }
.book {
  position: relative; display: flex; flex-direction: column; gap: .7rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: .9rem; box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
  animation: fadeUp .35s var(--ease) both;
}
.book:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.book:focus-visible { border-color: var(--accent); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.book-top { display: flex; gap: .8rem; align-items: flex-start; }
.cover {
  width: 76px; min-width: 76px; aspect-ratio: 2 / 3; border-radius: 8px 5px 5px 8px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: .2rem;
  padding: .45rem; color: #FFF8EA; font-size: .62rem; line-height: 1.35; overflow: hidden;
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, .22), var(--shadow-sm);
  position: relative; text-align: start;
}
.cover span { font-family: var(--font-display); font-size: .72rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cover em { font-style: normal; opacity: .8; font-size: .58rem; }
.cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.cover.sm { width: 44px; min-width: 44px; padding: .3rem; font-size: .5rem; }
.cover.sm span { font-size: .55rem; -webkit-line-clamp: 3; }
.book-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.book-body h3 { font-size: 1.02rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { color: var(--muted); font-size: .8rem; }
.book-meta { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .15rem; }

.status { font-size: .68rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; border: 1px solid transparent; }
.status.want { background: color-mix(in srgb, #A8A29E 18%, transparent); color: #57534E; border-color: color-mix(in srgb, #A8A29E 40%, transparent); }
.status.reading { background: color-mix(in srgb, #D97706 18%, transparent); color: #B45309; border-color: color-mix(in srgb, #D97706 40%, transparent); }
.status.paused { background: color-mix(in srgb, #0F766E 16%, transparent); color: #0F766E; border-color: color-mix(in srgb, #0F766E 35%, transparent); }
.status.done { background: color-mix(in srgb, #3F6212 16%, transparent); color: #3F6212; border-color: color-mix(in srgb, #3F6212 35%, transparent); }
[data-theme="dark"] .status.want { color: #C9C3BA; }
[data-theme="dark"] .status.reading { color: #FBBF24; }
[data-theme="dark"] .status.paused { color: #5CC8BE; }
[data-theme="dark"] .status.done { color: #A3C46A; }
.tag { font-size: .68rem; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); padding: .1rem .45rem; border-radius: 6px; }
.tag.ghost { background: transparent; color: var(--muted); border-style: dashed; }
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .68rem; padding: .1rem .45rem; border-radius: 6px; }
.badge.loan { background: color-mix(in srgb, #0F766E 14%, transparent); color: var(--teal); }
.badge.loan.late { background: var(--danger-soft); color: var(--danger); }
.badge .lucide { width: 12px; height: 12px; }

.stars-row { display: inline-flex; gap: .08rem; margin-top: .18rem; }
.stars-row .lucide { width: 13px; height: 13px; }
.stars-row .on { color: var(--accent); fill: color-mix(in srgb, var(--accent) 85%, transparent); }
.stars-row .off { color: var(--border-strong); }

.progress { display: flex; flex-direction: column; gap: .28rem; }
.progress-meta { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.progress-meta b { color: var(--accent-2); }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .45s var(--ease); }
.progress-note { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; color: var(--green); }
.progress-note .lucide { width: 14px; height: 14px; }

.notes { font-size: .8rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; border-inline-start: 2px solid var(--border); padding-inline-start: .55rem; }
.book-actions { display: flex; align-items: center; gap: .3rem; border-top: 1px solid var(--border); padding-top: .6rem; margin-top: auto; }
.grow { flex: 1; }
.mini {
  display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink-2); border-radius: 9px; padding: .32rem .55rem;
  font-size: .74rem; font-weight: 600; transition: all .18s var(--ease);
}
.mini:hover { background: var(--brand-soft); border-color: var(--border-strong); color: var(--brand); transform: translateY(-1px); }
.mini.icon { padding: .32rem; }
.mini.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.mini .lucide { width: 14px; height: 14px; }

/* قائمة */
.shelf[data-layout="list"] { grid-template-columns: 1fr; }
.shelf[data-layout="list"] .book { flex-direction: row; flex-wrap: wrap; align-items: center; padding: .7rem .9rem; }
.shelf[data-layout="list"] .book-top { flex: 1 1 320px; }
.shelf[data-layout="list"] .progress { flex: 1 1 200px; max-width: 260px; }
.shelf[data-layout="list"] .notes { display: none; }
.shelf[data-layout="list"] .book-actions { border-top: 0; padding-top: 0; margin-top: 0; flex: 0 0 auto; }
.shelf[data-layout="list"] .cover { width: 52px; min-width: 52px; }

/* ---------- الحالة الفارغة ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center;
  padding: 3rem 1.5rem; background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--r-xl); color: var(--muted); margin-top: 1rem;
}
.empty > .lucide { width: 44px; height: 44px; color: var(--accent); opacity: .8; }
.empty h3 { font-size: 1.2rem; color: var(--ink); }
.empty p { max-width: 46ch; font-size: .88rem; }
.empty-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .6rem; }

/* ---------- رؤوس الأقسام ---------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.view-head h2 { font-size: 1.7rem; }
.view-head p { color: var(--muted); font-size: .86rem; margin-top: .2rem; max-width: 60ch; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: .9rem; box-shadow: var(--shadow-sm); display: grid; gap: .1rem; }
.kpi-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand); margin-bottom: .3rem; }
.kpi p { color: var(--muted); font-size: .78rem; }
.kpi strong { font-family: var(--font-display); font-size: 1.65rem; line-height: 1.2; }
.kpi small { color: var(--muted); font-size: .72rem; }

.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .8rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1rem; box-shadow: var(--shadow-sm); }
.panel h3 { font-size: 1rem; display: flex; align-items: center; gap: .4rem; margin-bottom: .8rem; color: var(--ink); }
.panel h3 .lucide { width: 16px; height: 16px; color: var(--accent); }
.panel-danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); background: var(--danger-soft); }
.muted-note { color: var(--muted); font-size: .78rem; }
.panel .muted-note { margin-top: .4rem; }
.panel .btn { margin-top: .6rem; }

/* دونات + أسطوانات + أعمدة */
.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut {
  width: 132px; height: 132px; border-radius: 50%; position: relative; display: grid; place-items: center;
  flex: none; box-shadow: inset 0 0 0 1px var(--border);
}
.donut::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.donut span { position: relative; z-index: 1; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .8rem; }
.legend li { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.legend li i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend li span { flex: 1; }
.legend li b { color: var(--ink); }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.bars li { display: grid; grid-template-columns: 78px 1fr 28px; align-items: center; gap: .5rem; font-size: .78rem; }
.bar-label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 999px; transition: width .5s var(--ease); }
.bars b { color: var(--muted); font-size: .74rem; text-align: end; }

.columns { display: flex; align-items: flex-end; gap: .5rem; height: 140px; padding-top: .5rem; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .25rem; height: 100%; }
.col-val { font-size: .68rem; color: var(--muted); height: 1em; }
.col-bar { width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); transition: height .5s var(--ease); }
.col-label { font-size: .68rem; color: var(--muted); }

.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.top-list li { display: flex; align-items: center; gap: .55rem; }
.top-list li div { min-width: 0; display: grid; gap: .1rem; }
.top-list strong { font-family: var(--font-display); font-size: .92rem; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.top-list small { color: var(--muted); font-size: .72rem; }

.shortcuts { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; font-size: .8rem; }
.shortcuts li { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.shortcuts li span { margin-inline-start: auto; color: var(--ink-2); }
kbd { font-family: var(--font-ui); font-size: .72rem; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: .05rem .35rem; color: var(--ink-2); }
code { font-size: .9em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .25rem; }

/* ---------- الإعارات ---------- */
.loan-toolbar { margin-bottom: .8rem; }
.loan-list { display: grid; gap: .55rem; }
.loan {
  display: flex; align-items: center; gap: .75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: .7rem .9rem;
  box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.loan:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.loan-info { min-width: 0; flex: 1; display: grid; gap: .15rem; }
.loan-info h3 { font-size: .96rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loan-info p { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--ink-2); }
.loan-info p .lucide { width: 14px; height: 14px; color: var(--teal); }
.loan-info small { color: var(--muted); font-size: .72rem; }
.late-txt { color: var(--danger); }
.loan-actions { display: flex; align-items: center; gap: .35rem; }
.loan-actions .btn { padding: .45rem .7rem; font-size: .8rem; }

/* ---------- المودال ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(28, 25, 23, .55); backdrop-filter: blur(3px); animation: fadeIn .2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: relative; z-index: 1; width: min(620px, 100%); max-height: min(90vh, 900px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: sheetIn .28s var(--ease);
}
.sheet-sm { width: min(420px, 100%); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .95rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.sheet-head h2 { font-size: 1.2rem; }
.sheet-body { padding: 1.1rem; overflow-y: auto; display: grid; gap: .7rem; }
.sheet-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); }

.field { display: grid; gap: .28rem; }
.field-label { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.opt { font-weight: 400; color: var(--muted); font-size: .72rem; }
.field input, .field textarea { width: 100%; }
.field textarea { resize: vertical; min-height: 62px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.cover-row { display: flex; gap: .9rem; align-items: flex-start; padding-bottom: .3rem; border-bottom: 1px dashed var(--border); margin-bottom: .2rem; }
.cover-preview {
  width: 88px; min-width: 88px; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); border: 1px dashed var(--border-strong); display: grid; place-items: center;
  color: var(--muted); font-size: .72rem;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-controls { flex: 1; min-width: 0; display: grid; gap: .35rem; }
.cover-controls input[type="file"] { width: 100%; font-size: .78rem; }

.stars { display: flex; align-items: center; gap: .2rem; }
.stars button { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; width: 38px; height: 34px; display: grid; place-items: center; color: var(--border-strong); transition: all .16s var(--ease); }
.stars button:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
.stars button.on { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: var(--accent); color: var(--accent); }
.stars button.on .lucide { fill: color-mix(in srgb, var(--accent) 80%, transparent); }
.stars .clear-rate { width: auto; padding-inline: .6rem; font-size: .74rem; color: var(--muted); }
.more { border: 1px solid var(--border); border-radius: var(--r-sm); padding: .55rem .7rem; background: var(--surface-2); }
.more summary { font-size: .82rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.more[open] summary { margin-bottom: .6rem; }
.lend-book { font-family: var(--font-display); font-size: 1.05rem; color: var(--brand); }

/* ---------- التوست ---------- */
.toasts { position: fixed; inset-block-end: 1rem; inset-inline-start: 1rem; z-index: 80; display: grid; gap: .45rem; max-width: min(360px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: center; gap: .5rem; background: var(--ink); color: var(--bg);
  border-radius: 12px; padding: .6rem .8rem; font-size: .84rem; box-shadow: var(--shadow-lg);
  animation: toastIn .25s var(--ease); transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast .lucide { width: 16px; height: 16px; color: var(--accent); }
.toast.error .lucide { color: #FCA5A5; }
.toast span { flex: 1; }
.toast.has-action { padding-inline-end: .5rem; }
.toast-action { background: rgba(255, 255, 255, .14); border: 0; color: inherit; border-radius: 8px; padding: .25rem .55rem; font-size: .78rem; font-weight: 700; }
.toast-action:hover { background: rgba(255, 255, 255, .24); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- التذييل ---------- */
.foot { display: grid; gap: .3rem; padding-block: 1.4rem 2rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; }
.foot .hint { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.foot .hint .lucide { width: 15px; height: 15px; }
.foot .link-btn { font-size: .78rem; }
.meter { height: 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); transition: width .5s var(--ease); }
.meter span[data-level="mid"] { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter span[data-level="high"] { background: linear-gradient(90deg, #F87171, var(--danger)); }

/* ---------- استجابة ---------- */
@media (max-width: 900px) {
  .brand-text small { display: none; }
  .tabs { order: 3; width: 100%; margin-inline: 0; overflow-x: auto; justify-content: flex-start; }
  .tab span { display: inline; }
  .topbar-actions { margin-inline-start: auto; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { width: min(1180px, 100% - 1.6rem); }
  .shelf { grid-template-columns: 1fr; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .toolbar-right { width: 100%; }
  .toolbar-right select { flex: 1; min-width: 0; }
  .stat strong { font-size: 1.5rem; }
  .view-head h2 { font-size: 1.45rem; }
  .tabs .tab { padding: .4rem .6rem; font-size: .82rem; }
  .tab-count { display: none; }
  .toasts { inset-inline: .8rem; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}


/* لمسات أخيرة — حجم النص الصغير في RTL */
.status, .tag, .badge, .tab-count { font-size: .72rem; }
.mini { font-size: .76rem; }
.book-author { font-size: .82rem; }
.progress-meta, .chip, .search input { font-size: .84rem; }
.loan-info small, .loan-info p { font-size: .76rem; }
@media (max-width: 640px) { .status, .tag, .badge { font-size: .7rem; } }
