/* Enhanced App Styles - Extracted from public/app/index.html */

/* Base Theme & Body */
html {
  background-color: #111827;
  /* Dark Theme Base */
  overscroll-behavior: none;
}

html.light-mode {
  background-color: #EFF1F5;
  /* Light Theme Base */
}

body {
  background: linear-gradient(135deg, #111827 0%, #0f1419 50%, #111827 100%);
  color: #e5e7eb;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  letter-spacing: 0.02em;
  overscroll-behavior: none;
}

/* Custom Utilities for Dark Mode Depth */
.bg-gray-850 {
  background-color: #161e2e;
  /* Darker than 800 (#1f2937) */
}

.bg-gray-750 {
  background-color: #2d3748;
  /* Lighter than 800, darker than 700 (#374151) */
}

/* User Profile Header - Custom class to avoid global light-mode resets */
.user-profile-header {
  background-color: #161e2e;
  /* Match bg-gray-850 */
}

body.light-mode .user-profile-header {
  background-color: #F3F4F6 !important;
  /* Light Gray for contrast */
  border: none !important;
  /* Override global border rules */
  color: #111827 !important;
  /* Ensure text is dark */
}

/* Dictation Tips Legibility */
.tip-msg {
  color: #E2E8F0;
  /* Slate 200 - Bright for Dark Mode */
}

.tip-footer {
  color: #94A3B8;
  /* Slate 400 - Muted for Dark Mode */
}

body.light-mode .tip-msg {
  color: #1F2937 !important;
  /* Gray 800 for Light Mode */
}

body.light-mode .tip-footer {
  color: #6B7280 !important;
  /* Gray 500 for Light Mode */
}

/* Tips in Report Preview — override parent opacity */
#recording-tip {
  opacity: 1 !important;
}

#recording-tip #tip-content {
  color: #cbd5e1; /* slate-300 for dark mode */
}

#recording-tip #tip-content i {
  color: rgba(96, 165, 250, 0.8); /* blue-400/80 for dark mode */
}

/* Light mode: teal/green theme colors for tips */
body.light-mode #recording-tip #tip-content {
  color: #0f766e !important; /* teal-700 */
}

body.light-mode #recording-tip #tip-content i {
  color: #0d9488 !important; /* teal-600 */
}

/* Ensure empty state text is visible in light mode */
body.light-mode #report-empty-state {
  opacity: 0.7 !important;
}

body.light-mode #report-empty-state p {
  color: #4b5563 !important; /* gray-600 */
}

.app-container {
  min-height: calc(100vh - 4rem);
  max-width: 2200px;
}

/* Cap the nav inner wrapper to match the app container */
.nav-dark > div {
  max-width: 2200px;
  margin-left: auto;
  margin-right: auto;
}

/* 4-column report grid on wide screens (≥1536px) */
@media (min-width: 1536px) {
  #reports-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Enhanced Navigation */
.nav-dark {
  background: rgba(31, 41, 55, 0.95) !important;
  backdrop-filter: blur(20px);
  border-bottom: none !important;
  box-shadow: 0 1px 0 rgba(96, 165, 250, 0.1) !important;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile auto-hide navbar on scroll */
@media (max-width: 768px) {
  .nav-dark.nav-collapsed {
    transform: translateY(-100%);
  }
}

/* Glassmorphism Cards */
.glass-card {
  background: rgba(31, 41, 55, 0.7);
  backdrop-filter: blur(20px);
  border: none !important;
  box-shadow: none !important;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: none !important;
}

/* Enhanced Sections */
section>div {
  background: rgba(31, 41, 55, 0.8) !important;
  backdrop-filter: blur(20px);
  border: none !important;
  box-shadow: none !important;
  transition: all 0.3s ease;
}

/* Audio recorder styling */
.recorder-container {
  background: rgba(31, 41, 55, 0.8) !important;
  backdrop-filter: blur(20px);
  border: none !important;
  box-shadow: none !important;
  border-radius: 1rem !important;
  transition: all 0.3s ease;
}

.record-button {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  color: white;
  height: 60px;
  width: 60px;
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.record-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

.record-button.recording {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  animation: pulse 1.5s infinite;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

/* Continue recording button styling */
.continue-record-button {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  color: white;
  height: 60px;
  width: 60px;
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.continue-record-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.continue-record-button.recording {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  animation: pulse 1.5s infinite;
}

/* Type directly button styling */
.type-directly-button {
  background: linear-gradient(135deg, #4f46e5, #3730a3) !important;
  color: white;
  height: 60px;
  width: 60px;
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.type-directly-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
}

/* Button container styling */
.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.button-label {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  text-align: center;
  color: #d1d5db;
  width: 7rem;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* Visualizer */
.visualizer-container {
  background: rgba(17, 24, 39, 0.8) !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: blur(10px);
  border-radius: 0.75rem !important;
  transition: all 0.3s ease;
  height: 40px !important;
  /* Make visualizer smaller */
  opacity: 0.8;
  /* Make it slightly subtle */
}

/* Format selector */
.format-selector {
  background: rgba(31, 41, 55, 0.8) !important;
  backdrop-filter: blur(15px);
  border: none !important;
  box-shadow: none !important;
  border-radius: 1rem !important;
  transition: all 0.3s ease;
}

#generate-container {
  position: relative;
  z-index: 50;
  margin-top: 1.5rem;
  clear: both;
}

.format-selector:hover {
  transform: translateY(-2px);
  box-shadow: none !important;
}

/* Transcription area */
.transcription-area {
  background: transparent !important;
  backdrop-filter: none;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  transition: all 0.3s ease;
}

/* Textarea inside transcription area — resizable with scroll */
.transcription-area textarea {
  resize: vertical !important;
  overflow-y: auto !important;
  min-height: 120px;
  max-height: calc(100vh - 22rem);
}

/* Report area */
.report-container {
  background: rgba(31, 41, 55, 0.8) !important;
  backdrop-filter: blur(20px);
  border: none !important;
  box-shadow: none !important;
  border-radius: 1rem !important;
}

/* Modern Loading Animations */
.loading-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  width: 60px;
}

/* Dot Pulse Animation */
.dot-pulse {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: #3b82f6;
  animation: dotPulse 1.5s infinite ease-in-out;
}

.dot-pulse__dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #3b82f6;
  animation: dotPulseDot 1.5s infinite ease-in-out;
}

.dot-pulse:before,
.dot-pulse:after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: #3b82f6;
  opacity: 0.7;
}

.dot-pulse:before {
  left: -20px;
  animation: dotPulseBefore 1.5s infinite ease-in-out;
}

.dot-pulse:after {
  right: -20px;
  animation: dotPulseAfter 1.5s infinite ease-in-out;
}

@keyframes dotPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes dotPulseBefore {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.3);
    opacity: 0.5;
  }

  100% {
    transform: scale(1);
  }
}

@keyframes dotPulseDot {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.8);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes dotPulseAfter {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.3);
    opacity: 0.5;
  }

  100% {
    transform: scale(1);
  }
}

