:root {
    color-scheme: light;
    --bg: #f7f7f5;
    --fg: #1f2124;
    --muted: #6b7280;
    --border: #e0e0e0;
    --accent: #2f5d50;
    --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    align-items: center;
    padding: 0.9rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.topnav .brand {
    font-weight: 700;
    margin-right: auto;
    color: var(--fg);
    text-decoration: none;
}

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

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

.pageheader {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.card {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    min-width: 220px;
    text-decoration: none;
    color: var(--fg);
}

.card h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}

.searchbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.searchbar input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.datatable {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.datatable th, .datatable td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
    vertical-align: top;
}

.datatable th { background: #f0f0ee; }
.datatable .empty { text-align: center; color: var(--muted); }

.rowactions { display: flex; gap: 0.6rem; align-items: center; white-space: nowrap; }
.rowactions form { display: inline; margin: 0; }

.linkbtn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}
.linkbtn.danger { color: var(--danger); }

.form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-width: 520px;
    background: #fff;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.form input, .form textarea, .form select {
    font: inherit;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--fg);
}

.formactions { display: flex; gap: 1rem; align-items: center; }
.formactions a { color: var(--muted); }

.error { color: var(--danger); }
.success { color: var(--accent); }
.subtle { color: var(--muted); margin: 0.2rem 0 0; }
.hint { color: var(--muted); font-size: 0.85rem; }

.container.narrow { max-width: 380px; margin-top: 4rem; }

.navuser { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.navlogout { margin: 0; }
.navlogout .linkbtn { font-size: 0.85rem; }

.thumb {
    max-width: var(--thumb-size, 120px);
    max-height: var(--thumb-size, 120px);
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border);
    display: block;
}
.thumb.small { max-width: calc(var(--thumb-size, 120px) * 0.6); max-height: calc(var(--thumb-size, 120px) * 0.6); }
.thumb.large { max-width: calc(var(--thumb-size, 120px) * 1.65); max-height: calc(var(--thumb-size, 120px) * 1.65); }

.thumbgrid { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: -0.4rem; }

.profileheader { display: flex; gap: 1.25rem; align-items: flex-start; }

.linklist { font-size: 0.85rem; margin: 0.3rem 0 0; }
.linklist a { color: var(--accent); }

.pageheader-actions { display: flex; gap: 0.6rem; align-items: flex-start; flex-wrap: wrap; }

.btn.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.mediagrid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.mediaitem {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem;
    width: 220px;
    text-align: center;
}
.mediaitem .thumb { margin: 0 auto 0.4rem; max-width: 100%; max-height: calc(var(--thumb-size, 120px) * 1.3); }
.mediaitem a { cursor: zoom-in; }

.medialabel { font-weight: 600; font-size: 0.85rem; margin: 0.2rem 0 0; }
.medianotes { font-size: 0.8rem; color: var(--muted); margin: 0.1rem 0 0.4rem; }

.mediaupload {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
}
.mediaupload input[type="text"] {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    flex: 1;
    min-width: 140px;
}

.doclist { list-style: none; padding: 0; margin: 0 0 1rem; }
.doclist li {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.doclist a { color: var(--accent); }
.doclist-delete { margin-left: auto; }

.checkboxlabel { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.checkboxlabel input { width: auto; }

.noticebanner {
    background: #fff7e6;
    border: 1px solid #e8c877;
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    color: #6b5311;
}

.changelog-entry {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.changelog-entry h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.changelog-entry ul { margin: 0; padding-left: 1.2rem; }

#lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}
#lightbox-overlay[hidden] { display: none; }
#lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}
.lightbox-close {
    position: fixed;
    top: env(safe-area-inset-top, 1rem);
    right: 1.25rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1001;
}

.table-scroll { overflow-x: auto; margin-bottom: 1rem; }
.table-scroll .datatable { margin-bottom: 0; }

@media (max-width: 640px) {
    .topnav { gap: 0.75rem 1rem; padding: 0.75rem 1rem; }
    .navuser { display: none; }
    .container { padding: 1rem; }
    .profileheader { flex-wrap: wrap; }
    .mediaitem { width: 100%; max-width: 260px; }
}
