/* General Body Styles */
body {
    font-family: 'Nunito', sans-serif;
    background-color: #f7faff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    display: flex; /* Centers the app-container vertically and horizontally */
    align-items: center; /* Vertical centering */
    justify-content: center; /* Horizontal centering */
    min-height: 100vh; /* Ensures body takes full viewport height */
    overflow-y: hidden; /* Allow scrolling if content exceeds viewport */
}

/* App Container - Mobile First (Base) */
#app-container {
    width: 100%; /* Take full width on small screens */
    max-width: 100%; /* New: Max width for mobile, reducing wasted space */
    min-height: 100vh; /* Allow height to adjust to content, but keep it substantial */
    max-height: 100vh; /* Prevent it from touching top/bottom on large mobiles */
    position: relative;
    background-color: #ffffff;
    border-radius: 0px; /* rounded-2xl */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); /* shadow-xl */
    overflow: hidden; /* Keep content within bounds, especially rounded corners */
    display: flex;
    flex-direction: column;
    box-shadow: none !important;
    border: 1px solid #313131;
    border-bottom: none;
}

/* Responsive adjustments for #app-container */
@media (min-width: 768px) { /* md breakpoint for tablets and small laptops */
    #app-container {
        max-width: 100%; /* Wider for desktop */
        height: 90vh; /* More fixed height for desktop layout, allowing internal scroll */
        max-height: 900px; /* Prevent it from getting too tall */
    }
}

@media (min-width: 1024px) { /* lg breakpoint for larger desktops */
    #app-container {
        max-width: 100%; /* Even wider for large monitors */
        height: 95vh;
        max-height: 1000px;
    }
}

/* App Screens */
.app-screen {
    width: 100%;
    height: 100%; /* Fill parent height */
    display: flex;
    flex-direction: column;
    overflow-y: scroll;
    /* Removed padding here as it's applied in HTML, will adjust in media queries */
}

/* Base padding for screens (p-8 equivalent) */
.app-screen:not(#auth-screen) {
    padding: 2rem; /* Matches p-8 */
    padding-top: 1em;
}
#auth-screen { /* Auth screen might have different internal padding */
    padding: 2rem;
    padding-top: 1em;
}


/* Transitions and Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}
.pop-in {
    animation: popIn 0.3s ease-out forwards;
}

@keyframes xpSplash {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(1.1); opacity: 0; }
}
.xp-splash {
    background-color: #f59e0b; /* amber-500 */
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: bold;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    animation: xpSplash 2.5s ease-out forwards;
    white-space: nowrap; /* Prevent text wrapping */
}

/* Duolingo-style Button */
.duolingo-btn {
    border-bottom-width: 4px;
    transition: all 0.1s ease-in-out;
}
.duolingo-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* Duolingo-style Interactive Card */
.duolingo-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.duolingo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Grammar Point Card Style */
.grammar-point-card {
    border: 2px solid #424448; /* gray-200 */
    border-radius: 1rem; /* rounded-2xl */
    padding: 1rem; /* p-4 */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.grammar-point-card:hover {
    border-color: #3b82f6; /* blue-500 */
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.grammar-point-card.selected {
    border-color: #3b82f6; /* blue-500 */
    border-width: 3px;
    background-color: #eff6ff; /* blue-50 */
}

/* Chat Bubbles */
.chat-bubble-user {
    background-color: #3b82f6; /* blue-500 */
    color: white;
}
.chat-bubble-partner {
    background-color: #dfdfdf; /* gray-200 */
    color: #1f2937; /* gray-800 */
}
/* Adjust chat bubble max-width for larger screens */
@media (min-width: 768px) {
    .chat-bubble-wrapper {
        max-width: 60%; /* Allow bubbles to be wider on larger screens */
    }
}


/* Turn Indicator Animation */
.turn-indicator.turn-indicator-active {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Star Rating Styles */
.rating-stars {
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: center;
}
.rating-stars input {
    display: none;
}
.rating-stars label {
    font-size: 2.5rem; /* 40px */
    color: #424448; /* gray-200 */
    cursor: pointer;
    transition: color 0.2s;
}
.rating-stars input:checked ~ label,
.rating-stars label:hover,
.rating-stars label:hover ~ label {
    color: #f59e0b; /* amber-500 */
}

/* Modal container styling */
.pop-in-container {
    display: none; /* Controlled by JS */
    position: fixed; /* Use fixed for modals to overlay entire viewport */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* bg-black bg-opacity-50 */
    z-index: 50; 
    display: flex; /* Ensure flex is set by JS when visible */
    align-items: center;
    justify-content: center;
}
/* Specific z-index for guest restriction modal to ensure it's on top */
#guest-restriction-modal {
    z-index: 100;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
    opacity: 0; /* Start hidden */
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Typing Indicator Dots */
.typing-dots {
    display: flex;
    align-items: center;
    height: 20px; /* Adjust height as needed */
}

.typing-dots span {
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background-color: #999; /* Dot color */
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
}

/* Connection Banner */
#connection-banner {
    display: none; /* Default to hidden, controlled by JS */
    position: absolute; /* Position relative to its parent (#app-container) */
    top: 0;
    left: 0;
    width: 100%;
    padding: 0.5rem 0.75rem; /* p-2 and p-3 converted to rem */
    font-size: 0.875rem; /* text-sm */
    background-color: #2563eb; /* blue-600 */
    color: #ffffff; /* text-white */
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); /* shadow-lg */
    align-items: center; /* Vertically align items in flex */
    justify-content: space-between; /* Space out content and close button */
    z-index: 50; /* Ensure it's above regular content but below modals */
    border-radius: 16px 16px 0 0; /* Match app-container top corners */
    box-sizing: border-box; /* Include padding in width calculation */
}

/* Adjust connection banner for larger screens */
@media (min-width: 768px) {
    #connection-banner {
        padding: 0.75rem 1rem; /* Slightly more padding */
        font-size: 1rem; /* Larger font */
    }
}
@media (min-width: 1024px) {
    #connection-banner {
        padding: 1rem 1.25rem;
        font-size: 1.125rem; /* Even larger font */
    }
}

/* Specific button style for logout button in mode selection header */
#mode-selection-screen #logout-btn {
    flex-shrink: 0; /* Prevent it from shrinking */
}

/* Improve general padding and spacing for larger screens */
@media (min-width: 768px) {
    .app-screen {
        padding: 2.5rem; /* from p-8 (2rem) to 2.5rem (p-10 equivalent) */
    }
    .text-4xl {
        font-size: 3.5rem; /* Larger for desktop h1 */
    }
    .text-lg {
        font-size: 1.25rem; /* Larger for inputs/buttons */
    }
    .text-xl {
        font-size: 1.5rem; /* Larger for card titles */
    }
    .text-2xl {
        font-size: 1.875rem; /* Larger for screen headers */
    }
    .text-3xl {
        font-size: 2.25rem; /* Larger for profile username */
    }
    .space-y-4 > *:not([hidden]) ~ *:not([hidden]) {
        margin-top: 1.5rem; /* Increase vertical spacing */
    }
    .space-x-4 > *:not([hidden]) ~ *:not([hidden]) {
        margin-left: 1.5rem; /* Increase horizontal spacing */
    }
    .w-10.h-10 { /* Icons */
        width: 2.75rem; 
        height: 2.75rem;
    }
    /* Adjust input field padding for larger screens */
    input[type="text"], input[type="password"], input[type="email"], textarea, select {
        padding: 1rem; /* from p-4 (1rem) to 1.25rem */
        font-size: 1.125rem; /* text-lg equivalent */
    }
    
    /* Specific adjustments for mode selection screen layout */
    #mode-selection-screen .flex.space-x-2 { /* Navigation icons container */
        gap: 1rem; /* Add gap between icons */
    }
    #mode-selection-screen .flex-grow.flex-col.justify-center.space-y-4 {
        justify-content: flex-start; /* Align content to top, not center */
        margin-top: 2rem;
        padding-top: 0em;
    }
}

/* Specific styling for the actual modal content box */
.pop-in-container > div {
    background-color: #ffffff; /* bg-white */
    border-radius: 1rem; /* rounded-2xl */
    padding: 1.5rem; /* p-6 */
    width: 91.666667%; /* w-11/12 */
    max-width: 448px; /* max-w-md */
    position: relative; /* For absolute positioned close button */
}

@media (min-width: 768px) {
    .pop-in-container > div {
        padding: 2rem; /* Even more padding for desktop modals */
        max-width: 600px; /* Wider modals on desktop */
    }
}

/* Ensure inner screen content is scrollable if needed */
.app-screen > .flex-grow {
    /* overflow-y: auto; */
    /* Add padding-bottom to the scrollable area to prevent content being cut off at the bottom,
       especially with the "Connect to Partner Directly" section */
    padding-bottom: 2rem; /* Adjust as needed */
}

#mode-selection-screen > .flex-grow{
    /* padding-top: 11em; */
    /* overflow: hidden; */
    height: 1200px;
}

/* Specific adjustment for active chats container on larger screens if it gets too wide */
@media (min-width: 768px) {
    #active-chats-container {
        /* Consider wrapping or increasing scroll area. For now, just ensure it handles overflow. */
        flex-wrap: wrap; /* Allow wrapping if items don't fit in single row */
        justify-content: start; /* Center active chat bubbles if they wrap */
        gap: 1.5rem; /* Space between wrapped items */
        padding-bottom: 0; /* Remove extra padding if wrapping */
    }
}

div#chat-messages {
    background: transparent;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}
