/* ═══════════════════════════════════════════════════════════════════════
   Right-edge panel rail + drawers — Patient Context / Media Search /
   Personal Space. Theme-owned rebuild of the legacy .pcp-/.msp-/.psp-
   panels, same visual family as .lx-sheet/.lx-modal (glass, --lx-* tokens).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Rail ─────────────────────────────────────────────────────────────── */
.lx-panel-rail {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  /* One above the drawer (same --lx-z-panel): the drawer's right edge sits
     only var(--lx-s-3) from the viewport edge, which doesn't clear the
     rail's own width, so an open drawer paints over the rail wherever they
     overlap and silently blocks every button/drag on it unless the rail
     wins the stacking order. */
  z-index: calc(var(--lx-z-panel) + 1);
  display: flex;
  flex-direction: column;
  gap: var(--lx-s-2);
  padding: var(--lx-s-2);
  background: var(--lx-panel-surface);
  border: 1px solid var(--lx-glass-border);
  border-right: none;
  border-radius: var(--lx-r-lg) 0 0 var(--lx-r-lg);
  backdrop-filter: blur(var(--lx-glass-blur));
  -webkit-backdrop-filter: blur(var(--lx-glass-blur));
  box-shadow: var(--lx-shadow-raised), var(--lx-glass-inset);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lx-panel-rail { background: var(--lx-panel-surface); }
}
.lx-panel-rail { cursor: grab; touch-action: none; }
.lx-panel-rail.is-dragging { transition: none; cursor: grabbing; }
.lx-panel-rail__grip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 16px;
  margin-bottom: 2px;
  cursor: grab;
  touch-action: none;
  border-radius: var(--lx-r-sm);
}
.lx-panel-rail__grip::before {
  content: '';
  width: 20px;
  height: 3px;
  border-radius: var(--lx-r-full);
  background: var(--lx-t4);
  box-shadow: 0 5px 0 var(--lx-t4);
  opacity: .5;
  transition: opacity var(--lx-t-fast) var(--lx-ease);
}
.lx-panel-rail__grip:hover::before,
.lx-panel-rail.is-dragging .lx-panel-rail__grip::before { opacity: .9; }
.lx-panel-rail.is-dragging .lx-panel-rail__grip { cursor: grabbing; }
.lx-panel-rail__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 36px;
  padding: var(--lx-s-2) var(--lx-s-1);
  background: none;
  border: none;
  border-radius: var(--lx-r-md);
  color: var(--lx-t3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background var(--lx-t-fast) var(--lx-ease), color var(--lx-t-fast) var(--lx-ease),
              width var(--lx-t-fast) var(--lx-ease);
  position: relative;
}
/* Root-cause fix for the recurring "rail overlaps trailing page content"
   family of bugs (BUG-005, BUG-016, BUG-020, and this run's bill-detail
   finding): at rest the rail is icon-only (36px/button) instead of
   icon+label (52px/button), roughly halving its resting footprint on every
   page that mounts it, so it clears far more trailing-column/button layouts
   without any per-page CSS. The label reappears on hover/focus/drag, when
   the user's attention is already on the rail and not on the content behind
   it; `title`/`aria-label` on the button already carry the same text for
   anyone who never hovers, so nothing is lost when collapsed. The label
   span is a flex item without an explicit width, so it can be squeezed
   narrower than a short single word (e.g. "Space") and wrap mid-word —
   these labels are always one short word, never wrap them. */
.lx-panel-rail__btn span {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width var(--lx-t-fast) var(--lx-ease), opacity var(--lx-t-fast) var(--lx-ease);
}
.lx-panel-rail:hover .lx-panel-rail__btn,
.lx-panel-rail:focus-within .lx-panel-rail__btn,
.lx-panel-rail.is-dragging .lx-panel-rail__btn {
  width: 52px;
}
.lx-panel-rail:hover .lx-panel-rail__btn span,
.lx-panel-rail:focus-within .lx-panel-rail__btn span,
.lx-panel-rail.is-dragging .lx-panel-rail__btn span {
  max-width: 60px;
  opacity: 1;
}
.lx-panel-rail__btn:hover { background: var(--lx-fill-hover); color: var(--lx-t1); }
.lx-panel-rail__btn.is-active { background: var(--lx-accent-soft); color: var(--lx-accent); }
.lx-panel-rail__badge {
  position: absolute;
  top: 2px;
  right: 6px;
  min-width: 15px;
  height: 15px;
  border-radius: var(--lx-r-full);
  background: var(--lx-danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  padding: 0 3px;
}

/* ── Overlay (mobile) ─────────────────────────────────────────────────── */
/* Invisible on desktop (still catches clicks so click-outside-to-close
   works everywhere); tinted dark only on the mobile full-screen layout,
   where a floating drawer needs to visually separate from the page
   underneath it. */
.lx-panel-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: calc(var(--lx-z-panel) - 1);
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--lx-t-base) var(--lx-ease);
}
.lx-panel-overlay.is-open { visibility: visible; pointer-events: auto; }
@media (max-width: 900px) {
  .lx-panel-overlay { background: rgba(0, 0, 0, .45); opacity: 0; }
  .lx-panel-overlay.is-open { opacity: 1; }
}

