/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #F6F7F4;
  --cream-dark: #E9ECE6;
  --terracotta: #2C5F3F;
  --terracotta-dark: #1A3D28;
  --terracotta-light: #5E9E78;
  --brown: #1C2B21;
  --brown-light: #4A6B5A;
  --green: #3A7D5C;
  --green-dark: #2C5F3F;
  --text: #1B1F2A;
  --text-light: #64706B;
  --border: #CDD5CF;
  --white: #FFFFFF;
  --danger: #B5342A;
  --danger-light: #D94E43;
  --shadow: 0 2px 8px rgba(28, 43, 33, 0.08);
  --shadow-lg: 0 4px 16px rgba(28, 43, 33, 0.12);
  --radius: 10px;
  --radius-lg: 16px;
}

/* Horizontal-scroll prevention on html only. Applying overflow or
   max-width to <body> turns body into the scroll container on iOS
   Safari, which breaks position: fixed children — the hamburger +
   notif bell ended up scrolling with the page content instead of
   staying pinned to the viewport. */
html { overflow-x: clip; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
a { color: var(--terracotta); text-decoration: none; }
a:hover { color: var(--terracotta-dark); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--terracotta); color: var(--white); }
.btn-primary:hover { background: var(--terracotta-dark); }
.btn-secondary { background: var(--cream-dark); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-icon { padding: 8px; border-radius: 50%; background: transparent; }
.btn-icon:hover { background: var(--cream-dark); }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--brown-light);
  font-family: -apple-system, sans-serif;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--terracotta);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* === Auth Page === */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--cream) 0%, var(--cream-dark) 100%);
}
.auth-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 { color: var(--terracotta); font-size: 1.8rem; }
.auth-header p { color: var(--text-light); font-size: 0.95rem; margin-top: 4px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.auth-tabs .tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}
.auth-tabs .tab.active {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
}
.auth-form .btn { width: 100%; justify-content: center; margin-top: 8px; }
.auth-form .btn[disabled] { opacity: 0.65; cursor: wait; }
.error-msg { color: var(--danger); font-size: 0.85rem; margin-bottom: 8px; font-family: -apple-system, sans-serif; }

/* Prominent banner-style error for login/signup only. Scoped by id so the
   forgot-password and reset-password messages (which also live inside
   .auth-form divs) keep the plain-text .error-msg appearance and remain
   visible by default. */
#login-error, #signup-error {
  display: none;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 12px;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}
#login-error.visible, #signup-error.visible { display: flex; }
#login-error::before, #signup-error::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--white);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-8px); }
  30%, 60%, 90% { transform: translateX(8px); }
}
.auth-form.shake { animation: authShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* === App Layout === */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  background: var(--brown);
  color: var(--white);
  padding: 20px 0;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 { font-size: 1.2rem; color: var(--terracotta-light); margin: 0; }
.sidebar-header p { font-size: 0.8rem; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.06em; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.sidebar-brand-icon { width: 28px; height: 28px; border-radius: 6px; display: block; flex-shrink: 0; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  font-family: -apple-system, sans-serif;
  transition: background 0.2s, color 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}
.sidebar-nav .nav-section {
  padding: 8px 20px 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  font-family: -apple-system, sans-serif;
}
.nav-badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px;
  background: rgba(255,255,255,0.15); font-size: 0.7rem; text-align: center;
  font-weight: 600; margin-left: auto;
}
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer a { color: rgba(255,255,255,0.6); font-size: 0.85rem; font-family: -apple-system, sans-serif; }

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  max-width: 1200px;
  animation: pageIn 0.2s ease;
}
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile hamburger */
.hamburger {
  display: none;
  position: fixed;
  /* Anchored at the same top offset as .notif-bell so the two buttons
     sit on the same horizontal line. max() keeps a sane fallback when
     safe-area-inset-top is 0 (mobile Safari with the URL bar). */
  top: max(env(safe-area-inset-top, 0px), 46px);
  left: calc(12px + env(safe-area-inset-left, 0px));
  z-index: 200;
  background: var(--brown);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 1.2rem;
  cursor: pointer;
}

