:root {
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --danger: #dc2626;
    --text: #1f2937;
    --muted: #6b7280;
    --bg: #f3f4f6;
    --card: #ffffff;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over author display rules (.modal, form, ...) */
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.card {
    width: 100%;
    max-width: 480px;
    margin: 16px auto 0;
    padding: 24px 20px;
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card.wide { max-width: 720px; }

h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0; }
p { margin: 0 0 16px; color: var(--muted); }

form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

input {
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
}

input:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

button:active { background: var(--accent-dark); }

.link-button {
    background: none;
    color: var(--accent);
    font-weight: 500;
    text-decoration: underline;
    padding: 4px;
}

.message {
    padding: 12px;
    border-radius: 10px;
    background: #ecfdf5;
    color: #065f46;
}

.message.error { background: #fef2f2; color: var(--danger); }

.counter { font-weight: 600; color: var(--text); }

.user-name { font-size: 1.05rem; font-weight: 600; color: var(--accent); margin-bottom: 4px; }

.admin-link { margin: 16px 0 0; text-align: center; }
.admin-link a { color: var(--muted); font-size: 0.85rem; }

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

.cell { position: relative; aspect-ratio: 1; }

.cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}

.cell .delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 0.9rem;
    line-height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
}

.cell .download {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 50%;
    text-decoration: none;
}

.upload-button {
    display: block;
    text-align: center;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border-radius: 10px;
    cursor: pointer;
}

.upload-button.disabled { background: #9ca3af; pointer-events: none; }

.upload-buttons { display: flex; gap: 8px; }
.upload-buttons .upload-button { flex: 1; }

.toolbar { margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #e5e7eb; }

tbody tr { cursor: pointer; }
tbody tr:hover { background: #eff6ff; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header button {
    background: none;
    color: var(--muted);
    font-size: 1.2rem;
    padding: 4px 8px;
}

.branding {
    margin: 24px 0 16px;
    text-align: center;
}

.branding a {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.branding img { height: 52px; }

@media (min-width: 600px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
