:root {
    --bg: #0f172a;
    --bg-alt: #020617;
    --card: #020617;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.15);
    --text: #e5e7eb;
    --text-soft: #9ca3af;
    --danger: #f97373;
    --border: #1e293b;
    --radius-lg: 18px;
    --radius-md: 10px;
    --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.9);
}

* {
    box-sizing: border-box;
}

html {
    background-color: #020617;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    background: radial-gradient(circle at top, #1e293b 0, #020617 40%, #000 100%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: 1100px;
    padding: 20px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

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

.logo-mark {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb 0%, #6366f1 35%, #6366f1 65%, #2563eb 100%);
    padding: 2px;
}

.logo-inner {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: radial-gradient(circle at 30% 0, #1f2937, #020617);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #e5e7eb;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo-text h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.logo-text span {
    font-size: 12px;
    color: var(--text-soft);
}

.chip {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-soft);
}

.card {
    background: radial-gradient(circle at top left, #111827 0, #020617 50%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    padding: 18px 18px 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 500;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-soft);
}

.btn-primary {
    border-radius: 999px;
    border: none;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, #2563eb 0%, #6366f1 100%);
    color: #f9fafb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary span {
    font-size: 16px;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.muted {
    color: var(--text-soft);
    font-size: 11px;
}

.auth-root {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    padding: 22px 20px 18px;
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.auth-title {
    font-size: 18px;
    font-weight: 500;
}

.auth-subtitle {
    font-size: 12px;
    color: var(--text-soft);
}

.form-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 12px;
    color: var(--text-soft);
}

.form-input {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

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

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-soft);
}

.error-msg {
    margin-top: 8px;
    font-size: 11px;
    color: #fecaca;
}

main {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr);
    gap: 20px;
}

@media (max-width: 800px) {
    main {
        grid-template-columns: minmax(0, 1fr);
    }

    header {
        flex-direction: column;
        align-items: stretch;
    }

    .chip {
        align-self: flex-end;
        text-align: right;
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: var(--text-soft);
}

.upload-box {
    border-radius: var(--radius-md);
    border: 1px dashed rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.7);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
}

.upload-box.dragover {
    border-style: solid;
    background: rgba(99, 102, 241, 0.08);
}

.upload-title {
    font-size: 14px;
    font-weight: 500;
}

.upload-subtitle {
    font-size: 12px;
    color: var(--text-soft);
}

.progress {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 1);
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(135deg, #2563eb 0%, #6366f1 100%);
    transition: width 0.15s linear;
}

.media-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

.media-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 11px;
    color: var(--text-soft);
}

.media-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.9);
    font-size: 12px;
    color: var(--text-soft);
}

.media-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 12px;
}

.gallery {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

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

.media-card {
    border-radius: 14px;
    background: radial-gradient(circle at top left, #0f172a 0, #020617 60%);
    border: 1px solid rgba(15, 23, 42, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 12px;
}

.media-thumb {
    position: relative;
    height: 110px;
    overflow: hidden;
    background: radial-gradient(circle at center, #111827, #020617);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-thumb img,
.media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-type-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    font-size: 10px;
    color: var(--text-soft);
}

.media-body {
    padding: 8px 9px 7px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: var(--text-soft);
}

.media-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    gap: 6px;
}

.btn-link {
    border: none;
    background: transparent;
    font-size: 11px;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.badge {
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    font-size: 10px;
    color: var(--text-soft);
}

.empty-state {
    font-size: 12px;
    color: var(--text-soft);
    text-align: center;
    padding: 40px 10px;
}

.status {
    margin-top: 6px;
    font-size: 11px;
    min-height: 14px;
}

.status.error {
    color: #fecaca;
}

.status.success {
    color: #bbf7d0;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #020617;
}

::-webkit-scrollbar-thumb {
    background: #111827;
    border-radius: 999px;
}

#viewer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#viewer-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    color: white;
    font-size: 20px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    transition: background 0.2s ease;
}

#viewer-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

#viewer-content {
    box-sizing: border-box;
    max-width: 100vw;
    max-height: 100vh;
    padding: 64px 32px 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#viewer-overlay .viewer-media {
    display: block;
    max-width: calc(100vw - 64px);
    max-height: calc(100vh - 64px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.load-more-btn {
    width: 100%;
    margin: 14px 0 4px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.75);
    color: var(--text);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.load-more-btn:hover {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
}

.load-more-btn:active {
    background: rgba(15, 23, 42, 1);
}
