/* ============ HOME.css ============ */
.home-body {
    background: var(--bg-soft);
    padding-bottom: 92px;
    min-height: 100vh;
}

/* ---------- TOP BAR ---------- */
.hm-topbar {
    position: sticky;
    top: 0;
    z-index: 300;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    padding: 14px 18px 14px;
}

.hm-topbar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1180px;
    margin: 0 auto;
}

.hm-avatar-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, var(--blue), var(--green));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-family: var(--font-display);
    font-size: 17px;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.hm-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Guests get a plain, neutral placeholder — not the colored gradient
   used for a real signed-in person's initials. */
.hm-avatar-btn.is-guest {
    background: #E5E7EB;
    color: #8A8F98;
    box-shadow: none;
}

.hm-greeting {
    flex: 1;
    min-width: 0;
}

.hm-greeting-hi {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 17px;
    line-height: 1.2;
}

.hm-greeting-sub {
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.hm-topbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.hm-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}

.hm-icon-btn:hover {
    border-color: var(--blue);
    transform: translateY(-1px);
}

.hm-dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    border: 1.5px solid #fff;
}

/* Search row */
.hm-search-row {
    display: flex;
    gap: 10px;
    max-width: 1180px;
    margin: 14px auto 0;
}

.hm-search-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-soft);
    border: 1.5px solid var(--line);
    border-radius: 14px;
}

.hm-search-icon {
    padding-left: 14px;
    font-size: 15px;
    color: var(--ink-soft);
}

.hm-search-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 13px 8px;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--ink);
}

.hm-search-wrap input:focus {
    outline: none;
}

.hm-search-wrap:focus-within {
    border-color: var(--blue);
    background: #fff;
}

.hm-search-clear {
    padding: 0 12px;
    color: var(--ink-soft);
    font-size: 14px;
}

.hm-filter-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1.5px solid var(--line);
    background: #fff;
    font-weight: 700;
    font-size: 13.5px;
    white-space: nowrap;
    transition: all .2s ease;
}

.hm-filter-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.hm-filter-ico {
    font-size: 14px;
}

.hm-filter-count {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- MAIN / QUICK ACTIONS ---------- */
.hm-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 0 0;
}

.hm-quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 26px;
    padding: 0 18px;
}

.hm-quick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    transition: all .2s ease;
}

.hm-quick-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(37, 99, 235, 0.3);
}

.hm-quick-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
}

.qa-sell {
    background: rgba(16, 185, 129, 0.12);
}

.qa-cat {
    background: rgba(37, 99, 235, 0.12);
}

.qa-wish {
    background: rgba(220, 38, 38, 0.1);
}

.qa-orders {
    background: rgba(245, 158, 11, 0.14);
}

.hm-quick-label {
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    color: var(--ink);
}

/* ---------- FEED SECTIONS ---------- */
.hm-section {
    margin-bottom: 32px;
    padding: 0;
}

.hm-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 0 18px;
}

.hm-section-head h2 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.hm-viewall {
    font-size: 13px;
    font-weight: 700;
    color: var(--blue);
    white-space: nowrap;
}

.hm-scroll-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 0 18px 6px;
}

.hm-scroll-row::-webkit-scrollbar {
    height: 0;
}

/* Cards used to be fixed-width flex items for horizontal scrolling;
   inside the grid they should fill their cell instead. */
.hm-scroll-row .hm-card-compact {
    min-width: 0;
    max-width: none;
    width: auto;
}

@media (min-width: 640px) {
    .hm-scroll-row { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1025px) {
    .hm-scroll-row { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1400px) {
    .hm-scroll-row { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- BOOK CARD ---------- */
.hm-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease;
    position: relative;
}

.hm-card-compact {
    min-width: 198px;
    max-width: 198px;
    flex-shrink: 0;
    scroll-snap-align: start;
}

.hm-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.hm-card-cover {
    height: 120px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hm-cover-emoji {
    font-size: 34px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

.hm-cover-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hm-cond-badge {
    position: absolute;
    top: 9px;
    left: 9px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    font-size: 10px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 7px;
}

.hm-wish-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: transform .2s ease;
}

.hm-wish-btn:hover {
    transform: scale(1.15);
}

.hm-negotiable-badge {
    position: absolute;
    bottom: 9px;
    left: 9px;
    background: rgba(16, 185, 129, 0.95);
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 7px;
}

.hm-bundle-badge {
    position: absolute;
    bottom: 9px;
    right: 9px;
    background: rgba(124, 58, 237, 0.95);
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 7px;
}

.hm-card-body {
    padding: 12px;
}

.hm-card-title {
    font-weight: 700;
    font-size: 13px;
    line-height: 1.3;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}

.hm-card-meta {
    font-size: 10.5px;
    color: var(--ink-soft);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hm-card-price-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 7px;
}

.hm-price-now {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15.5px;
    color: var(--green);
}

.hm-price-old {
    font-size: 11px;
    color: #B0B5BE;
    text-decoration: line-through;
}

.hm-price-off {
    font-size: 10px;
    font-weight: 800;
    color: var(--green);
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 6px;
    border-radius: 6px;
}

.hm-card-seller-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 10px;
    color: var(--ink-soft);
    margin-bottom: 10px;
}

.hm-verified {
    font-size: 9px;
}

.hm-card-actions {
    display: flex;
    gap: 6px;
}

.hm-card-btn {
    flex: 1;
    padding: 8px 9px;
    font-size: 11.5px;
    border-radius: 10px;
}

/* Skeleton */
.hm-skeleton .hm-card-cover {
    background: var(--bg-soft);
}

.sk-shimmer {
    position: relative;
    overflow: hidden;
    background: #EEF0F3;
}

.sk-shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

.sk-line {
    height: 12px;
    border-radius: 6px;
    margin: 8px 0;
}

/* ---------- RESULTS VIEW ---------- */
.hm-results-view {
    padding: 0 18px 20px;
}

.hm-results-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.hm-back-btn {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--blue);
}

.hm-results-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 19px;
}

.hm-results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 10px;
}