.animate-wiggle {
    animation: wiggle 1s ease-in-out infinite;
}

div#conversation-timer {
    margin-left: 2em;
}

#topic-change-modal, #report-modal, #correction-modal{
    display: none;
}

/* =============================================== */
/* Styles for the Connected Partners Container    */
/* =============================================== */

/* * Main container for the section.
 * - Adds a light blue background.
 * - Adds padding and rounded corners for a modern card-like look.
*/
#connected-partners-section {
    background-color: #eff6ff; /* A light, pleasant blue (Tailwind blue-100) */
    padding: 1rem;
    border-radius: 1.25rem; /* A nice rounded corner */
    border: 1px solid #dbeafe; /* A slightly darker blue for the border */
}

/*
 * Styling for the "Connected Partners" title.
 * - Makes the text a darker, more readable blue to stand out.
*/
#connected-partners-section h3 {
    color: #1e3a8a; /* A rich, dark blue (Tailwind blue-800) */
    font-weight: 800; /* extra-bold */
    padding-left: 0.25rem;
}

/*
 * Styling for the placeholder text when no partners are connected.
 * - Ensures it's also a readable, muted blue color.
*/
#no-connected-partners {
    color: #3b82f6; /* A friendly, medium blue (Tailwind blue-500) */
    text-align: center;
    padding: 0.5rem 0;
    font-weight: 500;
}

/*
 * Styling for each individual partner item within the list.
 * - Changes the background from gray to a clean white for contrast.
 * - Adds a subtle inner shadow to give it depth.
*/
#connected-partners-container > div {
    background-color: #FFFFFF;
    box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    /* Padding and flex are handled by existing Tailwind classes, but we ensure them */
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/*
 * Styling for the partner's name text.
*/
#connected-partners-container .font-bold {
    color: #1e40af; /* A dark, readable blue (Tailwind blue-700) */
}

/*
 * Styling for the "Waiting for host..." text.
 * - Makes it a muted, italicized gray-blue.
*/
#connected-partners-container .text-gray-500 {
    color: #6b7280; /* A neutral gray (Tailwind gray-500) */
    font-style: italic;
    font-weight: 500;
}

/* The .start-direct-chat-btn is already styled well by its Tailwind classes, so no override is needed. */

div#direct-chat-selection-banner {
    margin-top: 5em;
}

/* General App Style */
#mode-selection-screen {
    background: #141213; /* Dark background for the app container */
}

/* Make text on mode screen white/light gray for dark background */
#mode-selection-screen, #mode-selection-screen h3, #mode-selection-screen p {
    color: #EAEAEA;
}
#mode-selection-screen .text-gray-500 {
    color: #9CA3AF;
}
#mode-selection-screen .text-gray-600 {
    color: #D1D5DB;
}
#mode-selection-screen .text-gray-300 {
    color: #D1D5DB;
}
#mode-selection-screen .border-gray-700 {
    border-color: #4A5568;
}

/* --- NEW CARD STYLES --- */

/* Large Card Style (Applied to Topic Mode) */
#select-topic-mode.duolingo-card-large {
    background-color: #ddc1ff; /* Light Purple */
    border-radius: 1.5rem; /* 24px */
    padding: 1.5rem; /* 24px */
    min-height: 250px;
    transition: transform 0.2s ease-in-out;
}
#select-topic-mode.duolingo-card-large:hover {
    transform: scale(1.02);
}
#select-topic-mode.duolingo-card-large h3, #select-topic-mode.duolingo-card-large p {
    color: #000;
}

/* Small Card Styles (For the grid) */
.duolingo-card-small {
    border-radius: 1.5rem; /* 24px */
    padding: 1rem; /* 16px */
    min-height: 180px;
    transition: transform 0.2s ease-in-out;
}
.duolingo-card-small:hover {
    transform: scale(1.03);
}
.duolingo-card-small h4, .duolingo-card-small p, .duolingo-card-small span {
     color: #000;
}

/* Specific colors for small cards */
#select-grammar-mode.duolingo-card-small {
    background-color: #F8E71C; /* Yellow */
}
#select-local-mode.duolingo-card-small {
    background-color: #7ED321; /* Green */
}
#select-bot-mode.duolingo-card-small {
    background-color: #50E3C2; /* Teal */
}
#assess-level-card.duolingo-card-small {
    background-color: #4A90E2; /* Blue */
}

/* Styles for top navigation icons */
.nav-icon-btn {
    width: 2.5rem; /* 40px */
    height: 2.5rem; /* 40px */
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffffe0;
    transition: background-color 0.2s;
}
.nav-icon-btn:hover {
    background-color: #4A5568; /* Lighter gray on hover */
}

.duolingo-card-small h4, .duolingo-card-small p{
    color: #000000 !important;
}

.proAvatarContainer{
    width: 100px;
}

#pro-button{
    overflow: hidden;
    max-height: 50px;
    background: #132b45;
    border: 1px solid #1e7393;
}

:root {
    /* I've defined a variable for the primary orange color from your design. */
    --brand-orange: #FF6B2C; 
  }
  
  /* --- Subscription Page Specific Styles --- */
  
  #subscription-screen {
      /* A dark charcoal background to match the mockup */
      background-color: #1F1F1F; 
  }
  
  .bg-brand-orange {
      background-color: var(--brand-orange);
  }
  
  .border-brand-orange {
      border-color: var(--brand-orange);
  }
  
  .text-brand-orange {
      color: var(--brand-orange);
  }
  
  /* The main orange container at the top */
  .subscription-hero {
      background-color: var(--brand-orange);
      box-shadow: 0px 10px 30px -5px rgba(255, 107, 44, 0.4);
  }
  
  /* The individual plan selection boxes */
  .subscription-plan {
      background-color: #2a2a2e; /* A slightly lighter dark gray for contrast */
      border-width: 2px;
      border-color: #4b5563; /* Default border color (gray-600) */
      transition: all 0.3s ease-in-out;
  }
  
  /* The style for the currently selected plan */
  .subscription-plan.selected {
      border-color: var(--brand-orange);
      background-color: #3a302b; /* A subtle, dark orange-tinted background */
      transform: scale(1.03);
  }
  
  /* The radio-button-like circle for selection */
  .plan-selector {
      width: 24px;
      height: 24px;
      border: 2px solid #6b7280; /* gray-500 */
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: border-color 0.3s ease;
  }
  
  .subscription-plan.selected .plan-selector {
      border-color: var(--brand-orange);
  }
  
  /* The inner orange dot of the selected plan */
  .plan-selector .selected-indicator {
      width: 14px;
      height: 14px;
      background-color: var(--brand-orange);
      border-radius: 50%;
      transform: scale(0);
      transition: transform 0.2s ease-in-out;
  }
  
  .subscription-plan.selected .selected-indicator {
      transform: scale(1);
  }

  .subscription-hero{
    padding-top:2em !important;
  }
/* 
  #chat-screen{
    background: #141213;
  } */
/* 
  div#chat-messages {
    background: #2b2b2b;
}

.chat-bubble-wrapper{
    background: #eb7828;
}

#chat-screen .p-4{
    background-color: rgb(35 36 45) !important;
} */

/*
 Styles for visually indicating a locked premium feature.
 Add this to your main style.css file.
*/

.locked-feature {
    opacity: 0.65;
    position: relative;
    cursor: pointer; /* Keeps it clickable to show the upgrade modal */
    transition: opacity 0.2s ease-in-out;
  }
  
  .locked-feature:hover {
      opacity: 0.8;
  }
  
  /* Add a crown icon to the top right of the locked feature card */
  .locked-feature::after {
    content: '🔒';
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 24px;
    color: #FBBF24; /* Tailwind's amber-400 color */
    z-index: 10;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    pointer-events: none; /* Make sure the icon doesn't block clicks */
  }
  
  /* ===== Custom Scrollbar CSS ===== */

/* For Webkit-based browsers (Chrome, Safari, Edge, etc.) */
* ::-webkit-scrollbar {
    width: 10px;
  }
  
  /* The track (the background of the scrollbar) */
  * ::-webkit-scrollbar-track {
    background: #2d2d2d; /* A dark gray, slightly lighter than the body */
    border-radius: 10px;
  }
  
  /* The draggable scrolling handle */
  * ::-webkit-scrollbar-thumb {
    background: #555; /* A medium gray for the handle */
    border-radius: 10px;
    border: 2px solid #2d2d2d; /* Creates a nice padding effect */
  }
  
  /* Handle on hover */
  * ::-webkit-scrollbar-thumb:hover {
    background: #6a6a6a; /* Lighter gray on hover for better UX */
  }
  
  /* For Firefox */
  *.overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: #555 #2d2d2d; /* thumb color track color */
  }

  /* Add this to your main CSS file */
