/* =========================================================================
   BANKPEDIAA COMMUNITY — DESIGN SYSTEM v3
   Rebuilt from zero. "Fintech noir": deep charcoal field, one emerald
   signal color, soft aurora glow, glass surfaces, restrained motion.

   GRID CONTRACT (read this before touching any grid):
   Every multi-card row uses CSS Grid with `minmax(0,1fr)` tracks and
   `grid-auto-rows: 1fr`. This is not a heuristic — with fr-unit tracks,
   the browser allocates exactly equal width to every column and exactly
   equal height to every row, by definition, regardless of what any card
   contains. A card can only look "bigger" than its siblings if something
   pulls it OUT of the grid flow (wrong markup) or gives it an explicit
   width/flex-basis override. Every card element must have no inline
   width/flex styles — that rule is enforced below with box-sizing +
   min-width:0 resets on every grid child.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
* { min-width: 0; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
html { scroll-behavior: smooth; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

:root {
  /* Surfaces */
  --bg:            #06070a;
  --bg-soft:       #0a0c10;
  --panel:         #12151a;
  --panel-2:       #181c22;
  --panel-hover:   #1e232a;
  --stroke:        #21262e;
  --stroke-2:      #2d333c;
  --stroke-soft:   rgba(255,255,255,0.06);

  /* Text */
  --text-hi:       #f4f6f7;
  --text-md:       #a3aab3;
  --text-lo:       #676f79;

  /* Signal */
  --community-green:      #2fd992;
  --community-green-dim:  #22b87c;
  --community-green-tint: rgba(47, 217, 146, 0.13);
  --community-green-glow: rgba(47, 217, 146, 0.35);
  --gold:          #f0b429;
  --gold-tint:     rgba(240, 180, 41, 0.13);
  --danger:        #f0564f;
  --danger-tint:   rgba(240, 86, 79, 0.12);
  --info:          #5b9dff;
  --info-tint:     rgba(91, 157, 255, 0.12);

  /* legacy alias kept so nothing depending on old token name breaks */
  --amber: var(--gold);

  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;

  --r-xs:  8px;
  --r-sm:  12px;
  --r-md:  16px;
  --r-lg:  22px;
  --r-xl:  28px;
  --r-pill: 999px;
  /* legacy aliases */
  --radius-lg: var(--r-lg);
  --radius-md: var(--r-md);
  --radius-sm: var(--r-sm);

  --shadow-1: 0 1px 0 rgba(255,255,255,0.03) inset, 0 1px 3px rgba(0,0,0,0.4);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.03) inset, 0 10px 30px rgba(0,0,0,0.4);
  --shadow-3: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 50px rgba(0,0,0,0.55);
  --shadow-card: var(--shadow-2);
  --shadow-card-hover: var(--shadow-3);
  --shadow-glow: 0 0 0 1px rgba(47,217,146,0.25), 0 8px 28px rgba(47,217,146,0.16);

  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.15s;
  --dur-med:  0.28s;
  --dur-slow: 0.5s;

  --nav-h: 62px;
  --sidebar-w: 264px;
  --max-content: 760px;
}

body {
  background: var(--bg);
  color: var(--text-md);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* ---- Aurora background: three soft blurred blobs, fixed, gently drifting.
   Decorative only — aria-hidden, pointer-events:none, zero layout impact. ---- */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora span {
  position: absolute; border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  will-change: transform;
}
.aurora span:nth-child(1) {
  width: 480px; height: 480px; top: -180px; left: -120px;
  background: var(--community-green);
  animation: auroraDrift1 26s ease-in-out infinite;
}
.aurora span:nth-child(2) {
  width: 420px; height: 420px; top: 30%; right: -160px;
  background: var(--info);
  opacity: 0.09;
  animation: auroraDrift2 32s ease-in-out infinite;
}
.aurora span:nth-child(3) {
  width: 380px; height: 380px; bottom: -160px; left: 30%;
  background: var(--gold);
  opacity: 0.07;
  animation: auroraDrift1 22s ease-in-out infinite reverse;
}
@keyframes auroraDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.15); }
}
@keyframes auroraDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, 30px) scale(1.1); }
}
@media (max-width: 640px) { .aurora span { filter: blur(60px); opacity: 0.12; } }

