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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Header */
.shop-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shop-header .logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.shop-header .logo svg {
    width: 28px;
    height: 28px;
    fill: var(--accent-primary);
}

.mifitness-link {
    background: var(--accent-primary);
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.mifitness-link:hover {
    background: var(--accent-hover);
}

.add-app-btn {
    background: var(--accent-success);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.add-app-btn:hover {
    background: #219a52;
}

.shop-header label {
    font-size: 13px;
    color: var(--text-secondary);
}

.shop-header select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    min-width: 220px;
}

.shop-header select:focus {
    border-color: var(--accent-primary);
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Main */
.shop-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* App Grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.app-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.app-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--border-color);
}

.app-card .app-icon {
    width: 72px;
    height: 72px;
    object-fit: cover;
    align-self: flex-start;
}

.app-card .app-card-row {
    display: flex;
    gap: 14px;
    width: 100%;
}

.app-card .app-card-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.app-card .app-card-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    margin-bottom: 2px;
    gap: 6px;
}

.app-card .app-model-badge {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.app-card .app-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.app-card .app-package {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', Monaco, monospace;
    margin-top: 2px;
    word-break: break-all;
}

.app-card .app-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.app-card .app-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-card .app-whatsnew {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-card .app-whatsnew-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.app-card .app-actions {
    margin-top: auto;
    padding-top: 12px;
    display: flex;
    gap: 8px;
}

.app-card .card-info-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.app-card .card-info-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.app-card .card-info-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.app-card .card-share-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.app-card .card-share-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.app-card .card-share-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover {
    background: var(--border-color);
}

/* Form styles for submit modal */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    fill: var(--border-color);
    margin-bottom: 16px;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.modal-header .modal-title {
    flex: 1;
}

.modal-header .modal-title h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal-header .modal-title .modal-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-body h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-info {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.info-row {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-row strong {
    color: var(--text-primary);
    font-weight: 500;
}

.modal-body h4:first-child { margin-top: 0; }

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px 24px;
}

/* Preview Gallery */
.preview-gallery {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-top: 8px;
}

.preview-gallery img {
    height: 140px;
    width: auto;
    max-width: 100%;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.preview-gallery img:hover {
    transform: scale(1.03);
    border-color: var(--accent-primary);
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* File hint */
.file-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.label-hint {
    font-weight: 400;
    color: var(--text-muted);
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .shop-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }
    .shop-header .logo {
        order: 1;
        font-size: 18px;
        justify-content: center;
        width: 100%;
    }
    .header-left {
        order: 2;
        width: 100%;
        justify-content: center;
    }
    .header-right {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    .shop-header select {
        min-width: 200px;
        flex: 1;
    }
    .shop-main {
        padding: 16px;
    }
    .app-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }
    .modal {
        max-height: 95vh;
        border-radius: var(--radius) var(--radius) 0 0;
    }
    .modal-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 16px 16px 12px;
        position: relative;
    }
    .modal-close {
        position: absolute;
        top: 12px;
        right: 12px;
    }
    .modal-body {
        padding: 16px;
    }
    .modal-footer {
        padding: 12px 16px 16px;
        flex-direction: column;
    }
    .modal-footer .btn,
    .modal-footer .btn.secondary {
        width: 100%;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .preview-gallery img {
        height: 110px;
    }
    .lightbox-overlay img {
        max-width: 95vw;
        max-height: 80vh;
    }
}
