/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Warm Sage (v1.0 redesign, 2026-07-19) — replaces the cream/terra/olive
     "Direction B" palette from the prior UI pass, which the user found
     dated/too busy ahead of the 1.0 launch. See DESIGN_HANDOFF.md. */
  --primary:       #7a9984;
  --primary-hover: #6a8974;
  --primary-light: #f0f5f3;
  --text-dark:     #2d3d34;
  --text-muted:    #666666;
  --border:        #e5e5e5;
  --bg-light:      #f9faf8;
  --white:         #ffffff;
  /* Dedicated warning/danger colors, kept independent of --primary — sage
     has no natural "needs attention" connotation the way terra did, so the
     event-slot "needs more" state and real error banners keep a warm color
     instead of collapsing into the same color as "complete"/success. */
  --warn:          #B45A33;
  --warn-bg:       #F6E2D8;
  --danger:        #c0392b;
  --ink-line:      var(--border);

  /* semantic aliases — kept so the rules below don't all need renaming */
  --ink:        var(--text-dark);
  --ink-soft:   var(--text-muted);
  --ink-muted:  var(--text-muted);
  --ink-faint:  #999999;
  --amber:      var(--primary);
  --amber-lt:   var(--primary-hover);
  --accent-2:   var(--primary-hover);
  --accent-2-lt:var(--primary);
  --cream:      var(--white);
  --espresso:      var(--text-dark);
  --espresso-soft: var(--text-muted);
  --parchment:  var(--white);
  --parchment-d:var(--bg-light);
  --parchment-dd:var(--primary-light);
  --rule:       var(--border);
  --rule-soft:  rgba(0,0,0,.04);
  --bark:       var(--text-dark);
  --bark-mid:   var(--primary);
  --green:      var(--primary-hover);
  --green-lt:   var(--primary-light);
  --green-rule: #cfe0d6;
  --red:        var(--danger);
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --shadow:       0 1px 3px rgba(0,0,0,.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:    0 10px 24px rgba(0,0,0,.15);
}
html, body { height: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--parchment);
  color: var(--ink);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}
button { cursor: pointer; font-family: inherit; }
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input, textarea, select {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
}
textarea { resize: vertical; }

/* ── Toast ──────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: var(--parchment);
  font-family: 'DM Mono', monospace; font-size: 12px;
  padding: 10px 20px; border-radius: 6px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0; z-index: 9999; pointer-events: none; white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── App Shell ──────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }
#topbar {
  background: var(--cream);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px; flex-shrink: 0;
  border-bottom: 1px solid var(--ink-line);
  z-index: 100;
}
.logo {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 600;
  color: var(--espresso); letter-spacing: 0.08em;
}
.logo span { color: var(--primary); }
.logo sub {
  font-family: 'DM Mono', monospace;
  font-size: 9px; letter-spacing: 0.12em;
  color: var(--ink-faint); vertical-align: super;
  text-transform: lowercase; font-weight: 400;
  margin-left: 4px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius); padding: 7px 13px;
  font-size: 12px; font-weight: 500; border: none;
  transition: opacity 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-ghost {
  background: transparent; color: var(--text-dark);
  border: 1px solid var(--border); font-family: 'DM Sans', sans-serif; font-weight: 500;
}
.btn-ghost:hover { opacity: 1; background: var(--bg-light); }
.btn-amber { background: var(--primary); color: #fff; }
.btn-amber:hover { opacity: 1; background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* Recipes/Events section nav (was client-side tabs, now real links) */
.section-nav { display:flex; gap:4px; background: rgba(46,38,32,0.05); border:1px solid var(--ink-line); border-radius:7px; padding:3px; }
.section-nav a {
  background:transparent; border:none; color: var(--espresso-soft);
  font-family:'DM Sans',sans-serif; font-size:13px;
  padding:6px 14px; border-radius:5px; text-decoration:none; display:inline-block;
}
.section-nav a:hover { background: rgba(46,38,32,0.08); text-decoration:none; }
.section-nav a.active { background: var(--amber); color: #fff; font-weight:500; }

.cb-switcher {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: rgba(46,38,32,0.05); border: 1px solid var(--ink-line);
  border-radius: 7px; padding: 6px 12px; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--espresso);
  transition: background 0.15s;
}
.cb-switcher:hover { background: rgba(46,38,32,0.09); }
.cb-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 240px; background: var(--parchment); border: 1px solid var(--rule);
  border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 150;
  overflow: hidden; padding: 6px;
}
.cb-menu.open { display: block; }
.cb-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 13px;
}
.cb-menu-item:hover { background: var(--parchment-d); }
.cb-menu-item.active { background: var(--parchment-dd); font-weight: 500; }
.cb-menu-item .cb-cover {
  width: 28px; height: 28px; border-radius: 5px; object-fit: cover;
  background: var(--rule-soft); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink-faint);
}
.cb-menu-item .cb-meta { flex: 1; min-width: 0; }
.cb-menu-item .cb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-menu-item .cb-role {
  font-family: 'DM Mono', monospace; font-size: 9px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.cb-menu-divider { height: 1px; background: var(--rule); margin: 6px 4px; }
.cb-menu-action {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 6px; cursor: pointer; color: var(--amber); font-size: 13px;
  font-family: 'DM Mono', monospace;
}
.cb-menu-action:hover { background: var(--parchment-d); }
.user-chip {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-faint); font-family: 'DM Mono', monospace; font-size: 11px;
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bark-mid); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500;
}

