/* ═══════════════════════════════════════════════════════════════════
   Community Hub — Master Shell CSS v1.2.0
   Mobile-first: tabs fixed to bottom on mobile, never exceed
   device height, safe-area insets for notched phones.
   ═══════════════════════════════════════════════════════════════════ */

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

/* ── CSS custom properties ─────────────────────────────────────── */
:root {
  --ch-bg-dark:      #1a1a2e;
  --ch-bg-dark2:     #2d2d50;
  --ch-accent:       #4f46e5;
  --ch-accent-light: #818cf8;
  --ch-top-h:        60px;   /* top bar height — desktop */
  --ch-top-h-mob:    50px;   /* top bar height — mobile  */
  --ch-tab-h:        48px;   /* tab bar height — desktop */
  --ch-tab-h-mob:    70px;   /* tab bar height — mobile  */
}

/* ── App shell ──────────────────────────────────────────────────── */
.ch-app-outer {
  /* Isolate the hub so inner fixed elements are relative to viewport */
  position: relative;
}

#ch-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 85vh;
  min-height: 480px;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #fff;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
}

/* ── Top bar ────────────────────────────────────────────────────── */
#ch-top-bar {
  /* height: var(--ch-top-h); */
  height:70px;
  background: var(--ch-bg-dark);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--ch-bg-dark2);
  /* Stack order inside the app */
  position: relative;
  z-index: 10;
}
.ch-logo {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 7px;
}
.ch-logo span { color: var(--ch-accent-light); }
.ch-spacer { flex: 1; }
.ch-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.09);
  border-radius: 28px;
  padding: 5px 14px 5px 5px;
  cursor: pointer;
  min-height: 44px;
  transition: background .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ch-user-pill:hover  { background: rgba(255,255,255,.16); }
.ch-user-pill:active { background: rgba(255,255,255,.22); }
.ch-user-av {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ch-accent), var(--ch-accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.ch-user-name  { font-size: 13px; font-weight: 600; color: #fff; }
.ch-online-dot { width: 8px; height: 8px; border-radius: 50%; background: #28a745; flex-shrink: 0; }

/* ── Logout button ──────────────────────────────────────────────── */
.ch-logout-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: rgba(220, 53, 69, 0.15);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: 20px;
  color: #ff6b7a;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  cursor: pointer;
  transition: all .15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ch-logout-btn:hover {
  background: rgba(220, 53, 69, 0.25);
  border-color: rgba(220, 53, 69, 0.5);
  color: #ff8591;
}
.ch-logout-btn:active {
  background: rgba(220, 53, 69, 0.35);
  transform: scale(0.98);
}
.ch-logout-icon {
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ch-logout-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  transition: stroke .15s;
}
.ch-logout-btn:hover .ch-logout-icon svg {
  stroke: #ff6b7a;
}

/* ── Logout modal ───────────────────────────────────────────────── */
.ch-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}
.ch-modal.ch-modal-open {
  display: flex;
}
.ch-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: ch-fade-in 0.2s ease;
}
.ch-modal-content {
  position: relative;
  background: var(--ch-bg-dark2);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: ch-slide-up 0.25s ease;
}
.ch-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px;
}
.ch-modal-message {
  font-size: 15px;
  color: rgba(255,255,255,.62);
  line-height: 1.5;
  margin: 0 0 24px;
}
.ch-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.ch-modal-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  cursor: pointer;
  transition: all .15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ch-modal-btn-secondary {
  background: rgba(255,255,255,.09);
  color: rgba(255,255,255,.80);
  border: 1px solid rgba(255,255,255,.14);
}
.ch-modal-btn-secondary:hover {
  background: rgba(255,255,255,.16);
  color: #fff;
}
.ch-modal-btn-primary {
  background: linear-gradient(135deg, #dc3545, #e74c3c);
  color: #fff;
  font-weight: 700;
  border: 1px solid rgba(220,53,69,.35);
}
.ch-modal-btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}
.ch-modal-btn-primary:active {
  transform: translateY(0);
}

