/* =====================================================================
   ReadQuest AI — layout.css
   Page layout, top bar, navigation, notifications, footer
   Ported unchanged from the original app.css (v2) unless marked NEW.
   ===================================================================== */
/* ---------- Layout ---------- */
.page { width: min(1180px, 100% - 32px); margin: 24px auto 40px; flex: 1; }
.page--narrow { width: min(560px, 100% - 32px); }
.grid { display: grid; gap: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dash-grid { display: grid; gap: 22px; grid-template-columns: 1.65fr 1fr; align-items: start; }
.stack > * + * { margin-top: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.center { text-align: center; }
.muted { color: var(--muted); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }

.page-head { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-weight: 600; }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; padding: 12px 16px 0; }
.topbar__inner {
  max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .9); border-radius: 22px; padding: 8px 12px 8px 14px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand__leo { width: 44px; height: 44px; }
.brand__text { font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; letter-spacing: -.02em; }
.brand__text span { color: var(--primary); }
.brand__text small { font-size: .62em; background: var(--sun); color: var(--ink); padding: 1px 7px; border-radius: 8px; vertical-align: 3px; }
.mainnav { flex: 1; }
.mainnav ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; justify-content: center; flex-wrap: wrap; }
.mainnav a {
  display: flex; align-items: center; gap: 5px; padding: 8px 11px; border-radius: 14px; text-decoration: none;
  color: var(--ink-2); font-weight: 800; font-size: .92rem; white-space: nowrap; transition: background .15s, color .15s;
}
.mainnav a:hover { background: var(--primary-50); color: var(--primary-700); }
.mainnav a.is-active { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-700); }
.nav-logout { color: var(--coral-700) !important; }
.nav-logout-li { display: none; }
.logout-btn { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--coral-50); text-decoration: none; font-size: 1.3rem; }
.logout-btn:hover { background: #ffdcdc; }
.nav-toggle { display: none; margin-left: auto; background: var(--primary-50); border: 0; width: 48px; height: 48px; border-radius: 14px; font-size: 1.5rem; cursor: pointer; color: var(--primary-700); }
.topbar__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.me-chip { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); background: var(--sun-50); border-radius: 999px; padding: 4px 14px 4px 4px; font-weight: 800; }
.me-chip__avatar { width: 38px; height: 38px; display: grid; place-items: center; background: #fff; border-radius: 50%; font-size: 1.4rem; box-shadow: var(--shadow-sm); }

/* ---------- Notifications ---------- */
.notif { position: relative; }
.notif__btn { position: relative; width: 48px; height: 48px; border-radius: 14px; border: 0; background: var(--primary-50); font-size: 1.35rem; cursor: pointer; }
.notif__btn:hover { background: #e2e2ff; }
.notif__count { position: absolute; top: -4px; right: -4px; background: var(--coral); color: #fff; font-size: .75rem; font-weight: 800; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; border: 2px solid #fff; }
.notif__panel { position: absolute; right: 0; top: 58px; width: min(380px, calc(100vw - 32px)); background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden; z-index: 60; }
.notif__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif__list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.notif__list li a, .notif__list li .notif__item { display: flex; gap: 10px; padding: 12px 16px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; border-bottom: 1px solid #f2f4fb; }
.notif__list li a:hover { background: #f7f8ff; }
.notif__list .is-unread { background: #f5f5ff; }
.notif__list .is-unread .notif__msg { font-weight: 800; }
.notif__icon { font-size: 1.3rem; flex-shrink: 0; }
.notif__time { display: block; font-size: .78rem; color: var(--muted); font-weight: 700; }
.notif__state { padding: 22px 16px; text-align: center; color: var(--muted); }
.notif__all { display: block; text-align: center; padding: 12px; background: #fafbff; text-decoration: none; }
.link-btn { background: none; border: 0; color: var(--primary-600); font-weight: 800; cursor: pointer; font: inherit; font-size: .88rem; padding: 4px 6px; }

.brand__by { display: block; font-style: normal; font-family: var(--font-body); font-size: .62rem; font-weight: 800; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-top: -4px; }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 26px 16px 34px; color: var(--muted); font-weight: 700; }
.footer p { margin: 0; }
.footer__small { font-size: .85rem; margin-top: 4px !important; }


/* ---------- NEW (HTML edition): boot loader while the session is checked ---------- */
body.is-booting #main > * { visibility: hidden; }
body.is-booting #main { position: relative; min-height: 50vh; }
body.is-booting #main::before {
  content: ""; position: absolute; left: 50%; top: 18vh; width: 46px; height: 46px; margin-left: -23px;
  border-radius: 50%; border: 5px solid #dfe3f6; border-top-color: var(--primary); animation: spin .8s linear infinite; visibility: visible;
}
.topbar:empty { display: none; }
.mainnav .nav-badge { margin-left: 2px; }
button.logout-btn { border: 0; cursor: pointer; font: inherit; font-size: 1.3rem; }