/* Text Fade Animation */
@keyframes textFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes textFadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Report editor */
.editor-container {
  background: rgba(31, 41, 55, 0.8) !important;
  backdrop-filter: blur(20px);
  border: none !important;
  box-shadow: none !important;
  border-radius: 1rem !important;
}

/* Enhanced Buttons */
button {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  border-radius: 0.75rem !important;
  font-weight: 600;
  letter-spacing: 0.025em;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Enhanced Form Elements */
select,
input[type="text"],
input[type="email"],
textarea {
  background: rgba(55, 65, 81, 0.8) !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease !important;
  border-radius: 0.75rem !important;
}

select:focus,
input:focus,
textarea:focus {
  box-shadow: none !important;
  outline: none !important;
  background: rgba(55, 65, 81, 0.9) !important;
}

/* Enhanced Typography */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h1,
h2 {
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Loading Enhancement */
.spinner {
  border-color: rgba(96, 165, 250, 0.2) !important;
  border-top-color: #60a5fa !important;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.5));
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(31, 41, 55, 0.3);
}

::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(96, 165, 250, 0.7);
}

/* Scroll Animations */
.scroll-fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Ripple Effect */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Moderately compact report cards */
.prose-sm {
  font-size: 0.85rem;
  line-height: 1.4rem;
}

.prose-sm p {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.prose-sm li {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Report card animations */
@keyframes flyIn {
  0% {
    opacity: 0;
    transform: translate(-50px, -50px) scale(0.8);
  }

  70% {
    transform: translate(5px, 5px) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

.animate-fly-in {
  animation: none;
  /* Don't run animation by default */
  opacity: 1;
  /* Start visible */
}

/* Class to trigger the animation */
.run-animation .animate-fly-in {
  animation: flyIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
  will-change: transform, opacity;
}

/* Format name badge in preview heading */
.format-name-badge {
  display: block;
  width: fit-content;
  margin: 6px auto 0;
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #93c5fd; /* blue-300 */
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 6px;
  padding: 3px 10px;
}

body.light-mode .format-name-badge {
  color: #1d4ed8; /* blue-700 */
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(37, 99, 235, 0.2);
}

/* Global border override to remove ANY borders or outlines */
.bg-gray-800,
.bg-gray-700,
.bg-gray-900,
section,
div[class*="bg-gray"],
.border,
.border-gray-600,
.border-gray-700,
[class*="border"],
button,
input,
select,
textarea,
.glass-card,
section>div,
.recorder-container,
.visualizer-container,
.format-selector,
.transcription-area,
.report-container,
.editor-container {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Completely borderless - no shadows, no outlines anywhere */
* {
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
}

/* Only preserve essential record button styling */
.record-button,
.continue-record-button {
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3) !important;
}

.record-button:hover,
.continue-record-button:hover {
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4) !important;
}

.record-button.recording {
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3) !important;
}

/* Force dropdown to be on top of everything */
#format-dropdown {
  position: absolute !important;
  z-index: 9999 !important;
  background: #374151 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Ensure the format selector container creates proper stacking context */
#format-selector-container {
  position: relative !important;
  z-index: 9999 !important;
}

/* =========================================
   LIGHT MODE OVERRIDES
   ========================================= */

body.light-mode {
  background: #EFF1F5 !important;
  /* Level 0: Cool Gray Background */
  color: #2B2B2B !important;
}

/* Navigation - Light Mode */
body.light-mode .nav-dark {
  background: rgba(255, 255, 255, 0.95) !important;
  border-bottom: 1px solid #D4D4D4 !important;
  box-shadow: none !important;
}

body.light-mode .nav-dark a,
body.light-mode .nav-dark button:not(.bg-blue-600) {
  color: #2B2B2B !important;
}

body.light-mode .nav-dark a:hover,
body.light-mode .nav-dark button:hover:not(.bg-blue-600) {
  color: #319795 !important;
}

/* Headings - Light Mode */
body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4,
body.light-mode strong {
  background: none !important;
  -webkit-text-fill-color: initial !important;
  color: #2B2B2B !important;
}

body.light-mode p.text-gray-400 {
  color: #B3B3B3 !important;
}

/* Cards & Containers - Light Mode */
/* Level 1: Main Containers (Off-White) */
body.light-mode section>div,
body.light-mode .recorder-container,
body.light-mode .report-container {
  background: #F8F9FA !important;
  /* Off-White/Light Gray Container */
  border: 1px solid #E2E8F0 !important;
  box-shadow: none !important;
}

/* Explicitly remove container styling from Reports Section to avoid double-boxing */
body.light-mode #reports-section,
body.light-mode #reports-section>div,
body.light-mode #reports-list {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Level 2: Modals */
body.light-mode #macro-manager-content,
body.light-mode #template-manager-modal .bg-gray-800,
body.light-mode #patient-details-modal .bg-gray-800,
body.light-mode #text-import-modal .bg-gray-800,
body.light-mode #export-filename-modal .bg-gray-800 {
  background: #FFFFFF !important;
  /* Pure White Modal Body */
  border: 1px solid #D4D4D4 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
}

/* Modal Headers */
body.light-mode #macro-manager-content .bg-gray-850,
body.light-mode #template-manager-modal .bg-gray-850,
body.light-mode #patient-details-modal .border-b,
body.light-mode #text-import-modal .bg-gray-850,
body.light-mode #export-filename-modal .bg-gray-850 {
  background: #F8F9FA !important;
  /* Off-White Header */
  border-bottom: 1px solid #E5E7EB !important;
}

/* Header Text */
body.light-mode #macro-manager-content h3,
body.light-mode #template-manager-modal h3,
body.light-mode #patient-details-modal h3,
body.light-mode #text-import-modal h3,
body.light-mode #export-filename-modal h3 {
  color: #2B2B2B !important;
}

/* Inner Sections (e.g. Add New Macro) - Level 3 Contrast */
body.light-mode #macro-manager-content .bg-gray-700\/50,
body.light-mode #template-manager-modal .bg-gray-750 {
  background: #F8F9FA !important;
  /* Off-White Container */
  border: 1px solid #E2E8F0 !important;
}

/* Info Boxes */
body.light-mode #macro-manager-content .bg-blue-900\/20,
body.light-mode #template-manager-modal .bg-gray-800\/50 {
  background: #EFF6FF !important;
  /* Light Blue tint */
  border: 1px solid #BFDBFE !important;
}

body.light-mode #macro-manager-content .bg-blue-900\/20 .text-gray-300,
body.light-mode #template-manager-modal .bg-gray-800\/50 .text-gray-300,
body.light-mode #template-manager-modal .bg-gray-800\/50 .text-gray-200,
body.light-mode #template-manager-modal .bg-gray-800\/50 ol {
  color: #4B5563 !important;
}