.app-shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text-hi); margin: 0 0 8px; font-weight: 750; letter-spacing: -0.015em; }
h1 { font-size: 27px; line-height: 1.22; }
h2 { font-size: 19px; letter-spacing: -0.01em; }
h3 { font-size: 15.5px; }
p { margin: 0 0 12px; color: var(--text-md); overflow-wrap: anywhere; }
a { color: var(--community-green); text-decoration: none; transition: color var(--dur-fast) ease; overflow-wrap: anywhere; }
a:hover { color: var(--community-green-dim); }
::selection { background: var(--community-green-tint); color: var(--text-hi); }
:focus-visible { outline: 2px solid var(--community-green); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-lo); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---- Layout shells ---- */
.sidebar { display: none; }
.main-col { flex: 1; min-width: 0; padding-bottom: calc(var(--nav-h) + 28px); }
.content { max-width: var(--max-content); margin: 0 auto; padding: 22px 16px 40px; animation: viewFadeIn 0.45s var(--ease-out) both; }
@keyframes viewFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column;
    width: var(--sidebar-w); flex-shrink: 0;
    border-right: 1px solid var(--stroke);
    padding: 22px 14px;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--bg-soft), var(--bg) 40%);
  }
  .main-col { padding-bottom: 40px; }
  .content { padding: 36px 36px 56px; }
  .bottom-nav { display: none; }
}

/* ---- Topbar (mobile) ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--stroke);
  position: sticky; top: 0;
  background: rgba(6,7,10,0.86);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  z-index: 20;
}
@media (min-width: 900px) { .topbar { display: none; } }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; color: var(--text-hi); font-size: 16px; letter-spacing: -0.01em; text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--r-xs);
  background: linear-gradient(155deg, var(--community-green), var(--community-green-dim));
  display: flex; align-items: center; justify-content: center;
  color: #04150d; font-weight: 900; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(47,217,146,0.35);
}
.brand-logo-img { height: 26px; width: auto; }
.brand-logo-sm { height: 22px; }

/* ---- Sidebar / drawer shared nav ---- */
.nav-list { list-style: none; margin: 22px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-lo); font-weight: 700; margin: 16px 12px 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text-md); font-weight: 600; font-size: 13.8px;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--panel-2); color: var(--text-hi); transform: translateX(2px); }
.nav-item.active {
  background: var(--community-green-tint);
  color: var(--community-green);
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: '';
  position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 4px 4px 0;
  background: var(--community-green);
  box-shadow: 0 0 10px var(--community-green-glow);
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(10,12,16,0.96);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-top: 1px solid var(--stroke);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px;
  color: var(--text-lo); font-size: 10.5px; font-weight: 600;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.bottom-nav a svg { width: 20px; height: 20px; transition: transform var(--dur-fast) var(--ease-spring); }
.bottom-nav a.active { color: var(--community-green); }
.bottom-nav a.active svg { transform: translateY(-1px) scale(1.08); }
.bottom-nav a:active svg { transform: scale(0.88); }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--r-pill);
  color: var(--text-hi); background: transparent; border: none; cursor: pointer;
  transition: background var(--dur-fast) ease, transform var(--dur-fast) ease;
  flex-shrink: 0; position: relative;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 20px; height: 20px; }

.notif-badge {
  position: absolute; top: 1px; right: 1px;
  background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 800;
  border-radius: 999px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  border: 2px solid var(--bg);
  animation: pulseBadge 2.2s ease-in-out infinite;
}
.notif-badge-tab { top: -3px; right: 16px; }
.nav-badge {
  margin-left: auto; background: var(--community-green); color: #04150d;
  font-size: 10px; font-weight: 800; border-radius: 999px;
  min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
  flex-shrink: 0;
}
@keyframes pulseBadge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

