/* ==========================================================================
   MUHAMI IQ (مُحامي العراق) - Design System
   Stack: HTML5 / Vanilla CSS / ES6 JavaScript
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
  --primary-navy: #001a38;
  --primary-dark: #001229;
  --secondary-navy: #002957;
  --accent-gold: #d4af37;
  --accent-gold-bright: #ffd700;
  --accent-gold-dark: #c59b27;
  --bg-surface: #f4f7fc;
  --bg-card: #ffffff;
  --text-main: #0a192f;
  --heading: #0a192f;
  --text-muted: #5a6e85;
  --text-light: #8ea8cc;
  --border-color: #e1e8f2;
  --border-dark: #002d5e;
  --shadow-sm: 0 2px 8px rgba(0, 26, 56, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 26, 56, 0.12);
  --shadow-lg: 0 16px 40px rgba(0, 26, 56, 0.18);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --font-tajawal: 'Tajawal', sans-serif;
  --font-ibm: 'IBM Plex Sans Arabic', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-tajawal);
}

html {
  overflow-x: clip;
}

body {
  background-color: var(--bg-surface);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Kill horizontal scroll on every page without breaking sticky headers
     (clip, unlike hidden, does not create a scroll container). */
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   Header & Web Navbar
   ========================================================================== */
.site-header {
  background: var(--primary-navy);
  border-bottom: 1px solid var(--border-dark);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.nav-toggle-btn {
  display: none;
}

.auth-lang-switch {
  position: fixed;
  top: 16px;
  inset-inline-start: 16px;
  z-index: 40;
}
.auth-lang-switch .lang-switch {
  background: var(--primary-navy);
}

.lang-switch {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid rgba(212, 175, 55, 0.55);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.lang-switch-btn {
  border: none;
  background: transparent;
  color: #c5d4ea;
  padding: 6px 11px;
  font-weight: 800;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  line-height: 1.2;
}
.lang-switch-btn[aria-pressed="true"] {
  background: var(--accent-gold);
  color: var(--primary-navy);
}
.lang-switch-btn:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-gold-bright);
  outline-offset: 2px;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  row-gap: 10px;
}

.brand-badge-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.syndicate-logo-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #000;
  border: 2px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.syndicate-logo-circle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title-main {
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-tajawal);
  letter-spacing: -0.2px;
}

.brand-title-sub {
  color: var(--accent-gold-bright);
  font-size: 0.75rem;
  font-family: var(--font-ibm);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}

.nav-link {
  color: #b0c4de;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link i {
  font-size: 0.92em;
  line-height: 1;
  flex-shrink: 0;
}

.nav-link:hover, .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.nav-actions .btn {
  white-space: nowrap;
  line-height: 1.2;
  padding: 8px 14px;
  flex-shrink: 0;
}

.nav-actions .hero-header-badge {
  margin: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  padding: 7px 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--accent-gold-bright), var(--accent-gold));
  transform: translateY(-1px);
}

.btn-navy {
  background: var(--secondary-navy);
  color: #ffffff;
  border: 1px solid var(--border-dark);
}

.btn-navy:hover {
  background: var(--primary-navy);
}

.btn-outline {
  background: transparent;
  color: var(--primary-navy);
  border: 1px solid var(--primary-navy);
}

.btn-outline:hover {
  background: rgba(0, 26, 56, 0.05);
}

/* ==========================================================================
   Main Content Layout Container
   ========================================================================== */
.main-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
}

/* ==========================================================================
   Hero Banner Section
   ========================================================================== */
.hero-card {
  background: linear-gradient(135deg, var(--primary-navy) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 40px;
  color: #ffffff;
  margin-bottom: 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -100px;
  left: -100px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.08);
  pointer-events: none;
}

.hero-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 6px 14px;
  border-radius: 50px;
  color: var(--accent-gold-bright);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero-header-badge i {
  flex-shrink: 0;
  line-height: 1;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 12px;
}

.hero-subtitle {
  color: var(--text-light);
  font-size: 1.05rem;
  max-width: 800px;
  line-height: 1.7;
  margin-bottom: 28px;
}

