/* Smooth scrolling for mobile grid viewport */
#mobile-grid-container .grid-viewport {
    scroll-behavior: smooth; /* ensures animated panning */
}
/* General Styles */
:root {
    /* Reference variables set by vconfig.js instead of hardcoding */
    --primary-color: var(--theme-primary-color, #fff);
    --secondary-color: var(--theme-secondary-color, #00ffcc);
    --tertiary-color: var(--theme-tertiary-color, #ff0059);
    --background-color: var(--theme-background-color, rgba(0, 0, 0, 0.7));
    --bubble-size: 50px;
    --vh: 100vh; /* Default to 100vh */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Enhanced touch highlighting prevention for all browsers */
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    /* Add for Safari/WebKit on macOS */
    -webkit-user-drag: none;
    outline: none;
}

/* Only allow text selection in chat messages and input fields */
.chat-messages .message, 
input, 
textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Specific fix for interactive elements to prevent highlight in Safari */
button, a, [role="button"], .history-button, .mobile-control-button {
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    outline: none; 
}

/* Prevent horizontal scroll on the viewport root.
   Without this, transform: scale(1.7) on a 100vw video element
   can make the document scrollable after grid interactions
   modify body/documentElement overflow inline styles. */
html {
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: #151515;
    color: var(--primary-color);
    overflow: hidden;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    position: fixed;
    touch-action: manipulation;
    overscroll-behavior: none;
}

/* Loading Screen */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

#loading-logo {
    max-width: 200px;
    margin-bottom: 20px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-overlay p {
    margin-top: 10px;
    color: var(--primary-color);
}

/* Main Container */
#mobile-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

/* Client Logo */
.client-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
}

.client-logo img {
    max-height: auto; /* Adjust as needed */
    width: 100px;
    display: block;
    margin: 0 auto 10px; /* Center logo and add space below */
}

/* New Action Buttons Styles */
.action-buttons {
    display: flex;
    justify-content: center; /* Center items horizontally */
    align-items: center;
    gap: 15px; /* Space between button and icon */
    margin-bottom: 10px; /* Space below the action buttons */
}

/* Allow runtime toggle to hide action buttons via class on body */
body.hide-action-buttons .action-buttons {
    display: none !important;
}

.book-now-btn {
    background-color: #00ffcc82;
    color: #000000;
    /* border: white; */
    /* border: solid; */
    /* border-style: solid; */
    padding: 3px 5px;
    border-radius: 5px;
    font-size: 0.6em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.action-icon {
    font-size: 1em; /* Match other icon sizes */
    color: var(--icon-color, #ccc); /* Use variable or default grey */
    cursor: pointer;
    text-shadow: rgba(0, 0, 0, 0.6) -1px -1px 0px, 
                 rgb(0, 0, 0, 0.6) 1px -1px 0px, 
                 rgb(0, 0, 0, 0.6) -1px 1px 0px, 
                 rgb(0, 0, 0, 0.6) 1px 1px 0px;
}
/* End New Action Buttons Styles */

/* Profile Information */
.profile-info {
    position: absolute;
    top: 5px;
    right: 40px; /* Adjusted to leave space for top-controls */
    text-align: right;
    z-index: 10;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    max-width: 200px;
    border: 2px solid transparent;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

/* Top Controls - positioned next to profile info */
.top-controls {
    position: absolute;
    top: 10px;
    right: 5px; /* Adjusted from 230px to 5px */
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 5px; /* Reduced from 10px to 5px for tighter spacing */
}

.top-controls .mobile-control-button {
    width: 32px; /* Reduced from 35px to 28px */
    height: 32px; /* Reduced from 35px to 28px */
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
}

.top-controls .mobile-control-button i {
    font-size: 17px; /* Reduced from 18px to 14px */
}

/* Mobile Session Transfer Quick-Access Button SVG sizing */
#mobile-session-transfer-button {
    display: grid;
    place-items: center;
}

#mobile-session-transfer-button svg {
    width: 22px !important;
    height: 22px !important;
    display: block;
}

#mobile-session-transfer-button:active {
    background: rgba(40, 167, 69, 0.6);
}

/* Profile icon placeholder */
#profile-icon-placeholder {
    display: none; /* Hidden by default, shown when no profile data exists */
    font-size: 28px;
    color: var(--tertiary-color, #00ffcc);
    justify-content: center;
    align-items: center;
    padding: 6px 8px;
    opacity: 0.9;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#profile-icon-placeholder:active {
    transform: scale(0.95);
    opacity: 1;
}

.profile-info h3 {
    font-size: 16px;
    margin: 0;
    font-weight: bold;
    color: var(--primary-color);
    text-overflow: ellipsis;
}

.profile-email {
    font-size: 12px;
    margin: 2px 0 0;
    opacity: 0.8;
    color: #00ffcc;
    text-overflow: ellipsis;
}

.profile-details {
    margin-top: 10px;
    font-size: 12px;
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.profile-details.hidden {
    max-height: 0;
    margin-top: 0;
}

.profile-details p {
    margin: 4px 0;
}

@keyframes profile-updated {
    0% {
      border-color: transparent;
      box-shadow: none;
    }
    30% {
      border-color: #00ffcc;
      box-shadow: 0 0 15px 2px rgba(0, 255, 204, 0.7);
    }
    70% {
      border-color: #00ffcc;
      box-shadow: 0 0 15px 2px rgba(0, 255, 204, 0.9);
    }
    85% {
      border-color: #00ffcc;
      box-shadow: 0 0 10px 1px rgba(0, 255, 204, 0.7);
    }
    100% {
      border-color: transparent;
      box-shadow: none;
    }
  }
  
.profile-updated {
border-width: 2px;
border-style: solid;
animation: profile-updated 2s ease-out forwards;
}

/* Profile Details Overlay */
.profile-details-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.profile-details-overlay.active {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.profile-details-content {
    width: 90%;
    max-width: 500px;
    background-color: #222;
    border-radius: 8px;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    max-height: 80vh; /* Maximum height relative to viewport */
}

.profile-details-overlay.active .profile-details-content {
    transform: translateY(0);
    opacity: 1;
}

.profile-content::-webkit-scrollbar {
    width: 6px;
}

.profile-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.profile-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.profile-header-overlay {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    background-color: #1a1a1a;
}

.profile-header-overlay h2 {
    margin: 0;
    font-size: 20px;
    color: #fff;
    font-weight: 700;
}

.profile-content {
    padding: 20px;
    color: #ddd;
    overflow-y: auto; /* Enable vertical scrolling */
    max-height: calc(80vh - 60px); /* Account for header height */
}

.profile-name-email {
    margin-bottom: 20px;
    text-align: center;
}

.profile-name-email h3 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 500;
    color: #fff;
}

#profile-email-overlay {
    margin: 0;
    color: #00ff99; /* Green email color */
    font-size: 16px;
}

.profile-additional-details {
    border-top: 1px solid #333;
    padding-top: 15px;
}

.profile-additional-details p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.5;
}

.profile-additional-details p strong {
    color: #fff;
    display: inline-block;
    min-width: auto;
}

.close-button {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Add blur effect to background when overlay is active */
#mobile-container.app-blurred {
    filter: blur(5px);
    transition: filter 0.3s;
}

/* Prevent scrolling when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100vw;
    height: 235px;
    margin-top: 10vh;
    z-index: 1;
    transition: height 0.3s ease;
    overflow: visible; /* Allow positioned elements to extend beyond container */
}

/* When video is zoomed, adjust container height */
.video-container:has(#mobile-video-player.zoomed) {
    height: 45vh;
}

#video-placeholder {
    position: absolute;
    width: 60%;
    max-width: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.7;
    z-index: 2;
    display: none!important; /* Hide the placeholder by default */  
}

#mobile-video-player {
    width: 100vw;
    height: 100%; /* Use 100% of container height */
    object-fit: contain !important;
    /* background: #000; */
    display: block;
    margin: 0 auto;
    object-position: top; /* Pin video to top */
    transform-origin: top center; /* Set transform origin to top */
    transition: transform 0.3s ease; /* Add transition for smooth zoom */
    position: relative; /* This ensures child elements position relative to this */
    overflow: visible;
}

/* Zoomed video state */
#mobile-video-player.zoomed {
    transform: scale(1.7); /* 70% zoom */
    object-fit: contain !important;
    height: 32vh; /* Maintain height for zoomed state */
    /* height property removed - now controlled by the container */
}

