/* ===========================================
   RESPONSIVE - Media Queries
   =========================================== */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
  .pricing-cards {
    grid-template-columns: repeat(2, 1fr);
    max-width: 700px;
  }

  .subscription-page {
    padding: 24px 16px;
  }

  /* Slightly reduce left panel width */
  .left-panel {
    width: 340px;
  }
}

/* ===========================================
   TABLET (900px and below)
   Main responsive breakpoint - stacks layout
   =========================================== */
@media (max-width: 900px) {
  /* =========================================
     CORE LAYOUT - Make everything scrollable
     ========================================= */

  /* Tool selector - wrap on mobile for 4+ buttons */
  .tool-selector-container {
    flex-wrap: wrap !important;
  }

  /* Top Navbar - slightly smaller */
  .top-navbar {
    height: 52px;
    padding: 0 12px;
    gap: 12px;
  }

  .navbar-logo {
    height: 36px;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
  }

  .navbar-logo:active {
    opacity: 0.7;
    transform: scale(0.95);
  }

  /* Body - flex column to push footer down */
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  /* Container - fills available space */
  .container {
    position: static;
    flex-direction: column;
    height: auto !important;
    min-height: auto;
    margin-top: 52px;
    padding-bottom: 0;
    overflow: visible;
    flex: 1;
  }

  /* =========================================
     SIDEBAR - Hidden, slides in as overlay
     ========================================= */
  .main-nav {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 80px;
    height: auto;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: var(--bg-secondary);
  }

  .main-nav.mobile-open {
    transform: translateX(0);
  }

  .main-nav.collapsed {
    transform: translateX(-100%);
  }

  /* Mobile overlay */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }

  .mobile-overlay.active {
    display: block;
  }

  /* =========================================
     TAB SECTIONS - Stack vertically
     ========================================= */
  .tab-section {
    flex-direction: column !important;
    width: 100%;
    min-height: auto;
  }

  .tab-section.active {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Left panel (controls) - flows naturally */
  .left-panel {
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: visible !important;
    padding-bottom: 0 !important;
  }

  .left-panel .header {
    padding: 14px 16px;
  }

  .left-panel .content {
    padding: 14px 16px;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Right panel (outputs) - flows below */
  .right-panel {
    width: 100% !important;
    flex: none;
    min-height: 300px;
    padding: 14px;
    overflow: visible !important;
  }

  /* =========================================
     FOOTER - Slim mobile footer
     ========================================= */
  .site-footer {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100%;
    padding: 0;
    margin-top: 0;
    flex-shrink: 0;
    /* Hide footer by default on mobile - only show when tool is active */
    display: none !important;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
  }

  /* Show footer when a tool is active (container is visible) */
  .container.mobile-tool-active ~ .site-footer {
    display: block !important;
  }

  .site-footer.sidebar-collapsed {
    left: auto !important;
  }

  /* Hide desktop footer content on mobile */
  .footer-desktop {
    display: none !important;
  }

  /* Mobile slim footer bar */
  .footer-mobile-slim {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    font-size: 0.75rem;
    color: var(--text-secondary);
  }

  .footer-mobile-slim .footer-copyright {
    opacity: 0.7;
  }

  .footer-mobile-ai {
    font-size: 0.7rem;
    opacity: 0.6;
  }

  .footer-more-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .footer-more-btn:active {
    transform: scale(0.95);
    background: var(--bg-card);
  }

  .footer-more-icon {
    font-size: 1rem;
    line-height: 1;
  }

  /* =========================================
     SPECIFIC SECTIONS
     ========================================= */

  /* Video section */
  #videoSection .left-panel {
    height: auto !important;
    max-height: none !important;
  }

  #videoSection .content {
    max-height: none !important;
    overflow: visible !important;
  }

  /* Inpaint container */
  .inpaint-container {
    flex-direction: column !important;
    height: auto !important;
    min-height: auto;
  }

  .inpaint-canvas-area {
    flex: none !important;
    width: 100% !important;
    max-width: 100%;
    height: auto;
    min-height: 200px;
    padding: 16px;
  }

  .inpaint-sidebar {
    flex: none !important;
    width: 100% !important;
    overflow-y: visible !important;
    overflow: visible !important;
    height: auto !important;
    padding: 16px;
    gap: 12px;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  .inpaint-control-section {
    gap: 6px;
  }

  .inpaint-control-label {
    font-size: 0.8rem;
  }

  .inpaint-textarea {
    min-height: 60px;
  }

  .inpaint-divider {
    margin: 8px 0;
  }

  .inpaint-result-section {
    width: 100% !important;
    min-width: auto;
    padding: 16px;
  }

  .inpaint-header {
    margin-bottom: 12px;
  }

  .inpaint-header h2 {
    font-size: 1.3rem;
  }

  .inpaint-subtitle {
    font-size: 0.8rem;
  }

  /* Caption container */
  .caption-container {
    height: auto !important;
    min-height: auto;
    flex: 1;
  }

  .caption-chat-area {
    flex: 1;
    min-height: 200px;
  }

  .caption-welcome {
    margin-top: 5vh;
    padding: 0 16px;
  }

  .caption-input-wrapper {
    max-width: 100%;
    padding: 0 12px 20px;
  }

  .caption-input-container {
    position: relative;
    padding: 12px;
  }

  /* =========================================
     UI COMPONENTS
     ========================================= */

  /* Output grid - adjust for tablet */
  .output-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }

  /* Model tabs - horizontal scroll */
  .model-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 8px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .model-tab {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 0.85rem;
    min-width: auto;
  }

  /* Content mode toggle */
  .content-mode-toggle {
    flex-wrap: wrap;
    gap: 10px;
  }

  .content-mode-info {
    display: none;
  }

  /* Prompt textarea */
  .prompt-input {
    min-height: 80px;
  }

  /* Generate button */
  .generate-btn {
    padding: 14px;
    font-size: 1rem;
  }

  /* Settings dropdowns */
  .settings-row {
    flex-direction: column;
    gap: 8px;
  }

  .settings-row select {
    width: 100%;
  }

  /* Settings grid - stack on tablet */
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .setting-item.full {
    grid-column: span 1;
  }

  /* Admin panel */
  .admin-container {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }

  .admin-content-area {
    max-height: none !important;
    padding: 16px;
  }

  /* Marketplace */
  .marketplace-page {
    padding: 20px;
  }

  .marketplace-title {
    font-size: 1.8rem;
  }

  .marketplace-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  /* Education/Learn section */
  .education-container {
    flex-direction: column;
  }

  .education-sidebar {
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
  }

  /* Modals */
  .user-menu {
    width: calc(100% - 24px);
    right: 12px;
    left: 12px;
    max-width: 300px;
  }

  .modal-content {
    width: calc(100% - 24px);
    max-width: none;
    margin: 12px;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Nav tab styling */
  .nav-icon svg {
    width: 20px;
    height: 20px;
  }

  .nav-label {
    font-size: 0.6rem;
  }

  .nav-tab {
    padding: 14px 0;
  }

  /* Reference images */
  .reference-images-section {
    padding: 12px;
  }

  .reference-preview {
    max-height: 150px;
  }

  /* Reference upload - smaller on tablet */
  .reference-upload {
    padding: 20px 16px;
  }

  .reference-upload-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
  }

  .reference-upload-text {
    font-size: 0.85rem;
  }

  .reference-upload-hint {
    font-size: 0.7rem;
  }

  /* Generated images header */
  .output-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .output-header h2 {
    font-size: 1.3rem;
  }

  /* Hide selection toggle and zoom slider on tablet */
  .selection-mode-toggle,
  .zoom-controls,
  .zoom-slider-container {
    display: none !important;
  }
}