@keyframes ch-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes ch-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Tab bar — desktop (top) ────────────────────────────────────── */
#ch-tab-bar {
  background: var(--ch-bg-dark);
  display: flex;
  align-items: flex-end;
  padding: 0 12px;
  gap: 2px;
  flex-shrink: 0;
  border-bottom: 3px solid var(--ch-bg-dark2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 10;
}
#ch-tab-bar::-webkit-scrollbar { display: none; }

.ch-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 18px 14px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.42);
  cursor: pointer;
  border: none;
  outline: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  border-radius: 8px 8px 0 0;
  background: none;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  transition: color .16s, background .16s, border-color .16s;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ch-tab:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(129,140,248,.7);
}
.ch-tab:hover { color: rgba(255,255,255,.75); background: rgba(255,255,255,.06); }
.ch-tab.ch-tab-active {
  color: #fff;
  border-bottom-color: var(--ch-accent-light);
  background: rgba(129,140,248,.13);
  text-shadow: 0 0 12px rgba(129,140,248,.5);
}
.ch-tab-icon  { font-size: 16px; }

/* ── Content area ───────────────────────────────────────────────── */
#ch-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
.ch-pane {
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.ch-pane.ch-pane-active {
  display: flex;
  flex-direction: column;
}

/* Force module plugins to fill their pane */
.ch-pane #wpcc-app {
  height: 100% !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.ch-pane #pl-practice-container {
  min-height: 100%;
  margin: 0;
  border-radius: 0;
}

/* ── Loading / placeholder ──────────────────────────────────────── */
.ch-pane-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #f7f8fc;
}
.ch-loading-spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 4px solid #e8eaf0;
  border-top-color: var(--ch-accent);
  animation: ch-spin .7s linear infinite;
}
@keyframes ch-spin { to { transform: rotate(360deg); } }

/* ── No-modules notice ──────────────────────────────────────────── */
.ch-no-modules {
  padding: 40px 24px;
  text-align: center;
  background: #f7f8fc;
  border-radius: 14px;
  border: 1px solid #e8eaf0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color: #888;
  font-size: 15px;
  line-height: 1.6;
}

/* ════════════════════════════════════════════════════════════════════
   MOBILE  ≤ 640px
   ─ App fills exactly the viewport (no scroll, no overflow)
   ─ Tab bar is FIXED to the bottom of the viewport
   ─ Safe-area padding for notched / home-indicator devices
   ════════════════════════════════════════════════════════════════════ */
/* ── Body/HTML scroll lock when hub is active on mobile ────────────
   Applied via JS on ≤640px so the page beneath the fixed app
   cannot scroll at all. The class is added/removed dynamically.   */
html.ch-locked,
html.ch-locked body {
  overflow: hidden !important;
  height: 100% !important;
  /* Prevent iOS rubber-band scroll on the page layer */
  overscroll-behavior: none !important;
  /* NOTE: touch-action is intentionally NOT set here.
     Setting touch-action:none on html/body would block all touch
     interactions (taps, drags, scrolls) inside child-app modals.
     Page-scroll prevention is handled by overflow:hidden +
     the document-level touchmove listener in community-hub.js. */
}

/* Restore full touch interaction for everything inside the app so
   child-plugin modals (dropdowns, pickers, scrollable lists) work. */
html.ch-locked #ch-app,
html.ch-locked #ch-app * {
  touch-action: auto;
}