.drawer-overlay {
  position: fixed; inset: 0; background: rgba(3,4,5,0.65); backdrop-filter: blur(2px); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-med) ease;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 85%; max-width: 320px;
  background: var(--panel); border-right: 1px solid var(--stroke);
  z-index: 50;
  transform: translateX(-105%);
  transition: transform 0.36s var(--ease-out);
  display: flex; flex-direction: column; overflow-y: auto;
  box-shadow: 30px 0 60px rgba(0,0,0,0.5);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--stroke); }
@media (min-width: 900px) { .drawer, .drawer-overlay { display: none; } }

/* =========================================================================
   CARDS + GRID — bulletproof, animated.
   ========================================================================= */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel) 60%, var(--panel-2));
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  animation: fadeCardIn 0.5s var(--ease-out) both;
  transition: border-color var(--dur-med) ease, box-shadow var(--dur-med) ease, transform var(--dur-med) var(--ease-out);
}
.card + .card { margin-top: 14px; }
.card-flat { border-radius: var(--r-md); padding: 16px; }
.card:hover { border-color: var(--stroke-2); box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
@keyframes fadeCardIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Bulletproof uniform grid: fr-unit tracks make every column exactly
   equal width and grid-auto-rows:1fr makes every row exactly equal
   height. This is a mathematical property of CSS Grid, not a guess. */
.directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  justify-items: stretch;
  gap: 12px;
}
@media (min-width: 640px)  { .directory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 1100px) { .directory-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }

.directory-grid > .card,
.directory-grid > * {
  height: 100%;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0 !important;      /* neutralise any stray ".card + .card" margin inside a grid */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Staggered entrance for the first 12 grid items — purely cosmetic,
   animates opacity/transform only, so it cannot affect track sizing. */
.directory-grid > *:nth-child(1)  { animation-delay: 0.00s; }
.directory-grid > *:nth-child(2)  { animation-delay: 0.04s; }
.directory-grid > *:nth-child(3)  { animation-delay: 0.08s; }
.directory-grid > *:nth-child(4)  { animation-delay: 0.12s; }
.directory-grid > *:nth-child(5)  { animation-delay: 0.16s; }
.directory-grid > *:nth-child(6)  { animation-delay: 0.20s; }
.directory-grid > *:nth-child(7)  { animation-delay: 0.24s; }
.directory-grid > *:nth-child(8)  { animation-delay: 0.28s; }
.directory-grid > *:nth-child(n+9) { animation-delay: 0.32s; }

.member-tile {
  text-align: center;
  padding: 20px 14px;
  align-items: center;
  justify-content: flex-start;
  contain: layout inline-size;
  position: relative;
  overflow: hidden;
}
.member-tile::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 46px;
  background: linear-gradient(180deg, var(--community-green-tint), transparent);
  opacity: 0; transition: opacity var(--dur-med) ease;
}
.member-tile:hover::before { opacity: 1; }
.member-tile .avatar { width: 58px; height: 58px; min-width: 58px; min-height: 58px; max-width: 58px; max-height: 58px; font-size: 19px; margin: 0 auto 12px; flex-shrink: 0; position: relative; z-index: 1; }
.member-tile .name { font-size: 13.5px; font-weight: 700; color: var(--text-hi); margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; position: relative; z-index: 1; }
.member-tile .role { font-size: 11.5px; color: var(--text-lo); margin-bottom: 10px; min-height: 14px; overflow: hidden; text-overflow: ellipsis; width: 100%; flex: 1; position: relative; z-index: 1; }

.stat-tile { justify-content: space-between; align-items: flex-start; position: relative; overflow: hidden; }
.stat-tile h2, .stat-tile h3 { margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.stat-tile::after {
  content: '';
  position: absolute; top: -30%; right: -20%; width: 90px; height: 90px; border-radius: 50%;
  background: var(--community-green-tint); filter: blur(20px);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-sm);
  padding: 11px 18px; font-weight: 700; font-size: 13.8px; font-family: var(--font-body);
  border: 1px solid transparent; cursor: pointer;
  transition: transform var(--dur-fast) ease, background var(--dur-fast) ease, border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, color var(--dur-fast) ease;
  text-align: center; white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(155deg, var(--community-green), var(--community-green-dim));
  color: #04150d;
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 6px 18px rgba(47,217,146,0.22);
}
.btn-primary:hover { box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 8px 24px rgba(47,217,146,0.38); transform: translateY(-1px); }
.btn-outline { background: transparent; border-color: var(--stroke-2); color: var(--text-hi); }
.btn-outline:hover { border-color: var(--community-green); color: var(--community-green); background: var(--community-green-tint); }
.btn-ghost { background: transparent; color: var(--text-md); }
.btn-ghost:hover { color: var(--text-hi); background: var(--panel-2); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 13px; font-size: 12.8px; }

