:root {
    --ios-bg: #F2F2F7;
    --ios-card: #FFFFFF;
    --ios-card-pressed: #E5E5EA;
    --ios-blue: #007AFF;
    --ios-green: #34C759;
    --ios-red: #FF3B30;
    --ios-label: #000000;
    --ios-secondary-label: #8E8E93;
    --ios-tertiary-bg: #7676801F;
    --ios-separator: #C6C6C8;
    --ios-blur-bg: rgba(242, 242, 247, 0.9);
    --shimmer-base: #E5E5EA;
    --shimmer-highlight: #F2F2F7;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ios-bg: #000000;
        --ios-card: #1C1C1E;
        --ios-card-pressed: #2C2C2E;
        --ios-blue: #0A84FF;
        --ios-green: #30D158;
        --ios-red: #FF453A;
        --ios-label: #FFFFFF;
        --ios-secondary-label: #8E8E93;
        --ios-tertiary-bg: #7676803D;
        --ios-separator: #38383A;
        --ios-blur-bg: rgba(0, 0, 0, 0.9);
        --shimmer-base: #2C2C2E;
        --shimmer-highlight: #3A3A3C;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--ios-bg);
    color: var(--ios-label);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

/* Mobile Viewport Container */
.ios-container {
    width: 100%;
    max-width: 440px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: calc(40px + var(--safe-area-bottom));
}

/* iOS Sticky Navigation Bar */
.ios-navbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--ios-blur-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: calc(12px + var(--safe-area-top)) 16px 12px 16px;
    border-bottom: 0.5px solid var(--ios-separator);
}

.ios-large-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
    color: var(--ios-label);
}

/* iOS Native Search Field */
.ios-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.ios-search-bar {
    width: 100%;
    background: var(--ios-tertiary-bg);
    border-radius: 10px;
    height: 36px;
    padding: 0 10px 0 34px;
    font-size: 15px;
    border: none;
    outline: none;
    color: var(--ios-label);
}

.ios-search-bar::placeholder {
    color: var(--ios-secondary-label);
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--ios-secondary-label);
    font-size: 14px;
    pointer-events: none;
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    background: var(--ios-secondary-label);
    color: var(--ios-bg);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
}

/* Content Layout */
.categories-content {
    padding: 16px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

/* Skeleton Shimmer Placeholders Animation */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(90deg, var(--shimmer-base) 25%, var(--shimmer-highlight) 50%, var(--shimmer-base) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-card {
    background: var(--ios-card);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
    border: 0.5px solid rgba(0, 0, 0, 0.04);
}

.skeleton-img {
    width: 100%;
    height: 115px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    width: 75%;
}

.skeleton-line.short {
    width: 45%;
    height: 10px;
    margin-bottom: 0;
}

/* Category Card */
.category-card {
    background: var(--ios-card);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
    border: 0.5px solid rgba(0, 0, 0, 0.04);
    transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.category-card:active {
    transform: scale(0.96);
    background: var(--ios-card-pressed);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* 10px Border Radius & Shadow on Category Image */
.cat-image-box {
    width: 100%;
    height: 115px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 0.5px solid rgba(0, 0, 0, 0.06);
    position: relative;
}

.cat-image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    padding: 6px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
}

.cat-image-box img.loaded {
    opacity: 1;
}

.category-card:active .cat-image-box img {
    transform: scale(1.05);
}

.cat-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ios-label);
    letter-spacing: -0.2px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.cat-count {
    font-size: 12px;
    color: var(--ios-secondary-label);
    font-weight: 500;
}

/* iOS Bottom Sheet Modal */
.ios-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.ios-sheet.open {
    opacity: 1;
    pointer-events: auto;
}

.ios-sheet-card {
    width: 100%;
    max-width: 440px;
    height: 100vh;
    height: 100dvh;
    background: var(--ios-bg);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

.ios-sheet.open .ios-sheet-card {
    transform: translateY(0);
}

.ios-sheet-handle {
    width: 36px;
    height: 5px;
    background-color: var(--ios-secondary-label);
    opacity: 0.4;
    border-radius: 3px;
    margin: calc(8px + var(--safe-area-top)) auto 4px auto;
}

.ios-sheet-header {
    padding: 8px 16px 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 0.5px solid var(--ios-separator);
    background: var(--ios-blur-bg);
}

.ios-back-btn {
    background: transparent;
    border: none;
    color: var(--ios-blue);
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
}

.ios-back-btn:active {
    opacity: 0.6;
}

.ios-sheet-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ios-label);
    letter-spacing: -0.3px;
    max-width: 55%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.ios-sheet-close {
    background: var(--ios-tertiary-bg);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-label);
    font-size: 13px;
    cursor: pointer;
}

.modal-search-area {
    padding: 10px 16px;
    background: var(--ios-bg);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px calc(24px + var(--safe-area-bottom)) 16px;
    -webkit-overflow-scrolling: touch;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Product Card */
.ios-product-card {
    background: var(--ios-card);
    border-radius: 16px;
    padding: 10px;
    text-decoration: none;
    color: var(--ios-label);
    display: flex;
    flex-direction: column;
    border: 0.5px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ios-product-card:active {
    transform: scale(0.97);
    background: var(--ios-card-pressed);
}

/* 10px Border Radius & Shadow for Product Image Box */
.product-img-box {
    width: 100%;
    height: 115px;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
    border: 0.5px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.product-img-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    padding: 6px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
}

.product-img-box img.loaded {
    opacity: 1;
}

.ios-product-card:active .product-img-box img {
    transform: scale(1.05);
}

/* Discount Badge */
.discount-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--ios-red);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.35);
    z-index: 2;
}

.prod-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-label);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
    min-height: 2.5em;
    margin-bottom: 6px;
}

/* Price & Discount Display */
.price-container {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.prod-sale-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--ios-blue);
}

.prod-regular-price {
    font-size: 12px;
    color: var(--ios-secondary-label);
    text-decoration: line-through;
    font-weight: 500;
}

.discount-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--ios-green);
}

.view-all-wrapper {
    margin-top: 16px;
    text-align: center;
}

.ios-btn-pill {
    background: var(--ios-blue);
    color: white;
    border: none;
    outline: none;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 24px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    transition: opacity 0.15s ease;
}

.ios-btn-pill:active {
    opacity: 0.8;
}

.state-message {
    grid-column: span 2;
    text-align: center;
    padding: 40px 10px;
    color: var(--ios-secondary-label);
    font-size: 14px;
}

.state-message i {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}