/* ── Drawer shell ─────────────────────────────────────────────────────── */
.lx-panel {
  position: fixed;
  top: calc(var(--lx-topbar-h) + var(--lx-s-2));
  bottom: var(--lx-s-3);
  right: var(--lx-s-3);
  width: 380px;
  max-width: calc(100vw - 2 * var(--lx-s-3));
  background: var(--lx-panel-surface);
  border: 1px solid var(--lx-glass-border-strong);
  border-radius: var(--lx-r-lg);
  backdrop-filter: blur(var(--lx-glass-blur));
  -webkit-backdrop-filter: blur(var(--lx-glass-blur));
  box-shadow: var(--lx-shadow-overlay), var(--lx-glass-inset);
  z-index: var(--lx-z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateX(12px) scale(.98);
  transition: opacity var(--lx-t-base) var(--lx-ease), transform var(--lx-t-base) var(--lx-ease), visibility var(--lx-t-base);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lx-panel { background: var(--lx-panel-surface); }
}
.lx-panel.is-open { opacity: 1; visibility: visible; transform: translateX(0) scale(1); }

.lx-panel__resize {
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 64px;
  cursor: ew-resize;
  touch-action: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 var(--lx-r-sm) var(--lx-r-sm) 0;
  transition: background var(--lx-t-fast) var(--lx-ease);
}
.lx-panel__resize::before {
  content: '';
  width: 3px;
  height: 32px;
  border-radius: 2px;
  background: repeating-linear-gradient(to bottom, var(--lx-t4) 0, var(--lx-t4) 3px, transparent 3px, transparent 7px);
}
.lx-panel__resize:hover,
.lx-panel__resize.is-resizing { background: var(--lx-accent-soft); }
.lx-panel__resize:hover::before,
.lx-panel__resize.is-resizing::before {
  background: repeating-linear-gradient(to bottom, var(--lx-accent) 0, var(--lx-accent) 3px, transparent 3px, transparent 7px);
}

.lx-panel__head {
  display: flex;
  align-items: center;
  gap: var(--lx-s-2);
  padding: var(--lx-s-3) var(--lx-s-4);
  border-bottom: 1px solid var(--lx-line-soft);
  flex-shrink: 0;
  color: var(--lx-t2);
}
.lx-panel__title {
  flex: 1;
  font-size: .85rem;
  font-weight: 600;
  color: var(--lx-t1);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lx-panel__head-actions { display: flex; align-items: center; gap: 2px; }
.lx-panel__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: var(--lx-r-sm);
  color: var(--lx-t3);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--lx-t-fast) var(--lx-ease), color var(--lx-t-fast) var(--lx-ease);
}
.lx-panel__icon-btn:hover { background: var(--lx-fill-hover); color: var(--lx-accent); }
.lx-panel__icon-btn--accent { color: var(--lx-accent); }
.lx-panel__icon-btn--danger:hover { color: var(--lx-danger); background: var(--lx-danger-soft); }
.lx-panel__deep-badge {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--lx-accent);
  background: var(--lx-accent-soft);
  border: 1px solid var(--lx-accent-soft);
  border-radius: var(--lx-r-sm);
  padding: 1px 6px;
}

.lx-panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--lx-s-3);
  display: flex;
  flex-direction: column;
  gap: var(--lx-s-3);
}
.lx-panel__body--media { padding: 0; gap: 0; }

.lx-panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--lx-s-2);
  color: var(--lx-t4);
  font-size: .82rem;
  text-align: center;
  padding: var(--lx-s-8) var(--lx-s-4);
}
.lx-panel-empty svg { opacity: .4; }
.lx-panel-empty-inline { color: var(--lx-t4); font-size: .8rem; padding: var(--lx-s-3); }

