/* Main Styles for Google Fonts Showcase */
@font-face {
    font-family: 'Roboto';
    src: url('https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxK.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary-color: #4285F4;
    --primary-gradient: linear-gradient(90deg, #4285F4 0%, #6A5ACD 25%, #9370DB 50%, #BA55D3 75%, #9932CC 100%);
    --dark-primary-color: #5a7bc4;
    --title-font: 'Arial', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Arial', 'Helvetica', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 0;
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Dark theme variant */
body.dark-theme {
    background-color: #212121;
    color: #f5f5f5;
}

.dark-theme .font-card {
    background-color: #333;
    color: #f5f5f5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.dark-theme .font-name:not([data-font-category="handwriting"]) {
    color: #EFEFEF;
    /* Very light grey for better visibility in dark mode */
}

/* Category-specific colors for font names in dark mode */
.dark-theme .font-card[data-font-category="sans-serif"] .font-name {
    color: #B3E5FC;
    /* Pale blue for Sans Serif font names */
}

.dark-theme .font-card[data-font-category="serif"] .font-name {
    color: #FFF9C4;
    /* Pale yellow for Serif font names */
}

.dark-theme .font-card[data-font-category="display"] .font-name {
    color: #D1C4E9;
    /* Light purple for Display font names - more visible */
}

.dark-theme .font-card[data-font-category="monospace"] .font-name {
    color: #C8E6C9;
    /* Pale green for Monospace font names */
}

.dark-theme .font-card[data-font-category="cursive"] .font-name,
body.dark-theme .font-card[data-font-category="cursive"] .font-name {
    color: #F5F5F5 !important;
    /* Slightly off-white for better contrast against dark background */
}

.dark-theme .font-size-badge,
.dark-theme .font-category,
.dark-theme .weights-badge,
.dark-theme .italic-badge {
    background-color: #4a5a6a;
    color: #8ab4f8;
}



.dark-theme .font-preview {
    color: #e0e0e0;
}

.dark-theme .btn-primary {
    background-color: var(--dark-primary-color);
}

.dark-theme .btn-primary:hover {
    background-color: #4a6bc4;
}

.dark-theme .btn-secondary {
    background-color: #424242;
    color: #f5f5f5;
}

/* Fix layering: html background -> background-letters -> body (transparent) -> content */
html {
    background-color: #f5f5f5;
    transition: background-color 0.3s;
}

html.dark-theme {
    background-color: #212121;
}

body {
    background-color: transparent !important;
    position: relative;
    z-index: 1;
}

/* BACKGROUND LETTERS STYLES */
.background-letters {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* Sits between HTML background and Body content */
    pointer-events: none;
    overflow: hidden;
}

.background-letter {
    position: absolute;
    color: var(--primary-color);
    line-height: 1;
    user-select: none;
    transition: color 0.3s, opacity 0.3s;
}

.corner-letter {
    opacity: 0.2;
    /* Reduced from 0.6 for a more subtle look */
    mix-blend-mode: soft-light;
    /* Premium watermark effect */
}

.pattern-letter {
    opacity: 0.4;
    /* High visibility */
}

/* Dark theme overrides for background letters - Removed to match light mode exactly as requested */
/* (Deleted overrides for .dark-theme .background-letter, .corner-letter, and .pattern-letter) */

#main-container,
.container {
    background: transparent !important;
}

.sticky-controls {
    z-index: 100;
}

.dark-theme .btn-secondary:hover {
    background-color: #525252;
}

.dark-theme #font-search,
.dark-theme #preview-text {
    background-color: #333;
    color: #f5f5f5;
    border-color: #555;
}

.dark-theme .category-btn {
    background-color: #333;
    border-color: #555;
    color: #f5f5f5;
}

/* Category-specific colors for sticky category buttons in dark mode */
.dark-theme .category-btn[data-category="sans-serif"] {
    color: #B3E5FC;
    /* Pale blue text for Sans Serif button */
}

.dark-theme .category-btn[data-category="serif"] {
    color: #FFF9C4;
    /* Pale yellow text for Serif button */
}

.dark-theme .category-btn[data-category="display"] {
    color: #D1C4E9;
    /* Light purple text for Display button - same as hover */
}

.dark-theme .category-btn[data-category="monospace"] {
    color: #C8E6C9;
    /* Pale green text for Monospace button */
}

.dark-theme .category-btn[data-category="cursive"] {
    color: #FFFFFF;
    /* White text for Cursive button */
}

/* Category-specific colors for sticky category buttons in light mode */
.category-btn[data-category="sans-serif"] {
    color: #003c8f;
    /* Dark blue text for Sans Serif button - better contrast on white */
}

.category-btn[data-category="sans-serif"]:hover,
.category-btn[data-category="sans-serif"].active {
    background-color: #B3E5FC;
    /* Pale blue background */
    color: #003c8f;
    /* Dark blue text for better readability */
    border-color: #1E88E5;
    /* Blue border for contrast */
}

.category-btn[data-category="serif"] {
    color: #5a4a00;
    /* Dark yellow/brown text for Serif button - better contrast on white */
}

.category-btn[data-category="serif"]:hover,
.category-btn[data-category="serif"].active {
    background-color: #FFF9C4;
    /* Pale yellow background */
    color: #5a4a00;
    /* Dark yellow/brown text for better readability */
    border-color: #FFD700;
    /* Gold border for contrast */
}

.category-btn[data-category="display"] {
    color: #4a148c;
    /* Dark purple text for Display button - better contrast on white */
}

.category-btn[data-category="display"]:hover,
.category-btn[data-category="display"].active {
    background-color: #D1C4E9;
    /* Light purple background */
    color: #4a148c;
    /* Dark purple text for better readability */
    border-color: #9C27B0;
    /* Purple border for contrast */
}

.category-btn[data-category="monospace"] {
    color: #1b5e20;
    /* Dark green text for Monospace button - better contrast on white */
}

.category-btn[data-category="monospace"]:hover,
.category-btn[data-category="monospace"].active {
    background-color: #C8E6C9;
    /* Pale green background */
    color: #1b5e20;
    /* Dark green text for better readability */
    border-color: #4CAF50;
    /* Green border for contrast */
}

.category-btn[data-category="cursive"] {
    color: #880e4f;
    /* Dark pink text for Cursive button - better contrast on white */
}

.category-btn[data-category="cursive"]:hover,
.category-btn[data-category="cursive"].active {
    background-color: #F8BBD0;
    /* Pale pink background */
    color: #880e4f;
    /* Dark pink text for better readability */
    border-color: #E91E63;
    /* Pink border for contrast */
}

.dark-theme .category-btn:hover,
.dark-theme .category-btn.active {
    background-color: var(--dark-primary-color);
    color: white;
    border-color: var(--dark-primary-color);
}

/* Sans Serif button states in dark mode */
.dark-theme .category-btn[data-category="sans-serif"]:hover {
    color: #B3E5FC;
    /* Keep pale blue text when hovered */
    background-color: #333;
    /* Dark grey background for contrast */
    border-color: #B3E5FC;
    /* Pale blue border - matches font name color */
}

.dark-theme .category-btn[data-category="sans-serif"].active {
    color: #B3E5FC;
    /* Keep pale blue text when active */
    background-color: #333;
    /* Dark grey background - consistent with other categories */
    border-color: #B3E5FC;
    /* Pale blue border - matches font name color */
}

/* Serif button states in dark mode */
.dark-theme .category-btn[data-category="serif"]:hover {
    color: #FFF9C4;
    /* Keep pale yellow text when hovered */
    background-color: #333;
    /* Dark grey background for contrast */
    border-color: #FFF9C4;
    /* Pale yellow border - matches font name color */
}

.dark-theme .category-btn[data-category="serif"].active {
    color: #FFF9C4;
    /* Keep pale yellow text when active */
    background-color: #333;
    /* Dark grey background - consistent with other categories */
    border-color: #FFF9C4;
    /* Pale yellow border - matches font name color */
}

/* Display button states in dark mode */
.dark-theme .category-btn[data-category="display"]:hover {
    color: #D1C4E9;
    /* Keep light purple text when hovered */
    background-color: #333;
    /* Dark grey background for contrast */
    border-color: #D1C4E9;
    /* Light purple border - matches font name color */
}

.dark-theme .category-btn[data-category="display"].active {
    color: #D1C4E9;
    /* Keep light purple text when active */
    background-color: #333;
    /* Dark grey background - consistent with other categories */
    border-color: #D1C4E9;
    /* Light purple border - matches font name color */
}

/* Monospace button states in dark mode */
.dark-theme .category-btn[data-category="monospace"]:hover {
    color: #C8E6C9;
    /* Keep pale green text when hovered */
    background-color: #333;
    /* Dark grey background for contrast */
    border-color: #C8E6C9;
    /* Pale green border - matches font name color */
}

.dark-theme .category-btn[data-category="monospace"].active {
    color: #C8E6C9;
    /* Keep pale green text when active */
    background-color: #333;
    /* Dark grey background - consistent with other categories */
    border-color: #C8E6C9;
    /* Pale green border - matches font name color */
}

/* Handwriting button hover/active states in dark mode */
.dark-theme .category-btn[data-category="cursive"]:hover {
    color: #F5F5F5;
    /* Off-white text for consistency with font names */
    background-color: #444;
    /* Slightly lighter grey for uniqueness */
    border-color: #F5F5F5;
    /* Off-white border to match text */
}

.dark-theme .category-btn[data-category="cursive"].active {
    color: #F5F5F5;
    /* Off-white text for consistency with font names */
    background-color: #333;
    /* Dark grey background for better contrast */
    border-color: #F5F5F5;
    /* Off-white border to match text */
}

/* Global card size button - matches category buttons but shows it's interactive */
#global-card-size-btn {
    position: relative;
    overflow: hidden;
    background-color: #e8f0fe;
    /* Match font category tag color */
    color: var(--primary-color);
    /* Match font category tag text color */
    padding-right: 25px !important;
    /* Ensure space for the + sign */
    min-width: 60px;
    /* Minimum width to prevent text overlap */
    white-space: nowrap;
    /* Prevent text wrapping */
}

#global-card-size-btn::after {
    content: '+';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: bold;
    opacity: 0.7;
    line-height: 1;
    /* Prevent vertical misalignment */
}