/* ---- Forms ---- */
label { display: block; font-size: 12.8px; font-weight: 650; color: var(--text-hi); margin-bottom: 6px; }
.field { margin-bottom: 16px; min-width: 0; }
input, textarea, select {
  width: 100%; max-width: 100%;
  background: var(--bg-soft); border: 1px solid var(--stroke); color: var(--text-hi);
  border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--community-green); outline: none; box-shadow: 0 0 0 3px var(--community-green-tint); }
textarea { resize: vertical; min-height: 90px; }
.help-text { font-size: 12px; color: var(--text-lo); margin-top: 6px; }
.error-text { font-size: 12px; color: var(--danger); margin-top: 6px; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.badge-member-id { font-family: var(--font-mono); background: var(--panel-2); color: var(--community-green); border: 1px solid var(--stroke-2); }
.badge-level { background: var(--community-green-tint); color: var(--community-green); }
.badge-free { background: rgba(255,255,255,0.06); color: var(--text-lo); }
.badge-locked { background: var(--gold-tint); color: var(--gold); }

/* ---- Avatar ---- */
.avatar {
  width: 40px; height: 40px; min-width: 40px; min-height: 40px;
  border-radius: 50%;
  background-color: var(--panel-2);
  background-size: cover; background-position: center;
  border: 1px solid var(--stroke);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-md); font-weight: 700;
  overflow: hidden;
}

/* ---- Alerts ---- */
.alert { border-radius: var(--r-md); padding: 12px 16px; font-size: 13.2px; margin-bottom: 16px; border: 1px solid; animation: fadeCardIn 0.35s var(--ease-out) both; }
.alert-error { background: var(--danger-tint); border-color: rgba(240,86,79,0.3); color: #f3968f; }
.alert-success { background: var(--community-green-tint); border-color: rgba(47,217,146,0.3); color: var(--community-green); }

/* ---- Locked content teaser ---- */
.locked-panel { position: relative; border-radius: var(--r-md); padding: 24px 18px; text-align: center; background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px dashed var(--stroke-2); overflow: hidden; }
.locked-panel::before { content:''; position:absolute; inset:0; background: radial-gradient(220px circle at 50% 0%, var(--gold-tint), transparent 70%); }
.lock-icon { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--gold); position: relative; }

/* ---- Auth screens ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; position: relative; z-index: 1; }
.auth-card { width: 100%; max-width: 400px; animation: fadeCardIn 0.5s var(--ease-out) both; }
.auth-hero { text-align: center; margin-bottom: 28px; }
.auth-hero .brand-mark { width: 46px; height: 46px; font-size: 21px; margin: 0 auto 14px; border-radius: var(--r-sm); }
.auth-hero h1 { font-size: 22px; margin-bottom: 6px; }
.auth-hero p { font-size: 13.5px; color: var(--text-lo); max-width: 320px; margin: 0 auto; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-lo); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--stroke); }
.auth-switch { text-align: center; font-size: 13.5px; margin-top: 18px; color: var(--text-lo); }

/* ---- Feed ---- */
.post-card { padding: 16px; }
.post-card.admin-post { border-color: rgba(47,217,146,0.35); background: linear-gradient(180deg, var(--community-green-tint), var(--panel)); }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-meta { display: flex; flex-direction: column; min-width: 0; }
.post-meta .name { font-weight: 700; color: var(--text-hi); font-size: 14px; }
.post-meta .sub { font-size: 12px; color: var(--text-lo); }
.post-body { font-size: 14.5px; color: var(--text-md); white-space: pre-wrap; overflow-wrap: anywhere; }
.post-actions { display: flex; gap: 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--stroke); }
.post-action { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-lo); font-weight: 600; background: none; border: none; cursor: pointer; padding: 4px; transition: color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-spring); }
.post-action svg { width: 17px; height: 17px; }
.post-action.liked { color: var(--community-green); }
.post-action:hover { color: var(--text-hi); }
.post-action:active { transform: scale(0.9); }
.pin-flag { display: inline-flex; align-items: center; gap: 4px; color: var(--community-green); font-size: 11px; font-weight: 700; }
.pin-flag svg { width: 12px; height: 12px; }

