/* ShriLahari — unified theme contrast layer
 * Loaded after page/component styles so light mode cannot inherit dark-only text.
 */
[data-theme="light"] {
  --text: #111827;
  --text-strong: #0f172a;
  --muted: #475569;
  --muted-2: #64748b;
  --link: #5b21b6;
  --link-hover: #4c1d95;
  --border: rgba(15,23,42,.12);
  --border-strong: rgba(15,23,42,.2);
}

[data-theme="light"] .main,
[data-theme="light"] .content,
[data-theme="light"] .page,
[data-theme="light"] .panel,
[data-theme="light"] .card,
[data-theme="light"] .box,
[data-theme="light"] .modal,
[data-theme="light"] .stat-card,
[data-theme="light"] .empty-state,
[data-theme="light"] .list-card,
[data-theme="light"] .table-wrap {
  color: #111827;
}

/* Common secondary text: readable, but still visually secondary. */
[data-theme="light"] small,
[data-theme="light"] .muted,
[data-theme="light"] .meta,
[data-theme="light"] .hint,
[data-theme="light"] .help-text,
[data-theme="light"] .field-hint,
[data-theme="light"] .text-muted,
[data-theme="light"] .description,
[data-theme="light"] .subtitle,
[data-theme="light"] .subtext,
[data-theme="light"] .form-help,
[data-theme="light"] .topbar-storage,
[data-theme="light"] .empty-state p {
  color: #475569 !important;
  opacity: 1 !important;
}

/* Headings and labels */
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4,
[data-theme="light"] h5,
[data-theme="light"] h6,
[data-theme="light"] .section-title,
[data-theme="light"] .page-title,
[data-theme="light"] .form-label,
[data-theme="light"] label,
[data-theme="light"] legend,
[data-theme="light"] .field-label {
  color: #0f172a !important;
  opacity: 1 !important;
}