/* Notifications bell (top-right).
   position: absolute — anchored to the top of the document, not the
   viewport, so it scrolls off as the user scrolls down. Visually
   placed inside the top-right of each page's title box (mem-hero /
   page-header / dash-hero).
   - Mobile default: top aligns ~8px inside the mem-hero top edge,
     right aligns with main-content's 16px horizontal padding.
   - Desktop override below positions it inside the title box on wider
     layouts where main-content has a max-width. */
.notif-bell {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 46px);
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 300;
  background: var(--brown);
  color: var(--white);
  border-radius: var(--radius);
  padding: 8px 10px;
  line-height: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notif-bell-icon { display: block; }
.notif-bell:hover { color: var(--white); opacity: 0.9; }
/* Hide the bell on fullscreen tree pages — tree-controls already live at top-right. */
body.tree-active .notif-bell { display: none; }

/* Desktop: tuck the bell into the top-right corner of the title box
   (mem-hero / page-header / dash-hero). Mobile keeps the default
   "floating at top-right of the document" placement from the rule
   above. 1424 = (260 sidebar + 1200 main-content max) - 32 right
   padding - a small aesthetic margin; below that breakpoint-width
   the bell sits a consistent 36px in from the viewport edge. */
@media (min-width: 769px) {
  .notif-bell {
    top: 32px;
    right: max(36px, calc(100vw - 1424px));
  }
}
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, sans-serif;
  box-shadow: 0 0 0 2px var(--cream);
}
.notif-badge[hidden] { display: none; }
[data-theme="dark"] .notif-badge { box-shadow: 0 0 0 2px #121712; }

/* Notifications list page */
.notif-list {
  max-width: 720px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.notif-row {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--cream-dark);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { background: var(--cream); color: var(--text); }
.notif-row-body { flex: 1; min-width: 0; }
.notif-row-text {
  font-size: 0.92rem; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis;
}
.notif-row-when { font-size: 0.78rem; color: var(--text-light); margin-top: 2px; }
.notif-unread { background: rgba(46, 125, 50, 0.06); }
.notif-unread .notif-row-text { font-weight: 500; }
[data-theme="dark"] .notif-list { background: #1a2019; }
[data-theme="dark"] .notif-row { border-bottom-color: #2a3229; color: var(--text); }
[data-theme="dark"] .notif-row:hover { background: #222a21; color: var(--text); }
[data-theme="dark"] .notif-unread { background: rgba(122, 184, 147, 0.08); }

/* === Cards === */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 1.3rem; }
.card-header h3 { font-size: 1.1rem; }

/* === Page Header === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.6rem; }

/* === Grid Layouts === */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* === Dashboard Hero === */
.dash-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
  padding: 28px 32px;
  background: linear-gradient(135deg, var(--terracotta-dark) 0%, var(--terracotta) 60%, var(--green) 100%);
  border-radius: var(--radius-lg);
  color: var(--white);
}
.dash-hero-text h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.dash-hero-text p { font-size: 0.9rem; opacity: 0.85; }
.dash-hero-actions { display: flex; gap: 8px; }
.dash-hero-actions .btn-secondary { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); color: var(--white); }
.dash-hero-actions .btn-secondary:hover { background: rgba(255,255,255,0.25); }

/* Dashboard Empty State */
.dash-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.dash-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.dash-empty h3 { font-size: 1.3rem; margin-bottom: 8px; }
.dash-empty p { color: var(--text-light); margin-bottom: 20px; max-width: 400px; margin-left: auto; margin-right: auto; }

/* Shared arrow chevron */
.dash-card-arrow { font-size: 1.5rem; color: var(--border); font-weight: 300; }

/* === Family Page Hero === */
.fam-page-hero {
  padding: 24px 28px 20px;
  background: linear-gradient(135deg, var(--terracotta-dark) 0%, var(--terracotta) 50%, var(--green) 100%);
  border-radius: var(--radius-lg);
  color: var(--white);
  margin-bottom: 16px;
}
.fam-page-hero .mem-back { color: rgba(255,255,255,0.7); }
.fam-page-hero .mem-back:hover { color: var(--white); }
.fam-page-hero-main { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.fam-page-icon {
  width: 60px; height: 60px; border-radius: 16px;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(4px);
  color: var(--white); display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; flex-shrink: 0;
  overflow: hidden;
}
.fam-page-icon-img { width: 100%; height: 100%; display: block; }
.fam-page-hero-info h1 { font-size: 1.5rem; margin-bottom: 6px; }
.fam-page-stats { display: flex; align-items: center; gap: 16px; }
.fam-page-stat { display: flex; align-items: baseline; gap: 4px; font-size: 0.8rem; opacity: 0.85; }
.fam-page-stat-num { font-size: 1.1rem; font-weight: 700; }
.fam-page-stat-role {
  padding: 2px 10px; border-radius: 20px;
  background: rgba(255,255,255,0.15); font-size: 0.7rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}

/* Family Page Navigation Tiles */
.fam-page-nav { display: flex; gap: 10px; margin-bottom: 20px; }
.fam-nav-tile {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 12px; background: var(--white);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}
.fam-nav-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--terracotta); }
.fam-nav-icon { font-size: 1.5rem; }
.fam-nav-label { font-size: 0.8rem; font-weight: 600; }

/* Family Page Cards Grid — 3 columns */
.fam-page-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1024px) { .fam-page-3col { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .fam-page-3col { grid-template-columns: 1fr; } }
.fam-page-staircase {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "invite recents"
    "recipes recents";
  gap: 16px;
  align-items: start;
}
.fam-area-invite  { grid-area: invite; }
.fam-area-recipes { grid-area: recipes; }
.fam-area-recents { grid-area: recents; }
@media (max-width: 640px) {
  .fam-page-staircase {
    grid-template-columns: 1fr;
    grid-template-areas:
      "invite"
      "recipes"
      "recents";
  }
}
.fam-page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.fam-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}
.fam-card h3 { font-size: 1.05rem; margin-bottom: 4px; }
.fam-card-desc { font-size: 0.85rem; color: var(--text-light); margin-bottom: 12px; }
.fam-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fam-invite-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.fam-admin-actions { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--cream-dark); }
.fam-recipe-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--cream-dark); cursor: pointer;
  transition: background 0.15s;
}
.fam-recipe-row:last-child { border-bottom: none; }
.fam-recipe-row:hover { background: var(--cream); margin: 0 -12px; padding: 10px 12px; border-radius: var(--radius); }
.fam-recipe-meta { display: block; font-size: 0.8rem; color: var(--text-light); }


