:root {
    --primary-color: #007AFF;
    --text-color: #1d1d1f;
    --text-secondary: #86868b;
    --danger-color: #FF3B30;
    --success-color: #34C759;

    --page-bg: linear-gradient(135deg, #eceff4 0%, #b8c6da 100%);
    --blob-1: #ffc3a0;
    --blob-2: #a1c4fd;
    --blob-opacity: 0.45;

    --glass-bg: rgba(255, 255, 255, 0.16);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.12);

    --surface: rgba(255, 255, 255, 0.96);
    --surface-solid: #ffffff;
    --surface-2: rgba(255, 255, 255, 0.8);
    --card-hover: rgba(255, 255, 255, 0.4);
    --overlay: rgba(0, 0, 0, 0.2);
    --overlay-soft: rgba(0, 0, 0, 0.08);
    --bar-bg: rgba(255, 255, 255, 0.2);
    --nav-pill-bg: rgba(255, 255, 255, 0.15);
    --nav-pill-hover: rgba(255, 255, 255, 0.25);
    --pill-bg: rgba(255, 255, 255, 0.5);
    --pill-hover: rgba(255, 255, 255, 0.7);
    --logo-hover: rgba(255, 255, 255, 0.1);
    --logo-active: rgba(255, 255, 255, 0.15);
    --input-bg: rgba(255, 255, 255, 0.18);
    --input-focus-bg: rgba(255, 255, 255, 0.25);
    --btn-secondary-bg: rgba(0, 0, 0, 0.05);
    --border-soft: rgba(0, 0, 0, 0.08);
    --border-modal: rgba(0, 0, 0, 0.06);
    --text-strong: #333333;
    --text-muted: #666666;
    --icon-placeholder: #cccccc;
    --hint-bg: rgba(0, 122, 255, 0.1);
    --shadow-modal: 0 10px 40px rgba(19, 30, 50, 0.08);
    --spinner-track: #c9d2e0;
    --scrollbar-thumb: #c3ccd9;
    --scrollbar-hover: #9aa8bd;
}