/* Video text overlay for mobile */
.video-text-overlay {
    position: absolute;
    bottom: 10px; /* Adjusted to be closer to the bottom of the actual video */
    left: 0px !important;
    width: 90%;
    text-align: left !important;
    padding: 8px 10px;
    z-index: 3;
    background: none;
    border-radius: 0;
    box-sizing: border-box;
    pointer-events: none;
    transition: bottom 0.3s ease;
    align-items: flex-start !important;
}

/* Adjust video text overlay in zoomed state */
.video-container:has(#mobile-video-player.zoomed) .video-text-overlay {
    bottom: 15px !important; /* Position just above chat section, adjusted for new container height */
}

/* ── Mobile Video Loading Overlay ──
   Spinner shown inside .video-container while a new video is buffering.
   Matches the grid-image-preload-overlay / desktop video-loading-overlay pattern. */
.mobile-video-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 14; /* Above video (z:1) but below playback-icon (z:15) and progress-bar (z:4 but thin) */
    backdrop-filter: blur(4px);
    pointer-events: none;
    overflow: hidden; /* Prevent bleed when .video-container has overflow:visible */
}

/* When video is zoomed (scale 1.7, transform-origin: top center), the visual video
   extends below the container. The overlay must match the zoomed visual area. */
.video-container:has(#mobile-video-player.zoomed) .mobile-video-loading-overlay {
    height: calc(32vh * 1.7);
}

.mobile-video-loading-overlay .mobile-video-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top: 3px solid #00ffcc;
    border-radius: 50%;
    animation: mobileVideoLoadingSpin 1s linear infinite;
}

@keyframes mobileVideoLoadingSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Video playback icon positioning - centered and adjusted for the container */
.video-playback-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 15;
    pointer-events: none; /* Prevent the icon from intercepting clicks */
}

/* Make playback icon visible when needed */
.video-playback-icon.visible {
    opacity: 1;
}

.video-playback-icon i {
    font-size: 36px;
    color: white;
}

/* ═══════════════════════════════════════════════════════
   Mobile Video Progress Bar (TikTok/Instagram-style)
   Thin line at bottom of video, expands on hover/touch
   ═══════════════════════════════════════════════════════ */

/* Container — sticks to bottom of visible video content.
   position: absolute within .video-container;
   JS dynamically sets 'bottom' via positionBar() because
   the video uses transform: scale(1.7) + overflow: visible,
   so the visible video extends well beyond the container CSS box. */
.mobile-video-progress {
    position: absolute;
    bottom: 0;                              /* Fallback; JS overrides dynamically */
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 4;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, height 0.2s ease;
}

/* Active state — visible when a video is loaded */
.mobile-video-progress.active {
    opacity: 1;
    pointer-events: auto;
}

/* Expanded state — on hover or touch interaction */
.mobile-video-progress.expanded {
    height: 12px;
}

/* Track — semi-transparent background spanning full width */
.mobile-video-progress .progress-track {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0;
}

/* Fill — colored portion showing current progress */
.mobile-video-progress .progress-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 0;
    transition: none;
    pointer-events: none;
}

/* Scrub thumb — appears only in expanded state */
.mobile-video-progress .progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Show thumb in expanded state */
.mobile-video-progress.expanded .progress-fill::after {
    opacity: 1;
}

/* Extended touch/mouse target — invisible but enlarges clickable area.
   44px tall, vertically centered on the progress bar so 22px extends
   above (into the video) and 22px below (past the bar edge).
   Meets Apple HIG / WCAG minimum touch target (~9mm).
   Mouse/emulator users are unaffected: the visual bar stays 3px and expansion
   only triggers on :hover (cursor) or programmatic .expanded class (touch). */
.mobile-video-progress::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 44px;
    transform: translateY(-50%);
    cursor: pointer;
}

/* Seek time tooltip — positioned below the progress bar, offset left
   so the user's finger on the ::after thumb does not obscure it.
   Only shown (via .visible class) during active seeking/dragging.
   Created dynamically in mobile-video-progress.js. */
.progress-time-tooltip {
    position: absolute;
    top: 100%;
    margin-top: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    /* Shift left so the tooltip sits to the left of the thumb, not under the finger */
    transform: translateX(calc(-100% - 36px));
    transition: opacity 0.2s ease;
    z-index: 5;
}

.progress-time-tooltip.visible {
    opacity: 1;
}

/* Hidden during zoom / container transitions to prevent position-jerk */
.mobile-video-progress.transitioning {
    opacity: 0 !important;
    transition: none !important;            /* Snap-hide, no fade */
}

/* Hover expansion (for cursor/emulated browser environments) */
.mobile-video-progress.active:hover {
    height: 12px;
}

.mobile-video-progress.active:hover .progress-fill::after {
    opacity: 1;
}

/* In fullscreen mode, JS positionBar() still manages bottom offset.
   No additional overrides needed — the calculation adapts to any container height. */

.video-title {
    font-size: 15px !important;
    font-weight: bold;
    margin-bottom: 2px;
    text-shadow: rgba(0, 0, 0, 0.6) -1px -1px 0px, 
                 rgb(0, 0, 0, 0.6) 1px -1px 0px, 
                 rgb(0, 0, 0, 0.6) -1px 1px 0px, 
                 rgb(0, 0, 0, 0.6) 1px 1px 0px;
}

.video-subtitle {
    font-size: 12px !important;
    opacity: 0.9;
    text-shadow: rgba(0, 0, 0, 0.6) -1px -1px 0px, 
                rgb(0, 0, 0, 0.6) 1px -1px 0px, 
                rgb(0, 0, 0, 0.6) -1px 1px 0px, 
                rgb(0, 0, 0, 0.6) 1px 1px 0px;
    /* Collapsible subtitle support — default is expanded (full text visible).
       Tapping the subtitle toggles .collapsed which truncates to one line. */
    pointer-events: auto;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    /* max-height transition animates the collapse/expand toward the title */
    max-height: 500px;                      /* large enough for any subtitle */
    transition: max-height 0.35s ease;
}

/* Collapsed state: single line with ellipsis + down-arrow indicator.
   max-width: 70vw keeps text within 7/10 of the visible screen even though
   the parent overlay width (90% of 100vw container) can extend offscreen
   when the video is scaled via transform: scale(1.7). */
.video-subtitle.collapsed {
    white-space: nowrap;
    text-overflow: ellipsis;
    max-height: 1.4em;                      /* exactly one line */
    max-width: 70vw;
}

/* Toggle arrow — inline SVG appended by JS.
   Only visible when collapsed (pointing down = "tap to expand").
   Hidden when expanded since the full text is already visible. */
.video-subtitle .subtitle-toggle-arrow {
    display: none;
    width: 10px;
    height: 10px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.8;
}

/* Show arrow only in collapsed state */
.video-subtitle.collapsed .subtitle-toggle-arrow {
    display: inline-block;
}

/* Video History */
.history-container {
    position: fixed;
    bottom: 45%;
    right: 5px;
    transform: translateY(-5%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: end;    /*gap: 10px;*/
    transition: opacity 0.7s ease, transform 0.7s ease;
    /* Remove any overflow constraints to allow touch areas to extend beyond */
    overflow: visible;
    /* Add padding to ensure the container area includes the extended touch areas */
    padding-left: 25px; /* Add padding to accommodate the left-extended touch area */
}

/* When collapsed, let taps pass through the container except for the buttons */
.history-container.collapsed {
    pointer-events: none;
}

.history-container.collapsed .history-buttons,
.history-container.collapsed .history-buttons * {
    pointer-events: auto;
}

/* Move properties to only affect the list when container is collapsed */
.history-container.collapsed .history-list {
    opacity: 0;
    transform: translateX(60px);
    pointer-events: none;
}

.history-buttons {
    display: flex;
    gap: 25px;
    margin-bottom: 10px;
    /* Ensure buttons remain visible even when container is collapsed */
    opacity: 1;
    transform: none;
    pointer-events: auto;
    flex-direction: row;
    position: relative;
    z-index: 20; /* Ensure proper stacking */
    /* Make sure this container doesn't clip its children */
    overflow: visible;
}

.history-button {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.348);
    border: 1px solid rgba(255, 255, 255, 0.075);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative; /* Add position relative for pseudo-element */
}

/* Create an invisible larger touch area */
.history-button::after {
    content: '';
    position: absolute;
    top: -14px;  /* Reduced from -25px to -14px to prevent overlap with mobile-session-transfer-button */
    right: -5px;
    bottom: -10px;
    left: -25px; /* Extend left touch area for all history buttons */
    /* Ensure it doesn't block other elements visually */
    background-color: transparent;
    z-index: -1;
    pointer-events: auto; /* Explicitly enable pointer events */
}

