/* Fælles komponenter: reset, topbar, bundnavigation, knapper, felter, ark, toast, FAB. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent; overflow-x: hidden; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
a { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

svg.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- skal ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 6px) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  min-height: calc(56px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 1.25rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }
.content { padding: 8px max(16px, env(safe-area-inset-right)) calc(var(--nav-h) + env(safe-area-inset-bottom) + 96px) max(16px, env(safe-area-inset-left)); max-width: 720px; margin: 0 auto; }
.content.no-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 32px); }

.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: none; border: 0; border-radius: 50%; color: var(--text); text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.bottomnav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.bottomnav a[aria-current="page"] { color: var(--accent); }
.bottomnav a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
.badge-dot { position: absolute; top: 6px; margin-left: 22px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-contrast); font-size: .7rem; line-height: 18px; text-align: center; }

.fab {
  position: fixed; z-index: 25; right: max(16px, env(safe-area-inset-right)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  width: 58px; height: 58px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg);
}
.fab:active { transform: scale(.95); }
.fab svg.ic { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---- knapper og felter ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:active { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:active { background: var(--accent-strong); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-ghost { background: none; border-color: transparent; color: var(--accent-strong); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: 0 0 5px 2px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 16px; /* 16px = ingen zoom ved fokus på iOS */ appearance: none; -webkit-appearance: none;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.hint { font-size: .85rem; color: var(--muted); margin: 4px 2px 0; }
.err { color: var(--danger); font-size: .9rem; margin: 8px 2px; min-height: 1.2em; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.chip[aria-pressed="true"], .chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.empty .big { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.3s infinite linear; border-radius: var(--radius); min-height: 72px; margin: 10px 0; }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- ark (bund) ---- */
body.sheet-open { overflow: hidden; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10, 16, 12, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.sheet {
  width: 100%; max-width: 600px; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 10px max(16px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  animation: rise .22s ease-out; box-shadow: var(--shadow-lg);
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 10px; }
.sheet h2 { font-size: 1.2rem; margin: 4px 2px 14px; }
@keyframes rise { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

/* ---- toast og forbindelsesbanner ---- */
.toasts { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; padding: 12px 16px; border-radius: 14px; background: #202824; color: #f2f6f3; box-shadow: var(--shadow-lg); animation: rise .2s ease-out; font-size: .95rem; }
.toast.error { background: #8a2f20; }
.toast button { background: none; border: 0; color: #9fe0b2; font-weight: 700; padding: 8px 4px; min-height: 36px; }
.netbanner { position: fixed; z-index: 90; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 6px) 12px 6px; text-align: center; background: var(--warn-soft); color: var(--warn); font-size: .9rem; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; } }
