/* ==========================================
   RESET
========================================== */

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

:root {

    --bg: #020617;
    --card: rgba(255, 255, 255, .05);
    --border: rgba(255, 255, 255, .08);

    --blue: #2563eb;
    --purple: #7c3aed;

    --text: #ffffff;
    --muted: #94a3b8;

}

html {
    scroll-behavior: smooth;
}

body {

    font-family: 'Inter', sans-serif;

    background: var(--bg);

    color: var(--text);

    min-height: 100vh;

    overflow-x: hidden;
}

/* ==========================================
   BACKGROUND
========================================== */

.bg-gradient {

    position: fixed;

    inset: 0;

    z-index: -1;

    background:

        radial-gradient(circle at top left,
            rgba(37, 99, 235, .25),
            transparent 35%),

        radial-gradient(circle at top right,
            rgba(124, 58, 237, .25),
            transparent 35%),

        radial-gradient(circle at bottom,
            rgba(14, 165, 233, .15),
            transparent 40%),

        #020617;
}

/* ==========================================
   APP
========================================== */

.app {

    width: 100%;

    max-width: 1500px;

    margin: 0 auto;

    padding: 32px;
}

/* ==========================================
   TOPBAR
========================================== */

.topbar {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 28px;
}

.brand-row {

    display: flex;

    align-items: center;

    gap: 16px;
}

.logo {

    width: 56px;

    height: 56px;

    border-radius: 18px;

    background: linear-gradient(135deg,
            var(--blue),
            var(--purple));

    display: flex;

    align-items: center;

    justify-content: center;

    font-weight: 800;

    font-size: 22px;
}

.topbar h1 {

    font-size: 32px;

    font-weight: 800;
}

.topbar p {

    color: var(--muted);

    margin-top: 4px;
}

.user-pill {

    padding: 12px 18px;

    border-radius: 999px;

    background: var(--card);

    border: 1px solid var(--border);

    font-weight: 700;
}

/* ==========================================
   HERO
========================================== */

.hero-card {

    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 28px;

    backdrop-filter: blur(20px);

    padding: 36px;

    margin-bottom: 24px;
}

.hero-badge {

    display: inline-block;

    padding: 8px 14px;

    border-radius: 999px;

    background: rgba(37, 99, 235, .15);

    color: #93c5fd;

    font-size: 12px;

    font-weight: 700;

    margin-bottom: 18px;
}

.hero-content h2 {

    font-size: 42px;

    margin-bottom: 10px;
}

.hero-content p {

    color: #cbd5e1;

    margin-bottom: 24px;

    max-width: 700px;

    line-height: 1.6;
}

/* ==========================================
   TABS
========================================== */

.tabs {

    display: flex;

    gap: 12px;

    margin-bottom: 20px;
}

.tab {

    border: none;

    cursor: pointer;

    padding: 14px 22px;

    border-radius: 14px;

    background: #1e293b;

    color: white;

    font-weight: 600;

    transition: .2s;
}

.tab:hover {

    opacity: .9;
}

.tab.active {

    background: linear-gradient(135deg,
            var(--blue),
            var(--purple));
}

/* ==========================================
   SEARCH
========================================== */

.search-row {

    display: flex;

    gap: 12px;

    margin-bottom: 18px;
}

.search-row input {

    flex: 1;

    height: 64px;

    border-radius: 18px;

    border: 1px solid var(--border);

    background: #0f172a;

    color: white;

    padding: 0 22px;

    outline: none;

    font-size: 16px;
}

.search-row input:focus {

    border-color: var(--blue);

    box-shadow:
        0 0 0 4px rgba(37, 99, 235, .15);
}

#searchBtn {

    min-width: 140px;

    border: none;

    cursor: pointer;

    border-radius: 18px;

    font-weight: 700;

    color: white;

    background: linear-gradient(135deg,
            var(--blue),
            var(--purple));
}

/* ==========================================
   RECENT SEARCHES
========================================== */

.recent-searches {

    display: flex;

    flex-wrap: wrap;

    gap: 10px;
}

.recent-chip {

    padding: 10px 14px;

    border-radius: 999px;

    cursor: pointer;

    background: rgba(255, 255, 255, .06);

    border: 1px solid var(--border);

    font-size: 13px;
}

/* ==========================================
   STATUS
========================================== */

.stats-bar {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 24px;
}

.result-count {

    color: var(--muted);

    font-weight: 700;
}

