/* Middag – familiens kokebok */

:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --line: #e7ddd0;
  --text: #2a231e;
  --muted: #7b6e63;
  --accent: #c25b3c;
  --accent-strong: #a3472b;
  --accent-soft: #f7e4da;
  --on-accent: #ffffff;
  --warn: #8f5a00;
  --warn-soft: #fbf0d9;
  --warn-line: #ecd29c;
  --danger: #b3261e;
  --ok: #3b7a4c;
  --die-face: #fffdf9;
  --die-edge: #eadfd2;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgb(60 40 20 / 0.06);
  --shadow: 0 1px 2px rgb(60 40 20 / 0.05), 0 10px 30px rgb(60 40 20 / 0.08);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gutter: 16px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(0.2, 0.7, 0.25, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #25201d;
    --surface-2: #2e2824;
    --line: #3b342f;
    --text: #f3ede6;
    --muted: #a99d92;
    --accent: #e27b5b;
    --accent-strong: #f09475;
    --accent-soft: #3e2a22;
    --on-accent: #1c1917;
    --warn: #f1bb55;
    --warn-soft: #382d16;
    --warn-line: #5c4a22;
    --danger: #ff8a80;
    --ok: #7fc493;
    --die-face: #f6efe6;
    --die-edge: #cbbcad;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.25), 0 10px 30px rgb(0 0 0 / 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent-strong);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 6vw, 2.5rem);
}

h2 {
  font-size: 1.35rem;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 10px;
}

.skip-link:focus {
  left: 8px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Ramme ---------- */

.topbar {
  display: none;
}

#view {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 20px) var(--gutter) 32px;
  outline: none;
}

#view.view-enter {
  animation: view-in 0.28s var(--ease);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.tabbar svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s var(--ease);
}

.tabbar svg .fill {
  fill: currentColor;
  stroke: none;
}

.tabbar a[aria-current='page'] {
  color: var(--accent-strong);
}

.tabbar a[aria-current='page'] svg {
  transform: translateY(-1px) scale(1.06);
}

.tabbar .tab-add svg {
  width: 32px;
  height: 32px;
  margin: -3px 0;
  padding: 5px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  stroke-width: 2.4;
}

.tabbar .tab-add[aria-current='page'] svg {
  background: var(--accent-strong);
}

.badge {
  position: absolute;
  top: 7px;
  left: calc(50% + 7px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    height: 68px;
    padding: 0 32px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--text);
    text-decoration: none;
  }

  .brand img {
    border-radius: 8px;
  }

  .tabbar {
    inset: 0 32px auto auto;
    height: 68px;
    padding: 0;
    display: flex;
    gap: 4px;
    align-items: center;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 0;
  }

  .tabbar a {
    flex-direction: row;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 15px;
  }

  .tabbar a:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  .tabbar a[aria-current='page'] {
    background: var(--accent-soft);
  }

  .tabbar svg {
    width: 22px;
    height: 22px;
  }

  .tabbar .tab-add {
    margin-left: 6px;
    background: var(--accent);
    color: var(--on-accent) !important;
  }

  .tabbar .tab-add:hover,
  .tabbar .tab-add[aria-current='page'] {
    background: var(--accent-strong);
  }

  .tabbar .tab-add svg {
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    background: none;
  }

  .badge {
    position: static;
  }

  #view {
    padding-top: 36px;
  }
}

/* ---------- Knapper ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 15.5px;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, transform 0.12s var(--ease), border-color 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14.5px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 6px 2px;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.12s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}

.back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Felles ---------- */

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.muted {
  color: var(--muted);
}

.small {
  font-size: 13.5px;
}

.empty {
  text-align: center;
  padding: 48px 16px;
}

.empty .empty-art {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 12px;
}

.empty h2 {
  margin-bottom: 8px;
}

.empty p {
  color: var(--muted);
  margin: 0 auto 20px;
  max-width: 34ch;
}

.empty .actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--text);
  margin-bottom: 16px;
}

