/* ============================================
   MADPLAN — Linear/Vercel premium design
   ============================================ */

:root {
  /* Base — sand & charcoal */
  --bg: #fafaf7;
  --bg-elevated: #ffffff;
  --bg-subtle: #f4f3ee;
  --bg-hover: #f0efe8;

  /* Ink (text) */
  --ink: #0a0a0a;
  --ink-2: #3f3f3f;
  --ink-3: #707070;
  --ink-4: #9a9a9a;
  --ink-disabled: #c8c8c8;

  /* Borders & dividers */
  --border: #e5e3da;
  --border-strong: #d4d1c5;
  --divider: #ebe9e0;

  /* Accent — dim blue, sober */
  --accent: #5a6acf;
  --accent-hover: #4956c1;
  --accent-soft: #e8eaf7;
  --accent-text: #3845a8;

  /* Semantic */
  --success: #2f7a5a;
  --success-soft: #e6f1ec;
  --warning: #a36417;
  --warning-soft: #fbf0dc;
  --danger: #b8443e;
  --danger-soft: #f7e3e1;

  /* Typography */
  --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', monospace;

  /* Spacing scale (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* Shadows — subtle */
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-md: 0 2px 8px rgba(10, 10, 10, 0.06), 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-lg: 0 8px 24px rgba(10, 10, 10, 0.08), 0 2px 4px rgba(10, 10, 10, 0.04);

  /* Heights for touch */
  --tap-min: 44px;

  /* Transitions */
  --t-fast: 0.12s ease;
  --t-base: 0.18s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-elevated: #141414;
    --bg-subtle: #1a1a1a;
    --bg-hover: #1f1f1f;
    --ink: #fafaf7;
    --ink-2: #c8c6bf;
    --ink-3: #8a8884;
    --ink-4: #595855;
    --ink-disabled: #353532;
    --border: #2a2925;
    --border-strong: #3a3934;
    --divider: #1f1e1a;
    --accent: #7a86d9;
    --accent-hover: #8d97e0;
    --accent-soft: #1f2545;
    --accent-text: #a8b1e8;
    --success-soft: #15291f;
    --warning-soft: #2a200f;
    --danger-soft: #2b1816;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font-family: inherit; }

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 { font-size: 24px; }
h3 { font-size: 18px; }
h4 {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============================================
   LUCIDE ICONS — uniform 20px, 1.5px stroke
   ============================================ */

.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ============================================
   TOPBAR
   ============================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.brand-mark {
  width: 24px;
  height: 24px;
  background: var(--ink);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-size: 13px;
  font-weight: 700;
}
.brand-mark::before {
  content: 'M';
  font-family: var(--font-sans);
}
.brand-text {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.family-strip {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.fm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.fm-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* ============================================
   TABS — premium bottom-bar feel
   ============================================ */

.tabs {
  display: flex;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 86px;
  z-index: 49;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: var(--space-3) var(--space-2);
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast);
  min-height: var(--tap-min);
}
.tab .icon { color: var(--ink-3); transition: color var(--t-fast); }
.tab.active { color: var(--ink); }
.tab.active .icon { color: var(--accent); }
.tab.active { border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--ink-2); }

/* Subnav — desktop: under topbar / mobil: skjult som default */
.subnav {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 132px;
  z-index: 48;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav[hidden] { display: none !important; }

.subnav-item {
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all var(--t-fast);
  font-weight: 500;
}
.subnav-item:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--ink-2);
}
.subnav-item.active {
  background: var(--ink);
  color: var(--bg);
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

main {
  padding: var(--space-6) var(--space-5) var(--space-12);
  max-width: 720px;
  margin: 0 auto;
}

.panel { display: none; }
.panel.active { display: block; animation: panelIn 0.2s ease; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px dashed var(--border-strong);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-ghost:hover { border-style: solid; color: var(--ink); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--ink); border-color: var(--border-strong); }

/* Week navigation */
.week-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
}
.week-label {
  min-width: 110px;
  text-align: center;
  color: var(--ink-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   DAY CARDS
   ============================================ */

.day-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-3);
  transition: border-color var(--t-fast);
}
.day-card:hover { border-color: var(--border-strong); }
.day-card.empty {
  background: transparent;
  border-style: dashed;
}

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.day-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.day-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}
.day-status.cooked { color: var(--success); background: var(--success-soft); }
.day-status.planned { color: var(--accent-text); background: var(--accent-soft); }