/* === Recipe Card === */
.recipe-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.recipe-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--cream-dark);
}
.recipe-card-img-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, var(--cream-dark), var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--border);
}
.recipe-card-body { padding: 16px; }
.recipe-card-body h3 { font-size: 1.1rem; margin-bottom: 6px; }
.recipe-card-body .meta {
  font-size: 0.8rem;
  color: var(--text-light);
  font-family: -apple-system, sans-serif;
  margin-bottom: 8px;
}
.recipe-card-body .tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* === Members Page === */
.mem-hero {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 28px; padding: 24px 28px;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.mem-back {
  font-size: 0.8rem; color: var(--terracotta); display: block; margin-bottom: 4px;
  text-decoration: none; font-weight: 500;
}
.mem-back:hover { color: var(--terracotta-dark); }
.mem-hero h1 { font-size: 1.4rem; line-height: 1.2; }
.mem-hero-sub { font-size: 0.85rem; color: var(--text-light); margin-top: 2px; }
.mem-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mem-hero-actions .btn { min-width: 120px; text-align: center; box-sizing: border-box; }
.mem-section-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-light); font-weight: 600; margin-bottom: 10px;
}
.mem-search-bar { margin-bottom: 12px; }
.mem-search-bar input {
  width: 100%; padding: 10px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); font-family: inherit; font-size: 0.9rem;
  background: var(--white); transition: border-color 0.2s; box-shadow: var(--shadow);
}
.mem-search-bar input:focus { outline: none; border-color: var(--terracotta); }