.hero-stats-row {
  display: flex;
  align-items: center;
  gap: 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 24px;
  margin-top: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-val {
  color: var(--accent-gold-bright);
  font-size: 1.6rem;
  font-weight: 900;
}

.stat-lab {
  color: #b0c4de;
  font-size: 0.85rem;
}

/* ==========================================================================
   Search & Filter Controls
   ========================================================================== */
.search-box-wrap {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  margin-top: 20px;
  border: 2px solid var(--border-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box-wrap:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
}

.search-input,
.form-control[type="search"],
.form-control[type="text"]#findSearch,
#mainSearchInput {
  border: none;
  outline: none;
  flex: 1;
  font-size: 1rem;
  color: var(--text-main);
  padding: 10px 8px;
  background: transparent;
  min-width: 0;
}

/* ==========================================================================
   Lawbooks Grid & Cards
   ========================================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--heading);
  display: flex;
  align-items: center;
  gap: 10px;
}

.law-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.law-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.law-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-gold);
}

.law-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.law-cat-badge {
  background: #eef4fc;
  color: var(--secondary-navy);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.law-card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--heading);
  margin-bottom: 8px;
}

.law-card-summary {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.law-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.article-count-tag {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==========================================================================
   Admin Dashboard & Roster Table
   ========================================================================== */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon-circle {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: #eef4fc;
  color: var(--primary-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-info-title {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-info-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--heading);
}

.data-table-container {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 32px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.data-table th {
  background: #f8fafc;
  padding: 14px 18px;
  font-weight: 800;
  color: var(--heading);
  border-bottom: 2px solid var(--border-color);
  font-size: 0.9rem;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.92rem;
}

.data-table tr:hover {
  background: #f8fafc;
}

.badge-uid {
  font-family: monospace;
  background: var(--primary-navy);
  color: var(--accent-gold-bright);
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.85rem;
  display: inline-block;
}

.badge-status {
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-block;
  white-space: nowrap;
}

.badge-status.registered {
  background: #dcfce7;
  color: #15803d;
}

.badge-status.pending {
  background: #fef9c3;
  color: #a16207;
}

.badge-status.published {
  background: #ccfbf1;
  color: #0f766e;
}

.admin-status-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 120px;
}

.admin-actions-cell {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}

.admin-actions-cell .btn {
  padding: 6px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.admin-roster-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-roster-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-pagination-btns .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.admin-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  flex-wrap: wrap;
}

.admin-pagination-info {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.admin-pagination-btns {
  display: flex;
  gap: 8px;
}

.data-table th:last-child,
.data-table td:last-child {
  white-space: nowrap;
}

/* ==========================================================================
   Lawyer Studio & 2-Column Desktop Grid
   ========================================================================== */
.lawyer-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

@media (max-width: 1100px) {
  .brand-title-sub {
    display: none;
  }

  .nav-link {
    padding: 7px 10px;
    font-size: 0.82rem;
  }

  .nav-actions .hero-header-badge {
    max-width: 140px;
  }
}

@media (max-width: 900px) {
  .lawyer-grid-layout {
    grid-template-columns: 1fr;
  }

  .header-inner {
    gap: 10px;
  }

  .nav-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(212,175,55,.4);
    background: rgba(255,255,255,.08);
    color: var(--accent-gold);
    border-radius: 10px;
    cursor: pointer;
    margin-inline-start: auto;
  }

  .nav-links {
    display: none;
    order: 4;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 0 4px;
  }

  body.nav-open .nav-links {
    display: flex;
  }

  .header-inner {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .nav-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 8px;
    min-width: 0;
  }

  .nav-actions .btn {
    padding: 8px 12px;
    font-size: 0.82rem;
    flex-shrink: 1;
  }

  .nav-actions .hero-header-badge {
    max-width: 60vw;
    flex-shrink: 1;
  }

  /* Uncontrolled inline `grid-template-columns` rows (lawyer studio + admin
     forms) must collapse to one column on narrow screens. auto-fit/minmax
     tracks are already responsive and are deliberately left alone. */
  .main-container [style*="grid-template-columns: 1fr 1fr"],
  .main-container [style*="grid-template-columns:1fr 1fr"],
  .main-container [style*="grid-template-columns: 2fr 1fr"],
  .main-container [style*="grid-template-columns:2fr 1fr"],
  .main-container [style*="grid-template-columns: 1fr 2fr"],
  .main-container [style*="grid-template-columns:1fr 2fr"] {
    grid-template-columns: 1fr !important;
  }

  .main-container input,
  .main-container select,
  .main-container textarea {
    max-width: 100%;
  }

  .hero-title {
    font-size: 1.35rem;
  }

  .hero-stats-row,
  .search-box-wrap,
  .home-doors {
    flex-direction: column;
    align-items: stretch;
  }

  .home-doors {
    grid-template-columns: 1fr;
  }

  .search-box-wrap .btn,
  .search-input {
    width: 100%;
  }

  .data-table-container,
  .pm-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table,
  .pm-table {
    min-width: 640px;
  }

  .admin-roster-toolbar,
  .admin-roster-tools,
  .pm-page-head,
  .pm-topbar {
    flex-direction: column;
    align-items: stretch !important;
  }

  .admin-roster-tools .form-control {
    width: 100% !important;
  }

  #addNewsForm,
  #addPublicInterestForm {
    grid-template-columns: 1fr !important;
  }

  .stat-row {
    grid-template-columns: 1fr !important;
  }

  #testimonialComposer > div {
    grid-template-columns: 1fr !important;
  }

  .law-grid {
    grid-template-columns: 1fr;
  }

  .main-container {
    padding: 16px 12px;
  }

  .card-panel,
  .hero-card {
    padding: 16px !important;
  }

  .pm-top-actions {
    flex-wrap: wrap;
  }

  .pm-top-actions .btn {
    flex: 1 1 auto;
  }

  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

.card-panel {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 28px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--heading);
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  outline: none;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

/* Auth pages (login / register) - centered card, no horizontal overflow */
body.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow-x: hidden;
  background: linear-gradient(135deg, #001229 0%, #002957 100%);
}

body.auth-page .card-panel {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  box-sizing: border-box;
  box-shadow: var(--shadow-lg);
}

body.auth-page.auth-page-register .card-panel {
  max-width: 500px;
}

.easy-captcha {
  position: relative;
  margin-bottom: 18px;
  overflow: hidden;
}

.easy-captcha-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.easy-captcha-prompt {
  flex: 0 1 auto;
  min-width: 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: #0b1f3a;
  color: #f5d78e;
  font-weight: 800;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.5px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  white-space: nowrap;
}

.easy-captcha-input {
  flex: 1 1 72px;
  min-width: 64px;
  max-width: 120px;
  text-align: center;
  font-weight: 700;
}

.easy-captcha-refresh {
  padding: 10px 12px;
  flex-shrink: 0;
}

/* Visually hidden honeypot - never use left:-9999px (breaks RTL scroll width) */
.easy-captcha-hp {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 480px) {
  body.auth-page {
    padding: 16px 12px;
    justify-content: flex-start;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  body.auth-page .card-panel {
    padding: 20px 16px;
    border-radius: 12px;
  }

  body.auth-page h2 {
    font-size: 1.15rem !important;
  }

  .easy-captcha-row {
    flex-wrap: wrap;
  }

  .easy-captcha-prompt {
    flex: 1 1 100%;
    font-size: 1rem;
  }

  .easy-captcha-input {
    flex: 1 1 auto;
    max-width: none;
  }
}

/* Photo Studio Box */
.photo-studio-box {
  background: linear-gradient(135deg, #001229, #00244d);
  border-radius: var(--radius-md);
  padding: 24px;
  color: #ffffff;
  text-align: center;
  margin-bottom: 24px;
  border: 1px solid var(--border-dark);
}

.portrait-preview-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  margin: 0 auto 16px;
  border: 3px solid var(--accent-gold);
  overflow: hidden;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
  position: relative;
  background: #ffffff;
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.studio-toggles {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.toggle-chip {
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
  user-select: none;
}

.toggle-chip.active {
  background: var(--accent-gold);
  color: var(--primary-navy);
  font-weight: bold;
  border-color: var(--accent-gold-bright);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 18, 41, 0.75);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 1200px;
  width: 95vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: #eef4fc;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--primary-dark);
  border-top: 1px solid var(--border-dark);
  color: #ffffff;
  padding: 40px 0 20px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

/* The footer had no responsive rule at all, so every page squeezed its three
   columns into ~85px/42px/42px on a phone. */
@media (max-width: 760px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 26px;
    padding: 0 18px;
  }
}

.footer-copyright {
  text-align: center;
  border-top: 1px solid var(--border-dark);
  padding-top: 20px;
  color: #617b9e;
  font-size: 0.85rem;
}

/* ==========================================================================
   App Toast Notifications (non-blocking alerts)
   ========================================================================== */
.app-toast-host {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  inset-block-start: auto;
  inset-inline-start: auto;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 24px));
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #0b1f33;
  color: #fff;
  border: 1px solid rgba(212, 175, 55, 0.45);
  box-shadow: 0 14px 34px rgba(0, 18, 41, 0.28);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.app-toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.05rem;
}

.app-toast-success .app-toast-icon { color: #34d399; background: rgba(16, 185, 129, 0.18); }
.app-toast-error .app-toast-icon { color: #f87171; background: rgba(239, 68, 68, 0.18); }
.app-toast-warning .app-toast-icon { color: #fbbf24; background: rgba(245, 158, 11, 0.18); }
.app-toast-info .app-toast-icon { color: var(--accent-gold-bright, #d4af37); }

.app-toast-success { border-color: rgba(16, 185, 129, 0.5); }
.app-toast-error { border-color: rgba(239, 68, 68, 0.45); }
.app-toast-warning { border-color: rgba(245, 158, 11, 0.45); }

.app-toast-body {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.app-toast-title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.35;
  margin-bottom: 2px;
}

.app-toast-msg {
  font-size: 0.84rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.82);
}

.app-toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

.app-toast-close:hover {
  color: #fff;
}

/* ==========================================================================
   Custom UI System Modal Dialog (kept for confirm actions only)
   ========================================================================== */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 15, 36, 0.82);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.custom-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.custom-modal-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid var(--accent-gold);
  animation: customModalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes customModalPop {
  0% { transform: scale(0.9) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.custom-modal-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.custom-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.custom-modal-body {
  padding: 24px;
}

html[dir="ltr"] * {
  direction: ltr;
}

html[data-theme="dark"] {
  --bg-surface: #0c1220;
  --bg-card: #1a2740;
  --text-main: #e8eef7;
  --heading: #f4f8ff;
  --text-muted: #c5d4e8;
  --text-light: #a8bdd4;
  --border-color: #3d5270;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] body {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

html[data-theme="dark"] .card-panel,
html[data-theme="dark"] .law-card,
html[data-theme="dark"] .hero-card,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .custom-modal-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .data-table-container,
html[data-theme="dark"] .account-section {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

html[data-theme="dark"] .law-card-title,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .library-hub h3,
html[data-theme="dark"] .stat-info-num {
  color: var(--heading);
}

html[data-theme="dark"] .law-card-summary,
html[data-theme="dark"] .article-count-tag,
html[data-theme="dark"] .library-hub p {
  color: var(--text-muted);
}

html[data-theme="dark"] .law-cat-badge {
  background: rgba(232, 238, 247, 0.12);
  color: var(--heading);
}

html[data-theme="dark"] .data-table th {
  background: #1a2a44;
  color: var(--heading);
}

html[data-theme="dark"] .data-table tr:hover {
  background: #1a2a44;
}

html[data-theme="dark"] .btn-navy {
  background: #2563eb;
  border-color: #60a5fa;
  color: #ffffff;
}

html[data-theme="dark"] .btn-navy:hover {
  background: #3b82f6;
}

.dir-lawyer-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 18px;
  padding: 18px;
  align-items: start;
}
.dir-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.dir-chip {
  font-size: .75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: #0a192f;
  color: #fff;
}
.dir-filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.dir-filter-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--heading);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.dir-filter-btn.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--primary-dark);
}
.bar-grade {
  display: inline-flex;
  align-items: center;
  font-size: .75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 8px;
}
.bar-grade.a { background: #ede9fe; color: #5b21b6; }
.bar-grade.b { background: #dbeafe; color: #1d4ed8; }
.bar-grade.c { background: #dcfce7; color: #166534; }
.bar-grade.abs { background: #ffedd5; color: #9a3412; }
.sponsored-badge {
  display: inline-block;
  background: var(--accent-gold);
  color: var(--primary-dark);
  font-size: .7rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
}
.dir-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
/* The overlay scrolls, not the card: a scrolling rounded card inside a fixed
   overlay mis-paints form controls in iOS/iPadOS Safari (text drifts out of its
   boxes and clips at the edge). margin:auto centres without cutting the top. */
.consult-request-overlay {
  position: fixed;
  inset: 0;
  z-index: 2400;
  background: rgba(0, 18, 41, 0.62);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.consult-request-overlay.open { display: flex; }
html.consult-open,
html.consult-open body { overflow: hidden; }
.consult-request-card {
  width: min(520px, 100%);
  margin: auto 0;
  font-size: 16px;
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: 0 24px 60px rgba(0, 18, 41, 0.28);
  padding: 20px 18px 16px;
  position: relative;
}
.consult-request-card h3 {
  margin: 0 0 6px;
  color: var(--heading);
  font-size: 1.12rem;
}
.consult-request-card p.hint {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: .86rem;
  line-height: 1.7;
  font-weight: 600;
}
.consult-request-close {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #eef4fc;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.consult-request-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
html[data-theme="dark"] .consult-request-card {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
html[data-theme="dark"] .consult-request-close {
  background: #1a2740;
  color: var(--heading);
}
html[data-theme="dark"] .consult-request-card h3 { color: var(--heading); }
.library-hub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0 8px;
}
.library-hub a, .library-hub .hub-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: block;
}
.library-hub h3 { margin: 8px 0 4px; color: var(--heading); font-size: 1rem; }
.library-hub p { color: var(--text-muted); font-size: .85rem; margin: 0; }

.home-doors {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin: 0 0 32px;
}
.door-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  color: inherit;
}
.door-card-primary {
  border: 2px solid var(--accent-gold);
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(212, 175, 55, 0.1) 100%);
}
.door-kicker {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-gold-dark);
}
.door-card h2 {
  color: var(--heading);
  font-size: 1.55rem;
  font-weight: 900;
  margin: 0;
  line-height: 1.35;
}
.door-card p {
  color: var(--text-muted);
  flex: 1;
  margin: 0;
  line-height: 1.7;
}
.door-cta {
  align-self: flex-start;
  margin-top: 8px;
  pointer-events: none;
}
.library-quiet-note {
  color: var(--text-muted);
  margin: -8px 0 16px;
  font-size: 0.95rem;
}
.library-quiet-stats {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
  margin-bottom: 16px;
  gap: 24px;
}
.library-quiet-stats .stat-val {
  color: var(--accent-gold-dark);
}
.library-quiet-stats .stat-lab {
  color: var(--text-muted);
}

html[data-theme="dark"] .home-intro-hero.hero-card {
  background: linear-gradient(135deg, var(--primary-navy) 0%, var(--primary-dark) 100%);
  color: #ffffff;
}
html[data-theme="dark"] .home-intro-hero .hero-title {
  color: #ffffff;
}
html[data-theme="dark"] .home-intro-hero .hero-subtitle {
  color: var(--text-light);
}
html[data-theme="dark"] .door-card {
  background: var(--bg-card);
  border-color: var(--border-color);
}
html[data-theme="dark"] .door-card h2 {
  color: var(--heading);
}
html[data-theme="dark"] .door-card p,
html[data-theme="dark"] .library-quiet-note,
html[data-theme="dark"] .library-quiet-stats .stat-lab {
  color: var(--text-muted);
}
html[data-theme="dark"] .library-quiet-stats .stat-val {
  color: var(--accent-gold-bright);
}
html[data-theme="dark"] .door-card-primary {
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(212, 175, 55, 0.16) 100%);
}
.account-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
.account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.account-row:last-child { border-bottom: none; }
.lang-toggle, .theme-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  font-size: .78rem;
}

/* ==========================================================================
   UI patterns: skeleton, spinner, progress, avatar group,
   marquee, command palette, breadcrumbs, chips, empty
   ========================================================================== */

.ui-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.ui-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--heading);
  font-weight: 700;
}
.ui-spinner-ring {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: ui-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }
.law-grid > .ui-empty,
.law-grid > .ui-loading-block,
.law-grid > .ui-skeleton-card {
  grid-column: 1 / -1;
}
.law-grid > .ui-skeleton-card {
  grid-column: auto;
}

.ui-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  width: 100%;
}
.ui-skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: start;
}
.ui-skeleton {
  background: linear-gradient(90deg, var(--border-color) 0%, rgba(212,175,55,.18) 50%, var(--border-color) 100%);
  background-size: 200% 100%;
  animation: ui-shimmer 1.2s ease-in-out infinite;
  border-radius: 8px;
}
.ui-skeleton-avatar { width: 56px; height: 56px; border-radius: 50%; }
.ui-skeleton-line { height: 12px; margin-bottom: 8px; }
.ui-skeleton-line.w60 { width: 60%; }
.ui-skeleton-line.w80 { width: 80%; }
.ui-skeleton-line.w40 { width: 40%; }
@keyframes ui-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ui-spinner-ring, .ui-skeleton { animation: none; }
}