.day-title {
  font-size: 18px;
  font-weight: 600;
  margin: var(--space-2) 0 var(--space-3);
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.day-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 12px;
}

.pref-dots { display: inline-flex; gap: 3px; }
.pref-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--ink-3);
}
.meta-pill.deal {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.meta-pill.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.day-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}
.day-actions button {
  background: var(--bg-elevated);
  color: var(--ink-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.day-actions button:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--ink);
}
.day-actions button.danger { color: var(--danger); }
.day-actions button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

/* ============================================
   SUGGESTION CARDS
   ============================================ */

.suggestion-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
@media (min-width: 600px) {
  .suggestion-grid { grid-template-columns: 1fr 1fr; }
}

.suggestion-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  font-family: inherit;
}
.suggestion-card:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.suggestion-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.suggestion-reason {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.45;
}
.suggestion-score {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.suggestions-loading {
  padding: var(--space-4);
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-2);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}

/* ============================================
   SHOPPING LIST
   ============================================ */

.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
@media (max-width: 600px) {
  .shop-grid { grid-template-columns: 1fr; }
}
.shop-col {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.shop-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--divider);
}
.shop-col-title { font-size: 14px; font-weight: 600; }
.shop-col-count {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-4);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 -4px;
  padding-left: 8px;
  padding-right: 8px;
  transition: background var(--t-fast);
}
.shop-item:hover { background: var(--bg-hover); }
.shop-item-amount {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-4);
}
.shop-category {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin: var(--space-3) 0 var(--space-1);
}
.shop-category:first-child { margin-top: 0; }

/* ============================================
   INPUTS
   ============================================ */

.search-input,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  transition: border-color var(--t-fast);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input { margin-bottom: var(--space-3); }

/* ============================================
   FILTER CHIPS
   ============================================ */

.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.chip {
  padding: 5px 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-fast);
  min-height: 28px;
}
.chip:hover:not(.active) { border-color: var(--border-strong); }
.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* ============================================
   RECIPE LIST
   ============================================ */

.recipe-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--t-fast);
  margin: 0 calc(var(--space-2) * -1);
  border-radius: var(--radius-sm);
}
.recipe-row:hover { background: var(--bg-hover); }
.recipe-row:last-child { border-bottom: none; }
.recipe-row-info { flex: 1; min-width: 0; }
.recipe-row-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink);
}
.recipe-row-meta {
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.recipe-row-arrow {
  color: var(--ink-4);
  font-size: 14px;
  margin-left: var(--space-2);
}

.warning-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--warning-soft);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--warning);
}

/* ============================================
   MEMBER (DISLIKES) SECTIONS
   ============================================ */

.member-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-3);
}
.member-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.member-emoji { font-size: 20px; }
.member-name {
  font-size: 15px;
  font-weight: 600;
}
.dislike-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.dislike-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-subtle);
  padding: 4px 8px 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid var(--border);
}
.dislike-tag.severe {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}
.dislike-tag button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  opacity: 0.6;
}
.dislike-tag button:hover { opacity: 1; }
.add-dislike {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.add-dislike input { flex: 1; min-width: 140px; }
.add-dislike select { width: auto; min-width: 130px; }

/* ============================================
   DEAL ROWS
   ============================================ */

.deal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
}
.deal-info { font-size: 14px; }
.deal-info strong { font-weight: 600; }
.deal-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ============================================
   DRAWER (BOTTOM SHEETS)
   ============================================ */

