:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --text: #2a2a2a;
  --muted: #666;
  --accent: #3a6b4a;
  --accent-dark: #2a5036;
  --border: #e5e3db;
  --error: #b83232;
  --success: #3a6b4a;
  --radius: 8px;
}

html[data-theme="dark"] {
  --bg: #17181b;
  --surface: #1f2024;
  --text: #e8e8ea;
  --muted: #9a9aa0;
  --accent: #7bbd91;
  --accent-dark: #5d9e73;
  --border: #2d2f35;
  --error: #e36d6d;
  --success: #7bbd91;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #15161a;
  color: var(--text);
}
html[data-theme="dark"] input:disabled {
  background: #2a2b30;
  color: var(--muted);
}
html[data-theme="dark"] .btn-ghost:hover {
  background: #2a2c32;
}
html[data-theme="dark"] .toast {
  background: #24262b;
  color: var(--text);
}
html[data-theme="dark"] .data-table tbody tr:hover {
  background: #23252a;
}
html[data-theme="dark"] code {
  background: #2a2c32;
}

html[data-size="large"] { font-size: 18px; }
html[data-size="xl"] { font-size: 20px; }

/* Mørk-tema overrides for pastell-farger brukt på tvers */
html[data-theme="dark"] .btn-danger:hover { background: #3a1e1e; }
html[data-theme="dark"] .badge-public,
html[data-theme="dark"] .badge-approved,
html[data-theme="dark"] .checkin-success,
html[data-theme="dark"] .stat-block.pending,
html[data-theme="dark"] .notice-success,
html[data-theme="dark"] .status-paid,
html[data-theme="dark"] .child-turlag-chip {
  background: #1e2a22;
  color: var(--accent);
}
html[data-theme="dark"] .badge-shared {
  background: #1e2534;
  color: #a0b8d0;
}
html[data-theme="dark"] .checkin-error,
html[data-theme="dark"] .flagged-row,
html[data-theme="dark"] .danger-zone {
  background: #2a1e1e;
}
html[data-theme="dark"] .danger-zone {
  border-color: #3a2626;
}
html[data-theme="dark"] .danger-action {
  border-bottom-color: #2a2222;
}
html[data-theme="dark"] .data-table tbody tr:hover,
html[data-theme="dark"] .clickable-row:hover {
  background: #242529;
}
html[data-theme="dark"] .info-panel,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .edit-banner,
html[data-theme="dark"] .alerts-panel,
html[data-theme="dark"] .alert-card {
  background: #2e2a1a;
  border-color: #4a4020;
  color: #d9c878;
}
html[data-theme="dark"] .info-panel > summary,
html[data-theme="dark"] .info-panel p,
html[data-theme="dark"] .alerts-title,
html[data-theme="dark"] .alert-count {
  color: #d9c878;
}
html[data-theme="dark"] .alert-card:hover {
  background: #3a3420;
  border-color: #6a5a28;
}
html[data-theme="dark"] .alert-label {
  color: #d9c878;
}
html[data-theme="dark"] body.system-mode .page h1 {
  color: var(--text);
}
html[data-theme="dark"] .danger-zone strong {
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 2.5rem; /* plass for fixed footer */
}

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

/* --- Topbar --- */
#topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
}
.topbar-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand {
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--text);
  padding-right: 0.5rem;
  border-right: 1px solid var(--border);
  margin-right: 0.25rem;
}
.lang-switcher,
.filter-select {
  font-size: 0.9rem;
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  color: var(--text);
  border-radius: 4px;
  font-family: inherit;
  cursor: pointer;
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* --- Layout --- */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.page {
  max-width: 52rem;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}
.page h1, .page h2 {
  font-weight: 400;
  letter-spacing: -0.02em;
}

/* --- Forms --- */
.auth-wrap {
  max-width: 26rem;
  margin: 3rem auto;
}

/* --- Login fullskjerm-kart --- */
body.login-body {
  overflow: hidden;
  padding-bottom: 0;
}
body.login-body #topbar,
body.login-body #footer {
  display: none;
}
body.login-body #app {
  max-width: none;
  margin: 0;
  padding: 0;
}
.login-map-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #cfd8dc;
}
.login-map-bg .leaflet-control-attribution {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.6);
}
.login-form-float {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 22rem;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login-form-float h1 {
  margin: 0;
  font-weight: 400;
  letter-spacing: -0.02em;
  font-size: 2rem;
}
.login-form-float p {
  margin: -0.5rem 0 0;
  font-size: 0.9rem;
}

/* Marquee-strip øverst på login */
.login-marquee {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  overflow: hidden;
  height: 140px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.25), rgba(0,0,0,0));
  pointer-events: none;
}
.login-marquee-track {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  width: max-content;
  animation: loginMarquee 200s linear infinite;
}
.login-marquee-track .marquee-item {
  flex-shrink: 0;
  width: 180px;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.login-marquee-track .marquee-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}