/* Form Inputs in Modals */
body.light-mode #macro-manager-content input,
body.light-mode #macro-manager-content textarea,
body.light-mode #template-manager-modal input,
body.light-mode #text-import-modal input,
body.light-mode #text-import-modal textarea,
body.light-mode #export-filename-modal input {
  background: #FFFFFF !important;
  border: 1px solid #D1D5DB !important;
  color: #1F2937 !important;
}

body.light-mode #macro-manager-content input:focus,
body.light-mode #template-manager-modal input:focus,
body.light-mode #text-import-modal input:focus,
body.light-mode #text-import-modal textarea:focus,
body.light-mode #export-filename-modal input:focus {
  border-color: #3B82F6 !important;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2) !important;
}

/* Level 2: Cards inside Containers (Pure White) */
body.light-mode .bg-gray-800,
body.light-mode .glass-card,
body.light-mode .format-preview-panel,
body.light-mode .report-results-panel,
body.light-mode .editor-container,
body.light-mode #format-dropdown {
  background: #FFFFFF !important;
  /* Pure White Card */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
  border: 1px solid #D4D4D4 !important;
}

body.light-mode .format-selector {
  background: transparent !important;
  /* Remove off-white box padding wrapper for modern sleek look */
  box-shadow: none !important;
  border: none !important;
}

/* Remove border from My Reports section to fix margin issue */
body.light-mode #reports-section {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.light-mode #reports-section>div:first-child {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Specific fix for Report Cards in the Grid */
body.light-mode #reports-list .bg-gray-700 {
  background: #FFFFFF !important;
  /* Main Card Container */
  border: 1px solid #D4D4D4 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

/* Report Card Header - Add Contrast */
body.light-mode #reports-list .bg-gray-700>div:first-child {
  background: #F8F9FA !important;
  /* Off-White Header */
  border-bottom: 1px solid #E5E7EB !important;
}

body.light-mode #reports-list .bg-gray-700>div:first-child:hover {
  background: #F3F4F6 !important;
  /* Slightly darker on hover */
}

/* Report Card Expandable Body - Pure White */
body.light-mode #reports-list .bg-gray-800 {
  background: #FFFFFF !important;
  color: #2B2B2B !important;
  border-top: 1px solid #E5E7EB !important;
  /* Ensure separation */
}

/* Force text colors inside report cards to be dark */
body.light-mode #reports-list .text-white,
body.light-mode #reports-list .text-gray-200,
body.light-mode #reports-list .text-gray-300,
body.light-mode #reports-list .text-gray-400 {
  color: #2B2B2B !important;
}

body.light-mode #reports-list h3 {
  color: #2B2B2B !important;
}

body.light-mode #format-dropdown {
  background: #FFFFFF !important;
}

/* Inputs - Light Mode */
body.light-mode input,
body.light-mode textarea,
body.light-mode select {
  background: #FFFFFF !important;
  border: 1px solid #D4D4D4 !important;
  color: #2B2B2B !important;
}

body.light-mode input:focus,
body.light-mode textarea:focus,
body.light-mode select:focus {
  border-color: #2B2B2B !important;
  box-shadow: 0 0 0 1px rgba(43, 43, 43, 0.1) !important;
  background: #FFFFFF !important;
}

/* Text Colors in Containers */
body.light-mode .text-gray-300,
body.light-mode .text-button-label {
  color: #B3B3B3 !important;
}

body.light-mode .text-white,
body.light-mode .text-gray-200 {
  color: #2B2B2B !important;
}