progress.ui-progress,
.ui-progress {
  appearance: none;
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 999px;
  background: var(--border-color);
  overflow: hidden;
  vertical-align: middle;
}
progress.ui-progress::-webkit-progress-bar { background: var(--border-color); border-radius: 999px; }
progress.ui-progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--primary-navy), var(--accent-gold));
  border-radius: 999px;
}
progress.ui-progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--primary-navy), var(--accent-gold));
  border-radius: 999px;
}
/* Admin-chosen lawyer card under citizen AI replies (renderFeaturedLawyer in app.js) */
.featured-lawyer-card {
  margin-top: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-inline-start: 4px solid var(--accent-gold);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(0, 26, 56, 0.06);
}
.flc-kicker { font-size: .78rem; font-weight: 800; color: #8a6d1a; margin-bottom: 10px; }
.flc-head { display: flex; gap: 14px; align-items: flex-start; }
.flc-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(212, 175, 55, 0.5);
}
.flc-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-navy);
  color: #f5d78e;
  font-size: 1.6rem;
  font-weight: 900;
}
.flc-id { min-width: 0; flex: 1; }
.flc-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.flc-name { margin: 0; font-size: 1.12rem; color: var(--heading); }
.flc-site-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  font-weight: 800;
  color: var(--primary-navy);
  background: rgba(212, 175, 55, 0.16);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
}
.flc-site-link:hover { background: rgba(212, 175, 55, 0.3); }
.flc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flc-badges:empty { display: none; }
.flc-tagline { margin: 6px 0 0; color: var(--text-muted); font-size: .9rem; }
.flc-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 16px;
  margin: 14px 0 0;
}
.flc-details > div { min-width: 0; }
.flc-details dt { font-size: .75rem; font-weight: 800; color: var(--text-muted); }
.flc-details dt i { color: var(--accent-gold); width: 14px; }
.flc-details dd { margin: 2px 0 0; font-weight: 700; color: var(--text-main); overflow-wrap: anywhere; }
.flc-about { margin: 12px 0 0; color: var(--text-main); line-height: 1.8; font-size: .92rem; }
.flc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.flc-actions .btn { flex: 1 1 130px; justify-content: center; }
.flc-wa { background: #16a34a; color: #fff; border: 1px solid #16a34a; }
.flc-outline { background: transparent; color: var(--primary-navy); border: 1px solid var(--border-color); }
html[data-theme="dark"] .flc-kicker { color: #f5d78e; }
html[data-theme="dark"] .flc-site-link { color: #f5d78e; background: rgba(212, 175, 55, 0.14); }
html[data-theme="dark"] .flc-outline { color: #e8eef7; border-color: rgba(232, 238, 247, 0.35); }
@media (max-width: 480px) {
  .flc-photo { width: 56px; height: 56px; }
  .flc-actions .btn { flex-basis: calc(50% - 4px); }
}

.ui-progress-row[hidden] { display: none; }
.ui-progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.ui-progress-row label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--heading);
}

/* Toast: pause hint + LTR body */
.app-toast:focus-within,
.app-toast:hover { outline: none; }
html[dir="ltr"] .app-toast-body { text-align: left; }
html[dir="ltr"] .app-toast-close { margin-right: 0; margin-left: auto; }

/* Avatar group - first on top, 2px --bg-card ring, logical overlap */
.avatar-group {
  display: inline-flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}
.avatar-group .avatar-item,
.avatar-group .avatar-overflow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  margin-inline-start: -10px;
  box-sizing: border-box;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--primary-navy);
  color: var(--accent-gold-bright);
  font-size: 0.72rem;
  font-weight: 800;
  position: relative;
}
.avatar-group .avatar-item:first-child,
.avatar-group .avatar-overflow:first-child { margin-inline-start: 0; }
.avatar-group img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-group .avatar-overflow {
  background: var(--accent-gold);
  color: var(--primary-dark);
  font-size: 0.7rem;
}

