/* Layout: sticky filter rail on the left, toolbar + card grid on the right, detail drawer slides in from the right. */
:root {
  --paper: #f3f4ef;
  --surface: #ffffff;
  --ink: #1c231f;
  --muted: #5d6860;
  --line: #dde0d8;
  --herb: #2f6b4f;
  --herb-soft: #e3eee7;
  --tomato: #c4432b;
  --tomato-soft: #f8e6e1;
  --gold: #b7791f;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --shadow: 0 1px 2px rgba(28,35,31,.06), 0 4px 14px rgba(28,35,31,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141816; --surface: #1c211e; --ink: #e8ece7; --muted: #9aa69e; --line: #2e3631;
    --herb: #7cc39e; --herb-soft: #1f3329; --tomato: #ec7a62; --tomato-soft: #3a221c; --gold: #e2b25a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141816; --surface: #1c211e; --ink: #e8ece7; --muted: #9aa69e; --line: #2e3631;
  --herb: #7cc39e; --herb-soft: #1f3329; --tomato: #ec7a62; --tomato-soft: #3a221c; --gold: #e2b25a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--herb); outline-offset: 2px; }
.app { display: grid; grid-template-columns: 290px 1fr; min-height: 100%; }

/* Rail */
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 20px 18px 40px; }
.brand { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.brand h1 { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.rail-actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rail-actions .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--herb); font-weight: 600; cursor: pointer; font-size: 13px; }
.linkbtn:disabled { color: var(--muted); cursor: default; opacity: .6; }
.group { border-top: 1px solid var(--line); padding: 10px 0; }
.group > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 14px; padding: 4px 0; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "+"; font-family: var(--mono); color: var(--muted); }
.group[open] > summary::after { content: "–"; }
.group .hint { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.group .sel-count { margin-left: auto; font-size: 12px; background: var(--herb); color: var(--surface); border-radius: 999px; padding: 0 7px; font-weight: 700; }
.opts { display: flex; flex-direction: column; gap: 1px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.opt:hover { background: var(--herb-soft); }
.opt input { accent-color: var(--herb); margin: 0; width: 15px; height: 15px; flex: none; }
.opt .name { flex: 1; min-width: 0; }
.opt .n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt.zero { opacity: .42; }
.opt.on .name { font-weight: 600; }
.group .more { margin-top: 4px; }
.group .gsearch { width: 100%; margin: 4px 0 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-size: 13px; }
.toggle-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; cursor: pointer; }
.toggle-row input { accent-color: var(--tomato); width: 15px; height: 15px; margin: 0; }
.note { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }

/* Main */
.main { min-width: 0; padding: 20px 28px 60px; display: flex; flex-direction: column; gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { flex: 1 1 320px; position: relative; }
.search input { width: 100%; padding: 11px 14px 11px 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; box-shadow: var(--shadow); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.ctl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.ctl select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 14px; }
.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: var(--herb); }
.btn.primary { background: var(--herb); border-color: var(--herb); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.filters-btn { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 8px 10px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--herb-soft); color: var(--herb); }

.courses { display: flex; gap: 8px; flex-wrap: wrap; }
.course-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.course-chip .n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.course-chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.course-chip[aria-pressed="true"] .n { color: var(--paper); opacity: .75; }
.course-chip.zero { opacity: .45; }

.status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); min-height: 30px; }
.status strong { color: var(--ink); font-family: var(--display); font-size: 18px; }
.active-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 10px; border-radius: 999px; background: var(--herb-soft); color: var(--herb); font-size: 13px; font-weight: 600; border: 0; cursor: pointer; }
.active-chip span.x { font-family: var(--mono); padding: 0 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 0 12px; overflow: hidden; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); cursor: pointer; position: relative; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--herb); transform: translateY(-1px); }
.card .course-stripe { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--c, var(--herb)); z-index: 2; }
.photo { position: relative; aspect-ratio: 3 / 2; background: var(--line); overflow: hidden; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .photo img { transform: scale(1.04); }
.photo.none { display: grid; place-items: center; background: linear-gradient(135deg, var(--c, var(--herb)), color-mix(in srgb, var(--c, var(--herb)) 55%, var(--ink))); color: #fff; }
.photo.none .ph { font-family: var(--display); font-weight: 700; font-size: 15px; opacity: .9; padding: 0 16px; text-align: center; }
.photo .badge { position: absolute; left: 10px; bottom: 10px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--tomato); color: #fff; }
.photo .tbadge { position: absolute; right: 10px; bottom: 10px; font-family: var(--mono); font-size: 12px; padding: 2px 7px; border-radius: 6px; background: rgba(20,24,22,.78); color: #fff; font-variant-numeric: tabular-nums; }
.card .inner { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .kicker { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.card h3 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.2; text-wrap: balance; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--muted); align-items: center; }
.time { font-family: var(--mono); font-size: 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-variant-numeric: tabular-nums; }
.stars { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.votes { font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 5px; background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
.tag.loved { background: var(--tomato-soft); color: var(--tomato); border-color: transparent; font-weight: 700; }
.fav { position: absolute; top: 10px; right: 10px; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; line-height: 0; z-index: 3; }
.card .fav { background: rgba(255,255,255,.92); color: #1c231f; border-radius: 999px; padding: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.card .fav[aria-pressed="true"] { color: #c4432b; }
.fav[aria-pressed="true"] { color: var(--tomato); }
.fav:hover { background: var(--paper); }
.card .fav:hover { background: #fff; }

.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: grid; grid-template-columns: 28px 54px minmax(0, 2.4fr) 1.2fr 1fr 80px 120px; gap: 12px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--herb-soft); }
.row.head { cursor: default; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--paper); }
.row.head:hover { background: var(--paper); }
.row .t { font-weight: 600; }
.thumb { width: 54px; height: 36px; border-radius: 5px; object-fit: cover; display: block; background: var(--line); }
.thumb.none { background: var(--c, var(--herb)); }
.row .fav { position: static; }
.row .c, .row .cu { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 50px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; }
.empty h2 { font-family: var(--display); color: var(--ink); margin: 0 0 6px; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(10,14,12,.35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(460px, 100%); background: var(--surface); border-left: 1px solid var(--line); z-index: 31; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer header { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer header h2 { font-family: var(--display); font-size: 24px; line-height: 1.15; margin: 4px 0 0; flex: 1; text-wrap: balance; }
.drawer .close { background: none; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; flex: none; }
.hero { margin: -16px -20px 0; aspect-ratio: 3 / 2; background: var(--line); }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drawer .body { padding: 16px 20px 30px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--paper); border-radius: 10px; padding: 10px; }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.fact .v { font-family: var(--display); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fact .s { font-size: 12px; color: var(--muted); }
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pill { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 1px 9px; font-size: 13px; cursor: pointer; }
.pill:hover { border-color: var(--herb); color: var(--herb); }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.similar h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.similar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.similar li button { width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.similar li button:hover { background: var(--herb-soft); }
.similar .time { flex: none; }
.caveat { font-size: 13px; color: var(--muted); background: var(--paper); padding: 10px 12px; border-radius: 8px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 40; top: 0; left: 0; width: min(320px, 88%); height: 100%; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .rail.open { transform: none; }
  .filters-btn { display: inline-flex; }
  .main { padding: 16px 16px 50px; }
  .row { grid-template-columns: 28px 54px minmax(0, 1fr) 70px; }
  .row .c, .row .cu, .row .r { display: none; }
  .facts { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Mealie browse view additions */
.brand-links { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.brand-links .btn { text-decoration: none; }
.brand-links .linkbtn { text-decoration: none; }
.blurb { margin: 0; color: var(--muted); line-height: 1.5; }
.load-error { padding: 1rem; margin: 1rem; background: var(--tomato-soft); color: var(--tomato); border-radius: 8px; }