/* Global fix for ALL bg-gray-800 elements in light mode */
body.light-mode .bg-gray-800,
body.light-mode .bg-gray-900,
body.light-mode [class*="bg-gray-"] {
  background-color: #FFFFFF !important;
  color: #2B2B2B !important;
  border: 1px solid #D4D4D4 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

body.light-mode .app-container {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.light-mode .bg-gray-800 *,
body.light-mode [class*="bg-gray-"] * {
  color: inherit;
}

/* Re-apply specific text colors for readability */
body.light-mode .text-gray-400 {
  color: #B3B3B3 !important;
}

body.light-mode .text-gray-300 {
  color: #B3B3B3 !important;
}

body.light-mode .text-blue-400 {
  color: #2563eb !important;
}

/* Export Button Accent Colors */
body.light-mode .text-green-400,
body.light-mode .text-green-300 {
  color: #16a34a !important;
}

body.light-mode .text-red-400,
body.light-mode .text-red-300 {
  color: #dc2626 !important;
}

body.light-mode .text-purple-400,
body.light-mode .text-purple-300 {
  color: #9333ea !important;
}

/* Format Highlights */
body.light-mode .format-preview-panel .section-highlight {
  border-left-color: #2B2B2B !important;
  background-color: rgba(43, 43, 43, 0.05) !important;
}

/* Buttons */
body.light-mode button.text-gray-300:hover {
  background-color: #F5F5F5 !important;
}

/* Softer Button Colors for Light Mode */
body.light-mode .record-button {
  background: linear-gradient(135deg, #319795, #2C7A7B) !important;
  box-shadow: 0 4px 6px rgba(49, 151, 149, 0.2) !important;
}

body.light-mode .record-button:hover {
  box-shadow: 0 6px 12px rgba(49, 151, 149, 0.3) !important;
}

body.light-mode .continue-record-button {
  background: linear-gradient(135deg, #68D391, #48BB78) !important;
  box-shadow: 0 4px 6px rgba(72, 187, 120, 0.2) !important;
}

body.light-mode .type-directly-button {
  background: linear-gradient(135deg, #319795, #2C7A7B) !important;
  box-shadow: 0 4px 6px rgba(49, 151, 149, 0.2) !important;
}

body.light-mode #generate-button {
  background: linear-gradient(135deg, #319795, #2C7A7B) !important;
  box-shadow: 0 4px 6px rgba(49, 151, 149, 0.2) !important;
  color: #ffffff !important;
}

body.light-mode #generate-button:hover {
  background: linear-gradient(135deg, #285E61, #234E52) !important;
  box-shadow: 0 6px 12px rgba(49, 151, 149, 0.3) !important;
  color: #ffffff !important;
}

/* Generic Blue Keys */
body.light-mode .bg-blue-600 {
  background-color: #319795 !important;
}

body.light-mode .bg-blue-600:hover {
  background-color: #2C7A7B !important;
}

body.light-mode button:has(.fa-plus) {
  background-color: #319795 !important;
}

body.light-mode #create-format-btn,
body.light-mode button:has(.fa-plus-circle),
body.light-mode button[onclick*="showFormatModal"] {
  background: rgba(0, 0, 0, 0.03) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: #4B5563 !important;
  box-shadow: none !important;
}

body.light-mode #create-format-btn:hover,
body.light-mode button:has(.fa-plus-circle):hover {
  background: rgba(0, 0, 0, 0.07) !important;
  color: #1F2937 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

body.light-mode #generate-quick-button {
  background: linear-gradient(135deg, #319795, #2C7A7B) !important;
  color: white !important;
  box-shadow: 0 2px 4px rgba(49, 151, 149, 0.2) !important;
  border: none !important;
}

body.light-mode #generate-quick-button:hover {
  background: linear-gradient(135deg, #2C7A7B, #285E61) !important;
  box-shadow: 0 4px 8px rgba(49, 151, 149, 0.3) !important;
  transform: translateY(-1px);
}

body.light-mode .visualizer-container {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.light-mode pre {
  color: #2B2B2B !important;
}

body.light-mode ::selection {
  background-color: #D4D4D4 !important;
  color: #2B2B2B !important;
}

body.light-mode #no-reports-message {
  color: #B3B3B3 !important;
}

/* Light Mode - Loading Overlay */
body.light-mode .panel-loading {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(8px) !important;
  border: 1px solid #D4D4D4 !important;
}

body.light-mode .panel-loading .loading-message {
  color: #2B2B2B !important;
  font-weight: 600 !important;
}

body.light-mode .panel-loading .bg-gray-700 {
  background-color: #D4D4D4 !important;
}

body.light-mode .panel-loading circle[opacity="0.3"] {
  stroke: #D4D4D4 !important;
  opacity: 1 !important;
}

body.light-mode .panel-loading .progress-percentage {
  color: #319795 !important;
}

/* Light Mode - Live Template Morphing Animation */
body.light-mode .report-scan-beam {
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(49, 151, 149, 0.2) 15%,
    rgba(49, 151, 149, 0.7) 50%,
    rgba(49, 151, 149, 0.2) 85%,
    transparent 100%);
  box-shadow:
    0 0 12px rgba(49, 151, 149, 0.4),
    0 0 30px rgba(49, 151, 149, 0.15);
}

body.light-mode .report-progress-bar {
  background: linear-gradient(90deg, #319795, #38b2ac, #4fd1c5);
  box-shadow: 0 0 8px rgba(49, 151, 149, 0.3);
}

body.light-mode .report-generating .report-section-scanning {
  background: linear-gradient(90deg, 
    rgba(49, 151, 149, 0.2) 0%, 
    rgba(49, 151, 149, 0.14) 100%);
}

body.light-mode .report-status-pill {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(49, 151, 149, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

body.light-mode .report-status-pill .status-dot {
  background: #319795;
}

body.light-mode .report-status-pill .status-text {
  color: #285e61;
}

body.light-mode .report-complete-flash {
  animation-name: completionFlashLight;
}

@keyframes completionFlashLight {
  0%   { box-shadow: inset 0 0 0 0 rgba(49, 151, 149, 0); }
  50%  { box-shadow: inset 0 0 0 2px rgba(49, 151, 149, 0.3); }
  100% { box-shadow: inset 0 0 0 0 rgba(49, 151, 149, 0); }
}

/* --- Theme Toggle Switch (Premium Pill Design) --- */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 88px;
  height: 34px;
  cursor: pointer;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* Track — Dark Mode default (dark pill) */
.theme-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1F2937;
  border-radius: 34px !important;
  border: 1px solid #374151 !important;
  display: flex;
  align-items: center;
  padding: 0 8px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

/* Text label inside the track */
.theme-label-text {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #9CA3AF;
  margin-left: 30px;
  transition: all 0.4s ease;
  user-select: none;
  white-space: nowrap;
}

/* Sliding knob with icon */
.theme-knob {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: #FFFFFF;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
  z-index: 10;
}

/* Icons inside the knob */
.theme-icon-moon,
.theme-icon-sun {
  position: absolute;
  font-size: 13px;
  transition: all 0.3s ease;
}

/* Dark Mode: moon visible, sun hidden */
.theme-icon-moon {
  color: #374151;
  opacity: 1;
  transform: rotate(0deg);
}

.theme-icon-sun {
  color: #F59E0B;
  opacity: 0;
  transform: rotate(-90deg);
}

/* ---- Checked = Light Mode ---- */
input:checked+.theme-track {
  background: #E5E7EB;
  border-color: #D1D5DB !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

input:checked+.theme-track .theme-label-text {
  color: #4B5563;
  margin-left: 4px;
  margin-right: auto;
}

input:checked+.theme-track .theme-knob {
  left: calc(100% - 31px);
  background: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

input:checked+.theme-track .theme-icon-moon {
  opacity: 0;
  transform: rotate(90deg);
}

input:checked+.theme-track .theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg);
}

/* --- Rounded Pill Buttons for Dictation Controls --- */
#record-button,
#continue-recording-button,
#type-directly-button {
  border-radius: 9999px !important;
}

/* Mobile Performance Updates - Disable backdrop-filter to prevent crashes */
@media (max-width: 768px) {

  section>div,
  .recorder-container,
  .glass-card,
  .format-selector,
  .report-container,
  .editor-container,
  .visualizer-container,
  .nav-dark,
  .report-results-panel,
  .format-preview-panel {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(31, 41, 55, 0.98) !important;
    /* Higher opacity fallback */
  }

  /* Disable all fly-in animations on mobile to prevent GPU crashes */
  .run-animation .animate-fly-in,
  .animate-fly-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    will-change: auto !important;
  }

  /* Disable other expensive animations on mobile */
  * {
    will-change: auto !important;
  }

  /* Ensure light mode also gets the opaque treatment */
  body.light-mode section>div,
  body.light-mode .recorder-container,
  body.light-mode .glass-card,
  body.light-mode .format-selector,
  body.light-mode .report-container,
  body.light-mode .editor-container,
  body.light-mode .report-results-panel,
  body.light-mode .format-preview-panel {
    background: #FFFFFF !important;
    border: 1px solid #D4D4D4 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* Global Modal Backdrop Override (User Request: 60% Transparency + Blur) */
#macro-manager-modal,
#template-manager-modal,
#text-import-modal,
#export-filename-modal,
#patient-details-modal,
#format-preview-modal {
  background-color: rgba(17, 24, 39, 0.6) !important;
  /* 60% opacity (40% transparent) */
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
}

/* Desktop Alignment Fix - Enforce Center */
@media (min-width: 769px) {

  #macro-manager-modal,
  #template-manager-modal,
  #text-import-modal,
  #export-filename-modal,
  #patient-details-modal,
  #format-preview-modal {
    align-items: center !important;
    justify-content: center !important;
  }

  /* Force max-height and flex column on content to fix infinite expansion */
  #macro-manager-content,
  #template-manager-modal>div:first-child,
  #text-import-modal>div:first-child,
  #export-filename-modal>div:first-child,
  #patient-details-modal>div:first-child,
  #format-preview-modal>div:first-child {
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
}

/* Mobile Modal Fixes - "Bottom Sheet" Style */
@media (max-width: 768px) {

  /* 1. Alignment: Anchor to bottom instead of center */
  #macro-manager-modal,
  #template-manager-modal,
  #text-import-modal,
  #export-filename-modal,
  #patient-details-modal,
  #format-preview-modal {
    align-items: flex-end !important;
    /* Push to bottom */
    padding: 0 !important;
    /* Remove side padding */
  }

  /* 2. Content Styling: Full width, rounded top only */
  #macro-manager-content,
  #template-manager-modal>div:first-child,
  #text-import-modal>div:first-child,
  #export-filename-modal>div:first-child,
  #patient-details-modal>div:first-child,
  #format-preview-modal>div:first-child {
    /* Dimensions */
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    max-height: 80dvh !important;
    /* Safe dynamic viewport height */
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    /* Force clipping to respect max-height */

    /* Shape */
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 16px !important;
    border-top-right-radius: 16px !important;

    /* Borders - Remove full border, add strong top border for definition */
    border: none !important;
    border-top: 1px solid #D4D4D4 !important;
    /* Light Mode Border */
  }

  /* Dark Mode Border Override for Sheets */
  body:not(.light-mode) #macro-manager-content,
  body:not(.light-mode) #template-manager-modal>div:first-child,
  body:not(.light-mode) #text-import-modal>div:first-child,
  body:not(.light-mode) #export-filename-modal>div:first-child,
  body:not(.light-mode) #patient-details-modal>div:first-child,
  body:not(.light-mode) #format-preview-modal>div:first-child {
    border-top: 1px solid #374151 !important;
    /* Gray 700 */
  }
}

/* =========================================
   RADIOLOGY NEWS SECTION STYLES
   ========================================= */

/* Line clamp utility for text truncation */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* News Section Container */
#news-section {
  background: rgba(31, 41, 55, 0.8) !important;
  backdrop-filter: blur(20px);
}

/* News Card Styling */
.news-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.15) !important;
}

