@media (max-width:1023px) {
    :root {
        font-size: 12px;
        /* Compact Density Overrides */
        --spacing-xs: 0.15rem;
        --spacing-sm: 0.35rem;
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --spacing-xl: 1.5rem;
        --card-padding: 0.75rem;
        --container-padding: 0.5rem;
    }

    .logo-image {
        height: 65px;
        width: auto;
        object-fit: contain
    }

    .container {
        padding: 0 var(--spacing-sm)
    }

    /* .items-container layout moved to intermediate/mobile specific queries */

    .filters-sidebar {
        margin-bottom: var(--spacing-md)
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr))
    }

    #fishing-map {
        height: 250px !important;
        max-height: 40vh !important;
    }

    /* Global Mobile Typography Enforcements */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    h4 {
        font-size: 1rem !important;
    }

    p,
    li,
    span {
        /* Prevent large inheritance */
        max-width: 100%;
    }

    /* Compact QCP Widget for Mobile */
    .qcp-widget {
        padding: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    .qcp-header h3 {
        font-size: 1.1rem !important;
        width: 100%;
        /* Keep title on its own line if needed, or check logic */
        margin-bottom: 0.5rem !important;
    }

    .qcp-location {
        flex-direction: row !important;
        align-items: center !important;
        width: 100%;
        justify-content: flex-start;
    }

    #qcp-change-location {
        width: auto !important;
        margin-left: auto !important;
        /* Push to right */
        padding: 0.2rem 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .qcp-header h3 {
        font-size: 1.1rem !important;
    }

    .score-circle {
        transform: scale(0.8);
        margin: -10px 0;
    }

    .qcp-details {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        font-size: 0.85rem;
    }

    .qcp-factor {
        padding: 0.4rem;
    }

    /* Horizontal Compact Forecast */
    .qcp-forecast-days {
        padding: 0.5rem 0.2rem !important;
        justify-content: flex-start !important;
        gap: 0.5rem !important;
    }

    .forecast-day-card {
        min-width: 90px !important;
        padding: 0.5rem !important;
    }

    .forecast-weather-icon {
        font-size: 1.5rem !important;
        margin: 0.25rem 0 !important;
    }

    .forecast-qcp,
    .forecast-temps {
        font-size: 0.8rem !important;
    }

    .page-header h1 {
        font-size: 1.4rem !important;
    }

    /* Compact 4-Column Footer for Mobile */
    .main-footer {
        padding: 1rem 0.5rem;
    }

    .footer-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.25rem !important;
    }

    .footer-col h4 {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
        word-break: break-word;
        /* Ensure headers don't overflow */
    }

    .footer-col ul li a {
        font-size: 0.65rem !important;
        padding: 0.1rem 0 !important;
        display: block;
    }

    .footer-col p {
        font-size: 0.65rem !important;
        margin-bottom: 0.25rem;
    }

    .social-links {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .social-links a {
        font-size: 0.8rem !important;
        width: 20px !important;
        height: 20px !important;
        line-height: 20px !important;
    }
}

@media (min-width:600px) and (max-width:768px) {
    .items-grid-catalog {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
        gap: var(--spacing-md)
    }
}