/* ── Fresh from the Kitchen (bell + panel) ─────────────── */
.bell-btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 7px; border: none;
  background: rgba(46,38,32,0.05); color: var(--espresso-soft); font-size: 16px;
  transition: background 0.15s;
}
.bell-btn:hover { background: rgba(46,38,32,0.09); }
.bell-dot {
  display: none; position: absolute; top: 5px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 1.5px solid var(--cream);
}
.bell-dot.show { display: block; }
.fresh-panel {
  display: none; position: fixed; top: 60px; right: 20px;
  width: 320px; max-width: calc(100vw - 40px); max-height: 420px; background: var(--parchment);
  border: 1px solid var(--rule); border-radius: 8px; box-shadow: var(--shadow-lg);
  z-index: 150; overflow: hidden; flex-direction: column;
}
.fresh-panel.open { display: flex; }
.fresh-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--rule);
  font-family: 'Playfair Display', serif; font-weight: 600; font-size: 14px;
}
.fresh-panel-list { overflow-y: auto; padding: 6px; flex: 1; }
.fresh-item { padding: 9px 10px; border-radius: 6px; }
.fresh-item:hover { background: var(--parchment-d); }
.fresh-item-title { font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 2px; }
.fresh-item-date {
  font-family: 'DM Mono', monospace; font-size: 10px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.fresh-item-body { font-size: 12px; color: var(--ink-soft); margin-top: 4px; line-height: 1.5; }
.fresh-empty { padding: 24px 14px; text-align: center; color: var(--ink-faint); font-size: 12px; }
.fresh-panel-foot {
  padding: 10px 14px; border-top: 1px solid var(--rule); text-align: center;
  font-family: 'DM Mono', monospace; font-size: 11px;
}

/* ── Shared section header (recipes toolbar + events toolbar) ── */
.section-head {
  font-family: 'Playfair Display', serif;
  font-size: 18px; color: var(--ink);
  display: flex; align-items: baseline; gap: 8px; flex: 1;
}
.section-head span {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--ink-faint); font-weight: 400;
}

/* ── Shared detail-view topbar (recipe detail + event detail) ── */
.detail-topbar {
  background: var(--cream); display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px; height: 52px;
  border-bottom: 1px solid var(--ink-line); position: sticky; top: 0; z-index: 10;
}
.back-btn {
  display: flex; align-items: center; gap: 7px;
  color: var(--espresso-soft); font-family: 'DM Mono', monospace; font-size: 12px;
  background: none; border: none;
}
.back-btn i { font-size: 15px; }
.detail-actions { display: flex; align-items: center; gap: 8px; }
.btn-outline {
  background: transparent; border: 1px solid var(--ink-line);
  color: var(--espresso-soft); border-radius: 6px; padding: 6px 12px;
  font-family: 'DM Mono', monospace; font-size: 12px;
  display: inline-flex; align-items: center; gap: 5px;
}
.section-lbl {
  font-family: 'DM Mono', monospace; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-lbl::after {
  content: ''; flex: 1; height: 1px; background: var(--rule);
}

/* ── Modals ─────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(46,38,32,0.55);
  z-index: 300; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
/* Opens on top of another already-open modal (e.g. the Host upgrade prompt
   triggered by the Class toggle inside the New Event modal) — same-z-index
   siblings stack by DOM order otherwise, and this one comes first in markup. */
#upgrade-modal { z-index: 350; }
.modal {
  background: var(--parchment); border-radius: var(--radius-lg);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--rule);
}
.modal-title {
  font-family: 'Playfair Display', serif; font-weight: 600; font-size: 20px; color: var(--ink);
}
.modal-close {
  background: none; border: none; color: var(--ink-faint); font-size: 20px;
}
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 8px;
}
.field input, .field select, .field textarea {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; color: var(--ink); font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px rgba(122,153,132,0.1);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--rule);
  display: flex; justify-content: flex-end; gap: 8px;
}
.btn-cancel {
  background: var(--parchment-d); border: 1px solid var(--rule);
  color: var(--ink-soft); border-radius: 6px; padding: 8px 16px; font-size: 13px;
}
.btn-save { background: var(--amber); color: #fff; border: none; border-radius: 6px; padding: 8px 18px; font-size: 13px; font-weight: 500; }
.btn-save.btn-danger { background: var(--red); }

/* ── Cookbook empty state ───────────────────────────── */
#cb-empty {
  display: none; position: fixed; inset: 0; z-index: 450;
  background: var(--bark); align-items: center; justify-content: center; padding: 20px;
}
#cb-empty.open { display: flex; }
.cb-empty-box {
  background: var(--parchment); border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 440px; text-align: center; box-shadow: var(--shadow-lg);
}
.cb-empty-logo {
  font-family: 'Playfair Display', serif; font-size: 32px; font-weight: 600;
  color: var(--ink); letter-spacing: 0.08em;
}
.cb-empty-logo span { color: var(--amber); }
.cb-empty-tag {
  font-family: 'DM Mono', monospace; font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.1em; margin-bottom: 24px;
}
.cb-empty-head {
  font-family: 'Playfair Display', serif; font-size: 20px; color: var(--ink); margin-bottom: 10px;
}
.cb-empty-sub {
  font-size: 13px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 24px;
}

