/* ============ Önskelistan ============ */
:root {
  --bg: #f4f1ec;
  --bg2: #e9e4dc;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --primary: #2d3b4e;
  --primary-ink: #ffffff;
  --accent: #b8860b;
  --ok: #1f7a4a;
  --danger: #b3261e;
  --border: #ddd6cb;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .07);
  --topbar: #2d3b4e;
  --topbar-ink: #fff;
  --heading-font: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

/* ---------- Jultema ---------- */
.theme-jul {
  --bg: #fbf6ef;
  --bg2: #f3e9dc;
  --primary: #a3162b;
  --primary-ink: #fff;
  --accent: #c9972b;
  --ok: #19643d;
  --border: #ead9c4;
  --topbar: #7a0f1c;
  --topbar-ink: #fff8ec;
}
.theme-jul body, body.theme-jul {
  background:
    radial-gradient(circle at 10% 0%, rgba(25, 100, 61, .08), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(163, 22, 43, .07), transparent 40%),
    var(--bg);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 { font-family: var(--heading-font); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; margin-top: 1.5rem; }
.card h2:first-child { margin-top: 0; }
h3 { font-size: 1.1rem; }
a { color: var(--primary); }
code { background: var(--bg2); padding: .1em .35em; border-radius: 6px; font-size: .95em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.block { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* ---------- Toppfält ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: .6rem max(1rem, env(safe-area-inset-right)) .6rem max(1rem, env(safe-area-inset-left));
  background: var(--topbar); color: var(--topbar-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none;
  font-family: var(--heading-font); font-size: 1.35rem; font-weight: 700; letter-spacing: .3px; }
.brand-icon { font-size: 1.5rem; }
.menu-toggle { display: none; background: none; border: 0; padding: .6rem; cursor: pointer; color: inherit; }
.burger, .burger::before, .burger::after {
  display: block; width: 24px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: "";
  transition: transform .2s;
}
.burger::before { position: absolute; top: -7px; }
.burger::after { position: absolute; top: 7px; }
.menu-toggle[aria-expanded="true"] .burger { background: transparent; }
.menu-toggle[aria-expanded="true"] .burger::before { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .burger::after { transform: translateY(-7px) rotate(-45deg); }
.mainnav { display: flex; align-items: center; gap: .25rem; }
.mainnav a, .mainnav .linklike {
  color: var(--topbar-ink); text-decoration: none; padding: .5rem .75rem; border-radius: 10px; font-size: .95rem;
}
.mainnav a.active, .mainnav a:hover, .mainnav .linklike:hover { background: rgba(255, 255, 255, .16); }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

/* Girlang under toppfältet */
.garland {
  height: 14px;
  background:
    radial-gradient(circle at 10px 4px, #f2c94c 3px, transparent 4px) 0 0 / 60px 14px,
    radial-gradient(circle at 30px 8px, #e8435a 3px, transparent 4px) 0 0 / 60px 14px,
    radial-gradient(circle at 50px 4px, #4cc38a 3px, transparent 4px) 0 0 / 60px 14px,
    linear-gradient(#1d5a37, #1d5a37) 0 5px / 100% 2px no-repeat;
  position: sticky; top: 58px; z-index: 19; pointer-events: none;
  animation: twinkle 2.4s steps(2) infinite;
}
@keyframes twinkle { 50% { filter: brightness(1.35) saturate(1.2); } }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 3rem; flex: 1; position: relative; z-index: 1; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom)); }
.page-title { margin-top: .25rem; }
.card {
  display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); color: inherit;
}
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.center-card { text-align: center; }
.center-card form { text-align: left; }
.hero-icon { font-size: 3rem; line-height: 1; margin: .25rem 0 .5rem; }
.back { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-weight: 600; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Formulär ---------- */
.stack { display: grid; gap: .9rem; margin: 1rem 0; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
input, select, textarea {
  font: inherit; font-size: 16px; /* undviker zoom i iOS */
  width: 100%; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px; border-color: var(--primary);
}
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
label.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Knappar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 46px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .05s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.07); }
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-secondary { background: var(--bg2); color: var(--text); border-color: var(--border); }
.btn-danger { background: #fff; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, #fff); }
.btn-buy { background: var(--ok); color: #fff; white-space: nowrap; }

/* ---------- Meddelanden ---------- */
.flash { padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500; border: 1px solid; }
.flash-success { background: #e8f5ee; border-color: #b6dcc6; color: #134d2e; }
.flash-error { background: #fdecea; border-color: #f2b8b5; color: #7d1a14; }

/* ---------- Startsida ---------- */
.mine-card, .person { display: flex; align-items: center; gap: .9rem; text-decoration: none; }
.mine-card { border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border)); }
.mine-icon { font-size: 1.8rem; }
.chev { margin-left: auto; font-size: 1.6rem; color: var(--muted); }
.people { list-style: none; padding: 0; margin: 0; }
.person-info { display: grid; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 1.15rem;
}
.theme-jul .people li:nth-child(even) .avatar { background: var(--ok); }
.badge { display: inline-flex; align-items: center; padding: .25rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.badge-done { background: #e3f3ea; color: var(--ok); }

/* ---------- Önskningar ---------- */
.items { list-style: none; padding: 0; margin: 1rem 0 0; }
.item { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.item-main { min-width: 0; flex: 1; }
.item-title { margin: 0 0 .25rem; overflow-wrap: anywhere; }
.price { display: inline-block; background: var(--bg2); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem; font-weight: 600; }
.note { margin: .4rem 0 0; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.item-link { display: inline-block; margin-top: .5rem; font-weight: 600; text-decoration: none; }
.item-actions { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; flex: none; }
.item-actions form { margin: 0; }
.item-actions .btn { width: 100%; }
.item-fav { border-left: 5px solid var(--accent); }
.item-bought { background: #f3f6f4; opacity: .85; }
.item-bought .item-title { text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .35); }
.bought-by { margin: .5rem 0 0; font-weight: 600; color: var(--ok); }
.add-card { padding: .75rem; }
.add-card > summary { list-style: none; }
.add-card > summary::-webkit-details-marker { display: none; }
.add-card[open] > summary { margin-bottom: .25rem; filter: saturate(.8); }

/* ---------- MFA ---------- */
.steps { padding-left: 1.2rem; display: grid; gap: 1.2rem; }
.steps li > strong { display: block; margin-bottom: .5rem; }
.qr { display: flex; justify-content: center; margin: .75rem 0; }
.qr svg { width: 220px; height: auto; max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.manual { margin-top: .75rem; }
.manual summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.secret { font-size: 1.05rem; letter-spacing: .05em; word-break: break-all; display: inline-block; padding: .4rem .6rem; }

/* ---------- Admin ---------- */
.new-link { border: 2px solid var(--ok); }
.link-output { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; margin: .5rem 0 .75rem; }
.admin-users, .invites { list-style: none; padding: 0; margin: 0; }
.admin-user, .invites li { padding: .9rem 0; border-top: 1px solid var(--border); }
.admin-user:first-child, .invites li:first-child { border-top: 0; }
.admin-user-head { display: flex; gap: .8rem; align-items: flex-start; }
.admin-user.inactive { opacity: .6; }
.invites li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.tags { display: inline-flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0; }
.tag { font-size: .75rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: var(--bg2); }
.tag-admin { background: #fff1d6; color: #7a5300; }
.tag-ok { background: #e3f3ea; color: var(--ok); }
.tag-warn { background: #fdecea; color: var(--danger); }
.tag-off { background: #e8e8e8; color: #555; }
.admin-actions { margin: .6rem 0 0 56px; }
.admin-actions > summary { list-style: none; }
.admin-actions > summary::-webkit-details-marker { display: none; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem; margin-top: .6rem; }
.action-grid form { margin: 0; }
.action-grid .btn { width: 100%; }

/* ---------- Snö ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flake {
  position: absolute; top: -12px; color: #fff; user-select: none;
  text-shadow: 0 0 3px rgba(120, 150, 190, .9);
  animation-name: fall; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes fall {
  0%   { transform: translate3d(0, -5vh, 0) rotate(0deg); }
  50%  { transform: translate3d(var(--drift, 20px), 50vh, 0) rotate(180deg); }
  100% { transform: translate3d(0, 105vh, 0) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .snow, .garland { animation: none; }
  .snow { display: none; }
}

/* ---------- Mobil ---------- */
@media (max-width: 640px) {
  h1 { font-size: 1.45rem; }
  .container { padding: 1rem .75rem 2.5rem; }
  .card { padding: 1rem; border-radius: 14px; }
  .menu-toggle { display: block; }
  .mainnav {
    display: none; width: 100%; flex-direction: column; align-items: stretch; gap: .1rem; padding: .5rem 0 .25rem;
  }
  .mainnav.open { display: flex; }
  .mainnav a, .mainnav .linklike { padding: .8rem .75rem; font-size: 1.05rem; text-align: left; width: 100%; }
  .garland { top: 54px; }
  .item { flex-direction: column; gap: .75rem; }
  .item-actions { flex-direction: row; width: 100%; }
  .item-actions > * { flex: 1; }
  .admin-actions { margin-left: 0; }
  .invites li { flex-direction: column; align-items: stretch; }
}
