/* ============================================================
   Bayt Al-Rahim — بيت الرحيم
   Design system : vert émeraude + or + blanc, mode sombre, RTL
   ============================================================ */

:root {
  --emerald: #1a5c45;
  --emerald-light: #2d8c6a;
  --emerald-pale: #e8f5f0;
  --gold: #c9a84c;
  --gold-light: #f0d080;
  --gold-pale: #fdf8ec;
  --dark: #0f1f1a;

  --bg: #f4f9f6;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --text: #1e3a2f;
  --text-light: #5a7a6e;
  --border: #c8ddd6;

  --danger: #c0392b;
  --danger-pale: #ffeaea;
  --warn: #b7800a;
  --warn-pale: #fff5d6;
  --info: #1a6ebc;
  --info-pale: #eaf3ff;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 18px rgba(26, 92, 69, 0.10);
  --shadow-lg: 0 10px 34px rgba(15, 31, 26, 0.18);

  --font: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-arabic: 'Amiri', 'Scheherazade New', serif;

  --font-scale: 1;
  --header-h: 60px;
  --tabbar-h: 66px;
  --maxw: 760px;
}

/* Dark mode -------------------------------------------------- */
html[data-theme='dark'] {
  --bg: #0c1714;
  --surface: #13241e;
  --surface-2: #18302770;
  --text: #e8f3ee;
  --text-light: #8fb3a6;
  --border: #224237;
  --emerald-pale: #16302593;
  --gold-pale: #2a2410;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: calc(16px * var(--font-scale)); }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* RTL adjustments ------------------------------------------- */
html[dir='rtl'] body { font-family: var(--font-arabic), var(--font); }
html[dir='rtl'] .tabbar-label { letter-spacing: 0; }

button, input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
}
button { cursor: pointer; }
img { max-width: 100%; display: block; }
a { color: var(--emerald-light); }

.arabic { font-family: var(--font-arabic); direction: rtl; }

/* ============================================================
   App shell
   ============================================================ */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 60px rgba(0,0,0,0.06);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--dark), var(--emerald));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.app-header .h-logo {
  font-family: var(--font-arabic);
  font-size: 1.5rem;
  color: var(--gold-light);
  line-height: 1;
}
.app-header .h-title { font-weight: 800; font-size: 1.02rem; flex: 1; }
.app-header .h-title small { display: block; font-weight: 600; font-size: 0.7rem; opacity: 0.75; }
.app-header .h-btn {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 1.05rem;
  display: grid; place-items: center;
}
.app-header .h-btn:active { transform: scale(0.94); }
.app-header .h-btn svg { width: 20px; height: 20px; fill: #fff; }

.app-main {
  padding: 16px 16px calc(var(--tabbar-h) + 24px);
  min-height: calc(100dvh - var(--header-h));
}

/* Tab bar --------------------------------------------------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--maxw);
  height: var(--tabbar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.tab {
  flex: 1;
  background: none; border: none;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-light);
  padding: 6px 2px;
  transition: color 0.15s;
}
.tab .tab-ico { font-size: 1.35rem; line-height: 0; }
.tab .tab-ico svg { width: 25px; height: 25px; display: block; margin: 0 auto; }
.tab .tab-label { font-size: 0.62rem; font-weight: 700; }
.tab.active { color: var(--emerald); }
html[data-theme='dark'] .tab.active { color: var(--gold-light); }
.tab.active .tab-ico { transform: translateY(-1px); }
.tab { position: relative; }
.tab .tab-dot {
  position: absolute;
  top: 6px; inset-inline-end: calc(50% - 18px);
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--surface);
}

/* ============================================================
   Reusable components
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.card-head .ch-ico {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 1.15rem;
  background: var(--emerald-pale);
  color: var(--emerald);
}
.card-head .ch-title { font-weight: 800; font-size: 1rem; }
.card-head .ch-sub { font-size: 0.75rem; color: var(--text-light); }
.card-head .ch-action { margin-inline-start: auto; }

.section-title {
  font-weight: 800;
  font-size: 1.1rem;
  margin: 4px 2px 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title .st-line { flex: 1; height: 1px; background: var(--border); }

.muted { color: var(--text-light); }
.center { text-align: center; }
.small { font-size: 0.8rem; }
.tiny { font-size: 0.7rem; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

/* Buttons --------------------------------------------------- */
.btn {
  background: var(--emerald);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 800;
  font-size: 0.92rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.06); }
