/* ==========================================================================
   Facile Study — design system
   ========================================================================== */
:root {
  --fs-primary: #4f46e5;        /* indigo */
  --fs-primary-dark: #3730a3;
  --fs-primary-soft: #eef2ff;
  --fs-accent: #f59e0b;         /* amber */
  --fs-accent-dark: #d97706;
  --fs-teal: #0d9488;
  --fs-pink: #ec4899;
  --fs-ink: #0f172a;
  --fs-muted: #64748b;
  --fs-bg: #f5f6fb;
  --fs-card: #ffffff;
  --fs-border: #e6e8f0;
  --fs-sidebar-w: 264px;
  --fs-radius: 16px;
  --fs-shadow: 0 8px 30px rgba(15, 23, 42, .06);
  --fs-shadow-lg: 0 20px 50px rgba(79, 70, 229, .18);
  --fs-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #db2777 100%);
  --fs-gradient-soft: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf2f8 100%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--fs-bg);
  color: var(--fs-ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fs-primary); text-decoration: none; }
a:hover { color: var(--fs-primary-dark); }
h1, h2, h3, h4, h5 { font-weight: 800; letter-spacing: -.02em; }
.text-muted { color: var(--fs-muted) !important; }
.fw-800 { font-weight: 800; }

/* Buttons ------------------------------------------------------------------ */
.btn { border-radius: 12px; font-weight: 600; padding: .6rem 1.1rem; transition: transform .12s ease, box-shadow .12s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--fs-primary); border-color: var(--fs-primary); }
.btn-primary:hover { background: var(--fs-primary-dark); border-color: var(--fs-primary-dark); box-shadow: 0 8px 20px rgba(79,70,229,.3); }
.btn-gradient { background: var(--fs-gradient); border: 0; color: #fff; }
.btn-gradient:hover { color: #fff; box-shadow: var(--fs-shadow-lg); transform: translateY(-1px); }
.btn-accent { background: var(--fs-accent); border-color: var(--fs-accent); color: #1f1300; }
.btn-accent:hover { background: var(--fs-accent-dark); border-color: var(--fs-accent-dark); color: #fff; }
.btn-soft { background: var(--fs-primary-soft); color: var(--fs-primary-dark); border: 0; }
.btn-soft:hover { background: #e0e7ff; color: var(--fs-primary-dark); }
.btn-outline-light-soft { border: 1.5px solid rgba(255,255,255,.55); color: #fff; }
.btn-outline-light-soft:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Forms -------------------------------------------------------------------- */
.form-control, .form-select { border-radius: 12px; border: 1.5px solid var(--fs-border); padding: .65rem .9rem; background: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--fs-primary); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.form-label { font-weight: 600; font-size: .9rem; color: #334155; }
.form-text { color: var(--fs-muted); }
.invalid-feedback { display: block; }
.form-check-input:checked { background-color: var(--fs-primary); border-color: var(--fs-primary); }

/* Cards -------------------------------------------------------------------- */
.card { border: 1px solid var(--fs-border); border-radius: var(--fs-radius); box-shadow: var(--fs-shadow); background: var(--fs-card); }
.card-header { background: transparent; border-bottom: 1px solid var(--fs-border); font-weight: 700; }
.stat-card { border: 0; border-radius: var(--fs-radius); padding: 1.25rem 1.35rem; color: #fff; position: relative; overflow: hidden; min-height: 118px; }
.stat-card .stat-icon { position: absolute; right: 14px; top: 10px; font-size: 3.2rem; opacity: .18; }
.stat-card .stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; font-weight: 700; }
.stat-card .stat-value { font-size: 1.85rem; font-weight: 800; line-height: 1.1; margin-top: .3rem; }
.stat-indigo { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.stat-teal { background: linear-gradient(135deg, #0d9488, #059669); }
.stat-amber { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.stat-pink { background: linear-gradient(135deg, #ec4899, #be185d); }
.stat-slate { background: linear-gradient(135deg, #334155, #0f172a); }
.stat-light { background: #fff; color: var(--fs-ink); border: 1px solid var(--fs-border); }
.stat-light .stat-label { color: var(--fs-muted); }
.stat-light .stat-icon { color: var(--fs-primary); opacity: .15; }

/* Media cards ---------------------------------------------------------------- */
.media-card { border-radius: var(--fs-radius); overflow: hidden; background: #fff; border: 1px solid var(--fs-border); transition: transform .18s ease, box-shadow .18s ease; height: 100%; display: flex; flex-direction: column; }
.media-card:hover { transform: translateY(-4px); box-shadow: var(--fs-shadow-lg); }
.media-card .thumb { position: relative; aspect-ratio: 16 / 9; background: var(--fs-gradient-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.media-card .thumb.book { aspect-ratio: 3 / 4; background: linear-gradient(160deg, #fdf2f8, #eef2ff); }
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-card .thumb .placeholder-icon { font-size: 3rem; color: var(--fs-primary); opacity: .45; }
.media-card .thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .18s; background: rgba(15,23,42,.35); }
.media-card:hover .thumb .play { opacity: 1; }
.media-card .thumb .play i { font-size: 3rem; color: #fff; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.media-card .body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.media-card a.title { color: var(--fs-ink); }
.media-card .meta a { color: var(--fs-primary); font-weight: 600; }
.media-card .title { font-weight: 700; font-size: .98rem; line-height: 1.3; color: var(--fs-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-card .meta { font-size: .8rem; color: var(--fs-muted); }
.media-card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: .4rem; }
.badge-price { background: var(--fs-ink); color: #fff; border-radius: 999px; padding: .3rem .7rem; font-weight: 700; font-size: .78rem; }
.badge-free { background: #dcfce7; color: #166534; border-radius: 999px; padding: .3rem .7rem; font-weight: 700; font-size: .78rem; }
.badge-owned { background: #e0e7ff; color: var(--fs-primary-dark); border-radius: 999px; padding: .3rem .7rem; font-weight: 700; font-size: .78rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #f1f5f9; color: #334155; border-radius: 999px; padding: .2rem .6rem; font-size: .75rem; font-weight: 600; }
.chip.indigo { background: var(--fs-primary-soft); color: var(--fs-primary-dark); }
.chip.amber { background: #fef3c7; color: #92400e; }
.duration { position: absolute; right: 8px; bottom: 8px; background: rgba(15,23,42,.8); color: #fff; font-size: .72rem; padding: .15rem .45rem; border-radius: 6px; font-weight: 600; }
.thumb .corner-badge { position: absolute; left: 8px; top: 8px; }

/* Layout ------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--fs-sidebar-w); background: #0f172a; color: #cbd5e1; position: fixed; inset: 0 auto 0 0; padding: 1.2rem 1rem; display: flex; flex-direction: column; overflow-y: auto; z-index: 1030; }
.sidebar nav { flex: 0 0 auto; }
.sidebar .user-box { margin-top: auto; }   /* the profile box always sits at the foot of the menu */
.sidebar .brand { display: flex; align-items: center; gap: .65rem; color: #fff; padding: .35rem .5rem 1.2rem; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--fs-gradient); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 1.15rem; box-shadow: 0 6px 16px rgba(124,58,237,.45); flex-shrink: 0; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; }
.sidebar .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #64748b; font-weight: 700; padding: 1rem .75rem .35rem; }
.sidebar .nav-link { color: #cbd5e1; border-radius: 12px; padding: .62rem .8rem; display: flex; align-items: center; gap: .7rem; font-weight: 600; font-size: .93rem; transition: background .12s, color .12s; }
.sidebar .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; opacity: .9; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--fs-gradient); color: #fff; box-shadow: 0 8px 20px rgba(79,70,229,.35); }
.sidebar .nav-link .badge { margin-left: auto; background: var(--fs-accent); color: #1f1300; border-radius: 999px; font-size: .7rem; }
.sidebar .nav-link.danger { color: #fca5a5; }
.sidebar .nav-link.danger:hover { background: rgba(248,113,113,.12); color: #fecaca; }
.sidebar .user-box { margin-top: auto; background: rgba(255,255,255,.05); border-radius: 14px; padding: .8rem; display: flex; align-items: center; gap: .7rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--fs-gradient); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 84px; height: 84px; font-size: 1.7rem; }
.sidebar .nav-sub { padding-left: 2.2rem; }
.sidebar .nav-sub .nav-link { font-size: .87rem; padding: .45rem .8rem; }
.sidebar .nav-toggle::after { content: "\F282"; font-family: "bootstrap-icons"; margin-left: auto; font-size: .8rem; transition: transform .15s; }
.sidebar .nav-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

.main { margin-left: var(--fs-sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: rgba(245,246,251,.85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 1020; padding: .9rem 1.5rem; display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid var(--fs-border); }
.topbar .page-title { font-weight: 800; font-size: 1.15rem; margin: 0; }
.content { padding: 1.5rem; flex: 1; }
.role-pill { border-radius: 999px; padding: .25rem .7rem; font-size: .75rem; font-weight: 700; background: var(--fs-primary-soft); color: var(--fs-primary-dark); text-transform: uppercase; letter-spacing: .05em; }

@media (max-width: 991.98px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
}
.offcanvas.sidebar-mobile { background: #0f172a; width: 290px; }
.offcanvas.sidebar-mobile .sidebar { display: flex; position: static; width: 100%; }

/* Hero / sections ------------------------------------------------------------ */
.hero { background: var(--fs-gradient); color: #fff; border-radius: 22px; padding: 2rem 2rem; position: relative; overflow: hidden; box-shadow: var(--fs-shadow-lg); }
.hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero::before { content: ""; position: absolute; right: 120px; bottom: -120px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero h1, .hero h2 { color: #fff; }
.hero .lead { opacity: .92; max-width: 640px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.6rem 0 .9rem; }
.section-title h5 { margin: 0; font-weight: 800; display: flex; align-items: center; gap: .5rem; }
.section-title h5 i { color: var(--fs-primary); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--fs-muted); }
/* Only the big illustration icon sitting directly in the empty state is faded and
   blown up. Icons inside buttons or links nested here keep their normal size —
   without the `>` they turned into ghost squares (the Register / Upload buttons). */
.empty > i { font-size: 3.2rem; color: var(--fs-primary); opacity: .35; display: block; margin-bottom: .6rem; }
.empty h5 { color: var(--fs-ink); }

/* Tables ------------------------------------------------------------------- */
.table { --bs-table-bg: transparent; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fs-muted); font-weight: 700; border-bottom: 1px solid var(--fs-border); }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8f9ff; }

/* Alerts ------------------------------------------------------------------- */
.alert { border-radius: 14px; border: 0; box-shadow: var(--fs-shadow); }
.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: 2000; width: min(380px, calc(100vw - 2rem)); }

/* Auth pages ---------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand { background: var(--fs-gradient); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: rgba(255,255,255,.1); right: -180px; bottom: -220px; }
.auth-brand::before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); left: -80px; top: 40%; }
.auth-brand h1 { font-size: 2.6rem; color: #fff; line-height: 1.1; }
.auth-brand .feature { display: flex; gap: .9rem; align-items: flex-start; margin-top: 1.1rem; position: relative; z-index: 1; }
.auth-brand .feature i { font-size: 1.4rem; background: rgba(255,255,255,.18); border-radius: 12px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.auth-brand .feature strong { display: block; }
.auth-brand .feature span { opacity: .85; font-size: .92rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--fs-bg); }
.auth-card { width: 100%; max-width: 480px; }
.auth-card.wide { max-width: 640px; }
.auth-card .card { padding: 2rem; border-radius: 22px; }
.role-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.role-tabs label { border: 1.5px solid var(--fs-border); border-radius: 14px; padding: .75rem .5rem; text-align: center; cursor: pointer; font-weight: 700; font-size: .9rem; transition: all .12s; background: #fff; }
.role-tabs label i { display: block; font-size: 1.4rem; margin-bottom: .2rem; color: var(--fs-primary); }
.role-tabs input { display: none; }
.role-tabs input:checked + label { border-color: var(--fs-primary); background: var(--fs-primary-soft); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.code-input { font-size: 2rem; letter-spacing: .6em; text-align: center; font-weight: 800; }
@media (max-width: 991.98px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem 1.5rem; min-height: 0; }
  .auth-brand h1 { font-size: 1.9rem; }
  .auth-brand .feature { display: none; }
}

/* Player / reader (DRM) --------------------------------------------------------- */
.player-wrap { position: relative; background: #000; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; box-shadow: var(--fs-shadow-lg); user-select: none; -webkit-user-select: none; }
.player-wrap video { width: 100%; height: 100%; display: block; }
.watermark { position: absolute; pointer-events: none; color: rgba(255,255,255,.6); font-size: .95rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.7); z-index: 5; padding: .2rem .5rem; white-space: nowrap; letter-spacing: .02em; }
.watermark.tile { color: rgba(255,255,255,.18); font-size: 1.5rem; transform: rotate(-20deg); }
.reader-shell { background: #1e1b2e; min-height: calc(100vh - 66px); border-radius: 18px; padding: 1rem; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; color: #e2e8f0; margin-bottom: .8rem; flex-wrap: wrap; }
.reader-toolbar .btn { border-radius: 10px; }
.reader-page { display: flex; justify-content: center; }
.reader-page canvas { max-width: 100%; height: auto; box-shadow: 0 20px 50px rgba(0,0,0,.5); background: #fff; border-radius: 6px; }
.reader-page .loading { color: #e2e8f0; padding: 4rem; }
@media print { body { display: none !important; } }

/* Misc ------------------------------------------------------------------------ */
.divider-text { display: flex; align-items: center; gap: 1rem; color: var(--fs-muted); font-size: .85rem; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--fs-border); }
.list-row { display: flex; align-items: center; gap: .9rem; padding: .8rem 0; border-bottom: 1px solid var(--fs-border); }
.list-row:last-child { border-bottom: 0; }
.thumb-sm { width: 96px; aspect-ratio: 16/9; border-radius: 10px; object-fit: cover; background: var(--fs-gradient-soft); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--fs-primary); overflow: hidden; }
.thumb-sm img { width: 100%; height: 100%; object-fit: cover; }
.thumb-sm.book { width: 56px; aspect-ratio: 3/4; }
.progress { height: 8px; border-radius: 999px; background: #e2e8f0; }
.progress-bar { background: var(--fs-gradient); }
.kbd { font-family: ui-monospace, monospace; background: #f1f5f9; border-radius: 6px; padding: .1rem .4rem; font-size: .85em; }
.sandbox-banner { background: #fef3c7; color: #92400e; font-size: .8rem; font-weight: 600; padding: .35rem 1rem; text-align: center; }
.pagination .page-link { border-radius: 10px; margin: 0 2px; border: 1px solid var(--fs-border); color: var(--fs-ink); }
.pagination .active .page-link { background: var(--fs-primary); border-color: var(--fs-primary); }
.step { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: .9rem; }
.step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--fs-gradient); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; font-size: .85rem; }

/* Upload-lesson button: a black icon inside a white disc so it stays legible on the
   purple gradient. The second selector beats `.empty i`, which would otherwise fade it. */
.upload-icon,
.empty .upload-icon {
  color: #0f172a;
  background: #fff;
  border-radius: 50%;
  width: 1.7em;
  height: 1.7em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  margin: 0 .35rem 0 0;
  vertical-align: -.45em;
  opacity: 1;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .3);
}

/* Teacher ranks ------------------------------------------------------------
   Bronze / Silver / Gold, earned through active referrals. The badge sits next
   to a teacher's name; the card version is used on the admin pricing page. */
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.35em; height: 1.35em; border-radius: 50%;
  font-size: .95em; line-height: 1; vertical-align: -.22em;
  color: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .35);
}
.rank-badge.rank-bronze { background: linear-gradient(140deg, #c98f5a, #8b5a2b); }
.rank-badge.rank-silver { background: linear-gradient(140deg, #d8dee9, #94a3b8); color: #334155; }
.rank-badge.rank-gold   { background: linear-gradient(140deg, #fbbf24, #d97706); }
.rank-card.rank-bronze { border-color: #e7cdb4; }
.rank-card.rank-silver { border-color: #dde3ea; }
.rank-card.rank-gold   { border-color: #fbe3ae; }
.rank-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 700;
  padding: .18rem .55rem; border-radius: 999px; }
.rank-chip.rank-bronze { background: #f7ece2; color: #8b5a2b; }
.rank-chip.rank-silver { background: #eef2f6; color: #475569; }
.rank-chip.rank-gold   { background: #fef3c7; color: #92400e; }

/* Active-referral dot */
.dot-active { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%;
  background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); margin-right: .4rem;
  vertical-align: middle; }

/* Stars -------------------------------------------------------------------- */
.stars { color: #f59e0b; letter-spacing: .04em; white-space: nowrap; }
.stars .bi { font-size: .95em; }
.stars-lg .bi { font-size: 1.35rem; }
.star-pick { display: inline-flex; gap: .25rem; }
.star-pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.star-pick label { cursor: pointer; color: #cbd5e1; font-size: 1.9rem; line-height: 1; transition: color .12s; }
.star-pick label:hover, .star-pick label.on { color: #f59e0b; }

/* Pill tabs (admin pricing sections) --------------------------------------- */
.pill-tabs { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill-tab { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem;
  border-radius: 999px; background: #fff; border: 1px solid var(--fs-border);
  color: var(--fs-ink); font-weight: 600; font-size: .86rem; text-decoration: none; }
.pill-tab:hover { border-color: var(--fs-primary); color: var(--fs-primary); }
.pill-tab.active { background: var(--fs-ink); border-color: var(--fs-ink); color: #fff; }

/* Quiz --------------------------------------------------------------------- */
.q-card { border: 1px solid var(--fs-border); border-radius: 14px; padding: 1rem; background: #fff; }
.q-card + .q-card { margin-top: .75rem; }
.q-num { display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem;
  border-radius: 50%; background: var(--fs-ink); color: #fff; font-weight: 700; font-size: .8rem; }
.q-opt { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 10px;
  border: 1px solid var(--fs-border); margin-top: .4rem; cursor: pointer; }
.q-opt:hover { border-color: var(--fs-primary); background: #f8f9ff; }
.q-opt.correct { border-color: #16a34a; background: #f0fdf4; }
.q-opt.wrong { border-color: #dc2626; background: #fef2f2; }

/* ==========================================================================
   Small screens — the app is used on phones more than laptops, so the
   layout, tables and modals are tuned for a narrow viewport.
   ========================================================================== */
@media (max-width: 767.98px) {
  .content { padding: .85rem .8rem 5.5rem; }        /* room for the install bar */
  .page-title { font-size: 1.05rem; }
  .topbar { padding: .6rem .8rem; gap: .5rem; }
  .card { border-radius: 14px; }
  .card.p-4 { padding: 1rem !important; }
  h2 { font-size: 1.45rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
  .hero { padding: 1.25rem; border-radius: 16px; }
  .hero h2 { font-size: 1.35rem; }
  .stat-card { min-height: 96px; padding: .9rem 1rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .stat-card .stat-icon { font-size: 2.4rem; }
  .btn { padding: .6rem .9rem; }
  /* anything the thumb has to hit is at least 44px tall */
  .btn-lg, .form-control-lg, .form-select-lg { min-height: 48px; }
  .form-control, .form-select { font-size: 16px; }  /* stops iOS zooming on focus */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table td, .table th { white-space: nowrap; }
  .modal-dialog { margin: .5rem; }
  /* all four pricing tabs stay visible on a phone rather than scrolling away */
  .pill-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .pill-tab { justify-content: center; text-align: center; font-size: .78rem; padding: .55rem .5rem; }
  .list-row { flex-wrap: wrap; }
  .q-opt { padding: .7rem .75rem; }                 /* bigger answer targets */
  .star-pick label { font-size: 2.3rem; }
  .reader-shell { min-height: calc(100vh - 120px); padding: .5rem; border-radius: 12px; }
  .empty { padding: 2rem .75rem; }
  .empty > i { font-size: 2.6rem; }
}

@media (max-width: 575.98px) {
  .media-card .body { padding: .7rem .75rem .8rem; }
  .media-card .title { font-size: .9rem; }
  .chip { font-size: .7rem; }
  .toast-stack { left: .5rem; right: .5rem; bottom: .5rem; }
}

/* Standalone (installed) app: keep clear of the notch and the home indicator */
@media (display-mode: standalone) {
  .topbar { padding-top: max(.7rem, env(safe-area-inset-top)); }
  .content { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
  .sidebar { padding-top: max(1.2rem, env(safe-area-inset-top)); }
}

/* "Add to home screen" prompt --------------------------------------------- */
.install-bar {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 1080;
  background: var(--fs-ink); color: #fff; border-radius: 16px;
  padding: .8rem 1rem; display: flex; align-items: center; gap: .75rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .35);
}
.install-bar .bi-download { font-size: 1.4rem; }
@media (min-width: 768px) { .install-bar { left: auto; right: 1.5rem; max-width: 420px; } }

/* notification bell */
.bell-dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #e11d48; color: #fff; font-size: .68rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1; }
.notif-row { display: flex; gap: .85rem; padding: .9rem 0; border-bottom: 1px solid var(--fs-border); }
.notif-row:last-child { border-bottom: 0; }
.notif-row .ico { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; background: #eef2ff; color: #4f46e5; font-size: 1.1rem; }
.notif-row.unread .ico { background: var(--fs-gradient); color: #fff; }
.notif-row.unread .n-title { font-weight: 800; }

/* ---------------------------------------------------------------------------
   Collapsible menu (desktop). The rail keeps the icons and drops the words;
   hovering it slides the full menu back over the page, so nothing needs a
   tooltip. Mobile keeps the off-canvas drawer it already had.
   Labels are plain text nodes inside each link, so font-size:0 is what hides
   them — the icon gets its size back explicitly.
--------------------------------------------------------------------------- */
:root { --fs-rail-w: 76px; }

@media (min-width: 992px) {
  .nav-collapsed .main { margin-left: var(--fs-rail-w); }
  .nav-collapsed .sidebar { width: var(--fs-rail-w); padding-left: .6rem; padding-right: .6rem; }

  .nav-collapsed .sidebar .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .nav-collapsed .sidebar .brand > span:last-child,
  .nav-collapsed .sidebar .nav-section,
  .nav-collapsed .sidebar .user-box > div,
  .nav-collapsed .sidebar .user-box > i { display: none; }

  .nav-collapsed .sidebar .nav-link { font-size: 0; justify-content: center; padding: .62rem 0; gap: 0; }
  .nav-collapsed .sidebar .nav-link i { font-size: 1.2rem; width: auto; }
  .nav-collapsed .sidebar .nav-link .badge { position: absolute; margin: 0; transform: translate(14px, -12px); font-size: .62rem; }
  .nav-collapsed .sidebar .nav-link { position: relative; }
  .nav-collapsed .sidebar .nav-toggle::after { display: none; }
  .nav-collapsed .sidebar .nav-sub { padding-left: 0; }
  .nav-collapsed .sidebar .user-box { justify-content: center; padding: .6rem; }

  /* hover the rail and the whole menu comes back, floating over the page */
  .nav-collapsed .sidebar:hover { width: var(--fs-sidebar-w); padding-left: 1rem; padding-right: 1rem;
    box-shadow: 24px 0 48px rgba(2,6,23,.35); }
  .nav-collapsed .sidebar:hover .brand { justify-content: flex-start; padding-left: .5rem; }
  .nav-collapsed .sidebar:hover .brand > span:last-child,
  .nav-collapsed .sidebar:hover .nav-section,
  .nav-collapsed .sidebar:hover .user-box > div,
  .nav-collapsed .sidebar:hover .user-box > i { display: block; }
  .nav-collapsed .sidebar:hover .user-box { justify-content: flex-start; padding: .8rem; }
  .nav-collapsed .sidebar:hover .nav-link { font-size: .93rem; justify-content: flex-start;
    padding: .62rem .8rem; gap: .7rem; }
  .nav-collapsed .sidebar:hover .nav-link i { font-size: 1.1rem; width: 22px; }
  .nav-collapsed .sidebar:hover .nav-link .badge { position: static; transform: none;
    margin-left: auto; font-size: .7rem; }
  .nav-collapsed .sidebar:hover .nav-toggle::after { display: block; }
  .nav-collapsed .sidebar:hover .nav-sub { padding-left: 2.2rem; }

  .sidebar, .main { transition: width .18s ease, margin-left .18s ease, padding .18s ease; }

  /* the collapse handle — a round button that sits right on the sidebar's
     edge, level with the page title, and slides with it as the rail
     collapses or expands */
  #navToggle {
    position: fixed;
    top: 22px;
    left: calc(var(--fs-sidebar-w) - 16px);
    z-index: 1035;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--fs-primary-dark);
    border: 1px solid var(--fs-border);
    box-shadow: 0 4px 12px rgba(2,6,23,.18);
    transition: left .18s ease, background .12s ease;
  }
  #navToggle:hover { background: var(--fs-primary-soft); }
  .nav-collapsed #navToggle { left: calc(var(--fs-rail-w) - 16px); }
  /* the rail floats open on hover, so slide the handle out to its edge too */
  .nav-collapsed .sidebar:hover ~ #navToggle { left: calc(var(--fs-sidebar-w) - 16px); }
}

/* the toggle itself — a rail handle on desktop, the drawer button on phones */
#navToggle i { transition: transform .18s ease; font-size: .95rem; }
.nav-collapsed #navToggle i { transform: rotate(180deg); }