.login-marquee-track .marquee-caption {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.login-marquee-track .marquee-caption .muted {
  color: rgba(255,255,255,0.7);
}
@keyframes loginMarquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (max-width: 700px) {
  .login-form-float {
    top: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    transform: none;
    padding: 1.25rem;
  }
  .login-feature-card {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }
}
.auth-form, .profile-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.profile-form {
  margin-bottom: 1.5rem;
}
.profile-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.profile-side .profile-form {
  margin-bottom: 0;
}
.auth-form h1, .profile-form h2 {
  margin: 0 0 0.5rem;
  font-weight: 300;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}
input, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
input:disabled {
  background: #f0ede5;
  color: var(--muted);
}

button {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: white;
  margin-top: 0.5rem;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  text-align: center;
}
.auth-status {
  text-align: center;
  color: var(--muted);
  padding: 1rem 0;
}

/* --- Toast --- */
#toast-host {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}
.toast {
  background: var(--surface);
  border-left: 3px solid var(--muted);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  opacity: 0;
  transform: translateY(-0.5rem);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 20rem;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }

/* --- Nav --- */
.topbar-nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
  flex: 1;  /* push profile/lang switchers til høyre */
}
.topbar-nav a {
  color: var(--muted);
}
.topbar-nav a:hover {
  color: var(--text);
  text-decoration: none;
}
.topbar-logout {
  font-size: 0.9rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.topbar-logout:hover {
  color: var(--error);
}
.topbar-logout-icon {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem;
  line-height: 0;
}
.topbar-logout-icon svg {
  display: block;
}

/* Barn-modus: subtil gul linje øverst som visuell påminnelse */
body.child-mode #topbar {
  border-top: 3px solid #e6d48a;
  background: #fffdf4;
}
html[data-theme="dark"] body.child-mode #topbar {
  background: #2d2a1e;
}

