:root {
    color-scheme: light dark;
    --bg: #f4f5f9;
    --text: #151a24;
    --muted: #667085;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --border: #e1e4ec;
    --accent: #5b5bf0;
    --accent-2: #8b5cf6;
    --accent-soft: rgba(91, 91, 240, 0.12);
    --error: #d92d20;
    --ok: #16a34a;
    --code: #c02d76;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
    --topbar-bg: rgba(255, 255, 255, 0.75);
    --radius: 14px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1017;
        --text: #e9ecf4;
        --muted: #98a2b3;
        --surface: #161b25;
        --surface-2: #1e2531;
        --border: #272f3d;
        --accent: #7c7cff;
        --accent-2: #a78bfa;
        --accent-soft: rgba(124, 124, 255, 0.16);
        --error: #ff7b72;
        --ok: #4ade80;
        --code: #f08cbc;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
        --topbar-bg: rgba(13, 16, 23, 0.75);
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.5rem 0 1rem; }

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

code {
    color: var(--code);
    background: var(--surface-2);
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
}

p { margin: 0.5rem 0; }

/* Layout */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    padding: 0.7rem 1.25rem;
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
}

.topbar nav { display: flex; gap: 0.25rem; flex: 1; }

.topbar nav a {
    color: var(--muted);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.topbar .user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--muted); }

@media (max-width: 640px) {
    .topbar { padding: 0.6rem 0.9rem; }
    .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
    .topbar .user { margin-left: auto; }
}

main { padding: 1.25rem; max-width: 1280px; margin: 0 auto; }

@media (max-width: 640px) {
    main { padding: 0.9rem; }
}

/* Controls */
button {
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

button:hover:not(:disabled) { background: var(--surface-2); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button[type=submit] {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border: 0;
}

button[type=submit]:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.08); }

button.danger, .viewer-bar .danger, .members .actions .danger {
    background: var(--error);
    color: #fff;
    border: 0;
}

button.danger:hover:not(:disabled) { background: var(--error); filter: brightness(1.1); }

button.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font-weight: 500;
}

button.link:hover:not(:disabled) { background: none; text-decoration: underline; }

input:not([type=file]) {
    font: inherit;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    min-width: 12rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:not([type=file]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--ok); }
.invalid { outline: 1px solid var(--error); }
.validation-message { color: var(--error); }

.status { color: var(--muted); }
.error { color: var(--error); }

/* Gallery */
.months {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.months::-webkit-scrollbar { display: none; }
.months strong { min-width: 3rem; color: var(--muted); font-weight: 700; }

.chip {
    flex: none;
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-weight: 500;
    background: var(--surface);
    box-shadow: var(--shadow);
    border-color: transparent;
}

.chip.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

.chip.active:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem;
    margin-top: 1.25rem;
}

@media (max-width: 640px) {
    .grid { grid-template-columns: repeat(3, 1fr); gap: 0.3rem; }
}

.tile {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-2);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tile:hover:not(:disabled) { background: var(--surface-2); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

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

.tile:hover img { transform: scale(1.04); }

.tile .restore {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    padding: 0.4rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.tile .restore:hover:not(:disabled) { background: rgba(0, 0, 0, 0.78); }

/* Photo viewer */
.viewer {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 12, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fade-in 0.15s ease;
}

.viewer-body { display: flex; flex-direction: column; align-items: center; max-width: 96vw; max-height: 96vh; gap: 0.9rem; }
.viewer-body img { max-width: 96vw; max-height: 82vh; object-fit: contain; border-radius: 10px; box-shadow: var(--shadow-lg); }
.viewer-body .status { color: #cbd2de; }

.viewer-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #e9ecf4;
}

.viewer-bar span { flex: 1 1 100%; text-align: center; font-size: 0.85rem; color: #aab2c0; }

.viewer-bar button {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 0;
}

.viewer-bar button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.22); }
.viewer-bar .danger { background: var(--error); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Upload */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 2.5rem 1rem;
    margin: 1rem 0;
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.disabled { opacity: 0.55; pointer-events: none; }
.dropzone .icon { font-size: 2rem; line-height: 1; }
.dropzone strong { font-size: 1.05rem; }
.dropzone small { color: var(--muted); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.results { list-style: none; padding: 0; display: grid; gap: 0.35rem; }

.results li {
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.results .ok { color: var(--ok); }
.results .fail { color: var(--error); }

/* Admin */
.invite { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.invite input { flex: 1 1 12rem; }

.notice {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.75rem 1.1rem;
    margin-bottom: 1.25rem;
}

.notice code { font-size: 1.1rem; user-select: all; }

.members {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.members th, .members td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.members th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); }
.members tr:last-child td { border-bottom: 0; }
.members tr.disabled td { color: var(--muted); opacity: 0.7; }
.members .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.members .actions button { padding: 0.3rem 0.7rem; font-size: 0.82rem; }

@media (max-width: 800px) {
    .members { display: block; overflow-x: auto; }
}

/* Blazor framework UI */
#blazor-error-ui {
    background: #fff4c2;
    color: #1d2733;
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.25);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary {
    background: var(--error);
    padding: 1rem;
    color: white;
    border-radius: 10px;
}

.blazor-error-boundary::after { content: "Hiba történt."; }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-2);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: var(--muted);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Betöltés"); }