/* ===========================================
   MOBILE PHONES (768px and below)
   Phone-specific optimizations
   =========================================== */
@media (max-width: 768px) {
  /* Navbar adjustments */
  .top-navbar {
    height: 50px;
    padding: 0 10px;
    gap: 10px;
  }

  .navbar-logo {
    height: 34px;
  }

  .container {
    margin-top: 50px;
  }

  .main-nav {
    top: 50px;
    height: calc(100vh - 50px) !important;
  }

  .mobile-overlay {
    top: 50px;
  }

  /* Smaller panel padding */
  .left-panel .header {
    padding: 12px 14px;
  }

  .left-panel .content {
    padding: 12px 14px;
  }

  .right-panel {
    padding: 12px;
  }

  /* Output grid - single column on mobile for better usability */
  .output-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Model tabs - more compact */
  .model-tabs {
    flex-direction: column;
    gap: 6px;
  }

  .model-tab {
    padding: 10px 12px;
    font-size: 0.85rem;
    width: 100%;
    max-width: none;
    text-align: center;
  }

  /* Content mode - keep horizontal on phones, centered */
  .content-mode-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 12px;
  }

  .content-mode-info {
    display: none;
  }

  /* Output header */
  .output-header h2 {
    font-size: 1.2rem;
  }

  /* Marketplace adjustments */
  .marketplace-page {
    padding: 16px;
  }

  .marketplace-title {
    font-size: 1.5rem;
  }

  .marketplace-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  /* Footer */
  .footer-ai-disclosure {
    font-size: 0.7rem;
    padding: 6px 10px;
  }

  .footer-links {
    gap: 10px;
    font-size: 0.8rem;
  }

  /* Nav tabs */
  .nav-icon svg {
    width: 18px;
    height: 18px;
  }

  .nav-label {
    font-size: 0.55rem;
  }

  .nav-tab {
    padding: 12px 0;
  }
}