.news-card img {
  transition: transform 0.5s ease;
}

.news-card:hover img {
  transform: scale(1.05);
}

/* Source badge colors */
.news-card .bg-green-600 {
  background: linear-gradient(135deg, #059669, #047857) !important;
}

.news-card .bg-purple-600 {
  background: linear-gradient(135deg, #7c3aed, #6d28d9) !important;
}

.news-card .bg-blue-600 {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
}

/* News Section Light Mode */
body.light-mode #news-section {
  background: #F8F9FA !important;
  border: 1px solid #E2E8F0 !important;
}

body.light-mode .news-card {
  background: #FFFFFF !important;
  border: 1px solid #E2E8F0 !important;
}

body.light-mode .news-card:hover {
  border-color: #3B82F6 !important;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.12) !important;
}

body.light-mode .news-card h3 {
  color: #1F2937 !important;
}

body.light-mode .news-card p {
  color: #6B7280 !important;
}

body.light-mode .news-card span.text-gray-500 {
  color: #9CA3AF !important;
}



body.light-mode #news-section .text-gray-400 {
  color: #6B7280 !important;
}

body.light-mode #news-section .text-gray-500 {
  color: #9CA3AF !important;
}

body.light-mode #news-section .text-gray-600 {
  color: #9CA3AF !important;
}

body.light-mode #news-section .border-gray-700\/50 {
  border-color: #E5E7EB !important;
}

/* News card image placeholder background */
.news-card .bg-gray-800 {
  background: #1f2937 !important;
}

body.light-mode .news-card .bg-gray-800 {
  background: #F3F4F6 !important;
}

/* News Section - Light Mode Overrides */
body.light-mode .news-list-item {
  background: #FFFFFF !important;
  border: 1px solid #E5E7EB !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

body.light-mode .news-list-item:hover {
  background: #F9FAFB !important;
  border-color: #3B82F6 !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

body.light-mode .news-list-item h3 {
  color: #111827 !important;
}

body.light-mode .news-list-item p {
  color: #4B5563 !important;
}

body.light-mode .news-list-item .text-gray-500 {
  color: #6B7280 !important;
}

body.light-mode .news-list-item a.text-blue-400 {
  color: #2563EB !important;
}

body.light-mode .news-list-item a.text-blue-400:hover {
  color: #1D4ED8 !important;
}

/* Ensure modal text is visible in light mode */


/* Softer source colors for Light Mode */
body.light-mode .news-list-item .bg-indigo-600 {
  background-color: #e0e7ff !important;
  /* Indigo 100 */
  color: #4338ca !important;
  /* Indigo 700 */
}

body.light-mode .news-list-item .bg-green-600 {
  background-color: #dcfce7 !important;
  /* Green 100 */
  color: #15803d !important;
  /* Green 700 */
}

body.light-mode .news-list-item .bg-teal-600 {
  background-color: #ccfbf1 !important;
  /* Teal 100 */
  color: #0f766e !important;
  /* Teal 700 */
}

body.light-mode .news-list-item .bg-purple-600 {
  background-color: #f3e8ff !important;
  /* Purple 100 */
  color: #7e22ce !important;
  /* Purple 700 */
}

body.light-mode .news-list-item .bg-blue-600 {
  background-color: #dbeafe !important;
  /* Blue 100 */
  color: #1d4ed8 !important;
  /* Blue 700 */
}

body.light-mode .news-list-item .bg-gray-600 {
  background-color: #f3f4f6 !important;
  /* Gray 100 */
  color: #374151 !important;
  /* Gray 700 */
}

/* =========================================
   THREE-PANEL LAYOUT — DARK MODE (DEFAULT)
   ========================================= */

/* Main three-panel container */
.three-panel-layout {
  display: flex;
  height: calc(100vh - 5.5rem);
  /* viewport minus navbar */
  gap: 1px;
  background: rgba(255, 255, 255, 0.04);
  /* subtle separator line */
  border-radius: 0.75rem;
  overflow: hidden;
  contain: layout style;
}

/* Override max-width for the recorder section parent so panels use full width */
#recorder-section {
  margin-left: -1rem;
  margin-right: -1rem;
  padding-left: 0;
  padding-right: 0;
}

/* Override section>div background rule for three-panel children */
.three-panel-layout>.panel>div,
#recorder-section .panel-header,
#recorder-section .panel-tab-bar {
  backdrop-filter: none !important;
  box-shadow: none !important;
}

/* Generic panel styles */
.panel {
  background: rgba(31, 41, 55, 0.95);
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: flex-basis 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  contain: layout style;
}