.pinned-chat-badge {
    position: absolute;
    top: -1px;
    right: 10px;
    background-color: #60a5fa; /* A nice blue color */
    color: white;
    padding: 2px 8px;
    border-radius: 0 0 0.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* --- Styles for the AI Summary --- */
.summary-section-card {
    background-color: white;
    border-radius: 0.75rem; /* 12px */
    border: 1px solid #424448; /* cool-gray-200 */
    padding: 1rem; /* 16px */
    margin-bottom: 1rem; /* 16px */
    transition: all 0.3s ease-in-out;
}

.summary-progress-bar {
    display: flex;
    height: 0.75rem; /* 12px */
    border-radius: 9999px;
    overflow: hidden;
    background-color: #424448; /* cool-gray-200 */
}

.summary-progress-user {
    background-color: #3b82f6; /* blue-500 */
    transition: width 0.5s ease-in-out;
}

.summary-progress-partner {
    background-color: #f97316; /* orange-500 */
    transition: width 0.5s ease-in-out;
}

/* For the fade-in animation */
.summary-fade-in {
    animation: fadeIn 0.5s ease-in-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#summary-container{
    /* position: absolute;
    top: 0;
    max-height: 100%;
    overflow-y: scroll; */
}

/* In css/style.css */

/* New Leaderboard Card Styles */
.leaderboard-item {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

#leaderboard-list .leaderboard-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* In css/style.css */

/* --- START: Replace old tooltip styles with this block --- */

#custom-tooltip {
    /* Core Styling */
    position: absolute; /* Changed from 'absolute' to 'fixed' for smoother viewport positioning */
    z-index: 100;
    padding: 12px 16px;
    font-size: 0.875rem; /* 14px */
    font-weight: 500;
    border-radius: 12px;
    max-width: 250px;
    
    /* Modern "Frosted Glass" Effect */
    background-color: rgba(30, 41, 59, 0.75); /* semi-transparent slate-800 */
    -webkit-backdrop-filter: blur(8px); /* Safari */
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Visibility & Smooth Animation Control */
    opacity: 0;
    pointer-events: none; /* Allows mouse to pass through to elements underneath */
    /* We now transition transform for smooth movement */
    transition: opacity 0.2s ease-in-out, transform 0.15s ease-out; 
}

#custom-tooltip.visible {
    opacity: 1;
}

/* Typography and Layout inside the tooltip */
#custom-tooltip .tooltip-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px; /* Increased gap for better spacing */
    align-items: center;
}

#custom-tooltip .tooltip-grid .lucide {
    color: #a78bfa; /* A nice violet color for icons */
    width: 18px;
    height: 18px;
}

#custom-tooltip .tooltip-grid span {
    color: #cbd5e1; /* Lighter text color (slate-300) */
}

#custom-tooltip .tooltip-grid span strong {
    color: #ffffff; /* White for emphasis */
    font-weight: 600;
}

/* --- END of new tooltip style block --- */

/* --- Advanced Leaderboard Card Styles --- */

.lb-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    border-width: 1px;
    transition: all 0.2s ease-in-out;
}

.lb-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border-color: #3b82f6; /* Blue-500 */
}

.lb-card-rank {
    font-size: 1.125rem;
    font-weight: 700;
    color: #6b7280; /* Gray-500 */
    width: 2.5rem;
    text-align: center;
}

.lb-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    object-fit: cover;
    border: 2px solid #424448; /* Gray-200 */
}

.lb-card-pro-badge {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: white;
    background-image: linear-gradient(to right, #4f46e5, #7c3aed); /* Indigo to Purple */
    padding: 2px 6px;
    border-radius: 9999px;
    margin-left: 8px;
    line-height: 1;
}

.lb-card .xp-progress-bar {
    background-color: #424448; /* Gray-200 */
    border-radius: 9999px;
    height: 8px;
    width: 100%;
    overflow: hidden;
    margin-top: 4px;
}

.lb-card .xp-progress-fill {
    background-color: #3b82f6; /* Blue-500 */
    height: 100%;
    border-radius: 9999px;
    transition: width 0.5s ease-out;
}

.lb-card-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.lb-card-stat-item {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Star Rating Styles */
.star-rating-display {
    display: flex;
    align-items: center;
}
.star-rating-display .lucide {
    width: 16px;
    height: 16px;
    color: #f59e0b; /* Amber-500 */
}

/* In css/style.css */

/* --- NEW: Advanced Podium Design --- */
#leaderboard-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Aligns users to the bottom of their stands */
    gap: 4px;
    padding: 2rem 1rem 0 1rem;
    position: relative;
    min-height: 280px; /* Give the podium area a fixed height */
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30%;
}

.podium-user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px; /* Space between user info and the stand */
}

.podium-stand {
    width: 100%;
    background-color: #424448; /* gray-200 */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    justify-content: center;
    font-weight: 800;
    color: #4b5563; /* gray-600 */
    font-size: 2rem;
    padding-top: 8px;
    box-shadow: inset 0 4px 6px rgba(0,0,0,0.1);
}

.podium-stand--1 {
    height: 120px;
    background-image: linear-gradient(to top, #fbbf24, #fde68a); /* amber-400 to amber-200 */
}
.podium-stand--2 {
    height: 90px;
    background-image: linear-gradient(to top, #9ca3af, #d1d5db); /* gray-400 to gray-300 */
}
.podium-stand--3 {
    height: 60px;
    background-image: linear-gradient(to top, #fb923c, #fdba74); /* orange-400 to orange-300 */
}

/* In css/style.css */

/* --- NEW: Advanced Profile Page Design --- */

.profile-header-banner {
    background: linear-gradient(to right, #43447a, #2c2d4e);
    height: 120px;
    position: relative;
    display: none;
}

.profile-avatar-container {
    position: absolute;
    bottom: -48px; /* Half of avatar height */
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid white;
    background-color: white;
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.profile-main-content {
    padding-top: 11px; /* Space for the overlapping avatar */
}

/* Stats Grid */
.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}



.profile-stat-card .lucide {
    margin: 0 auto 0.5rem auto;
    color: #4f46e5; /* indigo-600 */
}

/* Activity Heatmap */
.activity-heatmap {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    grid-auto-flow: column;
    gap: 3px;
    margin-top: 1rem;
}

.heatmap-day {
    width: 12px;
    height: 12px;
    background-color: #ebedf0; /* gray-200 */
    border-radius: 2px;
}
.heatmap-day[data-level="1"] { background-color: #9be9a8; }
.heatmap-day[data-level="2"] { background-color: #40c463; }
.heatmap-day[data-level="3"] { background-color: #30a14e; }
.heatmap-day[data-level="4"] { background-color: #216e39; }

/* In css/style.css */

/* --- NEW: Advanced Profile Page Re-Haul Styles --- */

.profile-stat-card .proficiency-meter {
    display: flex;
    gap: 4px;
    height: 10px;
    width: 100%;
}
.profile-stat-card .proficiency-segment {
    flex-grow: 1;
    background-color: #424448; /* gray-200 */
    border-radius: 4px;
}
.profile-stat-card .proficiency-segment.active {
    background-color: #4f46e5; /* indigo-600 */
}

.achievements-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}
.achievement-badge {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background-color: #f3f4f6; /* gray-100 */
    border-radius: 9999px;
    border: 2px solid #424448; /* gray-200 */
    color: #6b7280; /* gray-500 */
    cursor: pointer;
    transition: all 0.2s ease-out;
}
.achievement-badge.unlocked {
    background-color: #fefce8; /* yellow-50 */
    border-color: #facc15; /* yellow-400 */
    color: #ca8a04; /* yellow-600 */
}
.achievement-badge:hover {
    transform: scale(1.1);
}

.activity-feed-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    transition: background-color 0.2s;
}
.activity-feed-item:hover {
    background-color: #f9fafb; /* gray-50 */
}

p.text-xs.text-gray-500.font-semibold.text-right.mt-1 {
    text-align: left;
}

.profile-main-content{
    padding-top: 0 !important;
}

/* In css/style.css */

/* --- NEW: Advanced Heatmap Styling --- */
.heatmap-container {
    display: flex;
    gap: 6px;
}

.heatmap-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 9px;
    color: #6b7280; /* gray-500 */
    padding-top: 20px; /* Align with top of squares */
}

.heatmap-main {
    width: 100%;
    overflow-x: auto; /* This fixes the overflow issue */
    overflow-y: hidden;
    padding-bottom: 8px; /* Space for scrollbar */
}

.heatmap-months {
    display: flex;
    font-size: 10px;
    color: #6b7280; /* gray-500 */
    margin-bottom: 4px;
    padding-left: 20px; /* Align with first column */
}
.heatmap-months > div {
    min-width: 60px; /* Approx 4 weeks width */
}

#vocabulary-screen{
    overflow-y: scroll;
}

/* css/style.css or inside a <style> tag */

/* --- Quiz Effect Animations --- */

/* Shake animation for incorrect answers */
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
  }
  .shake-animation {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
  }
  
  /* Countdown animation for quiz start */
  @keyframes countdown-pop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
  }
  @keyframes countdown-fade {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
  }
  .countdown-container {
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: rgba(255, 255, 255, 0.7);
      z-index: 100;
  }
  .countdown-text {
      font-size: 8rem;
      font-weight: 800;
      color: #4c51bf;
      animation: countdown-pop 0.3s ease-out, countdown-fade 0.3s ease-in 0.5s;
  }
  
  /* Particle effect for correct answers */
  .particle {
      position: absolute;
      border-radius: 50%;
      pointer-events: none;
      z-index: 200;
  }
  
  /* Combo counter effect */
  .combo-counter {
      position: absolute;
      font-size: 2rem;
      font-weight: 800;
      color: #f59e0b; /* Amber-500 */
      text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
      pointer-events: none;
      z-index: 200;
      transform: translateX(-50%);
  }
  
  /* Results screen pop-in effect */
  .results-stat-card {
      opacity: 0;
      transform: scale(0.8);
      transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  }
  .results-stat-card.pop-in {
      opacity: 1;
      transform: scale(1);
  }
  
  /* Confetti for perfect scores */
  @keyframes confetti-fall {
      0% { transform: translateY(-100px) rotateZ(0deg); opacity: 1; }
      100% { transform: translateY(100vh) rotateZ(360deg); opacity: 0; }
  }
  .confetti {
      position: absolute;
      top: 0;
      width: 10px;
      height: 10px;
      opacity: 0;
      animation: confetti-fall 3s linear infinite;
  }

  /* In css/style.css */

/* --- ADVANCED QUIZ EFFECTS --- */

/* For Juicy Button Feedback */
.duolingo-btn:active, .quiz-option:active, .flashcard-feedback:active {
    transform: scale(0.96);
    filter: brightness(0.95);
    transition: transform 0.05s;
}

/* 3D Card Flip Animation */
.quiz-card-container {
    perspective: 1000px;
}
.quiz-card {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}
.quiz-card.is-flipped {
    transform: rotateY(180deg);
}
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.card-back {
    transform: rotateY(180deg);
}

/* "SSR" Effect for getting a difficult word right */
@keyframes ssr-flash {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 0.6; }
    100% { opacity: 0; transform: scale(1.5); }
}
.ssr-effect-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle, rgba(255,229,153,0) 0%, rgba(252,211,77,0.8) 40%, rgba(245,158,11,0) 80%);
    z-index: 200;
    pointer-events: none;
    animation: ssr-flash 0.8s ease-out forwards;
}