/* ===========================================
   VERY SMALL SCREENS (480px and below)
   Compact phone layouts
   =========================================== */
@media (max-width: 480px) {
  .top-navbar {
    height: 46px;
    padding: 0 8px;
  }

  .navbar-logo {
    height: 30px;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .user-credits {
    font-size: 0.6rem;
    padding: 3px 8px;
  }

  .navbar-brand-sub {
    display: none;
  }

  .container {
    margin-top: 46px;
  }

  .main-nav {
    top: 46px;
    height: calc(100vh - 46px) !important;
    width: 70px;
  }

  .mobile-overlay {
    top: 46px;
  }

  /* Even smaller padding */
  .left-panel .header,
  .left-panel .content {
    padding: 10px 12px;
  }

  .right-panel {
    padding: 10px;
    min-height: 250px;
  }

  /* Output grid - single column maintained on small phones */
  .output-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Compact model tabs - stacked vertically */
  .model-tabs {
    gap: 4px;
  }

  .model-tab {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  /* Reference upload - compact on small phones */
  .reference-upload {
    padding: 14px 12px;
  }

  .reference-upload-icon {
    font-size: 1.2rem;
    margin-bottom: 2px;
  }

  .reference-upload-text {
    font-size: 0.75rem;
  }

  /* Compact content mode */
  .content-mode-toggle {
    gap: 6px;
    padding: 8px 10px;
  }

  .content-mode-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  /* Compact generate button */
  .generate-btn {
    padding: 12px;
    font-size: 0.9rem;
  }

  /* Inpaint - extra compact on small phones */
  .inpaint-canvas-area {
    padding: 12px;
    min-height: 180px;
  }

  .inpaint-sidebar {
    padding: 12px;
    gap: 10px;
  }

  .inpaint-control-label {
    font-size: 0.75rem;
  }

  .inpaint-textarea {
    min-height: 50px;
    font-size: 0.85rem;
  }

  .inpaint-select {
    padding: 8px;
    font-size: 0.85rem;
  }

  .inpaint-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .inpaint-generate-btn {
    padding: 12px;
    font-size: 0.9rem;
  }

  .inpaint-mode-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .inpaint-header h2 {
    font-size: 1.1rem;
  }

  .inpaint-subtitle {
    font-size: 0.75rem;
  }

  .inpaint-result-section {
    padding: 12px;
  }

  /* Compact footer */
  .footer-links {
    gap: 8px;
    font-size: 0.75rem;
  }

  .footer-links a {
    font-size: 0.75rem;
  }

  .footer-ai-disclosure {
    font-size: 0.65rem;
    padding: 6px 8px;
  }

  /* Marketplace - single column */
  .marketplace-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .marketplace-title {
    font-size: 1.3rem;
  }

  /* Caption section */
  .caption-container {
    min-height: auto;
  }

  .caption-welcome {
    margin-top: 3vh;
  }

  .caption-welcome h1 {
    font-size: 1.5rem;
  }

  /* Reference grid */
  .reference-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============================================================================
   MOBILE DASHBOARD - Progressive Disclosure Layout
   Only shown on mobile devices (<= 900px)
   ============================================================================= */

/* Hide mobile dashboard on desktop */
.mobile-dashboard,
.mobile-account-sheet,
.mobile-back-bar {
  display: none;
}

/* Mobile Dashboard Styles - Only on mobile */
@media (max-width: 900px) {
  /* Hide the hamburger button since we have the dashboard */
  .hamburger-btn {
    display: none;
  }

  /* Show the dashboard by default on mobile */
  .mobile-dashboard {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 100;
    padding: 20px;
    /* Safe area insets for notched devices and landscape mode */
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide dashboard when viewing a tool */
  .mobile-dashboard.hidden {
    display: none;
  }

  /* Hide the main container content by default on mobile - show dashboard first */
  .container {
    display: none;
  }

  /* Show container when a tool is active */
  .container.mobile-tool-active {
    display: flex;
    margin-top: 90px; /* Extra space for back bar */
  }

  /* Hide the sidebar completely on mobile */
  .container.mobile-tool-active .main-nav {
    display: none !important;
  }

  /* Mobile Back Bar */
  .mobile-back-bar {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    height: 44px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    padding: 0 16px;
    /* Safe area insets for landscape mode */
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    align-items: center;
    justify-content: space-between;
  }

  .mobile-back-bar.visible {
    display: flex;
  }

  .mobile-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
  }

  .mobile-back-arrow {
    font-size: 1.2rem;
  }

  .mobile-current-tool {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-back-spacer {
    width: 60px;
  }

  /* Dashboard Header */
  .mobile-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
  }

  .mobile-dashboard-greeting {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .greeting-text {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .greeting-credits {
    font-size: 0.85rem;
    color: var(--text-secondary);
  }

  .mobile-dashboard-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: transform 0.2s;
    /* Button reset for semantic button element */
    border: none;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
  }

  .mobile-dashboard-avatar:active {
    transform: scale(0.95);
  }

  /* Tool Cards Grid */
  .mobile-dashboard-tools {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }

  .mobile-tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    /* Button reset for semantic button element */
    font-family: inherit;
    font-size: inherit;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
  }

  .mobile-tool-card:active {
    transform: scale(0.98);
    background: var(--bg-secondary);
  }

  .mobile-tool-icon {
    font-size: 2rem;
    margin-bottom: 4px;
  }

  .mobile-tool-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-tool-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
  }

  /* Wide tool card (for Marketplace) */
  .mobile-tool-card-wide {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
  }

  .mobile-tool-card-wide .mobile-tool-icon {
    font-size: 1.8rem;
    margin-bottom: 0;
  }

  .mobile-tool-card-wide .mobile-tool-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .mobile-tool-card-wide .mobile-tool-name {
    text-align: left;
  }

  .mobile-tool-card-wide .mobile-tool-desc {
    text-align: left;
  }

  /* Dashboard Section */
  .mobile-dashboard-section {
    margin-bottom: 24px;
  }

  .mobile-section-header {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
  }

  /* =========================================================================
     MOBILE ACCOUNT BOTTOM SHEET
     ========================================================================= */

  .mobile-account-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
  }

  .mobile-account-sheet.open {
    display: block;
  }

  .mobile-sheet-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
  }

  .mobile-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 14px));
    animation: slideUp 0.3s ease;
    max-height: 70vh;
    overflow-y: auto;
  }

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

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  .mobile-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 16px;
  }

  .mobile-sheet-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
  }

  .mobile-sheet-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
  }

  .mobile-sheet-user {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-sheet-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-sheet-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
  }

  .mobile-sheet-credits {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
  }

  .mobile-sheet-credits-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
  }

  .mobile-sheet-credits-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-secondary);
    flex: 1;
  }

  .mobile-sheet-buy-btn {
    background: var(--accent-gradient);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
  }

  .mobile-sheet-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
  }

  .mobile-sheet-menu {
    display: flex;
    flex-direction: column;
  }

  .mobile-sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
  }

  .mobile-sheet-item:active {
    background: var(--bg-secondary);
  }

  .mobile-sheet-item-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
  }

  .mobile-sheet-item-label {
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
  }

  .mobile-sheet-item-toggle {
    font-size: 0.85rem;
    color: var(--text-secondary);
  }

  .mobile-sheet-item-auth {
    color: var(--accent-primary);
  }

  .mobile-sheet-item-auth .mobile-sheet-item-label {
    color: var(--accent-primary);
  }
}