.home-landing section[id] {
  scroll-margin-top: 96px;
}

/* Command palette */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  background: rgba(0, 18, 41, 0.62);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 14vh 16px 16px;
}
.cmdk-overlay.open { display: flex; }
.cmdk-dialog {
  width: min(560px, 100%);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cmdk-head {
  padding: 18px 18px 8px;
}
.cmdk-head h2 {
  margin: 0;
  color: var(--heading);
  font-size: 1.15rem;
  font-weight: 900;
}
.cmdk-hint {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.cmdk-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 16px 12px;
  padding: 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-surface);
}
.cmdk-search-wrap:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}
.cmdk-search-wrap i { color: var(--accent-gold); }
.cmdk-input,
.cmdk-dialog input {
  width: 100%;
  border: none;
  padding: 4px 0;
  font: inherit;
  font-weight: 700;
  background: transparent;
  color: var(--heading);
  outline: none;
}
.cmdk-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: min(50vh, 360px);
  overflow: auto;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  border: none;
  background: transparent;
  color: var(--heading);
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.cmdk-item i { color: var(--accent-gold); width: 18px; text-align: center; }
.cmdk-item[aria-selected="true"],
.cmdk-item:hover { background: color-mix(in srgb, var(--accent-gold) 16%, var(--bg-card)); }
.cmdk-empty { padding: 16px; color: var(--text-muted); font-weight: 700; text-align: center; }

