/* ============================================================
   MyLifeInMilan — red / black / white.
   Black sidebar chrome, cream workspace, white cards, red as the
   single accent. No logos — a wordmark + a small red mark.
   ============================================================ */

/* ---------- Self-hosted fonts (kills the font FOUC + the Google-Fonts privacy leak)
   Montserrat (body/UI) and Bitcount Single (the wordmark) were loaded from Google's
   render-blocking stylesheet, so text flashed in a fallback font then snapped — very
   visible in the sidebar wordmark and the landing hero. Serving them same-origin (and
   preloading the latin files in base.html) means they're ready at first paint.
   Montserrat is a variable font: one file covers weights 200–700. `swap` keeps a
   graceful fallback if a file is ever slow. Material Symbols stays on Google (display=block
   already hides its glyphs until loaded, so it doesn't flash text). ---------- */
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 200 700; font-display: swap;
  src: url("../fonts/montserrat-latin.311d352d9323.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 200 700; font-display: swap;
  src: url("../fonts/montserrat-latinext.d16dfe26bcd7.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bitcount Single"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/bitcount-single-latin.26dab3263e94.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bitcount Single"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/bitcount-single-latinext.ccc1b0863c94.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Material Symbols, SELF-HOSTED + SUBSET to only the ~53 icons we use (the full Google font is
   3.9 MB, which loaded slowly and left the sidebar icons blank for seconds = the FOUC). This is
   a 56 KB subset built by pruning the ligature table to our icon names, so the icon ligatures
   ("today", "map", …) still resolve. Variable axes kept (FILL 0/1, wght) so filled/weighted
   icons still work. Preloaded in base.html -> ready at first paint. To refresh after adding a NEW
   icon name to a template, re-run the subset (see the commit that introduced static/fonts). */
@font-face {
  font-family: "Material Symbols Outlined"; font-style: normal; font-weight: 100 700; font-display: block;
  src: url("../fonts/material-symbols-subset.9ba5db428414.woff2?v=9") format("woff2");
}

:root {
  /* ---------- Palette: red / black / white ---------- */
  --red:        #E11D2A;            /* the one accent: active nav, CTAs, "near" */
  --red-dark:   #B3141F;            /* hover / pressed */
  --red-soft:   rgba(225, 29, 42, 0.10);
  --red-ring:   rgba(225, 29, 42, 0.30);

  --ok:         #2E7D52;            /* success (toasts) */
  --warn:       #B26A00;            /* warning (toasts) */

  --ink:        #161519;            /* near-black: sidebar, headings, body text */
  --ink-2:      #232227;            /* sidebar hover */
  --ink-3:      #2D2C33;            /* sidebar active surface */

  --paper:      #FFFFFF;            /* cards / panels */
  --cream:      #F6F5F2;            /* workspace background */
  --cream-2:    #EFEEEA;            /* subtle fills, input rest */

  --text:       #161519;
  --muted:      rgba(22, 21, 25, 0.60);
  --faint:      rgba(22, 21, 25, 0.42);
  --line:       rgba(22, 21, 25, 0.13);
  --line-soft:  rgba(22, 21, 25, 0.07);

  --sidebar-fg:    rgba(255, 255, 255, 0.74);
  --sidebar-fg-on: #FFFFFF;

  /* ---------- Spacing (8px scale + 4px half-step) ---------- */
  --space-xxs: 4px;  --space-xs: 8px;  --space-s: 12px;
  --space-m: 16px;   --space-l: 24px;  --space-xl: 32px;  --space-xxl: 40px;

  /* ---------- Radii ---------- */
  --radius-s: 6px;  --radius-m: 12px;  --radius-l: 18px;  --radius-pill: 999px;

  /* ---------- Shadows (subtle) ---------- */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-s:  0 1px 2px rgba(0,0,0,0.05), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-m:  0 2px 4px rgba(0,0,0,0.05), 0 10px 24px -6px rgba(0,0,0,0.12);

  /* ---------- Motion ---------- */
  --ease:        cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-reveal: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 140ms var(--ease);
  --t:      220ms var(--ease);

  /* ---------- Layout ---------- */
  --sidebar-w: clamp(228px, 18vw, 272px);
  --content-max: 1440px;
  --topbar-h: 60px;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--ink); letter-spacing: -0.02em; line-height: 1.12; margin: 0; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 3px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(22,21,25,0.22); border-radius: 999px; border: 3px solid var(--cream); }