/* LEVEL UP Animation */
@keyframes level-up-pop {
  0% { transform: translateY(50px) scale(0.5); opacity: 0; }
  50% { transform: translateY(0) scale(1.2); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes level-up-fade {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-50px); }
}
.level-up-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}
.level-up-text {
    font-size: 5rem;
    font-weight: 900;
    color: #f59e0b; /* Amber 500 */
    text-shadow: 3px 3px 0 #fff, -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 4px 4px 0px rgba(0,0,0,0.2);
    animation: level-up-pop 0.5s ease-out, level-up-fade 0.5s ease-in 1.5s;
}

.summary-fade-in.bg-slate-50.p-4.rounded-t-lg.overflow-y-auto.h-full {
    padding-bottom: 7em;
}

.mt-4 {
    /* z-index: 12; */
}

#bottom-dock {
    border-top: 1px solid #4a5568; /* a subtle top border */
    transition: transform 0.3s ease-in-out;
    border-radius: 20px;
    width: 350px;
    height: 50px;
    margin: 0 auto;
    margin-bottom: 1em;
}

.dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #a0aec0; /* gray-400 */
    font-size: 0.75rem; /* 12px */
    font-weight: 600;
    width: 20px;
    height: 20px;
    transition: all 0.2s ease-in-out;
    border-radius: 0.75rem; /* 12px */
    margin-top: 6px;
}

.dock-btn.active {
    color: #f6e05e; /* yellow-300 */
}

.dock-btn.active i {
    transform: scale(1.1);
}

.dock-btn span {
    margin-top: 4px;
}

/* Animation for the "More Options" menu */
.pop-up-from-bottom {
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

div#bottom-dock {
    background: #1f2123;
}

/* Default style for ALL icons inside the dock */
.dock-btn svg {
    width: 28px;
    height: 28px;
    stroke: #4e5256;  /* Set a consistent dark gray OUTLINE for all inactive icons */
    fill: none;       /* Ensure they are NOT filled by default */
    stroke-width: 2;
    transition: all 0.2s ease-in-out;
}



/* --- THE FIX: Active State with Higher Specificity --- */
/* This rule is more specific and will correctly override the defaults. */
.dock-btn.active {
    color: #f6e05e; /* Change text color to active yellow */
}

/* We target the SVG inside the active button */
.dock-btn.active svg {
    stroke: #f6e05e;    /* ALSO change the stroke to yellow for a solid look */
}

/* Set the background for the auth screen container */
#auth-screen {
    background-color: #1a1a1a; /* A very dark charcoal background */
    /* This ensures the content inside is centered vertically */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Style for the text-based inputs */
.auth-input-dark {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1.1rem;
    color: #ffffff;
    background-color: #1f2937; /* Dark blue-gray */
    border: 2px solid #374151; /* Slightly lighter gray border */
    border-radius: 0.75rem; /* 12px */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Style for the inputs when they are focused (clicked on) */
.auth-input-dark:focus {
    outline: none;
    border-color: #facc15; /* Bright yellow border on focus */
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.3); /* Soft yellow glow */
}

/* Style for the main action button (Login/Create Account) */
.auth-button-main {
    width: 100%;
    padding: 1rem;
    border-radius: 0.75rem; /* 12px */
    border: none;
    color: #111827; /* Dark text for contrast on yellow button */
    background-color: #facc15; /* Vibrant yellow */
    font-weight: 700; /* Bold */
    font-size: 1.1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.15s ease-out, background-color 0.15s ease-out;
    transform-origin: center;
}

/* Add a hover effect to make the button feel interactive */
.auth-button-main:hover {
    background-color: #fde047; /* Slightly lighter yellow on hover */
    transform: scale(1.03); /* Gently grows on hover */
}
/* === EVEN BETTER STYLING (ADD THIS TO css/style.css) === */
/* Add this to the bottom of your css/style.css file */

.mode-list-item {
    display: flex;
    align-items: center;
    padding: 0.75rem; /* 12px */
    border-radius: 1rem; /* 16px */
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

.mode-list-icon-wrapper {
    width: 4rem;  /* 64px */
    height: 4rem; /* 64px */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem; /* 12px */
    flex-shrink: 0;
    margin-right: 1rem; /* 16px */
}

.mode-list-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease-in-out;
}

.mode-list-item:hover .mode-list-icon {
    transform: scale(1.1);
}

.mode-list-text {
    flex-grow: 1;
}

.mode-list-title {
    font-size: 1.125rem; /* 18px */
    font-weight: 800; /* extra-bold */
    color: #E5E7EB; /* gray-200 */
}

.mode-list-description {
    font-size: 0.875rem; /* 14px */
    color: #9CA3AF; /* gray-400 */
}

.mode-list-arrow {
    width: 1.25rem; /* 20px */
    height: 1.25rem; /* 20px */
    color: #6B7280; /* gray-500 */
    margin-left: 1rem; /* 16px */
    flex-shrink: 0;
    transition: transform 0.2s ease-in-out, color 0.2s ease-in-out;
}

.mode-list-item:hover .mode-list-arrow {
    transform: translateX(4px);
    color: #E5E7EB; /* gray-200 */
}

/* --- 1. Base Styles for the Enhanced List Item --- */
.mode-list-item {
    /* Use a darker base and a gradient for a lighting effect */
    background-color: #1f2228; /* A dark, neutral base */
    background-image: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.08), transparent);
    
    /* A subtle inner shadow gives a top-lit 3D effect */
    box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.05);

    /* We'll use a pseudo-element for the border to allow for gradients */
    border: none; 
    position: relative; /* Needed for the pseudo-element border */
    z-index: 1;
}

/* --- 2. The Gradient Border Effect --- */
.mode-list-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 1rem; /* Must match the parent's border-radius */
    padding: 1px; /* This controls the "border" thickness */
    
    /* The magic: A gradient border that uses the --glow-color variable */
    background: linear-gradient(135deg, var(--glow-color, #888), #374151); /* Default from color to gray */
    
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: -1;
    opacity: 0.4;
    transition: opacity 0.3s ease-in-out;
}

/* Add this to css/style.css */
.view-toggle-btn {
    padding: 0.375rem; /* 6px */
    border-radius: 0.375rem; /* 6px */
    color: #9ca3af; /* gray-400 */
    transition: all 0.2s ease-in-out;
}
.view-toggle-btn:hover {
    color: #fff;
    background-color: #4b5563; /* gray-600 */
}
.view-toggle-btn.active {
    background-color: #3b82f6; /* blue-500 */
    color: #fff;
}

/*
================================
New Chat Screen Styles
================================
*/

/* --- Main Chat Screen --- */
#chat-screen {
    background-color: #1C1C1E;
}

/* --- Sticky Prompt Header --- */
#ai-question {
    color: #EAEAEA;
    font-size: 2rem;
    line-height: 1.25;
    font-weight: 700;
}

/* --- Message Bubbles --- */
#chat-messages .chat-bubble-user {
    background-color: #007AFF; /* A vibrant blue for user messages */
    color: white;
    border-radius: 1.25rem;
}

#chat-messages .chat-bubble-partner {
    background-color: #3A3A3C; /* Dark grey for partner messages */
    color: white;
    border-radius: 1.25rem;
}

/* --- Creative Correction Bubble Style --- */
.correction-bubble {
    background-color: #333;
    border-left: 4px solid #FDBB2D;
    padding: 1rem;
    border-radius: 0.75rem;
    margin: 1rem auto;
    max-width: 95%;
    width: 100%;
}

.correction-bubble .correction-header {
    font-weight: bold;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    color: #FDBB2D;
    font-size: 0.9rem;
}

.correction-bubble .correction-diff-text {
    font-size: 1.1rem;
    line-height: 1.6;
}

.correction-diff-text .diff-added {
    background-color: rgba(4, 120, 87, 0.4); /* Transparent green */
    color: #A7F3D0;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 4px;
}

.correction-diff-text .diff-removed {
    background-color: rgba(153, 27, 27, 0.4); /* Transparent red */
    color: #FECACA;
    text-decoration: line-through;
    padding: 2px 4px;
    border-radius: 4px;
}

/* --- Typing Indicator --- */
#typing-indicator .typing-dots span {
    background-color: #8E8E93;
}