/* FIX: Small Notebooks / Tablets Landscape (769px - 1023px) */
@media (min-width: 769px) and (max-width: 1023px) {
    .items-container {
        grid-template-columns: 200px 1fr !important;
        gap: var(--spacing-md);
    }

    .filters-sidebar {
        /* Ensure it fits with the potentially smaller header */
        position: sticky;
        top: 110px;
        /* Adjusted for typical header height in this range */
        max-height: calc(100vh - 130px);
        overflow-y: auto;
    }

    .subcategories-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 1024px) {

    .nav-link,
    .page-header-content button {
        width: 100%
    }

    .btn-icon:hover,
    .search-container i:hover {
        background: rgba(0, 0, 0, .05)
    }

    .footer-grid,
    .qcp-content,
    .news-grid {
        grid-template-columns: 1fr
    }

    body {
        padding-top: 110px
    }

    .hero-slideshow {
        height: 350px
    }

    .slide-content h1 {
        font-size: 1.5rem
    }

    .slide-content p {
        font-size: 0.9rem
    }

    .qcp-content {
        text-align: center;
        justify-items: center !important
    }

    .page-header h1 {
        font-size: 1.5rem
    }

    .btn-icon,
    .search-container i {
        font-size: 1.25rem;
        transition: var(--transition-fast)
    }

    .page-header-content {
        flex-direction: column;
        text-align: center
    }



    .search-container input {
        display: none
    }

    /* FIX: Reposition Main Nav Wrapper for Mobile */
    .main-nav {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        /* Remove transform to avoid trapping fixed children and ensure viewport positioning */
        background: var(--surface-color) !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1) !important;
        z-index: 2000 !important;
        padding: 0 !important;
        height: auto !important;
        border-top: 1px solid var(--border-color);
        padding-bottom: env(safe-area-inset-bottom) !important;
        /* Handle iPhone Home Bar */
    }

    /* Bottom Navigation Bar Content */
    .nav-menu {
        display: flex;
        flex-direction: row;
        width: 100%;
        margin: 0;
        padding: 0.75rem 0;
        background: transparent;
        box-shadow: none;
        max-height: none;
        overflow-y: visible;
        justify-content: space-between;
        /* Better spacing for fixed width items */
        align-items: center;
        position: static;
        flex-wrap: nowrap !important;
        /* Force Single Line */
    }

    .nav-menu li {
        flex: 1 1 auto;
        /* Basis auto gives more space to larger items */
        display: flex;
        justify-content: center;
        min-width: 0;
        /* Allow shrinking below min-content */
    }

    .nav-link {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 0.75rem 0;
        /* Reduced padding */
        font-size: 0.65rem;
        /* Smaller Font */
        gap: 2px;
        color: var(--text-secondary) !important;
        background: transparent !important;
        width: 100%;
        border-radius: 0;
        height: auto;
        white-space: nowrap;
        overflow: visible;
        /* Allow badge to overflow */
        /* text-overflow: ellipsis; Removed to prevent clipping */
    }

    .nav-link i {
        font-size: 1.1rem;
        /* Slightly smaller icons */
        margin: 0;
        display: block;
        margin-bottom: 2px;
    }

    .nav-link.active {
        color: var(--primary-color) !important;
        font-weight: 600;
    }

    .nav-link:hover {
        color: var(--primary-color) !important;
        background: transparent !important;
    }

    body {
        padding-top: 90px;
        /* Fix: Reduced from 110px to reduce header space */
        padding-bottom: 95px;
        /* Fix: Adjusted to 95px to be very close to navbar */
        /* Add space for bottom nav */
    }

    .header-actions {
        gap: .5rem
    }

    .btn-icon {
        width: 42px !important;
        height: 42px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: 0 0;
        border: none;
        color: var(--text-secondary)
    }

    #profile-btn {
        font-size: 1.5rem
    }

    .header-content {
        flex-wrap: nowrap !important;
        gap: .5rem !important
    }

    .search-container {
        flex: 0 0 auto !important;
        max-width: none !important;
        order: 1
    }

    .search-container i {
        position: static;
        transform: none;
        pointer-events: auto;
        cursor: pointer;
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%
    }

    .search-container.expanded {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        background: var(--surface-color);
        padding: 1rem;
        box-shadow: var(--shadow-md);
        max-width: 100% !important
    }

    .search-container.expanded input {
        display: block
    }

    .search-container.expanded i {
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%)
    }

    .logo-image {
        height: 50px !important
    }

    .header-actions {
        order: 2
    }

    #fishing-map {
        height: 350px !important
    }

    .map-container {
        margin-bottom: var(--spacing-md)
    }

    .locations-sidebar {
        max-height: 400px !important;
        padding: var(--spacing-sm) !important
    }

    .items-container {
        grid-template-columns: 1fr !important;
    }

    #locations-list {
        max-height: 300px !important
    }

    .items-grid-catalog {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-md)
    }

    .item-card-catalog {
        max-width: 100%
    }
}