.search-status {

    color: #60a5fa;

    font-size: 14px;
}

/* ==========================================
   EMPTY
========================================== */

.empty-state {

    text-align: center;

    padding: 90px 20px;
}

.empty-icon {

    font-size: 64px;

    margin-bottom: 16px;
}

.empty-state h3 {

    margin-bottom: 12px;

    font-size: 26px;
}

.empty-state p {

    color: var(--muted);

    max-width: 500px;

    margin: auto;

    line-height: 1.6;
}

/* ==========================================
   GRID
========================================== */

.results-grid {

    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(340px, 1fr));

    gap: 22px;
}

/* ==========================================
   CARD
========================================== */

.glass-card {

    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 24px;

    padding: 20px;

    cursor: pointer;

    transition:
        transform .2s ease,
        border-color .2s ease;

    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: "";

    position: absolute;

    top: 0;
    left: 0;

    width: 100%;
    height: 2px;

    background:
        linear-gradient(90deg,
            var(--blue),
            var(--purple));
}

.glass-card:hover {

    transform: translateY(-5px);

    box-shadow:
        0 12px 30px rgba(37, 99, 235, .12);

    border-color: var(--blue);
}

.card-title {

    font-size: 16px;

    font-weight: 600;

    line-height: 1.4;

    margin-bottom: 8px;
}

.card-subtitle {

    color: #64748b;

    margin-bottom: 18px;

    font-size: 13px;
}

.card-row {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 12px;

    margin-bottom: 6px;
}

.more {

    margin-top: 12px;

    color: #60a5fa;

    font-size: 14px;
}

/* ==========================================
   BADGES
========================================== */

.badge {

    padding: 6px 12px;

    border-radius: 999px;

    font-size: 12px;

    font-weight: 700;
}

.badge-a {
    background: #14532d;
    color: #bbf7d0;
}

.badge-b {
    background: #78350f;
    color: #fde68a;
}

.badge-c {
    background: #172554;
    color: #bfdbfe;
}

.badge-d {
    background: #581c87;
    color: #e9d5ff;
}

/* ==========================================
   DRAWER - ULTRA CLEAN COMPACT SYSTEM
========================================== */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: 0.22s ease;
    z-index: 999;
}

.drawer-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* DRAWER CORE */
.detail-drawer {
    position: fixed;
    top: 0;
    right: -560px;
    width: min(560px, 100vw);
    max-width: 100%;
    height: 100vh;

    background:
        radial-gradient(1200px 600px at 20% 0%, rgba(37, 99, 235, 0.08), transparent 60%),
        radial-gradient(900px 500px at 100% 20%, rgba(124, 58, 237, 0.06), transparent 55%),
        #0b1220;

    border-left: 1px solid rgba(255, 255, 255, 0.06);

    box-shadow: -40px 0 120px rgba(0, 0, 0, 0.75);

    transition: 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

.detail-drawer.open {
    right: 0;
}

/* HEADER (HIERARCHY FIXED) */
.drawer-header {
    padding: 18px 18px 14px;

    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.2px;
    margin: 0;
    color: #e5e7eb;
}

.drawer-subtitle {
    font-size: 11.5px;
    margin-top: 3px;
    color: rgba(148, 163, 184, 0.75);
}

/* CLOSE BUTTON (MINIMAL) */
.drawer-header button {
    width: 32px;
    height: 32px;
    border-radius: 10px;

    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);

    color: white;
    cursor: pointer;

    transition: 0.18s ease;
}

.drawer-header button:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.04);
}

/* CONTENT (KEY FIX: VISUAL BREATHING WITHOUT BULK) */
.drawer-content {
    padding: 14px 14px 18px;

    overflow-y: auto;
    flex: 1;

    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ROW (NARROW + PREMIUM LIST ITEM) */
.drawer-content .card-row {
    padding: 9px 10px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    border-radius: 10px;

    background: rgba(255, 255, 255, .035);
    border: 1px solid rgba(255, 255, 255, 0.04);

    transition: 0.18s ease;

    min-height: 38px;
}

.drawer-content .card-row:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.18);
    transform: translateX(3px);
}

