:root {
    --bg: #0a0a0a;
    --bg2: #111;
    --bg3: #1a1a1a;
    --border: #222;
    --red: #E63946;
    --green: #2ecc71;
    --blue: #3B82F6;
    --purple: #8B5CF6;
    --white: #fff;
    --dim: #999;
    --muted: #666;
    --font: 'Inter', sans-serif;
}

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

body { font-family: var(--font); background: var(--bg); color: var(--white); min-height: 100vh; }

/* Header */
.cdn-header {
    display: flex; align-items: center; gap: 24px;
    padding: 14px 28px;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}

.cdn-logo { display: flex; align-items: center; gap: 10px; }
.cdn-logo span { font-weight: 800; font-size: 18px; letter-spacing: 2px; }
.cdn-logo small { font-size: 10px; font-weight: 400; letter-spacing: 4px; color: var(--dim); }

.cdn-tabs { display: flex; gap: 4px; }
.cdn-tab {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: var(--bg3);
    color: var(--dim);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.cdn-tab:hover { color: var(--white); background: var(--bg2); }
.cdn-tab.active { background: var(--red); color: var(--white); }

.cdn-info { margin-left: auto; font-size: 12px; color: var(--muted); }

/* Actions */
.cdn-actions {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 28px 0;
    margin-bottom: 16px;
}

.cdn-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-family: var(--font);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.cdn-btn--accent { background: var(--red); color: var(--white); }
.cdn-btn--accent:hover { background: #cf303d; }
.cdn-btn--outline { background: transparent; border: 1px solid var(--border); color: var(--dim); }
.cdn-btn--outline:hover { border-color: var(--red); color: var(--red); }
.cdn-btn--sm { padding: 6px 14px; font-size: 12px; }
.cdn-btn--danger { color: var(--red); background: transparent; }
.cdn-btn--danger:hover { background: rgba(230,57,70,.1); }
.cdn-btn--ghost { background: transparent; color: var(--dim); padding: 6px 10px; }
.cdn-btn--ghost:hover { color: var(--white); background: var(--bg3); }

.cdn-btn--icon {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
}

#files-count { font-size: 13px; color: var(--dim); }

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

/* File Grid */
.cdn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 0 28px 28px;
}

.cdn-file {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color .15s;
}
.cdn-file:hover { border-color: var(--red); }

.cdn-file__thumb {
    width: 100%; height: 120px;
    background: var(--bg3);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.cdn-file__thumb img { width: 100%; height: 100%; object-fit: cover; }
.cdn-file__thumb i { font-size: 36px; color: var(--dim); }

.cdn-file__body { padding: 10px 14px; }
.cdn-file__name { font-size: 12px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cdn-file__meta { font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.cdn-file__actions { display: flex; gap: 6px; }

/* APK Grid */
.cdn-apk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 0 28px 28px;
}

.cdn-apk-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: border-color .15s;
}
.cdn-apk-card:hover { border-color: var(--red); }
.cdn-apk-card--empty { border-style: dashed; opacity: .6; }

.cdn-apk-card__icon { font-size: 24px; margin-bottom: 12px; }
.cdn-apk-card__name { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.cdn-apk-card__version { font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.cdn-apk-card__version span { color: var(--green); font-weight: 600; }

.cdn-apk-card__info { font-size: 11px; color: var(--muted); margin-bottom: 14px; line-height: 1.6; }
.cdn-apk-card__info i { width: 16px; color: var(--dim); }

.cdn-apk-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cdn-apk-avatar {
    position: relative;
    width: 56px; height: 56px;
    border-radius: 14px;
    background: var(--bg3);
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .2s;
}
.cdn-apk-avatar:hover { border-color: var(--red); }
.cdn-apk-avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
    position: absolute; inset: 0;
}
.cdn-apk-avatar__edit {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .2s;
    color: #fff; font-size: 12px;
}
.cdn-apk-avatar:hover .cdn-apk-avatar__edit { opacity: 1; }

.cdn-crop-frame {
    width: 300px; height: 300px;
    margin: 0 auto 12px;
    border: 2px solid var(--red);
    border-radius: 12px;
    overflow: hidden;
    cursor: move;
    position: relative;
    background: #111;
}
.cdn-crop-frame canvas { position: absolute; }

.cdn-crop-controls { display: flex; justify-content: center; margin-bottom: 12px; }
.cdn-crop-controls input[type=range] { width: 200px; accent-color: var(--red); }

/* Modal */
.cdn-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.cdn-modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    width: 360px;
    max-width: 90vw;
}
.cdn-modal h3 { font-size: 16px; margin-bottom: 16px; }
.cdn-modal label { display: block; font-size: 11px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.cdn-modal input, .cdn-modal select {
    width: 100%; padding: 8px 12px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 6px; color: var(--white);
    font-family: var(--font); font-size: 13px;
    margin-bottom: 12px; outline: none;
}
.cdn-modal input:focus, .cdn-modal select:focus { border-color: var(--red); }
.cdn-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.cdn-modal .cdn-version-row { display: flex; gap: 8px; }
.cdn-modal .cdn-version-row input { flex: 1; }

/* Toast */
.cdn-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--bg2); border: 1px solid var(--green);
    border-radius: 10px; padding: 12px 20px;
    font-size: 13px; color: var(--green);
    z-index: 300;
    animation: toastIn .3s ease-out;
}
.cdn-toast--error { border-color: var(--red); color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 600px) {
    .cdn-header { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
    .cdn-grid { grid-template-columns: 1fr 1fr; padding: 0 16px 16px; }
    .cdn-apk-grid { grid-template-columns: 1fr; padding: 0 16px 16px; }
    .cdn-actions { padding: 16px 16px 0; }
}

@keyframes cdnPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(230,57,70,0.4)); }
    50% { transform: scale(1.08); filter: drop-shadow(0 0 20px rgba(230,57,70,0.7)); }
}