/* Custom touch area for history-toggle button - extra 5px to the left */
#history-toggle::after {
    left: -25px; /* Extended even more to the left */
}

/* Safari-specific fix for ALL browsers now */
.history-button::after {
    /* Ensure touch events work properly */
    z-index: 1;
    pointer-events: auto;
}

.history-button {
    /* Ensure content is above the touch area */
    z-index: 2;
    position: relative;
}

.history-button:active {
    transform: scale(0.95);
    background-color: rgba(0, 255, 204, 0.2);
}

.history-button i {
    font-size: 14px;
    /* Ensure icon stays above the touch area in Safari */
    position: relative;
    z-index: 2;
}

.history-button-wrapper {
    padding: 10px;
    margin: -10px;
    display: inline-block;
}

.history-list {
    list-style-type: none;
    padding: 0;
    margin: 0;    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.7s ease;
    max-height: 235px; /* Height to fit exactly 4 items + gaps */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 5px;
    padding-left: 3px;
    padding-top: 3px;
    padding-bottom: 3px;
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

/* Style the scrollbar for better visibility */
.history-list::-webkit-scrollbar {
    width: 4px;
    display: none;
}

.history-list::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb:hover {
    display: none;
}

/* Ensure list items display correctly */
.history-list li {
    width: 70px;
    height: 52px;
    border-radius: 20%;
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    flex-shrink: 0; /* Prevent items from shrinking */
    display: block; /* Ensure proper display */
    
    /* Prevent context menus and native mobile interactions - more selective */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* Prevent context menu on history item images */
.history-list li img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block; /* Ensure image displays */
    
    /* Minimal context menu prevention for images */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Ensure grid items in history list have consistent styling */
.history-list li.history-grid-item {
    width: 70px;
    height: 52px;
    border-radius: 20%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.history-list li.history-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.history-list li.active {
    border-color: #00ccff;
    transform: scale(1.1);
}

/* Title tooltip that appears on long press */
.history-list li .thumbnail-title {
    /* Same as .history-item-title */
    position: absolute;
    bottom: 10%;
    left: 1%;
    right: 5%;
    width: 100%;
    color: white;
    padding-left: 5px;
    padding-right: 5px;
    font-size: 7px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    text-shadow: 
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
    z-index: 1;
}

.history-list li .thumbnail-title.visible {
    opacity: 1;
}

.history-list .comparison-item {
    position: relative;
}

.history-list .comparison-item::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    background-image: url(https://ultimxtechnologies.com/ultimx_app/assets/comp2.svg);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 20%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.history-list .comparison-item.active {
    border-color: var(--primary-color, #2196F3);
    /*box-shadow: 0 0 0 2px var(--primary-color, #2196F3);*/
}

/* History search button animation */
#history-search {
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none; /* Disable interaction when hidden */
}

#history-search.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto; /* Re-enable interaction */
}

.comparison-container {
    background-color: rgba(0, 0, 0, 0.9);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    overflow-y: auto;
    padding: 15px;
    box-sizing: border-box;
    touch-action: pan-y;
}

/* Mobile comparison container styles */
.mobile-comparison-container {
    position: fixed;
    top: 100px; /* Fixed distance from top to avoid overlapping with logo/profile */
    left: 0;
    right: 0;
    bottom: 12vh; /* Distance from bottom to avoid chat input */
    height: auto; /* Auto height instead of fixed vh */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    /* Modified: Still capture pointer events but allow vertical swipes to pass through */
    pointer-events: auto;
    /* Modified: Allow vertical pan/swipe gestures to manipulate chat */
    touch-action: pan-y;
    transition: height 0.3s ease, top 0.3s ease; /* Add transition for smooth size change */
}

/* Square comparison state - matches the zoomed video height */
.mobile-comparison-container.square {
    top: 60px;
    bottom: 8vh;
    height: 45vh; /* Match the zoomed video container height */
}

.comparison-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
    /* Modified: Allow vertical pan/swipe gestures */
    touch-action: pan-y;
}

.comparison-panel {
    position: relative;
    width: 92%;
    max-width: 600px;
    margin: auto;
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100% - 32px); /* Use available container height */
    /* Animation removed - only animate on creation, not on visibility changes */
    /* Contain scroll events within this element */
    overscroll-behavior: contain;
}

.comparison-panel-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    flex: 1;
    /* Enable only vertical touch scrolling */
    touch-action: pan-y;
    /* Contain scroll events within this element */
    overscroll-behavior: contain;
}

.comparison-header {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.comparison-header h2 {
    color: #333;
    font-size: 20px;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.comparison-header h3 {
    color: #666;
    font-size: 16px;
    margin: 0;
    font-weight: 500;
}

.comparison-columns {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comparison-column {
    padding: 16px;
    background-color: #f9f9f9;
    border-radius: 8px;
    /* border-left: 4px solid var(--primary-color, #2196F3); */
}

.comparison-column h4 {
    margin: 0 0 8px 0;
    font-size: 17px;
    font-weight: 600;
}

.comparison-content {
    line-height: 1.5;
    font-size: 15px;
}

.comparison-close-btn {
    display: none !important;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
}

@keyframes comparison-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Animation class applied only when comparison is first created */
.comparison-panel.slide-up-animation {
    animation: comparison-slide-up 0.3s ease-out;
}

/* Dark mode styles */
@media (prefers-color-scheme: dark) {
    .comparison-panel {
        background-color: #1f1f1f6e;
    }
    
    .comparison-header h2 {
        color: #e0e0e0;
    }
    
    .comparison-header h3 {
        color: #b0b0b0;
    }
    
    .comparison-column {
        background-color: #000000;
        /* border-left: 4px solid var(--primary-color, #2196F3); */
    }
    
    .comparison-close-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #ccc;
    }
}

/* Chatbox */
.chat-section {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    backdrop-filter: blur(10px);
    padding: 0px 1px 65px 15px; /* Extra padding at bottom for the form */
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Scope transitions to only animated properties — prevents jitter from animating gap, padding-right, justify-content etc. */
    transition: height 0.4s cubic-bezier(0.215, 0.61, 0.355, 1),
               max-height 0.4s cubic-bezier(0.215, 0.61, 0.355, 1),
               background-color 0.4s cubic-bezier(0.215, 0.61, 0.355, 1),
               padding-top 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
    height: 300px; /* Set explicit height for non-expanded state */
    max-height: 40vh;
    padding-right: 10%;
    background-color: rgba(0, 0, 0, 0.4);
    justify-content: end;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.2);
}

/* Transitioning state to avoid jumpy animation */
.chat-section.transitioning-to-minimal {
    /* Set intermediate values for smooth transition */
    height: 200px;
    max-height: 200px;
    padding-top: 15px;
    /* Scoped transition with longer duration for intermediate step */
    transition: height 0.5s cubic-bezier(0.215, 0.61, 0.355, 1),
               max-height 0.5s cubic-bezier(0.215, 0.61, 0.355, 1),
               background-color 0.5s cubic-bezier(0.215, 0.61, 0.355, 1),
               padding-top 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);
    /* Prevent any layout shifts during transition */
    will-change: height, max-height, padding-top, background-color;
}

/* Minimal state - just enough for one message row */
.chat-section.minimal {
    height: 120px; /* Increased to make more room */
    max-height: 120px;
    /*overflow: hidden;*/
    padding-top: 9px; /* Reduced to show more content */
    background-color: rgba(0, 0, 0, 0.5); /* More contrast to see content */
}

/* Expose variables consumed by grid layout (JS reads these) */
:root {
    --chat-minimal-height: 120; /* keep in sync with .chat-section.minimal height */
    --mobile-grid-bottom-safe: 0; /* override per-brand if needed */
}

/* Make the minimal toggle more visible in minimal state - match chat-toggle style */
.chat-section.minimal .minimal-toggle {
    height: 25px; /* Bigger touch target - match chat-toggle */
    background: rgba(0, 0, 0, 0.5); /* Match .chat-section.minimal background for seamless join */
    left: 50%; /* Keep position consistent at 50% right */
    top: -25px; /* Position higher to be more visible */
    border-bottom: none; /* Remove bottom border to blend with chat section */
    z-index: 20; /* Ensure it's above other elements */
}

.chat-section.expanded {
    height: 75vh !important;
    max-height: 75vh !important;
    display: flex;
    flex-direction: column;
}