.panel-templates {
  flex: 0 0 22%;
  min-width: 200px;
  max-width: 320px;
  border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.panel-report {
  flex: 1 1 48%;
  border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.panel-dictation {
  flex: 1 1 30%;
  max-width: 600px;
}

/* Panel Headers — unified height for alignment */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.75rem;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  background: rgba(22, 30, 46, 0.6);
  box-sizing: border-box;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #e5e7eb;
  margin: 0;
  background: none !important;
  -webkit-text-fill-color: inherit !important;
}

.panel-header-action {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem !important;
  color: #9ca3af;
  background: transparent !important;
  transition: all 0.2s ease !important;
}

.panel-header-action:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.08) !important;
}

.panel-close-action {
  color: #ef4444 !important;
}

.panel-close-action:hover {
  color: #f87171 !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

/* Template Actions */
.template-actions {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-action-btn {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #d1d5db;
  border-radius: 0.5rem !important;
  transition: all 0.2s ease !important;
  cursor: pointer;
  text-decoration: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  width: 100%;
  text-align: left;
}

.template-action-btn:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #f3f4f6;
  transform: none !important;
  box-shadow: none !important;
}

/* Tips Section (inline, compact) */
.panel-tips-inline {
  padding: 0.25rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

/* ─── Always-visible format list in templates panel ─── */
.panel-search-area {
  flex-shrink: 0;
}

.panel-search-area .format-selector {
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}

.panel-format-list-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Force format-dropdown to always be visible inside the inline list */
.panel-format-list-area #format-dropdown,
.panel-format-list-area #format-dropdown.hidden {
  display: block !important;
  position: static !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  border: none !important;
  width: 100% !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.panel-format-list .format-list-item,
.panel-format-list>div>div {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  transition: background 0.1s ease;
}

/* ─── Format Categories ─── */
.format-categories {
  padding: 0.5rem;
}

.category-header {
  padding: 0.375rem 0;
  margin-bottom: 0.25rem;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 0 0.25rem;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  color: #d1d5db;
  border-radius: 0.375rem !important;
  transition: all 0.15s ease !important;
  cursor: pointer;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  text-align: left;
  width: 100%;
}

.category-item:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #f3f4f6;
}

.category-icon {
  font-size: 0.65rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* ─── Minimal Waveform Visualizer v3 (sine-wave style) ─── */
.visualizer-container-v3 {
  height: 40px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  overflow: visible;
  position: relative;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.visualizer-container-v3:hover {
  opacity: 1;
}

.visualizer-container-v3 canvas {
  border-radius: 0;
}

/* Keep v2 for backward compat */
.visualizer-container-v2 {
  height: 40px;
  background: transparent !important;
}

/* ─── Full-height report panel content ─── */
.panel-report-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 0.5rem;
}

.panel-report-inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0.75rem;
  min-height: 0;
}

.panel-report-inner .prose {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#format-preview-content,
#report-results-content {
  flex: 1 !important;
  overflow-y: auto !important;
  min-height: 100px !important;
}


/* Full-height for format preview and report results inside three-panel (Desktop Only) */
@media (min-width: 769px) {

  #format-preview-panel:not(.hidden),
  #report-results-panel:not(.hidden) {
    min-height: calc(100vh - 10rem) !important;
    max-height: none !important;
  }
}

/* Let format-preview-panel and report-results-panel stretch to fill */
.panel-report-content .format-preview-panel,
.panel-report-content .report-results-panel {
  background: transparent !important;
  border-radius: 0 !important;
  flex: 1 1 auto !important;
}

/* ─── Recorder container within center panel ─── */
.panel-dictation .recorder-container {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  background: transparent !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* ─── Format selector within left panel ─── */
.panel-templates .format-selector {
  background: transparent !important;
  border-radius: 0.5rem !important;
  padding: 0.5rem !important;
  margin: 0.5rem !important;
}

/* ─── Report preview & results within right panel ─── */
.panel-report .format-preview-panel,
.panel-report .report-results-panel {
  background: transparent !important;
  border-radius: 0 !important;
  flex: 1 1 auto !important;
}

/* ─── Panel Tab Bar (Mobile Only) ─── */
.panel-tab-bar {
  display: none;
  /* Hidden on desktop */
  background: rgba(22, 30, 46, 0.95);
  padding: 0.5rem;
  gap: 0.25rem;
  border-radius: 0.75rem 0.75rem 0 0;
  overflow: hidden;
}

.panel-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  background: transparent !important;
  border: none !important;
  border-radius: 0.5rem !important;
  transition: all 0.2s ease !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.panel-tab:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06) !important;
  transform: none !important;
  box-shadow: none !important;
}

.panel-tab.active {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1) !important;
  box-shadow: none !important;
}

.panel-tab i {
  font-size: 0.65rem;
}

/* ─── Panel hidden class (mobile tab switching) ─── */
/* On desktop, panel-hidden has NO effect */
@media (min-width: 769px) {
  .panel-hidden {
    display: flex !important;
    /* Always show on desktop */
  }
}

/* Large screen refinements */
@media (min-width: 1440px) {
  .panel-report-inner {
    padding: 1rem 1.5rem;
  }
}

/* ─── Live structured indicator pulse ─── */
@keyframes livePulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.panel-report .animate-pulse {
  animation: livePulse 2s ease-in-out infinite !important;
}

/* ─── Report empty state ─── */
#report-empty-state {
  flex: 1;
  display: flex;
  min-height: 200px;
}

/* Hide empty state when format preview or report results are visible */
#format-preview-panel:not(.hidden)~#report-empty-state,
#report-results-panel:not(.hidden)~#report-empty-state {
  display: none !important;
}

/* ─── Custom scrollbar for panels ─── */
.panel::-webkit-scrollbar {
  width: 4px;
}

.panel::-webkit-scrollbar-track {
  background: transparent;
}

.panel::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, 0.3);
  border-radius: 2px;
}

.panel::-webkit-scrollbar-thumb:hover {
  background: rgba(96, 165, 250, 0.5);
}

/* =========================================
   THREE-PANEL — LIGHT MODE OVERRIDES
   ========================================= */

body.light-mode .three-panel-layout {
  background: #E2E8F0;
  /* separator color */
}

body.light-mode .panel {
  background: #FFFFFF;
}

body.light-mode .panel-header {
  background: #F8F9FA;
  border-bottom: 1px solid #E5E7EB;
}

body.light-mode .panel-title {
  color: #1F2937 !important;
}

body.light-mode .panel-header-action {
  color: #6B7280;
}

body.light-mode .panel-header-action:hover {
  color: #1F2937;
  background: rgba(0, 0, 0, 0.04) !important;
}

body.light-mode .template-actions {
  gap: 6px;
}

body.light-mode .template-action-btn {
  color: #4B5563;
  background: rgba(0, 0, 0, 0.03) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  padding: 0.6rem 0.75rem;
}