.btn.block { display: flex; width: 100%; }
.btn.gold { background: var(--gold); color: var(--dark); }
.btn.ghost { background: var(--emerald-pale); color: var(--emerald); }
.btn.outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 13px; font-size: 0.82rem; border-radius: 9px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--emerald-pale);
  color: var(--emerald);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.chip.gold { background: var(--gold-pale); color: var(--warn); }
.chip.outline { background: transparent; border-color: var(--border); color: var(--text-light); }
.chip.danger { background: var(--danger-pale); color: var(--danger); }
.chip.info { background: var(--info-pale); color: var(--info); }
.chip button { background: none; border: none; color: inherit; font-weight: 800; opacity: 0.6; }

/* Form fields ----------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 0.82rem; margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--emerald-light);
}
.textarea { resize: vertical; min-height: 84px; }

/* Avatar ---------------------------------------------------- */
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; color: #fff;
  font-size: 1.05rem; flex-shrink: 0;
  background: var(--emerald-light);
  overflow: hidden;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar.sm { width: 34px; height: 34px; font-size: 0.8rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Verse / arabic blocks ------------------------------------ */
.verse-ar {
  font-family: var(--font-arabic);
  direction: rtl;
  font-size: 1.7rem;
  line-height: 2.4;
  text-align: center;
  color: var(--text);
}
.verse-tr { font-style: italic; color: var(--text-light); font-size: 0.86rem; text-align: center; margin-top: 6px; }
.verse-fr { text-align: center; margin-top: 10px; font-size: 0.98rem; }
.verse-ref { text-align: center; margin-top: 8px; font-weight: 800; color: var(--gold); font-size: 0.82rem; }

/* Banner / hero gradient ----------------------------------- */
.hero {
  background: linear-gradient(140deg, var(--dark), var(--emerald) 70%, var(--emerald-light));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero h2 { font-size: 1.25rem; font-weight: 800; }
.hero .h-greet { font-size: 0.85rem; opacity: 0.85; }
.hero .arabic-deco {
  position: absolute; inset-inline-end: -10px; top: -14px;
  font-family: var(--font-arabic); font-size: 4.5rem;
  color: rgba(255,255,255,0.08);
}

/* Countdown pills ------------------------------------------ */
.countdown { display: flex; gap: 8px; justify-content: center; }
.cd-cell {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 0; min-width: 52px; text-align: center;
}
.cd-cell b { font-size: 1.3rem; font-weight: 800; display: block; line-height: 1; }
.cd-cell span { font-size: 0.6rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; }

/* Prayer list ---------------------------------------------- */
.prayer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--border);
}
.prayer-row:last-child { border-bottom: none; }
.prayer-row.next { background: var(--emerald-pale); border-radius: 10px; padding-inline: 12px; border-bottom: none; }
.prayer-row .p-name { font-weight: 800; flex: 1; }
.prayer-row .p-time { font-weight: 800; font-variant-numeric: tabular-nums; }
.prayer-row .p-ar { font-family: var(--font-arabic); color: var(--text-light); }

/* Progress bar --------------------------------------------- */
.progress { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald), var(--emerald-light)); border-radius: 6px; transition: width 0.4s; }

/* Tasbih counter ------------------------------------------- */
.tasbih {
  text-align: center; padding: 8px 0 4px;
}
.tasbih-num {
  font-size: 3.4rem; font-weight: 800; color: var(--emerald);
  line-height: 1; font-variant-numeric: tabular-nums;
}
html[data-theme='dark'] .tasbih-num { color: var(--gold-light); }
.tasbih-btn {
  width: 150px; height: 150px; border-radius: 50%;
  margin: 14px auto; border: none;
  background: radial-gradient(circle at 35% 30%, var(--emerald-light), var(--emerald));
  color: #fff; font-weight: 800; font-size: 1rem;
  box-shadow: 0 8px 26px rgba(26,92,69,0.4);
  transition: transform 0.08s;
}
.tasbih-btn:active { transform: scale(0.93); }
.dhikr-tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.dhikr-tab {
  border: 1.5px solid var(--border); background: var(--surface);
  border-radius: 20px; padding: 6px 12px; font-size: 0.78rem; font-weight: 700; color: var(--text-light);
}
.dhikr-tab.active { background: var(--emerald); color: #fff; border-color: var(--emerald); }

/* Family tree ---------------------------------------------- */
.tree { padding: 6px 0; }
.tree-root { text-align: center; margin-bottom: 8px; }
.branch {
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--bcolor, var(--emerald));
  border-radius: 12px; padding: 12px; margin-bottom: 12px;
  background: var(--surface);
}
.branch-title { font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.branch-title .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bcolor, var(--emerald)); }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px,1fr)); gap: 10px; }
.member-mini { text-align: center; }
.member-mini .avatar { margin: 0 auto 5px; }
.member-mini .mm-name { font-size: 0.74rem; font-weight: 700; line-height: 1.2; }
.member-mini .mm-city { font-size: 0.64rem; color: var(--text-light); }