.lx-panel-loading, .lx-panel-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--lx-s-2);
  color: var(--lx-t4);
  font-size: .82rem;
  padding: var(--lx-s-6);
  text-align: center;
}
.lx-panel-error { color: var(--lx-danger); }
.lx-panel-spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--lx-line);
  border-top-color: var(--lx-accent);
  border-radius: 50%;
  animation: lx-panel-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes lx-panel-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lx-panel-spinner { animation-duration: 1.4s; } }

/* ── Shared small controls ──────────────────────────────────────────── */
.lx-panel-chip {
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--lx-r-full);
  border: 1px solid var(--lx-line);
  background: var(--lx-fill);
  color: var(--lx-t2);
  cursor: pointer;
  transition: background var(--lx-t-fast) var(--lx-ease), color var(--lx-t-fast) var(--lx-ease), border-color var(--lx-t-fast) var(--lx-ease);
}
.lx-panel-chip:hover { background: var(--lx-fill-hover); color: var(--lx-t1); }
.lx-panel-chip.is-active,
.lx-panel-chip--accent { background: var(--lx-accent); border-color: var(--lx-accent); color: #fff; }
.lx-panel-chip:disabled { opacity: .5; cursor: default; }

/* ── Patient panel content ─────────────────────────────────────────── */
.lx-panel-content { display: flex; flex-direction: column; gap: var(--lx-s-3); }
.lx-panel-demo {
  background: var(--lx-fill);
  border: 1px solid var(--lx-line-soft);
  border-radius: var(--lx-r-md);
  padding: var(--lx-s-3);
}
.lx-panel-demo__name { font-size: .9rem; font-weight: 600; color: var(--lx-t1); margin-bottom: 4px; }
.lx-panel-demo__meta { font-size: .75rem; color: var(--lx-t3); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lx-panel-legend { display: flex; gap: 10px; font-size: .68rem; color: var(--lx-t4); flex-wrap: wrap; }
.lx-panel-legend__dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 3px; }

.lx-panel-section { border: 1px solid var(--lx-line-soft); border-radius: var(--lx-r-md); overflow: hidden; }
.lx-panel-section__head {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px;
  background: var(--lx-fill);
  cursor: pointer;
  user-select: none;
  font-size: .72rem;
  font-weight: 700;
  color: var(--lx-t2);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.lx-panel-section__head:hover { background: var(--lx-fill-hover); }
.lx-panel-section__chevron { margin-left: auto; transition: transform var(--lx-t-fast) var(--lx-ease); }
.lx-panel-section__head.is-collapsed .lx-panel-section__chevron { transform: rotate(-90deg); }
.lx-panel-section__body { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.lx-panel-section__body.is-collapsed { display: none; }
.lx-panel-notes-area {
  width: 100%;
  background: var(--lx-fill);
  border: 1px solid var(--lx-line);
  border-radius: var(--lx-r-sm);
  color: var(--lx-t2);
  font-size: .78rem;
  padding: 7px 9px;
  resize: vertical;
  min-height: 56px;
  font-family: inherit;
  box-sizing: border-box;
}
.lx-panel-notes-area:focus { outline: none; border-color: var(--lx-accent); color: var(--lx-t1); }

/* ── Media panel ────────────────────────────────────────────────────── */
.lx-panel-tabs { display: flex; gap: 2px; padding: var(--lx-s-2) var(--lx-s-3); border-bottom: 1px solid var(--lx-line-soft); flex-shrink: 0; }
.lx-panel-tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 10px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--lx-t3);
  background: none;
  border: none;
  border-radius: var(--lx-r-sm);
  cursor: pointer;
}
.lx-panel-tab:hover { background: var(--lx-fill-hover); color: var(--lx-t1); }
.lx-panel-tab.is-active { background: var(--lx-accent-soft); color: var(--lx-accent); }
.lx-media-box { flex: 1; overflow-y: auto; padding: var(--lx-s-3); display: flex; flex-direction: column; gap: var(--lx-s-3); }
.lx-media-search { display: flex; gap: 6px; }
.lx-media-search__input {
  flex: 1;
  background: var(--lx-fill);
  border: 1px solid var(--lx-line);
  border-radius: var(--lx-r-sm);
  color: var(--lx-t1);
  font-size: .82rem;
  padding: 7px 10px;
}
.lx-media-search__input:focus { outline: none; border-color: var(--lx-accent); }
.lx-media-search__btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px;
  background: var(--lx-accent);
  color: #fff;
  border: none;
  border-radius: var(--lx-r-sm);
  cursor: pointer;
}
.lx-media-results { display: grid; grid-template-columns: 1fr 1fr; gap: var(--lx-s-2); }
.lx-media-result {
  display: block; text-decoration: none; color: var(--lx-t2);
  border: 1px solid var(--lx-line-soft);
  border-radius: var(--lx-r-md);
  overflow: hidden;
  transition: border-color var(--lx-t-fast) var(--lx-ease);
}
.lx-media-result:hover { border-color: var(--lx-accent); }
.lx-media-result img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.lx-media-result__title { font-size: .74rem; font-weight: 600; padding: 5px 7px 2px; color: var(--lx-t1); line-height: 1.3; }
.lx-media-result__meta { font-size: .68rem; color: var(--lx-t4); padding: 0 7px 6px; }
/* Google CSE widget — reset its inline theme to match glass panel */
.lx-media-box .gsc-control-cse { background: transparent !important; border: none !important; padding: 0 !important; }
.lx-media-box .gsc-input-box { background: var(--lx-fill) !important; border-radius: var(--lx-r-sm) !important; }