body.light-mode .template-action-btn:hover {
  background: rgba(0, 0, 0, 0.07) !important;
  color: #1F2937;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

body.light-mode .panel-tips-inline {
  border-top-color: #E5E7EB;
  border-bottom-color: #E5E7EB;
}

body.light-mode .visualizer-container-v3 {
  background: transparent !important;
}

body.light-mode .category-item {
  color: #4B5563;
}

body.light-mode .category-item:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: #1F2937;
}

body.light-mode .panel-templates {
  border-right-color: #E2E8F0 !important;
}

body.light-mode .panel-report {
  border-right-color: #E2E8F0 !important;
}

body.light-mode .visualizer-container-v2,
body.light-mode .visualizer-container-v3 {
  background: transparent !important;
}

body.light-mode .visualizer-container-v2::before {
  background: linear-gradient(90deg,
      rgba(49, 151, 149, 0.05) 0%,
      rgba(49, 151, 149, 0.1) 50%,
      rgba(49, 151, 149, 0.05) 100%);
}

body.light-mode .panel-tab-bar {
  background: #F3F4F6;
}

body.light-mode .panel-tab {
  color: #6B7280;
}

body.light-mode .panel-tab:hover {
  color: #1F2937;
  background: rgba(0, 0, 0, 0.04) !important;
}

body.light-mode .panel-tab.active {
  color: #319795;
  background: rgba(49, 151, 149, 0.1) !important;
}

body.light-mode .panel-templates .format-selector {
  background: transparent !important;
}

body.light-mode .panel-report .format-preview-panel,
body.light-mode .panel-report .report-results-panel {
  background: transparent !important;
}

body.light-mode .panel-dictation .recorder-container {
  background: transparent !important;
}

body.light-mode #report-empty-state i {
  color: #D1D5DB !important;
}

body.light-mode #report-empty-state p {
  color: #9CA3AF !important;
}

/* =========================================
   THREE-PANEL — MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
  .three-panel-layout {
    flex-direction: column;
    /* Constrain to viewport minus navbar and tab bar */
    height: calc(100dvh - 8rem);
    max-height: calc(100dvh - 8rem);
    /* Fallback for older browsers without dvh support */
    height: calc(var(--vh, 1vh) * 100 - 8rem);
    max-height: calc(var(--vh, 1vh) * 100 - 8rem);
    min-height: 0;
    gap: 0;
    border-radius: 0;
    overflow: hidden;
    width: 100%;
  }

  .app-container {
    min-height: 0 !important;
  }

  /* Reset the negative margin expansion on mobile */
  #recorder-section {
    margin-left: 0;
    margin-right: 0;
    overflow: hidden;
  }

  .panel {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow: hidden;
  }

  .panel-hidden {
    display: none !important;
  }

  .panel-tab-bar {
    display: flex;
    border-radius: 0;
    width: 100%;
    overflow-x: hidden;
    flex-shrink: 0;
  }

  .panel-templates {
    max-width: none;
  }

  /* Constrain the templates format list on mobile */
  .panel-format-list-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: none;
  }

  /* Override the desktop min-height on mobile — critical fix */
  #format-preview-panel:not(.hidden),
  #report-results-panel:not(.hidden) {
    min-height: 0 !important;
    max-height: 100% !important;
    overflow-y: auto !important;
  }

  /* Ensure report content area scrolls internally on mobile */
  .panel-report-content {
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  .panel-report-inner {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  #format-preview-content,
  #report-results-content {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  /* Center the loading indicator within the visible panel area */
  #report-empty-state {
    min-height: 0 !important;
    flex: 1;
  }

  /* Disable backdrop-filter for panels (perf) */
  .panel,
  .panel-header,
  .visualizer-container-v2 {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Light mode mobile overrides */
  body.light-mode .panel {
    background: #FFFFFF !important;
  }

  body.light-mode .panel-tab-bar {
    background: #F3F4F6 !important;
  }
}

/* ─── Micro-animations ─── */
@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animate panel content when mobile tab changes */
@media (max-width: 768px) {
  .panel:not(.panel-hidden) {
    animation: panelFadeIn 0.25s ease-out;
  }
}

/* =========================================
   MOBILE CLOSE TAB BUTTON (in tab bar)
   ========================================= */
@media (max-width: 768px) {
  .panel-tab-close-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
    width: 18px;
    height: 16px;
    border-radius: 0 !important;
    color: #ef4444;
    font-size: 0.6rem;
    opacity: 1;
    transition: opacity 0.15s ease !important;
  }

  .panel-tab-close-inline:active {
    opacity: 1;
    background: rgba(248, 113, 113, 0.15) !important;
  }

  body.light-mode .panel-tab-close-inline {
    color: #EF4444;
    border-left-color: rgba(0, 0, 0, 0.15) !important;
  }
}

/* Hide inline close on desktop */
@media (min-width: 769px) {
  .panel-tab-close-inline {
    display: none !important;
  }
}

/* =========================================
   LIVE SPEECH PREVIEW (Web Speech API)
   ========================================= */
.live-speech-preview {
  text-align: left;
  padding: 0.25rem 1.5rem;
  pointer-events: none;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.live-speech-preview.live-speech-fade-in {
  opacity: 0.8;
  transform: translateY(0);
}

.live-speech-preview.live-speech-fade-out {
  opacity: 0;
  transform: translateY(4px);
}

.live-speech-text {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #9ca3af;
  font-style: italic;
  max-width: 92%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Light mode */
body.light-mode .live-speech-text {
  color: #6b7280;
}

/* ─── RadQC — Inline Report Annotations ─── */

/* Proofreading highlight — wavy underline */
.radqc-highlight {
  cursor: pointer;
  transition: background-color 0.2s;
}
.radqc-highlight-proofread {
  background-color: rgba(239, 68, 68, 0.35);
  border-bottom: 2px wavy rgba(239, 68, 68, 0.9);
  padding: 1px 2px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.15);
}
.radqc-highlight-proofread:hover {
  background-color: rgba(239, 68, 68, 0.5);
}

/* Recommendation insert marker (inline + icon) */
.radqc-insert-marker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #facc15;
  font-size: 14px;
  margin: 0 3px;
  vertical-align: middle;
  transition: color 0.2s, transform 0.2s;
}
.radqc-insert-marker:hover {
  color: #fde047;
  transform: scale(1.2);
}

/* Block-level marker (fallback for section end) */
.radqc-block-marker {
  display: block;
  margin: 6px 0;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(234, 179, 8, 0.06);
  border: 1px dashed rgba(234, 179, 8, 0.2);
  transition: background 0.2s;
}
.radqc-block-marker:hover {
  background: rgba(234, 179, 8, 0.12);
}

/* Applied text (after fix/insert) */
.radqc-applied-text {
  border-radius: 2px;
}