.composer { margin-bottom: 18px; }
.char-count { text-align: right; font-size: 11.5px; color: var(--text-lo); margin-top: -8px; margin-bottom: 12px; }
.char-count.warn { color: var(--danger); }
.comment { padding: 10px 0; border-top: 1px solid var(--stroke); font-size: 13.5px; }
.comment .name { font-weight: 700; color: var(--text-hi); }

/* ---- Classroom ---- */
.module-card { padding: 0; overflow: hidden; }
.module-head { padding: 16px 18px; border-bottom: 1px solid var(--stroke); background: linear-gradient(180deg, var(--community-green-tint), transparent); }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--stroke); transition: background var(--dur-fast) ease; }
.lesson-row:hover { background: var(--panel-2); }
.lesson-row:last-child { border-bottom: none; }
.lesson-row .idx { color: var(--text-lo); font-family: var(--font-mono); font-size: 12px; width: 20px; flex-shrink: 0; }
.lesson-row .title { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text-hi); font-weight: 600; overflow-wrap: anywhere; }
.lesson-row svg { width: 16px; height: 16px; color: var(--text-lo); flex-shrink: 0; }
.lesson-row.locked .title { color: var(--text-lo); }
.wizard-steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.wizard-step { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-lo); padding: 6px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--stroke); transition: all var(--dur-fast) ease; }
.wizard-step.done { color: var(--community-green); border-color: rgba(47,217,146,0.35); background: var(--community-green-tint); }
.wizard-step svg { width: 13px; height: 13px; }