@media (max-width: 640px) {

  /* Remove any outer wrapper spacing */
  .ch-app-outer {
    margin: 0;
    padding: 0;
  }

  /* App = full screen, no rounding, no shadow */
  #ch-app {
    position: fixed;
    inset: 0;               /* top:0 right:0 bottom:0 left:0 */
    width: 100%;
    height: 100%;
    /* Use dvh as progressive enhancement — falls back to 100% */
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
    /* Stack: top-bar | content | [tab-bar is outside normal flow] */
    display: flex;
    flex-direction: column;
  }

  /* ── Top bar ── */
  #ch-top-bar {
    height: var(--ch-top-h-mob);
    padding: 40px 14px;
    flex-shrink: 0;
    /* Push down below device status bar */
    /* padding-top: env(safe-area-inset-top, 0px); */
    height: calc(var(--ch-top-h-mob) + env(safe-area-inset-top, 0px));
  }
  .ch-logo     { font-size: 20px; }
  .ch-user-name { display: none; } /* reclaim space */

  /* ── Logout button — icon only on mobile ── */
  .ch-logout-text {
    display: none;
  }
  .ch-logout-btn {
    padding: 10px;
    border-radius: 50%;
    min-width: 44px;
    justify-content: center;
  }
  .ch-logout-icon svg {
    width: 22px;
    height: 22px;
  }

  /* ── Tab bar: fixed to viewport bottom ── */
  #ch-tab-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    z-index: 10000 !important; /* above any theme chrome */
    /* Flex row, stretch items equally */
    display: flex;
    align-items: stretch;
    padding: 0;
    gap: 0;
    overflow-x: visible;  /* no horizontal scroll on mobile */
    overflow-y: visible;
    border-bottom: none;
    border-top: 1px solid rgba(255,255,255,.10);
    /* Extend into home-indicator area */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(var(--ch-tab-h-mob) + env(safe-area-inset-bottom, 0px));
    /* Promote to own compositing layer — prevents iOS scroll containers
       from displacing position:fixed children */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    touch-action: manipulation;
  }

  .ch-tab {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px 10px;
    font-size: 11px;
    border-bottom: none;
    border-top: 3px solid transparent;
    margin-bottom: 0;
    margin-top: 0;
    border-radius: 0;
    min-height: 0;
    /* Active indicator at top */
  }
  .ch-tab.ch-tab-active {
    border-top-color: var(--ch-accent-light);
    border-bottom: none;
  }
  .ch-tab-icon  { font-size: 24px; }

  /* ── Content pane: fills space between top bar and fixed tab bar ── */
  #ch-content {
    flex: 1;
    overflow: hidden;
    /* Reserve space equal to fixed tab bar height */
    padding-bottom: calc(var(--ch-tab-h-mob) + env(safe-area-inset-bottom, 0px));
  }

  /* Active pane scrolls internally */
  .ch-pane.ch-pane-active {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth momentum scrolling */
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
  }

  /* ── Modal adjustments for mobile ── */
  .ch-modal-content {
    max-width: 90%;
    padding: 24px;
  }
  .ch-modal-title {
    font-size: 18px;
  }
  .ch-modal-message {
    font-size: 14px;
  }
  .ch-modal-actions {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .ch-modal-btn {
    width: 100%;
  }
}

/* ── Very small phones (≤ 360px) ── */
@media (max-width: 360px) {
  .ch-tab-label { display: none; }   /* icon only */
  .ch-tab-icon  { font-size: 24px; }
  .ch-tab       { min-height: 0; }
}

/* ════════════════════════════════════════════════════════════════════
   TABLET  641px – 1024px
   ─ Fixed layout identical to mobile: app locks to viewport, no scroll
   ─ Tab bar fixed to bottom, content fills between top-bar & tab-bar
   ─ All mobile-only (≤ 640px) rules remain untouched
   ════════════════════════════════════════════════════════════════════ */
@media (min-width: 641px) and (max-width: 1024px) {

  /* Strip any outer margin / padding the theme may add */
  .ch-app-outer {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Lock app to full viewport — no page scroll, no rounding */
  #ch-app {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }

  /* Top bar — respect device safe-area on tablets too */
  #ch-top-bar {
    flex-shrink: 0;
    height: calc(var(--ch-top-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }

  /* Tab bar — fixed to viewport bottom */
  #ch-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: stretch;
    padding: 0;
    gap: 0;
    overflow-x: visible;
    border-bottom: none;
    border-top: 1px solid rgba(255,255,255,.10);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(var(--ch-tab-h-mob) + env(safe-area-inset-bottom, 0px));
  }

  .ch-tab {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px 10px;
    font-size: 12px;
    border-bottom: none;
    border-top: 3px solid transparent;
    margin-bottom: 0;
    margin-top: 0;
    border-radius: 0;
    min-height: 0;
  }
  .ch-tab.ch-tab-active {
    border-top-color: var(--ch-accent-light);
    border-bottom: none;
  }
  .ch-tab-icon { font-size: 22px; }

  /* Content — fills space between top-bar and fixed tab-bar */
  #ch-content {
    flex: 1;
    overflow: hidden;
    padding-bottom: calc(var(--ch-tab-h-mob) + env(safe-area-inset-bottom, 0px));
  }

  .ch-pane.ch-pane-active {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
  }
}

