/* Mobile-friendly ElevenLabs widget */
      @media (max-width: 640px) {
        elevenlabs-convai {
          position: fixed !important;
          bottom: 80px !important;
          right: 16px !important;
          z-index: 30 !important;
        }
      }
      
      /* Hide scrollbar but keep functionality */
      .hide-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
      }
      .hide-scrollbar::-webkit-scrollbar {
        display: none;
      }
      
      /* Dutch Fluency Brand Colors & Animations */
      .df-gradient {
        background: linear-gradient(135deg, #FF7A00 0%, #FF9500 50%, #FFB000 100%);
      }
      .df-gradient-subtle {
        background: linear-gradient(135deg, rgba(255, 122, 0, 0.1) 0%, rgba(255, 149, 0, 0.05) 100%);
      }
      .df-shadow {
        box-shadow: 0 4px 20px rgba(255, 122, 0, 0.15);
      }
      .df-glow {
        box-shadow: 0 0 20px rgba(255, 122, 0, 0.3);
      }
      
      /* Voice Recording Animation */
      @keyframes pulse-recording {
        0% { transform: scale(1); }
        50% { transform: scale(1.1); }
        100% { transform: scale(1); }
      }
      .recording-pulse {
        animation: pulse-recording 1s ease-in-out infinite;
      }
      
      /* Message Animations */
      @keyframes messageSlide {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
      }
      .message-animate {
        animation: messageSlide 0.3s ease-out;
      }
      
      /* Tutor Message Styling */
      .tutor-message {
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border-left: 4px solid #FF7A00;
      }
      
      /* Enhanced Chat Styling */
      .user-message {
        background: linear-gradient(135deg, #FF7A00 0%, #FF9500 100%);
        position: relative;
      }
      .user-message::after {
        content: '';
        position: absolute;
        bottom: -8px;
        right: 16px;
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-top: 8px solid #FF7A00;
      }
      
      .tutor-message-enhanced {
        background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
        border: 1px solid #e5e7eb;
        position: relative;
      }
      .tutor-message-enhanced::after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 16px;
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-top: 8px solid #ffffff;
      }
      
      /* Chat welcome animation */
      @keyframes welcomeFloat {
        0%, 100% { transform: translateY(0px) rotate(0deg); }
        50% { transform: translateY(-10px) rotate(2deg); }
      }
      .welcome-float {
        animation: welcomeFloat 3s ease-in-out infinite;
      }
      
      /* Loading Overlay Styles */
      .loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #FF7A00 0%, #FF9500 50%, #FFB000 100%);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        opacity: 1;
        transition: opacity 0.5s ease-out;
      }
      
      .loading-overlay.fade-out {
        opacity: 0;
        pointer-events: none;
      }
      
      @keyframes logoSpin {
        0% { transform: rotate(0deg) scale(1); }
        50% { transform: rotate(180deg) scale(1.1); }
        100% { transform: rotate(360deg) scale(1); }
      }
      
      @keyframes sparkle {
        0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
        50% { opacity: 1; transform: scale(1) rotate(180deg); }
      }
      
      .logo-spin {
        animation: logoSpin 2s ease-in-out infinite;
      }
      
      .sparkle {
        position: absolute;
        color: white;
        font-size: 1.5rem;
        animation: sparkle 2s ease-in-out infinite;
      }
      
      .sparkle:nth-child(1) { top: 20%; left: 20%; animation-delay: 0s; }
      .sparkle:nth-child(2) { top: 20%; right: 20%; animation-delay: 0.3s; }
      .sparkle:nth-child(3) { bottom: 20%; left: 20%; animation-delay: 0.6s; }
      .sparkle:nth-child(4) { bottom: 20%; right: 20%; animation-delay: 0.9s; }
      .sparkle:nth-child(5) { top: 50%; left: 10%; animation-delay: 1.2s; }
      .sparkle:nth-child(6) { top: 50%; right: 10%; animation-delay: 1.5s; }
      
      /* Enhanced Markdown Styling for Chat Messages */
      .chat-markdown {
        line-height: 1.6 !important;
      }
      
      .chat-markdown h1, .chat-markdown h2, .chat-markdown h3, .chat-markdown h4, .chat-markdown h5, .chat-markdown h6 {
        color: #FF7A00 !important;
        font-weight: bold !important;
        margin: 12px 0 8px 0 !important;
        display: block !important;
      }
      .chat-markdown h1 { font-size: 1.5rem !important; }
      .chat-markdown h2 { font-size: 1.3rem !important; }
      .chat-markdown h3 { font-size: 1.1rem !important; }
      .chat-markdown h4 { font-size: 1rem !important; }
      
      .chat-markdown strong {
        color: #FF7A00 !important;
        font-weight: 700 !important;
        font-size: 1.05em !important;
      }
      
      .chat-markdown em {
        color: #1f2937 !important;
        font-style: italic !important;
      }
      
      .chat-markdown ul {
        margin: 8px 0 !important;
        padding-left: 20px !important;
        list-style-type: none !important;
      }
      
      .chat-markdown ul li {
        margin: 4px 0 !important;
        padding-left: 16px !important;
        position: relative !important;
        display: block !important;
      }
      
      .chat-markdown ul li:before {
        content: "•" !important;
        color: #FF7A00 !important;
        font-weight: bold !important;
        position: absolute !important;
        left: 0 !important;
      }
      
      .chat-markdown ol {
        margin: 8px 0 !important;
        padding-left: 20px !important;
        counter-reset: item !important;
      }
      
      .chat-markdown ol li {
        margin: 4px 0 !important;
        padding-left: 16px !important;
        position: relative !important;
        counter-increment: item !important;
        display: block !important;
      }
      
      .chat-markdown ol li:before {
        content: counter(item) "." !important;
        color: #FF7A00 !important;
        font-weight: bold !important;
        position: absolute !important;
        left: 0 !important;
      }
      
      .chat-markdown p {
        margin: 8px 0 !important;
        line-height: 1.6 !important;
        display: block !important;
      }
      
      .chat-markdown br {
        display: block !important;
        content: "" !important;
        margin-top: 4px !important;
      }
      
      .chat-markdown code {
        background: rgba(255, 122, 0, 0.1) !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
        color: #FF7A00 !important;
        font-family: 'Monaco', 'Menlo', monospace !important;
        font-size: 0.9em !important;
      }
      
      .chat-markdown blockquote {
        border-left: 3px solid #FF7A00 !important;
        padding-left: 12px !important;
        margin: 8px 0 !important;
        background: rgba(255, 122, 0, 0.05) !important;
        border-radius: 0 6px 6px 0 !important;
      }
      
      /* Exercise Section Styling */
      .exercise-section {
        background: linear-gradient(135deg, #fff8f0 0%, #fef3e8 100%);
        border: 2px solid #FFB366;
        border-radius: 12px;
        padding: 16px;
        margin: 12px 0;
      }
      
      .exercise-header {
        color: #FF7A00;
        font-weight: bold;
        font-size: 1.1em;
        margin-bottom: 8px;
        display: flex;
        align-items: center;
      }
      
      .mini-exercise {
        background: linear-gradient(135deg, #ff7a0015 0%, #ff950010 100%);
        border-left: 4px solid #FF7A00;
        padding: 12px;
        border-radius: 8px;
        margin: 8px 0;
      }

      /* Modal Animations */
      @keyframes modalFadeIn {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }

      @keyframes modalSlideIn {
        from {
          opacity: 0;
          transform: scale(0.95) translateY(-20px);
        }
        to {
          opacity: 1;
          transform: scale(1) translateY(0);
        }
      }

      .fixed.inset-0 {
        animation: modalFadeIn 0.2s ease-out;
      }

      .fixed.inset-0 > div {
        animation: modalSlideIn 0.3s ease-out;
      }

      /* Responsive Layout Improvements */
      @media (max-width: 1024px) {
        .grid.lg\\:grid-cols-2 {
          grid-template-columns: 1fr;
        }
      }

      @media (max-width: 768px) {
        .max-h-\\[40vh\\] {
          max-height: 30vh !important;
        }

        .h-\\[calc\\(100vh-80px\\)\\] {
          height: calc(100vh - 60px) !important;
        }
      }

      /* Scrollbar Styling for Modals */
      .overflow-y-auto:not(.hide-scrollbar) {
        scrollbar-width: thin;
        scrollbar-color: #FF7A00 #f3f4f6;
      }

      .overflow-y-auto:not(.hide-scrollbar)::-webkit-scrollbar {
        width: 6px;
      }

      .overflow-y-auto:not(.hide-scrollbar)::-webkit-scrollbar-track {
        background: #f3f4f6;
        border-radius: 3px;
      }

      .overflow-y-auto:not(.hide-scrollbar)::-webkit-scrollbar-thumb {
        background: #FF7A00;
        border-radius: 3px;
      }

      .overflow-y-auto:not(.hide-scrollbar)::-webkit-scrollbar-thumb:hover {
        background: #FF9500;
      }

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

      /* Audio Player Styling */
      .audio-player-card {
        background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
        border: 2px solid #FFB366;
        border-radius: 16px;
        padding: 24px;
        margin: 16px 0;
      }

      .waveform-container {
        height: 120px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 0 24px 0;
        background: linear-gradient(135deg, #fff8f0 0%, #fef3e8 100%);
        border-radius: 12px;
        padding: 20px;
      }

      .waveform-animation {
        display: flex;
        align-items: center;
        gap: 6px;
        height: 80px;
      }

      .wave-bar {
        width: 5px;
        background: linear-gradient(180deg, #FF7A00, #FFB000);
        border-radius: 3px;
        transition: transform 0.2s ease;
      }

      .wave-bar:nth-child(1) { height: 30%; }
      .wave-bar:nth-child(2) { height: 50%; }
      .wave-bar:nth-child(3) { height: 70%; }
      .wave-bar:nth-child(4) { height: 90%; }
      .wave-bar:nth-child(5) { height: 60%; }
      .wave-bar:nth-child(6) { height: 40%; }
      .wave-bar:nth-child(7) { height: 30%; }

      .wave-bar.playing {
        animation: waveAnimation 1.2s ease-in-out infinite;
      }

      .wave-bar.playing:nth-child(1) { animation-delay: 0s; }
      .wave-bar.playing:nth-child(2) { animation-delay: 0.1s; }
      .wave-bar.playing:nth-child(3) { animation-delay: 0.2s; }
      .wave-bar.playing:nth-child(4) { animation-delay: 0.3s; }
      .wave-bar.playing:nth-child(5) { animation-delay: 0.4s; }
      .wave-bar.playing:nth-child(6) { animation-delay: 0.5s; }
      .wave-bar.playing:nth-child(7) { animation-delay: 0.6s; }

      @keyframes waveAnimation {
        0%, 100% { transform: scaleY(1); }
        50% { transform: scaleY(1.6); }
      }

      .audio-progress-section {
        margin: 20px 0;
      }

      .audio-progress-bar {
        position: relative;
        height: 8px;
        background: #E5E7EB;
        border-radius: 4px;
        cursor: pointer;
        margin-bottom: 8px;
      }

      .audio-progress-fill {
        height: 100%;
        background: linear-gradient(90deg, #FF7A00, #FFB000);
        border-radius: 4px;
        transition: width 0.1s linear;
      }

      .audio-progress-handle {
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 16px;
        height: 16px;
        background: white;
        border: 3px solid #FF7A00;
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        cursor: grab;
        transition: transform 0.2s ease;
      }

      .audio-progress-handle:hover {
        transform: translate(-50%, -50%) scale(1.2);
      }

      .audio-time-display {
        display: flex;
        justify-content: space-between;
        font-size: 13px;
        color: #6B7280;
        font-weight: 600;
      }

      .audio-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 20px;
        margin: 24px 0;
      }

      .audio-btn-primary {
        min-width: 64px;
        min-height: 64px;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        border: none;
        background: linear-gradient(135deg, #FF7A00, #FFB000);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 6px 20px rgba(255,122,0,0.3);
      }

      .audio-btn-primary:hover {
        transform: scale(1.1);
        box-shadow: 0 8px 24px rgba(255,122,0,0.4);
      }

      .audio-btn-primary:active {
        transform: scale(1.05);
      }

      .audio-btn-secondary {
        min-width: 50px;
        min-height: 50px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: 2px solid #E5E7EB;
        background: white;
        color: #6B7280;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s ease;
      }

      .audio-btn-secondary:hover {
        border-color: #FF7A00;
        color: #FF7A00;
        background: #FFF7ED;
        transform: scale(1.05);
      }

      .audio-speed-controls {
        text-align: center;
        margin: 20px 0;
      }

      .audio-speed-label {
        font-size: 13px;
        font-weight: 600;
        color: #6B7280;
        margin-bottom: 10px;
      }

      .audio-speed-buttons {
        display: flex;
        gap: 8px;
        justify-content: center;
        flex-wrap: wrap;
      }

      .audio-speed-btn {
        min-width: 56px;
        min-height: 36px;
        padding: 8px 14px;
        border-radius: 18px;
        border: 2px solid #E5E7EB;
        background: white;
        color: #6B7280;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s ease;
      }

      .audio-speed-btn.active {
        background: linear-gradient(135deg, #FF7A00, #FFB000);
        color: white;
        border-color: #FF7A00;
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(255,122,0,0.3);
      }

      .audio-speed-btn:hover:not(.active) {
        border-color: #FF7A00;
        background: #FFF7ED;
      }

      .audio-download-link {
        display: block;
        text-align: center;
        margin-top: 16px;
        padding: 10px;
        background: white;
        border: 2px solid #E5E7EB;
        border-radius: 10px;
        color: #FF7A00;
        text-decoration: none;
        font-weight: 600;
        font-size: 14px;
        transition: all 0.2s ease;
      }

      .audio-download-link:hover {
        border-color: #FF7A00;
        background: #FFF7ED;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255,122,0,0.2);
      }

      /* Mobile-specific improvements */
      @media (max-width: 640px) {
        /* Ensure viewport is properly set */
        body {
          -webkit-text-size-adjust: 100%;
          -webkit-tap-highlight-color: rgba(255, 122, 0, 0.2);
        }

        /* Better touch targets on mobile */
        button {
          min-height: 44px;
          min-width: 44px;
        }

        input[type="text"],
        textarea {
          font-size: 16px; /* Prevents zoom on iOS */
        }

        /* Responsive audio player */
        .audio-player-card {
          padding: 16px;
          margin: 12px 0;
        }

        .waveform-container {
          height: 80px;
          padding: 12px;
          margin-bottom: 16px;
        }

        .waveform-animation {
          height: 56px;
          gap: 4px;
        }

        .wave-bar {
          width: 4px;
        }

        .audio-btn-primary {
          width: 56px;
          height: 56px;
        }

        .audio-btn-secondary {
          width: 56px;
          height: 40px;
          font-size: 13px;
        }

        .audio-speed-btn {
          padding: 6px 10px;
          font-size: 13px;
        }

        /* Better modal on mobile */
        .fixed.inset-0 {
          overflow-y: auto;
        }

        /* Prevent horizontal scroll */
        body, html {
          overflow-x: hidden;
          max-width: 100vw;
        }

        /* Fix chat input on mobile */
        .flex.gap-2 input[type="text"] {
          min-width: 0;
        }
      }

      /* iOS-specific fixes */
      @supports (-webkit-touch-callout: none) {
        /* Fix iOS Safari viewport issues */
        body {
          position: relative;
          min-height: -webkit-fill-available;
        }

        /* Fix iOS input zoom */
        input, textarea, select {
          font-size: 16px !important;
        }

        /* Fix iOS audio playback */
        audio {
          -webkit-playsinline: true;
          playsinline: true;
        }
      }

      /* Landscape mobile improvements */
      @media (max-width: 960px) and (orientation: landscape) {
        .max-h-\[400px\] {
          max-height: 200px !important;
        }

        .audio-player-card {
          padding: 12px;
        }

        .waveform-container {
          height: 60px;
          padding: 8px;
        }
      }

      /* Better scrolling on touch devices */
      @media (hover: none) and (pointer: coarse) {
        .overflow-y-auto {
          -webkit-overflow-scrolling: touch;
          scroll-behavior: smooth;
        }

        /* Larger touch targets for buttons */
        button:not(.text-3xl) {
          padding: 12px 16px;
        }
      }

      /* Loading Steps Animation */
      .loading-steps-container {
        background: linear-gradient(135deg, #fff8f0 0%, #fef3e8 100%);
        border: 2px solid #FFB366;
        border-radius: 16px;
        padding: 32px 24px;
        margin: 16px 0;
        animation: fadeInScale 0.4s ease-out;
      }

      @keyframes fadeInScale {
        from {
          opacity: 0;
          transform: scale(0.95);
        }
        to {
          opacity: 1;
          transform: scale(1);
        }
      }

      .loading-steps {
        display: flex;
        flex-direction: column;
        gap: 20px;
        margin-bottom: 20px;
      }

      .loading-step {
        display: flex;
        align-items: center;
        gap: 16px;
        position: relative;
        opacity: 0.4;
        transition: all 0.5s ease;
      }

      .loading-step.active {
        opacity: 1;
      }

      .loading-step.current .step-icon {
        animation: bounce 1s ease-in-out infinite;
      }

      @keyframes bounce {
        0%, 100% {
          transform: translateY(0) scale(1);
        }
        50% {
          transform: translateY(-8px) scale(1.1);
        }
      }

      .step-icon {
        font-size: 28px;
        min-width: 40px;
        text-align: center;
        transition: transform 0.3s ease;
      }

      .step-label {
        font-size: 16px;
        font-weight: 600;
        color: #374151;
        flex: 1;
      }

      .loading-step.current .step-label {
        color: #FF7A00;
        font-weight: 700;
      }

      .loading-message {
        text-align: center;
        padding: 16px;
        background: linear-gradient(135deg, rgba(255, 122, 0, 0.1) 0%, rgba(255, 149, 0, 0.05) 100%);
        border-radius: 12px;
        color: #6B7280;
        font-size: 14px;
        font-style: italic;
      }

      /* Mobile adjustments for loading steps */
      @media (max-width: 640px) {
        .loading-steps-container {
          padding: 24px 16px;
        }

        .loading-steps {
          gap: 16px;
        }

        .step-icon {
          font-size: 24px;
          min-width: 36px;
        }

        .step-label {
          font-size: 14px;
        }

        .loading-message {
          font-size: 13px;
          padding: 12px;
        }
      }