/* Smaller phones adjustments */
@media (max-width: 480px) {
  .mobile-dashboard {
    top: 46px;
    padding: 16px;
  }

  .mobile-back-bar {
    top: 46px;
  }

  .container.mobile-tool-active {
    margin-top: 90px;
  }

  .greeting-text {
    font-size: 1.2rem;
  }

  .mobile-tool-card {
    padding: 16px 12px;
  }

  .mobile-tool-icon {
    font-size: 1.6rem;
  }

  .mobile-tool-name {
    font-size: 0.85rem;
  }

  .mobile-tool-desc {
    font-size: 0.7rem;
  }
}

/* =============================================================================
   PHASE 2: MOBILE ENHANCEMENTS
   ============================================================================= */

@media (max-width: 900px) {
  /* =========================================
     OPTION A: TOOL SCREEN OPTIMIZATION
     Better touch targets and mobile-friendly controls
     ========================================= */

  /* Larger touch targets for buttons */
  .generate-btn {
    min-height: 52px;
    font-size: 1.05rem;
    border-radius: 12px;
    font-weight: 600;
  }

  /* Better prompt input for mobile */
  .prompt-input,
  #promptInput,
  textarea[id*="prompt" i] {
    min-height: 100px;
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    padding: 14px;
    border-radius: 12px;
    line-height: 1.5;
  }

  /* Larger select dropdowns for touch */
  .settings-grid select,
  .setting-item select {
    min-height: 48px;
    font-size: 16px !important;
    padding: 12px 14px;
    border-radius: 10px;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

  /* Model tabs - better touch targets */
  .model-tabs {
    gap: 6px;
    flex-wrap: wrap;
  }

  .model-tab {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.85rem;
    border-radius: 10px;
    flex: 1 1 auto;
  }

  /* Content mode toggle - larger buttons */
  .content-mode-btn {
    min-height: 40px;
    padding: 10px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  /* Reference upload area - better touch */
  .reference-upload {
    min-height: 100px;
    border-radius: 12px;
    padding: 20px;
  }

  /* Section labels - clearer hierarchy */
  .section-label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
  }

  /* Character dropdown - better touch */
  #characterSelect {
    min-height: 48px;
    font-size: 16px !important;
    padding: 12px;
  }

  /* Output images - better sizing */
  .output-images {
    gap: 12px;
  }

  .output-image-container {
    border-radius: 12px;
  }

  /* Result actions - larger buttons */
  .output-image-actions button,
  .result-actions button {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
  }

  /* =========================================
     OPTION B: QUICK ACTIONS SECTION
     ========================================= */

  .mobile-quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 4px 0;
    min-height: 52px;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mobile-quick-actions::-webkit-scrollbar {
    display: none;
  }

  .mobile-quick-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    min-height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-sizing: border-box;
    /* Button reset for semantic button element */
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
  }

  .mobile-quick-action:active {
    transform: scale(0.96);
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
  }

  .mobile-quick-action-icon {
    font-size: 1rem;
  }

  /* =========================================
     OPTION C: RECENT GENERATIONS SECTION
     ========================================= */

  .mobile-recent-section {
    margin-bottom: 24px;
  }

  .mobile-recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }

  .mobile-recent-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-recent-view-all {
    font-size: 0.8rem;
    color: var(--accent-primary);
    cursor: pointer;
  }

  .mobile-recent-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .mobile-recent-item {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
  }

  .mobile-recent-item:active {
    transform: scale(0.95);
  }

  .mobile-recent-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .mobile-recent-remix {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 46, 187, 0.9);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all 0.2s;
  }

  .mobile-recent-remix:active {
    transform: scale(1.1);
    opacity: 1;
  }

  .mobile-recent-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px dashed var(--border-color);
  }

  .mobile-recent-empty-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.5;
  }

  /* =========================================
     OPTION D: POLISH & GESTURES
     ========================================= */

  /* Smooth transitions for all interactive elements */
  .mobile-dashboard,
  .mobile-account-sheet,
  .mobile-back-bar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Pull indicator for swipe gestures */
  .mobile-swipe-indicator {
    position: fixed;
    top: 100px;
    left: 16px;
    right: 16px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 9999;
  }

  .mobile-swipe-indicator.active {
    opacity: 1;
  }

  /* Better tap feedback */
  .mobile-tool-card,
  .mobile-sheet-item,
  .mobile-quick-action,
  .mobile-recent-item {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  /* Pressed state with subtle scale */
  .mobile-tool-card:active,
  .mobile-sheet-item:active {
    transform: scale(0.98);
  }

  /* Account sheet slide animation improvement */
  .mobile-account-sheet {
    transition: none;
  }

  .mobile-account-sheet .mobile-sheet-content {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-account-sheet.open .mobile-sheet-content {
    transform: translateY(0);
  }

  .mobile-account-sheet:not(.open) .mobile-sheet-content {
    transform: translateY(100%);
  }

  /* Swipe handle styling for bottom sheet */
  .mobile-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 8px auto 16px;
    opacity: 0.6;
  }

  /* Haptic-ready button states */
  .mobile-dashboard-avatar,
  .mobile-back-btn {
    transition: transform 0.15s, opacity 0.15s;
  }

  .mobile-dashboard-avatar:active,
  .mobile-back-btn:active {
    transform: scale(0.92);
    opacity: 0.8;
  }

  /* Improved loading states */
  /* =========================================
     SKELETON LOADING STATES
     ========================================= */

  .skeleton {
    background: linear-gradient(
      90deg,
      var(--bg-tertiary) 0%,
      var(--bg-secondary) 50%,
      var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
  }

  .skeleton-text {
    height: 1em;
    border-radius: 4px;
  }

  .skeleton-text.short {
    width: 40%;
  }

  .skeleton-text.medium {
    width: 70%;
  }

  .skeleton-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
  }

  .skeleton-card {
    height: 100px;
    border-radius: 12px;
  }

  .skeleton-image {
    aspect-ratio: 1;
    border-radius: 10px;
  }

  /* Skeleton for tool cards */
  .mobile-tool-card.skeleton {
    pointer-events: none;
  }

  .mobile-tool-card.skeleton .mobile-tool-icon,
  .mobile-tool-card.skeleton .mobile-tool-name,
  .mobile-tool-card.skeleton .mobile-tool-desc {
    visibility: hidden;
  }

  /* Skeleton for recent images */
  .mobile-recent-item.skeleton {
    pointer-events: none;
  }

  .mobile-recent-item.skeleton img {
    visibility: hidden;
  }

  @keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  /* Fade in animation for loaded content */
  .fade-in {
    animation: fadeIn 0.3s ease-out;
  }

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

  /* Stagger animation delays for grid items */
  .stagger-1 { animation-delay: 0.05s; }
  .stagger-2 { animation-delay: 0.1s; }
  .stagger-3 { animation-delay: 0.15s; }
  .stagger-4 { animation-delay: 0.2s; }
  .stagger-5 { animation-delay: 0.25s; }
  .stagger-6 { animation-delay: 0.3s; }
  .stagger-7 { animation-delay: 0.35s; }
  .stagger-8 { animation-delay: 0.4s; }

  /* Scale-up animation for images loading */
  .scale-up {
    animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes scaleUp {
    from {
      opacity: 0;
      transform: scale(0.8);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  /* Pulse animation for active/loading states */
  .pulse {
    animation: pulse 2s ease-in-out infinite;
  }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
  }

  /* Pop animation for successful actions */
  .pop {
    animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
  }

  /* Slide-in from right for panels */
  .slide-in-right {
    animation: slideInRight 0.3s ease-out;
  }

  @keyframes slideInRight {
    from {
      opacity: 0;
      transform: translateX(20px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  /* Smooth image reveal animation */
  .image-reveal {
    animation: imageReveal 0.5s ease-out;
  }

  @keyframes imageReveal {
    0% {
      opacity: 0;
      clip-path: inset(0 100% 0 0);
    }
    100% {
      opacity: 1;
      clip-path: inset(0 0 0 0);
    }
  }

  /* Button press feedback */
  .mobile-tool-card:active,
  .mobile-quick-action:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }

  /* Smooth transitions for interactive elements */
  .mobile-tool-card,
  .mobile-quick-action,
  .mobile-recent-item,
  .mobile-auth-btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  }

  /* Hover lift effect */
  .mobile-tool-card:hover,
  .mobile-quick-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  /* Scroll snap for horizontal scrolling */
  .mobile-quick-actions {
    scroll-snap-type: x mandatory;
  }

  .mobile-quick-action {
    scroll-snap-align: start;
  }
}

/* ===========================================
   INPAINT MOBILE TOUCH MODE
   =========================================== */

/* Hide toggle button on desktop */
.inpaint-touch-mode-toggle,
.inpaint-touch-hint {
  display: none;
}

@media (max-width: 900px) {
  /* Mobile touch mode toggle button */
  .inpaint-touch-mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .inpaint-touch-mode-toggle:active {
    transform: scale(0.95);
  }

  .inpaint-touch-mode-toggle .toggle-icon {
    font-size: 1.1rem;
  }

  /* Navigate mode styling */
  .inpaint-touch-mode-toggle.navigate-mode {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
  }

  /* Canvas wrapper visual feedback */
  .inpaint-canvas-wrapper {
    position: relative;
    transition: box-shadow 0.2s ease;
  }

  .inpaint-canvas-wrapper:not(.navigate-mode) #inpaintCanvas,
  .inpaint-canvas-wrapper:not(.navigate-mode) #inpaintMaskCanvas {
    cursor: crosshair;
  }

  .inpaint-canvas-wrapper.navigate-mode #inpaintCanvas,
  .inpaint-canvas-wrapper.navigate-mode #inpaintMaskCanvas {
    cursor: grab;
  }

  /* Painting state visual feedback */
  #inpaintCanvas.painting,
  #inpaintMaskCanvas.painting {
    box-shadow: 0 0 0 3px var(--accent-primary);
  }

  /* First-use hint toast */
  .inpaint-touch-hint {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 101;
    opacity: 0;
    transition: all 0.3s ease;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 0.9rem;
    max-width: 250px;
  }

  .inpaint-touch-hint.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  .inpaint-touch-hint span {
    display: block;
    color: var(--text-primary);
  }

  .inpaint-touch-hint button {
    margin-top: 4px;
    padding: 8px 16px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }

  .inpaint-touch-hint button:active {
    transform: scale(0.95);
  }

  /* Ensure canvas wrapper has proper positioning for absolute children */
  .inpaint-canvas-wrapper {
    position: relative;
  }

  /* Edit tab canvas wrapper - same styles as inpaint */
  .edit-canvas-wrapper {
    position: relative;
    background: #0a0a0a;
    border-radius: 8px;
    overflow: visible; /* Allow toggle button to show outside */
    border: 1px solid var(--border-color);
  }

  .edit-canvas-wrapper:not(.navigate-mode) #maskCanvas {
    cursor: crosshair;
  }

  .edit-canvas-wrapper.navigate-mode #maskCanvas,
  .edit-canvas-wrapper.navigate-mode #bodyEditCanvas {
    cursor: grab;
  }

  .edit-canvas-wrapper:not(.navigate-mode) #bodyEditCanvas {
    cursor: crosshair;
  }

  #maskCanvas.painting {
    box-shadow: 0 0 0 3px var(--accent-primary);
  }

  /* Edit tab uses same toggle button styles as inpaint */
  #editTouchModeToggle {
    display: flex;
  }

  #editTouchHint {
    display: none;
  }

  #editTouchHint.visible {
    display: flex;
  }
}