/* --- Generic --- */
.muted { color: var(--muted); }
.section { margin-top: 2rem; }
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.btn-small { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.btn-danger { color: var(--error); }
.btn-danger:hover { background: #fbe5e5; }
/* Primary + danger combo: solid rød "destructive primary" */
.btn-primary.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.btn-primary.btn-danger:hover {
  background: #8a1f1f;
  border-color: #8a1f1f;
  color: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* --- Turlag list --- */
.turlag-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: grid;
  gap: 0.5rem;
}
.turlag-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.turlag-card:hover { border-color: var(--accent); text-decoration: none; }
.turlag-card-name {
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.turlag-card-meta {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
}

.role-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
  letter-spacing: 0.02em;
}
.role-admin { background: var(--accent); color: white; }

.badge-private, .badge-public {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}
.badge-public { background: #e0f0e4; color: var(--accent-dark); }

/* --- Inline/join form --- */
.inline-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 2rem;
}
.inline-form h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 500;
}
.inline-form-row {
  display: flex;
  gap: 0.5rem;
}
.inline-form-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-results {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.75rem;
}
.search-result {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.search-result:hover { border-color: var(--accent); text-decoration: none; }

/* --- Turlag detail --- */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 1.5rem 0 1.5rem;
}
.tab-link {
  padding: 0.75rem 1.25rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-link:hover { color: var(--text); text-decoration: none; }
.tab-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.edit-banner {
  background: #fff6dc;
  border: 1px solid #e6d48a;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  color: #6b5200;
  font-size: 0.9rem;
}
.edit-banner button {
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
}
.edit-banner-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.5rem;
  margin: 1rem 0;
}
.info-list dt {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.info-list dd {
  margin: 0;
}

.invitation-code-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.invitation-code-row code {
  background: var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.1em;
  font-size: 0.95rem;
}

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table tbody tr:hover { background: #f7f5ef; }

/* --- Wide page for map/grid-layouts --- */
.page-wide {
  max-width: 1200px;
}

/* Generisk to-kolonne layout som stables på smale skjermer */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
@media (max-width: 780px) {
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}

/* Grid av kort som auto-flyter (for turlag-lister o.l.) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.tab-header h2 {
  margin: 0;
  font-weight: 400;
  font-size: 1.25rem;
}

/* --- Maps --- */
.map {
  width: 100%;
  height: 400px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

/* Gjør Leaflet-markører mer synlige (skygge under + ikke for små) */
.map .leaflet-interactive {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}

/* Høyde-legend nederst i kartet */
.altitude-legend {
  background: rgba(255, 255, 255, 0.92);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: 0.75rem;
  color: var(--text);
  line-height: 1.2;
  min-width: 120px;
}
.altitude-legend-title {
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}
.altitude-legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right,
    rgb(46, 125, 50) 0%,
    rgb(239, 108, 0) 50%,
    rgb(198, 40, 40) 100%);
  margin-bottom: 0.25rem;
}
.altitude-legend-labels {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.map-picker {
  height: 500px;
  cursor: crosshair;
}

.posts-layout {
  display: grid;
  grid-template-columns: 1fr 22rem;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .posts-layout {
    grid-template-columns: 1fr;
  }
  .map { height: 300px; }
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.25rem;
  max-height: 400px;
  overflow-y: auto;
}
.post-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s;
}
.post-row:hover { border-color: var(--accent); }
.post-row.inactive { opacity: 0.55; }
.post-row-inner {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
}
.post-row-inner:hover { text-decoration: none; }
.post-row-main { margin-bottom: 0.25rem; }
.post-row-meta { font-size: 0.85rem; }

/* --- Post form layout --- */
.post-form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .post-form-layout {
    grid-template-columns: 1fr;
  }
}
.post-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.post-form h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: -0.03em;
}
.post-form textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  resize: vertical;
}
.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* --- Post row: make it a flex-row so edit link sits on the right --- */
.post-row {
  position: relative;
  display: flex;
  align-items: center;
}
.post-row-inner {
  flex: 1;
}
.post-edit-link {
  margin-right: 0.75rem;
}

/* --- Post detail layout --- */
.post-detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.post-detail-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.post-detail-col .card-title {
  margin: 0 0 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
@media (max-width: 900px) {
  .post-detail-layout {
    grid-template-columns: 1fr;
  }
  .post-detail-layout .map { height: 300px; }
}

/* --- Check-in card --- */
.checkin-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 500;
}
.checkin-status {
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.5em;
}
.checkin-status.error { color: var(--error); }
.checkin-result { min-height: 1.5em; }
.checkin-success {
  background: #e0f0e4;
  color: var(--accent-dark);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0;
}
.checkin-warning {
  background: #fff6dc;
  color: #6b5200;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0;
}
.checkin-error {
  background: #fbe5e5;
  color: var(--error);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0;
}
.countdown {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.5rem;
}
.countdown-time {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 500;
}