/* Tables: eliminate dark header + dark text combinations seen in light mode. */
[data-theme="light"] table thead,
[data-theme="light"] table thead tr,
[data-theme="light"] table thead th,
[data-theme="light"] .table-header,
[data-theme="light"] .table-head {
  background: #f1f5f9 !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] table th {
  color: #334155 !important;
  background: #f1f5f9 !important;
  font-weight: 700 !important;
}
[data-theme="light"] table td {
  color: #1f2937 !important;
  background: #ffffff;
  border-color: #e2e8f0 !important;
}
[data-theme="light"] table tr:hover td { background: #f8fafc !important; }

/* Common dark hard-coded table headers. */
[data-theme="light"] .dash-recent th,
[data-theme="light"] table thead th[style*="background"],
[data-theme="light"] .compact thead th {
  background: #f1f5f9 !important;
  color: #334155 !important;
}

/* Forms / controls */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea,
[data-theme="light"] .file-search,
[data-theme="light"] .file-sort {
  color: #111827 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder,
[data-theme="light"] select::placeholder {
  color: #64748b !important;
  opacity: 1 !important;
}
[data-theme="light"] option { color: #111827 !important; background: #ffffff !important; }
[data-theme="light"] button:not(.btn-primary):not(.theme-toggle-btn) {
  color: #334155;
}

/* Header controls */
[data-theme="light"] .theme-toggle-btn {
  color: #334155 !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  opacity: 1 !important;
}
[data-theme="light"] .theme-toggle-label { color: #334155 !important; opacity: 1 !important; }
[data-theme="light"] .theme-toggle-btn:hover { color: #4c1d95 !important; background: #f5f3ff !important; }
[data-theme="light"] .topbar,
[data-theme="light"] .topbar-row { color: #111827; }

/* Search/result surfaces */
[data-theme="light"] .pv-search-results,
[data-theme="light"] .search-results,
[data-theme="light"] .dropdown-menu,
[data-theme="light"] .popover {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 12px 30px rgba(15,23,42,.12) !important;
}
[data-theme="light"] .pv-s-h { color: #475569 !important; }
[data-theme="light"] .pv-s-item { color: #1f2937 !important; }
[data-theme="light"] .pv-s-empty { color: #475569 !important; }

/* Notes editor and inline editor controls. */
[data-theme="light"] .note-toolbar {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .note-toolbar .nt-btn,
[data-theme="light"] .note-toolbar .nt-select {
  color: #334155 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .note-editor,
[data-theme="light"] [contenteditable="true"] {
  color: #111827 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .note-editor:empty:before { color: #64748b !important; }
[data-theme="light"] .note-editor a { color: #5b21b6 !important; }
[data-theme="light"] .note-editor blockquote { color: #475569 !important; background: #f5f3ff !important; }

/* TinyMCE/WordPress-style editor chrome. */
[data-theme="light"] .wp-classic-wrap .tox-tinymce {
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .wp-classic-wrap .tox .tox-toolbar,
[data-theme="light"] .wp-classic-wrap .tox .tox-toolbar__primary,
[data-theme="light"] .wp-classic-wrap .tox .tox-toolbar__overflow,
[data-theme="light"] .wp-classic-wrap .tox .tox-menubar,
[data-theme="light"] .wp-classic-wrap .tox .tox-statusbar {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .wp-classic-wrap .tox .tox-tbtn,
[data-theme="light"] .wp-classic-wrap .tox .tox-mbtn,
[data-theme="light"] .wp-classic-wrap .tox .tox-statusbar__path-item,
[data-theme="light"] .wp-classic-wrap .tox .tox-statusbar__wordcount {
  color: #334155 !important;
  fill: #334155 !important;
}
[data-theme="light"] .wp-classic-wrap .tox .tox-tbtn svg { fill: #334155 !important; }
[data-theme="light"] .wp-classic-wrap .tox .tox-tbtn:hover,
[data-theme="light"] .wp-classic-wrap .tox .tox-tbtn--enabled { background: #e2e8f0 !important; }
[data-theme="light"] .wp-classic-wrap .tox .tox-statusbar { color: #64748b !important; }

/* Stotra media browser was historically dark-only. */
[data-theme="light"] .stotra-media-dialog {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .stotra-media-head,
[data-theme="light"] .stotra-media-foot {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .stotra-media-head h3 { color: #0f172a !important; }
[data-theme="light"] .stotra-media-tools input[type="search"] {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .stotra-media-item {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .stotra-media-item .nm,
[data-theme="light"] .stotra-media-empty { color: #475569 !important; }

[data-theme="light"] .stotra-audio-item { background: #ffffff !important; border-color: #cbd5e1 !important; }
[data-theme="light"] .stotra-audio-empty { color: #475569 !important; }

/* File/gallery cards and metadata. */
[data-theme="light"] .file-item,
[data-theme="light"] .file-card,
[data-theme="light"] .pv-item,
[data-theme="light"] .media-card {
  color: #1f2937 !important;
}
[data-theme="light"] .file-item .meta,
[data-theme="light"] .file-pick .meta small,
[data-theme="light"] .pv-items .meta { color: #475569 !important; }

/* Admin/mantra list text. */
[data-theme="light"] .med-item-badge,
[data-theme="light"] .mantra-player-category,
[data-theme="light"] .mantra-player-time,
[data-theme="light"] .med-muted,
[data-theme="light"] .med-offline-hint { color: #475569 !important; opacity: 1 !important; }

/* Keep deliberately white text on accent buttons/badges. */
[data-theme="light"] .btn-primary,
[data-theme="light"] .btn-primary:hover,
[data-theme="light"] .play-btn,
[data-theme="light"] #mantra-playerPlayPause,
[data-theme="light"] .japa-counter-tabs .active,
[data-theme="light"] .japa-counter-seg-btn.active {
  color: #ffffff !important;
}

/* Prevent opacity from making ordinary light-mode text look disabled. */
[data-theme="light"] .content > *:not(.disabled),
[data-theme="light"] .card > *:not(.disabled) { opacity: 1; }

/* Disabled controls remain intentionally muted. */
[data-theme="light"] button:disabled,
[data-theme="light"] input:disabled,
[data-theme="light"] select:disabled,
[data-theme="light"] textarea:disabled { color: #94a3b8 !important; }


/* v5.1.51 — Messages light-theme premium contrast/readability */
[data-theme="light"] .messages-toolbar {
  background: #f8fafc !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 16px !important;
  padding: 12px !important;
  box-shadow: 0 6px 20px rgba(15,23,42,.05) !important;
}
[data-theme="light"] .messages-folder-tabs { gap: 8px !important; }
[data-theme="light"] .messages-folder-tabs .btn,
[data-theme="light"] .messages-toolbar .btn {
  color: #334155 !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 2px rgba(15,23,42,.04) !important;
  font-weight: 650 !important;
}
[data-theme="light"] .messages-folder-tabs .btn:hover,
[data-theme="light"] .messages-toolbar .btn:hover {
  color: #4c1d95 !important;
  background: #f5f3ff !important;
  border-color: #c4b5fd !important;
}
[data-theme="light"] .messages-folder-tabs .btn-primary,
[data-theme="light"] .messages-folder-tabs .btn.btn-primary {
  color: #ffffff !important;
  background: linear-gradient(135deg,#7c3aed,#6d28d9) !important;
  border-color: #6d28d9 !important;
}
[data-theme="light"] .messages-folder-search input,
[data-theme="light"] .message-search input {
  color: #111827 !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03) !important;
}
[data-theme="light"] .messages-folder-search input::placeholder,
[data-theme="light"] .message-search input::placeholder { color:#64748b !important; opacity:1 !important; }
[data-theme="light"] .messages-folder-search input:focus,
[data-theme="light"] .message-search input:focus {
  border-color:#8b5cf6 !important;
  box-shadow:0 0 0 3px rgba(139,92,246,.14) !important;
}
[data-theme="light"] .msg-row {
  background: #ffffff !important;
  color: #111827 !important;
  border-bottom: 1px solid #e2e8f0 !important;
  transition: background .16s ease, box-shadow .16s ease !important;
}
[data-theme="light"] .msg-row:hover {
  background: #faf8ff !important;
  box-shadow: inset 3px 0 0 #c4b5fd !important;
}
[data-theme="light"] .msg-row.unread {
  background: #f5f3ff !important;
  box-shadow: inset 3px 0 0 #7c3aed !important;
}
[data-theme="light"] .msg-row > a { color:#111827 !important; }
[data-theme="light"] .msg-row .name,
[data-theme="light"] .msg-row .top .name {
  color:#3b0764 !important;
  font-weight:700 !important;
}
[data-theme="light"] .msg-row .time {
  color:#334155 !important;
  font-weight:650 !important;
}
[data-theme="light"] .msg-row .preview {
  color:#475569 !important;
  opacity:1 !important;
}
[data-theme="light"] .msg-row .msg-meta {
  color:#64748b !important;
  opacity:1 !important;
}
[data-theme="light"] .msg-row input[type="checkbox"],
[data-theme="light"] #checkAll { accent-color:#7c3aed; }
[data-theme="light"] .glass-card {
  border-color:#dbe3ef !important;
  box-shadow:0 8px 24px rgba(15,23,42,.055) !important;
}
[data-theme="light"] .bulk-bar {
  background:#ffffff !important;
  border:1px solid #dbe3ef !important;
  color:#334155 !important;
}
[data-theme="light"] .empty-state {
  background:#ffffff !important;
  color:#334155 !important;
}

/* Message detail/chat page in light mode */
[data-theme="light"] .chat-shell {
  --chat-bg:#f8fafc;
  --chat-surface:#ffffff;
  --chat-bubble-them:#ffffff;
  --chat-border:#dbe3ef;
  --chat-tick:#64748b;
  background:#f8fafc !important;
  border-color:#dbe3ef !important;
  box-shadow:0 8px 28px rgba(15,23,42,.06) !important;
}
[data-theme="light"] .chat-header,
[data-theme="light"] .chat-composer {
  background:rgba(255,255,255,.97) !important;
  border-color:#dbe3ef !important;
}
[data-theme="light"] .chat-header-meta h2 { color:#0f172a !important; }
[data-theme="light"] .chat-header-meta .sub,
[data-theme="light"] .chat-meta-line,
[data-theme="light"] .chat-day-sep { color:#64748b !important; }
[data-theme="light"] .chat-row.them .chat-bubble {
  background:#ffffff !important;
  color:#1f2937 !important;
  border-color:#dbe3ef !important;
  box-shadow:0 3px 12px rgba(15,23,42,.06) !important;
}
[data-theme="light"] .chat-row.me .chat-bubble { color:#ffffff !important; }
[data-theme="light"] .chat-reply-preview { color:#475569 !important; background:#f1f5f9 !important; }
[data-theme="light"] .chat-day-sep { background:#e2e8f0 !important; }
[data-theme="light"] .chat-composer textarea,
[data-theme="light"] .chat-composer input { background:#ffffff !important; color:#111827 !important; border-color:#cbd5e1 !important; }

/* v5.1.51 CSS FINAL POLISH — light theme surfaces */
[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --sidebar: #ffffff;
  --card: #ffffff;
  --card-soft: rgba(255,255,255,.98);
  --text: #172033;
  --text-strong: #0b1220;
  --muted: #475569;
  --muted-2: #64748b;
  --border: #d9e0ea;
  --border-strong: #c5cfdd;
  --shadow-card: 0 8px 26px rgba(15,23,42,.065);
  --topbar-bg: rgba(255,255,255,.92);
  --input-bg: #ffffff;
}
[data-theme="light"] .sidebar {
  background: linear-gradient(180deg,#ffffff 0%,#f8fafc 100%) !important;
  border-right-color: #d9e0ea !important;
}
[data-theme="light"] .nav-item { color: #475569 !important; }
[data-theme="light"] .nav-item:hover { background:#f1f5f9 !important; color:#172033 !important; }
[data-theme="light"] .nav-item.active,
[data-theme="light"] .nav-group-toggle.active,
[data-theme="light"] .nav-group.open > .nav-group-toggle {
  background:#f3e8ff !important;
  color:#5b21b6 !important;
  box-shadow: inset 3px 0 0 #7c3aed !important;
}
[data-theme="light"] .nav-sub-item { color:#475569 !important; }
[data-theme="light"] .nav-sub-item.active { color:#5b21b6 !important; background:#f5f3ff !important; }
[data-theme="light"] .card,
[data-theme="light"] .panel,
[data-theme="light"] .box,
[data-theme="light"] .stat-card,
[data-theme="light"] .list-card,
[data-theme="light"] .table-wrap,
[data-theme="light"] .glass-card {
  background:#ffffff !important;
  border-color:#d9e0ea !important;
  box-shadow:0 8px 26px rgba(15,23,42,.065) !important;
}
[data-theme="light"] .topbar,
[data-theme="light"] .topbar-row {
  background:rgba(255,255,255,.92) !important;
  border-color:#d9e0ea !important;
}
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea { box-shadow: inset 0 1px 2px rgba(15,23,42,.025); }
[data-theme="light"] .empty-state { border-color:#c5cfdd !important; }

/* v5.1.51 CSS FINAL POLISH — light theme surfaces */
[data-theme="light"] { --bg:#f6f7fb; --bg-elevated:#fff; --sidebar:#fff; --card:#fff; --card-soft:rgba(255,255,255,.98); --text:#172033; --text-strong:#0b1220; --muted:#475569; --muted-2:#64748b; --border:#d9e0ea; --border-strong:#c5cfdd; --shadow-card:0 8px 26px rgba(15,23,42,.065); --topbar-bg:rgba(255,255,255,.92); --input-bg:#fff; }
[data-theme="light"] .sidebar { background:linear-gradient(180deg,#fff 0%,#f8fafc 100%)!important; border-right-color:#d9e0ea!important; }
[data-theme="light"] .nav-item { color:#475569!important; }
[data-theme="light"] .nav-item:hover { background:#f1f5f9!important; color:#172033!important; }
[data-theme="light"] .nav-item.active,[data-theme="light"] .nav-group-toggle.active,[data-theme="light"] .nav-group.open>.nav-group-toggle { background:#f3e8ff!important; color:#5b21b6!important; box-shadow:inset 3px 0 0 #7c3aed!important; }
[data-theme="light"] .nav-sub-item { color:#475569!important; }
[data-theme="light"] .nav-sub-item.active { color:#5b21b6!important; background:#f5f3ff!important; }
[data-theme="light"] .card,[data-theme="light"] .panel,[data-theme="light"] .box,[data-theme="light"] .stat-card,[data-theme="light"] .list-card,[data-theme="light"] .table-wrap,[data-theme="light"] .glass-card { background:#fff!important; border-color:#d9e0ea!important; box-shadow:0 8px 26px rgba(15,23,42,.065)!important; }
[data-theme="light"] .topbar,[data-theme="light"] .topbar-row { background:rgba(255,255,255,.92)!important; border-color:#d9e0ea!important; }
[data-theme="light"] input,[data-theme="light"] select,[data-theme="light"] textarea { box-shadow:inset 0 1px 2px rgba(15,23,42,.025); }
[data-theme="light"] .empty-state { border-color:#c5cfdd!important; }

/* ======================================================================
   v5.1.53 — FINAL LIGHT THEME / FILE GRID POLISH
   Fixes legacy dark inline styles, pale text, admin status text, and
   selection-checkbox overlap across Images / Audio / Video / Documents.
   ====================================================================== */
[data-theme="light"] {
  --text:#172033 !important;
  --text-strong:#0b1220 !important;
  --muted:#475569 !important;
  --muted-2:#64748b !important;
  --link:#6d28d9 !important;
  --link-hover:#4c1d95 !important;
  --card:#ffffff !important;
  --card-bg:#ffffff !important;
  --input-bg:#ffffff !important;
  --border:#d9e0ea !important;
}

/* Never allow legacy dark inline presentation to leak into Light mode. */
[data-theme="light"] [style*="background:rgba(0,0,0"],
[data-theme="light"] [style*="background: rgba(0,0,0"],
[data-theme="light"] [style*="background:rgba(0, 0, 0"],
[data-theme="light"] [style*="background: rgba(0, 0, 0"] {
  background:#ffffff !important;
  color:#172033 !important;
}
[data-theme="light"] [style*="color:#c4b5fd"],
[data-theme="light"] [style*="color: #c4b5fd"],
[data-theme="light"] [style*="color:#ddd6fe"],
[data-theme="light"] [style*="color: #ddd6fe"],
[data-theme="light"] [style*="color:#e9d5ff"],
[data-theme="light"] [style*="color: #e9d5ff"] {
  color:#6d28d9 !important;
}
[data-theme="light"] [style*="color:#86efac"],
[data-theme="light"] [style*="color: #86efac"],
[data-theme="light"] [style*="color:#4ade80"],
[data-theme="light"] [style*="color: #4ade80"] {
  color:#15803d !important;
}
[data-theme="light"] [style*="color:#fca5a5"],
[data-theme="light"] [style*="color: #fca5a5"],
[data-theme="light"] [style*="color:#f87171"],
[data-theme="light"] [style*="color: #f87171"] {
  color:#b91c1c !important;
}

/* Global readable links / helper text in Light mode. */
[data-theme="light"] .content a:not(.btn),
[data-theme="light"] .content a:not(.btn):visited {
  color:#6d28d9 !important;
}
[data-theme="light"] .content a:not(.btn):hover { color:#4c1d95 !important; }
[data-theme="light"] .field-hint,
[data-theme="light"] .hint,
[data-theme="light"] .ua-line,
[data-theme="light"] .user-detail-line,
[data-theme="light"] .meta,
[data-theme="light"] .muted,
[data-theme="light"] small { opacity:1 !important; }

/* Admin informational bars / alerts. */
[data-theme="light"] .info-bar,
[data-theme="light"] .recovery-note,
[data-theme="light"] .warning-note,
[data-theme="light"] .danger-note {
  color:#334155 !important;
  background:#f8fafc !important;
  border-color:#d9e0ea !important;
}
[data-theme="light"] .info-bar strong,
[data-theme="light"] .info-bar a,
[data-theme="light"] .recovery-note strong { color:#4c1d95 !important; }
[data-theme="light"] .info-bar p,
[data-theme="light"] .info-bar span,
[data-theme="light"] .recovery-note p,
[data-theme="light"] .recovery-note li { color:#334155 !important; opacity:1 !important; }
[data-theme="light"] .alert-success { color:#166534 !important; background:#f0fdf4 !important; border-color:#bbf7d0 !important; }
[data-theme="light"] .alert-error { color:#991b1b !important; background:#fef2f2 !important; border-color:#fecaca !important; }
[data-theme="light"] .alert-info { color:#5b21b6 !important; background:#f5f3ff !important; border-color:#ddd6fe !important; }

/* Online Users: remove dark card background and make status readable. */
[data-theme="light"] .online-card {
  background:#ffffff !important;
  color:#172033 !important;
  border-color:#d9e0ea !important;
  box-shadow:0 6px 18px rgba(15,23,42,.055) !important;
}
[data-theme="light"] .online-card h3,
[data-theme="light"] .online-card .meta-item div { color:#172033 !important; }
[data-theme="light"] .online-card .meta-item label,
[data-theme="light"] .online-card .ua-line { color:#64748b !important; }
[data-theme="light"] .badge-online,
[data-theme="light"] .online-flag,
[data-theme="light"] .pm-on {
  color:#15803d !important;
  background:#f0fdf4 !important;
  border-color:#86efac !important;
}
[data-theme="light"] .offline-flag,
[data-theme="light"] .pm-off { color:#64748b !important; }

/* Special Users status cells. */
[data-theme="light"] .special-users-table td,
[data-theme="light"] .special-users-table th { color:#334155 !important; }
[data-theme="light"] .special-users-table td[data-label="Direct"] span,
[data-theme="light"] .special-users-table td[data-label="Status"] span { font-weight:700 !important; }

/* Backup / Recovery code and requirement text. */
[data-theme="light"] code,
[data-theme="light"] pre,
[data-theme="light"] .mono {
  color:#334155 !important;
}
[data-theme="light"] code {
  background:#f1f5f9 !important;
  border:1px solid #e2e8f0 !important;
  border-radius:4px;
  padding:1px 4px;
}
[data-theme="light"] pre {
  background:#f8fafc !important;
  border:1px solid #d9e0ea !important;
}

/* App Updates / Settings helper text and version/status values. */
[data-theme="light"] .content .value[style*="color"],
[data-theme="light"] .content strong[style*="color"] { opacity:1 !important; }
[data-theme="light"] .content [style*="color:#fbbf24"],
[data-theme="light"] .content [style*="color: #fbbf24"] { color:#a16207 !important; }

/* File cards: clean white surface in Light mode. */
[data-theme="light"] .files-root,
[data-theme="light"] .file-grid,
[data-theme="light"] .files-grid,
[data-theme="light"] .file-item,
[data-theme="light"] .rec-item,
[data-theme="light"] .doc-row {
  color:#172033 !important;
}
[data-theme="light"] .file-item,
[data-theme="light"] .rec-item,
[data-theme="light"] .doc-row {
  background:#ffffff !important;
  border-color:#d9e0ea !important;
  box-shadow:0 3px 12px rgba(15,23,42,.035) !important;
}
[data-theme="light"] .file-item:hover,
[data-theme="light"] .rec-item:hover,
[data-theme="light"] .doc-row:hover {
  background:#faf8ff !important;
  border-color:#c4b5fd !important;
}
[data-theme="light"] .file-item .name,
[data-theme="light"] .rec-item [style*="font-weight:600"] { color:#172033 !important; }
[data-theme="light"] .file-item .meta,
[data-theme="light"] .rec-item [style*="color:var(--muted)"] { color:#64748b !important; opacity:1 !important; }

/* File selection checkbox: never sit on top of the filename. */
[data-theme="light"] .file-grid[data-view="grid"] .file-item > label,
[data-theme="light"] #filesGrid[data-view="grid"] .file-item > label,
[data-theme="light"] .files-grid[data-view="grid"] .file-item > label {
  position:absolute !important;
  top:8px !important;
  left:auto !important;
  right:8px !important;
  z-index:3 !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  width:24px !important;
  height:24px !important;
  margin:0 !important;
  padding:0 !important;
  background:rgba(255,255,255,.96) !important;
  border:1px solid #cbd5e1 !important;
  border-radius:6px !important;
  box-shadow:0 2px 6px rgba(15,23,42,.10) !important;
}
[data-theme="light"] .file-grid[data-view="grid"] .file-item > label input[type="checkbox"],
[data-theme="light"] #filesGrid[data-view="grid"] .file-item > label input[type="checkbox"],
[data-theme="light"] .files-grid[data-view="grid"] .file-item > label input[type="checkbox"] {
  position:static !important;
  width:16px !important;
  height:16px !important;
  margin:0 !important;
  accent-color:#7c3aed !important;
}
[data-theme="light"] .file-grid[data-view="grid"] .file-item .name,
[data-theme="light"] #filesGrid[data-view="grid"] .file-item .name,
[data-theme="light"] .files-grid[data-view="grid"] .file-item .name {
  padding-right:30px !important;
  text-align:left !important;
}
/* List view keeps the checkbox in normal document flow. */
[data-theme="light"] .file-grid[data-view="list"] .file-item > label,
[data-theme="light"] #filesGrid[data-view="list"] .file-item > label,
[data-theme="light"] .files-grid[data-view="list"] .file-item > label {
  position:static !important;
  width:auto !important;
  height:auto !important;
  padding:0 !important;
  margin:0 !important;
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
}

/* Audio / Video / Image / Document toolbar and selection controls. */
[data-theme="light"] .file-toolbar,
[data-theme="light"] .pv-toolbar,
[data-theme="light"] .file-toolbar .btn,
[data-theme="light"] .pv-toolbar .btn {
  color:#334155 !important;
}
[data-theme="light"] .file-toolbar input,
[data-theme="light"] .pv-toolbar input,
[data-theme="light"] .file-toolbar select,
[data-theme="light"] .pv-toolbar select {
  color:#172033 !important;
  background:#ffffff !important;
  border-color:#cbd5e1 !important;
}

/* Voice recordings: replace the dark legacy cards. */
[data-theme="light"] .rec-list .rec-item {
  background:#ffffff !important;
  color:#172033 !important;
  border-color:#d9e0ea !important;
}
[data-theme="light"] .rec-item input[type="range"] { accent-color:#7c3aed !important; }
[data-theme="light"] .rec-item .btn:disabled {
  color:#94a3b8 !important;
  background:#f8fafc !important;
  border-color:#d9e0ea !important;
}

/* Rich editors on Stotra / Devotional Info: light surface and readable toolbar. */
[data-theme="light"] .pv-rich-wrap,
[data-theme="light"] .wp-editor-wrap,
[data-theme="light"] .tox-tinymce,
[data-theme="light"] .mce-container,
[data-theme="light"] .mce-panel {
  background:#ffffff !important;
  border-color:#cbd5e1 !important;
}
[data-theme="light"] .pv-rich-toolbar,
[data-theme="light"] .wp-toolbar,
[data-theme="light"] .mce-toolbar-grp,
[data-theme="light"] .tox-editor-header {
  background:#f8fafc !important;
  border-color:#d9e0ea !important;
}
[data-theme="light"] .pv-rich-toolbar button,
[data-theme="light"] .pv-rich-toolbar select,
[data-theme="light"] .wp-toolbar button,
[data-theme="light"] .mce-toolbar button,
[data-theme="light"] .tox-tbtn {
  color:#334155 !important;
}
[data-theme="light"] .pv-rich-wrap textarea,
[data-theme="light"] .wp-editor-area,
[data-theme="light"] .tox-edit-area__iframe {
  background:#ffffff !important;
  color:#172033 !important;
}

/* Generic admin form controls with legacy dark inline backgrounds. */
[data-theme="light"] .content input,
[data-theme="light"] .content select,
[data-theme="light"] .content textarea {
  color:#172033 !important;
}
[data-theme="light"] .content input::placeholder,
[data-theme="light"] .content textarea::placeholder { color:#64748b !important; opacity:1 !important; }

/* ===== v5.1.112 — Mobile table contrast (black-on-black fix) ===== */
/* Dark theme: ensure table text is always readable */
[data-theme="dark"] table,
:root table,
[data-theme="dark"] .table-wrap,
:root .table-wrap {
  color: var(--text, #f4f4f7);
}
[data-theme="dark"] table th,
:root table th,
[data-theme="dark"] table thead th,
:root table thead th {
  color: var(--text, #f4f4f7) !important;
  background: var(--bg-elevated, #111118) !important;
  border-color: var(--border, rgba(255,255,255,.1)) !important;
}
[data-theme="dark"] table td,
:root table td {
  color: var(--text, #f4f4f7) !important;
  background: var(--card, #16161f) !important;
  border-color: var(--border, rgba(255,255,255,.08)) !important;
}
[data-theme="dark"] table tr:nth-child(even) td,
:root table tr:nth-child(even) td {
  background: rgba(255,255,255,.03) !important;
}
[data-theme="dark"] table tr:hover td,
:root table tr:hover td {
  background: rgba(124,58,237,.12) !important;
}

/* Light theme reinforcement for mobile tables */
[data-theme="light"] table,
[data-theme="light"] .table-wrap,
[data-theme="light"] .japa-counter-hist-table {
  color: #111827 !important;
}
[data-theme="light"] table th,
[data-theme="light"] table thead th,
[data-theme="light"] .japa-counter-hist-table th {
  color: #334155 !important;
  background: #f1f5f9 !important;
}
[data-theme="light"] table td,
[data-theme="light"] .japa-counter-hist-table td {
  color: #1f2937 !important;
  background: #ffffff !important;
}
[data-theme="light"] table tr:nth-child(even) td {
  background: #f8fafc !important;
}

/* Kill hard-coded near-black text on dark surfaces (mobile Safari/WebView) */
@media (max-width: 900px) {
  [data-theme="dark"] td,
  [data-theme="dark"] th,
  :root:not([data-theme="light"]) td,
  :root:not([data-theme="light"]) th {
    color: #f4f4f7 !important;
  }
  [data-theme="dark"] td[style*="color"],
  [data-theme="dark"] th[style*="color"],
  :root:not([data-theme="light"]) td[style*="color:#"],
  :root:not([data-theme="light"]) th[style*="color:#"] {
    color: #f4f4f7 !important;
  }
  /* Common admin/list tables */
  [data-theme="dark"] .compact td,
  [data-theme="dark"] .data-table td,
  [data-theme="dark"] .list-table td,
  [data-theme="dark"] .dash-recent td {
    color: #f4f4f7 !important;
    background: transparent !important;
  }
}

/* Japa history table explicit contrast */
.japa-counter-hist-table th { color: var(--muted) !important; }
.japa-counter-hist-table td { color: var(--text) !important; }
[data-theme="light"] .japa-counter-hist-table th { color: #64748b !important; }
[data-theme="light"] .japa-counter-hist-table td { color: #1f2937 !important; }

/* ===== v5.1.112 — Visited/active button text always visible ===== */
/* Later global a:visited rules were forcing purple text onto purple tabs. */
[data-theme="light"] .japa-counter-tabs a.active,
[data-theme="light"] .japa-counter-tabs a.active:link,
[data-theme="light"] .japa-counter-tabs a.active:visited,
[data-theme="light"] .japa-counter-tabs a.active:hover,
[data-theme="light"] .japa-counter-tabs a.active:focus,
[data-theme="light"] .japa-counter-tabs button.active {
  color: #ffffff !important;
  background: #7c3aed !important;
  border-color: transparent !important;
}

[data-theme="light"] .btn-primary,
[data-theme="light"] .btn-primary:link,
[data-theme="light"] .btn-primary:visited,
[data-theme="light"] .btn-primary:hover,
[data-theme="light"] .btn-primary:focus,
[data-theme="light"] a.btn-primary,
[data-theme="light"] a.btn-primary:visited {
  color: #ffffff !important;
}

/* Ghost/secondary pills stay dark text even when visited */
[data-theme="light"] .btn-ghost,
[data-theme="light"] .btn-ghost:visited,
[data-theme="light"] a.btn-ghost,
[data-theme="light"] a.btn-ghost:visited,
[data-theme="light"] .japa-counter-tabs a:not(.active),
[data-theme="light"] .japa-counter-tabs a:not(.active):visited {
  color: #334155 !important;
}

/* Dark mode: active tab stays white */
[data-theme="dark"] .japa-counter-tabs a.active,
[data-theme="dark"] .japa-counter-tabs a.active:visited,
:root:not([data-theme="light"]) .japa-counter-tabs a.active,
:root:not([data-theme="light"]) .japa-counter-tabs a.active:visited {
  color: #ffffff !important;
}

/* Mantra player tabs / similar pill links */
[data-theme="light"] .mantra-player-tabs a.btn-primary,
[data-theme="light"] .mantra-player-tabs a.btn-primary:visited,
[data-theme="light"] .content a.btn.btn-primary:visited {
  color: #ffffff !important;
}

/* =====================================================================
   v5.1.112-final — Universal button / tab / link contrast
   Covers: light + dark · desktop + tablet + mobile · :link :visited :hover :active :focus
   ===================================================================== */

/* --- Primary (purple) — always white label --- */
.btn-primary,
.btn-primary:link,
.btn-primary:visited,
.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus,
.btn-primary:focus-visible,
a.btn-primary,
a.btn-primary:link,
a.btn-primary:visited,
a.btn-primary:hover,
a.btn-primary:active,
button.btn-primary {
  color: #ffffff !important;
}

/* --- Ghost / secondary --- */
[data-theme="light"] .btn-ghost,
[data-theme="light"] .btn-ghost:link,
[data-theme="light"] .btn-ghost:visited,
[data-theme="light"] .btn-ghost:hover,
[data-theme="light"] .btn-ghost:active,
[data-theme="light"] a.btn-ghost,
[data-theme="light"] a.btn-ghost:visited,
[data-theme="light"] button.btn-ghost {
  color: #334155 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .btn-ghost:hover,
[data-theme="light"] a.btn-ghost:hover {
  color: #1e293b !important;
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
}
[data-theme="dark"] .btn-ghost,
[data-theme="dark"] .btn-ghost:visited,
[data-theme="dark"] a.btn-ghost,
[data-theme="dark"] a.btn-ghost:visited,
:root:not([data-theme="light"]) .btn-ghost,
:root:not([data-theme="light"]) .btn-ghost:visited,
:root:not([data-theme="light"]) a.btn-ghost:visited {
  color: var(--text, #f4f4f7) !important;
}

/* --- Danger --- */
[data-theme="light"] .btn-danger,
[data-theme="light"] .btn-danger:visited,
[data-theme="light"] a.btn-danger:visited {
  color: #b91c1c !important;
  background: #fef2f2 !important;
  border-color: #fecaca !important;
}
[data-theme="dark"] .btn-danger,
[data-theme="dark"] .btn-danger:visited,
:root:not([data-theme="light"]) .btn-danger {
  color: #fecaca !important;
}

/* --- Generic .btn (not primary/ghost/danger) --- */
[data-theme="light"] .btn:not(.btn-primary):not(.btn-danger),
[data-theme="light"] .btn:not(.btn-primary):not(.btn-danger):visited,
[data-theme="light"] a.btn:not(.btn-primary):not(.btn-danger):visited {
  color: #334155 !important;
}
[data-theme="dark"] .btn:not(.btn-primary):not(.btn-danger),
[data-theme="dark"] .btn:not(.btn-primary):not(.btn-danger):visited,
:root:not([data-theme="light"]) .btn:not(.btn-primary):not(.btn-danger):visited {
  color: var(--text, #f4f4f7) !important;
}

/* --- Pill / tab strips (Japa, Mantra, Stotra, etc.) --- */
.japa-counter-tabs a.active,
.japa-counter-tabs a.active:link,
.japa-counter-tabs a.active:visited,
.japa-counter-tabs a.active:hover,
.japa-counter-tabs a.active:focus,
.japa-counter-tabs button.active,
.mantra-player-tabs a.btn-primary,
.mantra-player-tabs a.btn-primary:visited,
.mantra-player-tabs .btn-primary.active,
.japa-counter-seg-btn.active,
.lang-tabs .btn.active,
.lang-tabs a.btn-primary,
.messages-folder-tabs .btn-primary,
.messages-folder-tabs .btn.btn-primary {
  color: #ffffff !important;
}

[data-theme="light"] .japa-counter-tabs a:not(.active),
[data-theme="light"] .japa-counter-tabs a:not(.active):visited,
[data-theme="light"] .japa-counter-tabs button:not(.active) {
  color: #334155 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

[data-theme="dark"] .japa-counter-tabs a:not(.active),
[data-theme="dark"] .japa-counter-tabs a:not(.active):visited,
:root:not([data-theme="light"]) .japa-counter-tabs a:not(.active):visited {
  color: var(--text, #f4f4f7) !important;
}

/* --- Sidebar nav --- */
[data-theme="light"] .sidebar .nav-item,
[data-theme="light"] .sidebar .nav-item:visited {
  color: #334155 !important;
}
[data-theme="light"] .sidebar .nav-item.active,
[data-theme="light"] .sidebar .nav-item.active:visited {
  color: #4c1d95 !important;
}
[data-theme="dark"] .sidebar .nav-item,
[data-theme="dark"] .sidebar .nav-item:visited,
:root:not([data-theme="light"]) .sidebar .nav-item:visited {
  color: var(--text, #f4f4f7) !important;
}

/* --- Native <button> without .btn (forms, toolbars) --- */
[data-theme="light"] button:not(.btn-primary):not(.theme-toggle-btn):not(.japa-counter-btn-plus):not(.med-play-btn):not(#mantra-playerPlayPause) {
  color: #334155;
}
[data-theme="dark"] button:not(.btn-primary):not(.japa-counter-btn-plus):not(.med-play-btn):not(#mantra-playerPlayPause),
:root:not([data-theme="light"]) button:not(.btn-primary):not(.japa-counter-btn-plus):not(.med-play-btn):not(#mantra-playerPlayPause) {
  color: var(--text, #f4f4f7);
}

/* Keep dedicated white labels on round/play accents */
.japa-counter-btn-plus,
.med-play-btn,
#mantra-playerPlayPause,
.mantra-player-controls .play-btn {
  color: #ffffff !important;
}

/* --- Content links (not buttons) --- */
[data-theme="light"] .content a:not(.btn):not(.nav-item):not(.japa-counter-tabs a),
[data-theme="light"] .content a:not(.btn):not(.nav-item):not(.japa-counter-tabs a):visited {
  color: #6d28d9 !important;
}
[data-theme="light"] .content a:not(.btn):not(.nav-item):not(.japa-counter-tabs a):hover {
  color: #4c1d95 !important;
}

/* --- Mobile / tablet touch targets & contrast (all themes) --- */
@media (max-width: 900px) {
  .btn,
  .btn-primary,
  .btn-ghost,
  .btn-danger,
  a.btn {
    min-height: 40px;
  }
  .japa-counter-tabs a,
  .japa-counter-tabs button,
  .mantra-player-tabs a.btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
}
@media (max-width: 640px) {
  .btn,
  a.btn {
    min-height: 44px;
  }
  /* Re-assert primary white on small screens after any mobile overrides */
  .btn-primary,
  .btn-primary:visited,
  a.btn-primary:visited,
  .japa-counter-tabs a.active,
  .japa-counter-tabs a.active:visited {
    color: #ffffff !important;
  }
}

/* ===== v5.1.112 — Theme toggle + primary + chips + reply ===== */

/* Theme toggle always readable (icon + label) */
.theme-toggle-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-height: 40px !important;
  padding: 8px 12px !important;
  border-radius: 999px !important;
  border: 1px solid var(--border, rgba(255,255,255,.12)) !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  opacity: 1 !important;
}
.theme-toggle-btn .theme-toggle-icon {
  font-size: 16px !important;
  line-height: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}
.theme-toggle-btn .theme-toggle-label {
  opacity: 1 !important;
  white-space: nowrap !important;
}
[data-theme="dark"] .theme-toggle-btn,
:root:not([data-theme="light"]) .theme-toggle-btn {
  background: rgba(255,255,255,0.08) !important;
  color: #f4f4f7 !important;
  border-color: rgba(255,255,255,0.16) !important;
}
[data-theme="dark"] .theme-toggle-btn .theme-toggle-label,
[data-theme="dark"] .theme-toggle-btn .theme-toggle-icon,
:root:not([data-theme="light"]) .theme-toggle-btn .theme-toggle-label,
:root:not([data-theme="light"]) .theme-toggle-btn .theme-toggle-icon {
  color: #f4f4f7 !important;
}
[data-theme="light"] .theme-toggle-btn {
  background: #ffffff !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .theme-toggle-btn .theme-toggle-label,
[data-theme="light"] .theme-toggle-btn .theme-toggle-icon {
  color: #334155 !important;
}

/* Primary buttons: never black text on purple */
.btn-primary,
.btn-primary:link,
.btn-primary:visited,
.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus,
a.btn-primary,
a.btn-primary:visited,
button.btn-primary,
.file-actions .btn-primary,
.file-actions a.btn-primary,
.file-item .btn-primary {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* Light mode chips (read receipts) */
[data-theme="light"] .chip-on {
  background: #dcfce7 !important;
  color: #166534 !important;
  border: 1px solid #86efac !important;
  font-weight: 650 !important;
}
[data-theme="dark"] .chip-on,
:root:not([data-theme="light"]) .chip-on {
  background: rgba(34,197,94,0.2) !important;
  color: #86efac !important;
}

/* Notification panel — light/dark safe */
.notif-panel {
  background: var(--surface, rgba(20,20,35,0.98));
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  color: var(--text, #f5f3ff);
}
[data-theme="light"] .notif-panel {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 10px 28px rgba(15,23,42,0.12) !important;
  color: #0f172a !important;
}
[data-theme="light"] .notif-panel strong { color: #4c1d95 !important; }
[data-theme="light"] .notif-panel .btn-ghost {
  color: #334155 !important;
  border-color: #cbd5e1 !important;
  background: #f8fafc !important;
}
/* Prevent raw code / escaped HTML leaking near topbar */
.topbar .notif-wrap script { display: none !important; }


/* ===== v5.1.112 UX polish ===== */
/* Notification drawer — light mode readable */
[data-theme="light"] .notif-panel {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #1e1b4b !important;
  box-shadow: 0 12px 32px rgba(15,23,42,.14) !important;
}
[data-theme="light"] .notif-panel strong { color: #4c1d95 !important; }
[data-theme="light"] .notif-panel .btn-ghost {
  color: #334155 !important;
  border-color: #cbd5e1 !important;
  background: #f8fafc !important;
}

/* Kill accidental green body/meta text in messages light mode */
[data-theme="light"] .msg-row a,
[data-theme="light"] .inbox-item a,
[data-theme="light"] .preview a {
  color: #6d28d9 !important;
}
[data-theme="light"] .chip-on {
  background: #6d28d9 !important;
  color: #ffffff !important;
}
/* "Opened …" meta should not be green */
[data-theme="light"] .msg-meta,
[data-theme="light"] .inbox-item .meta,
[data-theme="light"] .preview {
  color: #64748b !important;
}
[data-theme="dark"] .chip-on {
  background: #7c3aed !important;
  color: #fff !important;
}
/* Keep online green only for status dots */
.status-online, .online-dot, .presence-online { color: #22c55e !important; }

/* Chat send button */
.chat-send-btn,
button.chat-send,
.composer-send,
#msgSendBtn,
.msg-send-btn {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 14px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 8px 20px rgba(109,40,217,.35) !important;
}
.chat-send-btn:hover,
.composer-send:hover {
  filter: brightness(1.08);
}


/* Message status badges */
.msg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.msg-badge-new {
  background: #6d28d9;
  color: #fff !important;
}
.msg-badge-opened {
  background: #e0e7ff;
  color: #3730a3 !important;
}
[data-theme="dark"] .msg-badge-opened {
  background: rgba(99,102,241,.25);
  color: #c7d2fe !important;
}
.msg-badge-read, .msg-badge-sent {
  background: #f1f5f9;
  color: #475569 !important;
}
[data-theme="dark"] .msg-badge-read,
[data-theme="dark"] .msg-badge-sent {
  background: rgba(148,163,184,.15);
  color: #cbd5e1 !important;
}
.msg-status-new { color: #6d28d9; font-weight: 700; }
.msg-status-opened { color: #4f46e5; font-weight: 600; }
.msg-status-delivered { color: #64748b; }

/* Notification panel always readable */
.notif-panel {
  background: #ffffff !important;
  color: #1e1b4b !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 16px 40px rgba(15,23,42,.18) !important;
}
[data-theme="dark"] .notif-panel {
  background: #16161e !important;
  color: #f5f3ff !important;
  border: 1px solid rgba(255,255,255,.12) !important;
}
.notif-panel strong { color: inherit !important; }


/* Messages ⋯ menu — light mode contrast */
[data-theme="light"] .chat-msg-menu-sheet,
[data-theme="light"] .chat-msg-menu-sheet button {
  color: #0f172a !important;
}
[data-theme="light"] .chat-msg-menu-sheet {
  background: #fff !important;
}
[data-theme="light"] .dropdown-menu a,
[data-theme="light"] .dropdown-menu button,
[data-theme="light"] .popover a,
[data-theme="light"] .popover button {
  color: #0f172a !important;
}

/* Prefer full-width content on large screens */
.content, .main-content, .page-content {
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