/* Genealogy tree nodes ------------------------------------- */
.ancestry-line {
  text-align: center; font-size: 0.82rem; font-weight: 700; color: var(--text-light);
  background: var(--bg); border: 1px dashed var(--border); border-radius: 12px;
  padding: 8px 10px; margin-bottom: 4px;
}
.ancestry-down { color: var(--gold); font-weight: 800; line-height: 1; }
.person { margin: 4px 0; }
.person-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; width: 100%; text-align: start;
  background: var(--surface); border: 1px solid var(--border);
}
.person-row:active { background: var(--emerald-pale); }
.person-row .pr-name { font-weight: 800; font-size: 1.02rem; line-height: 1.2; }
.person-row .pr-sub { font-size: 0.74rem; color: var(--text-light); }
.person-spouses { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; padding-inline-start: 52px; }
.person-spouse {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.7rem; color: var(--text-light);
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 2px 8px;
}
.person-children {
  margin-inline-start: 22px;
  border-inline-start: 2px dashed var(--border);
  padding-inline-start: 12px; margin-top: 4px;
}
.add-mini {
  border: 1.5px dashed var(--border); background: transparent; color: var(--text-light);
  border-radius: 10px; padding: 6px 10px; font-size: 0.72rem; font-weight: 700;
}
.add-mini:active { background: var(--emerald-pale); }

/* Visionneuse photo plein écran ---------------------------- */
.photo-viewer {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(8, 14, 12, 0.96);
  display: flex; align-items: center; justify-content: center;
}
.pv-img { max-width: 96vw; max-height: 80vh; object-fit: contain; border-radius: 10px; }
.pv-close {
  position: absolute; top: 16px; inset-inline-end: 16px;
  background: rgba(255,255,255,0.16); color: #fff; border: none;
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.2rem;
}
.pv-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.16); color: #fff; border: none;
  width: 46px; height: 70px; font-size: 1.8rem; border-radius: 14px;
}
.pv-prev { inset-inline-start: 10px; }
.pv-next { inset-inline-end: 10px; }
.pv-caption {
  position: absolute; bottom: 22px; left: 0; right: 0;
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  color: #fff; font-weight: 800; text-align: center;
}

/* Trombinoscope (famille en photos) ------------------------ */
.trombi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 14px 8px;
}
.trombi-cell { background: none; border: none; text-align: center; padding: 0; }
.trombi-cell .avatar { margin: 0 auto 5px; }
.trombi-cell span { display: block; font-size: 0.72rem; font-weight: 700; line-height: 1.15; }
.trombi-cell small { display: block; font-size: 0.62rem; color: var(--text-light); }
.trombi-cell:active .avatar { transform: scale(0.94); }

/* Photo gallery -------------------------------------------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell { border: none; padding: 0; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: var(--bg); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }

/* List rows ------------------------------------------------ */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  margin-bottom: 10px; width: 100%; text-align: start;
}
.list-row .lr-title { font-weight: 800; font-size: 0.92rem; }
.list-row .lr-sub { font-size: 0.76rem; color: var(--text-light); }
.list-row .lr-end { margin-inline-start: auto; text-align: end; }

/* ============================================================
   Style WhatsApp — liste de discussions, chat plein écran,
   statuts, bouton flottant
   ============================================================ */