/* Responsive fixes for the global size button */
@media (max-width: 768px) {
    #global-card-size-btn {
        padding-right: 22px !important;
        /* Slightly less padding on tablets */
        min-width: 55px;
        /* Slightly smaller minimum width */
    }

    #global-card-size-btn::after {
        right: 6px;
        /* Move + sign slightly left */
        font-size: 11px;
        /* Slightly smaller + sign */
    }

    /* Preview text controls - adjust for tablets */
    #preview-text {
        padding-right: 75px !important;
        /* Slightly less padding on tablets */
    }

    .preview-text-controls {
        right: 12px !important;
        /* Adjust positioning for tablets */
        gap: 5px !important;
        /* Keep original 5px gap on tablets */
        top: 55% !important;
        /* Maintain perfect vertical alignment */
    }

    .preview-text-control-btn {
        width: 28px !important;
        /* Keep original 28px size on tablets */
        height: 28px !important;
    }
}

@media (max-width: 552px) {
    #global-card-size-btn {
        padding-right: 20px !important;
        /* Less padding on mobile */
        min-width: 50px;
        /* Smaller minimum width */
        font-size: 13px !important;
        /* Ensure text fits */
    }

    #global-card-size-btn::after {
        right: 5px;
        /* Move + sign closer */
        font-size: 10px;
        /* Smaller + sign for mobile */
    }

    /* Preview text controls - adjust for mobile */
    #preview-text {
        padding-right: 70px !important;
        /* Less padding on mobile */
    }

    .preview-text-controls {
        right: 10px !important;
        /* Adjust positioning for mobile */
        gap: 5px !important;
        /* Keep original 5px gap on mobile */
        top: 55% !important;
        /* Maintain perfect vertical alignment */
    }

    .preview-text-control-btn {
        width: 28px !important;
        /* Keep original 28px size on mobile */
        height: 28px !important;
        font-size: 16px !important;
        /* Slightly smaller font size for mobile */
    }
}

@media (max-width: 474px) {
    #global-card-size-btn {
        padding-right: 18px !important;
        /* Even less padding */
        min-width: 45px;
        /* Minimum width for small screens */
    }

    #global-card-size-btn::after {
        right: 4px;
        /* + sign very close to edge */
    }

    /* Preview text controls - adjust for very small screens */
    #preview-text {
        padding-right: 65px !important;
        /* Minimum padding for small screens */
    }

    .preview-text-controls {
        right: 8px !important;
        /* Adjust positioning for small screens */
        gap: 5px !important;
        /* Keep original 5px gap even on small screens */
        top: 55% !important;
        /* Maintain perfect vertical alignment */
    }

    .preview-text-control-btn {
        width: 26px !important;
        /* Smallest buttons for very small screens */
        height: 26px !important;
        font-size: 15px !important;
        /* Smallest font size for very small screens */
    }
}

#global-card-size-btn:hover {
    background-color: #d9e8fe;
    /* Slightly lighter blue on hover */
    border-color: var(--primary-color);
}

#global-card-size-btn:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

#global-card-size-btn.active {
    transform: scale(1.05);
    background-color: #cce0fe;
    /* Slightly darker light blue for active state */
    border-color: var(--primary-color);
    transition: all 0.3s ease;
}

/* Animation for global size button text change */
#global-card-size-btn {
    transition: all 0.3s ease;
}

/* Animation class for global size button - uses theme-appropriate colors */
#global-card-size-btn.global-size-animating {
    color: #4285F4;
}

.dark-theme #global-card-size-btn.global-size-animating {
    color: #8ab4f8;
}

/* Pulse animation for global size button */
#global-card-size-btn.global-size-pulsing {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(66, 133, 244, 0.5);
}

.dark-theme #global-card-size-btn.global-size-pulsing {
    box-shadow: 0 0 10px rgba(90, 123, 196, 0.5);
}

/* Highlight animation for cards when global size changes */
.font-card {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.dark-theme #global-card-size-btn {
    background-color: #2a2a2a;
    /* Slightly darker grey than other categories (#333) */
    color: white;
    /* Keep text white as requested */
    border-color: var(--primary-color);
    /* Blue border as requested */
}

.dark-theme #global-card-size-btn:hover {
    background-color: #3a3a3a;
    /* Slightly lighter grey on hover */
    border-color: #5a9cf8;
    /* Lighter blue border on hover */
}

.dark-theme #global-card-size-btn.active {
    background-color: #4a4a4a;
    /* Even lighter grey for active state */
    color: white;
    border-color: #72b3ff;
    /* Even lighter blue border when active */
}

.dark-theme .pagination button {
    background-color: #333;
    border-color: #555;
    color: #f5f5f5;
}