::-webkit-scrollbar-thumb:hover { background: rgba(22,21,25,0.36); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ---------- Material Symbols ---------- */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal; font-style: normal; line-height: 1;
  display: inline-block; vertical-align: middle; white-space: nowrap; direction: ltr;
  /* These four guard the icon LIGATURES and used to come from Google's stylesheet (now that the
     font is self-hosted, we must set them ourselves). Without text-transform:none a parent
     `text-transform: uppercase` (e.g. the distance filter) uppercases the ligature text
     "directions_walk" -> no match -> the raw word shows instead of the icon. letter-spacing +
     word-wrap:normal stop spacing from splitting a ligature; font-feature-settings:'liga'
     keeps ligatures on. */
  letter-spacing: normal; text-transform: none; word-wrap: normal;
  font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Pixel-art utilities ----------
   Montserrat carries everything; "Bitcount Single" is a spot face used only for
   the wordmark and a few retro labels. .pixel-perfect keeps low-res sprites
   crisp at any scale (browsers smooth-scale <img> by default). */
.pixel-perfect { image-rendering: pixelated; image-rendering: crisp-edges; }
.font-pixel { font-family: "Bitcount Single", "Montserrat", system-ui, sans-serif; letter-spacing: 0; }

/* ============================================================
   LAYOUT — sidebar + main
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  max-width: calc(100vw - 52px);
  background: var(--ink); color: #fff;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px; gap: 14px;
  position: fixed; inset: 0 auto 0 0; z-index: 100;
  overflow-y: auto;
  transition: transform var(--t);
}

/* Brand — pixel spritz logo on a light tile + Bitcount Single wordmark.
   The tile keeps the dark-outlined sprite legible on the dark sidebar. */
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand__mark { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; padding: 3px; background: #fff; border-radius: 7px; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.brand__mark img { width: 100%; height: 100%; display: block; }
.brand__name { font-family: "Bitcount Single", "Montserrat", system-ui, sans-serif; font-weight: 400; font-size: 1.18rem; letter-spacing: 0.02em; color: #fff; line-height: 1; }
.brand__name b { color: var(--red); font-weight: 400; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav--main { flex: 1 1 auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-m);
  color: var(--sidebar-fg); font-weight: 500; font-size: 0.95rem;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a .material-symbols-outlined { font-size: 21px; opacity: 0.85; flex-shrink: 0; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.is-active { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 0 var(--red); }
.nav a.is-active .material-symbols-outlined { opacity: 1; color: var(--red); }
.nav__divider { border: 0; border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 2px; }

.sidebar__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 8px; }
.userline { display: flex; align-items: center; gap: 10px; padding: 4px 8px; min-width: 0; }
.userline__avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.userline__name { font-size: 0.78rem; color: rgba(255,255,255,0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: transparent; color: var(--sidebar-fg); font: inherit; font-weight: 500; cursor: pointer; border-radius: var(--radius-m); text-align: left; transition: background var(--t-fast), color var(--t-fast); }
.signout .material-symbols-outlined { font-size: 21px; opacity: 0.85; }
.signout:hover { background: var(--ink-2); color: #fff; }

/* Main column */
.main { flex: 1 1 auto; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

/* Top bar holds only the mobile menu toggle now, so it's hidden on desktop
   (re-shown in the ≤1024px query below) — no empty sticky strip eating space. */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h); display: none; align-items: center; gap: 14px;
  padding: 0 clamp(16px, 3vw, 36px);
  background: rgba(246,245,242,0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.hamburger { display: none; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--paper); cursor: pointer; color: var(--ink); }
.topbar__spacer { flex: 1 1 auto; }

.locchip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--radius-pill);
  background: var(--paper); border: 1px solid var(--line);
  font-size: 0.85rem; font-weight: 600; color: var(--ink);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.locchip .material-symbols-outlined { font-size: 18px; color: var(--red); }
.locchip:hover { border-color: var(--red); }
.locchip--empty { color: var(--muted); font-weight: 500; }
.locchip--empty .material-symbols-outlined { color: var(--muted); }

.content { flex: 1 1 auto; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: clamp(20px, 3vw, 34px) clamp(16px, 3vw, 36px) 56px; }

/* ---------- Page head ---------- */
.content > h1, .page-head h1 { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 700; }
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: clamp(14px, 2vw, 22px);
}
.page-head h1,
.page-head .page-title,
.page-head .feed-title { margin: 0; }
.sub { color: var(--muted); margin: 6px 0 22px; font-size: 0.95rem; }
.sub strong { color: var(--ink); }

/* ---------- Toast notifications (see static/js/toast.js) ---------- */
.toast-container {
  position: fixed; top: calc(var(--topbar-h) + 12px); right: 18px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(380px, calc(100vw - 36px)); pointer-events: none;
}
.toast {
  pointer-events: auto; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-m); box-shadow: var(--shadow-m); overflow: hidden;
  animation: toast-enter 0.22s var(--ease); position: relative;
}
.toast.toast-exit { animation: toast-exit 0.22s var(--ease) forwards; }
.toast-header { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; }
.toast-icon { font-size: 22px !important; flex-shrink: 0; margin-top: 1px; }
.toast-icon-success { color: var(--ok); }
.toast-icon-error { color: var(--red); }
.toast-icon-info { color: var(--ink); }
.toast-icon-warning { color: var(--warn); }
.toast-text { flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 500; color: var(--ink); line-height: 1.4; }
.toast-close-btn { background: transparent; border: 0; cursor: pointer; color: var(--faint); padding: 1px; display: inline-flex; align-items: center; flex-shrink: 0; transition: color var(--t-fast); }
.toast-close-btn:hover { color: var(--ink); }
.toast-close-btn .material-symbols-outlined { font-size: 18px; }
.toast-progress { height: 2px; width: 100%; transform-origin: left center; animation: toast-progress linear forwards; background: var(--ink); }
.toast-success .toast-progress { background: var(--ok); }
.toast-error .toast-progress { background: var(--red); }
.toast-warning .toast-progress { background: var(--warn); }
@keyframes toast-enter { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-exit { to { transform: translateX(16px); opacity: 0; } }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ============================================================
   FEED — filters + cards + reference sidebar
   ============================================================ */
.page-with-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: clamp(18px, 2.4vw, 32px); align-items: start; }
.feed-shell { display: block; }
.feed-filters { min-width: 0; }
.feed-results { min-width: 0; }
/* During an AJAX filter swap the results dim briefly instead of the whole page reloading. */
.feed-results.is-loading { opacity: 0.5; transition: opacity 0.12s ease; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .feed-results.is-loading { transition: none; } }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 16px; margin: 0 0 26px; box-shadow: var(--shadow-s);
}
.filters label { display: flex; flex-direction: column; gap: 5px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.filters input, .filters select {
  font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--cream-2); border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 8px 10px; min-width: 150px; max-width: 100%; transition: border-color var(--t-fast), background var(--t-fast);
}
.filters input:focus, .filters select:focus { outline: none; background: var(--paper); border-color: var(--red); }
.filters button { align-self: end; }

/* Interest picker — tri-state, expandable. Sits inline among the other filters. */
.interest-picker { position: relative; display: flex; flex-direction: column; gap: 5px; }
.interest-picker__caption { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.interest-picker__toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-size: 0.9rem; color: var(--ink); text-align: left;
  background: var(--cream-2); border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 8px 10px; min-width: 180px; transition: border-color var(--t-fast), background var(--t-fast);
}
.interest-picker__toggle:hover { background: var(--paper); border-color: var(--line); }
.interest-picker.is-active .interest-picker__toggle { border-color: var(--red); background: var(--paper); }
.interest-picker__toggle > .material-symbols-outlined { font-size: 18px; color: var(--red); }
.interest-picker__summary { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.interest-picker__caret { font-size: 18px; color: var(--faint); transition: transform var(--t-fast); }
.interest-picker__toggle[aria-expanded="true"] .interest-picker__caret { transform: rotate(180deg); }
.interest-picker__panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  width: min(420px, 86vw);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: var(--shadow-m); padding: 14px;
}
.interest-picker__hint { margin: 0 0 10px; font-size: 0.78rem; color: var(--muted); }
.interest-picker__chips { display: flex; flex-wrap: wrap; gap: 7px; }
.interest-chip {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font: inherit; font-size: 0.82rem; line-height: 1; color: var(--ink);
  background: var(--cream-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 11px; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.interest-chip:hover { border-color: var(--faint); }
.interest-chip__icon { font-size: 15px; color: var(--faint); }
/* "Show only these" — selected/included. */
.interest-chip[data-state="in"] { background: var(--red); border-color: var(--red); color: #fff; }
.interest-chip[data-state="in"] .interest-chip__icon { color: #fff; }
/* "Hide these" — excluded. */
.interest-chip[data-state="out"] { background: transparent; border-color: var(--faint); color: var(--muted); text-decoration: line-through; }
.interest-chip[data-state="out"] .interest-chip__icon { color: var(--muted); text-decoration: none; }
/* Interests chips carry the category's own colour (icon + a soft tint when included), mirroring
   the Map palette, instead of the plain red used by the Source picker. */
.interest-chip--cat .interest-chip__icon { font-size: 16px; color: var(--cat, var(--faint)); }
.interest-chip--cat[data-state="in"] {
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  border-color: color-mix(in srgb, var(--cat) 50%, transparent); color: var(--ink); text-decoration: none;
}
.interest-chip--cat[data-state="in"] .interest-chip__icon { color: var(--cat); }
.interest-chip--cat[data-state="out"] { opacity: 0.5; }
.interest-chip--cat[data-state="out"] .interest-chip__icon { color: var(--cat); filter: grayscale(1); }
.interest-picker__actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--red); }
.linklike:hover { text-decoration: underline; }
.linklike--reset {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red-soft); border: 1px solid var(--red-ring); border-radius: var(--radius-s);
  padding: 8px 12px; color: var(--red-dark); text-decoration: none;
}
.linklike--reset:hover { background: var(--red); border-color: var(--red); color: #fff; text-decoration: none; }
.linklike--reset[hidden] { display: none; }   /* class display:inline-flex otherwise beats the hidden attr */

/* Genre picker — searchable combobox (type to filter, click/arrow+enter to pick).
   Used by the Book Clubs genre filter; only genres present in the period are listed. */
.genre-picker { position: relative; display: flex; flex-direction: column; gap: 5px; }
.genre-picker__caption { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.genre-picker__field {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream-2); border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 0 6px 0 10px; min-width: 220px; transition: border-color var(--t-fast), background var(--t-fast);
}
.genre-picker__field:focus-within { background: var(--paper); border-color: var(--red); }
.genre-picker__icon { font-size: 18px; color: var(--red); flex: none; }
/* Scoped + explicit so the global `.filters input` rules (higher specificity) don't
   give this a second box + red focus border inside the field. */
.genre-picker__field .genre-picker__input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.9rem; color: var(--ink);
  background: transparent; border: 0; border-radius: 0; padding: 8px 0; box-shadow: none;
}
.genre-picker__field .genre-picker__input:focus { outline: none; background: transparent; border-color: transparent; }
.genre-picker__input::placeholder { color: var(--muted); }
/* Scoped past the global `.filters button { align-self: end }`, which otherwise drags
   this button to the bottom of the field instead of centring it. */
.genre-picker__field .genre-picker__clear {
  display: inline-flex; align-items: center; justify-content: center; align-self: center; flex: none;
  width: 24px; height: 24px; line-height: 0;
  background: none; border: 0; cursor: pointer; color: var(--faint);
  border-radius: var(--radius-pill); transition: color var(--t-fast), background var(--t-fast);
}
.genre-picker__field .genre-picker__clear:hover { color: var(--ink); background: var(--line-soft); }
/* display:block + line-height:0 drops the inline-glyph descender gap so the icon sits dead-centre. */
.genre-picker__field .genre-picker__clear .material-symbols-outlined { font-size: 16px; display: block; line-height: 0; }
.genre-picker__list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  width: 100%; max-height: 280px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-m);
}
.genre-picker__option {
  padding: 8px 10px; border-radius: var(--radius-s); cursor: pointer; font-size: 0.88rem; color: var(--ink);
}
.genre-picker__option:hover, .genre-picker__option.is-active { background: var(--cream-2); }
.genre-picker__option[aria-selected="true"] { color: var(--red); font-weight: 600; }

/* Neighbourhood combobox in Settings — type-to-search over the NIL <select>, mirrors the
   Book-Clubs genre picker. z-index keeps its dropdown above the Leaflet map below it. */
.nil-picker { position: relative; z-index: 500; }
.nil-picker__field {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream-2); border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 0 6px 0 10px; transition: border-color var(--t-fast), background var(--t-fast);
}
.nil-picker__field:focus-within { background: var(--paper); border-color: var(--red); }
.nil-picker__icon { font-size: 18px; color: var(--red); flex: none; }
.nil-picker__field .nil-picker__input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.95rem; color: var(--ink);
  background: transparent; border: 0; border-radius: 0; padding: 10px 0; box-shadow: none;
}
.nil-picker__field .nil-picker__input:focus { outline: none; background: transparent; border-color: transparent; }
.nil-picker__input::placeholder { color: var(--muted); }
.nil-picker__field .nil-picker__clear {
  display: inline-flex; align-items: center; justify-content: center; align-self: center; flex: none;
  width: 24px; height: 24px; line-height: 0;
  background: none; border: 0; cursor: pointer; color: var(--faint);
  border-radius: var(--radius-pill); transition: color var(--t-fast), background var(--t-fast);
}
.nil-picker__field .nil-picker__clear:hover { color: var(--ink); background: var(--line-soft); }
.nil-picker__field .nil-picker__clear .material-symbols-outlined { font-size: 16px; display: block; line-height: 0; }
.nil-picker__list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1;
  width: 100%; max-height: 280px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-m);
}
.nil-picker__option { padding: 9px 10px; border-radius: var(--radius-s); cursor: pointer; font-size: 0.9rem; color: var(--ink); }
.nil-picker__option:hover, .nil-picker__option.is-active { background: var(--cream-2); }
.nil-picker__option[aria-selected="true"] { color: var(--red); font-weight: 600; }

/* Inline notice banner (e.g. "set your neighbourhood" prompt above the feed). */
.notice { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-l); margin: 0 0 20px; font-size: 0.9rem; box-shadow: var(--shadow-s); }
.notice p { margin: 0; flex: 1; min-width: 0; }
.notice > .material-symbols-outlined { font-size: 22px; flex: none; }
.notice .btn { flex: none; }
.notice--warn { background: #FBF1E0; border: 1px solid rgba(178, 106, 0, 0.28); color: #6E4A12; }
.notice--warn > .material-symbols-outlined { color: var(--warn); }
.btn--sm { padding: 7px 12px; font-size: 0.82rem; }

/* Cards grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-s); transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.card:hover { box-shadow: var(--shadow-m); transform: translateY(-2px); border-color: var(--line); }
.card h3 { font-size: 1.06rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.card .when { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 0.84rem; font-weight: 500; }
.card .when .material-symbols-outlined { font-size: 16px; color: var(--faint); }
.card .when .dot { color: var(--line); }
/* Pin/cam icon stays glued to (and top-aligned with) its label, which wraps under it on long
   venue names — instead of the icon orphaning on the line above. */
.card .when__loc { display: inline-flex; align-items: flex-start; gap: 4px; min-width: 0; }
.card .when__loc > .material-symbols-outlined { flex: none; }
.card .book { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 0.92rem; }
.card .book > .material-symbols-outlined { font-size: 17px; color: var(--red); align-self: center; }
.card .book .book__title { font-weight: 700; color: var(--ink); }
/* The book is a Goodreads look-up link — make that legible (colour + underline + ext icon). */
.card .book .book__link { font-weight: 700; color: var(--red-dark); text-decoration: underline;
  text-decoration-color: rgba(199,42,42,0.4); text-underline-offset: 2px;
  display: inline-flex; align-items: center; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.card .book .book__link:hover { text-decoration-color: var(--red); }
.card .book .book__ext { font-size: 13px; opacity: 0.65; }
.card .book .book__author { color: var(--muted); font-weight: 500; }
/* Clamp to keep cards in a row visually even despite very different blurb lengths. */
.card .desc { color: rgba(22,21,25,0.78); font-size: 0.9rem; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; align-items: center; padding-top: 4px; }
.card__media { display: block; border-radius: var(--radius-m, 12px); overflow: hidden; margin-bottom: 2px; }
.card__media img { width: 100%; height: 158px; object-fit: cover; display: block; transition: transform var(--t); }
.card__media:hover img { transform: scale(1.04); }
/* "Immagine non disponibile" placeholder — no image, or a hotlink that failed to load. */
.card__noimg { display: none; }
.card__media--empty { background: linear-gradient(135deg, var(--cream-2), #E6E4DF); }
.card__media--empty img { display: none; }
.card__media--empty .card__noimg {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; height: 158px; color: var(--faint); text-align: center; padding: 10px;
}
.card__noimg .material-symbols-outlined { font-size: 38px; opacity: 0.65; }
.card__noimg span:last-child { font-size: 0.76rem; font-weight: 600; letter-spacing: 0.01em; }
.card .where { color: var(--faint); font-size: 0.8rem; margin: -4px 0 0; overflow-wrap: anywhere; }

/* Feed controls: compact date selects plus the compact/full view toggle. */
.feed-title { margin-bottom: clamp(16px, 2.2vw, 24px); }
.feed-controls {
  display: flex; align-items: center; justify-content: flex-start; gap: 14px;
  margin: -2px 0 18px;
}
.datebar {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%;
  padding: 6px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-m); box-shadow: var(--shadow-xs);
}
.feed-datebar__icon { flex: 0 0 auto; font-size: 19px; color: var(--red); margin-left: 2px; }
.feed-datefield,
.date-menu { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.feed-datefield[hidden] { display: none; }
.feed-datefield + .feed-datefield { margin-left: 1px; padding-left: 7px; border-left: 1px solid var(--line-soft); }
.date-menu__button {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-width: 130px; max-width: 100%;
  border: 0; border-radius: var(--radius-s); background: transparent; color: var(--ink);
  cursor: pointer; font: inherit; font-size: 0.86rem; font-weight: 650; line-height: 1;
  padding: 8px 8px; text-align: left;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.feed-datefield--day .date-menu__button { min-width: 108px; }
.date-menu__button:hover,
.date-menu__button[aria-expanded="true"] { background: var(--cream-2); }
.date-menu__button:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--red-ring); }
.date-menu__caret {
  flex: 0 0 auto; font-size: 18px; color: var(--faint); transition: transform var(--t-fast);
}
.date-menu__button[aria-expanded="true"] .date-menu__caret { transform: rotate(180deg); }
.date-menu__panel {
  position: absolute; top: calc(100% + 7px); left: 0; z-index: 55;
  min-width: max(100%, 190px); max-width: min(280px, calc(100vw - 32px));
  padding: 5px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-m); box-shadow: var(--shadow-m);
}
.feed-datefield--day .date-menu__panel { min-width: max(100%, 150px); }
.date-menu__option {
  display: flex; align-items: center; width: 100%; min-height: 34px;
  border: 0; border-radius: var(--radius-s); background: transparent; color: var(--ink);
  cursor: pointer; font: inherit; font-size: 0.84rem; font-weight: 600; text-align: left;
  padding: 8px 10px; white-space: nowrap;
}
.date-menu__option:hover { background: var(--cream-2); }
.date-menu__option.is-selected { background: var(--ink); color: var(--paper); }
.date-menu__panel[hidden] { display: none; }
.view-toggle {
  display: inline-flex; flex: 0 0 auto; gap: 2px; margin-left: auto; padding: 2px;
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--paper); box-shadow: var(--shadow-xs);
}
.view-toggle button {
  background: transparent; border: 0; border-radius: var(--radius-pill);
  cursor: pointer; font: inherit; font-size: 0.74rem; font-weight: 650; color: var(--muted);
  padding: 6px 12px; transition: background var(--t-fast), color var(--t-fast);
}
.view-toggle button:hover { background: var(--cream-2); color: var(--ink); }
.view-toggle button.is-active { background: var(--ink); color: var(--paper); }
.cards--compact .card__media,
.cards--compact .card .where,
.cards--compact .card .desc { display: none; }
.cards--compact .card { padding: 14px; gap: 6px; }

/* Tabs — Giochi di ruolo (Eventi / Bacheca). Links so ?view= works without JS. */
.tabs { display: flex; gap: 6px; margin: 0 0 18px; border-bottom: 1px solid var(--line); }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; margin-bottom: -1px;
  font-size: 0.92rem; font-weight: 600; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--brand, var(--ink)); }