/* --- Info-panel (utvidbar) --- */
.info-panel {
  margin-bottom: 1.5rem;
  background: #fff6dc;
  border: 1px solid #e6d48a;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.info-panel > summary {
  cursor: pointer;
  font-weight: 500;
  color: #6b5200;
  user-select: none;
  list-style: none;
}
.info-panel > summary::-webkit-details-marker {
  display: none;
}
.info-panel[open] > summary {
  margin-bottom: 0.5rem;
}
.info-panel p {
  margin: 0.5rem 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* --- Varder grid --- */
.wallet-display {
  margin-top: 0.5rem;
  font-size: 1.1rem;
}
.wallet-total {
  font-size: 1.5rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.varde-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.varde-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.varde-card.archived {
  opacity: 0.65;
}
.varde-card.has-image {
  background-size: cover;
  background-position: center;
  background-color: var(--surface); /* fallback under image */
  overflow: hidden;
}
.varde-card.has-image .varde-card-header h3 {
  background: rgba(255,255,255,0.94);
  color: var(--text);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  display: inline-block;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.varde-card.has-image .stat-block {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.varde-card.has-image .btn-ghost {
  background: rgba(255,255,255,0.94);
  border-color: rgba(0,0,0,0.08);
  color: var(--text);
}
.varde-card.has-image .btn-ghost:hover {
  background: #fff;
  color: var(--accent);
}
.varde-card.has-image .upgrade-section {
  background: rgba(255,255,255,0.94);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  border-top: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.varde-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.varde-card-header h3 {
  margin: 0;
  font-weight: 500;
  font-size: 1.1rem;
}

.badge-archived, .badge-full, .badge-shared {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--border);
  margin-left: 0.4rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.badge-full {
  background: #fff6dc;
  color: #6b5200;
}
.badge-shared {
  background: #e0ecf5;
  color: #2a4d7a;
}

.varde-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.stat-block {
  background: var(--bg);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
}
.stat-block.pending {
  background: #e0f0e4;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 1rem;
}

.upgrade-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.upgrade-meta {
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.upgrade-short {
  color: var(--error);
  font-weight: 500;
}
.upgrade-cost {
  opacity: 0.7;
}

/* --- Modal (season form) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: grid;
  place-items: center;
  z-index: 500;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 32rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.modal h2 {
  margin: 0 0 0.5rem;
  font-weight: 300;
  font-size: 1.5rem;
}

/* --- Seasons --- */
.section-title {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 2rem 0 0.75rem;
  font-weight: 500;
}
.section-title:first-of-type { margin-top: 0.5rem; }
.season-card {
  margin-bottom: 0.75rem;
}
.season-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.season-card-header h4 {
  margin: 0;
  font-weight: 500;
  font-size: 1.1rem;
}

/* --- Leaderboard --- */
.leaderboard-meta {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.filter-bar label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.filter-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* --- Gruppe-pills --- */
.group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.group-pill {
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.group-pill:hover {
  border-color: var(--accent);
  color: var(--text);
}
.group-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.group-admin-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
  display: grid;
  gap: 0.5rem;
}
.group-admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.modal-wide {
  max-width: 40rem;
}
.notice {
  background: #fff6dc;
  border-left: 3px solid #e6d48a;
  padding: 0.75rem 1rem;
  color: #6b5200;
  font-size: 0.9rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}
.leaderboard-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.leaderboard-table tr.is-self {
  background: #e0f0e4;
}
.leaderboard-table tr.is-self:hover {
  background: #d0e6d6;
}
.rank-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  width: 3rem;
}
.self-badge {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.85rem;
}
.completed-badge {
  color: var(--accent);
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* --- Profile switcher --- */
.profile-switcher {
  font-size: 0.9rem;
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border-radius: 4px;
  font-family: inherit;
  margin-left: 0.5rem;
  max-width: 10rem;
}
.profile-switcher.active {
  background: #fff6dc;
  border-color: #e6d48a;
  color: #6b5200;
  font-weight: 500;
}

/* --- Network page --- */
.conn-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.5rem;
}
.conn-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.conn-row .role-badge {
  margin-left: 0.5rem;
}
.conn-actions {
  display: flex;
  gap: 0.5rem;
}

/* --- Share modal --- */
.share-form {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.share-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}
.share-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 0.5rem;
}
.status-active { color: var(--success); font-size: 0.85rem; }
.status-expired, .status-revoked { color: var(--muted); font-size: 0.85rem; }

/* --- Subscription --- */
.tier-display {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tier-badge {
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.tier-pro {
  background: var(--accent);
  color: white;
}
.tier-free {
  background: var(--border);
  color: var(--text);
}

.upgrade-card .feature-list {
  margin: 0.5rem 0 1.5rem;
  padding-left: 1.5rem;
  color: var(--text);
}
.upgrade-card .feature-list li {
  margin-bottom: 0.25rem;
}

/* --- Tier-kort --- */
.tier-card {
  padding: 1.75rem 1.5rem;
}
.tier-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.tier-card-title {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.tier-price {
  font-weight: 500;
  color: var(--text);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.status-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.status-paid {
  background: #e0f0e4;
  color: var(--accent-dark);
}
.status-manual {
  background: #fff6dc;
  color: #6b5200;
}
.tier-details {
  margin: 1rem 0 1.25rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.feature-heading {
  margin: 1.25rem 0 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Features med ✓-ikon i stedet for bullet */
.feature-list-check {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}
.feature-list-check li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.5rem;
  color: var(--text);
}
.feature-list-check li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

.pay-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.pay-button-disabled {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.pay-button-disabled button {
  opacity: 0.5;
  cursor: not-allowed;
}

.notice-success {
  background: #e0f0e4;
  border-left-color: var(--success);
  color: var(--accent-dark);
}

/* --- System admin (egen visuell identitet) --- */
.system-link {
  color: #c4a000 !important;
  font-weight: 500;
}
body.system-mode #topbar {
  background: #1f1f2e;
  border-bottom-color: #3a3a4e;
}

.impersonate-banner {
  background: #c62828;
  color: #fff;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 200;
}
.impersonate-banner .btn-ghost {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  margin-top: 0;
}
.impersonate-banner .btn-ghost:hover {
  background: rgba(255,255,255,0.35);
}
body.impersonating {
  outline: 3px solid #c62828;
  outline-offset: -3px;
}

.clickable-row {
  cursor: pointer;
}
.clickable-row:hover {
  background: #f7f5ef;
}
.contrib-group {
  margin-bottom: 1.5rem;
}
.contrib-group-title {
  margin: 0.75rem 0 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}
.audit-metadata {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: monospace;
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 0;
}
.audit-metadata.expanded {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  text-overflow: clip;
}

.alerts-panel {
  background: #fff6dc;
  border: 1px solid #e6d48a;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.alerts-title {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b5200;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}
.alert-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #e6d48a;
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.alert-card:hover {
  border-color: #c28500;
  background: #fffaee;
  text-decoration: none;
}
.alert-count {
  font-size: 1.5rem;
  font-weight: 500;
  color: #c28500;
  min-width: 2rem;
  text-align: center;
}
.alert-label {
  font-size: 0.85rem;
  flex: 1;
}

.connect-code-card .connect-code-display {
  margin: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.25rem;
}
.connect-code-value {
  background: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.connect-code-timer {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.clickable-link {
  color: var(--accent);
  cursor: pointer;
}
.clickable-link:hover {
  text-decoration: underline;
}

.activity-feed {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1.5rem;
  display: grid;
  gap: 0.25rem;
}
.activity-item {
  display: grid;
  grid-template-columns: 11rem 1fr auto;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-left: 3px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  align-items: baseline;
}
.activity-item.flagged {
  border-left-color: var(--error);
  background: #fdf7f7;
}
.activity-item.activity-user_created {
  border-left-color: var(--accent);
}
.activity-item.activity-org_created {
  border-left-color: #c4a000;
}

/* Audit-feed: fargede venstrekanter etter action-kategori */
.audit-item .audit-actor {
  font-weight: 500;
}
.audit-item .audit-action {
  font-family: monospace;
  font-size: 0.78rem;
  background: var(--bg);
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
}
.audit-item .audit-entity {
  font-size: 0.85rem;
}
.audit-item.audit-system { border-left-color: #c4a000; }
.audit-item.audit-org { border-left-color: var(--accent); }
.audit-item.audit-turlag { border-left-color: var(--accent); }
.audit-item.audit-post { border-left-color: #2a6fb8; }
.audit-item.audit-checkin { border-left-color: #2a6fb8; }
.audit-item.audit-varde { border-left-color: #b07c2d; }
.audit-item.audit-auth { border-left-color: #7a3f9a; }
.audit-item.audit-user { border-left-color: var(--muted); }
.audit-imp {
  background: #fbe5e5;
  color: var(--error);
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  margin-left: 0.4rem;
}
html[data-theme="dark"] .audit-imp {
  background: #3a1e1e;
}
.activity-ts {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-family: monospace;
}
.activity-title {
  font-weight: 500;
}
.activity-sub {
  font-size: 0.75rem;
}

.orphan-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
}
.orphan-list li {
  padding: 0.2rem 0;
}
body.system-mode #topbar .brand,
body.system-mode #topbar .topbar-nav a {
  color: #e8e8ee;
}
body.system-mode #topbar .topbar-nav a:hover {
  color: #ffd700;
}
body.system-mode .page h1 {
  color: #1f1f2e;
}

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

.stats-combo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}
.stat-combo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.stat-combo-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}
.stat-combo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.9rem;
}
.stat-combo-item strong {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-right: 0.25rem;
}
@media (max-width: 780px) {
  .stats-combo {
    grid-template-columns: 1fr;
  }
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: left;
}
.stat-card-value {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-card-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
}
.action-stack button { font-size: 0.75rem; padding: 0.2rem 0.5rem; }

.badge-pending_approval {
  background: #fff6dc;
  color: #6b5200;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge-approved {
  background: #e0f0e4;
  color: var(--accent-dark);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge-private_only {
  background: var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* --- Footer (fixed nederst på skjerm) --- */
#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
  padding: 0.5rem 1.5rem;
  background: var(--surface);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
  align-items: center;
}
.footer-inner a {
  color: var(--muted);
}
.footer-inner a:hover {
  color: var(--text);
  text-decoration: none;
}

/* --- GDPR section --- */
.gdpr-action {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
}
.gdpr-action > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}
.gdpr-action > div > button {
  align-self: flex-start;
}
.profile-form hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

/* --- Radius input with live display --- */
.radius-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.radius-row input {
  flex: 1;
}
.radius-display {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--accent);
  min-width: 4.5rem;
  text-align: right;
}

/* --- Danger zone (arkiv/forlat-seksjon på oversikt) --- */
.danger-zone {
  margin-top: 3rem;
  padding: 1.25rem;
  border: 1px solid #e8cfcf;
  border-radius: var(--radius);
  background: #fdf7f7;
}
.danger-zone-title {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--error);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.danger-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0e4e4;
}
.danger-action:last-child { border-bottom: none; }
.danger-action > div:first-child {
  flex: 1;
}
.danger-action strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.danger-action .muted {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Publiser turlag (offentlig/privat) */
.publish-section {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.publish-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.publish-row > div:first-child { flex: 1; min-width: 0; }
.publish-row strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.publish-row .muted {
  font-size: 0.85rem;
  line-height: 1.4;
}
.badge-pending {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  background: #fff6dc;
  color: #5b4a00;
}
html[data-theme="dark"] .badge-pending {
  background: #3a3220;
  color: #f0e5c0;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.pagination .disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.page-indicator {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.flagged-row {
  background: #fdf7f7;
}

/* Skjermleser-only */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Barn: Turlag-modal --- */
.turlag-modal-list {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0.75rem;
  display: grid;
  gap: 0.4rem;
}
.turlag-modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.turlag-modal-row .btn-primary,
.turlag-modal-row .btn-ghost {
  margin-top: 0;
  flex-shrink: 0;
}

/* --- Quick check-in (/innsjekk) --- */
.quick-checkin-section {
  margin-bottom: 2.5rem;
}
.quick-checkin-heading {
  margin: 0 0 0.75rem;
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.checkin-gps-status,
.checkin-gps-meta {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}
.checkin-gps-error {
  background: #fbe5e5;
  color: var(--error);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 0.75rem;
}
.checkin-map {
  height: 260px;
  margin-bottom: 1rem;
}
.checkin-quick-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.5rem;
}
.checkin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.checkin-row.in-range {
  border-color: var(--accent);
  background: #f3f8f4;
}
html[data-theme="dark"] .checkin-row.in-range {
  background: #1e2a22;
}
.checkin-row-main {
  flex: 1;
  min-width: 0;
}
.checkin-row-name {
  font-weight: 500;
  margin-bottom: 0.15rem;
}
.checkin-row-meta {
  font-size: 0.85rem;
}
.checkin-row-result {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  min-height: 0;
}
.checkin-row-result:empty { display: none; }
.checkin-row-action {
  flex-shrink: 0;
}
.checkin-row-action button {
  white-space: nowrap;
  margin-top: 0;
}
.checkin-history-meta {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.recent-checkins-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
  display: grid;
  gap: 0.35rem;
}
.recent-checkins-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* User-marker (blå dott) */
.user-location-marker {
  background: #2a6fb8;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  width: 16px;
  height: 16px;
}

/* Post-markør: ✓ for besøkt, ? for ubesøkt. Farget bakgrunn = høyde. */
.post-map-marker {
  background: transparent;
  border: none;
}
.post-map-marker > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
.post-map-marker-visited > span {
  font-size: 16px;
}

@media (max-width: 600px) {
  .checkin-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .checkin-row-action button {
    width: 100%;
  }
}

/* --- Post-bilder (frimerke-komprimert) --- */
.post-image-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 0.5rem 0;
}
.post-image-section > label {
  font-size: 0.85rem;
  color: var(--muted);
}
.post-image-preview {
  max-width: 128px;
  max-height: 128px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--bg);
  display: block;
}
.post-image-dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}
.post-image-dropzone:hover,
.post-image-dropzone:focus-visible {
  border-color: var(--accent);
}
.post-image-dropzone.dragover {
  border-color: var(--accent);
  background: #e0f0e4;
}
.post-image-drop-prompt {
  font-size: 0.9rem;
  text-align: center;
  pointer-events: none;
}
.post-image-file-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.post-image-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Thumbnail i post-lister */
.post-row-thumb,
.checkin-row-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
}
.checkin-row-thumb {
  margin-right: 0.75rem;
}
.post-row-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.post-row-content {
  flex: 1;
  min-width: 0;
}

/* Post-detail: bidrag (når posten mangler bilde) */
.contribution-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.contribution-card .card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}
.contrib-upload {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.contrib-preview {
  max-width: 128px;
  max-height: 128px;
  border-radius: var(--radius);
  object-fit: cover;
  display: block;
  margin: 0 auto;
}
.contrib-disclaimer {
  font-size: 0.8rem;
  line-height: 1.4;
}
.contrib-admin-title {
  margin: 0.5rem 0 0.25rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.contrib-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}
.contrib-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.contrib-row-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: zoom-in;
  transition: transform 0.12s;
}
.contrib-row-thumb:hover {
  transform: scale(1.05);
}
.contrib-row-meta {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
}
.contrib-credit {
  font-size: 0.8rem;
}
.contrib-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Lightbox for bilde-forhåndsvisning */
.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: grid;
  place-items: center;
  z-index: 1100;
  padding: 2rem;
  cursor: zoom-out;
}
.image-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  width: 52px;
  height: 52px;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: background 0.15s;
  display: grid;
  place-items: center;
  margin-top: 0;
}
.lightbox-nav:hover {
  background: rgba(0,0,0,0.85);
}
.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }
.lightbox-counter {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
@media (max-width: 600px) {
  .lightbox-prev { left: 0.5rem; }
  .lightbox-next { right: 0.5rem; }
  .lightbox-nav { width: 44px; height: 44px; }
}
.contrib-row-actions .btn-primary,
.contrib-row-actions .btn-ghost {
  margin-top: 0;
}

/* Post-detail: stort bilde */
.post-image-card {
  padding: 0;
  overflow: hidden;
}
.post-detail-image {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}
.post-image-notice {
  margin: 0;
  border-radius: 0;
  font-size: 0.8rem;
}
.post-image-credit {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-style: italic;
  border-top: 1px solid var(--border);
}

.post-detail-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.post-detail-subheader {
  margin-top: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.post-detail-subheader h1 {
  font-size: 1.4rem;
  margin: 0;
}

/* Oversikts-kart på turlag-detail overview-tab */
.overview-map {
  height: 320px;
  margin-bottom: 1.25rem;
}

/* Kart over offentlige turlag på /turlag */
.turlag-discover-map {
  height: 460px;
  margin: 0.5rem 0 1.5rem;
}
@media (max-width: 700px) {
  .turlag-discover-map { height: 340px; }
}

.turlag-mine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.turlag-mine-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.1s;
}
.turlag-mine-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.turlag-mine-card-primary {
  border-color: var(--primary);
  background: var(--primary-bg, var(--surface));
}
.turlag-mine-card .muted {
  font-size: 0.8rem;
  text-transform: capitalize;
}

.turlag-description {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.turlag-description-edit {
  margin-bottom: 1.25rem;
}
.turlag-description-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  resize: vertical;
}

.radius-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.radius-input-small {
  width: 4rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.9rem;
}

/* Karusell av område-bilder */
.org-carousel-wrap {
  margin-bottom: 1.5rem;
}
.org-carousel {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  cursor: grab;
  user-select: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: auto;
}
.org-carousel::-webkit-scrollbar {
  display: none;
}
.org-carousel.dragging {
  cursor: grabbing;
}
.org-carousel-thumb {
  height: 180px;
  width: auto;
  flex-shrink: 0;
  border-radius: var(--radius);
  cursor: zoom-in;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
  user-select: none;
  -webkit-user-drag: none;
}

/* Bilde-redigering (admin+edit-mode) */
.org-image-manager {
  margin-bottom: 1.5rem;
}
.org-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.org-image-tile {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.org-image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}
.org-image-delete {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}
.org-image-delete:hover {
  background: var(--error);
}

/* Turlag-header: dropdown + handlinger */
.turlag-page-header {
  flex-wrap: wrap;
  gap: 1rem;
}
.turlag-header-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.turlag-switcher {
  font-size: 1.25rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  color: var(--text);
  max-width: 100%;
}
.turlag-switcher:focus {
  outline: none;
  border-color: var(--accent);
}
.turlag-status-pill {
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  background: var(--bg);
  border-radius: 999px;
}
.turlag-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.turlag-header-actions .btn-primary,
.turlag-header-actions .btn-ghost {
  margin-top: 0;
}

/* Leaflet-popup for poster — med thumbnail */
.post-popup {
  min-width: 140px;
  text-align: center;
}
.post-popup .post-popup-thumb {
  display: block;
  width: 100%;
  max-width: 180px;
  max-height: 140px;
  object-fit: cover;
  border-radius: 4px;
  margin: 0 auto 0.35rem;
}
.post-popup .popup-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.post-popup .popup-post-link {
  display: block;
  color: var(--accent);
  text-decoration: none;
}
.post-popup .popup-post-link:hover {
  text-decoration: underline;
}
.post-popup .popup-thumb-link {
  display: block;
}

/* --- Burger / mobile drawer --- */
.burger-btn {
  display: none;
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}
.burger-icon,
.burger-icon::before,
.burger-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.burger-icon {
  position: relative;
}
.burger-icon::before,
.burger-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.burger-icon::before { top: -7px; }
.burger-icon::after  { top: 7px; }

body.menu-open .burger-icon {
  background: transparent;
}
body.menu-open .burger-icon::before {
  transform: translateY(7px) rotate(45deg);
}
body.menu-open .burger-icon::after {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-drawer {
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem 1rem;
  box-shadow: 0 6px 12px rgba(0,0,0,0.06);
}
.mobile-drawer a,
.mobile-drawer button {
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  border-radius: 0;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
}
.mobile-drawer a:last-child,
.mobile-drawer button:last-child {
  border-bottom: none;
}
.mobile-drawer a:hover { text-decoration: none; color: var(--accent); }

body.menu-open .mobile-drawer {
  display: flex;
}

@media (max-width: 780px) {
  .topbar-nav {
    display: none;
  }
  .burger-btn {
    display: inline-flex;
    margin-left: auto;
  }
  .profile-switcher {
    max-width: 8rem;
  }
  .brand {
    padding-right: 0;
    border-right: none;
  }
  #topbar {
    padding: 0 1rem;
  }
  .topbar-inner {
    gap: 0.75rem;
  }
}
