/* ── Variables & Reset ──────────────────────────────── */
:root {
    --bg-0: #06060b;
    --bg-1: #0c0c14;
    --bg-2: #12121c;
    --bg-3: #1a1a27;
    --bg-4: #222233;
    --border: rgba(255, 255, 255, 0.06);
    --border-h: rgba(255, 255, 255, 0.12);
    --text-1: #eeeef5;
    --text-2: #9898aa;
    --text-3: #55556a;
    --accent: #7c5cfc;
    --accent-dim: rgba(124, 92, 252, 0.12);
    --accent-hover: #6a4ae8;
    --green: #00d68f;
    --green-dim: rgba(0, 214, 143, 0.12);
    --red: #ff4757;
    --red-dim: rgba(255, 71, 87, 0.1);
    --yellow: #feca57;
    --radius: 10px;
    --font: 'DM Sans', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

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

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 15% 10%, rgba(124, 92, 252, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 80%, rgba(0, 214, 143, 0.04) 0%, transparent 55%);
    pointer-events: none;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Nav ─────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(6, 6, 11, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: var(--text-1);
}

.nav-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

.nav-logo span {
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: -.02em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.nav-link {
    padding: .45rem .9rem;
    border-radius: 7px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    transition: all .15s;
}

.nav-link:hover {
    background: var(--bg-3);
    color: var(--text-1);
    text-decoration: none;
}

.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-username {
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-2);
    font-family: var(--mono);
}

/* ── Layout ──────────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* ── Forms ───────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .5rem;
}

.form-input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .7rem 1rem;
    color: var(--text-1);
    font-family: var(--font);
    font-size: .85rem;
    outline: none;
    transition: border-color .2s;
}

.form-input:focus {
    border-color: var(--accent);
}

.form-hint {
    font-size: .7rem;
    color: var(--text-3);
    margin-top: .3rem;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 600;
    padding: .6rem 1.3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text-1);
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-3);
    border-color: var(--border-h);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 25px var(--accent-dim);
}

.btn-danger {
    border-color: rgba(255, 71, 87, 0.3);
    color: var(--red);
}

.btn-danger:hover {
    background: var(--red-dim);
}

.btn-success {
    border-color: rgba(0, 214, 143, 0.3);
    color: var(--green);
}

.btn-success:hover {
    background: var(--green-dim);
}

.btn-sm {
    padding: .35rem .75rem;
    font-size: .72rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-secondary {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    padding: .5rem 1rem;
    border-radius: 7px;
    font-size: .75rem;
    cursor: pointer;
    font-family: var(--font);
    transition: all .15s;
}

.btn-secondary:hover {
    border-color: var(--border-h);
    color: var(--text-1);
}

/* ── Card ────────────────────────────────────────────── */
.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-title {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* ── Alerts ──────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    font-size: .8rem;
    margin-bottom: 1.25rem;
}

.alert-error {
    background: var(--red-dim);
    border: 1px solid rgba(255, 71, 87, 0.2);
    color: var(--red);
}

.alert-success {
    background: var(--green-dim);
    border: 1px solid rgba(0, 214, 143, 0.2);
    color: var(--green);
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-0);
}

::-webkit-scrollbar-thumb {
    background: var(--text-3);
    border-radius: 3px;
}

