:root {
    --bg: #0b0f17;
    --surface: rgba(22, 27, 34, 0.88);
    --surface-solid: #161b22;
    --input: #0d1117;
    --border: #2b3240;
    --border-input: #30363d;
    --text: #e6edf3;
    --text-strong: #f0f6fc;
    --muted: #8b949e;
    --accent: #2f81f7;
    --accent-hover: #1f6feb;
    --link: #58a6ff;
    --green: #3fb950;
    --yellow: #d29922;
    --red: #f85149;
    --radius: 12px;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: var(--bg) radial-gradient(ellipse at 70% 0%, #16213a 0%, var(--bg) 55%) no-repeat fixed;
    color: var(--text);
    font: 15px/1.55 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.3px; }
h2 { font-size: 18px; font-weight: 600; margin-top: 28px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
code { background: var(--input); border: 1px solid var(--border-input); border-radius: 4px; padding: 1px 5px; font-size: 13px; }

/* Sidhuvud */
.topbar {
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
    padding: 12px 24px; border-bottom: 1px solid var(--border);
    background: rgba(11, 15, 23, 0.85); backdrop-filter: blur(6px);
    position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); font-weight: 600; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
/* Menyn: rundade flikar i en gemensam list */
.nav {
    display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0;
    padding: 4px; border-radius: 999px;
    background: rgba(22, 27, 34, 0.75); border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: var(--muted); padding: 7px 16px; border-radius: 999px; white-space: nowrap;
    font-size: 14px; font-weight: 500; transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.nav a:hover { color: var(--text-strong); background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav a.active {
    color: #fff; background: var(--accent);
    box-shadow: 0 2px 10px rgba(47, 129, 247, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.nav a:focus-visible, .pill:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.nav-sep { width: 1px; height: 20px; background: var(--border-input); margin: 0 4px; flex: none; }

/* Anvandarknappar till hoger, samma rundade form */
.user { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 14px; }
.user .who { color: var(--text-strong); margin-right: 6px; }
.pill {
    display: inline-block; padding: 6px 14px; border-radius: 999px; white-space: nowrap;
    border: 1px solid var(--border-input); background: transparent; color: var(--text);
    font: 500 13px/1.4 inherit; font-family: inherit; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.pill:hover { background: rgba(255, 255, 255, 0.06); border-color: #3d4655; text-decoration: none; color: var(--text-strong); }
.pill.active { border-color: var(--accent); color: var(--text-strong); }
.user .btn-small { border-radius: 999px; padding: 7px 16px; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }

/* Layout */
.page { max-width: 960px; margin: 0 auto; padding: 32px 16px 64px; }
.center { min-height: calc(100vh - 0px); display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.topbar + .center { min-height: calc(100vh - 58px); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); padding: 28px;
}
.card.narrow { width: 100%; max-width: 400px; padding: 36px; }
.form-card { max-width: 560px; }
.form-card.wide { max-width: 860px; }
.card.empty { text-align: center; padding: 40px; }
.card-brand img { width: 56px; height: 56px; display: block; margin-bottom: 12px; }
.back { font-size: 14px; margin-bottom: 16px; }

/* Startsida */
.hero { width: 100%; max-width: 440px; padding: 44px 40px; text-align: center; }
.hero-logo { width: 104px; height: 104px; }
.hero h1 { font-size: 32px; margin-top: 12px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.form .actions { justify-content: flex-start; }

/* Knappar */
.btn {
    display: inline-block; padding: 10px 20px; border-radius: 8px; border: 1px solid transparent;
    background: var(--accent); color: #fff; font: 600 14px/1.2 inherit; font-family: inherit; cursor: pointer;
    text-align: center; white-space: nowrap; transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface-solid); border-color: var(--border-input); color: var(--text); }
.btn-secondary:hover { background: #21262d; }
.btn-danger { background: transparent; border-color: rgba(248, 81, 73, 0.5); color: #ff7b72; }
.btn-danger:hover { background: rgba(248, 81, 73, 0.12); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin-top: 8px; }

/* Formular */
.form { display: flex; flex-direction: column; }
.form label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 16px 0 4px; cursor: pointer; }
.form input[type=text], .form input[type=password], .form input[type=email], .form input:not([type]), .form textarea {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
    background: var(--input); border: 1px solid var(--border-input); border-radius: 8px;
}
.form textarea { resize: vertical; min-height: 200px; }
.form textarea.mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: 14px; line-height: 1.5; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.25); }
.form .btn { margin-top: 20px; align-self: flex-start; }
.form .btn-block { align-self: stretch; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.input-row { display: flex; gap: 8px; }
.input-row .btn { margin-top: 0; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.hint summary { cursor: pointer; margin-top: 8px; }
.field-error { color: #ff7b72; font-size: 13px; margin-top: 4px; }
.field-error:empty { display: none; }

/* Meddelanden */
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { color: #ffa198; background: rgba(248, 81, 73, 0.1); border-color: rgba(248, 81, 73, 0.4); }
.alert-success { color: #7ee787; background: rgba(63, 185, 80, 0.1); border-color: rgba(63, 185, 80, 0.4); }
.alert-info { color: #a5d6ff; background: rgba(56, 139, 253, 0.1); border-color: rgba(56, 139, 253, 0.4); }
.validation-summary-valid { display: none; }

/* Tabeller */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn, .actions-cell form { margin-left: 4px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid; }
.badge-green { color: #7ee787; border-color: rgba(63, 185, 80, 0.5); }
.badge-yellow { color: #e3b341; border-color: rgba(210, 153, 34, 0.5); }
.badge-red { color: #ff7b72; border-color: rgba(248, 81, 73, 0.5); }
.badge-blue { color: #79c0ff; border-color: rgba(56, 139, 253, 0.5); font-size: 11px; padding: 1px 6px; vertical-align: 1px; }
.info-list { margin: 0 0 16px; padding: 0; list-style: none; }
.info-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.info-list li span { color: var(--muted); display: inline-block; min-width: 140px; }

/* Inlagg */
.post-list { display: grid; gap: 14px; }
.post-item { display: block; color: var(--text); transition: border-color 0.15s; }
.post-item:hover { border-color: #3d4655; text-decoration: none; }
.post-item h2 { margin: 0 0 4px; }
.post-item p:last-child { margin: 8px 0 0; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.article { max-width: 760px; margin: 0 auto; padding: 36px 40px; }
.article h1 { font-size: 30px; margin-bottom: 6px; }
.prose { margin-top: 24px; font-size: 16px; line-height: 1.7; }
.prose h2 { font-size: 21px; margin-top: 32px; }
.prose h3 { font-size: 17px; margin-top: 24px; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose blockquote { margin: 16px 0; padding: 4px 16px; border-left: 3px solid var(--border-input); color: var(--muted); }
.prose pre { background: var(--input); border: 1px solid var(--border-input); border-radius: 8px; padding: 12px; overflow-x: auto; }
.prose pre code { border: 0; padding: 0; background: none; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--border-input); padding: 6px 10px; }
.admin-links { margin-top: 28px; }

/* Mobil */
@media (max-width: 640px) {
    .topbar { padding: 10px 16px; gap: 10px; }
    .nav { order: 3; flex-basis: 100%; }
    .nav a { padding: 7px 13px; }
    .user { gap: 6px; font-size: 13px; }
    .pill { padding: 5px 11px; }
    .user .who { display: none; }
    .card, .card.narrow, .article { padding: 24px 20px; }
    .hero { padding: 36px 24px; }
    .page-head { flex-wrap: wrap; }
    .table th:nth-child(4), .table td:nth-child(4) { display: none; }
    .actions-cell { white-space: normal; }
    .actions-cell .btn, .actions-cell form { margin: 2px 0; }
}

/* Gallerier */
.gallery-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.gallery-card { padding: 0; overflow: hidden; color: var(--text); display: block; transition: border-color 0.15s; }
.gallery-card:hover { border-color: #3d4655; text-decoration: none; }
.gallery-cover { aspect-ratio: 4 / 3; background: var(--input); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gallery-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-cover-empty { color: var(--muted); font-size: 28px; }
.gallery-info { padding: 14px 16px; }
.gallery-info h2 { margin: 0 0 4px; font-size: 17px; }
.gallery-info .meta { margin: 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.media-tile { display: block; aspect-ratio: 1; background: var(--input); border-radius: 6px; overflow: hidden; position: relative; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s; }
.media-tile:hover img { transform: scale(1.04); }
.media-video { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 34px; color: var(--text-strong); background: linear-gradient(135deg, #1b2333, #0d1117); }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 12, 0.94); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-stage { position: absolute; inset: 0 0 52px 0; display: flex; align-items: center; justify-content: center; padding: 16px 64px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.lb-btn { position: absolute; background: rgba(22, 27, 34, 0.7); color: var(--text-strong); border: 1px solid var(--border); border-radius: 999px; width: 44px; height: 44px; font-size: 26px; line-height: 1; cursor: pointer; }
.lb-btn:hover { background: rgba(48, 54, 61, 0.9); }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }
.lb-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.lb-open { overflow: hidden; }
.admin-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.admin-media-item { background: var(--input); border: 1px solid var(--border-input); border-radius: 8px; overflow: hidden; }
.admin-media-item.is-cover { border-color: rgba(63, 185, 80, 0.7); }
.admin-media-item > a { display: block; aspect-ratio: 1; }
.admin-media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-media-name { font-size: 12px; color: var(--muted); padding: 6px 8px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-media-actions { padding: 6px 8px 8px; }
.admin-media-actions .btn { margin: 2px 2px 0 0; }
.form input[type=file] { color: var(--text); padding: 10px; background: var(--input); border: 1px dashed var(--border-input); border-radius: 8px; }
@media (max-width: 640px) {
    .media-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
    .lb-stage { padding: 8px; }
    .lb-prev, .lb-next { top: auto; bottom: 64px; transform: none; }
}

/* Grupper */
.badge-muted { color: var(--muted); border-color: var(--border-input); }
.audience { margin-left: 8px; }
.audience .badge { margin-right: 4px; }
.group-picker { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.group-picker label.check { margin: 6px 0; }