/* Make the minimal toggle more visible in expanded state - match chat-toggle style */
.chat-section.expanded .minimal-toggle {
    height: 25px; /* Bigger touch target - match chat-toggle */
    background: rgba(0, 0, 0, 0.4); /* Match .chat-section base background for seamless join */
    left: 50%; /* Keep position consistent at 50% right */
    top: -25px; /* Position higher to be more visible */
    border-bottom: none; /* Remove bottom border to blend with chat section */
    z-index: 20; /* Ensure it's above other elements */
}

.chat-section.expanded .chat-messages {
    height: calc(75vh - 90px) !important;
    max-height: calc(75vh - 90px) !important;
    overflow-y: auto !important; /* Force scrolling in expanded mode */
    display: flex;
    flex-direction: column;
    opacity: 1;
    /*justify-content: flex-end;*/
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    touch-action: pan-y !important; /* Re-enable touch scrolling in expanded state */
}

/* Ensure chat input form stays at bottom */
.chat-section.expanded #mobile-chat-form {
    margin-top: auto;
}

.chat-toggle {
    position: absolute;
    top: -25px;
    left: 20px; /* Positioned where the border-radius curve meets the flat top edge */
    width: 45px;
    height: 25px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 16;
    opacity: 0; /* Hidden by default */
    transition: none; /* No transition initially to prevent fade-in effect */
}

/* Only show chat-toggle in standard state, and when not in no-messages state */
.chat-section:not(.minimal):not(.expanded):not(.no-messages) .chat-toggle {
    opacity: 1; /* Visible only in standard state with messages */
    transition: opacity 0.3s ease; /* Add transition back once loaded */
}

/* Minimal toggle button - appears to the right of the chat toggle in normal state */
.minimal-toggle {
    position: absolute;
    top: -25px;
    left: 50%; /* Positioned at 50% to the right */
    transform: translateX(-50%);
    width: 45px; /* Match width of chat-toggle */
    height: 25px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    background: rgba(0, 0, 0, 0.4); /* Darker background for better visibility */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 16;
    opacity: 0; /* Hidden by default */
    transition: none; /* No transition initially to prevent fade-in effect */
}

/* Show minimal toggle in all states - standard, minimal, and expanded, but only when not in no-messages state */
.chat-section:not(.no-messages) .minimal-toggle {
    opacity: 1;
    transition: opacity 0.3s ease; /* Add transition back once loaded */
}

.minimal-toggle img {
    transform: rotate(180deg) !important; /* Default: pointing up in normal state (to minimize) */
    transition: transform 0.3s ease !important;
    width: 18px; /* Match chat-toggle image size */
    height: 18px;
    opacity: 0.9;
    /* Ensure identical appearance to chat-toggle image */
}

/* Rotate the minimal toggle image in minimal state to indicate it can expand */
.chat-section.minimal .minimal-toggle img {
    transform: rotate(0deg) !important; /* Point down in minimal state (to expand) */
}

/* In expanded state, point to standard state (sideways) */
.chat-section.expanded .minimal-toggle img {
    transform: rotate(180deg) !important; /* Point left in expanded state (to go to normal) */
}

/* Style for chat-toggle in minimal state (but it's hidden) */
.chat-section.minimal .chat-toggle {
    height: 30px; /* Bigger touch target */
    background: rgba(0, 0, 0, 0.5); /* Match .chat-section.minimal background for seamless join */
    top: -25px; /* Position higher to be more visible */
    border-bottom: none; /* Remove bottom border to blend with chat section */
    z-index: 20; /* Ensure it's above other elements */
    opacity: 0; /* Hidden in minimal state */
}

.chat-toggle img {
    transform: rotate(0deg) !important; /* Default: pointing up (to expand) in non-expanded states */
    transition: transform 0.3s ease !important;
    width: 18px; /* Slightly larger icon */
    height: 18px;
    opacity: 0.9;
}

.chat-section.expanded .chat-toggle {
    opacity: 0; /* Hidden in expanded state */
}

.chat-section.expanded .chat-toggle img {
    transform: rotate(180deg) !important; /* Point down (to collapse) when expanded */
}

/* Normal state (neither minimal nor expanded) 
.chat-section:not(.minimal):not(.expanded) .chat-toggle img {
    transform: rotate(180deg) !important; /* Point down in normal state 
}*/

.chat-messages {
    display: flex !important;
    flex-direction: column !important;
    flex: 1;
    overflow-y: auto;
    max-height: calc(40vh - 69px);
    padding-right: 5px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;     /* Firefox */
    transition: max-height 0.3s ease, opacity 0.3s ease;
    /* Normal state: no touch scrolling — swipe gestures are handled by JS (mobile_adapters.js)
       and only mouse wheel scrolling is allowed. Expanded state overrides back to pan-y. */
    touch-action: none;
    /* Soft fade at top — masks content instead of adding darkness */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20px);
    mask-image: linear-gradient(to bottom, transparent 0%, black 20px);
}

/* Spacer pushes messages to the bottom when content is shorter than container.
   When content overflows, the spacer collapses to 0 and scroll works naturally.
   This replaces the old justify-content toggling approach that caused visual jumps. */
.chat-messages::before {
    content: '';
    flex: 1 0 0px;
}

/* In minimal state the chat area is only ~120px tall so the 20px fade
   occupies too much of the visible area and looks cut off. Use a much
   subtler 6px fade instead. */
.chat-section.minimal .chat-messages {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 6px);
    mask-image: linear-gradient(to bottom, transparent 0%, black 6px);
    overflow: hidden; /* No scrolling in minimal state — content is just a peek */
    touch-action: none; /* Reinforce: no touch gestures in minimal state */
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.chat-messages .message {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 15px;
    max-width: 95%;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-size: 12px;
}

.chat-messages .user-message {
    background: rgba(0, 255, 204, 0.2) !important;
    color: var(--primary-color);
    align-self: flex-end !important;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-messages .assistant-message {
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--primary-color);
    align-self: flex-start !important;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}
.chat-messages .user-message:last-child {
    margin-right: 20px !important; /* Even more space for the last message */
}

#mobile-chat-form {
    position: absolute;
    bottom: 15px; /* Match the padding of chat-section */
    left: 15px;
    right: 4%; /* Match right padding of chat-section */
    display: flex;
    align-items: center;
    z-index: 1000 !important;
    gap: 10px;
    background: transparent;
    /* Don't animate the form */
    transition: none;
}

#mobile-user-query {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
    outline: none;
    overflow: hidden;
    z-index: 1000;
}

#mobile-chat-form button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--tertiary-color);
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 1000;
}

#mobile-chat-form button:active {
    transform: scale(0.95);
}

/* Replace the current .ai-bubble styles with these */
.mobile-visualizer-container {
    cursor: pointer;
    position: fixed;
    bottom: 70px;
    right: 0px;
    width: 60px;
    height: 60px;
    z-index: 100;
    transition: transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mobile-visualizer-container:active {
    transform: scale(0.95); /* Visual feedback when pressed */
}

/* Style for the canvas */
#mobile-visualizer {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    overflow: visible; /* Ensure no clipping */
}

/* Style for the indicator dot */
.ai-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #0088ff; /* Default blue color */
    border: 2px solid #222;
    transition: background-color 0.3s;
}

/* Colors for voice status */
.voice-enabled .ai-dot {
    background-color: #0088ff; /* Blue when voice is on */
}

.voice-disabled .ai-dot {
    background-color: #ff3333; /* Red when voice is off */
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.mobile-visualizer-container.pulse .ai-dot {
    animation: pulse 0.5s ease;
}

/* Animation for messages */
@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: messageAppear 0.3s ease-out forwards;
}

/* Fix for iOS Safari 100vh issue */
@supports (-webkit-touch-callout: none) {
    body, #mobile-container {
        height: -webkit-fill-available;
    }
}

/* Add mobile controls styling */
.mobile-controls {
    position: fixed;
    bottom: 135px; /* Position above the mobile-visualizer-container */
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    z-index: 100;
}

.mobile-control-button {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.173);
    border: 1px solid rgba(255, 255, 255, 0.075);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Fullscreen button with 25% increased size and extended touch area */
#fullscreen-button {
    width: 35px;
    height: 35px;
    position: relative; /* Add position relative for pseudo-element */
}

/* Create invisible larger touch area for fullscreen-button */
#fullscreen-button::after {
    content: '';
    position: absolute;
    top: -10px;
    right: -10px;
    bottom: -10px;
    left: -10px;
    background-color: transparent;
    z-index: 1;
    pointer-events: auto;
}