.dark-theme .test-results {
    background-color: #333;
    color: #f5f5f5;
}

.dark-theme .visual-demo {
    background-color: #2a3a2a;
}

/* Theme toggle button - dark background with same size as other buttons */
.theme-toggle-btn {
    padding: 8px 16px;
    background-color: #333;
    color: white;
    border: 2px solid #555;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn:hover {
    background-color: var(--dark-primary-color);
    color: white;
    border-color: var(--dark-primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.dark-theme .theme-toggle-btn {
    background-color: #333;
    border-color: #555;
    color: #f5f5f5;
}

.dark-theme .theme-toggle-btn:hover {
    background-color: #4a4a4a;
    color: #8ab4f8;
    border-color: #8ab4f8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Theme icon styling */
.theme-icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
    margin: 0;
}

.moon-path {
    fill: #FFD700;
    /* Yellow color for light mode */
    transition: all 0.3s ease;
}

.sun-icon {
    display: none;
}

.dark-theme .moon-path {
    fill: #f5f5f5;
    /* Light color for dark mode */
}

.dark-theme .sun-icon {
    display: block;
}

.dark-theme .moon-icon {
    display: none;
}

/* Preview text using card font */
#preview-text.using-card-font {
    font-weight: normal !important;
    padding: 14px 80px 14px 22px !important;
    /* Increased right padding to prevent overlap with buttons */
    border: 2px solid var(--primary-color) !important;
    background-color: white !important;
    /* Keep white background in light mode */
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2) !important;
}

.dark-theme #preview-text.using-card-font {
    background-color: #333 !important;
    border-color: var(--dark-primary-color) !important;
    color: #f5f5f5 !important;
    box-shadow: 0 0 0 2px rgba(90, 123, 196, 0.3) !important;
}

/* Toast notifications - ultra-compact design */
.font-selection-notification,
.global-size-notification,
.card-size-notification {
    position: fixed;
    right: 20px;
    padding: 8px 14px;
    /* Further reduced for ultra-compact size */
    background-color: var(--primary-color);
    color: white;
    border-radius: 20px;
    /* Reduced from 25px for more compact look */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    /* Lighter shadow */
    z-index: 1000;
    font-size: 12px;
    /* Further reduced for ultra-compact size */
    font-weight: 500;
    opacity: 0;
    transform: translateY(-15px);
    /* Reduced animation distance */
    transition: opacity 0.2s, transform 0.2s;
    /* Faster animation */
    line-height: 1.2;
    /* Even tighter line height */
    max-width: 300px;
    /* Prevent overly wide toasts */
    white-space: nowrap;
    /* Prevent line breaks */
    overflow: hidden;
    /* Hide overflow */
    text-overflow: ellipsis;
    /* Add ellipsis if text is too long */
}

/* Ultra-compact vertical stacking */
.font-selection-notification {
    top: 15px;
    /* Reduced from 20px */
}

.global-size-notification {
    top: 40px;
    /* Further reduced for ultra-tight spacing */
}

.card-size-notification {
    top: 65px;
    /* Further reduced for ultra-tight spacing */
}

/* Font size information display - enhanced with font name */
.font-size-info {
    position: absolute;
    left: 25px;
    top: -15px;
    font-size: 14px;
    color: #666;
    /* Match pagination info color */
    font-weight: normal;
    z-index: 1;
    pointer-events: none;
    transition: all 0.2s;
    max-width: 300px;
    /* Prevent overly wide text */
    white-space: nowrap;
    /* Single line */
    overflow: hidden;
    /* Hide overflow */
    text-overflow: ellipsis;
    /* Add ellipsis if needed */
}

/* Enhanced font size info with font name */
.font-size-info.with-font {
    font-weight: 500;
    /* Slightly bolder when showing font name */
    color: #666;
    /* Slightly darker for better visibility */
}

.dark-theme .font-size-info {
    color: #ccc;
    /* Match pagination info color */
    font-weight: normal;
    /* Ensure not bold */
}

#preview-text.using-card-font+.preview-text-controls+.font-size-info,
#preview-text.using-card-font~.font-size-info {
    color: var(--primary-color);
}

.dark-theme #preview-text.using-card-font+.preview-text-controls+.font-size-info,
.dark-theme #preview-text.using-card-font~.font-size-info {
    color: #ccc;
    font-weight: normal;
}

/* Animations for font info and button updates */
.highlight-update {
    color: #4285F4 !important;
    transition: color 0.2s ease, transform 0.2s ease;
}

.reset-update {
    color: #999 !important;
    transition: color 0.2s ease;
}

.dark-theme .highlight-update {
    color: #8ab4f8 !important;
}

#current-font-size {
    color: inherit;
    /* Ensure the span always matches parent color */
}

/* Preview text control buttons container */
.preview-text-controls {
    position: absolute;
    right: 15px;
    /* Moved slightly to the right to create space between text and buttons */
    top: 55%;
    /* Adjusted for perfect vertical alignment */
    transform: translateY(-50%);
    display: flex;
    gap: 5px;
    /* Keep original 5px gap between buttons */
    opacity: 1;
    /* Always visible */
    pointer-events: auto;
    /* Always interactive */
    transition: opacity 0.2s;
}



/* Individual control buttons */
.preview-text-control-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    width: 28px;
    /* Keep original 28px size */
    height: 28px;
    /* Keep original 28px size */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    padding: 0;
}

.preview-text-control-btn:hover {
    background-color: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
}

.dark-theme .preview-text-control-btn {
    color: #777;
}

.dark-theme .preview-text-control-btn:hover {
    background-color: rgba(90, 123, 196, 0.2);
    color: #8ab4f8;
}

/* Active state for size buttons */
.preview-text-control-btn.active {
    background-color: rgba(66, 133, 244, 0.2);
    color: var(--primary-color);
    font-weight: bold;
}

.dark-theme .preview-text-control-btn.active {
    background-color: rgba(90, 123, 196, 0.3);
    color: #8ab4f8;
}

.reset-preview-font-btn:hover {
    background-color: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
}

.dark-theme .reset-preview-font-btn {
    color: #777;
}

.dark-theme #preview-text.using-card-font+.reset-preview-font-btn {
    color: #8ab4f8;
}

.dark-theme .reset-preview-font-btn:hover {
    background-color: rgba(90, 123, 196, 0.2);
    color: #8ab4f8;
}