/* ---- Leaderboard ---- */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--stroke); transition: background var(--dur-fast) ease; }
.rank-row:hover { background: var(--panel-2); }
.rank-row:last-child { border-bottom: none; }
.rank-num { width: 24px; font-family: var(--font-mono); font-weight: 700; color: var(--text-lo); font-size: 13px; flex-shrink: 0; }
.rank-num.top3 { color: var(--gold); }
.rank-row .avatar { width: 34px; height: 34px; font-size: 13px; }
.rank-row .name { font-size: 13.5px; font-weight: 700; color: var(--text-hi); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .pts { margin-left: auto; font-family: var(--font-mono); font-size: 13px; color: var(--community-green); font-weight: 700; flex-shrink: 0; }

/* ---- Section headers ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--community-green); font-weight: 750; margin-bottom: 6px; }
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--community-green); box-shadow: 0 0 8px var(--community-green-glow); }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 44px 20px; color: var(--text-lo); }
.empty-state svg { width: 36px; height: 36px; margin-bottom: 12px; color: var(--stroke-2); }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

/* ---- Utility ---- */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex { display: flex; flex-wrap: wrap; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.small { font-size: 12.5px; color: var(--text-lo); }

/* ---- Detail rows (admin member detail, etc.) ---- */
.detail-row { display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 11px 0; border-bottom: 1px solid var(--stroke); font-size: 13.5px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .detail-label { color: var(--text-lo); width: 140px; flex-shrink: 0; }
.detail-row .detail-value { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--text-hi); }
@media (max-width: 520px) {
  .detail-row { flex-direction: column; gap: 3px; padding: 12px 0; }
  .detail-row .detail-label { width: auto; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
}

/* ---- Avatar upload widget ---- */
.avatar-upload-wrap { position: relative; width: 88px; height: 88px; margin: 0 auto; }
.avatar-upload-wrap .avatar { width: 88px; height: 88px; min-width: 88px; min-height: 88px; font-size: 28px; cursor: pointer; }
.avatar-upload-btn { position: absolute; bottom: -2px; right: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--community-green); color: #04150d; display: flex; align-items: center; justify-content: center; border: 3px solid var(--bg); cursor: pointer; transition: transform var(--dur-fast) var(--ease-spring); }
.avatar-upload-btn:hover { transform: scale(1.1); }
.avatar-upload-btn svg { width: 14px; height: 14px; }

/* ---- Support tickets ---- */
.ticket-row { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-bottom: 1px solid var(--stroke); gap: 10px; flex-wrap: wrap; }
.ticket-row:last-child { border-bottom: none; }
.ticket-status { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status-OPEN { background: var(--gold-tint); color: var(--gold); }
.status-IN_PROGRESS { background: var(--info-tint); color: var(--info); }
.status-RESOLVED { background: var(--community-green-tint); color: var(--community-green); }
.status-NEW { background: var(--gold-tint); color: var(--gold); }
.status-REVIEWING { background: var(--info-tint); color: var(--info); }
.status-PLANNED { background: var(--community-green-tint); color: var(--community-green); }
.status-IMPLEMENTED { background: var(--community-green-tint); color: var(--community-green); }
.status-DECLINED { background: var(--danger-tint); color: var(--danger); }

/* ---- Chat bubbles ---- */
.chat-thread { display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 16px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; animation: fadeCardIn 0.3s var(--ease-out) both; }
.bubble-mine { align-self: flex-end; background: linear-gradient(155deg, var(--community-green), var(--community-green-dim)); color: #04150d; border-bottom-right-radius: 4px; }
.bubble-theirs { align-self: flex-start; background: var(--panel-2); color: var(--text-hi); border: 1px solid var(--stroke); border-bottom-left-radius: 4px; }
.bubble-time { font-size: 10.5px; opacity: 0.65; margin-top: 3px; }
.conversation-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--stroke); transition: background var(--dur-fast) ease; }
.conversation-row:hover { background: var(--panel-2); }
.conversation-row:last-child { border-bottom: none; }
.conversation-row .preview { font-size: 12.5px; color: var(--text-lo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---- Groups ---- */
.group-card { display: flex; align-items: center; gap: 14px; }
.group-icon { width: 46px; height: 46px; min-width: 46px; border-radius: var(--r-sm); background: var(--community-green-tint); color: var(--community-green); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.group-icon svg { width: 22px; height: 22px; }

/* ---- Suggestions ---- */
.suggestion-card { border-left: 3px solid var(--community-green); }

/* ---- Plan cards ---- */
.plan-badge-best { background: var(--community-green); color: #04150d; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }

/* ---- Tables (admin) — contained scroll, never breaks page layout ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); border: 1px solid var(--stroke); }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
td, th { overflow-wrap: normal; word-break: normal; padding: 12px 14px; text-align: left; white-space: nowrap; }
td { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
th { color: var(--text-lo); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--stroke); background: var(--panel-2); }
td { border-bottom: 1px solid var(--stroke); font-size: 13.5px; }
tbody tr { transition: background var(--dur-fast) ease; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }

/* =========================================================================
   EBOOKS EXTENSIONS — book grid, cover, detail, checkout, reader
   Built on top of the existing design tokens above. Same green signal
   color, same panel/glass surfaces, same radii/shadows/motion.
   ========================================================================= */

/* ---- Hero ---- */
.eb-hero { padding: 46px 0 30px; text-align: center; }
.eb-hero h1 { font-size: 30px; max-width: 620px; margin: 0 auto 10px; }
.eb-hero p { max-width: 480px; margin: 0 auto; font-size: 14.5px; }
.eb-search { max-width: 480px; margin: 20px auto 0; position: relative; }
.eb-search input { padding-left: 42px; }
.eb-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-lo); }

/* ---- Category chips ---- */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 26px; }
.chip { padding: 7px 14px; border-radius: 999px; font-size: 12.8px; font-weight: 650; color: var(--text-md); background: var(--panel-2); border: 1px solid var(--stroke); cursor: pointer; transition: all var(--dur-fast) ease; white-space: nowrap; }
.chip:hover { border-color: var(--stroke-2); color: var(--text-hi); }
.chip.active { background: var(--community-green-tint); color: var(--community-green); border-color: rgba(47,217,146,0.35); }

/* ---- Book grid + cover card ---- */
.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
@media (min-width: 640px)  { .book-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; } }
@media (min-width: 1000px) { .book-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 20px; } }
@media (min-width: 1300px) { .book-grid { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 20px; } }

.book-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; cursor: pointer; }
.book-cover-wrap { position: relative; width: 100%; aspect-ratio: 2/3; background: var(--panel-2); overflow: hidden; }
.book-cover-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-med) var(--ease-out); }
.book-card:hover .book-cover-wrap img { transform: scale(1.045); }
.book-cover-wrap::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.55)); pointer-events: none; }
.book-badge-owned { position: absolute; top: 8px; right: 8px; background: var(--community-green); color: #04150d; font-size: 10px; font-weight: 800; padding: 3px 9px; border-radius: 999px; z-index: 1; }
.book-card-body { padding: 12px 13px 14px; display: flex; flex-direction: column; flex: 1; }
.book-card-body .title { font-size: 13.8px; font-weight: 700; color: var(--text-hi); line-height: 1.3; margin-bottom: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card-body .author { font-size: 12px; color: var(--text-lo); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-card-body .price-row { margin-top: auto; display: flex; align-items: baseline; gap: 7px; }
.book-card-body .price { font-family: var(--font-mono); font-weight: 700; color: var(--community-green); font-size: 14.5px; }
.book-card-body .mrp { font-size: 12px; color: var(--text-lo); text-decoration: line-through; }

/* ---- Book detail page ---- */
.book-detail { display: grid; grid-template-columns: 1fr; gap: 26px; }
@media (min-width: 760px) { .book-detail { grid-template-columns: 300px 1fr; gap: 36px; align-items: start; } }
.book-detail-cover { border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-3); aspect-ratio: 2/3; background: var(--panel-2); position: sticky; top: 24px; }
.book-detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-detail-info h1 { font-size: 24px; margin-bottom: 4px; }
.book-detail-info .author { font-size: 14px; color: var(--text-md); margin-bottom: 14px; }
.book-buy-box { display: flex; align-items: center; gap: 16px; padding: 18px; margin: 18px 0; }
.book-buy-box .price { font-family: var(--font-mono); font-size: 24px; font-weight: 800; color: var(--community-green); }
.book-buy-box .mrp { font-size: 13px; color: var(--text-lo); text-decoration: line-through; margin-left: 4px; }
.book-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.book-tag { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); color: var(--text-lo); border: 1px solid var(--stroke); }

/* ---- Checkout modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(3,4,5,0.7); backdrop-filter: blur(4px); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity var(--dur-med) ease; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 24px; animation: fadeCardIn 0.35s var(--ease-out) both; }

/* ---- My Library ---- */
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
@media (min-width: 640px) { .library-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; } }
@media (min-width: 1000px) { .library-grid { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 18px; } }

/* ---- Reader ---- */
.reader-shell { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--stroke); background: var(--bg-soft); flex-shrink: 0; gap: 10px; }
.reader-toolbar .title { font-size: 13.5px; font-weight: 700; color: var(--text-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-page-nav { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-md); }
.reader-canvas-wrap { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 20px 0 60px; position: relative; background: #0a0a0c; }
.reader-canvas-wrap canvas { box-shadow: var(--shadow-3); border-radius: 2px; max-width: 94%; }
.reader-watermark { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
@media print { .reader-shell, body * { display: none !important; } }

/* ---- Access gate (email+phone re-confirmation before reading) ---- */
.gate-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 400px; }

/* ---- Admin: cover thumb in table ---- */
.admin-cover-thumb { width: 40px; height: 58px; object-fit: cover; border-radius: 4px; border: 1px solid var(--stroke); flex-shrink: 0; }
.upload-drop { border: 1px dashed var(--stroke-2); border-radius: var(--r-md); padding: 22px; text-align: center; cursor: pointer; transition: border-color var(--dur-fast) ease; }
.upload-drop:hover { border-color: var(--community-green); }
.upload-drop.has-file { border-color: var(--community-green); background: var(--community-green-tint); }