@media (prefers-color-scheme: dark) {
    body:not(.admin-body) {
        --primary-color: #0A84FF;
        --text-color: #f2f3f5;
        --text-secondary: #9aa0aa;

        --page-bg: linear-gradient(135deg, #0f1420 0%, #1b2233 100%);
        --blob-1: #6b4a33;
        --blob-2: #27405e;
        --blob-opacity: 0.5;

        --glass-bg: rgba(22, 27, 38, 0.55);
        --glass-border: rgba(255, 255, 255, 0.08);
        --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

        --surface: rgba(28, 33, 46, 0.97);
        --surface-solid: #2b3242;
        --surface-2: rgba(255, 255, 255, 0.06);
        --card-hover: rgba(255, 255, 255, 0.08);
        --overlay: rgba(0, 0, 0, 0.55);
        --overlay-soft: rgba(0, 0, 0, 0.3);
        --bar-bg: rgba(0, 0, 0, 0.28);
        --nav-pill-bg: rgba(255, 255, 255, 0.1);
        --nav-pill-hover: rgba(255, 255, 255, 0.18);
        --pill-bg: rgba(255, 255, 255, 0.12);
        --pill-hover: rgba(255, 255, 255, 0.2);
        --logo-hover: rgba(255, 255, 255, 0.08);
        --logo-active: rgba(255, 255, 255, 0.14);
        --input-bg: rgba(255, 255, 255, 0.06);
        --input-focus-bg: rgba(255, 255, 255, 0.12);
        --btn-secondary-bg: rgba(255, 255, 255, 0.12);
        --border-soft: rgba(255, 255, 255, 0.14);
        --border-modal: rgba(255, 255, 255, 0.1);
        --text-strong: #e6e8ec;
        --text-muted: #a1a7b3;
        --icon-placeholder: #565e6e;
        --hint-bg: rgba(10, 132, 255, 0.18);
        --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.5);
        --spinner-track: #3a4252;
        --scrollbar-thumb: #3a4252;
        --scrollbar-hover: #4a5464;
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

.seo-hidden {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

img {
    max-width: 100%;
    height: auto;
}

main, article, section, aside, nav, header, footer {
    display: block;
}
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--page-bg);
    background-attachment: fixed;
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body::before, body::after {
    content: '';
    position: fixed;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    z-index: -1;
    filter: blur(80px);
}
body::before { background: var(--blob-1); top: -50px; left: -50px; opacity: var(--blob-opacity); }
body::after { background: var(--blob-2); bottom: -50px; right: -50px; opacity: var(--blob-opacity); }

.app-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.header {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 8px;
}
.logo:hover {
    background: var(--logo-hover);
    transform: translateY(-1px);
}
.logo:active {
    transform: translateY(0);
    background: var(--logo-active);
}
.logo svg { width: 24px; height: 24px; fill: var(--primary-color); }

.nav-menu { display: flex; gap: 15px; }
.nav-item { cursor: pointer; font-size: 0.9rem; color: var(--primary-color); transition: opacity 0.3s; }
.nav-item:hover { opacity: 0.7; }

.main-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar {
    width: max-content;
    min-width: 84px;
    max-width: 168px;
    flex: 0 0 auto;
    padding: 16px 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.category-item {
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.92rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
}
.category-item:hover { background: var(--card-hover); }
.category-item.active { background: var(--surface-solid); color: var(--primary-color); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }

.content-area {
    flex: 1;
    padding: 20px 20px 40px 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    grid-auto-rows: max-content;
    gap: 25px;
    align-content: start;
}

.app-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}
.app-card:hover { transform: scale(1.05); }

.app-icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: var(--surface-solid);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--icon-placeholder);
}
.app-name {
    font-size: 12px;
    text-align: center;
    color: var(--text-color);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    margin-top: 2px;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.show { display: flex; opacity: 1; }

.modal {
    background: var(--surface);
    color: var(--text-color);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    width: 90%;
    max-width: 420px;
    padding: 20px;
    border-radius: 14px;
    box-shadow: var(--shadow-modal);
    border: 1px solid var(--border-modal);
    transform: scale(0.96);
    transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1), opacity .2s;
}
.modal-overlay.show .modal { transform: scale(1); }

.modal-header { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; text-align: center; color: var(--text-color); }
.modal-body { margin-bottom: 18px; font-size: 0.95rem; line-height: 1.5; color: var(--text-strong); }

input, select, textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
}
input:focus { background: var(--input-focus-bg); border-color: var(--primary-color); }

.btn-group { display: flex; gap: 10px; align-items: center; justify-content: center; }
.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--text-color); }
.btn:active { transform: scale(0.98); }

@property --go-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes go-spin { to { --go-angle: 360deg; } }
.go-circle {
    flex: 0 0 auto;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    color: #8E5572;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(180deg, #FFE3F0 0%, #F7C9E2 55%, #EFAFD6 100%) padding-box,
        conic-gradient(from var(--go-angle, 0deg),
            #FFB3C6, #FFD9A8, #FFF0A5, #B5E7C8, #A9D6F5, #D3B6EE, #FFB3C6) border-box;
    box-shadow:
        0 10px 22px rgba(224, 140, 190, 0.35),
        inset 0 3px 6px rgba(255, 255, 255, 0.78),
        inset 0 -5px 10px rgba(214, 120, 170, 0.28);
    transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.22s ease;
    animation: go-spin 6s linear infinite;
}
.go-circle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow:
        0 14px 28px rgba(224, 140, 190, 0.45),
        inset 0 3px 6px rgba(255, 255, 255, 0.82),
        inset 0 -5px 10px rgba(214, 120, 170, 0.3);
}
.go-circle:active { transform: scale(0.94); }