/* ─── Popover (fixed position, on document.body) ─── */
.radqc-popover {
  position: fixed;
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 20px);
  max-height: 350px;
  overflow-y: auto;
  background: #1f2937;
  border: 1px solid rgba(75, 85, 99, 0.6);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
  font-size: 12px;
  line-height: 1.5;
  animation: radqc-pop-in 0.15s ease-out;
}
@keyframes radqc-pop-in {
  from { opacity: 0; transform: translateY(4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Popover header */
.radqc-pop-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(75, 85, 99, 0.4);
  background: rgba(17, 24, 39, 0.6);
  border-radius: 10px 10px 0 0;
}
.radqc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.radqc-priority-pill {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.radqc-priority-high { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.radqc-priority-medium { background: rgba(234, 179, 8, 0.2); color: #fde68a; }
.radqc-priority-low { background: rgba(107, 114, 128, 0.2); color: #d1d5db; }
.radqc-pop-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  transition: color 0.15s;
}
.radqc-pop-close:hover { color: #f3f4f6; }

/* Popover body */
.radqc-pop-body {
  padding: 10px;
}
.radqc-badge-proof {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}
.radqc-badge-rec {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}
.radqc-pop-issue {
  color: #e5e7eb;
  font-weight: 500;
  margin: 0 0 6px;
}
.radqc-pop-title {
  color: #f3f4f6;
  font-weight: 600;
  font-size: 13px;
  margin: 0 0 4px;
}
.radqc-pop-desc {
  color: #9ca3af;
  margin: 0 0 8px;
}
.radqc-pop-diff {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  margin-top: 6px;
}
.radqc-diff-remove {
  display: flex;
  gap: 6px;
  color: #fca5a5;
}
.radqc-diff-add {
  display: flex;
  gap: 6px;
  color: #86efac;
}
.radqc-pop-preview {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 3px solid rgba(59, 130, 246, 0.4);
}
.radqc-pop-preview-label {
  display: block;
  font-size: 9px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.radqc-pop-preview-text {
  color: #d1d5db;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Popover actions */
.radqc-pop-actions {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid rgba(75, 85, 99, 0.3);
  background: rgba(17, 24, 39, 0.4);
  border-radius: 0 0 10px 10px;
}
.radqc-pop-btn-apply {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}
.radqc-pop-btn-apply:hover { background: rgba(34, 197, 94, 0.35); }
.radqc-pop-btn-dismiss {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(75, 85, 99, 0.4);
  background: transparent;
  font-size: 11px;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s;
}
.radqc-pop-btn-dismiss:hover { background: rgba(75, 85, 99, 0.2); color: #d1d5db; }

/* ─── Floating action bar (inside report panel) ─── */
.radqc-floating-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.08), rgba(59, 130, 246, 0.06));
  border: 1px solid rgba(234, 179, 8, 0.2);
  border-radius: 10px;
  font-size: 12px;
  animation: radqc-bar-in 0.3s ease-out;
}
@keyframes radqc-bar-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.radqc-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d1d5db;
}
.radqc-bar-label { font-weight: 500; }
.radqc-bar-label strong { color: #facc15; }
.radqc-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.radqc-bar-btn-apply {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  transition: all 0.15s;
}
.radqc-bar-btn-apply:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
}
.radqc-bar-btn-dismiss {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(75, 85, 99, 0.4);
  background: transparent;
  font-size: 11px;
  color: #9ca3af;
  cursor: pointer;
}
.radqc-bar-btn-dismiss:hover { background: rgba(75, 85, 99, 0.2); color: #d1d5db; }

/* Light mode overrides */
body.light-mode .radqc-popover {
  background: #ffffff;
  border-color: rgba(209, 213, 219, 0.8);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
body.light-mode .radqc-pop-header {
  background: rgba(243, 244, 246, 0.9);
  border-bottom-color: rgba(209, 213, 219, 0.5);
}
body.light-mode .radqc-badge-proof {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}
body.light-mode .radqc-badge-rec {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}
body.light-mode .radqc-pop-issue {
  color: #1f2937;
}
body.light-mode .radqc-pop-title {
  color: #111827;
}
body.light-mode .radqc-pop-desc {
  color: #4b5563;
}
body.light-mode .radqc-pop-diff {
  background: rgba(0, 0, 0, 0.04);
}
body.light-mode .radqc-diff-remove {
  color: #dc2626;
}
body.light-mode .radqc-diff-add {
  color: #16a34a;
}
body.light-mode .radqc-pop-preview {
  background: rgba(0, 0, 0, 0.04);
  border-left-color: rgba(59, 130, 246, 0.5);
}
body.light-mode .radqc-pop-preview-label {
  color: #6b7280;
}
body.light-mode .radqc-pop-preview-text {
  color: #374151;
}
body.light-mode .radqc-priority-high { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
body.light-mode .radqc-priority-medium { background: rgba(234, 179, 8, 0.12); color: #92400e; }
body.light-mode .radqc-priority-low { background: rgba(107, 114, 128, 0.12); color: #4b5563; }
body.light-mode .radqc-pop-btn-apply {
  background: rgba(22, 163, 74, 0.15);
  color: #15803d;
}
body.light-mode .radqc-pop-btn-apply:hover {
  background: rgba(22, 163, 74, 0.25);
}
body.light-mode .radqc-pop-actions {
  border-top-color: rgba(209, 213, 219, 0.5);
  background: rgba(249, 250, 251, 0.6);
}
body.light-mode .radqc-pop-btn-dismiss {
  color: #6b7280;
  border-color: rgba(209, 213, 219, 0.6);
}
body.light-mode .radqc-pop-btn-dismiss:hover {
  background: rgba(243, 244, 246, 0.8);
  color: #374151;
}
body.light-mode .radqc-pop-close {
  color: #9ca3af !important;
}
body.light-mode .radqc-pop-close:hover {
  color: #374151 !important;
}
body.light-mode .radqc-floating-bar {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.08), rgba(59, 130, 246, 0.06));
  border-color: rgba(234, 179, 8, 0.35);
}
body.light-mode .radqc-bar-left { color: #374151; }
body.light-mode .radqc-bar-label { color: #374151; }
body.light-mode .radqc-bar-btn-dismiss {
  color: #6b7280;
  border-color: rgba(209, 213, 219, 0.6);
}
body.light-mode .radqc-highlight-proofread {
  background-color: rgba(239, 68, 68, 0.25);
  border-bottom: 2px wavy rgba(220, 38, 38, 0.9);
}
body.light-mode .radqc-highlight-proofread:hover {
  background-color: rgba(239, 68, 68, 0.4);
}
body.light-mode .radqc-insert-marker {
  color: #d97706;
}
body.light-mode .radqc-insert-marker:hover {
  color: #b45309;
}
body.light-mode .radqc-block-marker {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.3);
}