/* Breadcrumbs */
.ui-breadcrumb { margin: 0 0 12px; }
.ui-breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}
.ui-breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ui-breadcrumb li:not(:last-child)::after {
  content: "/";
  color: var(--border-color);
  font-weight: 400;
}
.ui-breadcrumb a,
.ui-breadcrumb button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--primary-navy);
  cursor: pointer;
}
html[data-theme="dark"] .ui-breadcrumb a,
html[data-theme="dark"] .ui-breadcrumb button { color: var(--accent-gold-bright); }
.ui-breadcrumb [aria-current="page"] {
  color: var(--heading);
  font-weight: 900;
}
@media (max-width: 640px) {
  .ui-breadcrumb li:not(:first-child):not(:last-child) {
    max-width: 2.4em;
    overflow: hidden;
  }
  .ui-breadcrumb li:not(:first-child):not(:last-child) > * {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Badge / chip / pill / tag */
.ui-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-gold);
  color: var(--primary-dark);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  margin-inline-start: 6px;
}
.pm-nav-btn .ui-badge { margin-inline-start: auto; }
.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--heading);
  font-size: 0.78rem;
  font-weight: 800;
}
.ui-chip-remove {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  padding: 0;
}
.ui-chip-remove:hover { background: var(--border-color); color: var(--heading); }
.ui-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.ui-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: #dbeafe;
  color: #1d4ed8;
}
.ui-pill.open { background: #dbeafe; color: #1d4ed8; }
.ui-pill.accepted { background: #d1fae5; color: #047857; }
.ui-pill.closed { background: #e2e8f0; color: #475569; }
.ui-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-navy);
  color: #fff;
}
html[data-theme="dark"] .ui-tag { background: var(--accent-gold); color: var(--primary-dark); }
html[data-theme="dark"] .ui-pill.open { background: rgba(59,130,246,.22); color: #bfdbfe; }
html[data-theme="dark"] .ui-pill.accepted { background: rgba(16,185,129,.22); color: #6ee7b7; }
html[data-theme="dark"] .ui-pill.closed { background: rgba(148,163,184,.22); color: #cbd5e1; }

/* Empty states */
.ui-empty,
.pm-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}
.ui-empty i,
.pm-empty i {
  font-size: 2rem;
  color: var(--accent-gold);
  margin-bottom: 10px;
  display: block;
}
.ui-empty strong,
.ui-empty h3,
.pm-empty strong {
  display: block;
  color: var(--heading);
  margin-bottom: 4px;
  font-size: 1rem;
}
.ui-empty p { margin: 0 0 14px; }
.ui-empty .btn { margin-top: 4px; }

/* Dashboard bento */
.pm-bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: var(--border-color);
  border-radius: 18px;
  padding: 12px;
  overflow: hidden;
}
.pm-bento-tile {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
  color: var(--text-main);
}
.pm-bento-tile h3 {
  margin: 0 0 12px;
  color: var(--heading);
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pm-bento-span-2 { grid-column: span 2; }
.pm-bento-row-2 { grid-row: span 2; }
.pm-bento-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 980px) {
  .pm-bento { grid-template-columns: repeat(2, 1fr); }
  .pm-bento-span-2 { grid-column: span 2; }
  .pm-bento-row-2 { grid-row: auto; }
}
@media (max-width: 640px) {
  .pm-bento { grid-template-columns: 1fr; }
  .pm-bento-span-2 { grid-column: span 1; }
}

html[data-theme="dark"] .pm-bento { background: #0a1220; }
html[data-theme="dark"] .pm-bento-tile { background: var(--bg-card); }
html[data-theme="dark"] .ui-empty strong,
html[data-theme="dark"] .pm-empty strong { color: var(--heading); }
html[data-theme="dark"] .cmdk-dialog { background: var(--bg-card); }

html[data-theme="dark"] .pm-stat .value,
html[data-theme="dark"] .pm-page-head h2,
html[data-theme="dark"] .pm-panel h3,
html[data-theme="dark"] .pm-list-item strong,
html[data-theme="dark"] .pm-bento-tile h3,
html[data-theme="dark"] .pm-topbar-title strong {
  color: var(--heading);
}
.site-profile-panel {
  max-width: 920px;
  margin: 24px auto 48px;
  padding: 0 20px;
}
.site-profile-panel .card-panel { padding: 22px; }
.eula-row { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; }
.eula-row input { margin-top: 4px; }
.seg-toggle { display: flex; gap: 4px; background: #eef4fc; padding: 4px; border-radius: 8px; margin-bottom: 18px; }
html[data-theme="dark"] .seg-toggle { background: #1a2740; }
html[data-theme="dark"] .dir-chip { background: #d4af37; color: #001229; }
html[data-theme="dark"] .custom-modal-footer { background: #152238; }
html[data-theme="dark"] .pm-panel,
html[data-theme="dark"] table.pm-table { background: var(--bg-card); }

.custom-modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ---- Supplementary mobile pass (phone-first: many citizens & lawyers on mobile) ---- */
@media (max-width: 640px) {
  .section-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .section-title {
    font-size: 1.2rem;
  }
  .ui-breadcrumb { font-size: 0.82rem; }
  .law-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 24px;
  }
  .law-card { padding: 16px; }
  .dir-lawyer-card {
    grid-template-columns: 64px 1fr;
    gap: 12px;
  }
  .dir-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .dir-card-actions .btn,
  .dir-card-actions a { flex: 1 1 auto; text-align: center; }
  /* comfortable tap targets */
  .btn { min-height: 40px; }
  .dir-filter-btn { min-height: 38px; }
  input.form-control,
  select.form-control,
  textarea.form-control { font-size: 16px; } /* stop iOS zoom-on-focus */
  .home-doors .door-card { padding: 18px; }
  .lawyer-showcase-grid { grid-template-columns: 1fr !important; }
}

/* The `.home-doors` base rule is declared later in this file than the
   max-width:900px collapse, and media queries add no specificity - so the
   two-column grid was winning on phones and squeezing both doors. Restate the
   collapse after the base rule, where it actually takes effect. */
@media (max-width: 900px) {
  .home-doors { grid-template-columns: 1fr; }
}

/* Suggested-lawyer cards (find.html case→lawyer flow) */
.lawyer-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.lawyer-showcase-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.lawyer-showcase-card .avatar,
.lawyer-showcase-card img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-gold);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: #eef4fc;
  color: var(--accent-gold);
  font-weight: 800;
}
.lawyer-showcase-card .meta { min-width: 0; }
.lawyer-showcase-card .meta strong { display: block; color: var(--heading); }
.lawyer-showcase-card .meta span {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Repeatable (add-row) form fields - lawyer site builder */
.rpt-field { display: flex; flex-direction: column; gap: 8px; }
.rpt-row { display: grid; gap: 8px; align-items: start; }
.rpt-row.single { grid-template-columns: 1fr auto; }
.rpt-row.pair { grid-template-columns: 1fr 1.4fr auto; }
.rpt-row .rpt-del { padding: 8px 12px; align-self: start; }
.rpt-field + .rpt-add { align-self: flex-start; }
@media (max-width: 640px) {
  .rpt-row.single,
  .rpt-row.pair { grid-template-columns: 1fr; }
  .rpt-row .rpt-del { justify-self: end; }
}

/* ==========================================================================
   Homepage polish (hero eyebrow / actions, door icons, KB library cards)
   ========================================================================== */
.home-intro-hero { padding: 44px 40px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .82rem; font-weight: 800; letter-spacing: .02em;
  color: var(--accent-gold-bright);
  background: rgba(212,175,55,.14); border: 1px solid rgba(212,175,55,.32);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 18px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.hero-actions .btn { padding: 12px 22px; font-size: .95rem; }
.btn-ghost {
  background: transparent; color: #fff;
  border: 1.5px solid rgba(255,255,255,.35);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.6); }
.home-intro-hero .hero-stats-row {
  gap: 28px 40px; flex-wrap: wrap;
  border-top: 1px solid rgba(255,255,255,.12); padding-top: 22px; margin-top: 26px;
}

.door-card { position: relative; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.door-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent-gold); }
.door-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.15rem;
  background: rgba(212,175,55,.16); color: var(--accent-gold-dark);
  margin-bottom: 4px;
}
.door-card-primary .door-icon { background: var(--accent-gold); color: var(--primary-navy); }

#librarySearchResults button:hover { background: #f8fafc !important; }
.law-card .btn-navy { white-space: nowrap; }

@media (max-width: 640px) {
  .home-intro-hero { padding: 26px 20px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .home-intro-hero .hero-stats-row { flex-direction: row; flex-wrap: wrap; gap: 14px 22px; }
  .home-intro-hero .hero-stats-row .stat-item { flex: 0 0 auto; }
}

html[data-theme="dark"] .btn-ghost { color: var(--heading); border-color: rgba(255,255,255,.28); }
html[data-theme="dark"] .door-icon { background: rgba(212,175,55,.18); color: var(--accent-gold-bright); }

/* ==========================================================================
   Visual polish + motion (RTL). Typography, vertical rhythm, IntersectionObserver
   scroll-reveal, hover motion. NO colour / background / palette changes.
   ========================================================================== */

/* --- 1. Typography (IBM Plex Sans Arabic; never letter-space Arabic) --- */
* { font-family: var(--font-ibm); }
body { line-height: 1.9; letter-spacing: 0; }
h1, h2, h3, h4, h5, h6,
.hero-title, .section-title, .law-card-title, .door-card h2,
.pm-page-head h1, .modal-card h2 { line-height: 1.45; }
main p, .hero-subtitle, .library-quiet-note, .door-card p { max-width: 62ch; }
/* long-form legal article text */
#kbArticlesList > div > div:last-child,
#articlesListContainer > div,
#modalContent [style*="pre-wrap"],
.law-article-body { line-height: 2.1; }

/* --- 2. Vertical rhythm & hierarchy (4 / 8 px scale) --- */
.main-container { padding-block: 48px; }
.home-landing > section,
.main-container > section#news,
.main-container > section#public-interest { margin-block-end: 56px; }
.home-landing > section:last-child { margin-block-end: 0; }
.section-header { margin-block-end: 32px; }
.home-intro-hero { padding: 56px 48px; }
.home-intro-hero .hero-title { margin-block-end: 16px; }
.home-intro-hero .hero-subtitle { margin-block-end: 24px; }
.home-intro-hero .hero-actions { margin-block-start: 8px; }

/* the law search input is the largest thing in its section */
/* The all-laws search now leads the hero (see "Immersive hero" below). */
.hero-search { padding: 16px 20px; margin-block: 24px 14px; }
.hero-search #mainSearchInput { font-size: 1.15rem; padding-block: 14px; }
.hero-search .btn { padding: 14px 26px; font-size: 1rem; }
.hero-search > i { font-size: 1.4rem; }

/* --- 2b. Designed empty states --- */
.ui-empty,
.pm-empty,
.section-empty {
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 44px 24px;
}
.ui-empty p,
.section-empty p { max-width: 46ch; margin-inline: auto; }
.law-grid:empty { display: none; }

/* --- 3. Motion --- */
html.motion-ready [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 320ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
html.motion-ready [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

/* card hover: lift + (existing) border-colour shift, 160ms */
.law-card, .door-card, .stat-item, .lawyer-showcase-card, .card-panel {
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.law-card:hover, .lawyer-showcase-card:hover { transform: translateY(-3px); }

/* arrow icons nudge "forward" — negative translateX because RTL */
.btn i.fa-arrow-left, .btn i.fa-arrow-right,
.door-cta i, .law-card-footer .btn i, a i.fa-arrow-right, a i.fa-arrow-left {
  transition: transform 160ms ease;
}
.btn:hover i.fa-arrow-left, .btn:hover i.fa-arrow-right,
.door-card:hover .door-cta i, .law-card:hover .law-card-footer .btn i,
a:hover i.fa-arrow-right, a:hover i.fa-arrow-left {
  transform: translateX(-6px);
}

/* focus rings animate in */
input, select, textarea, .form-control, .search-box-wrap {
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

/* chips / badges: mirror-safe scale origin */
.law-cat-badge, .ui-tag, .hero-eyebrow, .article-count-tag,
.badge-uid, .door-kicker, .law-cat-badge.ui-tag {
  transform-origin: right center;
}

/* ==========================================================================
   Immersive hero — the homepage leads with search, not with a banner
   ========================================================================== */
.hero-immersive {
  position: relative;
  isolation: isolate;
  padding: 64px 48px 52px;
  border: 1px solid rgba(212, 175, 55, 0.22);
}

/* Slow drifting gold light. Purely decorative; sits behind the content.
   No filter: blur() here - radial gradients are already soft, and blurring a
   hero-sized layer every animation frame stalls the renderer on low-end phones. */
.hero-aurora {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(42% 58% at 18% 22%, rgba(212, 175, 55, 0.20), transparent 70%),
    radial-gradient(38% 52% at 86% 14%, rgba(0, 92, 187, 0.26), transparent 72%),
    radial-gradient(52% 62% at 70% 96%, rgba(212, 175, 55, 0.10), transparent 70%);
  animation: heroDrift 30s ease-in-out infinite alternate;
}

@keyframes heroDrift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1.02); }
  to   { transform: translate3d(1.5%, 1%, 0) scale(1.1); }
}

/* Oversized scales-of-justice watermark, bled off the leading edge. */
.hero-scales {
  position: absolute;
  z-index: -1;
  inset-inline-start: -28px;
  inset-block-start: 50%;
  transform: translateY(-50%);
  font-size: 19rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.045);
  pointer-events: none;
  user-select: none;
}

.hero-content { position: relative; }

.hero-immersive .hero-title {
  font-size: clamp(2rem, 1.2rem + 3.2vw, 3.4rem);
  letter-spacing: -0.5px;
  text-wrap: balance;
}

.hero-immersive .hero-subtitle {
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.18rem);
  color: #cfe0f5;
  margin-bottom: 0;
}

/* Search bar: white card floating on the navy hero. */
.hero-search {
  margin-inline: 0;
  max-width: 780px;
  border-color: transparent;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}
.hero-search-icon { color: var(--primary-navy); font-size: 1.2rem; flex-shrink: 0; }

.hero-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}
.hero-suggest-label { color: #9db6d6; font-size: 0.85rem; font-weight: 700; }
.hero-tag {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: #e8f0fa;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.hero-tag:hover,
.hero-tag:focus-visible {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--primary-navy);
}

/* Results render straight under the hero, where the query was typed. */
.hero-search-results:not(:empty) { margin-bottom: 32px; }

/* Glassy stat cells instead of a plain rule of numbers.
   flex-direction is pinned to row: the max-width:900px block above turns
   .hero-stats-row into a column, which would make the stat cells' flex-basis a
   150px HEIGHT instead of a width (the same trap that left a blank block in the
   dashboard topbar). Only <=640px restored the row, so 641-900px broke. */
.hero-immersive .hero-stats-row {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  gap: 14px;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
}
.hero-immersive .hero-stats-row .stat-item {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 150px;
  flex: 1 1 150px;
  backdrop-filter: blur(4px);
}

/* ---- "How it works": three steps between hero and the two doors ---- */
.home-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 22px;
  position: relative;
  overflow: hidden;
}
.step-card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-gold), transparent);
}
.step-num {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-navy);
  color: var(--accent-gold-bright);
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 14px;
}
.step-card h3 { color: var(--heading); font-size: 1.08rem; margin-bottom: 6px; }
.step-card p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.75; }

