:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --card: #151f36;
  --card-2: #1b2742;
  --line: #26344f;
  --text: #e8eef9;
  --muted: #8c9ab4;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --danger: #ef4444;
  --ok: #22c55e;
  --gold: #fbbf24;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -200px, rgba(59, 130, 246, 0.18), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + var(--safe-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
@keyframes pulse { 50% { opacity: .45; box-shadow: 0 0 4px 1px var(--accent-glow); } }

.profile-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px 4px 4px; max-width: 50%;
}
.profile-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }

.install-btn {
  background: var(--accent); border: 0; color: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 600;
}

/* ---------- faner ---------- */
.tabs { display: flex; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 16px 0; }
.tab { flex: 1; background: none; border: 0; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tab[aria-selected="true"] { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }
.tab .count { font-size: 12px; background: var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 6px; }

/* ---------- eventkort ---------- */
.grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0;
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { border-color: #344566; }
.card:active { transform: scale(.99); }
.card-img { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; background: var(--card-2); }
.card-img.placeholder { display: grid; place-items: center; color: var(--muted); background: linear-gradient(135deg, #17233d, #0f182b); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 18px; line-height: 1.25; }
.meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.meta svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.desc { color: #c3cde0; font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.card-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 6px; }
.agency-stack { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.agency-count { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: var(--muted); }
.past-badge { font-size: 12px; font-weight: 700; color: var(--ok); background: rgba(34, 197, 94, .12); border-radius: 999px; padding: 2px 8px; }
.card.past .card-img { filter: grayscale(.55) brightness(.8); }

/* ---------- knapper ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 12px; padding: 10px 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2f74e6; }
.btn-ok { background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .5); color: #86efac; }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, .5); color: #fca5a5; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- etatsikoner ---------- */
.agency-badge {
  --size: 28px;
  width: var(--size); height: var(--size); border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  background: var(--a-bg); color: var(--a-fg);
  font-weight: 800; font-size: calc(var(--size) * .34); letter-spacing: -.3px;
}
.agency-badge svg { width: 58%; height: 58%; }
.agency-badge.sm { --size: 22px; }
.agency-badge.lg { --size: 52px; }

.agency-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.agency-option {
  background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  padding: 14px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: border-color .15s, background .15s, color .15s;
}
.agency-option[aria-checked="true"] { border-color: var(--accent); background: rgba(59, 130, 246, .12); color: var(--text); box-shadow: 0 0 0 4px var(--accent-glow); }

/* ---------- skjema ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.input, textarea.input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: var(--text); font-weight: 400; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea.input { resize: vertical; min-height: 96px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }

.image-drop {
  border: 2px dashed var(--line); border-radius: 14px; aspect-ratio: 16 / 9; overflow: hidden;
  display: grid; place-items: center; color: var(--muted); position: relative; background: var(--bg-2); text-align: center; padding: 0;
}
.image-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.image-drop .hint { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; padding: 12px; }

/* ---------- onboarding ---------- */
.onboard { max-width: 480px; margin: 0 auto; padding: calc(40px + var(--safe-top)) 16px 40px; }
.onboard h1 { font-size: 30px; line-height: 1.15; margin: 18px 0 8px; }
.onboard p.lead { color: var(--muted); margin: 0 0 28px; }
.hero-logo { width: 180px; height: 180px; margin: 0 auto; filter: drop-shadow(0 10px 30px rgba(59, 130, 246, .25)); }
.onboard h1 { text-align: center; }
.onboard p.lead { text-align: center; }
.room-hero { text-align: center; padding: 28px 0 4px; }
.room-hero h1 { font-size: 28px; line-height: 1.15; margin: 16px 0 6px; }
.room-hero .lead { color: var(--muted); margin: 0; }
@media (max-width: 480px) { .room-hero .hero-logo { width: 140px; height: 140px; } .room-hero h1 { font-size: 24px; } }
.hero-lights { display: flex; gap: 8px; }
.hero-lights i { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px 4px var(--accent-glow); animation: pulse 1.2s infinite; }
.hero-lights i:nth-child(2) { animation-delay: .6s; }

/* ---------- tom tilstand ---------- */
.empty { text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty svg { width: 40px; height: 40px; margin-bottom: 8px; opacity: .6; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(3, 7, 15, .7);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 24px; } }
.modal {
  background: var(--bg-2); border: 1px solid var(--line); width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0;
  padding: 0 0 calc(20px + var(--safe-bottom)); animation: up .2s ease;
}
@media (min-width: 640px) { .modal { border-radius: 20px; } }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.icon-btn { background: none; border: 0; color: var(--muted); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--card); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.modal-hero { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px; }
.full-desc { white-space: pre-line; color: #c3cde0; margin: 0; overflow-wrap: anywhere; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 0 -4px; font-weight: 700; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 8px 12px; }
.people .muted { color: var(--muted); font-size: 13px; margin-left: auto; }

/* ---------- terningkast ---------- */
.dice-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.die-btn { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 8px; aspect-ratio: 1; display: grid; place-items: center; color: var(--text); }
.die-btn svg { width: 100%; height: 100%; max-width: 40px; }
.die-btn[aria-checked="true"] { border-color: var(--gold); background: rgba(251, 191, 36, .12); color: var(--gold); }
.die-inline { width: 20px; height: 20px; color: var(--gold); flex: none; }
.rating-summary { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 12px 16px; }
.rating-summary .big { font-size: 32px; font-weight: 800; color: var(--gold); line-height: 1; }
.rating-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--gold); font-size: 14px; }
.review { background: var(--card); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.review-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.review-head .when { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: auto; }
.review p { margin: 0; color: #c3cde0; font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- PIN ---------- */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; width: 100%; }
.pinpad button { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 0; font-size: 22px; font-weight: 600; }
.pinpad button:active { background: var(--card-2); }
.pin-error { color: #fca5a5; text-align: center; min-height: 1.5em; font-size: 14px; margin: 0; }

/* ---------- admin ---------- */
.gear {
  position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + var(--safe-bottom)); z-index: 20;
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--muted);
  opacity: .28; display: grid; place-items: center; transition: opacity .2s;
}
.gear:hover, .gear:focus-visible { opacity: .9; }
.gear svg { width: 18px; height: 18px; }
.admin-bar { display: flex; align-items: center; gap: 10px; background: rgba(59, 130, 246, .1); border: 1px solid rgba(59, 130, 246, .35); border-radius: 14px; padding: 10px 12px; margin-top: 16px; font-size: 14px; flex-wrap: wrap; }
.admin-bar strong { margin-right: auto; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-item { display: flex; flex-direction: column; gap: 8px; background: var(--card); border-radius: 12px; padding: 10px; }
.admin-item-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.admin-item img, .admin-item .thumb { width: 56px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--card-2); flex: none; }
.admin-item .t { flex: 1; min-width: 0; }
.admin-item .t div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item .t small { color: var(--muted); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: rgba(239, 68, 68, .6); }

.ios-hint { font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 16px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- NB: endret tidspunkt ---------- */
.nb {
  display: flex; gap: 8px; align-items: flex-start;
  background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .45); color: #fde68a;
  border-radius: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.35;
}
.nb svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--gold); }
.nb strong { color: var(--gold); margin-right: 4px; }

/* ---------- bjelle ---------- */
.bell { color: var(--muted); }
.bell.on { color: var(--gold); }
.admin-item .btn-danger { padding: 6px 10px; }

/* ---------- kalender ---------- */
.calendar-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: -8px; }
.calendar-choices .btn { text-decoration: none; font-size: 14px; text-align: center; }
@media (max-width: 420px) { .calendar-choices { grid-template-columns: 1fr; } }

.privacy-note { display: flex; gap: 8px; align-items: flex-start; margin: -4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.privacy-note svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