.background-letters {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.background-letter {
    position: absolute;
    user-select: none;
}

/* Individual corner letter colors - use classes for reliability */
.corner-letter.top-left {
    color: #B3E5FC;
}

/* Pale blue */
.corner-letter.top-right {
    color: #FFCDD2;
}

/* Pale yellow */
.corner-letter.bottom-left {
    color: #D1C4E9;
}

/* Light purple */
.corner-letter.bottom-right {
    color: #C8E6C9;
}

/* Pale green */

/* Dark mode - use very dark, subtle colors with extremely low opacity to be barely visible */
.dark-theme .corner-letter.top-left {
    color: #1a232a !important;
    opacity: 0.05;
}

.dark-theme .corner-letter.top-right {
    color: #2a1a1a !important;
    opacity: 0.05;
}

.dark-theme .corner-letter.bottom-left {
    color: #1a1523 !important;
    opacity: 0.05;
}

.dark-theme .corner-letter.bottom-right {
    color: #15231a !important;
    opacity: 0.05;
}

.pattern-letter {
    font-family: Arial, sans-serif;
    color: #FFF9C4;
    /* Pale yellow */
    opacity: 0.1;
    font-weight: 300;
}

/* Dark mode background letters - use very dark colors */
.dark-theme .corner-letter {
    color: #1a1a1a !important;
    /* Very dark gray */
}

.dark-theme .pattern-letter {
    color: #151515 !important;
    /* Even darker gray */
}

/* Additional background letter colors for more variety */
.dark-theme .background-letter.pale-purple {
    color: #D1C4E9 !important;
    /* Light purple */
}

.dark-theme .background-letter.pale-green {
    color: #C8E6C9 !important;
    /* Pale green */
}

.dark-theme .background-letter.off-white {
    color: #F5F5F5 !important;
    /* Off-white */
}

/* Add color variations for background letters using our pale colors */
.background-letter.pale-blue {
    color: #B3E5FC;
}

.background-letter.pale-yellow {
    color: #FFF9C4;
}

.background-letter.pale-purple {
    color: #E8EAF6;
}

.background-letter.pale-green {
    color: #C8E6C9;
}

.background-letter.off-white {
    color: #F5F5F5;
}

/* Show the 4 big corner letters in light mode */


.pattern-letter {
    font-family: Arial, sans-serif;
    color: rgba(40, 40, 40, 0.05);
    opacity: 0.05;
    font-weight: 300;
    /* Keep random letters visible in light mode */
}

/* Dark theme background letters - ensure they are barely visible */
.dark-theme .corner-letter {
    opacity: 0.05;
    display: block;
    /* Corner letters are extremely subtle in dark mode */
}

.dark-theme .pattern-letter {
    opacity: 0.03;
    /* Pattern letters are almost invisible in dark mode */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 20px;
    /* Space for sticky header */
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    position: relative;
    z-index: 50;
    /* Below sticky controls but above background */
}







/* Font counter in sticky controls */
.sticky-controls .font-counter {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    font-weight: 500;
    text-align: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
}

.dark-theme .sticky-controls .font-counter {
    color: #aaa;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sticky controls container */
.sticky-controls {
    position: sticky;
    top: 0;
    background-color: rgba(245, 245, 245, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
    padding: 0 15px 15px 15px;
    /* No top padding since counter is inside */
    border-radius: 0 0 12px 12px;
    /* Only round bottom corners */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    transition: all 0.3s;
    border: 1px solid rgba(0, 0, 0, 0.03);
    /* Subtle border for light theme */
    border-top: none;
    /* No top border for seamless look */
}

.dark-theme .sticky-controls {
    background-color: rgba(33, 33, 33, 0.9);
    /* Slightly reduced opacity to hint at background */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Very subtle border, slightly lighter than background */
}

/* Adjust spacing for sticky elements */
.sticky-controls .search-container {
    margin-bottom: 20px;
}

.sticky-controls .font-categories {
    margin-bottom: 20px;
}

.sticky-controls .preview-text-input {
    margin-bottom: 0;
}

h1,
body h1,
header h1,
.container h1 {
    font-family: var(--title-font) !important;
    background: linear-gradient(90deg, var(--primary-color) 0%, #6A5ACD 25%, #9370DB 50%, #BA55D3 75%, #9932CC 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    color: transparent !important;
    margin-bottom: 10px;
    font-size: 28px;
    display: inline-block;
}

@media (max-width: 768px) {

    h1,
    body h1,
    header h1,
    .container h1 {
        font-family: var(--title-font) !important;
        background: linear-gradient(90deg, var(--primary-color) 0%, #6A5ACD 25%, #9370DB 50%, #BA55D3 75%, #9932CC 100%) !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
        color: transparent !important;
        font-size: 24px;
        display: inline-block;
    }
}

@media (max-width: 552px) {

    h1,
    body h1,
    header h1,
    .container h1 {
        font-family: var(--title-font) !important;
        background: linear-gradient(90deg, var(--primary-color) 0%, #6A5ACD 25%, #9370DB 50%, #BA55D3 75%, #9932CC 100%) !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
        color: transparent !important;
        font-size: 20px;
        display: inline-block;
    }
}

/* Light theme gradient - ensure it works in light mode */
body:not(.dark-theme) h1,
body:not(.dark-theme) body h1,
body:not(.dark-theme) header h1,
body:not(.dark-theme) .container h1 {
    background: linear-gradient(90deg, var(--primary-color) 0%, #6A5ACD 25%, #9370DB 50%, #BA55D3 75%, #9932CC 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    color: transparent !important;
}

/* Dark theme gradient variant - blue to violet for consistency */
.dark-theme h1,
.dark-theme body h1,
.dark-theme header h1,
.dark-theme .container h1 {
    background: linear-gradient(90deg, #8ab4f8 0%, #9370DB 25%, #BA55D3 50%, #DDA0DD 75%, #C71585 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    color: transparent !important;
}

@media (max-width: 768px) {
    .dark-theme h1 {
        font-size: 24px;
    }
}

@media (max-width: 552px) {
    .dark-theme h1 {
        font-size: 20px;
    }
}

.subtitle {
    color: #666;
    font-size: 18px;
}

.font-number {
    position: absolute !important;
    bottom: 10px !important;
    left: 10px !important;
    font-weight: bold;
    color: #ccc;
    /* Lighter grey */
    font-size: 14px;
    z-index: 1;
}

.font-card {
    position: relative;
    /* Needed for absolute positioning of font-number */
}

.search-container {
    margin-bottom: 30px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 500px;
}

.search-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

#font-search {
    padding: 12px 20px;
    width: 100%;
    max-width: 500px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
    padding-right: 40px;
    /* Make space for clear button */
}

#clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 18px;
    display: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 1;
}

#clear-search:hover {
    color: #666;
    background-color: rgba(0, 0, 0, 0.05);
}

#clear-search:active {
    transform: translateY(-50%) scale(0.95);
}

.dark-theme #clear-search {
    color: #777;
}

.dark-theme #clear-search:hover {
    color: #ccc;
    background-color: rgba(255, 255, 255, 0.1);
}

#font-search:focus {
    border-color: var(--primary-color);
}

.font-categories {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    gap: 10px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 10px 20px;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

@media (max-width: 768px) {
    .category-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
}

@media (max-width: 552px) {
    .category-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .font-categories {
        gap: 8px;
    }
}

.category-btn:hover,
.category-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.fonts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    padding: 0 15px;
    width: 100%;
    box-sizing: border-box;
}

.font-card {
    background-color: white;
    border-radius: 10px;
    padding: 20px 20px 15px;
    /* Reduced bottom padding for better button fit */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0 !important;
    /* Prevent flex shrinking to maintain card size */
}

@media (max-width: 552px) {
    .font-card {
        min-height: 280px !important;
        /* Maintain consistent height at 552px and above mobile */
    }
}

.font-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

/* Font variant badges - three separate tags */
.font-variants {
    display: inline-flex;
    gap: 6px;
    margin-left: 8px;
    height: 16px;
    flex-wrap: wrap;
    align-items: center;
}

/* UNIFIED TAG SYSTEM */
.font-size-badge,
.font-category,
.weights-badge,
.italic-badge,
.variant-badge {
    display: inline-block;
    padding: 4px 12px;
    background-color: #e8f0fe;
    color: var(--primary-color);
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
    margin-bottom: 0;
    vertical-align: middle;
    visibility: visible !important;
    opacity: 1 !important;
}

.variant-badge.italic,
.italic-badge {
    font-style: italic;
}

.variant-badge:hover {
    transform: scale(1.1);
    background-color: #e0e0e0;
    cursor: help;
}

.variant-badge.active {
    opacity: 1;
    background-color: #e0e0e0;
}

.weight-badge {
    font-weight: bold;
}

/* Badge for fonts with poor accent support */
.accent-warning-badge {
    display: inline-block;
    padding: 4px 12px;
    background-color: #ffebee;
    color: #c62828;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
    margin-bottom: 0;
    vertical-align: middle;
    visibility: visible !important;
    opacity: 1 !important;
}

.font-name {
    font-size: 28px;
    margin-bottom: 8px;
    color: #333333;
    line-height: 1.1;
    display: flex;
    align-items: center;
    max-width: 85%;
    /* Restore truncation to avoid layout issues */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-name.long-name {
    font-size: 22px;
}

.font-name.extra-long-name {
    font-size: 18px;
}



/* Caps Badge - Different color for CAPS (green) */
.caps-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background-color: #e8f5e9;
    color: #2E7D32;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    border: 1px solid #2E7D32;
    height: 18px;
    vertical-align: middle;
}

/* Container for ALL tags - align them horizontally */
.font-category-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    /* Reduced gap for tighter spacing */
    margin-bottom: 15px;
}