/* Liste des discussions */
.wa-list { margin: -16px -16px 0; background: var(--surface); }
.wa-row {
  display: flex; align-items: center; gap: 13px;
  width: 100%; text-align: start;
  padding: 12px 16px;
  background: var(--surface);
  border: none; border-bottom: 1px solid var(--border);
}
.wa-row:active { background: var(--emerald-pale); }
.wa-row .wa-main { flex: 1; min-width: 0; }
.wa-row .wa-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wa-row .wa-name { font-weight: 800; font-size: 0.98rem; }
.wa-row .wa-time { font-size: 0.68rem; color: var(--text-light); flex-shrink: 0; }
.wa-row .wa-time.hot { color: #25d366; font-weight: 800; }
.wa-row .wa-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wa-row .wa-preview {
  color: var(--text-light); font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wa-badge {
  background: #25d366; color: #fff;
  border-radius: 12px; min-width: 20px; height: 20px; padding: 0 6px;
  font-size: 0.68rem; font-weight: 800;
  display: grid; place-items: center; flex-shrink: 0;
}
/* Bandeau prière (comme la ligne "Archivées") */
.wa-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface);
  border: none; border-bottom: 1px solid var(--border);
  width: 100%; text-align: start;
  font-size: 0.82rem; color: var(--text-light);
}
.wa-banner b { color: var(--emerald); }
html[data-theme='dark'] .wa-banner b { color: var(--gold-light); }