/* --- Bottom Input Area --- */
#message-input {
    background-color: transparent;
    border: none;
    color: white;
}

#message-input:focus {
    outline: none;
    box-shadow: none;
    ring-offset-width: 0;
}

#message-input::placeholder {
    color: #8E8E93;
}

#send-message-btn {
    background-color: #FDBB2D;
    color: #1C1C1E; /* Dark icon for contrast */
    transition: background-color 0.2s;
}

#send-message-btn:hover {
    background-color: #ffca48;
}

/* --- Turn Indicator (Hidden but styled for JS compatibility) --- */
#turn-indicator {
    display: none; /* We are hiding this in favor of the new design */
}



/*
================================
New "Background-less" Message Styles
================================
*/

/* --- Remove the bubble background and padding --- */
#chat-messages .chat-bubble-user,
#chat-messages .chat-bubble-partner {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    max-width: 100%; /* Allow messages to take more width */
    align-items: flex-start; /* Align icon to the top */
}

/* Position the message text and action buttons */
#chat-messages .chat-bubble-partner {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Space between text and icon */
}

/* --- Style the message text itself --- */
#chat-messages .chat-bubble-wrapper p.break-words {
    font-size: 1.4rem;  /* Larger font size */
    line-height: 1.5;   /* More space between lines */
    font-weight: 600;   /* Bolder text */
    flex-grow: 1;       /* Allow text to take up space */
}

/* User's sent message text is the accent color */
#chat-messages .chat-bubble-user p.break-words {
    color: #FDBB2D; 
    text-align: right; /* Align user text to the right */
}

/* Partner's received message text is white */
#chat-messages .chat-bubble-partner p.break-words {
    color: #EAEAEA;
}

/* --- Reposition and style action buttons (Translate/Speak) --- */
#chat-messages .message-actions {
    margin-top: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column; /* Stack icons vertically if needed */
    gap: 0.5rem;
}

#chat-messages .message-actions .translate-message-btn,
#chat-messages .message-actions .speak-message-btn {
    color: #8E8E93; /* Subtle grey for icons */
    transition: color 0.2s ease;
}

#chat-messages .message-actions .translate-message-btn:hover,
#chat-messages .message-actions .speak-message-btn:hover {
    color: #FFFFFF; /* Bright white on hover */
}

/* --- Style for System Messages (e.g., "Time's up!") --- */
span.bg-gray-200.text-gray-600.text-xs.font-semibold.px-3.py-1.rounded-full {
    background: #333333;
    color: #ffc32a;
}

button.speak-message-btn.text-purple-500.hover\:text-purple-700, svg.lucide.lucide-volume-2.w-5.h-5 {
    margin: 0 !important;
    color: #fff !important;
}

svg.lucide.lucide-languages.w-5.h-5, svg.lucide.lucide-volume-2.w-5.h-5 {
    color: #fff;
}

/* --- New styles for translated text layout --- */

/* This turns the main message container into a vertical layout */
#chat-messages .chat-bubble-partner {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Aligns content to the left */
    gap: 0.5rem; /* Adds a small space between the original message and the translation */
}

/* This new class keeps the original message and its icons on the same line */
.message-line {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
}

/* This is the style for the translated text that appears underneath */
.translation-text {
    color: #8E8E93; /* A lighter grey for the translation */
    font-size: 1.1rem; /* Slightly smaller font for the translation */
    font-weight: 500;
    font-style: italic;
    max-width: 100%;
}

.button.speak-message-btn{
    margin-right: 0 !important;
    margin-left: 0 !important;
}

.space-x-2 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 0;
    margin-right: 0 !important;
    margin-left: 0 !important;
}

#ai-question {
    font-size: 2rem;
}

/* Override for mobile screens (<= 500px) */
@media only screen and (max-width: 500px) {
    #ai-question {
        font-size: 22px;
    }
}

.sticky.top-0.bg-gradient-to-b.from-\[\#1C1C1E\].to-transparent.p-6.pt-2.z-10 {
    border-bottom: 1px solid #3f3f3f;
}

svg.lucide.lucide-arrow-left {
    width: 17px;
    color: #fff;
}

/*
================================
New Homepage Header & Lists Styles
================================
*/

/* --- New Simplified Header --- */
.home-header {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
.home-header:hover {
    background-color: #2C2C2E;
}
.home-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #555;
}
.home-header-text {
    margin-left: 0.75rem;
}
.home-header-text #user-name-display {
    font-size: 1.125rem;
    font-weight: 700;
    color: #FFF;
}
.home-header-text #user-status-display {
    font-size: 0.75rem;
    font-weight: 700;
    color: #FDBB2D; /* Gold accent for PRO */
    text-transform: uppercase;
}
.home-header-stats {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #AEAEB2;
}
.home-header-stats #streak-container,
.home-header-stats #xp-container {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 700;
}
.home-header-stats .lucide {
    width: 20px;
    height: 20px;
}
.home-header-stats #streak-container { color: #FDBB2D; }
.home-header-stats #xp-container { color: #5E5CE6; }
.home-header-stats #admin-btn { color: #AEAEB2; }

/* --- Section Titles --- */
.home-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #EAEAEA;
    margin-bottom: 0.5rem;
}

/* --- Active Chats --- */
#active-chats-container .active-chat-bubble img {
    border: 3px solid #0A84FF;
    padding: 2px;
}
#active-chats-container .active-chat-bubble p {
    color: #EAEAEA;
    font-weight: 500;
}

/* --- New Learner Card --- */
.learner-card {
    background-color: #1C1C1E;
    border: 1px solid #3A3A3C;
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease-in-out;
}
.learner-card:hover {
    transform: translateY(-2px);
    border-color: #555;
}
.learner-card-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    flex-grow: 1;
    min-width: 0;
}
.learner-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.learner-card-info {
    min-width: 0;
}
.learner-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.learner-card-langs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 2px;
}
.learner-card-langs img {
    width: 20px;
    height: 15px;
    border-radius: 2px;
}
.learner-card-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 1rem;
}
.learner-card-level {
    background-color: #5856D6; /* Purple accent */
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    border: 2px solid #1C1C1E;
    box-shadow: 0 0 0 2px #5856D6;
}
.learner-card .hub-connect-btn {
    background-color: #34C759; /* Green accent */
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transform: scale(1);
    transition: transform 0.2s ease;
}
.learner-card .hub-connect-btn:hover {
    transform: scale(1.1);
}

.recent-learners-container{
    margin-bottom: 1em;
    margin-top: -1em;
}

#user-name-display svg{
    position: relative;
    top: 13px;
}

/*
================================
New Active Chat Card Styles
================================
*/

/* Add horizontal padding to the scrolling container */
#active-chats-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    gap: 1em;
}

.active-chat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 240px;
    height: 140px;
    background: #2C2C2E;
    border-radius: 1.25rem;
    padding: 1rem;
    border: 1px solid #3A3A3C;
    flex-shrink: 0;
    transition: all 0.2s ease-in-out;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.active-chat-card:hover {
    transform: translateY(-4px);
    border-color: #555;
}

/* Colored accent border at the top */
.active-chat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: #5856D6; /* Default color */
}
.active-chat-card.mode-topic::before {
    background-color: #0A84FF; /* Blue for Topic */
}
.active-chat-card.mode-grammar::before {
    background-color: #5856D6; /* Purple for Grammar */
}

/* Card content styling */
.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #444;
}
.card-partner-info {
    min-width: 0;
}
.partner-name {
    font-weight: 700;
    color: #FFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topic-name {
    font-size: 0.8rem;
    color: #AEAEB2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background-color: #FF453A;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1C1C1E;
}

.card-body {
    padding: 0.25rem 0;
}
.last-message {
    font-style: italic;
    color: #EAEAEA;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-footer {
    text-align: right;
}
.timestamp {
    font-size: 0.75rem;
    font-weight: 500;
    color: #8E8E93;
}

svg.lucide.lucide-shield-check{
    stroke: #fff;
}

/* Styling for the last message sender's name */
.last-sender-name {
    display: block;
    font-size: 0.75rem;
    color: #AEAEB2;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hub-connect-btn .lucide {
    pointer-events: none;
}

p.text-4xl.font-bold.text-gray-800.break-words, .p.text-4xl.font-bold.break-words {
    font-size: 20px;
    text-align: center;
    line-height: 24px;
}

.app-screen:not(#chat-screen) svg.lucide-arrow-left {
    color: #333 !important;
}

.profile-stat-card {
    background-color: white;
    border-radius: 0.75rem; /* 12px */
    border: 1px solid rgb(67 66 66 / 16%) !important;
    padding: 1rem;
    text-align: center;
}

/*
================================
Auto-Hide Bottom Dock Styles
================================
*/
#bottom-dock {
    /* Establishes the default, visible state and the transition effect */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

#bottom-dock.hidden-by-scroll {
    /* This class is added by JS to fade out the dock */
    opacity: 0;
    visibility: hidden;
}

/* --- Styling for the new 'End Chat' button on cards --- */

/* This wrapper helps separate the main clickable area from the button */
.card-content-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.end-chat-card-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    padding: 0.25rem;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.3);
    color: #AEAEB2;
    cursor: pointer;
    line-height: 0;
    transition: all 0.2s ease-in-out;
}

.end-chat-card-btn:hover {
    background-color: #FF453A; /* Red on hover */
    color: white;
    transform: scale(1.1);
}

.active-chat-card{
    cursor: pointer !important;
}

#connect-partner-mode-container{
    margin-bottom: 1em;
}