.mem-empty {
  padding: 32px 16px; text-align: center;
  color: var(--text-light); font-size: 0.9rem;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.mem-list { display: flex; flex-direction: column; gap: 8px; }
.mem-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 14px 16px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.mem-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.mem-card-main {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--text); flex: 1; min-width: 0;
}
.mem-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--cream-dark);
}
.mem-avatar-init {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--terracotta), var(--green));
  color: var(--white); display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; flex-shrink: 0;
}
.mem-card-info { min-width: 0; }
.mem-card-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem-card-years { font-size: 0.78rem; color: var(--text-light); }
.mem-card-linked { font-size: 0.72rem; color: var(--brown-light); }
.mem-card-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: 8px; }
.mem-action-btn {
  width: 32px; height: 32px; border: none;
  border-radius: 8px; background: var(--cream-dark);
  cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  color: var(--text-light);
}
.mem-action-btn:hover { background: var(--border); color: var(--text); }
.mem-action-danger:hover { background: var(--danger); color: var(--white); }

/* Inline relations under member card */
.mem-card-wrap { display: flex; flex-direction: column; gap: 0; }
.mem-card-wrap .mem-card { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.mem-card-wrap .mem-rels-inline { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.mem-card-wrap:not(:has(.mem-rels-inline)) .mem-card { border-radius: var(--radius-lg); }
.mem-rels-inline {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 16px;
  background: var(--cream);
  border-top: 1px solid var(--cream-dark);
}
.mem-rel-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 6px 3px 10px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 20px; font-size: 0.75rem;
  transition: border-color 0.15s;
}
.mem-rel-chip:hover { border-color: var(--terracotta-light); }
.mem-rel-chip-label { color: var(--text-light); }
.mem-rel-chip-name { color: var(--terracotta); font-weight: 600; text-decoration: none; }
.mem-rel-chip-name:hover { color: var(--terracotta-dark); }
.mem-rel-chip-del {
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-light);
  cursor: pointer; font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.mem-rel-chip-del:hover { background: var(--danger); color: var(--white); }

/* === Tags === */
.tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--cream-dark);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--brown-light);
  font-family: -apple-system, sans-serif;
}
.tag-active {
  background: var(--terracotta);
  color: var(--white);
}

/* === Recipe Detail === */
.recipe-hero {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.recipe-meta {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  font-family: -apple-system, sans-serif;
}
.recipe-meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  background: var(--cream-dark);
  border-radius: var(--radius);
  min-width: 80px;
}
.recipe-meta-item .value { font-size: 1.2rem; font-weight: 600; color: var(--terracotta); }
.recipe-meta-item .label { font-size: 0.75rem; color: var(--text-light); }
.recipe-section { margin-bottom: 28px; }
.recipe-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.recipe-section-head h2 { margin-bottom: 0; }
.instacart-carrot { margin-right: 4px; }
.recipe-section h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
  color: var(--brown);
  border-bottom: 2px solid var(--terracotta-light);
  padding-bottom: 4px;
  display: inline-block;
}
.ingredient-list { list-style: none; }
.ingredient-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.95rem;
}
.instruction-list { list-style: none; counter-reset: step; }
.instruction-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--cream-dark);
  display: flex;
  gap: 12px;
}
.instruction-list li::before {
  counter-increment: step;
  content: counter(step);
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--terracotta);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: bold;
  font-family: -apple-system, sans-serif;
}
.family-story {
  background: var(--cream-dark);
  border-left: 4px solid var(--terracotta);
  padding: 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  line-height: 1.8;
}

/* === Search & Filters === */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-bar input {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}
.search-bar input:focus { outline: none; border-color: var(--terracotta); }
.search-bar select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  background: var(--white);
}
.search-bar select:focus { outline: none; border-color: var(--terracotta); }

/* === Invite Code === */
.invite-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cream-dark);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  letter-spacing: 2px;
  font-weight: bold;
  color: var(--brown);
}