/* LEFT TEXT (TRUNCATED, CLEAN TYPOGRAPHY) */
.drawer-content .card-row span:first-child {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;

    max-width: 72%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* RIGHT BADGE (TIGHT MICRO UI) */
.drawer-content .card-row span:last-child {
    font-size: 11px;
    font-weight: 600;

    color: #93c5fd;

    padding: 2px 8px;
    border-radius: 999px;

    background: rgba(37, 99, 235, 0.10);
    border: 1px solid rgba(37, 99, 235, 0.15);

    flex-shrink: 0;
}

/* SCROLLBAR (SUBTLE) */
.drawer-content::-webkit-scrollbar {
    width: 4px;
}

.drawer-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.18);
    border-radius: 20px;
}

/* MOBILE */
@media (max-width: 768px) {
    .detail-drawer {
        width: 100%;
        right: -100%;
    }

    .detail-drawer.open {
        right: 0;
    }
}

/* ==========================================
   SCROLLBAR
========================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-thumb {

    background: #334155;

    border-radius: 999px;
}


/* ==========================================
   MOBILE
========================================== */

@media (max-width: 768px) {

    .app {

        padding: 18px;
    }

    .topbar {

        flex-direction: column;

        align-items: flex-start;

        gap: 18px;
    }

    .hero-content h2 {

        font-size: 30px;
    }

    .search-row {

        flex-direction: column;
    }

    #searchBtn {

        height: 58px;

        width: 100%;
    }

    .results-grid {

        grid-template-columns: 1fr;
    }

    .detail-drawer {

        width: 100%;
    }

    .stats-bar {

        flex-direction: column;

        align-items: flex-start;

        gap: 10px;
    }
}

/* =========================
   COPY BUTTON SYSTEM
========================= */

.copy-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    opacity: .75;
}

.glass-card:hover .copy-bar {
    opacity: 1;
}

.copy-text-btn,
.copy-img-btn {
    flex: 1;
    padding: 8px 10px;
    border-radius: 10px;

    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);

    color: white;
    font-size: 12px;

    cursor: pointer;

    transition: 0.2s ease;
}

.copy-text-btn:hover,
.copy-img-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.copy-text-btn:active,
.copy-img-btn:active {
    transform: scale(0.97);
}

/* =========================
   MASTER EXPORT BUTTONS
========================= */

.copy-pill {

    display: flex;
    align-items: center;
    justify-content: center;

    min-width: 140px;
    height: 46px;

    padding: 0 18px;

    border-radius: 14px;

    border: 1px solid rgba(255, 255, 255, .08);

    background:
        linear-gradient(135deg,
            rgba(37, 99, 235, .18),
            rgba(124, 58, 237, .18));

    backdrop-filter: blur(12px);

    color: white;

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform .18s ease,
        border-color .18s ease,
        box-shadow .18s ease,
        background .18s ease;
}

.copy-pill:hover {

    transform: translateY(-2px);

    border-color: rgba(255, 255, 255, .18);

    box-shadow:
        0 8px 24px rgba(37, 99, 235, .18),
        0 8px 24px rgba(124, 58, 237, .12);

    background:
        linear-gradient(135deg,
            rgba(37, 99, 235, .28),
            rgba(124, 58, 237, .28));
}

.copy-pill:active {

    transform: scale(.97);
}

#masterActions {

    display: flex;
    gap: 12px;

    margin-bottom: 22px;

    flex-wrap: wrap;
}