html[data-theme="dark"] .step-card {
  background: var(--bg-card);
  border-color: var(--border-color);
}

@media (max-width: 768px) {
  .hero-immersive { padding: 34px 20px 30px; }
  .hero-scales { font-size: 12rem; inset-inline-start: -46px; opacity: 0.7; }
  .hero-search { padding: 10px 12px; margin-block: 20px 12px; }
  .hero-search #mainSearchInput { font-size: 1rem; padding-block: 10px; }
  /* Icon + full-width input + full-width button, in that order. */
  .hero-search { flex-wrap: wrap; }
  .hero-search-icon { display: none; }
  .hero-search .btn { width: 100%; justify-content: center; padding: 12px 18px; }
  .hero-suggest { gap: 6px; }
  .hero-tag { padding: 5px 11px; font-size: 0.8rem; }
  .hero-immersive .hero-stats-row .stat-item { min-width: 0; flex: 1 1 44%; padding: 12px 14px; }
  .home-steps { gap: 12px; margin-bottom: 28px; }
  .step-card { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-aurora { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  html.motion-ready [data-reveal],
  html.motion-ready [data-reveal].is-revealed {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .law-card, .door-card, .stat-item, .card-panel, .lawyer-showcase-card,
  .btn i, .door-cta i, a i, input, select, textarea, .form-control, .search-box-wrap {
    transition: none !important;
  }
  .law-card:hover, .door-card:hover, .lawyer-showcase-card:hover { transform: none; }
  html { scroll-behavior: auto; }
}

/* ------------------------------------------------------------------ *
 * Dark mode: inline light backgrounds
 *
 * Panels, pills and callouts across the app carry a hardcoded light
 * background in a style="" attribute (from the HTML or built in JS) and
 * set no color, so in dark mode they inherit --text-main (near-white)
 * and render as white-on-white or as a bright island. A stylesheet rule
 * with !important outranks a normal inline declaration, so this remaps
 * the handful of literal colors that actually occur to the theme
 * surfaces. Scoped to [data-theme="dark"] only - light mode is untouched.
 * Deliberately no text-color rules here: the reported bug is invisible
 * text on a light box, and remapping the box fixes it.
 * ------------------------------------------------------------------ */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background-color:#ffffff"],
html[data-theme="dark"] [style*="background-color: #ffffff"] {
  background-color: var(--bg-card) !important;
}
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f4f7fc"],
html[data-theme="dark"] [style*="background: #f4f7fc"],
html[data-theme="dark"] [style*="background:#f1f5fb"],
html[data-theme="dark"] [style*="background: #f1f5fb"],
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"],
html[data-theme="dark"] [style*="background:#eef4fc"],
html[data-theme="dark"] [style*="background: #eef4fc"],
html[data-theme="dark"] [style*="background:#eef4ff"],
html[data-theme="dark"] [style*="background: #eef4ff"],
html[data-theme="dark"] [style*="background:#f9fafb"],
html[data-theme="dark"] [style*="background: #f9fafb"],
html[data-theme="dark"] [style*="background-color:#f8fafc"],
html[data-theme="dark"] [style*="background-color: #f8fafc"] {
  background-color: var(--bg-surface) !important;
}

/* ================================================================== *
 * Homepage: five-audience section, trust band, AI-analyzer highlight
 * (§8 main-page upgrade). Matches the immersive hero already in place.
 * ================================================================== */
.home-audiences-head { text-align: center; margin: 8px 0 26px; }
.home-audiences-head h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 900; color: var(--heading); }
.home-audiences-head p { color: var(--text-muted); margin-top: 6px; }

.home-audiences {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 44px;
}
.aud-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.aud-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.aud-card.aud-new { border-color: var(--accent-gold); box-shadow: var(--shadow-md); }
.aud-icon {
  width: 46px; height: 46px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 26, 56, 0.06); color: var(--primary-navy);
  font-size: 1.15rem;
}
html[data-theme="dark"] .aud-icon { background: rgba(212, 175, 55, 0.14); color: var(--accent-gold-bright); }
.aud-card.aud-new .aud-icon { background: rgba(212, 175, 55, 0.16); color: var(--accent-gold-dark); }
.aud-kicker { font-size: 0.78rem; font-weight: 800; color: var(--text-muted); letter-spacing: 0.2px; }
.aud-card h3 { font-size: 1.12rem; font-weight: 900; color: var(--heading); }
.aud-card p { color: var(--text-muted); font-size: 0.92rem; flex: 1; }
.aud-badge {
  align-self: flex-start; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-gold); color: var(--primary-dark);
  font-size: 0.7rem; font-weight: 900;
}
.aud-cta {
  align-self: flex-start; margin-top: 4px;
  padding: 9px 16px; border-radius: 10px;
  font-weight: 800; font-size: 0.86rem;
  background: var(--primary-navy); color: #fff;
}
.aud-card.aud-new .aud-cta { background: var(--accent-gold); color: var(--primary-dark); }
.aud-card-row { display: flex; align-items: center; justify-content: space-between; }