#fullscreen-button i {
    font-size: 22px; /* Slightly larger icon to match the increased button size */
    position: relative;
    z-index: 2; /* Ensure icon stays above the touch area */
}

.mobile-control-button:active {
    transform: scale(0.95);
    background-color: rgba(0, 255, 204, 0.2);
}

.mobile-control-button i {
    font-size: 16px;
}

#fullscreen-button.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}

#fullscreen-button.disabled i {
    color: #888;
}

/* Mobile Grid Nav Toggle and Panel */
/* Grid nav toggle uses same size as fullscreen */
#mobile-grid-nav-toggle.mobile-grid-nav-button {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* darker base than generic mobile-control-button for clearer affordance */
    background-color: rgba(0, 0, 0, 0.35) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* Fixed UI layer inside mobile grid container (does not pan/zoom) */
#mobile-grid-container .grid-fixed-ui {
    position: absolute;
    left: 0;
    right: 0;
    top: 8px;
    z-index: 110; /* above grid content, below modal overlays */
    pointer-events: none; /* let clicks pass unless overridden by children */
}
#mobile-grid-container .grid-fixed-ui .grid-header,
#mobile-grid-container .grid-fixed-ui .info-text,
#mobile-grid-container .grid-fixed-ui .grid-header-toggle {
    pointer-events: auto; /* allow interaction inside */
}

/* On mobile, the entire header card is tappable to hide it (same as the T button).
   pointer-events: auto so taps land on the header background/padding, not markers behind. */
#mobile-grid-container .grid-fixed-ui .grid-header {
    pointer-events: auto;
    cursor: pointer;
}
/* Ensure any explicit interactive controls in the header (if present) remain clickable */
#mobile-grid-container .grid-fixed-ui .grid-header .grid-header-toggle,
#mobile-grid-container .grid-fixed-ui .grid-header .grid-title-toggle,
#mobile-grid-container .grid-fixed-ui .grid-header a,
#mobile-grid-container .grid-fixed-ui .grid-header button {
    pointer-events: auto;
}
/* Title and subtitle inherit pointer-events from parent (auto) — no override needed.
   cursor: pointer also inherits from the header container. */

/* On mobile, the T button replaces the small header chevron; hide it entirely */
#mobile-grid-container .grid-fixed-ui .grid-header-toggle {
    display: none !important;
}

/* Slightly narrower header typography on mobile */
#mobile-grid-container .grid-fixed-ui .grid-header {
    margin: 0 10px;
}

/* Inline info-text card (mobile: reuses marker card container) */
#mobile-container .grid-marker-card.info-text-card {
    width: auto;
    max-width: 78vw;
    min-width: 200px;
}
/* Mobile-only: compact marker card sizing and subtitle clamp without affecting desktop */
#mobile-grid-container .grid-fixed-ui .grid-marker-card {
    padding: 11px 14px !important;
    width: min(78vw, 252px) !important;
    max-width: min(78vw, 252px) !important;
    min-width: 216px !important;
    min-height: 85px !important;
    max-height: 140px !important;
    font-size: 12.5px !important;
}

#mobile-grid-container .grid-fixed-ui .grid-marker-card.has-video {
    padding: 4px 4px 4px 10px !important;
}

#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-subtitle {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important; /* allow 3 lines as requested */
    line-clamp: 3 !important;
    font-size: 10px !important;
    margin: 0 0 4px 0 !important;
    line-height: 1.3 !important;
}
#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-title {
    font-size: 12px !important;
    margin: 0 0 2px 0 !important;
    line-height: 1.2 !important;
}

/* For mobile video cards, rely on clickable thumbnail and hide extra actions to reduce height */
#mobile-grid-container .grid-fixed-ui .grid-marker-card.has-video .grid-marker-card-actions {
    display: none !important;
}

/* Mobile-only: reduce spacing between content and thumbnail */
#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-thumbnail {
    margin-left: 2px !important;
}

/* When wrapper is present, apply the margin to the wrapper instead */
#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-thumb-wrap {
    margin-left: 2px !important;
}

#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-content {
    gap: 2px !important;
}

/* Keep touch targets generous on mobile while icons stay visually compact */
#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-action {
    min-width: 36px !important; /* slightly smaller but still finger-friendly */
    min-height: 36px !important;
    padding: 4px !important;
    font-size: 14px !important; /* reduce visual size */
}

/* Tighten internal spacing for mobile to keep card within thumbnail height */
#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-actions {
    margin-top: 0 !important;
    gap: 4px !important;
}

#mobile-grid-container .grid-fixed-ui .grid-marker-card .grid-marker-card-title {
    margin-bottom: 4px !important;
}
#mobile-container .grid-marker-card.info-text-card .info-text-content h3 {
    font-size: 16px;
    margin: 0 0 4px 0;
}
#mobile-container .grid-marker-card.info-text-card .info-text-content p {
    font-size: 13px;
    margin: 0;
}

/* Remove speech arrow for inline info-text cards on mobile */
#mobile-container .grid-marker-card.info-text-card::after,
#mobile-container .grid-marker-card.info-text-card::before {
    display: none !important;
}

/* Active state for the nav toggle when flyout is open */
#mobile-grid-nav-toggle.mobile-grid-nav-button.active {
    /* dark green tone, subtle glow via border */
    background-color: rgba(0, 80, 60, 0.6) !important;
    border-color: rgba(0, 200, 160, 0.65) !important;
}

/* Flyout: attaches within .mobile-controls and expands left */
#mobile-grid-nav-panel {
    position: absolute;
    right: 45px; /* sits left of the toggle (35px + small gap) */
    bottom: -7px;
    z-index: 150;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    backdrop-filter: blur(6px);
    color: #fff;
    padding: 6px;
    overflow: hidden; /* clip during animation */
    will-change: transform, opacity;
    transform-origin: right center;
    transform: scaleX(0.001);
    opacity: 0;
    pointer-events: none;
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1), opacity 140ms ease;
}

#mobile-grid-nav-panel.expanded {
    transform: scaleX(1);
    opacity: 1;
    pointer-events: auto;
}

#mobile-grid-nav-panel.collapsed {
    transform: scaleX(0.001);
    opacity: 0;
    pointer-events: none;
}

/* Horizontal row of controls that scrolls if needed */
#mobile-grid-nav-panel .mobile-grid-nav-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    max-width: 82vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
}

/* Ensure desktop grid button visuals carry over inside panel */
/* Minor spacing adjustment for desktop-styled controls inside the panel */
#mobile-grid-nav-panel .grid-navigation-controls.in-mobile-panel {
    position: static;
    background: transparent;
    border: none;
    height: auto;
    padding: 0;
}

#mobile-grid-nav-panel .grid-navigation-controls.in-mobile-panel .nav-collapse-toggle {
    display: none;
}

#mobile-grid-nav-panel .grid-navigation-controls.in-mobile-panel .nav-controls-content {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    width: auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    /* Pad left to clear the panel border-radius (10px) so the first button
       is never clipped by overflow:hidden + rounded corners */
    padding-left: 4px !important;
    scroll-padding-inline-start: 4px !important;
}

/* Override all desktop button sizes to be compact inside the flyout */
#mobile-grid-nav-panel .grid-navigation-controls .nav-button {
    width: 32px !important;
    height: 32px !important;
    padding: 4px !important;
    margin: 0 !important;
    min-width: 32px !important;
    min-height: 32px !important;
    box-sizing: border-box !important;
}

/* Specific overrides for different button types */
#mobile-grid-nav-panel .grid-navigation-controls .arrow-paths-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .arrow-paths-btn .path-icon {
    width: 20px !important;
    height: 20px !important;
}

/* Grid Tour Play Button — mobile compact override */
#mobile-grid-nav-panel .grid-navigation-controls .grid-tour-play-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 12px !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .show-all-grids-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 4px !important;
    margin: 0 !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .show-all-grids-btn .grid-icon {
    width: 16px !important;
    height: 16px !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .back-button {
    width: 32px !important;
    height: 32px !important;
    padding: 2px !important;
    margin: 0 !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .back-button .back-button-thumbnail {
    width: 26px !important;
    height: 26px !important;
}

/* Mobile Title toggle ("T") button styling */
#mobile-grid-nav-panel .grid-navigation-controls .mobile-title-toggle {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    line-height: 1 !important;
    color: #fff !important;
    background: rgba(255,255,255,0.12) !important; /* default subtle */
    border: 1px solid rgba(255,255,255,0.18) !important;
    border-radius: 6px !important;
}

/* Active/shown state: match the green style family of arrow-paths control */
#mobile-grid-nav-panel .grid-navigation-controls .mobile-title-toggle.active {
    background: rgba(0, 120, 90, 0.85) !important;
    border-color: rgba(0, 220, 170, 0.9) !important;
    box-shadow: 0 0 0 1px rgba(0, 220, 170, 0.35) inset !important;
}