.notice.error {
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.notice.info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.notice p {
  margin: 0;
}

.notice .notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 0;
  color: var(--muted);
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-weight: 600;
}

/* ---------- Terning ---------- */

.dice-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 3vh;
}

.dice-page .eyebrow {
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.dice-page h1 {
  max-width: 14ch;
}

/* Før første kast: stor terning og knapp. Etter kast tar resultatkortet plassen. */
.dice-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 32px;
}

.dice-page.has-result .dice-intro {
  display: none;
}

.die-btn {
  padding: 14px;
  border: 0;
  border-radius: 36px;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.die-btn:hover .die:not(.rolling) {
  transform: rotate(-3deg) translateY(-3px);
}

.die-btn:active .die:not(.rolling) {
  transform: rotate(-8deg) scale(0.94);
}

.die {
  --die-size: 116px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  flex: none;
  width: var(--die-size);
  height: var(--die-size);
  /* Prosent-padding regnes av forelderens bredde, så vi bruker terningens størrelse. */
  padding: calc(var(--die-size) * 0.17);
  border-radius: 26%;
  background: var(--die-face);
  box-shadow:
    inset 0 -5px 0 var(--die-edge),
    0 14px 28px rgb(60 30 10 / 0.16);
  transform: rotate(-8deg);
  transition: transform 0.2s var(--ease);
}

.die-sm {
  --die-size: 24px;
  padding: calc(var(--die-size) * 0.14);
  border-radius: 7px;
  box-shadow: inset 0 -2px 0 var(--die-edge);
  transform: rotate(-8deg);
}

.pip {
  width: 78%;
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.25);
}

.die-sm .pip {
  box-shadow: none;
}

.p-tl { grid-area: 1 / 1; }
.p-tr { grid-area: 1 / 3; }
.p-ml { grid-area: 2 / 1; }
.p-c { grid-area: 2 / 2; }
.p-mr { grid-area: 2 / 3; }
.p-bl { grid-area: 3 / 1; }
.p-br { grid-area: 3 / 3; }

.die.rolling {
  animation: die-tumble 0.55s linear infinite;
}

.die.landed {
  animation: die-land 0.4s var(--ease);
}

@keyframes die-tumble {
  0% { transform: translateY(0) rotate(-8deg); }
  25% { transform: translateY(-16%) rotate(80deg); }
  50% { transform: translateY(0) rotate(172deg); }
  75% { transform: translateY(-8%) rotate(262deg); }
  100% { transform: translateY(0) rotate(352deg); }
}

@keyframes die-land {
  0% { transform: rotate(-8deg) scale(1.15); }
  60% { transform: rotate(-8deg) scale(0.96); }
  100% { transform: rotate(-8deg) scale(1); }
}

.dice-cta {
  min-width: 220px;
  min-height: 54px;
  font-size: 17px;
}

.dice-note {
  margin: 0;
  max-width: 32ch;
  color: var(--muted);
  font-size: 14.5px;
}

.roll-result {
  width: 100%;
  max-width: 440px;
  margin-top: 24px;
  transition: opacity 0.2s;
  animation: rise 0.5s var(--ease);
}

.roll-result.dimmed {
  opacity: 0.45;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
}

.roll-card {
  display: block;
  overflow: hidden;
  text-align: left;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.roll-card:hover {
  transform: translateY(-2px);
}

.roll-card .roll-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  font-size: 56px;
}

.roll-card .roll-body {
  padding: 16px 18px 18px;
}

.roll-card .roll-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13.5px;
}

.roll-card h2 {
  font-size: 1.55rem;
}

.roll-card .roll-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14.5px;
}

.roll-card .open-hint {
  color: var(--accent-strong);
  font-weight: 600;
}

.roll-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