/* ── Personal Space panel ──────────────────────────────────────────── */
.lx-personal-quickadd { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lx-personal-quickadd__label { font-size: .72rem; color: var(--lx-t4); }
.lx-personal-quickform { display: flex; flex-direction: column; gap: 6px; background: var(--lx-fill); border-radius: var(--lx-r-md); padding: var(--lx-s-2); }
.lx-personal-quickform__input {
  background: var(--lx-glass);
  border: 1px solid var(--lx-line);
  border-radius: var(--lx-r-sm);
  color: var(--lx-t1);
  font-size: .8rem;
  padding: 6px 9px;
}
.lx-personal-quickform__input:focus { outline: none; border-color: var(--lx-accent); }
.lx-personal-quickform__btns { display: flex; justify-content: flex-end; gap: 6px; }

.lx-personal-block { border: 1px solid var(--lx-line-soft); border-radius: var(--lx-r-md); overflow: hidden; }
.lx-personal-block__head {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 9px;
  background: var(--lx-fill);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--lx-t2);
  text-transform: uppercase;
}
.lx-personal-block__title { flex: 1; }
.lx-personal-block__meta { font-size: .66rem; font-weight: 500; text-transform: none; color: var(--lx-t4); }
.lx-personal-block__arrow {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  color: var(--lx-t3);
  cursor: pointer;
  border-radius: 3px;
}
.lx-personal-block__arrow:hover { background: var(--lx-fill-hover); color: var(--lx-accent); }
#lxPersonalBlocks.is-editing .lx-personal-block { border-color: var(--lx-accent-soft); }
.lx-personal-cal-nav { display: flex; gap: 2px; }
.lx-personal-cal-nav button {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  background: none; border: none; color: var(--lx-t3); cursor: pointer; border-radius: 3px;
}
.lx-personal-cal-nav button:hover { background: var(--lx-fill-hover); color: var(--lx-t1); }

.lx-cal-grid { width: 100%; border-collapse: collapse; padding: 6px; font-size: .68rem; }
.lx-cal-grid th { color: var(--lx-t4); font-weight: 600; padding: 2px 0; }
.lx-cal-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 3px 0; border-radius: 5px; min-height: 24px; cursor: pointer;
}
.lx-cal-day:hover { background: var(--lx-fill-hover); }
.lx-cal-day.is-today { background: var(--lx-accent-soft); }
.lx-cal-day.other-month { visibility: hidden; }
.lx-cal-day__num { color: var(--lx-t2); }
.lx-cal-day__dots { display: flex; gap: 2px; height: 5px; }
.lx-cal-dot { width: 4px; height: 4px; border-radius: 50%; }
.lx-cal-dot--todo { background: var(--lx-info); }
.lx-cal-dot--todo-linked { background: var(--lx-success); }
.lx-cal-dot--event { background: var(--lx-warning); }

