/* ── Desktop: hide mobile elements ── */
@media (min-width: 961px) {
    .mobile-navbar       { display: none !important; }
    .mobile-footer       { display: none !important; }
    .mobile-menu-overlay { display: none !important; }
    .search-cancel-btn   { display: none !important; }
}

/* ══════════════════════════════════════
   Mobile overrides
═══════════════════════════════════════ */
@media (max-width: 960px) {

    /* Fix body — remove centering and top padding that breaks mobile layout */
    html {
        overflow-x: hidden;
    }

    body {
        align-items: stretch !important;
        padding-top: 0 !important;
        overflow-x: hidden;
    }

    /* Hide desktop navbar and footer */
    .navbar { display: none !important; }
    .footer { display: none !important; }

    /* Hide the oneko cat — no mouse on touch screens */
    #oneko { display: none !important; }

    /* ── Mobile search ── */
    .search-modal {
        padding-top: 0;
        align-items: flex-start;
        backdrop-filter: blur(4px);
        background-color: rgba(0, 0, 0, 0.45);
    }

    .search-input-container {
        min-width: unset !important;
        max-width: unset !important;
        width: 100% !important;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid #e0e0e0;
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13);
        padding: 1rem 1.2rem;
        /* slide down instead of scale */
        transform: translateY(-8px) !important;
        opacity: 0;
        transition: transform 0.22s ease, opacity 0.22s ease;
    }

    .search-modal.active .search-input-container {
        transform: translateY(0) !important;
        opacity: 1;
    }

    /* 16px prevents iOS auto-zoom on input focus */
    .search-input-container input {
        font-size: 16px;
    }

    .esc-label { display: none; }

    .search-cancel-btn {
        background: transparent;
        border: none;
        font-size: 15px;
        font-weight: 500;
        color: #555;
        cursor: pointer;
        padding: 4px 0 4px 4px;
        white-space: nowrap;
        font-family: inherit;
        flex-shrink: 0;
    }

    .search-cancel-btn:active { color: #111; }

    .search-suggestions {
        border-radius: 0 0 16px 16px;
        border-top: 1px solid #eee;
        border-left: 1px solid #e0e0e0;
        border-right: 1px solid #e0e0e0;
        border-bottom: 1px solid #e0e0e0;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
        max-height: 55vh;
        margin-top: 0;
    }

    .search-suggestions li {
        padding: 0.85rem 1.2rem;
        font-size: 15px;
        white-space: normal;
    }

    /* Clean tap highlight — no dashed border */
    .search-suggestions li:hover,
    .search-suggestions li.active {
        background-color: #f5f5f5;
        border: none;
        margin: 0;
    }

    /* Hide OTP code column — not useful in mobile search */
    .search-suggestions .suggestion-code {
        display: none;
    }

    /* Dark mode */
    .dark-mode .search-input-container {
        border-bottom-color: #2a2a2a;
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    }

    .dark-mode .search-cancel-btn {
        color: #aaa;
    }

    .dark-mode .search-cancel-btn:active { color: #fff; }

    .dark-mode .search-suggestions {
        border-top-color: #222;
        border-left-color: #2a2a2a;
        border-right-color: #2a2a2a;
        border-bottom-color: #2a2a2a;
    }

    .dark-mode .search-suggestions li:hover,
    .dark-mode .search-suggestions li.active {
        background-color: #222;
        border: none;
        margin: 0;
    }

    /* ── Navbar bar ── */
    .mobile-navbar {
        display: flex;
        flex-direction: column;
        width: 100%;
        background: rgba(255, 255, 255, 0.72);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        backdrop-filter: blur(24px) saturate(180%);
        border-bottom: 1px solid rgba(0, 0, 0, 0.07);
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
        font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        font-size: 14px;
        position: sticky;
        top: 0;
        z-index: 999;
        transition: opacity .2s ease-out, transform .2s ease-out;
        will-change: opacity, transform;
    }

    .mobile-navbar.is-hidden {
        opacity: 0;
        transform: translateY(-6px);
        pointer-events: none;
    }

    .mobile-navbar-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.8rem 1.1rem;
    }

    .mobile-navbar-right {
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }

    .mobile-menu-toggle,
    .theme-toggle-mobile {
        background: transparent;
        border: none;
        font-size: 18px;
        cursor: pointer;
        color: #111;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: background 0.15s;
    }

    .mobile-menu-toggle:active,
    .theme-toggle-mobile:active {
        background: #f0f0f0;
    }

    /* ── Backdrop ── */
    .mobile-menu-overlay {
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0);
        transition: background 0.35s ease;
        pointer-events: none;
    }

    .mobile-menu-overlay.open {
        background: rgba(0, 0, 0, 0.38);
        pointer-events: auto;
    }

    /* ── Sliding panel ── */
    .mobile-menu-panel {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(80vw, 300px);
        background: #fff;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.14);
        transform: translateX(100%);
        transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .mobile-menu-overlay.open .mobile-menu-panel {
        transform: translateX(0);
    }

    /* ── Panel header ── */
    .mobile-menu-overlay-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.8rem 1.1rem;
        border-bottom: 1px solid #eaeaea;
        opacity: 0;
        transform: translateY(-6px);
        transition: opacity 0.24s ease 0.18s, transform 0.24s ease 0.18s;
    }

    .mobile-menu-overlay.open .mobile-menu-overlay-header {
        opacity: 1;
        transform: translateY(0);
    }

    .mobile-menu-close {
        background: transparent;
        border: none;
        font-size: 20px;
        cursor: pointer;
        color: #111;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: background 0.15s;
    }

    .mobile-menu-close:active {
        background: #f0f0f0;
    }

    /* ── Nav links with stagger ── */
    .mobile-menu-links {
        display: flex;
        flex-direction: column;
        padding: 0.5rem 0;
    }

    .mobile-menu-links a {
        font-size: 16px;
        font-weight: 500;
        color: #222;
        text-decoration: none;
        padding: 0.95rem 1.4rem;
        border-bottom: 1px solid #f3f3f3;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        opacity: 0;
        transform: translateX(14px);
        transition: opacity 0.22s ease, transform 0.22s ease, background 0.1s;
    }

    .mobile-menu-links a:last-child {
        border-bottom: none;
    }

    .mobile-menu-links a:active {
        background: #f7f7f7;
    }

    .mobile-menu-overlay.open .mobile-menu-links a:nth-child(1) {
        opacity: 1; transform: translateX(0); transition-delay: 0.22s;
    }
    .mobile-menu-overlay.open .mobile-menu-links a:nth-child(2) {
        opacity: 1; transform: translateX(0); transition-delay: 0.28s;
    }
    .mobile-menu-overlay.open .mobile-menu-links a:nth-child(3) {
        opacity: 1; transform: translateX(0); transition-delay: 0.34s;
    }

    .mobile-menu-search {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.95rem 1.4rem;
        border-top: 1px solid #f3f3f3;
        border-bottom: 1px solid #f3f3f3;
        border-left: none;
        border-right: none;
        font-size: 16px;
        font-weight: 500;
        color: #222;
        background: transparent;
        cursor: pointer;
        width: 100%;
        font-family: inherit;
        text-align: left;
        opacity: 0;
        transform: translateX(14px);
        transition: opacity 0.22s ease 0.34s, transform 0.22s ease 0.34s, background 0.1s;
    }

    .mobile-menu-overlay.open .mobile-menu-search {
        opacity: 1;
        transform: translateX(0);
    }

    .mobile-menu-search:active {
        background: #f7f7f7;
    }

    .mobile-menu-search .material-symbols-outlined {
        font-size: 20px;
        line-height: 1;
        color: #666;
    }

    /* ── Panel footer ── */
    .mobile-menu-footer {
        margin-top: auto;
        padding: 1rem 1.4rem 1.5rem;
        border-top: 1px solid #f0f0f0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.65rem;
        opacity: 0;
        transform: translateY(6px);
        transition: opacity 0.22s ease 0.38s, transform 0.22s ease 0.38s;
    }

    .mobile-menu-overlay.open .mobile-menu-footer {
        opacity: 1;
        transform: translateY(0);
    }

    .mobile-menu-footer-links {
        display: flex;
        align-items: center;
        gap: 1.1rem;
    }

    .mobile-menu-footer-links a {
        font-size: 13px;
        color: #999;
        text-decoration: none;
        opacity: 1;
        transform: none;
        transition: color 0.15s;
        border-bottom: none;
        padding: 0;
        justify-content: unset;
    }

    .mobile-menu-footer-links a:active {
        color: #111;
        background: transparent;
    }

    .mobile-menu-footer-copy {
        font-size: 11px;
        color: #bbb;
    }

    /* ── Mobile Footer ── */
    .mobile-footer {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding: 1.1rem 1rem 1.6rem;
        border-top: 1px solid #eaeaea;
        font-size: 12px;
        color: #999;
        font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        width: 100%;
    }

    .mobile-footer-links {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .mobile-footer a {
        text-decoration: none;
        color: #999;
        font-size: 13px;
        transition: color 0.15s;
    }

    .mobile-footer a:active {
        color: #111;
    }

    /* ── Dark mode ── */
    .dark-mode .mobile-navbar {
        background: rgba(15, 15, 16, 0.75);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        backdrop-filter: blur(24px) saturate(180%);
        border-bottom-color: rgba(255, 255, 255, 0.07);
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    }

    .dark-mode .mobile-menu-toggle,
    .dark-mode .theme-toggle-mobile {
        color: #e0e0e0;
    }

    .dark-mode .mobile-menu-toggle:active,
    .dark-mode .theme-toggle-mobile:active {
        background: #2a2a2a;
    }

    .dark-mode .mobile-menu-panel {
        background: #1a1a1a;
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
    }

    .dark-mode .mobile-menu-overlay-header {
        border-bottom-color: #2b2b2b;
    }

    .dark-mode .mobile-menu-close {
        color: #e0e0e0;
    }

    .dark-mode .mobile-menu-close:active {
        background: #2a2a2a;
    }

    .dark-mode .mobile-menu-links a {
        color: #ddd;
        border-bottom-color: #222;
    }

    .dark-mode .mobile-menu-links a:active {
        background: #222;
    }

    .dark-mode .mobile-menu-search {
        color: #ddd;
        border-color: #222;
    }

    .dark-mode .mobile-menu-search:active {
        background: #222;
    }

    .dark-mode .mobile-menu-footer {
        border-top-color: #222;
    }

    .dark-mode .mobile-menu-footer-links a {
        color: #666;
    }

    .dark-mode .mobile-menu-footer-links a:active {
        color: #eee;
    }

    .dark-mode .mobile-menu-footer-copy {
        color: #444;
    }

    .dark-mode .mobile-menu-search .material-symbols-outlined {
        color: #888;
    }

    .dark-mode .mobile-footer {
        border-top-color: #2b2b2b;
    }

    .dark-mode .mobile-footer a,
    .dark-mode .mobile-footer > span {
        color: #666;
    }

    .dark-mode .mobile-footer a:active {
        color: #eee;
    }
}

/* ── Tablet footer: single row like desktop ── */
@media (min-width: 600px) and (max-width: 960px) {
    .mobile-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 1.5rem 1.4rem;
        gap: 1rem;
    }

    .mobile-footer-links {
        gap: 1.2rem;
    }
}