/* Disabled/inert visual (if ever applied) */
#mobile-grid-nav-panel .grid-navigation-controls .mobile-title-toggle:disabled,
#mobile-grid-nav-panel .grid-navigation-controls .mobile-title-toggle[aria-disabled="true"] {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.08) !important;
    color: rgba(255,255,255,0.4) !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .view-button,
#mobile-grid-nav-panel .grid-navigation-controls .level-button {
    width: 32px !important;
    height: 32px !important;
    padding: 4px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .nav-icon {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Specific alignment for horizontal navigation arrows */
#mobile-grid-nav-panel .grid-navigation-controls .view-button .nav-icon {
    width: 16px !important;
    height: 16px !important;
    display: block !important;
    margin: 0 auto !important;
    object-fit: contain !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .alternative-view-button {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 2px !important;
    margin: 0 !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .alternative-view-button .alt-view-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px !important;
    width: 100%;
    white-space: nowrap;
}

#mobile-grid-nav-panel .grid-navigation-controls .alternative-view-button .alt-view-current-number,
#mobile-grid-nav-panel .grid-navigation-controls .alternative-view-button .alt-view-next-number {
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
}

#mobile-grid-nav-panel .grid-navigation-controls .alternative-view-button .alt-view-arrow {
    font-size: 10px !important;
    line-height: 1 !important;
    display: inline-block !important;
    transform: scaleX(0.6) !important; /* squish horizontally to free space for numbers */
    transform-origin: center center !important;
    margin: 1px 0px 0px 0px !important;
}

/* Container adjustments */
#mobile-grid-nav-panel .grid-navigation-controls .alternative-view-navigation { 
    margin-bottom: 0 !important; 
    scale: none !important;
}
#mobile-grid-nav-panel .grid-navigation-controls .horizontal-navigation { 
    margin-bottom: 0 !important;
    /* Override the mobile media query forcing column layout */
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
}
#mobile-grid-nav-panel .grid-navigation-controls .level-navigation { 
    margin-bottom: 0 !important;
    /* Override the mobile media query forcing column layout */
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px !important;
}

/* Reposition the mobile-visualizer-container to ensure proper spacing */
.mobile-visualizer-container {
    bottom: 70px;
    right: 2px;
    width: 50px;
    height: 50px;
}

/* Remove the old mobile-clear-chat styling */
.mobile-clear-chat {
    display: none; /* Hide any existing buttons with this class */
}

/* Confirmation Dialog Styling for Mobile */
.confirm-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1200; /* Above settings-menu-overlay (1000) and modal (1100) */
    justify-content: center;
    align-items: center;
}

.confirm-dialog.active {
    display: flex;
}

.confirm-dialog-content {
    background-color: #000000;
    padding: 20px;
    border-radius: 10px;
    max-width: 80%;
    text-align: center;
    border: 1px solid rgba(0, 255, 204, 0.5);
}

.confirm-dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.confirm-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    min-width: 55px;
}

.confirm-btn i {
    font-size: 18px;
}

/* Primary button - accent color for positive action (checkmark) */
.confirm-btn.primary {
    background-color: rgba(0, 255, 204, 0.8);
    color: #000000;
}

.confirm-btn.primary:active {
    background-color: rgba(0, 255, 204, 1);
}

/* Danger button - subtle red for cancel/destructive action (X) */
.confirm-btn.danger {
    background-color: rgba(255, 77, 77, 0.3);
    border: 1px solid rgba(255, 77, 77, 0.5);
    color: #ff4d4d;
}

.confirm-btn.danger:active {
    background-color: rgba(255, 77, 77, 0.5);
}

/* Ghost button - outline style for cancel/secondary */
.confirm-btn.ghost {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
}

.confirm-btn.ghost:active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Dialog hint text */
.dialog-hint {
    display: block;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85em;
    margin-top: 4px;
    margin-bottom: 8px;
}

/* ========== Exit Dialog (Back Button Guard) ========== */
.exit-dialog {
    z-index: 1250; /* Above confirm-dialog (1200), below suggestions-modal (2000) */
}

.exit-dialog-content {
    padding: 20px 24px;
    /* Entry animation — scale + fade */
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.exit-dialog.active .exit-dialog-content {
    transform: scale(1);
    opacity: 1;
}

.exit-dialog .confirm-btn {
    min-width: 55px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.exit-dialog .confirm-btn i {
    font-size: 18px;
}

/* Leave (X) button — white icon on red */
.exit-dialog .confirm-btn.danger i {
    color: #ffffff;
}

/* Legacy support for old yes/no classes */
.confirm-btn.yes {
    background-color: #ff4d4d;
    color: white;
}

.confirm-btn.no {
    background-color: #333;
    color: white;
}

/* ========== Admin Password Modal (Mobile) ========== */
.admin-password-dialog {
    z-index: 1300 !important; /* Above exit-dialog (1250), settings-menu-overlay (1000) */
}

.admin-password-input {
    width: 80%;
    padding: 12px 14px;
    margin-top: 12px;
    border: 1px solid rgba(0, 255, 204, 0.4);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 16px; /* Prevent iOS zoom on focus */
    text-align: center;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease;
}

.admin-password-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.admin-password-input:focus {
    border-color: rgba(0, 255, 204, 0.8);
}

.admin-password-input.error {
    border-color: rgba(255, 77, 77, 0.8);
    animation: admin-pw-shake 0.4s ease;
}

.admin-password-error {
    display: block;
    color: #ff4d4d;
    font-size: 0.8em;
    margin-top: 6px;
    margin-bottom: 4px;
}

@keyframes admin-pw-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ========== Demo Mode Warning Modal ========== */
.demo-mode-warning-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1300;
    justify-content: center;
    align-items: center;
}

.demo-mode-warning-modal.active {
    display: flex;
}

.demo-mode-warning-content {
    background-color: #000000;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.5);
    text-align: center;
    max-width: 90%;
    width: 360px;
    color: white;
}

.demo-mode-warning-icon {
    font-size: 32px;
    color: #f59e0b;
    margin-bottom: 10px;
}

.demo-mode-warning-content h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #f59e0b;
}

.demo-mode-warning-content p {
    margin: 0 0 10px 0;
    font-size: 13px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.75);
    text-wrap: balance;
}

.demo-mode-warning-content p.demo-mode-features {
    margin: 0 0 16px 0;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    text-wrap: balance;
}

.demo-mode-warning-ok {
    padding: 10px 28px;
    border: none;
    border-radius: 8px;
    background-color: rgba(245, 158, 11, 0.8);
    color: #000;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
}

.demo-mode-warning-ok:active {
    background-color: rgba(245, 158, 11, 1);
}

/* ========== Demo Mode Deactivated Notice (success variant, mobile) ========== */
.demo-deactivated-notice-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 10001;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}

.demo-deactivated-notice-modal.active {
    display: flex;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.demo-deactivated-notice-content {
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.98), rgba(20, 20, 20, 0.98));
    padding: 32px;
    border-radius: 16px;
    border: 1px solid rgba(34, 197, 94, 0.4);
    text-align: center;
    max-width: 460px;
    width: 90%;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.demo-deactivated-notice-modal.active .demo-deactivated-notice-content {
    opacity: 1;
    transform: scale(1);
}

.demo-deactivated-notice-icon {
    font-size: 36px;
    color: #22c55e;
    margin-bottom: 12px;
}

.demo-deactivated-notice-content h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: #22c55e;
}

.demo-deactivated-notice-content p {
    margin: 0 0 20px 0;
    font-size: 16px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    text-wrap: balance;
}

.demo-deactivated-notice-ok {
    padding: 10px 32px;
    border: none;
    border-radius: 8px;
    background-color: rgba(34, 197, 94, 0.8);
    color: #000;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.demo-deactivated-notice-ok:active {
    background-color: rgba(34, 197, 94, 1);
}

/* Mobile settings-header demo label */
.settings-demo-label {
    position: absolute;
    top: 8px;
    right: 50px;
    background: #f59e0b;
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    pointer-events: none;
}

