:root {
    color-scheme: light;
    --background: #f3f4f6;
    --surface: #ffffff;
    --text: #171717;
    --muted: #6b7280;
    --border: #dedfe3;
    --accent: #1f6feb;
    --accent-dark: #195fc8;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --shadow: 0 12px 30px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--background);
    color: var(--text);
}

a { color: var(--accent); }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.3rem clamp(1rem, 4vw, 3rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 2rem); }
.site-header p { margin: .25rem 0 0; color: var(--muted); }

.content {
    width: min(1500px, calc(100% - 2rem));
    margin: 1.5rem auto 3rem;
}

.toolbar {
    position: sticky;
    top: 92px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, .96);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0,0,0,.05);
    backdrop-filter: blur(12px);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.photo-card {
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 3px 12px rgba(0,0,0,.045);
}

.selection-box {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .65rem .75rem;
    cursor: pointer;
    font-size: .9rem;
}

.selection-box input {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--accent);
}

.photo-link {
    display: block;
    background: #e5e7eb;
    aspect-ratio: 4 / 3;
}

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

.photo-link:hover img { transform: scale(1.025); }

.photo-info {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem .75rem .8rem;
}

.photo-info span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.photo-info small {
    flex: 0 0 auto;
    color: var(--muted);
}

.primary-button,
.secondary-button,
.text-button {
    border: 0;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
}

.primary-button {
    padding: .75rem 1rem;
    color: #fff;
    background: var(--accent);
    font-weight: 700;
}

.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }

.secondary-button {
    display: inline-block;
    padding: .65rem .9rem;
    color: var(--text);
    background: #eef0f3;
    text-decoration: none;
}

.text-button {
    padding: .35rem .5rem;
    color: var(--accent);
    background: transparent;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin-top: 2rem;
}

.pagination a {
    padding: .6rem .8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-card {
    width: min(430px, 100%);
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.login-card h1 { margin-top: 0; }
.brand-mark { font-size: 3rem; }
.muted { color: var(--muted); }

.login-card form {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.login-card label {
    display: grid;
    gap: .45rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: .8rem;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

textarea { margin-top: .6rem; resize: vertical; }

.alert {
    padding: .8rem;
    color: var(--danger-text);
    background: var(--danger-bg);
    border-radius: 8px;
}

.empty-state {
    padding: 3rem;
    text-align: center;
    background: var(--surface);
    border-radius: 14px;
}

@media (max-width: 1050px) {
    .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar {
        top: 78px;
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 460px) {
    .gallery-grid { grid-template-columns: 1fr; }
    .site-header { align-items: flex-start; }
}