@media (max-width:480px) {

    .fishing-date-info,
    .weather-info-grid {
        box-sizing: border-box !important;
        width: 100% !important
    }

    :root {
        font-size: 14px
    }

    .container {
        padding: 0 .5rem !important
    }

    .header-content {
        padding: .5rem 0
    }

    .logo-text {
        display: none
    }

    .slide-content h1 {
        font-size: 1.5rem
    }

    .quick-grid {
        grid-template-columns: repeat(2, 1fr)
    }

    .btn {
        font-size: .9rem;
        padding: .6rem 1rem
    }

    .weather-info-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: .4rem !important;
        padding: 0 !important;
        margin: 1rem 0 0 !important
    }

    .groups-grid,
    .item-details-grid,
    .items-grid-catalog,
    .specs-grid {
        grid-template-columns: 1fr
    }

    .fishing-date-info,
    .qcp-display {
        margin-left: 0 !important;
        margin-right: 0 !important
    }

    .weather-info-grid>div {
        min-width: 0 !important;
        padding: .2rem 0 !important;
        box-sizing: border-box !important
    }

    .weather-info-grid i {
        font-size: 1.25rem !important
    }

    .weather-info-grid>div>div:first-of-type {
        font-size: .95rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 .15rem !important;
        box-sizing: border-box !important
    }

    .weather-info-grid>div>div:last-of-type {
        font-size: .65rem !important
    }

    .fishing-date-info {
        padding: 1rem .5rem !important;
        overflow: hidden !important
    }

    #assistant-results .card,
    #assistant-results>.card {
        padding: .75rem .5rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important
    }

    .qcp-display {
        padding: 0 !important
    }

    .qcp-score {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%
    }

    .qcp-score-large {
        padding: 1rem .5rem !important;
        margin: 0 auto;
        font-weight: 600;
        color: var(--text-secondary)
    }

    .qcp-content {
        justify-items: center !important;
        place-items: center !important
    }

    .group-icon {
        width: 60px;
        height: 60px;
        font-size: 2rem
    }

    .items-filter-bar {
        flex-direction: column;
        gap: var(--spacing-sm)
    }

    .comparison-header,
    .item-actions-large {
        flex-direction: column
    }

    .filter-search {
        min-width: 100%
    }

    .filter-select {
        width: 100%
    }

    .breadcrumb-nav {
        font-size: .85rem
    }

    .item-image-large {
        height: 250px
    }

    .item-details-info h2 {
        font-size: 1.5rem
    }

    .item-price-large {
        font-size: 2rem
    }

    .toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        min-width: auto
    }

    .selected-items {
        grid-template-columns: repeat(2, 1fr)
    }

    .item-slot {
        min-height: 150px;
        padding: var(--spacing-md)
    }

    .comparison-header {
        gap: var(--spacing-md);
        align-items: flex-start
    }

    .items-grid-catalog {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
        gap: var(--spacing-md)
    }

    .floating-add-btn {
        bottom: 90px;
        /* Clear Fixed Navbar */
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.5rem
    }

    .captures-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: stretch
    }

    .captures-header .btn {
        width: 100%;
        justify-content: center
    }

    .profile-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none
    }

    .profile-tabs::-webkit-scrollbar {
        display: none
    }

    .profile-tab {
        flex-shrink: 0;
        min-width: 120px;
        font-size: .9rem
    }

    .inventory-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm)
    }

    .inventory-actions {
        width: 100%;
        justify-content: space-between
    }

    .floating-compare-btn {
        bottom: 20px;
        right: 20px;
        padding: 1rem 1.5rem;
        font-size: .9rem
    }

    .items-grid-catalog {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-md)
    }

    .item-card-catalog {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0
    }

    .converter-bidirectional,
    .tools-category-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md)
    }

    .item-image-catalog {
        width: 100%;
        height: 200px;
        flex-shrink: 0;
        position: relative
    }

    .btn-favorite {
        width: 36px;
        height: 36px;
        top: 8px;
        left: 8px
    }

    .notifications-dropdown,
    .search-results-dropdown {
        left: 10px;
        right: 10px;
        width: auto
    }

    .btn-favorite i {
        font-size: 1rem
    }

    .item-card-catalog .item-badge {
        top: 8px;
        right: 8px;
        padding: .3rem .6rem;
        font-size: .7rem;
        max-width: calc(100% - 60px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis
    }

    .item-info-catalog {
        flex: 1
    }

    .item-content-catalog {
        padding: var(--spacing-sm)
    }

    .search-results-dropdown {
        max-height: 60vh
    }

    .qcp-display {
        padding: var(--spacing-md)
    }

    .qcp-gauge {
        width: 120px;
        height: 120px
    }

    .category-card {
        padding: var(--spacing-lg)
    }

    .category-icon {
        font-size: 2.5rem
    }

    .capacity-mode .form-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm)
    }

    .converter-arrow {
        padding-top: 0;
        transform: rotate(90deg);
        font-size: 1.2rem
    }

    .converter-info {
        font-size: .85rem;
        padding: .5rem .75rem
    }

    @media (max-height:500px) and (orientation:landscape) {
        .modal-content {
            max-height: 90vh;
            padding: var(--spacing-sm)
        }

        .capture-form .form-grid {
            grid-template-columns: 1fr 1fr
        }
    }
}

/* FIX: QCP Widget Horizontal Scrolling */
@media (max-width: 768px) {
    #qcp-forecast-days {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: var(--spacing-sm);
        padding-bottom: 10px;
        /* Space for scrollbar */
        width: 100%;
    }

    .forecast-day-card {
        flex: 0 0 auto;
        min-width: 100px;
        /* Ensure cards have minimum width */
    }

    /* Scrollbar Styling for QCP Widget */
    #qcp-forecast-days::-webkit-scrollbar {
        height: 4px;
    }

    #qcp-forecast-days::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 2px;
    }

    #qcp-forecast-days::-webkit-scrollbar-thumb {
        background-color: var(--primary-color);
        border-radius: 2px;
    }

}

/* FIX: Specific padding for Small Notebooks/Tablets to prevent header overlap */
@media (min-width: 769px) and (max-width: 1024px) {
    body {
        padding-top: 120px !important;
    }
}