.lx-todo-row { display: flex; align-items: center; gap: 8px; padding: 5px 9px; font-size: .8rem; }
.lx-todo-check {
  width: 15px; height: 15px; border-radius: 4px;
  border: 1.5px solid var(--lx-line);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.lx-todo-check.is-checked { background: var(--lx-accent); border-color: var(--lx-accent); }
.lx-todo-title { color: var(--lx-t1); }
.lx-todo-title.is-done { color: var(--lx-t4); text-decoration: line-through; }

.lx-note-row { padding: 6px 9px; cursor: pointer; border-radius: var(--lx-r-sm); }
.lx-note-row:hover { background: var(--lx-fill-hover); }
.lx-note-row__title { font-size: .8rem; font-weight: 600; color: var(--lx-t1); }
.lx-note-row__body { font-size: .74rem; color: var(--lx-t3); }

.lx-vn-label { font-size: .68rem; font-weight: 600; color: var(--lx-t4); text-transform: uppercase; letter-spacing: .03em; margin: 6px 9px 4px; }
.lx-vn-bar { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 9px 6px; }
.lx-vn-btn {
  font-size: .68rem; font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--lx-r-full);
  border: 1px solid var(--lx-line);
  background: var(--lx-fill);
  color: var(--lx-t3);
  cursor: pointer;
}
.lx-vn-btn.is-active { background: var(--lx-accent); border-color: var(--lx-accent); color: #fff; }
.lx-vn-patient-row { padding: 0 9px 8px; display: flex; flex-direction: column; gap: 3px; }
.lx-vn-select, .lx-vn-transcript, .lx-vn-patient-row select {
  width: 100%;
  background: var(--lx-fill);
  border: 1px solid var(--lx-line);
  border-radius: var(--lx-r-sm);
  color: var(--lx-t1);
  font-size: .78rem;
  padding: 6px 8px;
  font-family: inherit;
  box-sizing: border-box;
}
.lx-vn-transcript { min-height: 90px; resize: vertical; }
.lx-vn-field-label { display: block; font-size: .68rem; color: var(--lx-t4); margin: 8px 0 3px; }
.lx-vn-record-row { display: flex; align-items: center; gap: 8px; padding: 4px 9px 8px; }
.lx-vn-mic-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--lx-r-full);
  border: 1px solid var(--lx-line);
  background: var(--lx-fill);
  color: var(--lx-t1);
  cursor: pointer;
}
.lx-vn-mic-btn.is-recording { background: var(--lx-danger); border-color: var(--lx-danger); color: #fff; }
.lx-vn-status { font-size: .72rem; color: var(--lx-t4); }
.lx-vn-viewall { text-align: right; padding: 2px 9px 8px; }
.lx-vn-viewall a { font-size: .74rem; color: var(--lx-accent); text-decoration: none; }

.lx-ws-search-row { padding: 8px 9px 4px; }
.lx-ws-search {
  width: 100%; box-sizing: border-box;
  background: var(--lx-glass);
  border: 1px solid var(--lx-line);
  border-radius: var(--lx-r-sm);
  color: var(--lx-t1);
  font-size: .78rem;
  padding: 6px 9px;
}
.lx-ws-search:focus { outline: none; border-color: var(--lx-accent); }

.lx-ws-tree { font-size: .78rem; padding: 2px 6px 4px; max-height: 140px; overflow-y: auto; }
.lx-ws-tree-item, .lx-ws-tree-row {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 6px; border-radius: var(--lx-r-sm);
  cursor: pointer; color: var(--lx-t2);
}
.lx-ws-tree-item:hover, .lx-ws-tree-row:hover { background: var(--lx-fill-hover); }
.lx-ws-tree-item.is-active, .lx-ws-tree-row.is-active { background: var(--lx-accent-soft); color: var(--lx-accent); }
.lx-ws-tree-node { margin-left: .85rem; }
.lx-ws-caret { width: 11px; text-align: center; font-size: .62rem; color: var(--lx-t4); cursor: pointer; user-select: none; }
.lx-ws-caret.is-leaf { visibility: hidden; }
.lx-ws-tree-children { display: none; }
.lx-ws-tree-children.open { display: block; }

.lx-ws-files { padding: 2px 6px 6px; max-height: 160px; overflow-y: auto; }
.lx-ws-file-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px; border-radius: var(--lx-r-sm);
  cursor: pointer; font-size: .78rem; color: var(--lx-t1);
}
.lx-ws-file-row:hover { background: var(--lx-fill-hover); }
.lx-ws-file-row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-ws-file-row__path { font-size: .66rem; color: var(--lx-t4); }
.lx-vn-row { padding: 6px 9px; cursor: pointer; border-radius: var(--lx-r-sm); }
.lx-vn-row:hover { background: var(--lx-fill-hover); }
.lx-vn-row__title { font-size: .78rem; font-weight: 600; color: var(--lx-t1); }
.lx-vn-row__meta { font-size: .68rem; color: var(--lx-t4); }
.lx-vn-type-badge {
  font-size: .6rem; font-weight: 700;
  padding: 1px 5px; border-radius: 4px;
  background: var(--lx-info-soft); color: var(--lx-info);
  margin-left: 5px;
}
.lx-vn-ai-status { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--lx-t3); padding: 8px 0; }
.lx-vn-structured-head { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--lx-t4); margin: 10px 0 4px; }
.lx-vn-structured-field { margin-bottom: 6px; }