/* Styles for the new Learn Mode Flashcard */
#learn-gameplay-container {
    background-color: #f7f3e9;
}

.flashcard-learn {
    width: 100%;
    max-width: 400px;
    background-color: white;
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    text-align: center;
}

.flashcard-learn .reading {
    font-size: 1.1rem;
    color: #777;
    margin-bottom: 0.5rem;
    font-family: 'Nunito', sans-serif;
}

.flashcard-learn .word {
    font-size: 3.5rem;
    font-weight: 800;
    color: #333;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.flashcard-learn .separator {
    width: 80%;
    height: 2px;
    background-color: #f0f0f0;
    margin: 0 auto 1.5rem auto;
}

.flashcard-learn .definition {
    font-size: 1.5rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 2rem;
}

.flashcard-learn .audio-btn {
    background-color: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    margin: 0 auto;
}

.flashcard-learn .audio-btn:hover {
    background-color: #e0e0e0;
}

.flashcard-learn .audio-btn svg {
    width: 28px;
    height: 28px;
    color: #555;
}

#learn-next-btn {
    background-color: #ffc107;
    border-bottom: 4px solid #e0a800;
}

/* --- NEW MODERN QUIZ UI STYLES --- */

/* General Gameplay Container */
#quiz-gameplay-container {
    background-color: #f8f4ed;
}

/* Header & Progress Bar */
#quiz-header {
    position: relative;
    padding-top: 10px; /* Space for the progress bar */
}

.quiz-header-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
}

.quiz-header-progress-bar {
    height: 100%;
    background-color: #84d853; /* Duolingo green */
    border-radius: 0 5px 5px 0;
    transition: width 0.3s ease-in-out;
}

/* Main Content Area */
.quiz-main-content {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.quiz-question-text {
    font-size: 2rem;
    font-weight: 800;
    color: #4a4a4a;
    text-align: center;
    margin-bottom: 2rem;
}

/* Multiple Choice Options */
.quiz-mc-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    background-color: #fff;
    border-radius: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #4a4a4a;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom-width: 4px;
    text-align: left;
}

.quiz-mc-option:hover:not(:disabled) {
    background-color: #f7fafc;
    transform: translateY(-2px);
}

.quiz-mc-option:disabled {
    cursor: not-allowed;
}

.quiz-mc-option.selected-correct {
    background-color: #d7ffb8 !important;
    border-color: #84d853 !important;
    color: #58a700 !important;
}

.quiz-mc-option.selected-incorrect {
    background-color: #ffdfe0 !important;
    border-color: #ff7277 !important;
    color: #ea2b2b !important;
}

.quiz-mc-option .option-number {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-right: 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: #717171;
    transition: all 0.2s ease;
}

.selected-correct .option-number {
    border-color: #84d853;
    background-color: #fff;
}
.selected-incorrect .option-number {
    border-color: #ff7277;
    background-color: #fff;
}

/* Flashcard Styles */
.flashcard-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard-inner.is-flipped {
    transform: rotateY(180deg);
}

.card-face {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden; /* Safari */
}

.prompt-label {
    font-size: 1rem;
    font-weight: 700;
    color: #a1a1a1;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

/* Action Buttons (Check, Next, etc.) */
.quiz-action-button {
    width: 100%;
    padding: 1.25rem;
    border-radius: 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    color: white;
    border: none;
    border-bottom-width: 5px;
    cursor: pointer;
    transition: transform 0.1s ease;
}
.quiz-action-button:active {
    transform: translateY(2px);
    border-bottom-width: 3px;
}
.quiz-action-button.yellow {
    background-color: #ffc107;
    border-color: #e0a800;
    color: #4a4a4a;
}
.quiz-action-button.green {
    background-color: #84d853;
    border-color: #61a932;
}
.quiz-action-button.red {
    background-color: #ff7277;
    border-color: #ea2b2b;
}

/* Highlight for vocab words that appear in a story */
.vocab-hit {
    background: #fff7c2;
    color: #7a5c00;
    padding: 0 .25em;
    border-radius: .35em;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.05);
  }

  /* Reading UI helpers */
.vocab-hit {
  background: #fef08a; /* soft yellow */
  border-radius: 4px;
  padding: 0 2px;
}

.sentence-wrap .sentence-text.transition {
  transition: filter 200ms ease, opacity 200ms ease;
}

.option-chip {
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 12px;
}