.drawer {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  margin: auto;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  color: var(--ink);
  padding: 0;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.drawer::backdrop {
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(8px);
}
.drawer-head {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.drawer-head h3 { font-size: 17px; font-weight: 600; }
.drawer .search-input { margin: var(--space-4) var(--space-5) 0; width: calc(100% - 40px); }
.drawer .filter-row { margin: var(--space-3) var(--space-5); }
.drawer > div:not(.drawer-head):not(.filter-row), .drawer > form { padding: 0 var(--space-5) var(--space-5); }

/* ============================================
   FORMS
   ============================================ */

.form-grid {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-6);
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-grid label input, .form-grid label textarea {
  text-transform: none;
  letter-spacing: normal;
}
.form-grid textarea { resize: vertical; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.ingredient-row {
  display: grid;
  grid-template-columns: 1fr 70px 70px 28px;
  gap: 4px;
  margin-bottom: 4px;
}
.ingredient-row input { padding: 6px 8px; font-size: 13px; }

/* ============================================
   RECIPE DETAIL
   ============================================ */

.recipe-detail-section { margin-bottom: var(--space-5); }
.recipe-detail-section h4 {
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--divider);
}
.ingredient-list { list-style: none; padding: 0; }
.ingredient-list li {
  padding: 6px 0;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  border-bottom: 1px solid var(--divider);
}
.ingredient-list li:last-child { border-bottom: none; }
.ingredient-amount {
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  font-size: 13px;
}
.instructions {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}
.preference-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--divider);
}
.preference-row:last-child { border-bottom: none; }
.preference-buttons { display: flex; gap: 4px; }
.preference-buttons button {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--t-fast);
  color: var(--ink-2);
}
.preference-buttons button:hover { border-color: var(--border-strong); }
.preference-buttons button.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.preference-buttons button[data-level="-2"].active { background: var(--danger); border-color: var(--danger); }
.preference-buttons button[data-level="-1"].active { background: var(--warning); border-color: var(--warning); }
.preference-buttons button[data-level="2"].active { background: var(--success); border-color: var(--success); }

/* ============================================
   TOAST
   ============================================ */

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { animation: toastIn 2.4s ease forwards; }
@keyframes toastIn {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  10%, 80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ============================================
   MOBILE — bottom tab bar
   ============================================ */

@media (max-width: 768px) {
  html, body { font-size: 15px; }

  .topbar { padding: var(--space-3) var(--space-4); gap: var(--space-2); }
  .brand-text { font-size: 15px; }
  .family-strip { gap: 5px; }
  .fm-pill { padding: 3px 9px 3px 7px; font-size: 11px; }

  .tabs {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    z-index: 100;
  }
  .tab {
    border-top: 2px solid transparent;
    border-bottom: none;
    margin-bottom: 0;
    padding: var(--space-2) var(--space-1);
    font-size: 11px;
  }
  .tab.active { border-bottom-color: transparent; border-top-color: var(--accent); }

  .subnav {
    position: fixed;
    top: auto;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: var(--space-2) var(--space-3);
    z-index: 99;
    justify-content: space-around;
  }
  .subnav-item { padding: 6px 10px; font-size: 12px; }

  main { padding: var(--space-4) var(--space-4) 100px; }

  .panel-head { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .panel-head h2 { font-size: 22px; }

  .btn-primary, .btn-secondary { min-height: 40px; padding: 9px 14px; }
  .icon-btn { width: 36px; height: 36px; }

  .day-card { padding: var(--space-4); }
  .day-title { font-size: 17px; }
  .day-actions button { padding: 8px 12px; font-size: 12px; min-height: 36px; flex: 1 1 auto; }

  .suggestion-grid { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: 1fr; }
  .shop-item { padding: 10px 8px; }

  .drawer {
    max-height: 92vh;
    max-width: 100%;
    margin: 0;
    margin-top: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    animation: slideUp 0.25s ease-out;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Når subnav er synlig, skub main op */
  body:has(.subnav:not([hidden])) main { padding-bottom: 150px; }

  input[type="text"], input[type="search"], input[type="number"], input[type="date"],
  textarea, select, .search-input { font-size: 16px; min-height: 42px; }

  .toast { bottom: 140px; }
}

@media (hover: none) {
  .suggestion-card:active, .recipe-row:active, .day-actions button:active,
  .chip:active, .shop-item:active {
    background: var(--bg-hover);
  }
}

/* ============================================
   OVERRIDES — Forbedret hierarki
   ============================================ */

/* Family strip er kun synlig på Smag-fanen */
.family-strip { display: none; }
body[data-current-panel="dislikes"] .topbar .family-strip { display: none; } /* også her - vi viser dem i panel-headeren */

/* Topbar slankere når family-strip er væk */
.topbar { padding-bottom: var(--space-3); }

/* Ny uge-header til ugeplanen — uge-vælgeren ER overskriften */
.week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.week-header-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.week-header h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.week-header-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 4px;
  letter-spacing: 0.01em;
}
.week-nav-pair {
  display: flex;
  align-items: center;
  gap: 2px;
}
.week-nav-pair button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.week-nav-pair button:hover {
  background: var(--bg-hover);
  color: var(--ink);
  border-color: var(--border-strong);
}
.week-nav-pair button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: none; }
.week-nav-pair button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

@media (max-width: 768px) {
  .week-header h2 { font-size: 22px; }
  .week-nav-pair button { width: 36px; height: 36px; }
}

/* ============================================
   SMAG — bedre inputs alignment
   ============================================ */

.add-dislike {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: var(--space-2);
  align-items: stretch;
}
.add-dislike input,
.add-dislike select {
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  margin: 0;
}
.add-dislike button {
  height: 38px;
  padding: 0 16px;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
.add-dislike button:hover { background: var(--ink-2); border-color: var(--ink-2); }

@media (max-width: 600px) {
  .add-dislike {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .add-dislike input, .add-dislike select, .add-dislike button {
    width: 100%;
    height: 42px;
  }
}

/* Forbedret member-section header */
.member-header {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--divider);
}
.member-emoji { font-size: 24px; }
.member-name {
  font-size: 16px;
  font-weight: 600;
  position: relative;
}
.member-name::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 24px;
  height: 2px;
  background: var(--member-color, var(--accent));
  border-radius: 1px;
}

/* Dislike-tags strammere */
.dislike-tag {
  padding: 5px 10px 5px 8px;
  font-size: 12px;
  font-weight: 500;
  gap: 4px;
}
.dislike-tag.severe { font-weight: 500; }


/* ============================================
   TOAST FIX — kun synlig under animation
   ============================================ */
.toast { display: none; }
.toast.show { display: flex; }
.toast[hidden] { display: none !important; }

/* ============================================
   NY WEEK HEADER — uge-nummer + dato på én linje
   ============================================ */
.week-header {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.week-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.week-title-group {
  flex: 1;
  text-align: center;
}
.week-header h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.week-now {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  line-height: 1.5;
}
.week-header-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 4px;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.week-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.week-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--ink);
  border-color: var(--border-strong);
}
@media (max-width: 768px) {
  .week-header h2 { font-size: 20px; }
}