/* === Member List === */
.member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--cream-dark);
}
.member-item:last-child { border-bottom: none; }
.member-info h4 { font-size: 1rem; }
.member-info p { font-size: 0.8rem; color: var(--text-light); font-family: -apple-system, sans-serif; }
.member-actions { display: flex; gap: 4px; }

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
/* Focus visibility for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}
.modal h2 { margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* === Dynamic Ingredients/Instructions === */
.dynamic-list { list-style: none; }
.dynamic-list li {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.dynamic-list li input, .dynamic-list li textarea {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
}
.dynamic-list li textarea { min-height: 50px; resize: vertical; }
.remove-item {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  flex-shrink: 0;
}
.add-item {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 8px;
  width: 100%;
  cursor: pointer;
  color: var(--terracotta);
  font-family: -apple-system, sans-serif;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}
.add-item:hover { border-color: var(--terracotta); }

/* === Loading/Empty States === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
  font-family: -apple-system, sans-serif;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Onboarding === */
.onboard-card {
  text-align: center; padding: 48px 24px;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  max-width: 560px; margin: 40px auto;
}
.onboard-icon { font-size: 3.5rem; margin-bottom: 16px; }
.onboard-card h2 { font-size: 1.5rem; margin-bottom: 8px; }
.onboard-card p { color: var(--text-light); max-width: 420px; margin: 0 auto 24px; line-height: 1.6; }
.onboard-steps {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.onboard-step {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 20px;
  background: var(--cream); color: var(--text-light);
  font-size: 0.82rem; font-weight: 500;
}
.onboard-step.active { background: var(--terracotta); color: #fff; }
.onboard-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
}
.onboard-step.active .onboard-step-num { background: rgba(255,255,255,0.25); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 20px; font-family: -apple-system, sans-serif; }

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-family: -apple-system, sans-serif;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
}
.pagination button:hover { background: var(--cream-dark); }
.pagination button:disabled { opacity: 0.5; cursor: default; }
.pagination .current { background: var(--terracotta); color: var(--white); border-color: var(--terracotta); }

/* === Photo Upload === */
.photo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.photo-upload:hover { border-color: var(--terracotta); }
.photo-upload input { display: none; }
.photo-upload img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
}
.photo-upload .placeholder {
  color: var(--text-light);
  font-family: -apple-system, sans-serif;
}

/* === Member Detail === */
.mem-detail-grid { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
@media (max-width: 768px) { .mem-detail-grid { grid-template-columns: 1fr; } }
.mem-detail-profile {
  text-align: center; background: var(--white);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 24px; position: sticky; top: 24px;
}
.mem-detail-photo-wrap {
  position: relative; display: inline-block; margin: 0 auto;
}
.mem-detail-edit-btn {
  position: absolute; top: 2px; right: 2px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--terracotta); color: var(--white);
  border: 2px solid var(--white); cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: background 0.15s; z-index: 2;
}
.mem-detail-edit-btn:hover { background: var(--terracotta-light); }
[data-theme="dark"] .mem-detail-edit-btn { border-color: var(--cream-dark); }

/* "+" badge on the bottom-right of the photo circle in add/edit member modals */
.member-photo-badge {
  position: absolute; bottom: 0; right: 0;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--terracotta); color: var(--white);
  border: 2px solid var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700;
  pointer-events: none;
}
[data-theme="dark"] .member-photo-badge { border-color: var(--cream-dark); }