@media (min-width: 480px) {
  .roll-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.dice-footer {
  margin-top: 28px;
}

/* ---------- Oppskriftsliste ---------- */

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

@media (min-width: 600px) {
  .recipe-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.recipe-tile {
  display: block;
  overflow: hidden;
  height: 100%;
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.recipe-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.recipe-tile img,
.recipe-tile .thumb-placeholder {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  font-size: 34px;
}

.recipe-tile .tile-body {
  padding: 10px 12px 12px;
}

.recipe-tile h3 {
  font-size: 1.02rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.recipe-tile .tile-time {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Oppskrift ---------- */

.recipe-hero {
  margin: calc(-20px - var(--safe-t)) calc(-1 * var(--gutter)) 20px;
}

.recipe-hero img,
.recipe-hero .thumb-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0 0 28px 28px;
  font-size: 72px;
}

@media (min-width: 760px) {
  .recipe-hero {
    margin: 0 0 24px;
  }

  .recipe-hero img,
  .recipe-hero .thumb-placeholder {
    aspect-ratio: 16 / 9;
    max-height: 420px;
    border-radius: var(--radius);
  }
}

.recipe-hero-nav {
  position: relative;
}

.recipe-hero-nav .back {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: 12px;
  z-index: 2;
  margin: 0;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
}

@media (min-width: 760px) {
  .recipe-hero-nav .back {
    position: static;
    background: none;
    padding: 0;
    margin-bottom: 12px;
    backdrop-filter: none;
    color: var(--muted);
  }
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.recipe-meta li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--muted);
}

.recipe-meta svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.recipe-description {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16.5px;
}

.recipe-body {
  display: grid;
  gap: 28px;
  margin-top: 28px;
}

@media (min-width: 900px) {
  #view.wide {
    max-width: 1040px;
  }

  .recipe-body {
    grid-template-columns: 380px 1fr;
    align-items: start;
    gap: 40px;
  }

  .recipe-body .ingredients-col {
    position: sticky;
    top: 92px;
  }
}

.section-title {
  margin-bottom: 12px;
}

.portions {
  padding: 16px;
  margin-bottom: 18px;
}

.portions-row {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.stepper {
  display: grid;
  gap: 6px;
}

.stepper-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

.stepper-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper-value {
  min-width: 2ch;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.portions-hint {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

.ingredients {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ingredients li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}

.ingredients li:last-child {
  border-bottom: 0;
}

.ingredients .ing-section {
  display: block;
  padding: 18px 0 4px;
  border-bottom: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.ingredients .ing-section:first-child {
  padding-top: 0;
}

.ing-qty {
  flex: none;
  min-width: 5.2em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);
}

.ing-note {
  color: var(--muted);
}

.ing-raw {
  flex: 1;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  font-weight: 600;
  vertical-align: 1px;
  white-space: nowrap;
}

.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
}

.steps li {
  position: relative;
  counter-increment: step;
  padding: 0 0 20px 48px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 15px;
}

.steps li.done {
  opacity: 0.45;
}

.steps li.done::before {
  content: '✓';
}

.recipe-notes {
  margin-top: 8px;
  padding: 16px 18px;
  white-space: pre-line;
}

.recipe-actions {
  display: grid;
  gap: 10px;
  margin-top: 32px;
}

.recipe-actions .row {
  display: flex;
  gap: 10px;
}

.recipe-actions .row .btn {
  flex: 1;
}

.recipe-footer {
  display: grid;
  gap: 20px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.recipe-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin: 0;
}

.recipe-info dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.recipe-info dd {
  margin: 2px 0 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.recipe-info a {
  text-decoration: none;
  font-weight: 500;
}

.recipe-info a:hover {
  text-decoration: underline;
}

.recipe-footer-actions {
  display: flex;
  gap: 10px;
}

.recipe-footer-actions .btn {
  flex: 1;
}

@media (min-width: 760px) {
  .recipe-footer {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .recipe-footer-actions {
    grid-column: 2;
  }

  .recipe-footer-actions .btn {
    flex: none;
    min-width: 130px;
  }
}

/* ---------- Skjema ---------- */

.form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > label,
.field > .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14.5px;
}

.field .hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.field.is-missing > label::after,
.field.is-missing > .label::after {
  content: 'Mangler';
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  font-weight: 600;
}

.field.is-missing input,
.field.is-missing textarea {
  border-color: var(--warn-line);
  background: color-mix(in srgb, var(--warn-soft) 45%, var(--surface));
}

input[type='text'],
input[type='url'],
input[type='number'],
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px; /* hindrer zoom på iOS */
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.image-field {
  display: grid;
  gap: 10px;
}

.image-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 15px;
}

.image-preview.thumb-placeholder {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--muted);
}

.image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.parse-preview {
  list-style: none;
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px;
  display: grid;
  gap: 4px;
}

.parse-preview li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.parse-preview .pp-icon {
  flex: none;
  width: 1.2em;
  text-align: center;
  font-weight: 700;
}

.parse-preview .ok .pp-icon {
  color: var(--ok);
}

.parse-preview .warn {
  color: var(--warn);
}

.parse-preview .section {
  font-weight: 600;
  padding-top: 4px;
}

.parse-preview .pp-parts {
  color: var(--muted);
}

.parse-summary {
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0 0;
}

.parse-summary.has-warn {
  color: var(--warn);
  font-weight: 600;
}

.savebar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px);
  z-index: 5;
  display: flex;
  gap: 10px;
  padding: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.savebar .btn-primary {
  flex: 1;
}

@media (min-width: 900px) {
  .savebar {
    bottom: 16px;
  }
}

.import-box {
  padding: 18px;
}

.import-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.import-row input {
  flex: 1;
  min-width: 0;
}

.or-manual {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
}

.preview-banner {
  margin-bottom: 18px;
}

/* ---------- Handleliste ---------- */

.shop-entries {
  display: grid;
  gap: 10px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.shop-entry {
  padding: 12px 14px;
}

.shop-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shop-entry-head a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.shop-entry .portions-row {
  margin-top: 10px;
  justify-content: flex-start;
  gap: 24px;
}

.shop-entry .icon-btn {
  width: 38px;
  height: 38px;
}

.shop-entry .stepper-value {
  font-size: 17px;
}

.shop-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shop-group-name {
  padding: 14px 4px 2px;
  font-weight: 600;
  font-size: 15px;
}

.shop-line {
  border-bottom: 1px solid var(--line);
}

.shop-line > label {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 8px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.shop-line.sub > label {
  padding-left: 18px;
}

.shop-line input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.shop-line input::after {
  content: '';
  width: 7px;
  height: 13px;
  margin-top: -3px;
  border: solid var(--on-accent);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s var(--ease);
}

.shop-line input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.shop-line input:checked::after {
  transform: rotate(45deg) scale(1);
}

.shop-text {
  flex: 1;
  min-width: 0;
}

.shop-text .shop-main {
  overflow-wrap: anywhere;
  transition: color 0.2s;
}

.shop-text .shop-src {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.shop-line.checked .shop-main {
  text-decoration: line-through;
  color: var(--muted);
}

.shop-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.shop-actions .btn {
  flex: 1;
}

/* ---------- Toast og dialog ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

@media (min-width: 900px) {
  .toast-region {
    bottom: 24px;
  }
}

.toast {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  font-size: 15px;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s var(--ease);
}

.toast.warn {
  background: var(--warn-soft);
  color: var(--text);
  border: 1px solid var(--warn-line);
}

.toast.out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

dialog.confirm {
  width: min(92vw, 400px);
  padding: 24px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}

dialog.confirm[open] {
  animation: dialog-in 0.25s var(--ease);
}

dialog.confirm::backdrop {
  background: rgb(20 12 8 / 0.45);
  backdrop-filter: blur(2px);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

dialog.confirm h2 {
  font-size: 1.3rem;
}

.confirm-message {
  color: var(--muted);
  margin: 8px 0 20px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-actions .btn {
  flex: 1;
}

.confirm-ok.danger {
  background: var(--danger);
  color: #fff;
}

/* ---------- Redusert bevegelse ---------- */

@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;
  }

  .spinner {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}