/* Add to mobile_styles.css */
.mobile-clear-chat {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #777;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
}

.mobile-clear-chat:hover {
    color: #ff4d4d;
}

/* Voice Selection Modal - Mobile Version */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #2a2a2a;
    border-radius: 15px;
    width: 85%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.modal h2 {
    color: white;
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
}

.modal button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    margin-top: 15px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    transition: background-color 0.2s;
}

.modal button:hover {
    background-color: #2980b9;
}

/* Voice selection specific styles */
.voice-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.voice-options label {
    display: flex;
    align-items: center;
    color: white;
    font-size: 14px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.voice-options label:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.voice-options input[type="radio"] {
    margin-right: 10px;
}

/* Logo selection specific styles */
.logo-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 10px;
}

.logo-option {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-option:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.logo-option.selected {
    border: 2px solid #3498db;
}

.logo-option img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
}

/* AI name selection specific styles */
.coming-soon {
    color: #ff9800;
    text-align: center;
    font-style: italic;
    margin: 20px 0;
    font-size: 16px;
}

.input-container {
    margin: 15px 0;
}

.input-container label {
    display: block;
    color: white;
    margin-bottom: 5px;
    font-size: 14px;
}

.input-container input {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
}

.input-container.disabled input {
    opacity: 0.5;
    cursor: not-allowed;
}

.speech-feedback {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    z-index: 1000;
    min-width: 200px;
    text-align: center;
}

.speech-waves {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    margin-bottom: 8px;
}

.speech-wave {
    width: 3px;
    height: 10px;
    background-color: #0088ff;
    margin: 0 2px;
    border-radius: 1px;
    animation: wave 1s infinite ease-in-out;
}

.speech-wave:nth-child(1) { animation-delay: 0.0s; }
.speech-wave:nth-child(2) { animation-delay: 0.2s; }
.speech-wave:nth-child(3) { animation-delay: 0.4s; }
.speech-wave:nth-child(4) { animation-delay: 0.2s; }
.speech-wave:nth-child(5) { animation-delay: 0.0s; }

@keyframes wave {
    0%, 100% { height: 10px; }
    50% { height: 25px; }
}

/* Add these styles to mobile_styles.css */
.video-suggestions {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

chat-form {
    display: none;
}

#user-query {
    display: none;
}

#logoutButton {
    display: none;
}

#override-controls {
    display: none;
}

#video-player {
    display: none;
}

#controls-container {
    display: none;
}

.toggle-button {
    display: none;
}

#profile-arrow-container {
    display: none;
}

#chat-form {
    display: none;
}

#mainVideoPlayer {
    display: none;
}

.video-overlay {
    display: none;
}

.video-section {
    display: none;
}

body::before {
    content: "";
    position: fixed;
    z-index: 0;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw;
    height: 100vh;
    background: url('https://ultimxtechnologies.com/ultimx_app/assets/black_bg.jpg') center center / cover no-repeat;
    filter: blur(0px) brightness(1);
    opacity: 1;
    pointer-events: none;
    transition: filter 5s cubic-bezier(0.4,0,0.2,1);
}

body.bg-loaded::before {
    filter: blur(18px) brightness(0);
}

#empty-chat-prompt {
    position: fixed;
    top: 18vh;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    max-width: 400px;
    text-align: center;
    font-size: 1.5rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.092);
    border-radius: 18px;
    padding: 24px 10px 20px 10px;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: 
        opacity 0.5s cubic-bezier(0.4,0,0.2,1),
        transform 0.5s cubic-bezier(0.4,0,0.2,1),
        top 0.5s cubic-bezier(0.4,0,0.2,1),
        font-size 0.4s cubic-bezier(0.4,0,0.2,1),
        padding 0.4s cubic-bezier(0.4,0,0.2,1),
        width 0.4s cubic-bezier(0.4,0,0.2,1),
        background 0.4s ease;
    font-weight: bold;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 24px 0 rgba(0,0,0,0.18);
}

#empty-chat-prompt.visible {
    opacity: 1;
}

/* Compact state - when history exists but no content is active */
#empty-chat-prompt.compact {
    top: calc(10vh + 100px); /* Position inside video container area */
    font-size: 1.1rem;
    padding: 14px 16px 12px 16px;
    width: auto;
    max-width: 280px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 16px 0 rgba(0,0,0,0.25);
}

/* Add a subtle pulse animation when compact */
#empty-chat-prompt.compact.visible {
    animation: compactPulse 3s ease-in-out infinite;
}

@keyframes compactPulse {
    0%, 100% {
        box-shadow: 0 2px 16px 0 rgba(0,0,0,0.25);
        border-color: rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 0 2px 20px 0 rgba(0, 204, 204, 0.15);
        border-color: rgba(0, 204, 204, 0.2);
    }
}

/* Video History Gallery Popup */
.history-gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.history-gallery-overlay.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.history-gallery-header {
    display: block; /* Hide the header completely */
}

.history-gallery-title {
    display: none;
}

.history-gallery-item-content {
    flex: 1;
    padding-right: 10px;
    text-align: left;
    max-width: calc(100% - 130px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.history-gallery-close {
    position: absolute;
    top: 5px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 201; /* Ensure it's above other elements in the overlay */
}

.history-gallery-content {
    flex: 1;
    width: 98%;
    margin: 0 auto;
    padding: 15px;
    padding-top: 0px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 95vh;
    margin-top: 35px;
    /* Ensure smooth scrolling on mobile */
    -webkit-overflow-scrolling: touch;
}

.history-gallery-item {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease, border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    /* Normalize height for consistent appearance */
    height: 105px;
    min-height: 105px;
    margin-bottom: 0;
    flex-shrink: 0;
}

/* New comparison badge for gallery items - only show when using regular thumbnail */
.history-gallery-item[data-comparison-id].using-regular-thumbnail::after {
    content: "";
    position: absolute;
    top: 15px;
    right: 35px;
    width: 70px;
    height: 70px;
    background-image: url(https://ultimxtechnologies.com/ultimx_app/assets/comp2.svg);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 20%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 2;
    pointer-events: none;
}

/* Hide comparison badge when using msthumbnail (since msthumbnail already shows comparison visually) */
.history-gallery-item[data-comparison-id].using-msthumbnail::after {
    display: none;
}

.history-gallery-item.active {
    border-color: #00ccff;
}

.history-gallery-item:active {
    transform: scale(0.95);
}

.history-gallery-item img {
    width: 135px;
    height: 90px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0; /* Prevent image from shrinking */
}

/* Grid thumbnail specific styling */
.history-gallery-item.using-grid-thumbnail img {
    object-fit: cover; /* Ensure proper containment */
    background-color: #f8f9fa; /* Light background for grid thumbnails */
    border: 1px solid #dee2e6; /* Subtle border for definition */
}

/* Grid thumbnail loading state */
.history-gallery-item.using-grid-thumbnail.loading img {
    opacity: 0.7;
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Grid visual indicator */
.history-gallery-item[data-grid-id]::after {
    content: '🗺️';
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}

.history-gallery-item-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-gallery-item-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property for broader compatibility */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.8em; /* Limit to 2 lines */
}

/* Add styling for touch-protected gallery items */
.history-gallery-item.touch-protected {
    pointer-events: none;
    transition: none !important; /* Disable transitions */
    border-color: rgba(255, 255, 255, 0.2) !important; /* Force default border color */
    transform: none !important; /* Prevent any transform effects */
    box-shadow: none !important; /* Prevent any glow/shadow effects */
}

.history-gallery-item.touch-protected:active,
.history-gallery-item.touch-protected:hover {
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* .history-gallery-item .title {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    font-size: 12px;
    text-align: center;
    overflow: hidden;
    /* Enable multi-line text with ellipsis after 2 lines */
    /*display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property for broader compatibility */
    /*-webkit-box-orient: vertical;
    box-orient: vertical; /* Standard property for broader compatibility */
    /*line-height: 1.3em;
    max-height: 4em; /* Increased from 2.6em to accommodate padding and prevent text cutoff */
/*} */

/* Blur effect for background elements when gallery is active */
.video-container.blurred,
.chat-section.blurred {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

/* Hide video container completely when comparison is active and gallery is open */
.video-container.comparison-active.blurred {
    display: none !important;
}

/* Mobile Fullscreen Support */
:root {
    --vh: 1vh; /* Will be updated by JavaScript */
    --full-vh: 1vh; /* Full viewport height */
}

/* Use real viewport height instead of vh units to avoid address bar issues */
.fullscreen-height {
    height: calc(var(--vh, 1vh) * 100);
    min-height: calc(var(--vh, 1vh) * 100);
}

/* Fullscreen mode styles */
body.fullscreen-active {
    overflow: hidden;
}

body.fullscreen-active .video-container {
    height: 100vh !important;
}

/* Address bar hidden state */
/* body.address-bar-hidden .video-container {
    /* Use full available height when address bar is hidden
    height: calc(var(--full-vh, 1vh) * 76);
} */

/* Mobile fullscreen toggle button */
#mobile-fullscreen-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#mobile-fullscreen-toggle:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
}

#mobile-fullscreen-toggle:active {
    transform: translateY(0);
}

#mobile-fullscreen-toggle.active {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

#mobile-fullscreen-toggle:before {
    content: "📱";
    font-size: 16px;
}

#mobile-fullscreen-toggle.active:before {
    content: "🔙";
}

/* Fullscreen and Address Bar Hiding Styles */
.address-bar-hidden {
    /* Enhanced mobile viewport handling */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for modern browsers */
}

.address-bar-hidden body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Grid Tools modal button alignment and consistency */
.admin-tools-actions { display: flex; flex-direction: column; gap: 10px; }
.admin-tools-actions .admin-action { width: 100%; display: inline-flex; align-items: center; justify-content: center; padding: 12px 14px; border-radius: 10px; }
.admin-tools-actions .admin-action.primary { font-weight: 600; }

/* Fullscreen toggle button active state */
#fullscreen-toggle-btn.active {
    color: #4CAF50;
    font-weight: bold;
}

/* Fullscreen settings option styling */
#fullscreen-settings-option {
    transition: all 0.3s ease;
}