/* Container for variant badges only */
.font-variants {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    /* Reduced gap for tighter spacing */
    margin-bottom: 0;
    /* Remove margin since it's inside category container */
}

.font-preview {
    font-size: 16px;
    line-height: 1.4;
    color: #555;
    margin-bottom: 15px;
    min-height: 80px;
    transition: font-size 0.2s;
    overflow-x: hidden;
    /* Prevent horizontal overflow */
    text-overflow: ellipsis;
    /* Add ellipsis for overflowed text */
}

/* Cursive fonts - larger default size and higher max size */
.font-card[data-font-category="cursive"] .font-preview {
    font-size: 20px;
}

.card-size-increase-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    opacity: 0.7;
}

.card-size-increase-btn:hover {
    color: var(--primary-color);
    background-color: rgba(66, 133, 244, 0.1);
    opacity: 1;
    transform: scale(1.1);
}

.card-size-increase-btn:active {
    transform: scale(0.95);
}

.card-size-increase-btn.active {
    color: var(--primary-color);
    background-color: rgba(66, 133, 244, 0.2);
    opacity: 1;
    transform: scale(1.2);
}

.dark-theme .card-size-increase-btn {
    color: #777;
}

.dark-theme .card-size-increase-btn:hover {
    color: #8ab4f8;
    background-color: rgba(90, 123, 196, 0.2);
}

/* Fallback font indicator - purple color */
.font-preview.fallback {
    color: #9C27B0;
    /* Distinctive purple */
    font-style: italic;
}

.font-preview.fallback::after {
    content: " [Fallback Font]";
    font-size: 14px;
    font-weight: bold;
    color: #9C27B0;
    font-style: normal;
}

.font-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
    padding-bottom: 15px;
    /* Ensure space below buttons */
    flex-wrap: wrap;
    /* Allow wrapping if needed */
}

.favorite-heart {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer !important;
    /* Ensure cursor stays pointer */
    color: #ccc;
    transition: all 0.3s;
    z-index: 10;
}

.favorite-heart.favorited {
    color: #ff4444;
}

/* Special favorites summary card styles */
.favorites-summary-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid #ff4444;
    position: relative;
    overflow: hidden;
}

.favorites-summary-card .font-card-content {
    position: relative;
    padding: 20px 20px 15px 20px;
    min-height: 260px;
}

.favorites-summary-card::before {
    content: "F";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
    font-size: 250px;
    font-weight: 900;
    color: rgba(255, 68, 68, 0.08);
    z-index: 0;
    line-height: 1;
    user-select: none;
    pointer-events: none;
    font-family: Arial, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorites-summary-card>* {
    position: relative;
    z-index: 1;
}

.favorites-summary-card .font-name {
    font-size: 24px !important;
    font-weight: 700 !important;
    color: #ff4444 !important;
    margin-bottom: 15px !important;
    text-align: center !important;
}

.favorites-list-simple {
    margin: 15px 0;
    padding: 10px;
    background-color: rgba(255, 68, 68, 0.05);
    border-radius: 6px;
    border: 1px dashed #ff4444;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-break: break-word;
    user-select: text;
    cursor: text;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
}

/* Dropdown menu styles for better visibility at 16px font size */
.dropdown-menu {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    z-index: 2000;
    min-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    right: 0;
    left: auto;
    font-size: 14px;
    margin-bottom: 10px;
    bottom: 100%;
}

.dropdown-menu .dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.4;
}

.dropdown-menu .dropdown-item:hover {
    background-color: #f0f0f0;
}

/* Dark theme dropdown menu */
.dark-theme .dropdown-menu {
    background-color: #333;
    border-color: #555;
}

.dark-theme .dropdown-menu .dropdown-item {
    color: #f5f5f5;
}

.dark-theme .dropdown-menu .dropdown-item:hover {
    background-color: #4a4a4a;
}