/* Bouton flottant (FAB) */
.fab {
  position: fixed;
  bottom: calc(var(--tabbar-h) + 18px);
  inset-inline-end: max(18px, calc(50% - var(--maxw)/2 + 18px));
  width: 58px; height: 58px;
  border-radius: 18px;
  border: none;
  background: linear-gradient(135deg, #25d366, var(--emerald-light));
  color: #fff; font-size: 1.5rem;
  box-shadow: 0 6px 18px rgba(18, 140, 126, 0.45);
  z-index: 70;
  display: grid; place-items: center;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 26px; height: 26px; fill: #fff; }
.send-btn svg { width: 21px; height: 21px; fill: currentColor; display: block; margin: 0 auto; }

/* Chat plein écran */
.chat-page {
  position: fixed; inset: 0; z-index: 150;
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.chat-topbar {
  background: linear-gradient(135deg, var(--dark), var(--emerald));
  color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  flex-shrink: 0;
}
.chat-topbar .ct-back {
  background: none; border: none; color: #fff;
  font-size: 1.3rem; padding: 4px 8px;
}
.chat-topbar .ct-name { font-weight: 800; font-size: 0.98rem; line-height: 1.2; }
.chat-topbar .ct-sub { font-size: 0.68rem; opacity: 0.8; }
.chat-body {
  flex: 1; overflow-y: auto;
  padding: 14px 12px;
  background:
    radial-gradient(circle at 20% 20%, rgba(201,168,76,0.05) 0 6px, transparent 7px),
    radial-gradient(circle at 80% 60%, rgba(26,92,69,0.05) 0 5px, transparent 6px),
    var(--bg);
  background-size: 90px 90px, 70px 70px, auto;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-inputbar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-inputbar .input { border-radius: 24px; }
.send-btn {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 50%; border: none;
  background: linear-gradient(135deg, #25d366, var(--emerald-light));
  color: #fff; font-size: 1.1rem;
}
.send-btn:active { transform: scale(0.92); }
.chat-notice {
  align-self: center;
  background: var(--gold-pale); color: var(--warn);
  font-size: 0.68rem; font-weight: 700;
  border-radius: 10px; padding: 6px 12px;
  text-align: center; max-width: 90%;
  margin-bottom: 6px;
}

/* Statuts (ronds façon WhatsApp Actus) */
.status-row {
  display: flex; gap: 14px;
  overflow-x: auto; scrollbar-width: none;
  padding: 4px 2px 12px;
}
.status-row::-webkit-scrollbar { display: none; }
.status-item { background: none; border: none; width: 66px; flex-shrink: 0; text-align: center; }
.status-ring {
  width: 58px; height: 58px; margin: 0 auto 4px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 1.5rem;
}
.status-item span { font-size: 0.62rem; font-weight: 700; color: var(--text-light); display: block; }
.status-item:active .status-ring { transform: scale(0.94); }

/* Chat ----------------------------------------------------- */
.chat-wrap { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; padding: 9px 13px; border-radius: 14px; }
.msg .msg-author { font-size: 0.68rem; font-weight: 800; color: var(--emerald-light); margin-bottom: 2px; }
.msg .msg-text { font-size: 0.9rem; }
.msg .msg-time { font-size: 0.6rem; color: var(--text-light); text-align: end; margin-top: 2px; }
.msg.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--emerald); color: #fff; border-bottom-right-radius: 4px; }
.msg.me .msg-time, .msg.me .msg-author { color: rgba(255,255,255,0.7); }
.chat-input {
  position: sticky; bottom: calc(var(--tabbar-h) + 6px);
  display: flex; gap: 8px; padding-top: 8px;
}
.chat-input .input { background: var(--surface); }

/* Transactions --------------------------------------------- */
.tx-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tx-row:last-child { border-bottom: none; }
.tx-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 1rem; flex-shrink: 0; }
.tx-in { background: var(--emerald-pale); color: var(--emerald); }
.tx-out { background: var(--danger-pale); color: var(--danger); }
.tx-amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.tx-amt.plus { color: var(--emerald); }
.tx-amt.minus { color: var(--danger); }

/* Balance card --------------------------------------------- */
.balance {
  background: linear-gradient(135deg, var(--emerald), var(--emerald-light));
  color: #fff; border-radius: var(--radius); padding: 22px; text-align: center;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.balance .b-label { font-size: 0.78rem; opacity: 0.85; }
.balance .b-amount { font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.balance .deco { position: absolute; font-family: var(--font-arabic); font-size: 4rem; opacity: 0.1; inset-inline-end: 8px; bottom: -10px; }

/* Calendar / events ---------------------------------------- */
.event-card { display: flex; gap: 12px; }
.event-date {
  text-align: center; flex-shrink: 0;
  background: var(--emerald-pale); color: var(--emerald);
  border-radius: 12px; padding: 8px 10px; min-width: 56px;
}
.event-date b { display: block; font-size: 1.5rem; line-height: 1; }
.event-date span { font-size: 0.66rem; text-transform: uppercase; font-weight: 700; }

/* Charter / callout ---------------------------------------- */
.callout {
  background: var(--gold-pale);
  border-inline-start: 4px solid var(--gold);
  border-radius: 0 12px 12px 0;
  padding: 14px 16px; font-size: 0.86rem;
}
.callout strong { color: var(--text); }

/* Vote bars ------------------------------------------------- */
.vote-opt { margin-bottom: 10px; }
.vote-opt .vo-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }
.vote-bar { height: 30px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; position: relative; }
.vote-bar > i { display: block; height: 100%; background: var(--emerald-pale); }
.vote-bar.voted > i { background: var(--gold-pale); }

/* Modal / sheet -------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15,31,26,0.55);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s;
}
.sheet {
  background: var(--surface); width: 100%; max-width: var(--maxw);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom,0));
  max-height: 90dvh; overflow-y: auto; animation: slideup 0.25s;
}
.sheet-handle { width: 42px; height: 4px; background: var(--border); border-radius: 3px; margin: 0 auto 14px; }
.sheet h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(40px); opacity: 0.6; } }

/* Toast ----------------------------------------------------- */
.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--dark); color: #fff; padding: 11px 20px; border-radius: 24px;
  font-size: 0.85rem; font-weight: 700; z-index: 300; box-shadow: var(--shadow-lg);
  animation: fade 0.2s; max-width: 90%; text-align: center;
}

/* Empty state ---------------------------------------------- */
.empty { text-align: center; color: var(--text-light); padding: 30px 16px; }
.empty .e-ico { font-size: 2.4rem; margin-bottom: 8px; opacity: 0.6; }

/* Stat grid ------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 8px; text-align: center;
}
.stat b { font-size: 1.4rem; font-weight: 800; color: var(--emerald); display: block; line-height: 1; }
html[data-theme='dark'] .stat b { color: var(--gold-light); }
.stat span { font-size: 0.66rem; color: var(--text-light); }

/* Skeleton loading ----------------------------------------- */
.skel { background: linear-gradient(90deg, var(--border), var(--bg), var(--border)); background-size: 200% 100%; border-radius: 8px; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Onboarding ------------------------------------------------ */
.onb {
  min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; padding: 28px 22px;
  background: linear-gradient(160deg, var(--dark), var(--emerald) 70%, var(--emerald-light));
  color: #fff;
}
.onb .onb-logo { font-family: var(--font-arabic); font-size: 3.4rem; color: var(--gold-light); text-align: center; }
.onb h1 { text-align: center; font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.onb .onb-sub { text-align: center; opacity: 0.82; margin-bottom: 26px; font-size: 0.9rem; }
.onb .card { color: var(--text); }

/* utility spacing */
.stack > * + * { margin-top: 10px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.badge-count {
  background: var(--gold); color: var(--dark); border-radius: 12px;
  font-size: 0.6rem; font-weight: 800; padding: 1px 7px; margin-inline-start: 4px;
}
