/* =============================================================================
   FamilyCalendar — stylesheet
   =============================================================================

   MOBILE-FIRST. Every rule in the main body is written for a phone. Desktop
   is added at the bottom under a single @media (min-width: 900px) block that
   only ADDS. It never has to undo anything, so nothing can leak between the
   two — which is what broke the previous version.

   Hierarchy rule, used everywhere:
     .k   small, muted, uppercase   = the label
     .v   larger, bold              = the data
   ============================================================================= */

:root {
  /* Contrast-first palette. Backgrounds are three clearly separate tones,
     text is near-black, and every tint (Shabbos, Yom Tov, out-of-month,
     selected) is a distinct colour rather than a shade of the same beige. */
  --ink: #141c26;          /* text */
  --paper: #e9e5dc;        /* page background -- visibly darker than cards */
  --card: #ffffff;         /* cards, cells, fields */
  --rail: #dcd6ca;         /* nav rail, top bar, table headers */
  --soft: #f3f0ea;         /* subtle hover / inner sections */
  --line: #b9b1a2;         /* borders -- dark enough to see */
  --muted: #4d545d;        /* secondary text, 7:1 on white */
  --brass: #7d5010;        /* primary action, 5.8:1 on white */
  --brass-bg: #9c6218;     /* filled buttons */
  --oxblood: #8f2f22;      /* danger, stale */
  --sage: #29603d;         /* ok, connected, Yom Tov */
  --amber: #9a6a00;
  --shabbos: #f6e7c8;      /* warm sand -- clearly not white */
  --yomtov: #d6e8d2;       /* green tint */
  --outmonth: #ece9e2;     /* out-of-month cells */
  --sel: #141c26;
  --birth: #b8772a; --wedding: #6b5aa8; --death: #3c4a5a; --other: #2f6b45;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", Palatino, Georgia, serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  --top: calc(52px + env(safe-area-inset-top));
  --tab: calc(58px + env(safe-area-inset-bottom));
  --r: 10px;
  --gap: 12px;             /* THE spacing unit between controls. 8px read as "touching". */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.45 var(--sans); overflow-x: hidden;
  padding-top: var(--top); padding-bottom: calc(var(--tab) + 76px); min-height: 100dvh;   /* + room to scroll the last row clear of the FAB */
}
a { color: var(--brass); text-decoration: none; }
h1 { font: 400 24px/1.15 var(--serif); margin: 0 0 4px; }
h1 .heb { font-size: 24px; color: var(--muted); font-family: var(--sans); font-weight: 400; }
h2 { font: 400 17px/1.3 var(--serif); margin: 0 0 10px; }
h3 { font: 700 11.5px/1.3 var(--sans); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
p { margin: 0 0 10px; }
code { font: 13px var(--mono); background: var(--soft); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.heb { direction: rtl; unicode-bidi: isolate; }
.ok-text { color: var(--sage); } .warn-text { color: var(--oxblood); font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.sub { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ---- Labels and values --------------------------------------------------- */
.k { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.v { font-size: 18px; font-weight: 600; line-height: 1.3; }
.kv { display: grid; grid-template-columns: 1fr; gap: 2px 14px; }
.kv .k { margin-top: 12px; } .kv .k:first-child { margin-top: 0; }
.kv .v { margin-bottom: 2px; }
.kv .v.plain { font-weight: 400; }

/* ---- Chrome: top bar --------------------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--top); padding: env(safe-area-inset-top) 6px 0;
  display: flex; align-items: center; gap: 2px;
  background: color-mix(in srgb, var(--rail) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { flex: 1; text-align: center; font: 600 17px var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border: 0; background: none; color: var(--brass); font: 600 15px var(--sans); border-radius: 22px; cursor: pointer; padding: 0; min-height: 0;
}
.iconbtn.big { font-size: 24px; }
.iconbtn:active { background: rgba(0,0,0,.06); }
.iconbtn[hidden] { display: none; }

/* ---- Chrome: tab bar ---------------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: var(--tab); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: color-mix(in srgb, var(--rail) 94%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 10.5px; min-height: 58px; position: relative; }
.tabbar a.on { color: var(--brass); font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar .dot { position: absolute; top: 8px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--oxblood); }

/* ---- Chrome: drawer (full section list) ------------------------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(28,42,58,.45); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.nav {
  position: fixed; top: 0; bottom: 0; left: 0; width: 272px; z-index: 70; background: var(--rail);
  padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 14px);
  transform: translateX(-102%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); visibility: hidden;
}
.nav.on { transform: translateX(0); visibility: visible; }
.nav .brand { font: 600 18px var(--serif); display: block; color: var(--ink); margin-bottom: 2px; }
.nav .dates { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.nav .greeting { font: italic 13px var(--serif); color: var(--muted); margin-bottom: 14px; }
.nav a.item { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--ink); margin-bottom: 2px; gap: 8px; }
.nav a.item.on { background: var(--ink); color: #fff; }
.nav a.item .pill { margin-left: auto; }
.nav .sep { border-top: 1px solid var(--line); margin: 10px 0; }
.nav .logout { display: block; margin-top: 20px; font-size: 13px; color: var(--muted); padding: 0 12px; }

/* ---- Content ------------------------------------------------------------------ */
.content { padding: 14px 16px 28px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 0 0 12px; }
.card > h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 12px; }
.stat { font: 400 26px/1 var(--serif); }
.stat small { display: block; font: 12px var(--sans); color: var(--muted); margin-top: 4px; }

/* ---- Buttons, chips, segmented ------------------------------------------------------ */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r); font: 600 15px var(--sans);
  background: var(--card); border: 1px solid var(--line); color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn.primary, button.primary { background: var(--brass-bg); border-color: var(--brass-bg); color: #fff; }
.btn.danger, button.danger { color: var(--oxblood); border-color: color-mix(in srgb, var(--oxblood) 40%, transparent); }
.btn.sm, button.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
button:active, .btn:active { filter: brightness(.94); }
button[disabled] { opacity: .5; }
.actions { display: flex; gap: var(--gap); margin: 12px 0 16px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.chips { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px 8px; margin: 0 -16px 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { font-size: 11.5px; color: var(--muted); } .chip.on .n { color: #cfd6e0; }
.seg { display: inline-flex; background: var(--rail); border-radius: 9px; padding: 3px; }
.seg a, .seg button { border: 0; background: none; min-height: 34px; padding: 0 11px; border-radius: 7px; font: 500 13.5px var(--sans); color: var(--muted); display: inline-flex; align-items: center; white-space: nowrap; }
.seg .on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--rail); color: var(--ink); font-weight: 600; white-space: nowrap; }
.pill.warn { background: var(--oxblood); color: #fff; }
.pill.ok { background: var(--sage); color: #fff; }
.pill.dim { background: var(--soft); color: var(--muted); font-weight: 500; border: 1px solid var(--line); }
.flash { padding: 10px 14px; border-left: 3px solid var(--brass); background: var(--card); border-radius: 0 var(--r) var(--r) 0; margin-bottom: 12px; font-size: 14px; }
.flash.error { border-color: var(--oxblood); } .flash.warn { border-color: var(--amber); } .flash.ok { border-color: var(--sage); }

/* ---- Forms ------------------------------------------------------------------------ */
input, select, textarea { font: 16px var(--sans); color: var(--ink); }   /* 16px: iOS does not zoom */
.field, form.grid input:not([type=checkbox]):not([type=file]), form.grid select, form.grid textarea, .toolbar input, .toolbar select, .filters input, .filters select {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
}
form.grid input[type=file] { padding: 10px 0; }
form.grid textarea { min-height: 90px; }
form.grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 6px 0; }
form.grid label { margin-top: 12px; }
form.grid label, .toolbar label { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
form.grid .help { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
form.grid .check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
form.grid .check input { width: 22px; height: 22px; }
form.grid .span { margin-top: 18px; display: flex; gap: var(--gap); flex-wrap: wrap; }
.toolbar { display: flex; flex-direction: column; gap: var(--gap); margin: 10px 0 14px; }
.toolbar .btn { width: 100%; }
.toolbar.hz { flex-direction: row; flex-wrap: wrap; }
.toolbar.hz > * { flex: 1 1 140px; }
.code { width: 100%; font: 600 34px/1 var(--mono); letter-spacing: .34em; text-align: center; padding: 16px 0 16px .34em; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
pre.out { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow: auto; font: 12px/1.4 var(--mono); max-height: 60dvh; white-space: pre-wrap; }
.inline { display: inline; }

/* ---- Lists (replace tables on mobile) --------------------------------------------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 58px; border-bottom: 1px solid var(--line); color: var(--ink); }
.li:last-child { border-bottom: 0; }
.li.stale { background: #f7dcd6; }
.li .main { flex: 1 1 0; min-width: 0; }
.li .t { font-weight: 600; }
.li .s { font-size: 12.5px; color: var(--muted); }
.li .r { text-align: right; font-size: 12.5px; color: var(--muted); flex: none; }
.li .r b { display: block; color: var(--ink); font-size: 14px; }
.li .chev { color: #b8b3a8; flex: none; }
.card .list { border: 0; border-radius: 0; margin: 0; }
.card .li { padding-left: 0; padding-right: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--rail); display: grid; place-items: center; font: 600 14px var(--serif); color: var(--ink); flex: none; }
.avatar.zl { color: var(--muted); } .avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.grp { background: #e3ecdd; }
.hero { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.hero .avatar { width: 56px; height: 56px; font-size: 20px; }
.hero .meta { font-size: 13px; color: var(--muted); }

/* ---- Event rows ----------------------------------------------------------------- */
.ev { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.ev:first-child { border-top: 0; }
.ev .bar { width: 4px; border-radius: 2px; flex: none; align-self: stretch; min-height: 34px; }
.ev .who { font-weight: 600; } .ev .who a { color: var(--ink); }
.ev .what { font-size: 13px; color: var(--muted); }
.ev .r { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--muted); flex: none; }
.i-birth { background: var(--birth); } .i-wedding { background: var(--wedding); } .i-death { background: var(--death); } .i-other { background: var(--other); }

/* ---- Alias rows ----------------------------------------------------------------- */
.alias { display: flex; align-items: center; gap: var(--gap); padding: 10px 0; border-top: 1px solid var(--line); }
.alias:first-of-type { border-top: 0; }
.alias .t { flex: 1; font-weight: 600; }
.alias .kind { font-size: 11.5px; color: var(--muted); font-weight: 400; direction: ltr; }
/* form.alias-edit is the inline editor and the add row; form.inline is a
   bare Remove button and must NOT stretch. The old ".alias form" matched
   both, which is why Remove sat glued to Edit. */
form.alias-edit { display: flex; gap: var(--gap); flex: 1 1 100%; align-items: center; flex-wrap: wrap; }
form.alias-edit input, form.alias-edit select { min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: var(--card); }
form.alias-edit input { flex: 1 1 160px; min-width: 0; }
form.alias-edit select { flex: 0 1 150px; }
.alias .btns { display: flex; gap: var(--gap); flex: none; }

/* ---- Calendar ------------------------------------------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-head h1 { font-size: 21px; }
.cal-nav { display: flex; gap: 0; flex: none; }
.cal-ctrl { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.cal-ctrl .seg { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.cal-jump { font-size: 14px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px 2px; margin: 8px 0 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1 / 1.15; border-radius: var(--r); padding: 5px 3px 3px; position: relative; min-height: 0;
  display: flex; flex-direction: column; align-items: center; background: none; border: 0; font: inherit; color: inherit; text-align: center;
}
.cal-cell .top { display: contents; }
.cal-cell .d { font-size: 15px; font-weight: 600; line-height: 1; color: inherit; }
.cal-cell .d sup { font-size: 9px; font-weight: 400; }
.cal-cell .h { font-size: 9.5px; color: var(--muted); margin-top: 3px; }
.cal-cell .dots { display: flex; gap: 3px; margin-top: auto; height: 6px; }
.cal-cell .dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.cal-cell .names { display: none; }
.cal-cell.out { background: var(--outmonth); color: #8a8a8a; }
.cal-cell.out .h { color: #a0a0a0; }
.cal-cell.shabbos { background: var(--shabbos); }
.cal-cell.yomtov { background: var(--yomtov); }
.cal-cell.today .d { color: var(--brass); text-decoration: underline; text-underline-offset: 3px; }
.cal-cell.sel { background: var(--sel); color: #fff; }
.cal-cell.sel .d, .cal-cell.sel.today .d { color: #fff; }
.cal-cell.sel .h { color: #cfd6e0; }
.cal-fest { font-size: 8px; color: var(--sage); font-weight: 800; margin-top: 2px; line-height: 1; text-align: center; }
.agenda { margin-top: 14px; }
.agenda h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cal-list .day { margin-bottom: 14px; }
.cal-list .day h2 { display: flex; justify-content: space-between; align-items: baseline; }
.cal-year { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cal-year .day { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 4px 0; font-size: 13px; }

/* ---- FAB, sheet, picker ------------------------------------------------------------ */
.fab { position: fixed; right: 16px; bottom: calc(var(--tab) + 14px); z-index: 45; width: 56px; height: 56px; border-radius: 28px; border: 0; background: var(--brass); color: #fff; box-shadow: 0 6px 18px rgba(28,42,58,.25); display: grid; place-items: center; padding: 0; min-height: 0; }
.fab svg { width: 26px; height: 26px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; background: var(--card); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.18); transform: translateY(105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92dvh; display: flex; flex-direction: column; overflow-y: auto; visibility: hidden; }
.sheet.on { transform: translateY(0); visibility: visible; }
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: #d6d0c4; margin: 4px auto 12px; flex: none; }
.sheet label { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 4px; }
.sheet textarea { min-height: 110px; resize: none; }
.to { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.to .val { flex: 1; min-width: 0; }
.to .val .s { font-size: 12.5px; color: var(--muted); }
.to .placeholder { color: #9a9a9a; }
.sheet .row { margin-top: 12px; flex-wrap: nowrap; }
.sheet .row .btn { flex: 1; }
.row { gap: var(--gap); }
.sheet .status { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.light { width: 10px; height: 10px; border-radius: 50%; background: #bbb; flex: none; }
.light.ok { background: var(--sage); } .light.bad { background: var(--oxblood); } .light.warn { background: var(--amber); }
.picker { position: fixed; inset: 0; z-index: 80; background: var(--paper); transform: translateY(100%); visibility: hidden; transition: transform .22s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.picker.on { transform: translateY(0); visibility: visible; }
.picker .bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px; border-bottom: 1px solid var(--line); background: var(--rail); flex: none; }
.picker .bar .field { flex: 1; }
.picker .results { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.picker .sec { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px 4px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 60px; border-bottom: 1px solid var(--line); background: var(--card); cursor: pointer; }
.opt .main { flex: 1; min-width: 0; }
.opt .t { font-weight: 600; } .opt .s { font-size: 12.5px; color: var(--muted); }
.opt .nowl { color: var(--oxblood); font-weight: 600; font-size: 11px; }
.opt.hl { background: var(--soft); }

/* ---- Person type-ahead (inline, both sizes) ----------------------------------------- */
.ta { position: relative; }
.ta .results { position: absolute; z-index: 30; left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); max-height: 260px; overflow: auto; display: none; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.ta .results .opt { min-height: 48px; padding: 8px 12px; }

/* ---- Chats ------------------------------------------------------------------------- */
.bubbles { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.bubble { max-width: 84%; padding: 9px 12px; border-radius: 14px; background: #ebe7de; align-self: flex-start; font-size: 15px; white-space: pre-wrap; unicode-bidi: plaintext; }
.bubble.out { background: #d3e5cc; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.in { border-bottom-left-radius: 4px; }
.bubble .ts { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; unicode-bidi: normal; direction: ltr; }
.reply { position: sticky; bottom: calc(var(--tab) + 6px); display: flex; gap: var(--gap); background: var(--paper); padding: 8px 0 4px; }
.reply .field { flex: 1; min-height: 44px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 6px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.preview-msg { padding: 8px 0; border-top: 1px solid var(--line); }
.preview-msg .bubble { max-width: 100%; margin-top: 6px; }

/* ---- Login ------------------------------------------------------------------------- */
body.login { padding: 0; }
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login-wrap h1 { font-size: 30px; text-align: center; }
.login-wrap p { text-align: center; color: var(--muted); font-size: 14px; }
.login-wrap .code { margin: 18px 0 12px; }
.login-wrap .btn { width: 100%; font-size: 16px; min-height: 50px; }
.login-wrap details { margin-top: 22px; text-align: center; }
.login-wrap summary { color: var(--muted); font-size: 13px; cursor: pointer; }

/* ---- Tree ------------------------------------------------------------------------ */
.tree { list-style: none; padding: 0; margin: 0; }
.tree li { padding: 6px 0; border-top: 1px solid var(--line); }
.tree li:first-child { border-top: 0; }
.tree .d1 { padding-left: 16px; } .tree .d2 { padding-left: 32px; } .tree .d3 { padding-left: 48px; } .tree .d4 { padding-left: 64px; } .tree .d5 { padding-left: 80px; }
.zl { color: var(--muted); }

/* ---- Desktop-only helpers hidden on mobile -------------------------------------------- */
.side, .desk { display: none; }

/* =============================================================================
   DESKTOP — adds only.
   ============================================================================= */
@media (min-width: 900px) {
  :root { --top: 0px; --tab: 0px; }
  body { display: grid; grid-template-columns: 210px minmax(0,1fr) 320px; grid-template-areas: "nav main side"; padding: 0; }
  body.viewer { grid-template-columns: 210px minmax(0,1fr); grid-template-areas: "nav main"; }
  body.login { display: block; }
  .topbar, .tabbar, .fab, .scrim, .sheet, .picker { display: none; }
  .nav { grid-area: nav; position: sticky; top: 0; height: 100vh; transform: none; transition: none; visibility: visible; width: auto; border-right: 1px solid var(--line); padding: 20px 14px; }
  .nav a.item { min-height: 38px; }
  .content { grid-area: main; padding: 28px 32px 48px; max-width: 1200px; }
  .side { grid-area: side; display: block; background: var(--rail); border-left: 1px solid var(--line); padding: 20px 18px; position: sticky; top: 0; height: 100vh; overflow: auto; }
  .side .status { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 2px; }
  .side .k { display: block; margin: 12px 0 4px; }
  .side textarea { min-height: 120px; }
  .side .ta .results { max-height: 320px; }
  .desk { display: initial; }
  h1 { font-size: 28px; } h2 { font-size: 18px; }
  .cols { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
  .cols.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .stats { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .actions { justify-content: flex-start; } .actions .btn { flex: none; }
  .chips { margin: 0 0 10px; padding: 2px 0 4px; flex-wrap: wrap; overflow: visible; }
  .toolbar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .toolbar > * { width: auto; } .toolbar .btn { width: auto; }
  .toolbar input, .toolbar select { width: auto; min-width: 160px; }
  .toolbar .grow { flex: 1 1 260px; }
  .toolbar.hz > * { flex: 0 0 auto; }
  form.grid { grid-template-columns: 200px minmax(0,1fr); gap: 10px 16px; align-items: center; max-width: 780px; }
  form.grid label { margin-top: 0; }
  form.grid .help { grid-column: 2; margin-top: -6px; }
  form.grid .span { grid-column: 1 / -1; }
  .kv { grid-template-columns: fit-content(170px) minmax(0,1fr); gap: 10px 16px; align-items: baseline; }
  .kv .k { margin-top: 0; } .kv .v { margin: 0; }
  .li { min-height: 52px; padding: 9px 14px; }
  .li .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cal-head h1 { font-size: 26px; }
  .cal-ctrl { flex-direction: row; justify-content: space-between; align-items: center; }
  .cal-grid { gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 14px; }
  .cal-wd { background: var(--rail); padding: 6px; text-transform: uppercase; }
  .cal-cell { aspect-ratio: auto; min-height: 116px; border-radius: 0; background: var(--card); align-items: stretch; padding: 6px 8px; text-align: left; }
  .cal-cell .top { display: flex; justify-content: space-between; align-items: baseline; }
  .cal-cell .h { margin: 0; font-size: 11px; }
  .cal-cell .dots { display: none; }
  .cal-cell .names { display: block; margin-top: 4px; font-size: 12px; text-align: left; }
  /* Names WRAP; only the description truncates. Two names in one cell must
     never collapse to "Ch… & Le…". */
  .cal-cell .names div { display: block; margin: 3px 0; min-width: 0; line-height: 1.25; }
  .cal-cell .names i { display: inline-block; vertical-align: middle; margin-right: 4px; }
  .cal-cell .names a { white-space: normal; }
  .cal-cell .names span { display: block; padding-left: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
  .cal-cell .names i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
  .cal-cell .names a { color: var(--ink); font-weight: 600; }
  .cal-cell .names span { color: var(--muted); }
  .cal-cell.sel { background: var(--card); color: inherit; outline: 3px solid var(--brass-bg); outline-offset: -3px; }
  .cal-cell.sel .d { color: var(--ink); } .cal-cell.sel.today .d { color: var(--brass); }
  .cal-cell.sel .h { color: var(--muted); }
  .cal-fest { text-align: left; font-size: 10px; }
  .agenda.month-only { display: none; }
  .cal-year { grid-template-columns: repeat(3, 1fr); }
  .chat-layout { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; }
  .chat-list { max-height: 78vh; overflow: auto; }
  .bubbles { max-height: 62vh; overflow: auto; padding: 12px; }
  .reply { position: static; }
  .chat-back { display: none; }
  .stat { font-size: 30px; }
}
@media (min-width: 900px) and (max-width: 1150px) {
  body { grid-template-columns: 190px minmax(0,1fr) 280px; }
  .cols.three { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* ---- Filters: a side sheet on phones, a compact bar on desktop ------------- */
.filters { position: fixed; inset: 0 0 0 auto; width: min(86vw, 360px); z-index: 75; background: var(--card);
  transform: translateX(104%); transition: transform .22s cubic-bezier(.2,.8,.2,1); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 16px); box-shadow: -8px 0 30px rgba(0,0,0,.18); visibility: hidden; }
.filters.on { transform: translateX(0); visibility: visible; }
.filters h2 { display: flex; justify-content: space-between; align-items: center; }
.filters .f { margin-bottom: 14px; }
.filters .f label { display: block; margin-bottom: 4px; }
.filters .span { display: flex; gap: var(--gap); margin-top: 8px; }
.filters .span .btn { flex: 1; }
.filter-btn { display: inline-flex; }
@media (min-width: 900px) {
  .filters { position: static; width: auto; transform: none; transition: none; box-shadow: none; padding: 0; visibility: visible;
    background: none; display: flex; flex-wrap: wrap; gap: var(--gap); align-items: end; margin: 8px 0 14px; }
  .filters h2, .filters .close { display: none; }
  .filters .f { margin: 0; flex: 1 1 150px; max-width: 220px; }
  .filters .f.wide { flex: 2 1 240px; max-width: 320px; }
  .filters .span { margin: 0; flex: none; }
  .filters .span .btn { flex: none; }
  .filter-btn { display: none; }
}
form.grid.tight { max-width: none; }
@media (min-width: 900px) { form.grid.tight { grid-template-columns: 140px minmax(0,1fr); } }
@media (min-width: 900px) {
  .toolbar input[type=number] { min-width: 0; width: 96px; }
  .card form.grid { grid-template-columns: 120px minmax(0,1fr); max-width: none; }
}
/* On phones a search box owns its row; buttons go beneath it. */
.toolbar.hz .grow { flex: 1 1 100%; }
@media (min-width: 900px) { .toolbar.hz .grow { flex: 1 1 260px; } }