.hm-results-count {
    font-size: 13px;
    color: var(--ink-soft);
    font-weight: 600;
}

.hm-sort-select {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    background: #fff;
}

.hm-active-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.hm-chip-tag {
    font-size: 11.5px;
    font-weight: 700;
    background: rgba(37, 99, 235, 0.08);
    color: var(--blue);
    padding: 5px 11px;
    border-radius: 99px;
}

.hm-chip-clear {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-soft);
    text-decoration: underline;
    padding: 5px 4px;
}

.hm-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.hm-results-grid .hm-card {
    min-width: 0;
    max-width: none;
}

.hm-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.hm-empty-emoji {
    font-size: 46px;
    margin-bottom: 10px;
}

.hm-empty-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 6px;
}

.hm-empty-sub {
    font-size: 13.5px;
    color: var(--ink-soft);
    max-width: 320px;
    margin: 0 auto 18px;
    line-height: 1.5;
}

/* ---------- FILTER SHEET ---------- */
.hm-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 400;
}

.hm-sheet-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.hm-filter-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 401;
    background: #fff;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -20px 50px rgba(17, 24, 39, 0.2);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    transform: translateY(105%);
    transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

.hm-filter-sheet.open {
    transform: translateY(0);
}

.hm-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--line);
    border-radius: 99px;
    margin: 12px auto 4px;
}

.hm-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 22px 14px;
    border-bottom: 1px solid var(--line);
}

.hm-sheet-head h3 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
}

.hm-sheet-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-soft);
    font-size: 14px;
}

.hm-sheet-body {
    padding: 18px 22px;
    overflow-y: auto;
    flex: 1;
}

.hm-f-label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin: 18px 0 8px;
}

.hm-f-hint {
    text-transform: none;
    font-weight: 600;
    letter-spacing: 0;
    color: #B0B5BE;
    font-size: 11px;
}

.hm-f-label:first-child {
    margin-top: 0;
}

.hm-price-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hm-price-row input {
    flex: 1;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    font-family: inherit;
    font-size: 14px;
}

.hm-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hm-fchip {
    padding: 9px 14px;
    border-radius: 99px;
    border: 1.5px solid var(--line);
    font-size: 12.5px;
    font-weight: 700;
    background: #fff;
    transition: all .2s ease;
}

.hm-fchip.selected {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.hm-f-select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.hm-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.hm-toggle-row input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.hm-toggle-track {
    width: 42px;
    height: 24px;
    border-radius: 99px;
    background: var(--line);
    position: relative;
    transition: background .2s ease;
    flex-shrink: 0;
}

.hm-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform .2s ease;
}

.hm-toggle-row input:checked~.hm-toggle-track {
    background: var(--blue);
}

.hm-toggle-row input:checked~.hm-toggle-track .hm-toggle-thumb {
    transform: translateX(18px);
}

.hm-sheet-footer {
    display: flex;
    gap: 12px;
    padding: 16px 22px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
}

.hm-sheet-footer .btn {
    flex: 1;
}

/* ---------- TOAST ---------- */
.hm-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    transition: all .3s ease;
    z-index: 500;
    max-width: 88%;
    text-align: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.hm-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- BOTTOM NAV ---------- */
.hm-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}

.hm-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--ink-soft);
    padding: 8px 14px;
    min-height: 48px;
    justify-content: center;
    border-radius: 14px;
    transition: all .2s ease;
}

.hm-nav-item.active {
    color: var(--blue);
    background: rgba(37, 99, 235, 0.08);
}

.hm-nav-ico {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hm-nav-ico svg {
    width: 100%;
    height: 100%;
    color: currentColor;
}

.hm-nav-sell {
    background: linear-gradient(135deg, var(--blue), var(--green));
    color: #fff;
    transform: translateY(-10px);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.35);
}

.hm-nav-sell .hm-nav-ico {
    width: 24px;
    height: 24px;
}

.hm-nav-sell:hover,
.hm-nav-sell.active {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--green));
}

/* ================= TABLET ================= */
@media (min-width:681px) and (max-width:1024px) {
    .hm-results-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .hm-card-compact {
        min-width: 220px;
        max-width: 220px;
    }
}

/* ================= DESKTOP ================= */
@media (min-width:1025px) {
    .home-body {
        padding-bottom: 0;
    }

    .hm-bottom-nav {
        display: none;
    }

    .hm-main {
        padding: 28px 32px 60px;
    }

    .hm-topbar-inner,
    .hm-search-row {
        padding: 0 14px;
    }

    .hm-quick-actions {
        grid-template-columns: repeat(4, 1fr);
        max-width: 640px;
    }

    .hm-results-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .hm-card-compact {
        min-width: 230px;
        max-width: 230px;
    }

    .hm-filter-sheet {
        left: auto;
        right: 24px;
        bottom: 24px;
        top: 24px;
        width: 380px;
        border-radius: 24px;
        transform: translateX(120%);
    }

    .hm-filter-sheet.open {
        transform: translateX(0);
    }
}

/* ================= SMALL MOBILE ================= */
@media (max-width:380px) {
    .hm-quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .hm-results-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .hm-card-compact {
        min-width: 172px;
        max-width: 172px;
    }
}