.trust-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  background: var(--primary-dark);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 40px;
}
.trust-item { display: flex; align-items: flex-start; gap: 12px; }
.trust-item i { color: var(--accent-gold); font-size: 1.5rem; flex-shrink: 0; margin-top: 2px; }
.trust-item strong { display: block; color: #fff; font-size: 0.98rem; }
.trust-item span { color: #8ea8cc; font-size: 0.83rem; }

.ai-highlight {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 32px;
  align-items: center;
  background: linear-gradient(150deg, var(--primary-navy), var(--secondary-navy));
  border-radius: var(--radius-lg);
  padding: 36px;
  margin-bottom: 44px;
}
.ai-highlight-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 13px; border-radius: 999px;
  background: rgba(212, 175, 55, 0.16); color: var(--accent-gold-bright);
  font-weight: 800; font-size: 0.78rem;
}
.ai-highlight h2 { color: #fff; font-size: 1.6rem; font-weight: 900; margin: 14px 0 12px; }
.ai-highlight > div > p { color: #c3d3e8; font-size: 1rem; margin-bottom: 16px; }
.ai-highlight ul { list-style: none; display: flex; flex-direction: column; gap: 9px; margin: 0 0 22px; }
.ai-highlight li { display: flex; align-items: center; gap: 10px; color: #dfe8f4; font-size: 0.92rem; }
.ai-highlight li i { color: var(--accent-gold); }
.ai-highlight-card {
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 20px; box-shadow: var(--shadow-lg);
}
.ai-highlight-card .lbl { font-size: 0.76rem; font-weight: 800; color: var(--text-muted); margin-bottom: 5px; }
.ai-highlight-card .txt { font-size: 0.9rem; color: var(--text-main); margin-bottom: 14px; }
.ai-highlight-card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.ai-highlight-card .chip {
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-surface); border: 1px solid var(--border-color);
  font-size: 0.78rem; font-weight: 700; color: var(--text-main);
}
.ai-highlight-card .spec {
  padding: 4px 12px; border-radius: 999px;
  background: rgba(212, 175, 55, 0.18); color: var(--accent-gold-dark);
  font-size: 0.8rem; font-weight: 800;
}
html[data-theme="dark"] .ai-highlight-card .spec { color: var(--accent-gold-bright); }

@media (max-width: 900px) {
  .home-audiences { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trust-band { grid-template-columns: 1fr; gap: 14px; }
  .ai-highlight { grid-template-columns: 1fr; padding: 26px; }
}
@media (max-width: 560px) {
  .home-audiences { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Phone app shell (public pages): bottom tab bar + compact top bar.
   The tabs are built per role in initDynamicNavbar (app.js).
   ========================================================================== */
.app-tabbar { display: none; }

.bar-accredited-badge { vertical-align: middle; }
html[data-theme="dark"] .bar-accredited-badge { color: #f5d77a !important; background: rgba(212, 175, 55, 0.2) !important; }

@media (max-width: 900px) {
  html { -webkit-tap-highlight-color: transparent; }
  body.has-app-tabbar {
    --app-bottom-offset: 64px;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
  .app-tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 1300;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--primary-navy);
    border-top: 1px solid rgba(212, 175, 55, 0.35);
    box-shadow: 0 -8px 24px rgba(0, 18, 41, 0.22);
    user-select: none;
  }
  .app-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 6px 2px;
    color: #9fb3cf;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    touch-action: manipulation;
    transition: color 0.15s ease, transform 0.1s ease;
  }
  .app-tab i { font-size: 1.15rem; line-height: 1; }
  .app-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-tab.active { color: var(--accent-gold-bright); }
  .app-tab:active { transform: scale(0.94); }
  .app-tab:focus-visible { outline: 2px solid var(--accent-gold-bright); outline-offset: -4px; border-radius: 10px; }

  /* Compact top bar: logo, language, theme and logout. Everything the old
     hamburger menu held is in the tab bar. */
  body.has-app-tabbar .nav-toggle-btn,
  body.has-app-tabbar .nav-links { display: none !important; }
  body.has-app-tabbar .header-inner { flex-wrap: nowrap; padding: 8px 14px; }
  body.has-app-tabbar .brand-title-sub { display: none; }
  body.has-app-tabbar .brand-badge-wrap { min-width: 0; gap: 8px; }
  body.has-app-tabbar .brand-badge-wrap img { width: 38px !important; height: 38px !important; }
  body.has-app-tabbar .nav-actions { width: auto; flex-wrap: nowrap; margin-inline-start: auto; }
  body.has-app-tabbar .nav-actions > :not(.lang-switch):not(.theme-toggle):not(.nav-logout) { display: none; }
  body.has-app-tabbar .nav-logout { width: 40px; height: 40px; padding: 0; }
  body.has-app-tabbar .nav-logout .nav-btn-label { display: none; }

  /* iOS Safari zooms the page into any field under 16px. */
  input, select, textarea { font-size: max(16px, 1em); }
}

@media print {
  .app-tabbar { display: none !important; }
}

/* Live status line while an AI answer is being prepared (startAiStatus, app.js). */
.ai-status { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-weight: 700; }
.ai-status-dots { display: inline-flex; gap: 4px; flex-shrink: 0; }
.ai-status-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-gold);
  animation: aiStatusPulse 1.2s ease-in-out infinite;
}
.ai-status-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-status-dots span:nth-child(3) { animation-delay: 0.3s; }
.ai-status-time { margin-inline-start: auto; font-size: 0.8rem; font-variant-numeric: tabular-nums; opacity: 0.8; }
.ai-status-note { margin-top: 6px; font-size: 0.82rem; color: var(--text-muted); }
@keyframes aiStatusPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-status-dots span { animation: none; opacity: 0.8; }
}