/* ── Chat tab unread badge ──────────────────────────────────────── */
.ch-chat-unread-badge {
  display: none;
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: #dc3545;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  line-height: 17px;
  border-radius: 9px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
  white-space: nowrap;
  /* Subtle pop-in animation */
  animation: none;
}
.ch-chat-unread-badge--visible {
  display: block;
  animation: ch-badge-pop .2s ease;
}
@keyframes ch-badge-pop {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* On mobile the icon is larger — shift badge accordingly */
@media (max-width: 640px) {
  .ch-chat-unread-badge {
    top: -4px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    line-height: 18px;
  }
}

/* ── Practice tab breathing animation ──────────────────────────── */
/* Applied to .ch-tab-icon when the practice timer is running.     */
/* Gentle scale + opacity pulse — visible on dark tab bar.          */
@keyframes ch-practice-breathe {
  0%   { transform: scale(1);    opacity: 1;   filter: drop-shadow(0 0 0px rgba(129,140,248,0)); }
  50%  { transform: scale(1.22); opacity: .80; filter: drop-shadow(0 0 6px rgba(129,140,248,.9)); }
  100% { transform: scale(1);    opacity: 1;   filter: drop-shadow(0 0 0px rgba(129,140,248,0)); }
}
.ch-practice-breathing {
  animation: ch-practice-breathe 2s ease-in-out infinite;
  display: inline-block; /* needed for transform to apply on inline elements */
}

/* ════════════════════════════════════════════════════════════════════
   Schedule tab — Live Date Icon  (cs-live-icon)
   Renders like a native iOS/Android calendar app icon:
   a coloured month header strip + large bold day number below.
   The .ch-tab-icon wraps it so the existing badge and breathing
   animation continue to work untouched on the parent span.
   ════════════════════════════════════════════════════════════════════ */
.cs-live-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: #fff;
  border: 1.5px solid rgba(255,255,255,.35);
  overflow: hidden;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  vertical-align: middle;
}
.cs-live-icon-month {
  display: block;
  width: 100%;
  background: #dc3545;          /* iOS-style red header strip */
  color: #fff;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .04em;
  text-align: center;
  padding: 2px 0 1px;
  line-height: 1;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}
.cs-live-icon-day {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #1a1a2e;
  text-align: center;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  line-height: 1;
  padding: 1px 0 2px;
}