/* ===========================================
   MOBILE FOOTER LINKS SHEET
   =========================================== */

/* Hide footer mobile elements on desktop */
.footer-mobile-slim {
  display: none;
}

.footer-links-sheet {
  display: none;
}

@media (max-width: 900px) {
  /* Footer links bottom sheet */
  .footer-links-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
  }

  .footer-links-sheet.open {
    display: block;
  }

  .footer-sheet-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
  }

  .footer-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 14px));
    animation: slideUp 0.3s ease;
    max-height: 70vh;
    overflow-y: auto;
  }

  .footer-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 16px;
    opacity: 0.6;
  }

  .footer-sheet-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
  }

  .footer-sheet-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .footer-sheet-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 12px;
    transition: background 0.15s;
  }

  .footer-sheet-links a:active {
    background: var(--bg-tertiary);
  }

  .footer-sheet-disclosure {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }

  .footer-sheet-disclosure .ai-badge {
    flex-shrink: 0;
  }

  /* ===========================================
     IMAGE LIBRARY MODAL - Mobile Bottom Sheet
     =========================================== */

  #imageLibraryModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25000;
    background: transparent;
  }

  #imageLibraryModal.active {
    display: block;
  }

  .library-modal-backdrop {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.2s ease;
  }

  #imageLibraryModal .modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
  }

  .library-modal-handle {
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 12px auto 0;
    opacity: 0.6;
  }

  #imageLibraryModal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
  }

  #imageLibraryModal .modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary, #fff);
  }

  #imageLibraryModal .modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary, #fff);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  #imageLibraryModal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }

  /* Filter buttons - scrollable row on mobile */
  #imageLibraryModal .library-modal-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }

  #imageLibraryModal .lib-filter-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* 2-column grid for larger thumbnails */
  #imageLibraryModal .library-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  #imageLibraryModal .library-modal-item {
    aspect-ratio: 1;
    border-radius: 10px;
  }

  #imageLibraryModal .library-item-badge {
    font-size: 0.6rem;
    padding: 2px 5px;
  }

  /* Footer - sticky at bottom */
  #imageLibraryModal .modal-footer {
    flex-shrink: 0;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
  }

  #imageLibraryModal .modal-footer .account-btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  /* Hide the close button in footer on mobile - use X or swipe */
  #imageLibraryModal .modal-footer .account-btn.secondary {
    display: none;
  }

  /* ===========================================
     CHARACTER MODAL - Mobile Optimization
     =========================================== */

  .character-modal {
    padding: 16px !important;
    align-items: center !important;
  }

  .character-modal-content {
    max-width: 100%;
    max-height: 90vh;
    height: auto;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .character-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
  }

  .character-modal-header {
    flex-direction: row;
    gap: 12px;
    padding: 12px;
    align-items: flex-start;
  }

  .character-modal-image {
    width: 120px;
    height: 120px;
    min-height: unset;
    max-height: unset;
    border-radius: 12px;
    flex-shrink: 0;
  }

  .character-modal-info {
    padding: 0;
    flex: 1;
    min-width: 0;
  }

  .character-modal-name {
    font-size: 1.1rem;
    margin-bottom: 2px;
  }

  .character-modal-category {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  .character-modal-description-wrapper,
  .character-modal-description {
    font-size: 0.85rem;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .character-modal-readmore {
    display: none;
  }

  .character-modal-tags {
    margin-bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .character-tag {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  /* Purchase section - compact */
  .character-modal-purchase {
    margin: 0;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
  }

  .character-modal-price {
    font-size: 1.3rem;
    margin-bottom: 0;
  }

  .character-modal-buy-btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    min-height: unset;
    white-space: nowrap;
  }

  /* Gallery on mobile - small horizontal scroll */
  .character-modal-gallery {
    padding: 12px;
    border-top: 1px solid var(--border-color);
  }

  .character-modal-gallery-title {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .character-gallery-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .character-gallery-grid::-webkit-scrollbar {
    display: none;
  }

  .character-gallery-item {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
  }

  /* Hide all the extra mobile optimization elements */
  .character-modal-sticky-bar,
  .character-gallery-toggle {
    display: none;
  }
}


/* ==================== FACE LOCK RESPONSIVE ==================== */

/* Tablet and below */
@media (max-width: 900px) {
  .facelock-control {
    padding: 14px 16px;
  }

  .facelock-mode-btn {
    min-height: 48px;
    font-size: 0.95rem;
  }

  .facelock-thumb {
    width: 60px;
    height: 60px;
  }

  .facelock-thumb-add {
    width: 60px;
    height: 60px;
  }

  /* Manager modal - full width on mobile */
  .facelock-manager-content {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
  }

  .facelock-add-content {
    max-width: 100%;
  }
}

/* Phone */
@media (max-width: 768px) {
  .facelock-thumb {
    width: 52px;
    height: 52px;
  }

  .facelock-thumb-add {
    width: 52px;
    height: 52px;
  }

  .facelock-manager-grid {
    gap: 10px;
  }

  .facelock-manager-item,
  .facelock-manager-add {
    border-radius: 10px;
  }
}

/* Small phone */
@media (max-width: 480px) {
  .facelock-control {
    padding: 12px 14px;
  }

  .facelock-thumb {
    width: 48px;
    height: 48px;
  }

  .facelock-thumb-add {
    width: 48px;
    height: 48px;
  }

  .facelock-manager-remove {
    opacity: 1;
  }
}