.mem-detail-avatar {
  width: 120px; height: 120px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--terracotta-light); margin: 0 auto; display: block;
}
.mem-detail-avatar-init {
  width: 120px; height: 120px; border-radius: 50%;
  background: linear-gradient(135deg, var(--terracotta), var(--green));
  color: var(--white); display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 700; margin: 0 auto;
}
.mem-detail-bio { margin-top: 14px; font-size: 0.9rem; line-height: 1.6; color: var(--text); }
.mem-detail-linked { margin-top: 8px; font-size: 0.78rem; color: var(--text-light); }
.mem-detail-content { display: flex; flex-direction: column; gap: 16px; }
.mem-detail-rel {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--cream-dark);
}
.mem-detail-rel:last-child { border-bottom: none; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--cream-dark);
}
.admin-row:last-child { border-bottom: none; }
.role-badge {
  display: inline-block; font-size: 0.72rem; color: var(--brown-light);
  background: var(--cream-dark); padding: 1px 8px; border-radius: 12px;
  margin-left: 6px; font-family: -apple-system, sans-serif;
}
.role-badge-admin { color: var(--white); background: var(--terracotta); }
[data-theme="dark"] .role-badge { background: #2a3a31; color: #b8c4bb; }
[data-theme="dark"] .role-badge-admin { background: var(--terracotta); color: #fff; }
.mem-detail-rel-main {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); flex: 1;
  transition: background 0.15s; border-radius: var(--radius); padding: 4px;
}
.mem-detail-rel-main:hover { background: var(--cream); }
.mem-rel-type-inline {
  font-size: 0.72rem; color: var(--brown-light);
  background: var(--cream-dark); padding: 1px 8px; border-radius: 12px;
}
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-initials-sm {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--terracotta); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; flex-shrink: 0;
}

/* === Redesigned Recipe Cards === */
.recipe-filters {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.recipe-filter-input {
  flex: 1; min-width: 180px; padding: 10px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); font-family: inherit; font-size: 0.9rem;
  background: var(--white); box-shadow: var(--shadow); transition: border-color 0.2s;
}
.recipe-filter-input:focus { outline: none; border-color: var(--terracotta); }
.recipe-filter-select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  font-family: inherit; font-size: 0.85rem; background: var(--white); box-shadow: var(--shadow);
}
.recipe-filter-select:focus { outline: none; border-color: var(--terracotta); }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.rcard {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.rcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.rcard-img {
  height: 160px; background-size: cover; background-position: center; background-color: var(--cream-dark);
}
.rcard-img-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; color: var(--border);
  background: linear-gradient(135deg, var(--cream-dark), var(--border));
}
.rcard-body { padding: 14px 16px; }
.rcard-body h3 { font-size: 1rem; margin-bottom: 4px; }
.rcard-meta { font-size: 0.8rem; color: var(--text-light); margin-bottom: 6px; }
.rcard-cat {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 12px;
  background: var(--cream-dark); font-size: 0.7rem; color: var(--brown-light); vertical-align: middle;
}
.rcard-time {
  display: inline-block; font-size: 0.75rem; color: var(--terracotta);
  font-weight: 600; margin-right: 8px;
}
.rcard-attr {
  display: inline-block; font-size: 0.72rem; color: var(--text-light); font-style: italic;
}

/* Recipe heart (favorite) icon */
.recipe-heart {
  cursor: pointer; font-size: 1.4rem; transition: color 0.15s;
  line-height: 1; user-select: none;
}
.recipe-heart.favorited { color: #e53e3e; }
.recipe-heart:not(.favorited) { color: var(--text-light); }
.recipe-heart:hover { opacity: 0.8; }

/* Recipe tabs — mirrors .auth-tabs */
.recipe-tabs {
  display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border);
}
.recipe-tabs .tab {
  flex: 0 1 auto;
  padding: 10px 20px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}
.recipe-tabs .tab:hover { color: var(--terracotta); }
.recipe-tabs .tab.active {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
}

/* === Loading Skeletons === */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.skeleton-card {
  height: 220px; border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--cream-dark) 25%, var(--cream) 50%, var(--cream-dark) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton-list { display: flex; flex-direction: column; gap: 8px; }
.skeleton-row {
  height: 66px; border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--cream-dark) 25%, var(--cream) 50%, var(--cream-dark) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}