/* Active tab: invert day number so it's readable on the indigo background */
.ch-tab.ch-tab-active .cs-live-icon-day { color: #1a1a2e; }

/* Slightly smaller on desktop where tab icons are 16px */
@media (min-width: 641px) {
  .cs-live-icon { width: 28px; height: 28px; border-radius: 6px; }
  .cs-live-icon-month { font-size: 6px; }
  .cs-live-icon-day   { font-size: 13px; }
}

/* On mobile the tab icon is 24px — let the calendar icon breathe */
@media (max-width: 640px) {
  .cs-live-icon { width: 34px; height: 34px; border-radius: 8px; }
  .cs-live-icon-month { font-size: 8px; }
  .cs-live-icon-day   { font-size: 15px; }
}


/* ── Universal modal loader spinner ────────────────────────────────
   Used by practice-logger and chat modals.
   .pl-modal-loader  : wrapper (centres the spinner in a modal body)
   .pl-spinner       : the spinning ring
   ────────────────────────────────────────────────────────────────── */
.pl-modal-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    min-height: 140px;
    gap: 14px;
}
.pl-spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(79,70,229,.15);
    border-top-color: #4f46e5;
    animation: pl-spin .7s linear infinite;
    flex-shrink: 0;
}
.pl-spinner-label {
    font-size: 13px;
    color: #888;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   Desktop / PC / Mac only (≥1025px)
   ══════════════════════════════════════════════════════════════════
   Layout goal: hub fills full viewport; tabs merge into the header
   row so the content area is taller.

   Merged header technique:
   ┌─────────────────────────────────────────────────┐
   │ 🕌 Hub Brand    [Chat][Practice][Schedule]…   👤 Logout │
   └─────────────────────────────────────────────────┘
   ─────────────────────────────────────────────────────────
                     Content pane (full remaining height)

   #ch-top-bar and #ch-tab-bar are DOM siblings inside #ch-app.
   We switch #ch-app to CSS Grid (2 rows), then place BOTH the
   top-bar and tab-bar in grid row 1. #ch-tab-bar is positioned
   absolutely within the row so it floats in the centre while
   #ch-top-bar keeps logo on the left and user+logout on the right.
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 1025px) {

  /* Strip outer wrapper spacing */
  .ch-app-outer {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Hub fills full viewport */
  #ch-app {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 9990;
    /* Switch to grid: row 1 = merged header, row 2 = content */
    display: grid;
    grid-template-rows: 72px 1fr;
    grid-template-columns: 1fr;
  }

  /* Admin bar: shift hub down 32px */
  html.admin-bar #ch-app {
    top: 32px;
    height: calc(100dvh - 32px);
  }

  /* ── Merged header row ── */
  /* Both #ch-top-bar and #ch-tab-bar occupy grid row 1 */
  #ch-top-bar,
  #ch-tab-bar {
    grid-row: 1;
    grid-column: 1;
  }

  /* Top bar: full-width dark background, logo left, user+logout right */
  #ch-top-bar {
    position: relative;     /* establishes stacking context for tab overlay */
    z-index: 2;
    display: flex;
    align-items: center;
    height: 72px;
    padding: 0 24px;
    border-bottom: none;    /* tabs provide the bottom border */
    gap: 16px;
  }

  /* Hide the spacer — tabs fill the middle instead */
  #ch-top-bar .ch-spacer {
    display: none;
  }

  /* Push user pill and logout button to the far right */
  #ch-top-bar .ch-user-pill {
    margin-left: auto;
  }

  /* Tab bar: overlay on top of the top-bar, centred between logo and user area */
  #ch-tab-bar {
    position: relative;
    z-index: 3;             /* above top-bar so tabs receive pointer events */
    background: transparent;
    border-bottom: none;
    display: flex;
    align-items: center;    /* vertically centre tabs in the 60px row */
    padding: 0;
    gap: 2px;
    /* Push tabs away from logo and user pill */
    padding-left: 210px;
    padding-right: 260px;
    pointer-events: none;   /* top-bar handles background clicks */
    overflow: visible;
  }

  /* Re-enable pointer events on the actual tab buttons */
  #ch-tab-bar .ch-tab {
    pointer-events: auto;
    border-bottom: none;
    border-radius: 8px;
    padding: 8px 16px;
    margin-bottom: 0;
    /* Highlight active tab with bottom accent line */
    position: relative;
  }
  #ch-tab-bar .ch-tab::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--ch-accent-light);
    border-radius: 3px;
    transition: width .2s ease;
  }
  #ch-tab-bar .ch-tab.ch-tab-active::after {
    width: 70%;
  }
  #ch-tab-bar .ch-tab.ch-tab-active {
    border-bottom-color: transparent;
    background: rgba(129,140,248,.13);
  }

  /* A subtle bottom border for the whole combined header */
  #ch-top-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--ch-bg-dark2);
  }

  /* ── Content area ── */
  #ch-content {
    grid-row: 2;
    grid-column: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
  }

  /* Panes fill content area */
  .ch-pane {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  .ch-pane.ch-pane-active {
    display: flex;
    flex-direction: column;
  }

  /* Chat plugin fills its pane — stays in normal flow, not fixed */
  .ch-pane #wpcc-app {
    position: static !important;
    height: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }
}