/* ── Auth pages ──────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.auth-header p {
    color: var(--text-2);
    font-size: .82rem;
    margin-top: .4rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: .8rem;
    color: var(--text-2);
}

.remember-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1.25rem;
    font-size: .8rem;
    color: var(--text-2);
}

.remember-row input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ── Dashboard ───────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.stat {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
}

.stat .label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-3);
    margin-bottom: .4rem;
}

.stat .val {
    font-size: 1.35rem;
    font-weight: 700;
    font-family: var(--mono);
}

.stat .val.purple {
    color: var(--accent);
}

.stat .val.green {
    color: var(--green);
}

.storage-bar {
    margin-top: .5rem;
    height: 4px;
    background: var(--bg-3);
    border-radius: 2px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .3s;
}

.storage-text {
    font-size: .65rem;
    color: var(--text-3);
    margin-top: .3rem;
    font-family: var(--mono);
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: all .2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-zone h3 {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: .3rem;
}

.upload-zone p {
    color: var(--text-2);
    font-size: .78rem;
}

.upload-zone .fmts {
    font-family: var(--mono);
    font-size: .6rem;
    color: var(--text-3);
    margin-top: .5rem;
}

.upload-zone.uploading {
    pointer-events: none;
    opacity: .6;
}

.upload-progress {
    display: none;
    margin-top: 1rem;
}

.progress-track {
    height: 4px;
    background: var(--bg-0);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .3s;
    width: 0%;
}

.upload-results {
    display: none;
    background: var(--bg-2);
    border: 1px solid rgba(0, 214, 143, 0.15);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    text-align: left;
}

.url-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .4rem;
}

.url-row label {
    font-size: .6rem;
    color: var(--text-3);
    min-width: 55px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.url-row code {
    flex: 1;
    font-family: var(--mono);
    font-size: .68rem;
    background: var(--bg-0);
    padding: .3rem .6rem;
    border-radius: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--green);
}

.toolbar {
    display: flex;
    gap: .75rem;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box input {
    width: 100%;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem 1rem .6rem 2.3rem;
    color: var(--text-1);
    font-family: var(--font);
    font-size: .8rem;
    outline: none;
    transition: border-color .2s;
}

.search-box input:focus {
    border-color: var(--accent);
}

.search-box::before {
    content: '⌕';
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
}

.filter-pills {
    display: flex;
    gap: 2px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.pill {
    font-family: var(--font);
    font-size: .72rem;
    font-weight: 500;
    padding: .35rem .85rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}

.pill.active {
    background: var(--accent);
    color: #fff;
}

.pill:hover:not(.active) {
    color: var(--text-1);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.g-item {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all .2s;
    position: relative;
}

.g-item:hover {
    border-color: var(--border-h);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.g-item .thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: var(--bg-2);
    cursor: pointer;
}

.g-item .info {
    padding: .6rem .75rem;
}

.g-item .name {
    font-size: .68rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: .2rem;
}

.g-item .meta-row {
    display: flex;
    justify-content: space-between;
    font-size: .58rem;
    color: var(--text-3);
    font-family: var(--mono);
}

.g-item .badge {
    position: absolute;
    top: .4rem;
    right: .4rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    font-size: .55rem;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: 600;
    color: var(--yellow);
}

.g-item .overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 11, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    opacity: 0;
    transition: opacity .15s;
}

.g-item:hover .overlay {
    opacity: 1;
}

.modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

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

.modal-bg img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: var(--radius);
}

.modal-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--text-1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: .4rem;
    margin: 1.5rem 0;
}

.empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-3);
}

.empty .icon {
    font-size: 2.5rem;
    margin-bottom: .75rem;
    opacity: .25;
}

.empty h3 {
    color: var(--text-2);
    margin-bottom: .3rem;
    font-size: 1rem;
}

.empty p {
    font-size: .8rem;
}

.toast-wrap {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem 1rem;
    font-size: .78rem;
    animation: toast-in .25s ease;
}

.toast.ok {
    border-color: rgba(0, 214, 143, 0.25);
    color: var(--green);
}

.toast.err {
    border-color: rgba(255, 71, 87, 0.25);
    color: var(--red);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(.5rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.embed-modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.embed-modal-bg.open {
    display: flex;
}

.embed-modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
}

.embed-modal h3 {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.embed-modal label {
    display: block;
    font-size: .68rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .3rem;
}

.embed-modal input,
.embed-modal textarea {
    width: 100%;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: .55rem .75rem;
    color: var(--text-1);
    font-family: var(--font);
    font-size: .8rem;
    outline: none;
    transition: border-color .2s;
    margin-bottom: 1rem;
}

.embed-modal input:focus,
.embed-modal textarea:focus {
    border-color: var(--accent);
}

.embed-modal textarea {
    resize: vertical;
    min-height: 60px;
}

.embed-modal .actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: .25rem;
}

#file-input {
    display: none;
}

/* ── Settings ────────────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.settings-grid .card.full {
    grid-column: 1/-1;
}

.api-key-box {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}

.api-key-box code {
    flex: 1;
    font-family: var(--mono);
    font-size: .75rem;
    background: var(--bg-0);
    padding: .65rem 1rem;
    border-radius: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent);
    border: 1px solid var(--border);
    user-select: all;
}

.api-key-box .hidden-key {
    color: var(--text-3);
}

.inline-form {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
}

.inline-form .form-group {
    flex: 1;
    margin-bottom: 0;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.info-item .info-label {
    font-size: .65rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .3rem;
}

.info-item .info-val {
    font-family: var(--mono);
    font-size: .85rem;
}

.embed-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}

.color-swatches {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .5rem;
}

.color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform .1s, border-color .1s;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: #fff;
}

.dc-preview-wrap {
    position: sticky;
    top: 1.5rem;
}

.dc-preview-label {
    font-size: .65rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .6rem;
}

.dc-embed {
    background: #2b2d31;
    border-radius: 4px;
    overflow: hidden;
    max-width: 320px;
    border-left: 4px solid #5865F2;
    font-family: 'gg sans', 'Noto Sans', sans-serif;
}

.dc-embed-inner {
    padding: .75rem 1rem .75rem .75rem;
}

.dc-author {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .35rem;
}

.dc-author-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    background: #5865f2;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    overflow: hidden;
}

.dc-author-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dc-author-name {
    font-size: .78rem;
    font-weight: 600;
    color: #fff;
}

.dc-title {
    font-size: .9rem;
    font-weight: 600;
    color: #00aff4;
    margin-bottom: .3rem;
    word-break: break-word;
}

.dc-desc {
    font-size: .78rem;
    color: #dbdee1;
    line-height: 1.4;
    margin-bottom: .5rem;
    word-break: break-word;
}

.dc-image {
    width: 100%;
    border-radius: 4px;
    display: block;
    max-height: 160px;
    object-fit: cover;
    background: #1e1f22;
}

.dc-footer {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .6rem;
}

.dc-footer-txt {
    font-size: .68rem;
    color: #87898c;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
    .embed-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .nav {
        padding: 0 1rem;
    }

    .nav-links {
        gap: 0;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .toolbar {
        flex-direction: column;
    }

    .search-box {
        min-width: 100%;
    }
}