/* === Toast Notifications === */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 20px; border-radius: var(--radius); color: var(--white);
  font-size: 0.9rem; font-family: inherit; box-shadow: var(--shadow-lg);
  pointer-events: auto; animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 360px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--brown-light); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-action {
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4);
  color: white; padding: 4px 12px; border-radius: 6px; cursor: pointer;
  font-size: 0.8rem; font-weight: 600; font-family: inherit; white-space: nowrap;
}
.toast-action:hover { background: rgba(255,255,255,0.35); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* === Modal Animations === */
.modal-overlay { animation: overlayIn 0.2s ease; }
.modal-overlay .modal { animation: modalIn 0.25s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* === Dark Mode === */
[data-theme="dark"] {
  --cream: #1a1f1c;
  --cream-dark: #252d27;
  --terracotta: #6aad82;
  --terracotta-dark: #4e9468;
  --terracotta-light: #7ab893;
  --brown: #0f1512;
  --brown-light: #8db89e;
  --green: #6aad82;
  --green-dark: #4e9468;
  --text: #e8ece9;
  --text-light: #a4b3a8;
  --border: #3d4f43;
  --white: #1e2621;
  --danger: #e86358;
  --danger-light: #f07e73;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .sidebar { background: #0f1512; }
[data-theme="dark"] .sidebar-header h2 { color: #7ab893; }
[data-theme="dark"] .tree-container { background: #1e2621; }
[data-theme="dark"] .dash-hero,
[data-theme="dark"] .fam-page-hero { background: linear-gradient(135deg, #0f1512, #1a3d28, #2c5f3f); }
/* Ensure text on colored backgrounds stays white */
[data-theme="dark"] .btn-primary { color: #fff; }
[data-theme="dark"] .toast { color: #fff; }
[data-theme="dark"] .fam-page-hero,
[data-theme="dark"] .fam-page-hero h1,
[data-theme="dark"] .fam-page-hero .fam-page-stat,
[data-theme="dark"] .fam-page-hero .fam-page-stat-role { color: #fff; }
[data-theme="dark"] .dash-hero,
[data-theme="dark"] .dash-hero h1,
[data-theme="dark"] .dash-hero p { color: #fff; }
[data-theme="dark"] .mem-avatar-init { color: #fff; }
[data-theme="dark"] .fam-page-icon { color: #fff; }
[data-theme="dark"] .dash-card-icon { color: #fff; }
[data-theme="dark"] .invite-code { color: var(--text); background: var(--cream-dark); }
[data-theme="dark"] .auth-header h1 { color: var(--terracotta); }
[data-theme="dark"] .mem-rel-chip { background: var(--cream-dark); border-color: var(--border); }
[data-theme="dark"] .mem-rel-chip-label { color: var(--text-light); }
[data-theme="dark"] .mem-rels-inline { background: var(--cream); }
[data-theme="dark"] a { color: var(--terracotta); }
[data-theme="dark"] .fam-nav-tile { color: var(--text); }
[data-theme="dark"] .fam-nav-tile:hover { color: var(--terracotta); }
/* Recipe page */
[data-theme="dark"] .rcard-body h3 { color: var(--text); }
[data-theme="dark"] .rcard-meta { color: var(--text-light); }
[data-theme="dark"] .rcard-cat { color: var(--text-light); background: var(--cream-dark); }
[data-theme="dark"] .rcard-time { color: var(--terracotta); }
[data-theme="dark"] .rcard-attr { color: var(--text-light); }
[data-theme="dark"] .recipe-heart:not(.favorited) { color: var(--text-light); }
[data-theme="dark"] .recipe-tabs { border-bottom-color: var(--border); }
[data-theme="dark"] .recipe-tabs .tab { color: var(--text-light); }
[data-theme="dark"] .recipe-tabs .tab.active { color: var(--terracotta); border-bottom-color: var(--terracotta); }
[data-theme="dark"] .recipe-filter-input,
[data-theme="dark"] .recipe-filter-select { background: var(--white); color: var(--text); border-color: var(--border); }
/* Recipe detail text — --brown is near-black in dark mode, must override */
[data-theme="dark"] .recipe-section h2 { color: var(--terracotta); border-color: var(--terracotta); }
[data-theme="dark"] .page-header h1 { color: var(--text); }
[data-theme="dark"] .ingredient-list li { color: var(--text); }
[data-theme="dark"] .instruction-list li { color: var(--text); }
[data-theme="dark"] .family-story { color: var(--text); }
[data-theme="dark"] .invite-code { color: var(--text); }
[data-theme="dark"] .tag { color: var(--text-light); }
[data-theme="dark"] .btn-secondary { color: var(--text); border-color: var(--border); }
[data-theme="dark"] .onboard-card h2,
[data-theme="dark"] .onboard-card p { color: var(--text); }
[data-theme="dark"] .onboard-step { color: var(--text-light); }
/* Hamburger menu button */
[data-theme="dark"] .hamburger { background: var(--terracotta); color: #fff; }
/* Sidebar nav links — active and all states */
[data-theme="dark"] .sidebar-nav a { color: rgba(255,255,255,0.75); }
[data-theme="dark"] .sidebar-nav a:hover,
[data-theme="dark"] .sidebar-nav a.active { color: #fff; background: rgba(255,255,255,0.1); }
[data-theme="dark"] .sidebar-nav .nav-section { color: rgba(255,255,255,0.45); }
[data-theme="dark"] .sidebar-footer a { color: rgba(255,255,255,0.65); }
/* Modal in dark mode */
[data-theme="dark"] .modal { background: var(--white); color: var(--text); }
[data-theme="dark"] .modal h2 { color: var(--text); }
[data-theme="dark"] .form-group label { color: var(--text-light); }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background: var(--cream); color: var(--text); border-color: var(--border); }
/* Member detail in dark mode */
[data-theme="dark"] .mem-detail-bio { color: var(--text); }
[data-theme="dark"] .mem-card-name { color: var(--text); }
[data-theme="dark"] .mem-card-years { color: var(--text-light); }
[data-theme="dark"] .mem-hero h1 { color: var(--text); }
[data-theme="dark"] .mem-hero-sub { color: var(--text-light); }
/* Search bar */
[data-theme="dark"] .mem-search-bar input { background: var(--white); color: var(--text); border-color: var(--border); }
/* Empty states */
[data-theme="dark"] .dash-empty h3 { color: var(--text); }
[data-theme="dark"] .dash-empty p { color: var(--text-light); }
[data-theme="dark"] .fam-card-desc { color: var(--text-light); }
[data-theme="dark"] .fam-card h3 { color: var(--text); }

/* === Bottom tab bar (mobile primary nav) ===
   Hidden on desktop — desktop keeps the sidebar. Shown on mobile when
   router.js populates the hrefs with a valid family id (.has-family
   class). hrefs are blank until then so an unconfigured user doesn't
   navigate into a dead route. */
.bottom-tabs {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: var(--brown);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-tabs .tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 6px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  min-height: 56px;
}
.bottom-tabs .tab.active { color: #fff; }
.bottom-tabs .tab .tab-icon { font-size: 1.35rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.bottom-tabs .tab .tab-label { white-space: nowrap; }
/* Reuun logo standing in for the Dashboard tab icon. Sized to match the
   emoji icons next to it, rounded corners so it reads as an app mark. */
.bottom-tabs .tab .tab-logo { width: 22px; height: 22px; border-radius: 5px; display: block; }

/* === Responsive === */
@media (max-width: 768px) {
  /* Hamburger + sidebar retired on mobile — primary nav lives in the
     bottom tab bar. Sidebar markup is kept in the DOM so desktop still
     works without an HTML fork. */
  .hamburger { display: none; }
  .sidebar { display: none; }
  .bottom-tabs.has-family { display: flex; }
  .main-content { margin-left: 0; padding: max(calc(10px + env(safe-area-inset-top, 0px)), 38px) 16px calc(76px + env(safe-area-inset-bottom, 0px)); }
  .form-row { flex-direction: column; gap: 0; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .recipe-meta { gap: 8px; }
  .search-bar { flex-direction: column; }
  .auth-container { margin: 16px; padding: 24px; }
  .mem-detail-grid { grid-template-columns: 1fr; }
  .mem-detail-profile { position: static; }
  .mem-hero { flex-direction: column; align-items: stretch; }
  .mem-hero-actions { justify-content: stretch; }
  .mem-hero-actions .btn { flex: 1 1 0; min-width: 0; }
}
