.pg-app, .pg-app * {
    box-sizing: border-box;
}

.pg-app {
    --pg-red: #e60023;
    --pg-red-hover: #ad001d;
    --pg-chip-bg: #111111;
    --pg-chip-text: #ffffff;
    --pg-chip-inactive-bg: #f0f0f0;
    --pg-chip-inactive-text: #111111;
    --pg-radius: 16px;
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 16px 130px 16px;
}

.pg-toolbar {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.pg-search-box {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.pg-search-input {
    width: 100%;
    background-color: var(--pg-chip-inactive-bg);
    border: none;
    border-radius: 999px;
    padding: 10px 42px 10px 16px;
    font-size: 13px;
    outline: none;
}

.pg-search-box .pg-svg {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    fill: #5f5f5f;
}

.pg-chips-bar {
    padding: 10px 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    margin-bottom: 10px;
}

.pg-chips-bar::-webkit-scrollbar { display: none; }

.pg-chips-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pg-chip {
    background-color: var(--pg-chip-inactive-bg);
    color: var(--pg-chip-inactive-text);
    border: none;
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.pg-chip.active, .pg-chip:hover {
    background-color: var(--pg-chip-bg);
    color: var(--pg-chip-text);
}

/* JS builds N .pg-masonry-col divs inside this and appends cards into
   whichever column comes next in rotation -- deliberately NOT CSS
   column-count, which rebalances (and visibly shifts) ALL cards on every
   single append. */
.pg-masonry-flex {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.pg-masonry-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 0;
    min-width: 0;
}

@media (min-width: 640px) {
    .pg-masonry-flex, .pg-masonry-col { gap: 16px; }
}

.pg-card {
    display: block;
}

.pg-card-media {
    position: relative;
    width: 100%;
    border-radius: var(--pg-radius);
    overflow: hidden;
    background-color: var(--pg-chip-inactive-bg);
    cursor: pointer;
}

.pg-card-media img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--pg-radius);
    transition: transform 0.3s ease, filter 0.2s ease;
}

.pg-card-media:hover img {
    transform: scale(1.02);
}

.pg-save-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: var(--pg-red);
    color: #ffffff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.pg-save-btn .pg-svg {
    width: 15px;
    height: 15px;
    fill: #ffffff;
}

.pg-card-media:hover .pg-save-btn,
.pg-card-media.pg-active .pg-save-btn {
    opacity: 1;
}

.pg-save-btn:hover {
    background-color: var(--pg-red-hover);
}

.pg-save-btn.pg-saved {
    background-color: #111111;
}

.pg-info-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 28px 12px 12px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.35) 55%, rgba(0, 0, 0, 0) 100%);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

.pg-card-media:hover .pg-info-overlay,
.pg-card-media.pg-active .pg-info-overlay {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.pg-info-price {
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 2px;
}

.pg-info-title {
    color: #f0f0f0;
    font-size: 11px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.pg-info-link {
    display: inline-block;
    background-color: #ffffff;
    color: #111111;
    font-size: 11px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 999px;
    text-decoration: none;
}

.pg-empty {
    padding: 40px 0;
    text-align: center;
    color: #5f5f5f;
}

.pg-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}

.pg-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--pg-chip-inactive-bg);
    border-top-color: var(--pg-red);
    border-radius: 50%;
    animation: pg-spin 0.7s linear infinite;
}

@keyframes pg-spin {
    to { transform: rotate(360deg); }
}

.pg-error-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 0;
    text-align: center;
    color: #5f5f5f;
    font-size: 13px;
}

.pg-error-box button {
    background-color: var(--pg-chip-bg);
    color: var(--pg-chip-text);
    border: none;
    padding: 8px 22px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.pg-end-message {
    text-align: center;
    color: #a1a1aa;
    font-size: 12px;
    padding: 16px 0;
}

.pg-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #18181b;
    color: #fff;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 700;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.pg-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* -----------------------------------------------------------------
 * Floating bottom nav: menu / home / cart / profile.
 * Rendered via displayBeforeBodyClosingTag -- a direct child of
 * <body>, not nested inside .pg-app -- needs its own box-sizing reset.
 * ----------------------------------------------------------------- */
.pg-floating-nav, .pg-floating-nav * {
    box-sizing: border-box;
}

.pg-floating-nav {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background-color: rgba(17, 17, 17, 0.94);
    backdrop-filter: blur(16px);
    padding: 10px 26px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

.pg-nav-item {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.pg-nav-icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.pg-nav-cart {
    position: relative;
}

.pg-nav-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: var(--pg-red, #e60023);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Side menu drawer (opened from the floating nav's menu button) */
.pg-side-backdrop, .pg-side-menu, .pg-side-menu * {
    box-sizing: border-box;
}

.pg-side-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.pg-side-backdrop.pg-open {
    opacity: 1;
    pointer-events: auto;
}

.pg-side-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 78%;
    max-width: 320px;
    background: #ffffff;
    color: #111111;
    z-index: 10001;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    overflow-y: auto;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.pg-side-menu.pg-open {
    transform: translateX(0);
}

.pg-side-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    border-bottom: 1px solid #eeeeee;
}

.pg-side-title {
    font-size: 15px;
    font-weight: 800;
}

.pg-side-close {
    background: none;
    border: none;
    color: #111111;
    cursor: pointer;
    padding: 4px;
    display: flex;
}

.pg-side-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #9a9a9a;
    padding: 16px 16px 6px 16px;
}

.pg-side-links {
    display: flex;
    flex-direction: column;
}

.pg-side-links a {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #111111;
    text-decoration: none;
    border-bottom: 1px solid #f5f5f5;
}

.pg-side-links a:hover {
    background-color: #f7f7f7;
}

/* Accordion category tree */
.pg-side-tree {
    padding-bottom: 8px;
}

.pg-side-node-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f5f5f5;
}

.pg-side-node-link {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #111111;
    text-decoration: none;
}

.pg-side-node-link:hover {
    background-color: #f7f7f7;
}

.pg-side-toggle {
    background: none;
    border: none;
    color: #9a9a9a;
    cursor: pointer;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

.pg-side-node.pg-open > .pg-side-node-row > .pg-side-toggle {
    transform: rotate(90deg);
    color: var(--pg-red, #e60023);
}

.pg-side-children {
    display: none;
    padding-right: 14px;
    background-color: #fafafa;
}

.pg-side-node.pg-open > .pg-side-children {
    display: block;
}

.pg-side-children .pg-side-node-link {
    font-size: 13px;
    font-weight: 500;
    color: #333333;
}