/* ── Members list ───────────────────────────────────── */
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px dashed var(--rule-soft);
}
.member-row:last-child { border-bottom: none; }
.member-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--bark-mid);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; flex-shrink: 0;
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13px; color: var(--ink); }
.member-email { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--ink-faint); }
.member-role {
  font-family: 'DM Mono', monospace; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 2px 8px; border-radius: 3px;
  background: var(--parchment-d); color: var(--ink-faint);
}
.member-role.owner { background: var(--amber); color: #fff; }
.member-remove, .member-promote {
  background: transparent; border: 1px solid var(--rule); border-radius: 5px;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); flex-shrink: 0;
}
.member-remove:hover { color: var(--red); border-color: var(--red); }
.member-promote:hover { color: var(--amber); border-color: var(--amber); }

/* ── Join preview card ──────────────────────────────── */
.join-card {
  background: var(--parchment-d); border: 1px solid var(--rule);
  border-radius: 10px; padding: 16px; text-align: center; margin-top: 4px;
}
.join-card-name {
  font-family: 'Playfair Display', serif; font-size: 18px; color: var(--ink); margin-bottom: 12px;
}
.join-note, .join-error {
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--ink-faint);
}
.join-error { color: var(--red); margin-top: 8px; }

/* ── Footer ─────────────────────────────────────────── */
#mise-footer {
  background: var(--bark);
  border-top: 1px solid rgba(232,217,195,.16);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-brand {
  font-family: 'Playfair Display', serif;
  font-size: 12px;
  color: var(--cream);
  letter-spacing: 0.04em;
}
.footer-brand span { color: var(--amber-lt); }
.footer-legal {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: rgba(232,217,195,.6);
  line-height: 1.6;
  text-align: right;
}
.footer-legal a {
  color: rgba(232,217,195,.6);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-legal a:hover { color: var(--cream); }

/* ── Login Screen ───────────────────────────────────── */
#login-screen {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: var(--bark); align-items: center; justify-content: center;
}
#login-screen.open { display: flex; }
.login-box {
  background: var(--parchment); border-radius: var(--radius-lg);
  padding: 40px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo {
  font-family: 'Playfair Display', serif; font-size: 36px;
  font-weight: 600; color: var(--ink); letter-spacing: 0.08em; margin-bottom: 4px;
}
.login-logo span { color: var(--amber); }
.login-tagline {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--ink-faint); letter-spacing: 0.1em; margin-bottom: 28px;
}
.login-box .field { text-align: left; }
.login-box .field input {
  background: var(--parchment-d); border: 1px solid var(--rule);
  border-radius: 6px; padding: 11px 14px; width: 100%; font-size: 14px;
}
.login-box .field input:focus { border-color: var(--amber); outline: none; }
.btn-login {
  width: 100%; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); padding: 12px;
  font-size: 14px; font-weight: 500; margin-top: 8px;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn-login:hover {
  background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-hover);
}
.login-error {
  font-family: 'DM Mono', monospace; font-size: 12px;
  color: var(--red); margin-top: 8px; display: none;
}
.login-error.show { display: block; }
.login-note {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--ink-faint); margin-top: 20px; line-height: 1.6;
}

/* ── RESPONSIVE / MOBILE (shared chrome only) ───────── */
@media (max-width: 768px) {
  #topbar { padding: 6px 12px; height: auto; min-height: 48px; flex-wrap: wrap; }
  /* .section-nav lives inside #topbar's first child (logo + cb-switcher wrapper),
     not as a direct sibling of .topbar-right — that inner group needs to wrap
     too, or the order/width rule below has nothing to wrap onto. */
  #topbar > div:first-child { flex-wrap: wrap; row-gap: 6px; }
  .logo { font-size: 19px; }
  .cb-switcher { padding: 5px 9px; font-size: 12px; max-width: 140px; }
  #cb-current-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-chip span { display: none; }            /* avatar only on mobile */
  .btn .btn-sm, .topbar-right .btn { padding: 6px 9px; }
  .topbar-right .btn span,
  .topbar-right .btn { font-size: 0; }           /* icon-only buttons */
  .topbar-right .btn i { font-size: 15px; }
  .section-nav { order: 3; width: 100%; margin-top: 6px; }

  .section-head { font-size: 16px; }

  .detail-topbar { padding: 0 12px; }

  .modal { max-width: 100%; max-height: 94vh; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .field-row { grid-template-columns: 1fr; }     /* stack paired fields */

  #mise-footer { flex-direction: column; gap: 4px; text-align: center; padding: 8px 12px; }
  .footer-legal { text-align: center; }

  .cb-menu { min-width: 220px; }
}