/* ============================================
   WEEK HEADER — centreret kompakt layout
   ============================================ */
.week-header-main {
  justify-content: center !important;
  gap: var(--space-5) !important;
}
.week-title-group {
  flex: 0 0 auto !important;
  min-width: 140px;
}
@media (max-width: 768px) {
  .week-header-main { gap: var(--space-4) !important; }
  .week-title-group { min-width: 130px; }
}

/* ============================================
   WEEK HEADER — endelig version, centreret
   ============================================ */
.week-header {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.week-header-main {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
}

.week-title-group {
  text-align: center;
  min-width: 130px;
}

.week-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.week-now {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  line-height: 1.5;
}

.week-header-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 4px;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.week-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.week-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--ink);
  border-color: var(--border-strong);
}


/* Manuel vare i indkøbsliste */
.shop-item-manual {
  background: rgba(90, 106, 207, 0.06);
  border-left: 2px solid var(--accent, #5a6acf);
}
.shop-item-manual .shop-item-name {
  font-style: italic;
}
.manual-tag {
  display: inline-block;
  font-size: 0.7em;
  background: rgba(90, 106, 207, 0.15);
  color: var(--accent, #5a6acf);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-style: normal;
  vertical-align: middle;
}
.shop-item-delete {
  background: transparent;
  border: none;
  color: var(--muted, #888);
  font-size: 1.4em;
  cursor: pointer;
  padding: 0 8px;
  margin-left: auto;
  line-height: 1;
}
.shop-item-delete:hover {
  color: #d44;
}

/* Manual item drawer */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field > span { font-size: 0.85em; color: var(--muted, #888); }
.form-field input, .form-field select {
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  font-size: 1em;
  background: var(--surface, #fff);
}
.form-row { display: flex; gap: 10px; }


/* Indkøbsliste: rute-sortering dropdown */
.shop-sort-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
  padding: 8px 12px;
  background: var(--surface-2, #f7f7f4);
  border-radius: 8px;
}
.shop-sort-select {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 6px;
  background: var(--surface, #fff);
  font-size: 0.9em;
  cursor: pointer;
}


/* Rute-redigering (drag-and-drop) */
.btn-icon-small {
  background: transparent;
  border: 1px solid var(--rule, #e5e5e5);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-muted, #888);
  display: inline-flex;
  align-items: center;
}
.btn-icon-small:hover {
  background: var(--surface-2, #f7f7f4);
  color: var(--ink, #0a0a0a);
}
.route-editor {
  margin: 8px 0 14px 24px;
  padding: 10px 12px;
  background: var(--surface-2, #f7f7f4);
  border-radius: 8px;
}
.route-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.route-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--rule, #e5e5e5);
  border-radius: 6px;
  user-select: none;
}
.route-cat {
  flex: 1;
  text-transform: capitalize;
}
.route-buttons {
  display: flex;
  gap: 4px;
}
.route-btn {
  width: 32px;
  height: 32px;
  background: var(--surface, #fff);
  border: 1px solid var(--rule, #e5e5e5);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8em;
  color: var(--ink, #0a0a0a);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.route-btn:hover:not(:disabled) {
  background: var(--surface-hover, #fafaf7);
}
.route-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}


/* === AUTH-FLOW (login/register/forgot/reset) === */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg, #fafafa);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface, #fff);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  border: 1px solid var(--rule, #e5e5e5);
}
.auth-screen {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-title {
  font-size: 1.6em;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink, #0a0a0a);
}
.auth-subtitle {
  color: var(--ink-muted, #888);
  font-size: 0.92em;
  margin: 0 0 24px;
  line-height: 1.5;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auth-form .form-field > span {
  font-size: 0.85em;
  color: var(--ink-muted, #888);
}
.auth-form .form-field input {
  padding: 12px 14px;
  border: 1px solid var(--rule, #e5e5e5);
  border-radius: 8px;
  font-size: 1em;
  background: var(--surface, #fff);
  transition: border-color 0.15s;
}
.auth-form .form-field input:focus {
  outline: none;
  border-color: var(--accent, #5a6acf);
}
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 0.9em;
  color: var(--ink, #0a0a0a);
}
.form-check input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.form-check a {
  color: var(--accent, #5a6acf);
  text-decoration: underline;
}
.btn-block {
  width: 100%;
  padding: 12px 16px;
  font-size: 1em;
  margin-top: 4px;
}
.auth-error {
  padding: 10px 12px;
  background: #fdecea;
  border-left: 3px solid #d44;
  color: #a02;
  border-radius: 4px;
  font-size: 0.9em;
}
.auth-success {
  padding: 10px 12px;
  background: #e6f7e6;
  border-left: 3px solid #4a4;
  color: #064;
  border-radius: 4px;
  font-size: 0.9em;
}
.auth-links {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  font-size: 0.9em;
}
.auth-links a {
  color: var(--accent, #5a6acf);
  text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }
.auth-sep { color: var(--ink-muted, #888); }

/* === USER MENU i top bar === */
.user-menu {
  margin-left: auto;
  position: relative;
}
.btn-user {
  background: transparent;
  border: 1px solid var(--rule, #e5e5e5);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9em;
  color: var(--ink, #0a0a0a);
}
.btn-user:hover {
  background: var(--surface-2, #f7f7f4);
}
.user-family-name {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--rule, #e5e5e5);
  border-radius: 8px;
  min-width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 100;
  overflow: hidden;
}
.user-info {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule, #e5e5e5);
}
.user-email {
  font-size: 0.92em;
  color: var(--ink, #0a0a0a);
  word-break: break-all;
}
.user-family-label {
  font-size: 0.82em;
  color: var(--ink-muted, #888);
  margin-top: 2px;
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.92em;
  color: var(--ink, #0a0a0a);
}
.dropdown-item:hover {
  background: var(--surface-2, #f7f7f4);
}