.breakdown-card{border:1px solid rgba(0,0,0,.06);border-radius:12px;padding:16px}
.breakdown-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.breakdown-title{font-size:18px;font-weight:700;margin:0}
.breakdown-row{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-top:12px}
.breakdown-col{min-width:0}
.section-title{font-size:14px;font-weight:600;margin:0 0 6px 0}
.chip-row{display:flex;flex-wrap:wrap;gap:6px}
.chip{display:inline-block;padding:4px 8px;border-radius:9999px;border:1px solid rgba(0,0,0,.1);font-size:12px}
.muted{color:#6b7280;font-size:12px}
.stats{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:8px}
.stat{background:#f9fafb;border:1px solid rgba(0,0,0,.05);border-radius:8px;padding:8px}
.stat-label{font-size:11px;color:#6b7280;margin-bottom:2px}
.stat-value{font-size:14px;font-weight:600}

/* Modern reading view */
.reading-modern {
    background: #f8fafc;
    border-radius: 10px;
    padding: 20px;
    line-height: 1.8;
    font-size: 1.15rem;
  }
  
  .reading-sentence {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: background 0.2s ease;
  }
  
  .reading-sentence:hover {
    background: #f1f5f9;
  }
  
  .reading-text {
    flex: 1;
    margin-right: 10px;
    word-break: break-word;
  }
  
  .reading-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  
  .btn-tts {
    border: none;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    padding: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
  }
  
  .btn-tts:hover {
    background: #1e40af;
  }
  
  .reading-token {
    background: #fef08a;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
  }
  
  .reading-token:hover {
    background: #fde047;
  }
  
  .reading-translation {
    font-size: 0.85rem;
    color: #475569;
    font-style: italic;
    display: inline-block;
    margin-left: 6px;
  }
  
  /* ===== Design tokens */
:root{
    --bg:#0b1118;
    --panel:#0f1723;
    --elev:#121b2a;
    --card:#131f31;
    --card-2:#0e1a2a;
    --stroke:#1f2a3d;
    --muted:#9fb2cd;
    --text:#e6edf6;
    --brand:#6e8bff;
    --brand-2:#2dd4bf;
    --accent:#f59e0b;
    --danger:#ef4444;
    --ok:#10b981;
    --shadow:0 10px 30px rgba(0,0,0,.35);
  }
  
  *{box-sizing:border-box}
  .hidden{display:none !important}
  .w-100{width:100%}
  .mr-2{margin-right:.5rem}
  
  /* ===== Shared wrappers */
  .screen{background:linear-gradient(180deg,#0a1018 0%, #0d1522 100%); color:var(--text); min-height:100%; display:flex; flex-direction:column}
  .rm-header{display:flex; align-items:center; gap:12px; padding:14px 16px; background:var(--panel); border-bottom:1px solid var(--stroke); position:sticky; top:0; z-index:2}
  .rm-header__center{display:flex; align-items:center; gap:14px; margin:0 auto}
  .rm-header__right{display:flex; align-items:center; gap:8px}
  .rm-title{margin:0; font-size:18px; font-weight:800; letter-spacing:.2px}
  .icon-btn{width:36px; height:36px; display:grid; place-items:center; border-radius:10px; border:1px solid var(--stroke); background:transparent; color:var(--muted); cursor:pointer}
  .icon-btn:hover{color:var(--text); border-color:#2a3a55}
  
  .rm-hint-badge{padding:4px 8px; border-radius:999px; font-size:12px; background:#102134; border:1px solid var(--stroke)}
  .rm-hint-badge.success{background:rgba(16,185,129,.12); border-color:rgba(16,185,129,.32); color:#a7f3d0}
  
  .rm-steps{display:flex; gap:6px}
  .rm-steps .dot{width:8px; height:8px; border-radius:999px; background:#384a6a; opacity:.6}
  .rm-steps .dot.is-active{background:var(--brand); opacity:1}
  .rm-steps .dot.is-complete{background:var(--brand-2); opacity:1}
  
  /* ===== Body layout */
  @media (max-width:980px){ .rm-body{grid-template-columns:1fr} }
  .rm-col--left{display:flex; flex-direction:column; gap:14px}
  .rm-col--right{position:relative}
  .sticky{position:sticky; top:18px}
  
  /* ===== Cards & form */
  .card{background:var(--card); border:1px solid var(--stroke); border-radius:14px; padding:14px; box-shadow:var(--shadow)}
  .card__head h3{margin:0 0 4px; font-size:14px; font-weight:800}
  .card__head p{margin:0; color:var(--muted); font-size:12px}
  
  .field{display:flex; flex-direction:column; gap:6px; margin-top:8px}
  .input, .select{background:var(--card-2); color:var(--text); border:1px solid var(--stroke); border-radius:10px; padding:10px 12px; outline:none}
  .input::placeholder{color:#6a7fa1}
  .input:focus, .select:focus{border-color:#3b5cd7; box-shadow:0 0 0 3px rgba(110,139,255,.15)}
  .range{width:100%; accent-color:var(--brand)}
  .hint{color:var(--muted); margin-left:6px; font-size:12px; font-weight:600}
  
  .grid{display:grid; gap:12px}
  .grid--3{grid-template-columns:repeat(3,minmax(0,1fr))}
  .grid__span-3{grid-column:1 / -1}
  @media (max-width:1100px){ .grid--3{grid-template-columns:repeat(2,minmax(0,1fr))} }
  @media (max-width:740px){ .grid--3{grid-template-columns:1fr} }
  
  .row{display:flex; align-items:center}
  .row--gap{gap:8px}
  
  /* Switch */
  .switch{display:flex; align-items:center; gap:10px; cursor:pointer; user-select:none}
  .switch input{display:none}
  .switch__ui{width:42px; height:24px; border-radius:999px; background:#22324b; border:1px solid var(--stroke); position:relative; transition:.2s}
  .switch__ui::after{content:""; position:absolute; top:2px; left:2px; width:18px; height:18px; background:#fff; border-radius:50%; transition:.2s}
  .switch input:checked + .switch__ui{background:linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%); border-color:transparent}
  .switch input:checked + .switch__ui::after{transform:translateX(18px)}
  .switch__label{font-size:14px}
  
  /* Buttons */
  .btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; border-radius:12px; padding:10px 14px; border:1px solid var(--stroke); background:#15243a; color:var(--text); cursor:pointer}
  .btn:hover{border-color:#345077}
  .btn--primary{background:linear-gradient(180deg,#6e8bff 0%, #526ff3 100%); border-color:#526ff3}
  .btn--primary:hover{filter:brightness(1.08)}
  .btn--dark{background:#0e1a2a}
  .btn--ghost{background:transparent}
  .btn--danger{background:rgba(239,68,68,.12); color:#fecaca; border-color:rgba(239,68,68,.35)}
  .btn--soft{background:#142338}
  .btn--circle{width:38px; height:38px; border-radius:999px; padding:0}
  .btn--xl{width:100%; padding:16px; border-radius:16px; font-weight:800}
  
  /* Footer */
  .rm-footer{margin-top:auto; padding:16px; background:var(--panel); border-top:1px solid var(--stroke); position:sticky; bottom:2em}
  
  /* Preview */
  .preview{background:#0d1525; border:1px solid var(--stroke); border-radius:16px; padding:14px; box-shadow:var(--shadow)}
  .preview h4{margin:0 0 10px; font-size:12px; letter-spacing:.3px; color:#9fb2cd; text-transform:uppercase}
  .preview ul{list-style:none; padding:0; margin:0; display:grid; gap:8px}
  .preview li{display:flex; justify-content:space-between; align-items:center; background:#0f1a2c; border:1px solid var(--stroke); padding:8px 10px; border-radius:10px}
  .preview li span{color:#9fb2cd; font-size:12px}
  .preview li strong{font-size:13px}
  .preview__meter{margin-top:12px; position:relative; height:8px; background:#0e1a2a; border:1px solid var(--stroke); border-radius:999px; overflow:hidden}
  .preview__meter .bar{height:100%; background:linear-gradient(90deg,#6e8bff,#2dd4bf)}
  .preview__meter-label{position:absolute; top:-22px; right:0; font-size:11px; color:#9fb2cd}
  
  /* ================= Story Screen ================ */
  .story-body{
    display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
        padding: 18px;
  }
  @media (max-width:980px){ .story-body{grid-template-columns:1fr} }
  .story-wrap{display:flex; flex-direction:column; gap:14px}
  .story-title{margin:4px 0 0; font-size:22px; font-weight:900}
  .story-meta{display:flex; flex-wrap:wrap; gap:8px}
  .chip{display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border-radius:999px; font-size:12px; border:1px solid var(--stroke); background:#122036}
  .chip--genre{border-color:#394f9b; background:rgba(110,139,255,.12)}
  .chip--tone{border-color:#3c6a67; background:rgba(45,212,191,.12)}
  .chip--pov{border-color:#6c4a2f; background:rgba(245,158,11,.14)}
  .chip--target{border-color:#2a5d2e; background:rgba(16,185,129,.12)}
  
/*
 * === Responsive Story Card CSS ===
 * Replaces the old styles for a better mobile-first layout.
*/

/* Container for all sentence cards */
#reading-story-container {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between cards */
    padding: 16px 8px; /* Add some padding around the whole story area */
  }
  
  /* The wrapper for a single sentence and its controls */
  .sentence-wrap {
    display: flex; /* Use flexbox for easy alignment */
    align-items: center; /* Vertically align text and button */
    gap: 12px; /* Space between text and button */
    background-color: #0D1525; /* Dark background from your theme */
    padding: 16px;
    border-radius: 14px;
    border: 1px solid #17243a; /* Subtle border */
  }
  
  /* The text content of the sentence */
  .sentence-text {
    flex-grow: 1; /* Allows the text to take up all available space */
    color: #EAEAEA; /* A light, readable text color */
    line-height: 1.7; /* Improves readability */
    font-size: 1.1rem; /* Slightly larger font for mobile */
  }
  
  /* Make individual words interactive */
  .sentence-text .reading-token {
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0;
    border-radius: 3px;
    white-space: nowrap;
  }
  
  .sentence-text .reading-token:hover {
    background-color: rgba(74, 144, 226, 0.25); /* Subtle highlight on hover */
  }
  
  /* The container for the audio button */
  .sentence-controls {
    flex-shrink: 0; /* Prevents the button container from shrinking */
  }
  
  /* The audio (TTS) button */
  .btn-tts {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;  /* A good tap-target size for mobile */
    height: 44px;
    background-color: #17243A; /* A contrasting color */
    color: #92B4F4; /* A nice blue for the icon */
    border: 1px solid #2a3a5a;
    border-radius: 50%; /* Makes it a circle */
    cursor: pointer;
    font-size: 20px; /* Make the emoji/icon a bit larger */
    transition: background-color 0.2s ease;
  }
  
  .btn-tts:hover, .btn-tts:active {
    background-color: #2a3a5a; /* Visual feedback on interaction */
  }
  /* Aside */
  .story-aside{display:flex; flex-direction:column; gap:12px}
  .story-actions{display:grid; grid-template-columns:repeat(2,1fr); gap:8px}
  .ask{position:relative}
  .ask__input{width:100%; border:1px solid var(--stroke); background:#0e1a2a; color:var(--text); border-radius:999px; padding:12px 48px 12px 14px}
  .ask__input::placeholder{color:#6a7fa1}
  .ask__send{position:absolute; top:50%; right:6px; transform:translateY(-50%); border:none; background:linear-gradient(180deg,#22c55e,#16a34a); color:#fff; width:36px; height:36px; border-radius:999px; display:grid; place-items:center; cursor:pointer}
  .chat{height:200px; overflow:auto; background:#0b1524; border:1px solid var(--stroke); border-radius:12px; padding:10px}
  
  /* ===== Inline highlights (tokens, vocab, grammar) */
  .reading-token{cursor:pointer; padding:0 3px; border-radius:4px; background:transparent !important;}
  .reading-token:hover{background: transparent !important}
  .vocab-hit{
    background: rgb(74 217 0 / 48%) !important;
    border-radius: 4px;
    color: #fff;
    padding: 0 3px;
  }
  .reading-translation{font-style:italic; color:#b8c6e3; font-size:.9em; margin-left:6px}
  .grammar-hit{background:linear-gradient(180deg, rgba(45,212,191,.25), rgba(45,212,191,.1)); border-bottom:1px dashed #2dd4bf}
  
  /* ===== Utility states */
  .card:hover{border-color:#33507c}
  .sentence.card:hover{background:#132238}
  
  .sel-toolbar{position:fixed;z-index:9999;display:flex;gap:6px;background:#0f172a;border:1px solid #23324e;
    border-radius:12px;padding:6px;box-shadow:0 10px 24px rgba(0,0,0,.35)}
  .sel-toolbar.hidden{display:none}
  .sel-btn{min-width:34px;height:34px;border-radius:10px;border:1px solid #2b3c5d;background:#12233c;
    color:#e6edf6;font-weight:700;cursor:pointer}
  .sel-btn:hover{border-color:#3b5cd7;background:#152a48}
  
  .sel-translation{margin-top: 2em;position:fixed;z-index:9998;max-width:420px;background:#0b1322;color:#d7e2f3;border:1px solid #22324b;
    border-radius:12px;padding:10px 12px;font-size:14px;line-height:1.5;box-shadow:0 10px 24px rgba(0,0,0,.35)}
  .sel-translation.hidden{display:none}
  
  #reading-story-container{position:relative} /* ensure no clipping */
  
  #more-options-menu { z-index: 1000; }

  /* FILE: assets/css/reading.css */
.vocab-known {
    background: #fff3bf;         /* soft yellow */
    box-shadow: inset 0 -2px 0 #ffd43b;
    border-radius: 4px;
    padding: 0 2px;
  }
  
  .vocab-known[data-lemma]::after {
    content: attr(data-lemma);
    font-size: 0.75em;
    color: #6b7280;              /* gray-500 */
    margin-left: 4px;
  }
  
  /* Reading tooltip */
.reading-tt {
    position: fixed;
    max-width: 320px;
    background: rgba(18, 22, 28, 0.98);
    color: #e6eef8;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.35;
    z-index: 9999;
    box-shadow: 0 10px 28px rgba(0,0,0,0.4);
    transform: translateY(-6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease, transform .12s ease;
    word-wrap: break-word;
  }
  .reading-tt::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: rgba(18, 22, 28, 0.98) transparent transparent transparent;
  }
  .reading-tt.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  
  /* Tooltip content layout */
  .reading-tt .tt-row { display: flex; gap: 10px; margin: 6px 0; }
  .reading-tt .tt-label { width: 92px; flex: 0 0 92px; color: #98a2b3; font-weight: 600; }
  .reading-tt .tt-value { flex: 1; color: #e6eef8; }
  .reading-tt .tt-kanji { font-size: 20px; font-weight: 800; letter-spacing: 0.02em; }
  .reading-tt .tt-kana  { font-size: 16px; opacity: .95; }
  .reading-tt .tt-tran  { font-size: 14px; }
  .reading-tt .tt-ex    { font-size: 14px; opacity: .95; }
  
  .hidden { display: none !important; }
  
  /* =========================================
   Reading — Your Stories Library
   ========================================= */

:root {
    --rl-bg: #0b1118;
    --rl-panel: #0e1621;
    --rl-card: #121a26;
    --rl-card-hover: #192233;
    --rl-border: #1f2a3a;
    --rl-text: #e9eef5;
    --rl-dim: #9fb0c3;
    --rl-accent: #3b82f6;      /* blue-500 */
    --rl-accent-2: #22c55e;    /* green-500 */
    --rl-danger: #ef4444;      /* red-500 */
    --rl-shadow: 0 6px 16px rgba(0,0,0,0.25);
  }
  
  .reading-library {
    margin-top: 18px;
    background: var(--rl-panel);
    border: 1px solid var(--rl-border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--rl-shadow);
    color: var(--rl-text);
    max-height: 300px;
    overflow-y: auto;
  }
  
  /* Header & Controls */
  .reading-library__header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 12px;
  }
  .reading-library__title {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0;
  }
  
  .reading-library__controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .rlc__search {
    position: relative;
  }
  .rlc__search-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--rl-border);
    background: var(--rl-card);
    color: var(--rl-text);
    outline: none;
  }
  .rlc__search-input::placeholder { color: #7e8fa5; }
  
  .rlc__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
  }
  .rlc__label {
    font-size: 0.85rem;
    color: var(--rl-dim);
  }
  .rlc__select {
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--rl-border);
    background: var(--rl-card);
    color: var(--rl-text);
    padding: 0 10px;
  }
  
  /* Grid */
  .reading-library__grid {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Card */
  .rl-card {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border: 1px solid var(--rl-border);
    background: var(--rl-card);
    border-radius: 12px;
    transition: background 0.2s ease, transform 0.12s ease, border-color 0.2s ease;
    overflow: hidden;
  }
  .rl-card:hover {
    background: var(--rl-card-hover);
    border-color: #2a3b52;
    transform: translateY(-1px);
  }
  
  .rl-card__click {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    padding: 10px;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
  }
  
  .rl-card__thumb {
    background: linear-gradient(135deg, #0f172a, #101826);
    border: 1px solid var(--rl-border);
    border-radius: 10px;
    position: relative;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7e8fa5;
    font-size: 0.85rem;
  }
  
  .rl-card__lang {
    position: absolute;
    top: 8px;
    left: 8px;
  }
  .rl-card__length {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 0.75rem;
    color: #a8b6c7;
  }
  
  .rl-card__body { align-self: center; }
  .rl-card__title {
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--rl-text);
  }
  .rl-card__meta {
    margin: 0;
    color: var(--rl-dim);
    font-size: 0.85rem;
  }
  .rl-meta__dot { margin: 0 6px; color: #5c6f86; }
  .rl-card__date {
    margin: 6px 0 0 0;
    color: #7e8fa5;
    font-size: 0.8rem;
  }
  
  .rl-card__actions {
    display: flex;
    gap: 8px;
    padding: 10px;
    align-items: center;
    justify-content: flex-end;
  }
  
  /* Badges */
  .rl-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid var(--rl-border);
    background: #101a28;
    color: #cfe3ff;
  }
  .rl-badge--en { color: #dbeafe; background: #0b2542; border-color: #16314d; }
  .rl-badge--ja { color: #fee2e2; background: #3a1020; border-color: #4b1428; }
  
  /* Buttons */
  .rl-btn {
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--rl-border);
    background: #111a27;
    color: var(--rl-text);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  }
  .rl-btn:hover { background: #182338; border-color: #2a3b52; }
  .rl-btn:active { transform: translateY(1px); }
  .rl-btn:disabled { opacity: 0.55; cursor: not-allowed; }
  
  .rl-btn--secondary {
    background: var(--rl-accent);
    border-color: #295ea8;
    color: white;
  }
  .rl-btn--secondary:hover { background: #3c86ff; }
  
  .rl-btn--ghost {
    background: transparent;
    border-color: var(--rl-border);
    color: var(--rl-text);
  }
  
  .rl-btn--danger {
    background: transparent;
    border-color: var(--rl-danger);
    color: #fecaca;
  }
  .rl-btn--danger:hover {
    background: rgba(239, 68, 68, 0.12);
  }
  
  /* Empty state */
  .reading-library__empty {
    display: grid;
    place-items: center;
    padding: 24px 8px;
  }
  .reading-library__empty-card {
    text-align: center;
    border: 1px dashed var(--rl-border);
    background: #0c1420;
    color: var(--rl-dim);
    padding: 18px 16px;
    border-radius: 12px;
    max-width: 520px;
  }
  .reading-library__empty-card h3 {
    margin: 8px 0;
    color: var(--rl-text);
    font-weight: 800;
  }
  .reading-library__empty-icon { font-size: 32px; }
  
  /* Pagination */
  .reading-library__pagination {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
  }
  .rl-page { color: var(--rl-dim); }
  
  /* Responsive */
  @media (min-width: 640px) {
    .reading-library__controls {
      grid-template-columns: 1fr auto;
      align-items: center;
    }
    .reading-library__grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  @media (min-width: 960px) {
    .reading-library__grid {
      grid-template-columns: repeat(1, 1fr);
    }
  }
  @media (min-width: 1280px) {
    .reading-library__grid {
      grid-template-columns: repeat(4, 1fr);
    }
  }
  
  /*
 * === Fix for Text Wrapping in Story Cards ===
*/

/* The container for each sentence bubble */
.sentence-wrap {
    /* Allow height to adjust based on content */
    height: auto;
    min-height: 50px; /* Ensures short sentences still have a nice size */
  
    /* Use flexbox to easily center the text inside */
    display: flex;
    align-items: center;
    padding: 12px 24px; /* Adjust padding for a better look */
  }
  
  /* The text element itself */
  .sentence-text {
    /* This is the key fix to allow text wrapping */
    white-space: normal;
  
    /* Ensures long words don't break the layout */
    word-break: break-word;
    overflow-wrap: break-word;
    width: 100%; /* Allow text to use the full container width */
  }

  @media only screen and (max-width:600px){
    .reading-library__controls{
        display: none;
    }
  }

  /* ===== Tooltip header with TTS button ===== */
#reading-translation-tooltip .tt-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .25rem 0 .5rem 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: .5rem;
  }
  
  #reading-translation-tooltip .tt-word {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: .2px;
  }
  
  #reading-translation-tooltip .tt-tts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .5rem;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: .4rem;
    background: rgba(255,255,255,.06);
    cursor: pointer;
    line-height: 1;
  }
  #reading-translation-tooltip .tt-tts-btn:hover { background: rgba(255,255,255,.1); }
  
  /* ===== Hide iOS long-press callout on reading text & toolbar ===== */
  #reading-story-container,
  #reading-story-container .reading-token,
  #selection-toolbar {
    -webkit-touch-callout: none; /* iOS: hide copy/lookup callout */
  }

  #reading-story-container,
#reading-story-container .reading-token,
#selection-toolbar {
  -webkit-touch-callout: none; /* iOS: hide long-press callout */
}

/* Selection result panel themed like your tooltip */
#selection-translation {
    position: absolute;
    z-index: 9999;
    max-width: 320px;
    background: #0f1216;           /* match your dark UI */
    color: #eaeff7;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.35;
    display: none; /* toggled by JS */
  }
  #selection-translation.show { display: block; }
  #selection-translation .tt-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; padding-bottom: .5rem; margin-bottom: .5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  #selection-translation .tt-word { font-weight: 800; font-size: 1.05rem; }
  #selection-translation .tt-tts-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .25rem .5rem; line-height: 1;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: .4rem; cursor: pointer;
  }
  #selection-translation .tt-tts-btn:hover { background: rgba(255,255,255,.1); }
  #selection-translation .tt-row {
    display: grid; grid-template-columns: 90px 1fr; gap: .5rem; padding: .15rem 0;
  }
  #selection-translation .tt-label { color: #93a0b4; }
  #selection-translation .tt-value { color: #eaeff7; word-break: break-word; }
  
  /* (keeps iOS copy/lookup callout hidden while interacting) */
  #reading-story-container,
  #reading-story-container .reading-token,
  #selection-toolbar,
  #selection-translation {
    -webkit-touch-callout: none;
  }
/* Let the selected phrase display with normal spacing/wrap */
#reading-translation-tooltip .tt-word,
#selection-translation .tt-word {
  white-space: normal;
}
  
/* ensure panels float above the story and are clickable */
#reading-translation-tooltip { z-index: 10020; pointer-events: auto; }
#selection-translation       { z-index: 10010; pointer-events: auto; }

/* when hidden (your JS toggles .hidden), also kill clicks */
#reading-translation-tooltip.hidden,
#selection-translation.hidden { pointer-events: none; }

@media only screen and (max-width:600px){
    .story-body{
        max-width: 390px;
    }
  }