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

:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-2: #252525;
    --border: #333;
    --text: #e0e0e0;
    --text-muted: #888;
    --primary: #6c63ff;
    --primary-hover: #5a52e0;
    --danger: #e74c3c;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,.3);
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 16px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: .9rem;
    transition: color .2s;
}

.nav-link:hover {
    color: var(--primary);
}

.main {
    padding: 32px 20px;
    min-height: calc(100vh - 140px);
}

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 24px;
}

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

.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.album-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: transform .2s, box-shadow .2s;
}

.album-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(108, 99, 255, .15);
}

.album-cover {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--surface-2);
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-muted);
}

.album-info {
    padding: 16px;
}

.album-info h2 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.photo-count {
    font-size: .85rem;
    color: var(--text-muted);
}

.album-desc {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.photo-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    aspect-ratio: 3 / 2;
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}

.photo-card:hover img {
    transform: scale(1.05);
}

.photo-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.photo-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0,0,0,.7));
    font-size: .8rem;
    color: #fff;
}

.photo-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .2s;
}

.photo-card:hover .photo-actions {
    opacity: 1;
}

.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    color: #fff;
    text-decoration: none;
    font-size: .85rem;
    cursor: pointer;
    border: none;
    transition: background .2s;
}

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

.btn-small.active {
    background: var(--primary);
}

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

.album-header {
    margin-bottom: 24px;
}

.album-header h1 {
    margin-bottom: 8px;
}

.album-description {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.album-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background .2s;
}

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

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

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: .9;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: .9rem;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .95rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-select {
    appearance: auto;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 24px;
}

.album-form {
    max-width: 600px;
}

.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    margin-bottom: 24px;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(108, 99, 255, .05);
}

.upload-message p {
    font-size: 1rem;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: .85rem;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.upload-progress {
    margin-bottom: 24px;
}

.progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0;
    transition: width .3s;
}

.progress-text {
    font-size: .85rem;
    color: var(--text-muted);
    text-align: center;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .9rem;
}

.alert-error {
    background: rgba(231, 76, 60, .15);
    color: var(--danger);
    border: 1px solid rgba(231, 76, 60, .3);
}

.login-form {
    max-width: 400px;
    margin: 60px auto;
}

.login-form h1 {
    text-align: center;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox.hidden {
    display: none;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 2.5rem;
    color: #fff;
    cursor: pointer;
    z-index: 1001;
    opacity: .7;
    transition: opacity .2s;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.1);
    color: #fff;
    border: none;
    font-size: 3rem;
    padding: 8px 16px;
    cursor: pointer;
    z-index: 1001;
    border-radius: 4px;
    transition: background .2s;
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255,255,255,.2);
}

.lightbox-exif {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    color: var(--text-muted);
    font-size: .85rem;
}

.lightbox-exif span {
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 4px;
}

/* Admin */
.admin-header .nav-link[target="_blank"] {
    color: var(--primary);
}

.quick-upload {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
}

.quick-upload h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.quick-upload .upload-zone {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: .9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.reorder-cell {
    white-space: nowrap;
    text-align: center;
    width: 40px;
}

.drag-handle {
    cursor: grab;
    font-size: 1.3rem;
    color: var(--text-muted);
    display: inline-block;
    line-height: 1;
    user-select: none;
    padding: 4px;
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.3;
    background: var(--surface-2) !important;
}

.sortable-drag {
    opacity: 0.9;
    background: var(--surface) !important;
    border: 1px solid var(--primary) !important;
}

.sortable-table tbody tr {
    cursor: default;
}

.sortable-table tbody tr:hover .drag-handle {
    color: var(--primary);
}

.reorder-notice {
    display: none;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: rgba(46, 204, 113, .15);
    color: #2ecc71;
    margin-bottom: 16px;
    font-size: .9rem;
    text-align: center;
    transition: opacity .3s;
}

.reorder-notice.visible {
    display: block;
}

.reorder-notice.saving {
    color: var(--text-muted);
    background: var(--surface-2);
}

.reorder-form {
    margin-top: 24px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--surface-2);
    font-size: .85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table small {
    color: var(--text-muted);
}

.actions-cell {
    white-space: nowrap;
}

.btn-sm {
    padding: 6px 12px;
    font-size: .8rem;
}

.legal-page {
    max-width: 720px;
    margin: 0 auto;
}

.legal-page h1 {
    font-size: 1.6rem;
    margin-bottom: 32px;
}

.legal-page h2 {
    font-size: 1.15rem;
    margin-top: 28px;
    margin-bottom: 12px;
    color: var(--primary);
}

.legal-page p,
.legal-page li {
    color: var(--text-muted);
    font-size: .95rem;
    line-height: 1.7;
}

.legal-page ul {
    padding-left: 20px;
    margin-top: 8px;
}

.legal-page a {
    color: var(--primary);
}

.photo-exif {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,.8));
    font-size: .65rem;
    color: #ccc;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

.photo-card:hover .photo-exif {
    opacity: 1;
}

.photo-exif span {
    background: rgba(0,0,0,.5);
    padding: 1px 5px;
    border-radius: 3px;
}

.photo-edit-form {
    position: absolute;
    top: 44px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .2s;
}

.photo-card:hover .photo-edit-form {
    opacity: 1;
}

.photo-edit-input {
    width: 90px;
    padding: 3px 6px;
    background: rgba(0,0,0,.7);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: #fff;
    font-size: .75rem;
}

.photo-edit-order {
    width: 50px;
    padding: 3px 6px;
    background: rgba(0,0,0,.7);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: #fff;
    font-size: .75rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    padding: 16px 0;
}

.pagination-info {
    font-size: .9rem;
    color: var(--text-muted);
}

.alert-success {
    background: rgba(46, 204, 113, .15);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, .3);
}

@media (max-width: 768px) {
    .albums-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }

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

    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }

    .header .container {
        flex-direction: column;
        gap: 8px;
    }
}