.search-hints {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.hint-chip {
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    color: #94a3b8;
    font-size: 12px;
}

/* ==========================================
   MOBILE PREMIUM UI
   PASTE AT VERY BOTTOM
========================================== */

@media (max-width: 768px) {

    .app {
        padding: 14px;
    }

    /* TOP */

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .hero-card {
        padding: 20px;
        border-radius: 20px;
    }

    .hero-content h2 {
        font-size: 26px;
        line-height: 1.25;
    }

    /* TABS */

    .tabs {
        display: flex;
        gap: 8px;
    }

    .tab {
        flex: 1;
        height: 48px;
        padding: 0;
        font-size: 13px;
        border-radius: 12px;
    }

    /* SEARCH */

    .search-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .search-row input {

        flex: 1;

        height: 58px;

        border-radius: 18px;

        font-size: 16px;

        padding: 0 18px;

        min-width: 0;
    }

    #searchBtn {

        width: 58px;

        min-width: 58px;

        height: 58px;

        border-radius: 18px;

        font-size: 0;
        position: relative;
    }

    #searchBtn::after {

        content: "🔍";

        font-size: 20px;
    }

    /* MASTER BUTTONS */

    #masterActions {

        display: flex;

        gap: 8px;

        margin-bottom: 18px;
    }

    .copy-pill {

        flex: 1;

        min-width: auto;

        height: 40px;

        font-size: 11px;

        border-radius: 12px;
    }

    /* RESULTS */

    .results-grid {

        grid-template-columns: 1fr;

        gap: 12px;
    }

    /* CARD */

    .glass-card {

        padding: 14px;

        border-radius: 18px;
    }

    .card-title {

        font-size: 14px;

        line-height: 1.4;
    }

    .card-subtitle {

        font-size: 12px;
    }

    /* COPY BUTTONS */

    .copy-bar {

        gap: 6px;

        margin-bottom: 10px;
    }

    .copy-text-btn,
    .copy-img-btn {

        height: 32px;

        padding: 0 10px;

        font-size: 11px;

        border-radius: 8px;
    }

    /* STATUS */

    .stats-bar {

        display: flex;

        flex-direction: row;

        justify-content: space-between;

        align-items: center;
    }

    .result-count,
    .search-status {

        font-size: 12px;
    }

    /* DRAWER */

    .detail-drawer {

        width: 100%;

        right: -100%;
    }

    .drawer-header h2 {

        font-size: 17px;
    }

    .drawer-content {

        padding: 12px;
    }
}

#installBtn {
    height: 64px;
    padding: 0 18px;
    border: none;
    border-radius: 18px;
    cursor: pointer;

    background: rgba(255, 255, 255, .08);
    color: white;

    font-weight: 700;
}

#installBtn:hover {
    background: rgba(255, 255, 255, .14);
}

@media(max-width:768px) {

    .search-row {
        display: flex;
        flex-direction: row;
        gap: 8px;
    }

    .search-row input {
        flex: 1;
    }

    #searchBtn {
        width: auto;
        min-width: 90px;
        height: 56px;
    }

    #installBtn {
        width: auto;
        min-width: 70px;
        height: 56px;
        padding: 0 12px;
        font-size: 12px;
    }
}

/* ==========================================================
   CLOUDFLARE BUILD — FIXES + PROFESSIONAL MOBILE APP UI
   (desktop look above is unchanged)
========================================================== */

html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button { font-family: inherit; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }

/* drawer: overlay used ".show" in CSS but ".open" in JS, so it never appeared */
.drawer-overlay.open { opacity: 1; visibility: visible; }
.detail-drawer { z-index: 1000; height: 100vh; height: 100dvh; }

