:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #2a211c;
  --muted: #7a6d64;
  --line: #ebe2d8;
  --red: #b23a2f;
  --red-ink: #ffffff;
  --green: #2f6b4f;
  --green-soft: #e6f1ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --card: #26201c;
    --ink: #f3ebe3;
    --muted: #a99c91;
    --line: #3a312b;
    --red: #e0675b;
    --red-ink: #1b1714;
    --green: #7fc3a0;
    --green-soft: #22352b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
h1, h2, .brand { font-family: Fraunces, Georgia, serif; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 6vw, 2.4rem); margin: .2em 0 .4em; line-height: 1.1; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .6em; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 14px 16px;
}
.brand { font-size: 1.35rem; text-decoration: none; }
.who { font-size: .9rem; color: var(--muted); text-align: right; }
.who .me {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink);
  font-weight: 600; padding: 6px 12px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line);
}
.who .me::before { content: '👤'; font-size: .85em; }
.who .me:hover { box-shadow: inset 0 0 0 1.5px var(--red); }

main { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }

button, input, textarea { font: inherit; color: inherit; }
.btn {
  appearance: none; border: 0; border-radius: 999px; cursor: pointer;
  padding: 10px 18px; font-weight: 600; background: var(--red); color: var(--red-ink);
  min-height: 44px; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: .9rem; }
.link {
  appearance: none; background: none; border: 0; padding: 4px 2px; cursor: pointer;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.link.danger { color: var(--red); }

input[type=text], input[type=url], input[type=password], textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--card); outline: none; min-height: 48px;
}
input:focus, textarea:focus { border-color: var(--red); }
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; margin-top: 10px; font-size: .85rem; color: var(--muted); }
label.field > span { display: block; margin-bottom: 4px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }

/* Innlogging / navn */
.center { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.center p { color: var(--muted); }
.center form { display: grid; gap: 12px; margin-top: 20px; }
.error { color: var(--red); font-size: .9rem; min-height: 1.4em; }

/* Barneoversikt */
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kid {
  display: block; padding: 18px 16px; text-decoration: none;
  transition: transform .12s ease, border-color .12s;
}
.kid:hover { transform: translateY(-2px); border-color: var(--red); }
.kid .name { font-family: Fraunces, Georgia, serif; font-size: 1.35rem; font-weight: 700; }
.kid .count { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.kid .bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 12px; overflow: hidden; }
.kid .bar > i { display: block; height: 100%; background: var(--green); }

.back { display: inline-block; color: var(--muted); text-decoration: none; margin-top: 4px; font-size: .95rem; }

/* Legg til */
.add { padding: 14px; margin-bottom: 20px; }
.add .row { display: flex; gap: 8px; }
.add .row input { flex: 1; min-width: 0; }
.add .more { margin-top: 6px; }
.add .extra { display: none; }
.add.open .extra { display: block; }

/* Ønsker */
.wishes { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.wish { display: flex; gap: 14px; padding: 14px; align-items: flex-start; }
.wish.bought { background: var(--green-soft); border-color: transparent; }
.wish .thumb {
  width: 76px; height: 76px; flex: none; border-radius: 10px; object-fit: cover;
  background: var(--bg); border: 1px solid var(--line); cursor: zoom-in;
}
.wish .body { flex: 1; min-width: 0; }
.wish .title { font-weight: 600; font-size: 1.05rem; word-wrap: break-word; }
.wish.bought .title { text-decoration: line-through; text-decoration-thickness: 1.5px; opacity: .75; }
.wish .comment { color: var(--muted); font-size: .95rem; white-space: pre-wrap; word-wrap: break-word; }
.wish .shop { font-size: .9rem; color: var(--red); text-decoration: none; font-weight: 500; }
.wish .meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.wish .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem;
  color: var(--green);
}
.badge.mine { background: var(--green); color: var(--card); padding: 4px 12px; border-radius: 999px; }

.edit { padding: 14px; }
.edit .buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.edit .buttons .spacer { flex: 1; }
.edit .imgrow { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.edit .imgrow img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

.mine-group h2 a { text-decoration: none; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center;
  padding: 16px; z-index: 50; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); text-align: center; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

input[type=file] { font-size: .9rem; max-width: 100%; }

/* Egen kjøpsstatus */
.progress {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px; text-decoration: none;
}
.progress .arrow { color: var(--red); font-weight: 600; font-size: .9rem; }
.kid { position: relative; }
.kid.has-mine { border-color: var(--green); }
.mine-tag {
  position: absolute; top: 10px; right: 10px; background: var(--green); color: var(--card);
  font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; line-height: 1.4;
}
.lead { color: var(--muted); margin-top: 0; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.chip { display: flex; flex-direction: column; padding: 10px 14px; text-decoration: none; }
.chip strong { font-family: Fraunces, Georgia, serif; font-size: 1.1rem; }
.chip span { color: var(--muted); font-size: .8rem; }
.mine-group h2 { margin-top: 1em; }

.wish .marked { color: var(--muted); font-size: .8rem; }