.toast {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    padding: 12px 24px;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-strong);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}
.toast.show {
    top: 20px;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .header {
        padding: 0 12px;
    }

    .logo {
        font-size: 1.1rem;
        padding: 6px;
    }

    .nav-menu {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .nav-item {
        font-size: 0.75rem;
        padding: 6px 10px;
        background: var(--nav-pill-bg);
        border-radius: 8px;
        white-space: nowrap;
        transition: all 0.2s ease;
        min-width: fit-content;
    }
    .nav-item:hover {
        background: var(--nav-pill-hover);
        opacity: 1;
        transform: translateY(-1px);
    }

    .mobile-cats {
        display: flex;
        overflow-x: auto;
        padding: 10px;
        gap: 10px;
        background: var(--bar-bg);
        position: sticky;
        top: 60px;
        z-index: 90;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    .mobile-cat-pill {
        white-space: nowrap;
        padding: 6px 12px;
        background: var(--pill-bg);
        border-radius: 15px;
        font-size: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .mobile-cat-pill.active { background: var(--surface-solid); color: var(--primary-color); }
    .mobile-cat-pill:hover { background: var(--pill-hover); }

    .content-area {
        padding: 12px 14px calc(30px + env(safe-area-inset-bottom, 0px)) 14px;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

.mobile-cats {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.mobile-cats::-webkit-scrollbar { display: none; }
}

@media (max-width: 480px) {
    .header {
        padding: 0 8px;
        flex-wrap: wrap;
        min-height: 60px;
    }

    .logo {
        font-size: 1rem;
        padding: 4px;
    }

    .nav-menu {
        gap: 4px;
        width: 100%;
        justify-content: space-between;
        margin-top: 4px;
    }

    .nav-item {
        font-size: 0.7rem;
        padding: 4px 6px;
        flex: 1;
        text-align: center;
        max-width: calc(25% - 3px);
    }

    .content-area {
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

.admin-row, .list-row {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, background .18s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-card {
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff, #fbfbfd);
    box-shadow: 0 8px 24px rgba(12,18,36,0.06);
    border: 1px solid rgba(0,0,0,0.04);
    min-width: 140px;
    display:flex;
    flex-direction:column;
    gap:6px;
}
.stat-card .stat-value { font-size:18px; font-weight:700; color: #111; }
.stat-card .stat-label { font-size:12px; color:#666; }

.admin-row::before, .list-row::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    transform: translateX(-100%);
    transition: transform .36s cubic-bezier(.2,.9,.2,1);
    pointer-events: none;
    z-index: 0;
}
.admin-row > *, .list-row > * { position: relative; z-index: 1; }
.admin-row:hover, .list-row:hover { transform: translateY(-6px); box-shadow: 0 12px 30px rgba(0,0,0,0.12); background: rgba(255,255,255,0.04); }
.admin-row:hover::before, .list-row:hover::before { transform: translateX(0); }

.admin-nav-item { border-radius: 10px; position: relative; overflow: hidden; }
.admin-nav-item::before { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)); transform: translateX(-100%); transition: transform .36s cubic-bezier(.2,.9,.2,1); z-index: 0; pointer-events: none; }
.admin-nav-item > * { position: relative; z-index: 1; }
.admin-nav-item:hover::before { transform: translateX(0); }
.admin-nav-item.active { background: rgba(255,255,255,0.95); color: var(--primary-color); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.admin-nav-item.active::before { transform: translateX(0); }

.list-row { display: flex; justify-content: space-between; align-items: center; }

.content-area {
    overscroll-behavior-y: contain;
}
#pullIndicator {
    position: fixed;
    top: 60px;
    left: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    color: var(--primary-color);
    transform: translate(-50%, -48px);
    transition: transform 0.25s ease;
    z-index: 80;
    pointer-events: none;
}
#pullIndicator .ptr-arrow { font-size: 18px; line-height: 1; transition: transform 0.2s ease; }
#pullIndicator.ready .ptr-arrow { transform: rotate(180deg); }
#pullIndicator .ptr-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--spinner-track);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: ptr-spin 0.8s linear infinite;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb); border-radius: 999px;
    border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-hover); }
::-webkit-scrollbar-corner { background: transparent; }