/* ── Modals (voice note pre-save / detail) ─────────────────────────── */
.lx-panel-modal {
  position: fixed;
  inset: 0;
  z-index: var(--lx-z-sheet);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--lx-s-4);
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--lx-t-base) var(--lx-ease), visibility var(--lx-t-base);
}
.lx-panel-modal.is-open { opacity: 1; visibility: visible; }
.lx-panel-modal__panel {
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--lx-panel-surface);
  backdrop-filter: blur(var(--lx-glass-blur));
  -webkit-backdrop-filter: blur(var(--lx-glass-blur));
  border: 1px solid var(--lx-glass-border-strong);
  border-radius: var(--lx-r-lg);
  box-shadow: var(--lx-shadow-overlay), var(--lx-glass-inset);
  overflow: hidden;
  transform: scale(.97);
  transition: transform var(--lx-t-base) var(--lx-ease);
}
.lx-panel-modal.is-open .lx-panel-modal__panel { transform: scale(1); }
.lx-panel-modal__panel--wide { max-width: 480px; }
.lx-panel-modal__head {
  display: flex; align-items: center; gap: 8px;
  padding: var(--lx-s-3) var(--lx-s-4);
  border-bottom: 1px solid var(--lx-line-soft);
}
.lx-panel-modal__title { flex: 1; font-size: .88rem; font-weight: 700; color: var(--lx-t1); }
.lx-panel-modal__head-actions { display: flex; align-items: center; gap: 4px; }
.lx-panel-modal__body { flex: 1; overflow-y: auto; padding: var(--lx-s-4); display: flex; flex-direction: column; }
.lx-panel-modal__body > audio { width: 100%; margin-bottom: var(--lx-s-2); }
.lx-panel-modal__body input[type="text"] {
  background: var(--lx-fill);
  border: 1px solid var(--lx-line);
  border-radius: var(--lx-r-sm);
  color: var(--lx-t1);
  font-size: .82rem;
  padding: 7px 9px;
}
.lx-panel-modal__body input[type="text"]:focus { outline: none; border-color: var(--lx-accent); }
.lx-panel-modal__foot { display: flex; align-items: center; gap: 8px; padding: var(--lx-s-3) var(--lx-s-4); border-top: 1px solid var(--lx-line-soft); }
.lx-panel-modal__status { flex: 1; font-size: .72rem; color: var(--lx-t4); }

/* ── Mobile (<=900px): full-screen drawers, rail collapses to a slim bar ── */
@media (max-width: 900px) {
  .lx-panel__resize { display: none; }
  .lx-panel {
    top: calc(var(--lx-topbar-h) + var(--lx-s-1));
    bottom: var(--lx-s-2);
    left: var(--lx-s-2);
    right: var(--lx-s-2);
    width: auto;
    max-width: none;
    transform: translateY(10px) scale(.98);
  }
  .lx-panel.is-open { transform: translateY(0) scale(1); }
  .lx-panel-rail { top: auto; bottom: 90px; transform: none; border-radius: var(--lx-r-lg) 0 0 var(--lx-r-lg); }
  .lx-media-results { grid-template-columns: 1fr 1fr; }
}

/* ──────────────────────────────────────────────────────────────────────────
   Legacy area panels mounted into the rail.

   patientarea's profile (.pcp-*) and personal-space (.psp-*) drawers predate
   this shell and carry their own hardcoded z-index (1060/1100), far above the
   --lx-z-* scale. The rail's own rule already lifts it one above
   --lx-z-panel so an open drawer cannot swallow it — that reasoning applies
   just as much here, but the numbers don't, so the rail is lifted explicitly
   above the legacy layer whenever such a panel is mounted.

   Stacking is presentation, so the fix lives here rather than in the shell:
   nothing about which panels an area mounts changes.
   ────────────────────────────────────────────────────────────────────────── */
body:has(.pcp-panel, .psp-drawer) .lx-panel-rail {
  z-index: 1200;
}

/* Their own floating toggle buttons are hidden by the rail adapter (which
   sets [hidden]); this keeps them down even if a stylesheet resets display. */
.pcp-toggle-btn[hidden],
.psp-toggle-btn[hidden] {
  display: none !important;
}