#fullscreen-settings-option:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#fullscreen-settings-option .settings-icon i {
    transition: transform 0.3s ease;
}

#fullscreen-settings-option:active .settings-icon i {
    transform: scale(1.1);
}

/* Enhanced viewport height support for better mobile experience */
:root {
    --vh: 1vh;
    --dvh: 1dvh;
}

/* Mobile fullscreen container adjustments */
.mobile-container.fullscreen-active {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
    max-height: 100vh;
    max-height: calc(var(--vh, 1vh) * 100);
    max-height: 100dvh;
}

/* Address bar hidden state adjustments */
body.address-bar-hidden .mobile-container {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
    overflow: hidden;
}

/* Smooth transition for fullscreen changes */
.mobile-container,
.mobile-container * {
    transition: height 0.3s ease-out, max-height 0.3s ease-out;
}

/* Prevent scrolling when address bar is hidden */
body.address-bar-hidden {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* iOS Safari specific adjustments */
@supports (-webkit-touch-callout: none) {
    body.address-bar-hidden {
        height: -webkit-fill-available;
    }
    
    .mobile-container.fullscreen-active {
        height: -webkit-fill-available;
        max-height: -webkit-fill-available;
    }
}

/* =====================================================
   QR SESSION TRANSFER MODAL - MOBILE
   ===================================================== */

/* Mobile QR Overlay */
.mobile-qr-transfer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.mobile-qr-transfer-overlay.active {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.mobile-qr-transfer-content {
    width: 92%;
    max-width: 380px;
    max-height: 90vh;
    background-color: #1a1a1a;
    border-radius: 16px;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-qr-transfer-overlay.active .mobile-qr-transfer-content {
    transform: translateY(0);
    opacity: 1;
}

/* Header */
.mobile-qr-transfer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mobile-qr-transfer-header h2 {
    margin: 0;
    font-size: 17px;
    color: #fff;
    font-weight: 600;
}

.mobile-qr-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 44px;  /* Increased from 36px for better tap target */
    height: 44px; /* Increased from 36px for better tap target */
    min-width: 44px;  /* Ensure minimum tap target size */
    min-height: 44px; /* Ensure minimum tap target size */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;  /* Slightly larger icon */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* Prevent double-tap zoom */
    pointer-events: auto; /* Explicitly enable pointer events */
    position: relative;
    z-index: 10; /* Ensure button is above other elements */
}

.mobile-qr-close-btn i {
    pointer-events: none; /* Let clicks pass through icon to button */
}

/* Body */
.mobile-qr-transfer-body {
    padding: 24px 20px;
    text-align: center;
    position: relative;
    min-height: 260px;
}

.mobile-qr-description {
    color: #888;
    font-size: 14px;
    margin: 0 0 20px 0;
}

/* QR Container */
.mobile-qr-code-wrapper {
    display: inline-block;
    margin-bottom: 16px;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    pointer-events: auto; /* Explicitly enable pointer events for tap-to-enlarge */
    touch-action: manipulation;
}

.mobile-qr-container {
    background: #1a1a2e;
    padding: 16px;
    border-radius: 12px;
    display: inline-block;
    pointer-events: none; /* Let clicks pass through to wrapper */
}

.mobile-qr-container canvas,
.mobile-qr-container img {
    display: block;
    border-radius: 8px;
    pointer-events: none; /* Let clicks pass through to wrapper */
}

.mobile-qr-enlarge-hint {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    margin-top: 8px;
}

/* URL Display */
.mobile-qr-url-display {
    font-size: 10px;
    color: #666;
    word-break: break-all;
    margin-bottom: 16px;
    font-family: monospace;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    max-height: 60px;
    overflow-y: auto;
}

/* Buttons */
.mobile-qr-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease;
}

.mobile-qr-btn:active {
    transform: scale(0.98);
}

.mobile-qr-copy-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 12px;
}

.mobile-qr-copy-feedback {
    color: #28a745;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s ease;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-qr-copy-feedback.visible {
    opacity: 1;
}

/* Footer */
.mobile-qr-footer {
    padding: 16px 20px;
    background: #111;
    display: flex;
    gap: 12px;
}

.mobile-qr-footer .mobile-qr-btn {
    flex: 1;
    padding: 12px;
    font-size: 13px;
}

.mobile-qr-regenerate-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.mobile-qr-email-btn {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
}

/* Loading */
.mobile-qr-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    z-index: 10;
}

.mobile-qr-loading.hidden {
    display: none;
}

.mobile-qr-loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00cccc;
    border-radius: 50%;
    animation: mobileQrSpin 0.8s linear infinite;
}

@keyframes mobileQrSpin {
    to { transform: rotate(360deg); }
}

.mobile-qr-loading-dots {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

.mobile-qr-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00cccc;
    animation: mobileQrDotPulse 1.4s ease-in-out infinite;
}

.mobile-qr-loading-dots span:nth-child(1) { animation-delay: 0s; }
.mobile-qr-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.mobile-qr-loading-dots span:nth-child(3) { animation-delay: 0.3s; }
.mobile-qr-loading-dots span:nth-child(4) { animation-delay: 0.45s; }
.mobile-qr-loading-dots span:nth-child(5) { animation-delay: 0.6s; }

@keyframes mobileQrDotPulse {
    0%, 100% { 
        transform: scale(0.6); 
        opacity: 0.4; 
        background: #00ffcc; 
    }
    50% { 
        transform: scale(1.2); 
        opacity: 1; 
        background: #00cccc; 
        box-shadow: 0 0 15px rgba(0,204,204,0.8); 
    }
}

/* Error */
.mobile-qr-error {
    padding: 30px 20px;
    text-align: center;
}

.mobile-qr-error-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.mobile-qr-error p {
    color: #ff6b6b;
    margin-bottom: 16px;
}

.mobile-qr-retry-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
}

/* Enlarged Overlay */
.mobile-qr-enlarged-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-qr-enlarged-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-qr-enlarged-container {
    text-align: center;
}

.mobile-qr-enlarged-code {
    background: #1a1a2e;
    padding: 20px;
    border-radius: 16px;
    display: inline-block;
}

.mobile-qr-enlarged-code canvas,
.mobile-qr-enlarged-code img {
    display: block;
    border-radius: 8px;
}

.mobile-qr-enlarged-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    margin-top: 20px;
}

/* Button loading/success states */
.mobile-qr-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.mobile-qr-btn.success {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%) !important;
}

/* End of QR Session Transfer Modal styles */

/* === SwipeGuard: touch-action hardening === */
/* Prevent double-tap zoom on interactive list items */
.history-list li { touch-action: manipulation; }
.history-gallery-item { touch-action: manipulation; }
.mobile-suggestion-btn { touch-action: manipulation; }
.mobile-thread-item { touch-action: manipulation; }