/* Favorites buttons container styles */
.favorites-buttons-container {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.copy-list-container {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
    /* Ensure buttons stay aligned horizontally */
}

/* Firefox-specific fix for mobile layout - enhanced version */
@-moz-document url-prefix() {
    .copy-list-container {
        flex-wrap: nowrap !important;
        /* Prevent wrapping in Firefox - force with !important */
        align-items: center !important;
        /* Ensure vertical alignment */
        justify-content: flex-start !important;
        /* Force horizontal alignment */
    }

    .copy-list-container .btn {
        min-width: 80px !important;
        /* Minimum width for buttons - force with !important */
        flex-shrink: 0 !important;
        /* Prevent buttons from shrinking - force with !important */
        flex-grow: 0 !important;
        /* Prevent buttons from growing */
        white-space: nowrap !important;
        /* Prevent text wrapping */
    }

    .copy-list-container .dropdown-toggle {
        min-width: 40px !important;
        /* Minimum width for dropdown button - force with !important */
        flex-shrink: 0 !important;
        /* Prevent dropdown from shrinking - force with !important */
        flex-grow: 0 !important;
        /* Prevent dropdown from growing */
        white-space: nowrap !important;
        /* Prevent text wrapping */
    }

    /* Additional Firefox-specific fixes */
    .copy-list-container>* {
        display: inline-flex !important;
        /* Force inline-flex display */
        vertical-align: middle !important;
        /* Ensure vertical alignment */
    }
}

.dropdown {
    position: relative;
    display: inline-block;
}

/* Responsive adjustments for favorites card */
@media (max-width: 768px) {
    .favorites-summary-card .font-card-content {
        min-height: 240px;
    }

    .dropdown-menu {
        min-width: 180px;
        font-size: 13px;
    }
}

@media (max-width: 552px) {
    .favorites-summary-card .font-card-content {
        min-height: 220px;
    }

    .dropdown-menu {
        min-width: 160px;
        font-size: 12px;
    }

    .dropdown-menu .dropdown-item {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 474px) {
    .favorites-summary-card .font-card-content {
        min-height: 200px;
    }

    .favorites-buttons-container {
        flex-direction: column;
        gap: 8px;
    }

    .copy-list-container {
        flex-direction: row;
        gap: 4px;
        justify-content: flex-start;
        align-items: center;
        flex-wrap: nowrap !important;
        /* Prevent wrapping on mobile - force with !important */
        width: 100% !important;
        /* Ensure full width */
    }

    .copy-list-container .btn {
        min-width: 70px !important;
        /* Minimum width for mobile buttons - force with !important */
        flex-shrink: 0 !important;
        /* Prevent buttons from shrinking - force with !important */
        flex-grow: 0 !important;
        /* Prevent buttons from growing */
        white-space: nowrap !important;
        /* Prevent text wrapping */
    }

    .copy-list-container .dropdown-toggle {
        min-width: 35px !important;
        /* Minimum width for mobile dropdown - force with !important */
        flex-shrink: 0 !important;
        /* Prevent dropdown from shrinking - force with !important */
        flex-grow: 0 !important;
        /* Prevent dropdown from growing */
        white-space: nowrap !important;
        /* Prevent text wrapping */
    }

    /* Additional mobile fixes */
    .copy-list-container>* {
        display: inline-flex !important;
        /* Force inline-flex display */
        vertical-align: middle !important;
        /* Ensure vertical alignment */
    }

    /* Firefox mobile fallback - use display: inline-block if flex fails */
    @-moz-document url-prefix() {
        .copy-list-container.fallback {
            display: inline-block !important;
            white-space: nowrap !important;
        }

        .copy-list-container.fallback>* {
            display: inline-block !important;
            vertical-align: middle !important;
            margin-right: 4px !important;
        }

        .copy-list-container.fallback .dropdown-toggle {
            margin-right: 0 !important;
        }
    }

    .dropdown {
        width: auto;
        margin-left: auto;
    }

    .dropdown-menu {
        min-width: 140px;
        font-size: 11px;
        right: 0;
        left: auto;
        bottom: 100%;
        top: auto;
        margin-top: 0;
        margin-bottom: 10px;
        transform: none;
        position: absolute;
    }
}

.copy-all-favorites-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
    background-color: #ff4444;
    border: none;
}

.copy-all-favorites-btn:hover {
    background-color: #e63838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
}

.dark-theme .favorites-summary-card {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    border-left: 4px solid #ff6b6b;
}

.dark-theme .favorites-summary-card::before {
    color: rgba(255, 107, 107, 0.06);
}

.dark-theme .favorites-summary-card .font-name {
    color: #ff6b6b !important;
}

.dark-theme .favorites-list-simple {
    background-color: rgba(255, 107, 107, 0.05);
    border-color: #ff6b6b;
    color: #f5f5f5;
}

.dark-theme .copy-all-favorites-btn {
    background-color: #ff6b6b;
}

.dark-theme .copy-all-favorites-btn:hover {
    background-color: #ff5a5a;
}

.favorite-heart:hover {
    transform: scale(1.2);
}

/* Ensure all cards have same height and buttons at bottom */
.font-card {
    min-height: 280px;
    /* Unified min-height for all cards */
    overflow-x: hidden;
    /* Prevent horizontal overflow on cards */
}

.font-card-content {
    flex-grow: 1;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #3367D6;
}

.btn-secondary {
    background-color: #f1f1f1;
    color: #333;
}

.btn-secondary:hover {
    background-color: #e1e1e1;
}

.preview-text-input {
    margin: 30px auto 20px;
    max-width: 1200px;
    padding: 0 20px;
    position: relative;
    /* Ensure proper positioning context */
}

.preview-text-input>div {
    position: relative;
    /* Positioning context for font size info */
    overflow: visible;
    /* Ensure child elements aren't clipped */
}

/* Global card size control */
.global-card-controls {
    margin: 10px auto 20px;
    max-width: 1200px;
    padding: 0 20px;
    text-align: center;
}

.global-card-controls button {
    padding: 12px 24px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.global-card-controls button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.global-card-controls button:active {
    transform: translateY(0);
}

.global-card-controls button.active {
    background-color: #3e8e41;
    transform: scale(1.05);
}

.dark-theme .global-card-controls button {
    background-color: #4CAF50;
    color: white;
}

.dark-theme .global-card-controls button:hover {
    background-color: #45a049;
}

#preview-text {
    padding: 12px 80px 12px 25px;
    /* Increased left padding to 25px and top/bottom to 12px for better font rendering */
    /* Increased right padding to 80px to ensure text doesn't touch buttons */
    width: 100%;
    max-width: 100%;
    border: 2px solid #ddd;
    border-radius: 25px;
    outline: none;
    box-sizing: border-box;
    background-color: white;
    /* White background for light mode */
    transition: background-color 0.3s, border-color 0.3s;
    margin-top: 10px;
    /* Space for the font size info above */
    position: relative;
    /* Make this the positioning context for buttons */
    text-align: left;
    /* Ensure text starts from the left */
    text-indent: 0;
    /* Remove any text indent */
    overflow: visible;
    /* Ensure text isn't clipped */
    white-space: normal;
    /* Allow text to wrap normally */
    line-height: normal;
    /* Normal line height for proper text rendering */
    font-variant-ligatures: none;
    /* Disable ligatures that might cause rendering issues */
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #666;
}

.no-results {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #666;
    margin: 0 auto;
    max-width: 600px;
    background-color: #333;
    color: #f5f5f5;
    border-radius: 8px;
    padding: 30px 20px;
}

/* Special styling for "no favorites" message */
.favorites-summary-card+.no-results {
    background: linear-gradient(135deg, #ffebee 0%, #fce4ec 100%);
    color: #d32f2f;
    border: 2px dashed #ffcdd2;
}

.dark-theme .favorites-summary-card+.no-results {
    background: linear-gradient(135deg, #4a1414 0%, #6a1b1b 100%);
    color: #ff8a80;
    border: 2px dashed #ff5252;
}

.no-results ❤️ {
    font-size: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

.dark-theme .no-results {
    background-color: #2a2a2a;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    /* Reduced from 10px to keep compact */
    margin: 20px 0;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 12px;
    /* Slightly less horizontal padding */
    border: 2px solid #ddd;
    background-color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.pagination-top {
    margin-bottom: 20px;
    margin-top: 0;
}

#pagination-top-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.pagination button,
.pagination-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background-color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.pagination button:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-info {
    font-size: 14px;
    color: #666;
    margin: 0 10px;
    /* Reduced from 15px to keep compact */
}

.dark-theme .pagination-info {
    color: #ccc;
    /* Lighter grey for better visibility in dark mode */
}

@media (max-width: 1200px) and (min-width: 769px) {
    .fonts-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        padding: 0 20px;
    }
}

@media (max-width: 768px) {
    .fonts-grid {
        grid-template-columns: 1fr;
    }
}

/* Test pagination styles */
.test-results {
    margin-top: 20px;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 5px;
}

.success {
    color: green;
}

.error {
    color: red;
}

.visual-demo {
    margin: 20px 0;
    padding: 15px;
    background: #e8f5e9;
    border-radius: 5px;
}

.demo-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

.demo-button {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
}

.demo-info {
    font-size: 14px;
    color: #666;
}

.demo-info strong {
    font-weight: bold;
}

/* Footer Disclaimer Styles */
.footer-disclaimer {
    background-color: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px 0;
    margin-top: 50px;
    border-top: 1px solid #e9ecef;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-text {
    text-align: center;
    margin-bottom: 30px;
}

.footer-copyright {
    text-align: center;
    margin-top: 25px;
    font-size: 13px;
    color: #868e96;
    font-style: italic;
    opacity: 0.9;
    transition: all 0.3s ease;
}

.footer-copyright a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(134, 142, 150, 0.3);
    padding-bottom: 1px;
    transition: all 0.3s ease;
}

.footer-copyright a:hover {
    color: #495057;
    border-bottom-color: rgba(73, 80, 87, 0.5);
    opacity: 1;
}


.footer-logo-centered {
    margin-top: 30px;
    text-align: center;
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
}

.footer-logo-centered img {
    max-width: 375px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    opacity: 0.95;
    transition: all 0.3s ease;
    display: inline-block;
}

.footer-logo-centered img:hover {
    opacity: 1;
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

.disclaimer-text {
    color: #6c757d;
    margin-bottom: 10px;
}

.disclaimer-text strong {
    color: #495057;
    font-weight: 600;
}

.last-updated {
    color: #868e96;
    font-size: 13px;
    margin-bottom: 15px;
    font-style: italic;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Footer link styles removed - no longer needed */

/* Dark Theme Footer Styles */
.dark-theme .footer-disclaimer {
    background-color: rgba(45, 45, 45, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #444;
}

.dark-theme .disclaimer-text {
    color: #adb5bd;
}

.dark-theme .disclaimer-text strong {
    color: #e9ecef;
}

.dark-theme .last-updated {
    color: #8d99ae;
}

/* Dark theme footer link styles removed - no longer needed */

/* Responsive Footer */
@media (max-width: 768px) {
    .footer-text {
        margin-bottom: 20px;
    }

    .footer-logo-centered img {
        max-width: 375px;
        width: 100%;
    }

    .footer-disclaimer {
        padding: 15px 0;
        margin-top: 30px;
    }

    .disclaimer-text {
        font-size: 13px;
    }

    .last-updated {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .footer-logo-centered img {
        max-width: 375px;
        width: 100%;
    }

    .footer-copyright {
        font-size: 12px;
        margin-top: 20px;
    }
}

/* Dark theme footer logo */
.dark-theme .footer-logo-centered img {
    opacity: 0.9;
}

/* Dark theme footer copyright */
.dark-theme .footer-copyright {
    color: #8d99ae;
    opacity: 0.8;
}

.dark-theme .footer-copyright a {
    border-bottom-color: rgba(141, 153, 174, 0.3);
}

.dark-theme .footer-copyright a:hover {
    color: #e9ecef;
    border-bottom-color: rgba(233, 236, 239, 0.5);
}

/* Favorites button styles */
.favorites-btn-heart {
    color: #ccc;
    transition: all 0.3s;
    margin-right: 5px;
}

.dark-theme .favorites-btn-heart {
    color: #777;
}

.favorites-btn-heart.favorited {
    color: #ff4444;
}

.dark-theme .favorites-btn-heart.favorited {
    color: #ff6b6b;
}

#favorites-count {
    margin: 0 5px;
    font-weight: 600;
}

.dark-theme #favorites-count {
    color: #f5f5f5;
}

/* Removed Fonts Modal Styles */
.removed-fonts-link {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    font-weight: 500;
}

.removed-fonts-link:hover {
    color: #3367D6;
    text-decoration: underline;
}

/* Modal styles - card-like appearance */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #ffffff;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 80%;
    max-width: 800px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid #e0e0e0;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.modal-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3367D6 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close-modal {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-modal:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-description {
    color: #666;
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.5;
}

.removed-fonts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.removed-font-item {
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.removed-font-item-link {
    text-decoration: none;
    display: block;
}

.removed-font-item-link:hover .removed-font-item {
    background-color: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.removed-font-item-link:active .removed-font-item {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Dark theme modal styles */
.dark-theme .modal-content {
    background-color: #2d2d2d;
    border-color: #444;
}

.dark-theme .modal-body {
    color: #e0e0e0;
}

.dark-theme .modal-description {
    color: #b0b0b0;
}

.dark-theme .removed-font-item {
    background-color: #3a3a3a;
    border-color: #555;
    color: #f0f0f0;
}

.dark-theme .removed-font-item-link:hover .removed-font-item {
    background-color: #4a4a4a;
}

/* Mobile-specific fixes for font display */
@media (max-width: 768px) {

    /* Fix for Serif category - handle longer font names */
    .font-card[data-font-category="serif"] .font-name {
        font-size: 28px;
        /* Slightly smaller for Serif on mobile */
        line-height: 1.3;
        max-width: 90%;
        /* More restrictive for Serif fonts */
        word-break: break-word;
        /* Allow breaking long words */
    }

    /* Fix for CAPS category as well */
    .font-card[data-font-category="caps"] .font-name {
        font-size: 26px;
        /* Slightly smaller for CAPS on mobile */
        line-height: 1.3;
        max-width: 95%;
        /* Slightly more restrictive for CAPS fonts */
        word-break: break-word;
        /* Allow breaking long words */
    }

    /* Fix for Monospace category - often has technical names */
    .font-card[data-font-category="monospace"] .font-name {
        font-size: 24px;
        /* Slightly smaller for Monospace on mobile */
        line-height: 1.3;
        max-width: 92%;
        /* More restrictive for Monospace fonts */
        word-break: break-word;
        /* Allow breaking long words */
    }
}

/* Additional fixes for smaller screens */
@media (max-width: 552px) {

    /* More aggressive fixes for very small screens */
    .font-card .font-name {
        font-size: 22px !important;
        /* Consistent smaller size for all categories */
        line-height: 1.2 !important;
        max-width: 85% !important;
        /* More restrictive for all */
        white-space: nowrap !important;
        /* Prevent wrapping */
        overflow: hidden !important;
        /* Hide overflow */
        text-overflow: ellipsis !important;
        /* Add ellipsis */
    }

    /* Specific adjustments for Serif and CAPS */
    .font-card[data-font-category="serif"] .font-name {
        max-width: 80% !important;
        /* Even more restrictive for Serif */
    }

    .font-card[data-font-category="caps"] .font-name {
        max-width: 82% !important;
        /* More restrictive for CAPS */
    }

    /* Ensure font cards don't overflow on very small screens - maintain consistent height */
    .font-card {
        min-height: 280px !important;
        /* Maintain same height as 552px */
        max-height: 320px !important;
        /* Allow slight expansion if needed */
    }

    /* Adjust font preview for small screens - only if no global size applied */
    .font-preview:not([style*="font-size"]):not(.global-size-applied) {
        font-size: 14px !important;
        /* Smaller preview text */
        min-height: 60px !important;
        /* Reduced preview height */
    }

    /* Ensure cards fit in small screens */
    .fonts-grid {
        grid-template-columns: 1fr !important;
        /* Single column on very small screens */
        gap: 15px !important;
        /* Reduced gap */
    }
}

/* Consistent behavior for small screens (474px and below) */
@media (max-width: 474px) {
    .font-card .font-name {
        font-size: 22px !important;
        /* Maintain same size as 552px for consistency */
        max-width: 85% !important;
        /* Less restrictive for better readability */
    }

    .font-card[data-font-category="caps"] .font-name {
        max-width: 82% !important;
        /* Consistent with 552px behavior */
    }

    .font-card {
        min-height: 280px !important;
        /* Maintain consistent height */
        max-height: 320px !important;
    }

    .font-preview:not([style*="font-size"]):not(.global-size-applied) {
        font-size: 14px !important;
        /* Slightly larger for better readability */
        min-height: 60px !important;
        /* More space for text */
    }
}

/* Consistent behavior for very small screens (442px and below) */
@media (max-width: 442px) {
    .font-card .font-name {
        font-size: 22px !important;
        /* Maintain same size as larger breakpoints */
        max-width: 80% !important;
        /* Less restrictive for better consistency */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Special handling for Serif fonts - maintain consistency */
    .font-card[data-font-category="serif"] .font-name {
        font-size: 22px !important;
        /* Same as other categories */
        max-width: 75% !important;
        /* Less restrictive for better consistency */
        letter-spacing: normal;
        /* Normal spacing */
    }

    /* Handling for long Serif font names */
    .font-card[data-font-category="serif"] .font-name.long-serif-name {
        font-size: 20px !important;
        /* Slightly smaller but still readable */
        max-width: 70% !important;
        letter-spacing: normal;
    }

    /* Extra restrictive for long Monospace and CAPS font names */
    .font-card[data-font-category="monospace"] .font-name.long-mono-caps-name,
    .font-card[data-font-category="caps"] .font-name.long-mono-caps-name {
        font-size: 15px !important;
        max-width: 65% !important;
        letter-spacing: -0.6px;
        font-weight: 500;
        /* Slightly lighter to save space */
    }

    /* Special handling for CAPS and Monospace categories */
    .font-card[data-font-category="caps"] .font-name,
    .font-card[data-font-category="monospace"] .font-name {
        max-width: 72% !important;
        /* More restrictive for CAPS and Monospace */
        font-size: 17px !important;
        /* Slightly smaller for better fit */
    }

    .font-card {
        min-height: 280px !important;
        /* Maintain consistent height */
        max-height: 320px !important;
    }

    .font-preview:not([style*="font-size"]) {
        font-size: 12px !important;
        min-height: 40px !important;
    }

    /* Button fixes for small screens - prevent overflow */
    .font-actions {
        flex-wrap: wrap;
        /* Allow buttons to wrap if needed */
        gap: 8px;
        /* Reduced gap for tighter spacing */
        margin-top: 8px;
        /* Reduced margin for tighter spacing */
        padding-bottom: 8px;
        /* Add padding to prevent buttons from touching bottom */
    }

    .btn {
        padding: 6px 12px !important;
        /* Smaller buttons */
        font-size: 13px !important;
        /* Smaller text */
        min-width: auto;
        /* Allow buttons to shrink */
        margin-bottom: 4px;
        /* Reduced margin between buttons */
    }

    /* Ensure consistent card height and button positioning */
    .font-card {
        min-height: 280px !important;
        /* Maintain consistent height */
        max-height: 320px !important;
        display: flex !important;
        /* Ensure flex layout */
        flex-direction: column !important;
        /* Vertical layout */
    }

    .font-card-content {
        padding: 15px 20px 8px !important;
        /* Reduced bottom padding, consistent top/bottom */
        flex-grow: 1;
        /* Allow content to grow */
        overflow: hidden;
        /* Prevent content overflow */
    }

    /* Special adjustments for categories with potentially larger content */
    .font-card[data-font-category="monospace"],
    .font-card[data-font-category="caps"] {
        min-height: 280px !important;
        /* Maintain consistent height */
    }

    /* Ensure buttons stay within card boundaries */
    .font-actions {
        margin-top: auto !important;
        /* Push buttons to bottom */
        padding-top: 6px !important;
        /* Add some spacing above buttons */
        border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
        /* Subtle separator */
    }

    /* Dark theme adjustments for button separator */
    .dark-theme .font-actions {
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    }

    /* Reduce grid gap for better space utilization */
    .fonts-grid {
        gap: 12px !important;
    }
}

/* Consistent behavior for screens around 436px */
@media (max-width: 436px) {
    .font-card .font-name {
        font-size: 20px !important;
        /* Larger for better consistency */
        max-width: 75% !important;
        /* Less restrictive */
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .font-card[data-font-category="serif"] .font-name {
        font-size: 20px !important;
        /* Same as other categories */
        max-width: 70% !important;
        /* Less restrictive for better consistency */
        letter-spacing: normal;
    }

    .font-card[data-font-category="caps"] .font-name {
        max-width: 75% !important;
        /* More space for CAPS fonts */
        font-size: 20px !important;
        /* Consistent size */
    }

    .font-card {
        min-height: 280px !important;
        /* Maintain consistent height */
        max-height: 320px !important;
        overflow: hidden;
        /* Prevent scrollbars */
    }

    .font-preview:not([style*="font-size"]):not(.global-size-applied) {
        font-size: 13px !important;
        /* More readable */
        min-height: 50px !important;
        /* More space */
        overflow: hidden;
        /* Prevent overflow */
    }

    /* Special handling for CAPS category to prevent overflow */
    .font-card[data-font-category="caps"] .font-preview {
        font-size: 12px !important;
        /* Slightly smaller for CAPS */
        min-height: 45px !important;
        overflow: hidden;
    }

    /* Ensure card content doesn't overflow */
    .font-card-content {
        overflow: hidden;
        /* Prevent content overflow */
        max-height: 260px;
        /* Leave room for buttons */
    }
}

/* Extremely aggressive fixes for tiny screens (374px and below) */
@media (max-width: 374px) {
    .font-card .font-name {
        font-size: 18px !important;
        /* Smallest size */
        max-width: 75% !important;
        /* Most restrictive */
    }

    .font-card[data-font-category="caps"] .font-name {
        max-width: 72% !important;
        /* Most restrictive for CAPS */
    }

    .font-card {
        min-height: 280px !important;
        /* Maintain consistent height */
        max-height: 320px !important;
    }

    /* Only apply mobile font size if global size hasn't been applied */
    .font-preview:not([style*="font-size"]):not(.global-size-applied) {
        font-size: 12px !important;
        min-height: 40px !important;
    }

    /* Ensure global size takes precedence over media queries */
    .font-preview.global-size-applied {
        font-size: inherit !important;
        /* Use the inline style */
        min-height: auto !important;
    }

    /* Extra specificity to ensure inline style wins */
    body .font-card .font-preview.global-size-applied,
    .font-card-content .font-preview.global-size-applied {
        font-size: inherit !important;
        min-height: auto !important;
    }

    /* Delete all favorites icon - use exact same styles as heart */
    .favorites-summary-card .favorite-heart {
        position: absolute;
        top: 15px;
        right: 15px;
        font-size: 24px;
        cursor: pointer;
        color: #666;
        transition: all 0.3s;
        z-index: 10;
    }

    .favorites-summary-card .favorite-heart:hover {
        color: #d32f2f;
        transform: scale(1.2);
    }

    .favorites-summary-card .delete-all-favorites-btn:hover {
        color: #d32f2f;
        transform: scale(1.2);
    }

    /* Dark theme styles */
    .dark-theme .favorites-summary-card .delete-all-favorites-btn {
        color: #aaa;
    }

    .dark-theme .favorites-summary-card .delete-all-favorites-btn:hover {
        color: #ff7070;
    }
}

/* Notification styles */
.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.notification.show {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.dark-theme .notification {
    background-color: var(--dark-primary-color);
}

/* Final favorites button styles */
#favorites-count {
    display: none;
}

.has-favorites #favorites-count {
    display: inline;
    order: -1;
    /* Move count to the left of heart */
    margin-right: 3px;
}

.heart-icon {
    color: #ff4444;
}

/* Dark theme adjustments */
.dark-theme .heart-icon {
    color: #ff6666;
}

/* Special styles for Copy List button in favorites card */
.favorites-summary-card .btn-secondary {
    background-color: #e1e1e1;
    color: #333;
}

.favorites-summary-card .btn-secondary:hover {
    background-color: #efefef;
}

.favorites-summary-card .dropdown-toggle {
    background-color: #e1e1e1;
    color: #333;
}

.favorites-summary-card .dropdown-toggle:hover {
    background-color: #efefef;
}