.data-info {
    text-align: center;
    color: #475569;
    font-size: 12px;
    padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
}
.search-status:empty { display: none; }
.recent-searches:empty { display: none; }
.recent-chip:hover { border-color: var(--blue); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* installed app window: respect notches */
@media (display-mode: standalone) {
    .app { padding-top: calc(20px + env(safe-area-inset-top)); }
}

/* ==========================================================
   MOBILE  (<= 768px)  — compact header, sticky search,
   segmented tabs, bottom-sheet details
========================================================== */
@media (max-width: 768px) {

    .app {
        padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
    }

    /* header: one slim row */
    .topbar { flex-direction: row; align-items: center; margin-bottom: 12px; gap: 10px; }
    .brand-row { gap: 12px; }
    .logo { width: 40px; height: 40px; border-radius: 13px; font-size: 18px; }
    .topbar h1 { font-size: 20px; line-height: 1.1; }
    .topbar p { font-size: 12px; margin-top: 2px; }
    .user-pill { padding: 7px 12px; font-size: 10px; letter-spacing: .08em; }

    /* search area sticks to the top while you scroll results */
    .hero-card {
        position: sticky;
        top: 0;
        z-index: 30;
        margin: 0 -14px 14px;
        padding: 12px 14px 14px;
        border-radius: 0 0 22px 22px;
        border-width: 0 0 1px;
        background: rgba(2, 6, 23, .86);
        -webkit-backdrop-filter: blur(18px);
        backdrop-filter: blur(18px);
    }
    .hero-badge, .hero-content h2, .hero-content > p, .search-hints { display: none; }

    /* tabs become a segmented control */
    .tabs {
        gap: 0;
        padding: 4px;
        margin-bottom: 12px;
        border-radius: 14px;
        background: #0f172a;
        border: 1px solid var(--border);
    }
    .tab { flex: 1; height: 42px; font-size: 14px; border-radius: 11px; background: transparent; color: #94a3b8; }
    .tab.active { color: #fff; box-shadow: 0 4px 14px rgba(37, 99, 235, .35); }

    /* search bar: big, thumb friendly */
    .search-row { gap: 8px; margin-bottom: 0; align-items: stretch; }
    .search-row input { height: 52px; border-radius: 16px; font-size: 16px; padding: 0 16px; min-width: 0; }
    #searchBtn { width: 52px; min-width: 52px; height: 52px; border-radius: 16px; font-size: 0; }
    #searchBtn::after { content: "🔍"; font-size: 20px; }
    #installBtn { height: 52px; min-width: 0; padding: 0 14px; border-radius: 16px; font-size: 13px; }

    /* recent searches: one swipeable row */
    .recent-searches {
        flex-wrap: nowrap; overflow-x: auto; gap: 8px; margin: 10px -14px 0; padding: 0 14px 2px;
        scrollbar-width: none;
    }
    .recent-searches::-webkit-scrollbar { display: none; }
    .recent-chip { flex-shrink: 0; padding: 8px 14px; font-size: 13px; }

    /* master export buttons */
    #masterActions { gap: 8px; margin-bottom: 12px; }
    .copy-pill { flex: 1; min-width: 0; height: 42px; font-size: 12px; border-radius: 12px; }

    .stats-bar { margin-bottom: 12px; }
    .result-count { font-size: 13px; }

    .empty-state { padding: 48px 16px; }
    .empty-icon { font-size: 48px; }
    .empty-state h3 { font-size: 20px; }
    .empty-state p { font-size: 14px; }

    /* result cards */
    .results-grid { gap: 12px; padding-bottom: 12px; }
    .glass-card { padding: 16px; border-radius: 20px; transition: transform .12s ease; }
    .glass-card:hover { transform: none; box-shadow: none; border-color: var(--border); }
    .glass-card:active { transform: scale(.985); }
    .card-title { font-size: 16px; font-weight: 700; }
    .card-subtitle { margin-bottom: 12px; }
    .card-row { font-size: 14px; margin-bottom: 8px; }
    .badge { font-size: 12px; padding: 5px 11px; }
    .more { font-size: 13px; font-weight: 600; }
    .copy-bar { opacity: 1; gap: 8px; margin-bottom: 12px; }
    .copy-text-btn, .copy-img-btn { height: 40px; font-size: 12px; font-weight: 600; border-radius: 10px; }

    /* details open as a bottom sheet */
    .drawer-overlay { background: rgba(0, 0, 0, .6); }
    .detail-drawer {
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100%; max-width: 100%;
        height: auto; max-height: 86vh; max-height: 86dvh;
        border-left: 0;
        border-top: 1px solid rgba(255, 255, 255, .1);
        border-radius: 26px 26px 0 0;
        transform: translateY(105%);
        transition: transform .34s cubic-bezier(.2, .9, .2, 1);
        box-shadow: 0 -24px 70px rgba(0, 0, 0, .65);
    }
    .detail-drawer.open { right: 0; transform: translateY(0); }
    .detail-drawer::before {
        content: ""; display: block; width: 42px; height: 5px; margin: 10px auto 0;
        border-radius: 99px; background: rgba(255, 255, 255, .22); flex-shrink: 0;
    }
    .drawer-header { padding: 14px 18px 12px; }
    .drawer-header h2 { font-size: 18px; line-height: 1.3; padding-right: 10px; overflow-wrap: anywhere; }
    .drawer-subtitle { font-size: 13px; }
    .drawer-header button { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; font-size: 16px; }
    .drawer-content { padding: 12px 14px calc(18px + env(safe-area-inset-bottom)); gap: 8px; }
    .drawer-content .card-row { min-height: 48px; padding: 10px 12px; border-radius: 12px; }
    .drawer-content .card-row:hover { transform: none; }
    .drawer-content .card-row span:first-child { font-size: 14px; max-width: 64%; white-space: normal; overflow: visible; }
    .drawer-content .card-row span:last-child { font-size: 12px; padding: 4px 10px; }
}

@media (max-width: 360px) {
    .topbar p { display: none; }
    .user-pill { display: none; }
}

@media (max-width: 768px) {
    #masterActions { margin: 10px 0 0; }
    .copy-pill { height: 38px; }
    .recent-searches { margin-top: 8px; }
}