.tab .material-symbols-outlined { font-size: 20px; }
.tab__count {
  font-size: 0.74rem; font-weight: 700; line-height: 1; padding: 3px 7px; border-radius: var(--radius-pill);
  background: var(--cream-2, #efece6); color: var(--muted);
}
.tab.is-active .tab__count { background: var(--ink); color: #fff; }
.tab-panel[hidden] { display: none; }

/* Distance filter on the themed section pages (Magic / Giochi da tavolo e wargames / Sport). */
.section-filter { margin: 0 0 16px; }

/* Staff dashboard (events/dashboard.html) — replaces the old "Fonti" sidebar panel. */
.nav__badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 0.68rem; font-weight: 700; line-height: 18px; text-align: center; }
.dash-health { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-l);
  border: 1px solid var(--line); background: var(--paper); margin: 0 0 18px; box-shadow: var(--shadow-s); }
.dash-health .material-symbols-outlined { font-size: 28px; }
.dash-health.is-ok .material-symbols-outlined { color: var(--ok, #2e7d32); }
.dash-health.is-alert { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.dash-health.is-alert .material-symbols-outlined { color: var(--red); }
.dash-health__text { display: flex; flex-direction: column; gap: 2px; }
.dash-health__text strong { font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; }
.dash-health__badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red);
  color: #fff; font-size: 0.72rem; font-weight: 700; line-height: 20px; text-align: center; }
.dash-health__sub { font-size: 0.82rem; color: var(--muted); }
.dash-health__why { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.dash-health__item { display: inline-flex; align-items: baseline; gap: 4px; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); white-space: nowrap; }
.dash-health__item strong { font-weight: 600; color: var(--ink); font-size: inherit; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0 0 22px; }
.dash-stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-s); }
.dash-stat__num { font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1; }
.dash-stat__label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
/* Budgets & usage — external-service spend cards (Firecrawl/GitHub/Gemini/Northflank/Neon). */
.dash-budgets { margin: 0 0 22px; }
.dash-budgets__title { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dash-budgets__month { font-size: 0.72rem; font-weight: 600; color: var(--faint, var(--muted)); text-transform: none; letter-spacing: 0; }
.dash-budgets__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.dash-budget { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-s); }
.dash-budget__svc { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.dash-budget__num { font-size: 1.5rem; font-weight: 700; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.dash-budget__num--sm { font-size: 1rem; }
.dash-budget__of { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.dash-budget__sub { font-size: 0.72rem; color: var(--muted); line-height: 1.35; }
.dash-budget__link { color: var(--red); text-decoration: none; }
.dash-budget__link:hover { color: var(--red-dark, var(--red)); text-decoration: underline; }
.dash-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--paper); box-shadow: var(--shadow-s); }
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
.dash-table th, .dash-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.dash-table th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.dash-table th.num, .dash-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dash-table tbody tr:last-child td { border-bottom: 0; }
.dash-src strong { display: block; }
.dash-slug { font-size: 0.72rem; color: var(--muted); }
.dash-muted { color: var(--faint, var(--muted)); }
.dash-row--down { background: color-mix(in srgb, var(--red) 6%, transparent); }
.dash-row--warn { background: color-mix(in srgb, var(--warn, #b26a00) 8%, transparent); }
.dash-pill { display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap; }
.dash-pill--ok { background: color-mix(in srgb, var(--ok, #2e7d32) 14%, transparent); color: var(--ok, #2e7d32); }
.dash-pill--info { background: var(--cream-2, #efece6); color: var(--muted); }
.dash-pill--warn { background: color-mix(in srgb, var(--warn, #b26a00) 16%, transparent); color: var(--warn, #b26a00); }
.dash-pill--down { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
/* Status column = PLAIN text (no chip), level conveyed by colour alone. The legend below still
   uses .dash-pill so the key reads as labelled swatches. */
.dash-status { font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.dash-status--ok { color: var(--ok, #2e7d32); }
.dash-status--info { color: var(--muted); }
.dash-status--warn { color: var(--warn, #b26a00); }
.dash-status--down { color: var(--red); }
/* "Fetched via" tier column: PLAIN text naming the rung that last fetched the source
   (fetch / firecrawl / stealth / residential). Firecrawl/residential tiers get a coloured
   word — no chip — so a credit-spending fetch stands out from a free datacenter fetch. */
.dash-tier { white-space: nowrap; }
.dash-tier__name { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.dash-tier--firecrawl, .dash-tier--firecrawl_stealth { color: var(--warn, #b26a00); }
.dash-tier--firecrawl_stealth { font-weight: 700; }
.dash-tier--fetch_residential, .dash-tier--nodriver_residential { color: var(--accent, #7C3AED); }
.dash-tier__lock { margin-left: 6px; font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--red); }
/* "Categorized by" column — plain text naming how a source classifies its events (cursor:help
   because it carries a percentage-breakdown tooltip). */
.dash-method { font-size: 0.82rem; color: var(--muted); white-space: nowrap; cursor: help; }
/* Muted (ignore_notifications) rows: real status still shown, just dimmed + a small bell-off. */
.dash-row--muted td { opacity: 0.6; }
.dash-notif { display: inline-flex; align-items: center; gap: 5px; }
.dash-notif input { cursor: pointer; margin: 0; }
.dash-notif__lbl { font-size: 0.7rem; color: var(--muted); }
.dash-legend { margin: 22px 0 0; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--paper); padding: 0 16px; }
.dash-legend > summary { cursor: pointer; padding: 13px 2px; font-weight: 600; font-size: 0.88rem; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
.dash-legend > summary::-webkit-details-marker { display: none; }
.dash-legend > summary::before { content: "help"; font-family: "Material Symbols Outlined"; font-size: 19px; color: var(--red); }
.dash-legend[open] > summary { border-bottom: 1px solid var(--line); }
.dash-legend__list { list-style: none; margin: 0; padding: 12px 0 16px; display: grid; gap: 11px; }
/* First column sizes to the WIDEST pill (max-content) so a long label like the Italian
   "Raccolta non riuscita" can't overflow a fixed width and collide with its description. */
.dash-legend__list li { display: grid; grid-template-columns: max-content 1fr; align-items: baseline; gap: 14px; font-size: 0.85rem; color: var(--ink); }
.dash-legend__list .dash-pill { justify-self: start; white-space: nowrap; }
.dash-legend__list li > span:last-child { color: var(--muted); }
@media (max-width: 560px) { .dash-legend__list li { grid-template-columns: 1fr; gap: 3px; } }
.dash-foot { margin: 20px 0 0; }
.dash-foot a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-pill);
  background: var(--paper); border: 1px solid var(--line); color: var(--ink);
  font-size: 0.84rem; font-weight: 600; text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.dash-foot a:hover { border-color: var(--red); color: var(--red-dark); box-shadow: var(--shadow-s); }
.dash-foot a .material-symbols-outlined { font-size: 18px; color: var(--red); }

/* --- User-activity dashboard: KPIs + aggregate bar charts (no chart lib, just CSS bars) --- */
.act-kpis { max-width: 460px; }
.act-viz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 2.4vw, 26px); margin: 0 0 24px; }
@media (max-width: 680px) { .act-viz-grid { grid-template-columns: 1fr; } }
.act-viz { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px 20px; box-shadow: var(--shadow-s); }
.act-viz__title { font-size: 0.98rem; font-weight: 700; margin: 0 0 2px; }
.act-viz .sidehint { margin: 0 0 14px; }
.act-chart { display: flex; flex-direction: column; gap: 9px; }
.act-row { display: grid; grid-template-columns: 132px 1fr 34px; align-items: center; gap: 10px; font-size: 0.84rem; }
.act-row__label { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-row__track { background: var(--cream-2); border-radius: 999px; height: 10px; overflow: hidden; }
.act-row__bar { display: block; height: 100%; border-radius: 999px; min-width: 3px; background: var(--ink); transition: width var(--t); }
.act-row__bar--sec { background: var(--red); }
.act-row__bar--src { background: var(--ink); }
.act-row__bar--srcin { background: #2563EB; }
.act-row__bar--srcout { background: var(--faint); }
.act-row__count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.act-empty { color: var(--muted); font-size: 0.85rem; padding: 6px 0 2px; }
.act-badge { font-size: 0.76rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--cream-2); }
.act-badge--7 { color: var(--ok, #2e7d32); }
.act-badge--30 { color: var(--ink); }
.act-badge--off { color: var(--faint); }
.act-toggle { margin: 4px 0 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.act-toggle__label { display: inline-flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 600; color: var(--ink); cursor: pointer; background: var(--paper); border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 16px; box-shadow: var(--shadow-s); transition: border-color var(--t), background var(--t), color var(--t); }
.act-toggle__label:hover { border-color: var(--red); }
.act-toggle__label input { width: 17px; height: 17px; accent-color: var(--red); cursor: pointer; }
.act-toggle.is-on .act-toggle__label { border-color: var(--red); background: var(--cream-2); color: var(--red-dark); }

/* Dashboard tabs (Sources / Data quality) — client-side panel switch. */
.dash-tabs { display: flex; gap: 4px; margin: 0 0 20px; border-bottom: 2px solid var(--line); }
.dash-tab { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border: 0; background: none;
  font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color var(--t-fast), border-color var(--t-fast); }
.dash-tab .material-symbols-outlined { font-size: 18px; }
.dash-tab:hover { color: var(--ink); }
.dash-tab.is-active { color: var(--red); border-bottom-color: var(--red); }
.dash-panel.is-hidden { display: none; }

/* Sortable column headers — click to sort, a caret marks the active column + direction. */
.dash-th--sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.dash-th--sortable:hover { color: var(--ink); }
.dash-th--sortable::after { content: "\2195"; margin-left: 5px; font-size: 0.78em; opacity: 0.35; }
.dash-table th.num.dash-th--sortable::after { margin-left: 4px; }
.dash-th--sortable.is-sorted { color: var(--ink); }
.dash-th--sortable.is-sorted[data-dir="asc"]::after { content: "\2191"; opacity: 0.9; }
.dash-th--sortable.is-sorted[data-dir="desc"]::after { content: "\2193"; opacity: 0.9; }

/* Data-quality stat cards carry a small sub-line under the label. */
.dash-stats--quality { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.dash-stat__sub { font-size: 0.72rem; color: var(--faint, var(--muted)); }

.dash-quality-hint { font-size: 0.78rem; color: var(--muted); margin: 6px 0 14px; }

/* Per-source classification mix — a compact stacked bar per row (segments = % of each mechanism).
   Colours are shared with the legend below + via .dash-method--<key>. */
.dash-classbar { display: flex; width: 150px; max-width: 100%; height: 12px; border-radius: 6px;
  overflow: hidden; background: var(--cream-2, #efece6); }
.dash-classbar__seg { height: 100%; min-width: 1px; }
.dash-classlegend { font-size: 0.74rem; color: var(--muted); margin: 6px 0 12px; display: flex;
  flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.dash-classlegend strong { color: var(--ink); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.dash-classlegend__item { display: inline-flex; align-items: center; gap: 6px; }
.dash-classlegend__item::before { content: ""; width: 11px; height: 11px; border-radius: 3px; background: currentColor; }
/* Per-method accent colours (native = source taxonomy, ai = Gemini, etc.) — used by the legend
   text (currentColor swatch) AND the stacked-bar segments (background). */
.dash-method--native { color: var(--ok, #2e7d32); } .dash-classbar__seg.dash-method--native { background: var(--ok, #2e7d32); }
.dash-method--keyword { color: #2563EB; } .dash-classbar__seg.dash-method--keyword { background: #2563EB; }
.dash-method--ai { color: var(--accent, #7C3AED); } .dash-classbar__seg.dash-method--ai { background: var(--accent, #7C3AED); }
.dash-method--default { color: var(--warn, #b26a00); } .dash-classbar__seg.dash-method--default { background: var(--warn, #b26a00); }
.dash-method--none { color: var(--muted); } .dash-classbar__seg.dash-method--none { background: var(--muted); }

/* Cross-source duplicate overlaps (Data-quality tab) — a small, calm aligned table. */
.dash-dupes { margin: 4px 0 22px; }
.dash-dupes__table { border-collapse: collapse; font-size: 0.84rem; min-width: 280px; }
.dash-dupes__table th { text-align: left; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 0 18px 6px 0; }
.dash-dupes__table td { padding: 5px 18px 5px 0; color: var(--ink); border-top: 1px solid var(--line); }
.dash-dupes__table .num { text-align: right; padding-right: 0; font-variant-numeric: tabular-nums; color: var(--muted); }
.dash-dupes__table th.num { text-align: right; padding-right: 0; }

/* Quality % cell — a small coloured chip flags the worst offenders. */
.dash-q { font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-q--ok { color: var(--ok, #2e7d32); }
.dash-q--warn { color: var(--warn, #b26a00); }
.dash-q--bad { color: var(--red); }

/* Page heading breathing room (e.g. Book Clubs h1 above its filter card) */
.page-title { margin-bottom: clamp(14px, 2vw, 22px); }

/* Day section headers (This Week / Next Week feeds) */
.day-head { font-size: 0.95rem; font-weight: 700; color: var(--ink); margin: 24px 0 12px; padding-bottom: 7px; border-bottom: 2px solid var(--line); text-transform: capitalize; }
.day-section:first-child .day-head { margin-top: 2px; }

/* Week band — the "Questa settimana / Prossima settimana" divider inside the united feed. */
.week-band {
  font-size: 1.15rem; font-weight: 800; color: var(--ink); margin: 30px 0 4px;
  letter-spacing: 0.01em; display: flex; align-items: center; gap: 12px;
}
.week-band::after { content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px; }
/* `display:flex` above out-specifies the [hidden] UA rule, so restore it for the range filter. */
.week-band[hidden] { display: none; }
.week-band:first-child { margin-top: 2px; }
.week-band + .day-section .day-head { margin-top: 10px; }

/* Distance multi-select — toggle bucket chips (combine e.g. close + medium) */
.distance-pick { display: flex; flex: 0 0 auto; flex-direction: column; align-self: end; gap: 5px; min-width: max-content; }
.distance-pick__cap { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.distance-pick__options { display: flex; align-items: center; gap: 7px; flex-wrap: nowrap; width: max-content; }
.filters .dchip,
.distance-pick--inline .dchip { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 11px; border-radius: var(--radius-s);
  border: 1px solid var(--line); font-size: 0.78rem; font-weight: 700; color: var(--ink);
  flex: 0 0 auto; text-transform: uppercase; letter-spacing: 0.05em; background: var(--paper); cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t); }
.filters .dchip span:last-child { white-space: nowrap; }
.dchip:hover { border-color: var(--muted); color: var(--ink); }
.dchip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* Selected look is driven by :checked (via :has), NOT only the server-rendered `is-on` class.
   The weekly feed swaps just #feedResults on an AJAX filter, leaving the filter form (and its
   chips) un-rerendered — so an `is-on`-only style never updated after a click and multi-select
   looked broken. `:has(input:checked)` reflects the live checkbox state, so each chip toggles its
   highlight instantly and you can stack several. `is-on` is kept for the SSR/no-JS state. */
.dchip.is-on, .dchip:has(input:checked) { background: var(--red); color: #fff; border-color: var(--red); }
.dchip .material-symbols-outlined { font-size: 18px; color: var(--red); }
.dchip.is-on .material-symbols-outlined, .dchip:has(input:checked) .material-symbols-outlined { color: #fff; }
.dchip input:focus-visible + span, .dchip:focus-within { outline: 2px solid var(--red); outline-offset: 2px; }

/* Google sign-in button (login page) */
.gbtn { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #3c4043; border: 1px solid var(--line); border-radius: var(--radius-m, 12px); padding: 11px 18px; font-weight: 600; font-size: 0.95rem; text-decoration: none; box-shadow: var(--shadow-s); transition: box-shadow var(--t), border-color var(--t); }
.gbtn:hover { box-shadow: var(--shadow-m); border-color: var(--muted); }
.gbtn__logo { flex: none; }

/* Tags + chips */
/* De-chipped card meta (category + distance). These read as quiet inline LABELS — a colour
   dot + text, an icon + text — so the only rounded "pills" left on screen are the genuinely
   clickable filters. Less pill monotony, clearer interactive/decorative hierarchy. */
.card .meta { gap: 14px; }
.cat-label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 600; color: var(--ink); }
.cat-label__icon { font-size: 17px; line-height: 1; flex: none; }
.dist-label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.dist-label .material-symbols-outlined { font-size: 16px; line-height: 1; }
/* Three distinct shades so the range reads at a glance: near = warm red, doable = strong ink,
   out-of-the-way = faded. Before, only --close had a colour, so "Ci sta" and "Fuori mano" both
   fell back to the same muted grey and were indistinguishable. */
.dist-label--close { color: var(--red-dark); }
.dist-label--medium { color: var(--ink); }
.dist-label--far { color: var(--faint); }

.tag { font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--cream-2); color: var(--muted); }
/* Category chip: neutral pill, the per-category colour carried by the Material icon. */
.tag.cat { background: var(--cream-2); color: var(--ink); display: inline-flex; align-items: center; gap: 5px; }
.tag.cat .cat__icon { font-size: 15px; line-height: 1; }
.chip { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; gap: 4px; }
.chip.close { background: var(--red); color: #fff; }
.chip.medium { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.chip.far { background: var(--ink); color: #fff; }
.chip.approx { font-weight: 600; opacity: 0.9; }
.chip.close.approx { background: var(--red-soft); color: var(--red-dark); }
.chip.far.approx { background: var(--cream-2); color: var(--ink); }

/* Card footer links */
.cardlinks { display: flex; gap: 12px; align-items: center; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.cardlinks a { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 0.84rem; color: var(--red-dark); }
.cardlinks a .material-symbols-outlined { font-size: 15px; }
.cardlinks a:hover { color: var(--red); }
.reason { color: var(--faint); font-size: 0.74rem; }
.cardlinks__favorite { margin-left: auto; display: flex; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  background: transparent; border: 0; color: var(--faint); cursor: pointer;
  transition: color var(--t-fast), transform var(--t-fast);
}
.icon-btn .material-symbols-outlined { font-size: 20px; }
.icon-btn:hover { color: var(--ink); }
/* Kill the square focus box left after a mouse click; keep a ring for keyboard users only. */
.icon-btn:focus { outline: none; }
.icon-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 50%; }
.star:hover { color: var(--red); transform: translateY(-1px); }
.star.on { color: var(--red); }
.star.on .material-symbols-outlined { font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24; }

/* ---------- Reference sidebar ---------- */
.sidepanel {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 18px; box-shadow: var(--shadow-s);
}
.sidepanel h2 { font-size: 0.95rem; font-weight: 700; margin: 0 0 3px; }
.sidehint { color: var(--muted); font-size: 0.78rem; margin: 0 0 12px; }
.place-list { display: flex; flex-direction: column; }
.place-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.place-row:last-child { border-bottom: 0; }
.place-row:hover .place-main strong { color: var(--red-dark); }
.place-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.place-main strong { font-size: 0.85rem; line-height: 1.2; transition: color var(--t-fast); overflow-wrap: anywhere; }
.place-main span { color: var(--muted); font-size: 0.74rem; line-height: 1.25; overflow-wrap: anywhere; }

/* A second titled block inside a sidepanel (e.g. LARP under RPG groups). */
.side-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

.side-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-details > summary, .nested-details > summary { cursor: pointer; color: var(--ink); font-size: 0.82rem; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 6px; }
.side-details > summary::before, .nested-details > summary::before { content: "chevron_right"; font-family: "Material Symbols Outlined"; font-size: 18px; color: var(--faint); transition: transform var(--t-fast); }
.side-details[open] > summary::before, .nested-details[open] > summary::before { transform: rotate(90deg); }
.nested-details { margin-top: 8px; }
.nested-details > summary { font-weight: 600; font-size: 0.8rem; }
.mini-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mini-row { display: flex; flex-direction: column; gap: 1px; }
.mini-row strong { font-size: 0.8rem; }
.mini-row span, .research-items { color: var(--muted); font-size: 0.74rem; line-height: 1.4; }
.research-items { margin: 6px 0 0; }

/* ---------- Empty / section titles ---------- */
.empty { color: var(--muted); background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius-l); padding: 32px 24px; text-align: center; }
.empty code { background: var(--cream-2); padding: 1px 6px; border-radius: 4px; font-size: 0.85em; }
/* The inline heart in the favourites empty-state: the real (red) Material favourite icon. */
.fav-empty-heart { color: var(--red); font-size: 1.15em; vertical-align: -3px; }
.section-title { display: inline-flex; align-items: center; margin: 30px 0 12px; color: var(--muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; }

/* ============================================================
   FORMS (settings, delete)
   ============================================================ */
form.stack { display: flex; flex-direction: column; gap: 18px; max-width: 560px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 24px; box-shadow: var(--shadow-s); }
form.stack > div { display: flex; flex-direction: column; gap: 6px; }
form.stack label { font-weight: 600; font-size: 0.9rem; }
form.stack input[type=text], form.stack input[type=email], form.stack select {
  font: inherit; width: 100%; color: var(--ink); background: var(--cream-2);
  border: 1px solid transparent; border-radius: var(--radius-s); padding: 10px 12px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
form.stack input:focus, form.stack select:focus { outline: none; background: var(--paper); border-color: var(--red); }
.helptext { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.danger { color: var(--red-dark); font-weight: 600; }
.errorlist { color: var(--red-dark); list-style: none; padding: 0; margin: 4px 0; font-size: 0.85rem; }

/* Settings */
.settings-stack { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: min(1120px, 100%); }
.settings-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 20px; box-shadow: var(--shadow-s);
}
.settings-card--row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.settings-card__head { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.settings-card__icon {
  width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: var(--radius-s); background: var(--red-soft); color: var(--red);
}
.settings-card h2 { font-size: 1rem; font-weight: 700; letter-spacing: 0; margin: 0 0 3px; }
.settings-card p { color: var(--muted); margin: 0; font-size: 0.88rem; }
.settings-form { display: flex; flex-direction: column; gap: 18px; }
.settings-section { display: flex; flex-direction: column; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.settings-section:last-of-type { padding-bottom: 0; border-bottom: 0; }
.field-row { display: flex; flex-direction: column; gap: 6px; }
.field-row label { font-weight: 600; font-size: 0.9rem; }
.field-row select,
.field-row input[type="email"],
.field-row input[type="password"],
.field-row input[type="text"] {
  font: inherit; width: 100%; color: var(--ink); background: var(--cream-2);
  border: 1px solid transparent; border-radius: var(--radius-s); padding: 10px 12px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.field-row select:focus,
.field-row input[type="email"]:focus,
.field-row input[type="password"]:focus,
.field-row input[type="text"]:focus { outline: none; background: var(--paper); border-color: var(--red); }
.invite-field { max-width: 420px; }
.settings-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.settings-actions--inline { justify-content: flex-end; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--red); color: #fff; border: 1px solid var(--red);
  border-radius: var(--radius-s); padding: 10px 18px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn:active { transform: translateY(1px); }
.btn .material-symbols-outlined { font-size: 19px; }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--cream-2); border-color: var(--line); }
.btn--danger { background: var(--paper); color: var(--red-dark); border-color: var(--line); }
.btn--danger:hover { background: var(--red-soft); color: var(--red-dark); border-color: var(--red-ring); }

/* ---------- Footer ---------- */
.foot { color: var(--faint); font-size: 0.8rem; text-align: center; padding: 26px 20px 8px; margin-top: auto; border-top: 1px solid var(--line-soft); }

/* ============================================================
   AUTH SHELL — login / request access (anonymous)
   ============================================================ */
.layout--auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; background:
  linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 26px 26px,
  linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 26px 26px,
  radial-gradient(90% 70% at 50% -10%, rgba(225,29,42,0.22), transparent 60%),
  linear-gradient(180deg, #1b1922, #141319); }
.authshell { width: 100%; max-width: 390px; }
.authbrand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 8px; }
.authbrand .brand__mark { width: 44px; height: 44px; border-radius: 10px; padding: 5px; }
.authbrand .brand__name { color: #fff; font-size: 1.7rem; }
.authbrand .brand__name b { color: var(--red); }
.authtag { text-align: center; color: rgba(255,255,255,0.74); font-size: 0.92rem; margin: 0 0 22px; }

.auth-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 26px 24px; box-shadow: var(--shadow-m); }
.auth-card h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 4px; }
.auth-card h2 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 10px; }
.auth-card p { color: var(--muted); font-size: 0.92rem; }
.auth-card hr { border: 0; border-top: 1px solid var(--line-soft); margin: 18px 0; }

/* allauth emits class-less elements — style them in scope */
.auth-card form p { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; color: var(--text); }
.auth-card label { font-weight: 600; font-size: 0.85rem; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password] {
  font: inherit; width: 100%; color: var(--ink); background: var(--cream-2);
  border: 1px solid transparent; border-radius: var(--radius-s); padding: 11px 13px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.auth-card input:focus { outline: none; background: var(--paper); border-color: var(--red); }
.auth-card button[type=submit] {
  width: 100%; background: var(--red); color: #fff; border: 1px solid var(--red);
  border-radius: var(--radius-s); padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background var(--t-fast);
}
.auth-card button[type=submit]:hover { background: var(--red-dark); }
/* Social provider list (Google) */
.auth-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.auth-card ul a {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: #fff; font-weight: 600; font-size: 0.92rem;
  transition: background var(--t-fast);
}
.auth-card ul a:hover { background: var(--ink-2); }

/* Login card — branded, centred, echoes the landing hero (invite pill + 1-click Google) */
.login { text-align: center; }
.login__badge {
  display: inline-block; margin: 0 0 16px; padding: 0; border-radius: 0;
  background: transparent; color: var(--ink-3);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
}
.auth-card .login h1 { font-size: 1.35rem; margin: 0 0 6px; }
.login__lede { color: var(--muted); font-size: 0.92rem; margin: 0 auto 20px; max-width: 28ch; }
.gbtn--block { width: 100%; justify-content: center; padding: 13px 18px; font-size: 1rem; }
.login__fine { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--faint); font-size: 0.78rem; margin: 14px 0 0; }
.login__fine .material-symbols-outlined { font-size: 16px; }

/* ============================================================
   LANGUAGE TOGGLE (topbar EN / IT)
   ============================================================ */
.langtoggle { display: inline-flex; gap: 2px; padding: 2px; background: var(--paper); border: 1px solid rgba(0,0,0,0.12); border-radius: 999px; }
.langtoggle .lang {
  border: 0; background: transparent; cursor: pointer; font: inherit; font-weight: 700;
  font-size: 0.72rem; letter-spacing: 0.04em; color: #8a8a8a; padding: 4px 10px;
  border-radius: 999px; transition: background 0.15s ease, color 0.15s ease;
}
.langtoggle .lang:hover { color: var(--ink); }
.langtoggle .lang.is-active { background: var(--red); color: #fff; }

/* Dark variant — reads on the landing hero's dark pixel field */
.langtoggle--dark { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); }
.langtoggle--dark .lang { color: rgba(255,255,255,0.6); }
.langtoggle--dark .lang:hover { color: #fff; }
.langtoggle--dark .lang.is-active { background: var(--red); color: #fff; }
.langtoggle--lg { padding: 3px; margin-bottom: 4px; }
.langtoggle--lg .lang { padding: 8px 22px; font-size: 0.9rem; }
.lp-lang { position: absolute; top: 18px; right: 18px; z-index: 2; }

/* ============================================================
   REVEALS (calm fade-up)
   ============================================================ */
/* Scroll-reveal. Default is VISIBLE so there is no flash of blank content on first paint
   (the old `.reveal { opacity:0 }` hid every card until the body-end JS ran — a FOUC on every
   page load, and a permanent blank if JS was slow/off). The JS adds `is-pending` ONLY to cards
   that start below the fold, so on-screen content renders instantly while off-screen cards still
   fade in as you scroll. */
.reveal { opacity: 1; }
.reveal.is-pending { opacity: 0; transform: translateY(16px); transition: opacity 0.5s var(--ease-reveal), transform 0.5s var(--ease-reveal); }
.reveal.is-pending.is-revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal.is-pending { opacity: 1; transform: none; transition: none; } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-m); }
  html.sb-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .hamburger { display: inline-flex; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); opacity: 0; pointer-events: none; transition: opacity var(--t); z-index: 90; }
  html.sb-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 880px) {
  /* minmax(0,…), not bare 1fr: wide content (book rows, tab strips) must shrink/scroll,
     not blow the column past the viewport. */
  .page-with-sidebar { grid-template-columns: minmax(0, 1fr); }
  .sidepanel { position: static; padding: 16px; }
  .place-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 0 18px;
  }
  .place-row { min-width: 0; }
  .distance-pick { min-width: 0; }
  .distance-pick__options { flex-wrap: wrap; width: auto; }
  .settings-card--row { align-items: flex-start; flex-direction: column; }
  .settings-actions--inline { justify-content: flex-start; }
}

@media (max-width: 640px) {
  :root { --topbar-h: 58px; }
  body { font-size: 14px; }
  .topbar { padding: 0 12px; }
  .hamburger { width: 42px; height: 42px; }
  .content { padding: 16px 12px 40px; }
  .content > h1 { font-size: 1.42rem; }
  .page-head { gap: 10px; margin-bottom: 14px; align-items: flex-start; }
  .page-head h1 { font-size: 1.42rem; }
  .sub { margin: 4px 0 16px; font-size: 0.88rem; }
  .foot { padding: 22px 8px 4px; }

  .notice {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 10px;
    padding: 12px;
    border-radius: 14px;
  }
  .notice .btn {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
    align-items: start;
    padding: 14px;
    margin-bottom: 22px;
    border-radius: 16px;
  }
  .filters > label:first-child,
  .filters > .distance-pick,
  .filters > noscript { grid-column: 1 / -1; }
  .filters > label,
  .filters > .interest-picker,
  .filters > .distance-pick { min-width: 0; width: 100%; }
  .filters label,
  .interest-picker,
  .distance-pick { gap: 4px; }
  .filters input,
  .filters select,
  .interest-picker__toggle {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    font-size: 0.86rem;
  }
  .interest-picker__toggle { padding: 8px 9px; gap: 7px; }
  .interest-picker__toggle > .material-symbols-outlined,
  .interest-picker__caret { font-size: 17px; }
  .interest-picker__panel {
    width: calc(100vw - 32px);
    max-height: min(440px, 64vh);
    overflow-y: auto;
    padding: 12px;
    border-radius: 14px;
  }
  .filters > .interest-picker:nth-of-type(2) .interest-picker__panel {
    left: auto;
    right: 0;
  }

  .distance-pick__options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }
  .filters .dchip {
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-width: 0;
    min-height: 58px;
    padding: 7px 6px;
    font-size: 0.68rem;
    line-height: 1.12;
    text-align: center;
    letter-spacing: 0.02em;
  }
  .filters .dchip .material-symbols-outlined { font-size: 20px; }
  .filters .dchip span:last-child { white-space: normal; overflow-wrap: anywhere; }

  .feed-controls {
    display: block;
    margin: 0 0 14px;
  }
  .feed-datebar {
    width: 100%;
    gap: 5px;
  }
  .feed-datefield { flex: 1 1 0; }
  .date-menu__button {
    min-width: 0;
    font-size: 0.8rem;
    padding-left: 7px;
  }
  .feed-datefield--day { flex: 0.8 1 0; }
  .view-toggle { margin-left: auto; }
  .view-toggle button { padding: 6px 10px; font-size: 0.71rem; }
  .tabs {
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: 0 0 auto;
    padding: 9px 10px;
    font-size: 0.84rem;
  }
  .tab .material-symbols-outlined { font-size: 18px; }
  .tab__count { padding: 3px 6px; }
  .week-band { margin-top: 24px; font-size: 1rem; gap: 9px; }
  .day-head { margin: 20px 0 10px; font-size: 0.92rem; }

  .cards { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .card { padding: 15px; border-radius: 14px; gap: 9px; }
  .card:hover { transform: none; }
  .card h3 { font-size: 1rem; }
  .card__media img,
  .card__media--empty .card__noimg { height: 136px; }
  .card .when { gap: 5px; font-size: 0.8rem; }
  .card .desc { -webkit-line-clamp: 3; line-clamp: 3; font-size: 0.86rem; }
  .card .meta { gap: 8px 12px; }
  .cat-label,
  .dist-label { max-width: 100%; }
  .cat-label { font-size: 0.74rem; }
  .cardlinks { gap: 8px; }
  .cardlinks a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cardlinks__favorite { flex: 0 0 auto; }
  .sidepanel {
    border-radius: 14px;
    padding: 14px;
  }
  .sidepanel h2 { font-size: 0.9rem; }
  .sidehint { margin-bottom: 8px; }
  .place-list {
    display: flex;
    flex-direction: column;
  }
  .place-row { padding: 10px 0; align-items: flex-start; }
  .place-row .chip { flex: 0 0 auto; margin-top: 1px; }
  .empty { padding: 24px 18px; border-radius: 14px; }

  .layout--auth { padding: 18px 12px; align-items: start; }
  .authshell { max-width: 100%; }
  .authbrand .brand__mark { width: 38px; height: 38px; }
  .authbrand .brand__name { font-size: 1.38rem; }
  .auth-card { padding: 22px 18px; border-radius: 14px; }

  form.stack,
  .settings-stack,
  .settings-card { max-width: none; }
  form.stack,
  .settings-card { padding: 18px 16px; border-radius: 14px; }
  .settings-card__head { gap: 10px; }
  .settings-card__icon { width: 32px; height: 32px; }
  .settings-actions,
  .settings-actions--inline { width: 100%; }
  .settings-actions .btn,
  .settings-actions--inline .btn,
  form.stack .btn { width: 100%; justify-content: center; }
  .langtoggle--lg { width: 100%; }
  .langtoggle--lg .lang { flex: 1 1 0; text-align: center; padding-inline: 10px; }
  .locmap { height: min(420px, 56vh); border-radius: 14px; }
  .nil-picker__list { max-height: min(280px, 42vh); }

  .dash-health { align-items: flex-start; padding: 12px; border-radius: 14px; }
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash-table-wrap { border-radius: 14px; }
}

@media (max-width: 360px) {
  .filters { grid-template-columns: 1fr; }
  .filters > .interest-picker:nth-of-type(2) .interest-picker__panel {
    left: 0;
    right: auto;
  }
  .feed-datebar { flex-wrap: wrap; }
  .feed-datebar__icon { display: none; }
  .feed-datefield { flex: 1 1 100%; }
  .feed-datefield + .feed-datefield {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding-top: 4px;
  }
  .distance-pick__options { gap: 6px; }
  .filters .dchip { font-size: 0.64rem; padding-inline: 4px; }
  .view-toggle { gap: 10px; }
}

/* ============================================================
   LANDING — public marketing page at "/" (anonymous visitors)
   ============================================================ */
.lp { background: #141319; display: flex; flex-direction: column; min-height: 100vh; }

/* Hero — dark pixel-grid field with the spritz logo + pixel wordmark */
.lp-hero {
  position: relative; flex: 1 1 auto; min-height: 92vh; display: grid; place-items: center;
  text-align: center; padding: 84px 24px 44px; overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,0.035) 2px, transparent 2px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255,255,255,0.035) 2px, transparent 2px) 0 0 / 40px 40px,
    radial-gradient(85% 60% at 50% -6%, rgba(225,29,42,0.24), transparent 60%),
    linear-gradient(180deg, #1b1922 0%, #141319 100%);
}
.lp-hero__inner { position: relative; max-width: 760px; }
.lp-logo {
  width: 104px; height: 104px; margin: 0 auto 24px; display: grid; place-items: center;
  background: #fff; border-radius: 22px; padding: 13px;
  box-shadow: 0 12px 34px -10px rgba(0,0,0,0.6);
}
.lp-logo img { width: 100%; height: 100%; display: block; }
.lp-wordmark {
  font-family: "Bitcount Single", "Montserrat", system-ui, sans-serif;
  color: #fff; font-weight: 400; line-height: 1; letter-spacing: 0.02em; margin: 0;
  font-size: clamp(2.3rem, 6.6vw, 4rem);
}
.lp-wordmark b { color: var(--red); font-weight: 400; }
.lp-tag { color: rgba(255,255,255,0.76); font-size: clamp(1rem, 2.4vw, 1.2rem); margin: 18px auto 8px; max-width: 32ch; }
.lp-note { color: rgba(255,255,255,0.42); font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em; margin: 0 0 30px; }
.lp-cta {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--red); color: #fff; font-weight: 600; font-size: 1rem;
  padding: 13px 26px; border-radius: var(--radius-s);
  box-shadow: 0 10px 26px -8px rgba(225,29,42,0.65);
  transition: background var(--t-fast), transform var(--t-fast);
}
.lp-cta:hover { background: var(--red-dark); transform: translateY(-1px); }
.lp-cta:active { transform: translateY(0); }
.lp-cta .material-symbols-outlined { font-size: 20px; }

.lp-foot {
  background: #141319; color: rgba(255,255,255,0.5); font-size: 0.82rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 4px 16px; padding: 20px clamp(20px, 5vw, 40px);
}
.lp-foot a { color: rgba(255,255,255,0.8); }

/* ---------- Staff source-health panel (left sidebar, staff only) ---------- */
.sysstatus {
  margin: var(--space-s) 0 0;
  padding: 10px var(--space-s) 11px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-m);
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--sidebar-fg);
}
.sysstatus--alert { border-color: var(--red-ring); background: var(--red-soft); }
.sysstatus__head { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: 0.02em; color: var(--sidebar-fg-on); }
.sysstatus__head .material-symbols-outlined { font-size: 18px; }
.sysstatus--ok    .sysstatus__head .material-symbols-outlined { color: #5BD08C; }
.sysstatus--alert .sysstatus__head .material-symbols-outlined { color: #FF8A8A; }
.sysstatus__title { flex: 1 1 auto; }
.sysstatus__badge { min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--red); color: #fff; font-weight: 700; font-size: 11px; text-align: center; line-height: 19px; }

.sysstatus__list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 9px; }
.sysstatus__item { display: flex; align-items: flex-start; gap: 8px; }
.sysstatus__dot { margin-top: 5px; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.sysstatus__dot--down { background: #FF5B66; box-shadow: 0 0 0 3px rgba(255,91,102,0.15); }
.sysstatus__dot--warn { background: #F0A500; }
.sysstatus__dot--info { background: rgba(255,255,255,0.40); }

.sysstatus__body { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
.sysstatus__top { display: flex; align-items: baseline; gap: 8px; }
.sysstatus__name { flex: 1 1 auto; min-width: 0; color: var(--sidebar-fg-on); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sysstatus__count { flex: 0 0 auto; color: var(--sidebar-fg); font-size: 11px; font-variant-numeric: tabular-nums; }

.sysstatus__bot { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sysstatus__tag { flex: 0 0 auto; padding: 1px 7px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.sysstatus__tag--down { background: rgba(255,91,102,0.18); color: #FF9AA1; }
.sysstatus__tag--warn { background: rgba(240,165,0,0.18); color: #F4B740; }
.sysstatus__tag--info { background: rgba(255,255,255,0.10); color: var(--sidebar-fg); }
.sysstatus__slug { flex: 1 1 auto; min-width: 0; color: rgba(255,255,255,0.38); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sysstatus__note { margin: 10px 0 0; color: var(--sidebar-fg); line-height: 1.45; }
.sysstatus__note--ok { margin: 6px 0 0; color: rgba(255,255,255,0.5); }
.sysstatus__note a { color: var(--sidebar-fg-on); text-decoration: underline; white-space: nowrap; }

/* ============================================================
   MAP — quartieri + macro-category explorer (events/map.html)
   ============================================================ */
.mapfilters {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: start;
  gap: 14px 18px; margin: 16px 0 14px;
}
.mapdates { align-self: start; }
.mapdates .date-menu__button { min-width: 172px; }
.mapcatwrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.maphelp { margin: 0; font-size: 0.72rem; color: var(--muted); }
.mapmeta { margin: 0 0 10px; }
.mapmeta strong { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.mapmeta span { color: var(--muted); font-size: 0.84rem; }
.mapcanvas--full { height: clamp(480px, 74vh, 780px); }

/* Category filter — tri-state chips mirroring the weekly feed's interest picker. Click cycles
   off -> include -> exclude; double-click solos. The colour lives in the icon; the chip's own
   look carries the state (include = tinted, exclude = dimmed + struck). --cat = its brand hue.
   The whole group sits in a subtle inset tray so the 15 chips read as one tidy palette. */
.mapcats {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px;
  padding: 7px; border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--paper); max-width: none; box-shadow: var(--shadow-xs);
}
.mapcat {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font: inherit;
  font-size: 0.76rem; font-weight: 600; line-height: 1; color: var(--ink); user-select: none;
  background: var(--cream-2); border: 1px solid transparent; border-radius: 8px; padding: 5px 8px;
  transition: background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.mapcat:hover { background: var(--paper); border-color: var(--line); }
.mapcat__icon { font-size: 17px; line-height: 1; flex: none; color: var(--cat, #6B7280); }
.mapcat__label { white-space: nowrap; }
.mapcat[data-state="in"] {
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  border-color: color-mix(in srgb, var(--cat) 45%, transparent);
}
.mapcat[data-state="out"] { opacity: 0.4; }
.mapcat[data-state="out"] .mapcat__icon { filter: grayscale(1); }
.mapcat[data-state="out"] .mapcat__label { text-decoration: line-through; }

@media (max-width: 560px) { .mapcats { max-width: none; } }

/* Side-panel readout of the hovered neighbourhood + its count (replaces the floating tooltip). */
.maphover { font-size: 0.82rem; font-weight: 700; color: var(--red-dark); min-height: 1.1em; margin: 0 0 6px; }
.maphover:empty { display: none; }

/* Clicking a Leaflet polygon focuses its SVG <path>, which the browser rings with a black
   bounding-box outline (the "weird black border"). Drop it — selection shows via the dashed
   red style instead. Keyboard focus is unaffected (paths aren't in the tab order). */
.leaflet-interactive:focus { outline: none; }

.maplayout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: clamp(16px, 2vw, 24px); align-items: start; }
.mapcanvas {
  position: relative; z-index: 0;  /* own stacking context: Leaflet's high z-indexes stay inside */
  height: clamp(420px, 64vh, 620px); border-radius: var(--radius-l); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow-s); background: var(--cream-2);
}
.mappanel {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 16px; box-shadow: var(--shadow-s);
  max-height: clamp(420px, 64vh, 620px); display: flex; flex-direction: column;
}
.mappanel__head { display: flex; align-items: baseline; gap: 6px; margin: 0 0 4px; }
.mappanel__head strong { font-size: 1.3rem; font-weight: 800; color: var(--ink); line-height: 1; }
.mappanel__head span { color: var(--muted); font-size: 0.84rem; }
.mappanel__head .linklike { margin-left: auto; }
.mappanel .sidehint { margin: 0 0 10px; }
.mapchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.mapchips:empty { display: none; }
.qchip {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  font: inherit; font-size: 0.74rem; font-weight: 700; line-height: 1; color: #fff;
  background: var(--red); border: 0; border-radius: var(--radius-pill); padding: 5px 7px 5px 11px;
  transition: background var(--t-fast);
}
.qchip:hover { background: var(--red-dark); }
.qchip .material-symbols-outlined { font-size: 15px; }
.maplist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.maprow { display: flex; gap: 9px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.maprow:last-child { border-bottom: 0; }
.maprow__dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.maprow__main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.maprow__main strong { font-size: 0.86rem; line-height: 1.25; color: var(--ink); transition: color var(--t-fast); }
.maprow:hover .maprow__main strong { color: var(--red-dark); }
.maprow__main span { color: var(--muted); font-size: 0.74rem; }
.mappanel .empty { padding: 18px 14px; }

/* Leaflet popup, scoped to win over the later-loaded leaflet.css (equal specificity) */
.maplayout .leaflet-popup-content { font-family: "Montserrat", system-ui, sans-serif; font-size: 0.84rem; line-height: 1.45; margin: 12px 14px; }
.maplayout .leaflet-popup-content a { color: var(--red-dark); font-weight: 700; }

/* Neighbourhood label — a clean Montserrat pill (with its live event count) instead of
   Leaflet's default yellow box, and no arrow so the sticky label reads cleanly under the cursor. */
.leaflet-tooltip.nil-tip {
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 9px; font-family: "Montserrat", system-ui, sans-serif;
  font-size: 0.76rem; font-weight: 600; box-shadow: var(--shadow-s); white-space: nowrap;
}
.leaflet-tooltip.nil-tip strong { font-weight: 800; }
.leaflet-tooltip.nil-tip::before { display: none; }

/* Settings neighbourhood picker — the same NIL map; click a neighbourhood to set your area. */
.locmap {
  position: relative; z-index: 0;
  height: clamp(300px, 42vh, 420px); border-radius: var(--radius-m); overflow: hidden;
  border: 1px solid var(--line); margin: 6px 0 10px; background: var(--cream-2);
}

@media (max-width: 880px) {
  .mapfilters { grid-template-columns: 1fr; }
  .mapdates,
  .mapdates .date-menu,
  .mapdates .date-menu__button { width: 100%; }
  .mapcats { max-height: 190px; overflow-y: auto; }
  .maplayout { grid-template-columns: 1fr; }
  .mappanel { position: static; max-height: none; }
  .maplist { max-height: 360px; }
}

@media (max-width: 640px) {
  .mapfilters { gap: 10px; margin-bottom: 10px; }
  .mapdates { padding: 5px; }
  .mapdates .feed-datebar__icon { display: none; }
  .mapdates .date-menu__button { min-width: 0; min-height: 38px; }
  .mapcats {
    gap: 4px;
    padding: 6px;
    max-height: 150px;
    border-radius: 12px;
  }
  .mapcat {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 7px 7px;
    font-size: 0.72rem;
  }
  .mapcat__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mapmeta { margin-bottom: 8px; }
  .mapcanvas--full,
  .mapcanvas { height: min(520px, 62vh); border-radius: 14px; }
  .leaflet-control-container .leaflet-top,
  .leaflet-control-container .leaflet-bottom { z-index: 450; }
}

/* ============================================================
   FEED v5 (2026-07) — macro-tab toolbar + one visible controls row (no popovers)
   ============================================================ */

/* Day headers: weekday leads (the datum you scan for), date + count support it, and the
   whole row STICKS (just under the toolbar) while its day's cards scroll under —
   calendar-style orientation in a long feed. */
:root { --feed-toolbar-h: 56px; }
/* A paper band, same chrome as the filter card — so when it sticks it docks FLUSH under
   the tab card (top overlaps the card's edge by 2px: no cream sliver between them). */
.day-head {
  display: flex; align-items: baseline; gap: 8px;
  position: sticky; top: calc(var(--feed-toolbar-h) - 2px); z-index: 10;
  margin: 24px 0 12px; padding: 9px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m);
}
.day-head__name { font-weight: 700; }
.day-head__date { font-weight: 500; color: var(--muted); font-size: 0.88em; }
.day-head__count {
  margin-left: auto; font-size: 0.72rem; font-weight: 700; color: var(--muted);
  background: var(--cream-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 8px; line-height: 1.3;
}

/* THE TOOLBAR — replaces the old white filter card entirely: one quiet sticky row (search +
   macro tabs), so the events start basically at the top. The fine controls live VISIBLY in
   the results' controls row, next to the date menus. */
/* ONE component: the filter panel is a single white card — tabs + sub-tabs in the sticky
   top half (.feed-filters), the controls row (dates/fonte/distance, AJAX-swapped) fused on
   as the card's bottom half (see .feed-controls below). Sticky lives on the WRAPPER
   (.feed-filters): the form's own parent is only as tall as itself, so sticking the form
   would stop the moment its parent scrolls off — the wrapper participates in the tall
   .feed-shell instead. Its height is mirrored into --feed-toolbar-h by a ResizeObserver in
   feed.html, which keeps the day headers sticking exactly underneath. */
.feed-shell .feed-filters {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-l) var(--radius-l) 0 0; border-bottom: 0;
  padding: 4px 14px 0;
}
.filters--toolbar {
  display: block; margin: 0; padding: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.ftoolbar { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; min-height: 62px; }
/* The search label needs the .filters--toolbar prefix to out-rank the generic
   `.filters label` column layout. */
.filters--toolbar .ftoolbar__search {
  display: flex; flex-direction: row; align-items: center; gap: 6px; flex: none;
  font-size: inherit; font-weight: 400; text-transform: none; letter-spacing: 0;
  background: var(--cream-2); border: 1px solid transparent; border-radius: 999px;
  padding: 0 4px 0 10px; transition: border-color var(--t-fast), background var(--t-fast);
}
.filters--toolbar .ftoolbar__search:focus-within { background: var(--paper); border-color: var(--red); }
.filters--toolbar .ftoolbar__search > .material-symbols-outlined { font-size: 17px; color: var(--faint); flex: none; }
.filters--toolbar .ftoolbar__search input {
  width: 110px; min-width: 0; font: inherit; font-size: 0.86rem; color: var(--ink);
  background: transparent; border: 0; padding: 8px 6px 8px 0; transition: width var(--t-fast);
}
.filters--toolbar .ftoolbar__search input:focus { outline: none; width: 170px; background: transparent; border-color: transparent; }

/* Macro tabs — Meetup-style: icon over label, underline marks the active one. Single
   select; "Tutti" is the reset. Short labels + flex:1 keep every tab the SAME width. */
.fam-tabs { display: flex; align-items: stretch; gap: 2px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.fam-tabs::-webkit-scrollbar { display: none; }
.ftab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 0; min-width: 0; cursor: pointer; padding: 10px 10px 11px;
  font: inherit; font-size: 0.86rem; font-weight: 600; line-height: 1; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.ftab:hover { color: var(--ink); }
.ftab__icon { font-size: 23px; color: var(--fam, var(--faint)); transition: transform var(--t-fast); }
.ftab:hover .ftab__icon { transform: translateY(-1px); }
.ftab.is-active { color: var(--ink); border-bottom-color: var(--fam, var(--ink)); }
.ftab__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Preferite's companion: a small round "edit in Settings" control ON the tab face, right
   of the heart (an <a> can't nest in the tab <button>, so tab + link share a wrapper and
   the link is absolutely placed on the icon row). 24px target — touch-ok. */
.ftab-wrap { position: relative; display: flex; flex: 1 1 0; min-width: 0; }
.ftab-wrap .ftab { flex: 1 1 auto; width: 100%; }
.ftab__edit {
  position: absolute; top: 7px; left: calc(50% + 16px);
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  color: var(--red); background: var(--red-soft); border: 1px solid var(--red-ring);
  text-decoration: none;
}
.ftab__edit:hover { background: var(--red); color: #fff; }
.ftab__edit .material-symbols-outlined { font-size: 14px; }
.ftab__edit[hidden] { display: none; }

/* Subcategory tabs: a smaller second line of the same tab language. */
.sub-tabs { padding: 2px 0 8px; }
.sub-tabs[hidden] { display: none; }
.sub-tabs__group { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.sub-tabs__group[hidden] { display: none; }
.ftab--sub {
  flex: none; flex-direction: row; gap: 6px; padding: 8px 12px; font-size: 0.84rem;
  border-bottom-width: 2px;
}
.ftab--sub.is-active { color: var(--ink); border-bottom-color: var(--cat, var(--fam, var(--ink))); }
.ftab__subicon { font-size: 17px; color: var(--cat, var(--fam, var(--faint))); flex: none; }

/* Settings: the Categories card — sidebar sections + favourite categories as ONE chip
   language with ONE save. The native checkbox is hidden; a chip is its own control:
   neutral at rest, category-tinted with a check glyph when selected. */
.favcat-block { margin-top: 4px; }
.favcat-block + .favcat-block { margin-top: 20px; }
.favcat-block__cap {
  display: block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink);
}
.favcat-block__hint { margin: 2px 0 10px; font-size: 0.8rem; color: var(--muted); }
.favcat-group__choices { display: flex; flex-wrap: wrap; gap: 8px; }
.favcat-choice {
  position: relative; display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 0.86rem; font-weight: 600; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 14px; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.favcat-choice:hover { border-color: color-mix(in srgb, var(--cat) 55%, transparent); color: var(--ink); }
.favcat-choice .material-symbols-outlined { font-size: 17px; color: var(--cat, var(--faint)); }
.favcat-choice input {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.favcat-choice:has(input:checked) {
  background: color-mix(in srgb, var(--cat) 13%, transparent);
  border-color: color-mix(in srgb, var(--cat) 55%, transparent);
  color: var(--ink);
}
/* The selected chip grows a small check glyph in place of dead air. */
.favcat-choice::after {
  content: "check"; font-family: "Material Symbols Outlined"; font-size: 15px;
  width: 0; overflow: hidden; color: var(--cat, var(--ink));
  transition: width var(--t-fast);
}
.favcat-choice:has(input:checked)::after { width: 15px; }
.favcat-choice input:focus-visible ~ * { outline: 2px solid var(--red); outline-offset: 2px; }
/* Onboarding: the tiny "has its own sidebar section" star marker on a chip. */
.favcat-choice__star { font-size: 13px; color: var(--warn, #D97706); flex: none; }

/* The controls row = the BOTTOM HALF of the single filter card: it lives in the
   AJAX-swapped results region, but fuses onto .feed-filters visually (same paper, shared
   side borders, bottom radius). Dates + Fonte sit LEFT; distance chips push RIGHT. */
.feed-controls {
  flex-wrap: wrap;
  margin: 0 0 22px; padding: 12px 14px;
  background: var(--paper); border: 1px solid var(--line); border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--radius-l) var(--radius-l);
}
.feed-controls .interest-picker__caption { display: none; }
.feed-controls .interest-picker { flex-direction: row; }
/* Inside the card every field is WHITE with a thin border (owner: the grey blobs read as
   one mush) — and the Date + Fonte fields share ONE explicit recipe: same background in
   every state, same radius, same 0.9rem/700 type, same grey caret. Active state = a red
   ring, never a background change. */
.feed-controls .datebar,
.feed-controls .interest-picker__toggle {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: none; font-size: 0.9rem; font-weight: 700; color: var(--ink);
}
.feed-controls .interest-picker__toggle { min-width: 170px; padding: 12px 12px; }
.feed-controls .interest-picker__toggle:hover { background: var(--paper); border-color: var(--faint); }
.feed-controls .interest-picker.is-active .interest-picker__toggle {
  background: var(--paper); border-color: var(--red-ring);
}
.feed-controls .date-menu__button { font-size: 0.9rem; font-weight: 700; color: var(--ink); }
/* Beat `.interest-picker__toggle > .material-symbols-outlined { color: red }` for the
   CARET specifically — the datebar caret is grey, this must match. */
.feed-controls .interest-picker__toggle > .interest-picker__caret { color: var(--faint); font-size: 18px; }
.distance-pick--inline { display: flex; flex-direction: row; align-items: center; gap: 6px; min-width: 0; align-self: center; margin-left: auto; }
.distance-pick--inline .distance-pick__cap { display: none; }
.distance-pick--inline .dchip { background: var(--paper); border-color: var(--line); }
.distance-pick--inline .dchip:hover { border-color: var(--faint); }

/* Family clusters inside the Categorie picker panel: thin colour-tagged captions so the
   fine chips read as small groups. */
.interest-picker__groups { display: flex; flex-direction: column; gap: 10px; }
.interest-group { display: flex; flex-direction: column; gap: 6px; }
.interest-group__cap {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
}
.interest-group__cap::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--fam, var(--faint)); flex: none;
}

@media (max-width: 1024px) {
  /* The mobile topbar is sticky at top:0 — the toolbar rides under it, day rows under both.
     The toolbar keeps its single-row shape; family chips scroll horizontally. */
  .feed-shell .feed-filters { top: var(--topbar-h); }
  .day-head { top: calc(var(--topbar-h) + var(--feed-toolbar-h) - 2px); }
}
/* The page-head search field (feed) — same quiet pill as the card's inner fields. */
.headsearch {
  display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 4px 0 12px; transition: border-color var(--t-fast);
}
.headsearch:focus-within { border-color: var(--red); }
.headsearch > .material-symbols-outlined { font-size: 17px; color: var(--faint); flex: none; }
.headsearch input {
  width: 140px; min-width: 0; font: inherit; font-size: 0.88rem; color: var(--ink);
  background: transparent; border: 0; padding: 9px 8px 9px 0; transition: width var(--t-fast);
}
.headsearch input:focus { outline: none; width: 200px; }
.page-head .headsearch + .view-toggle { margin-left: 14px; }

@media (max-width: 640px) {
  /* Tabs stop stretching and scroll horizontally, at a size that keeps ~5 on a phone.
     Search shares the page-head row with the title. */
  .ftab { flex: none; padding: 8px 9px 9px; font-size: 0.72rem; gap: 4px; }
  .ftab-wrap { flex: none; }
  .ftab__icon { font-size: 20px; }
  .ftab--sub { padding: 7px 9px; font-size: 0.76rem; }
  .feed-shell .feed-filters { padding: 0 10px; }
  .ftoolbar { min-height: 56px; gap: 6px; }
  .feed-controls { padding: 10px; gap: 8px; }
  /* Date + Fonte become two identical full-width rows. */
  .feed-controls .datebar,
  .feed-controls .interest-picker,
  .feed-controls .interest-picker__toggle { width: 100%; min-width: 0; }
  .headsearch input { width: 90px; }
  .headsearch input:focus { width: 140px; }
  .distance-pick--inline { margin-left: 0; }
}

@media (max-width: 400px) {
  .mapcat { flex-basis: 100%; }
}

/* Invite auth */
.login-form { display: grid; gap: 12px; width: 100%; }
.login-form label { display: grid; gap: 6px; color: var(--ink); font-weight: 700; font-size: 0.84rem; text-align: left; }
.login-form input[type=email],
.login-form input[type=password] {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); padding: 9px 11px; font: inherit;
}
.login-form .errorlist { margin: 0; padding-left: 18px; color: var(--red-dark); font-size: 0.82rem; text-align: left; }
/* On the dark login panel the deep red is unreadable — lift it. */
.lp-login-panel .login-form .errorlist { color: #ff8f96; }
.login__forgot {
  display: block; margin-top: 2px; color: rgba(255,255,255,0.55);
  font-size: 0.8rem; text-decoration: none; text-align: center;
}
.login__forgot:hover { color: #fff; text-decoration: underline; }
/* Beats `.lp-login-panel p` (the SOLO-SU-INVITO tag style) — body copy must NOT be shouty caps. */
.lp-login-panel p.lp-login-panel__text {
  margin: 0; color: rgba(255,255,255,0.75); font-size: 0.9rem; font-weight: 400;
  line-height: 1.5; text-align: left; text-transform: none; letter-spacing: 0;
}
.hp-field { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
.btn--block { width: 100%; justify-content: center; }
.login__divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0; }
.login__divider::before,
.login__divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.lp-hero-main { display: grid; justify-items: center; }
.lp-hero-main[hidden],
.lp-login-panel[hidden] { display: none !important; }
.lp-login-panel {
  width: min(380px, calc(100vw - 32px)); display: grid; gap: 14px;
  padding: 20px; border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
  background: rgba(21, 20, 25, 0.82); box-shadow: 0 20px 80px rgba(0,0,0,0.34);
  backdrop-filter: blur(10px);
}
.lp-login-panel__head { display: flex; align-items: center; gap: 12px; text-align: left; }
.lp-login-panel__logo {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px;
  background: #fff; flex: none;
}
.lp-login-panel__logo img { width: 34px; height: 34px; }
.lp-login-panel h1 { margin: 0; color: #fff; font-size: 1.6rem; line-height: 1; }
.lp-login-panel p { margin: 4px 0 0; color: rgba(255,255,255,0.68); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }
.lp-login-panel .login-form label { color: #fff; }
.lp-login-panel .login-form input { background: #fff; }
.lp-login-panel .login__divider { color: rgba(255,255,255,0.62); }
.lp-login-panel .login__divider::before,
.lp-login-panel .login__divider::after { background: rgba(255,255,255,0.18); }
.lp-cta--submit { border: 0; cursor: pointer; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.category-choice {
  display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--cream-2);
  color: var(--ink); font-size: 0.86rem; font-weight: 700;
}
.category-choice input { flex: none; }
.category-choice__star {
  margin-left: auto; font-size: 16px; color: var(--red);
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 20;
}
.category-choice__icon { flex: none; font-size: 18px; color: var(--muted); }
.category-grid__legend {
  display: flex; align-items: center; gap: 5px; margin: 6px 0 0;
  color: var(--muted); font-size: 0.8rem;
}
.category-grid__legend .category-choice__star { margin-left: 0; }

/* ---------- Onboarding (sidebar-less focused shell) ---------- */
.onb { min-height: 100vh; display: flex; flex-direction: column; }
.onb__bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink, #191716); padding: 10px 18px;
}
.onb__bar .signout { width: auto; }
.onb__bar .brand { padding: 0; border-bottom: 0; }
.onb__main { width: min(860px, 100%); margin: 0 auto; padding: 34px 20px 64px; }

.sidebar-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sidebar-section-choice {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 10px;
  min-height: 52px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font-size: 0.88rem; font-weight: 800;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.sidebar-section-choice:has(input:checked) {
  border-color: color-mix(in srgb, var(--red) 42%, var(--line));
  background: color-mix(in srgb, var(--red) 7%, var(--paper));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 18%, transparent);
}
.sidebar-section-choice input { width: 16px; height: 16px; margin: 0; }
.sidebar-section-choice__icon { font-size: 21px; color: var(--red-dark); }

@media (max-width: 680px) {
  .sidebar-section-grid { grid-template-columns: 1fr; }
}

.invite-list { display: grid; gap: 8px; }
.invite-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.invite-row:last-child { border-bottom: 0; }
.invite-row span { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
