/* Obscura HQ — "Aperture".
   A darkroom layout in the studio's monochrome identity. Colour is reserved for
   pipeline status: if something on screen is coloured, it is telling you where a
   post sits between Idea and Published. Everything else is bone, ash and hairline.

   Source of truth for this palette: docs/design/aperture.dc.html (artboards 01-07).
   Before this, the app shipped the stock baseplate light theme (warm off-white,
   burnt orange, 8px radii, 76 hardcoded hexes). Every literal below is a token now,
   so the next brand swap is a :root edit. */

:root {
  /* surfaces, darkest to lightest */
  --bg-deep:   #0a0a09;   /* nav rail, editor stage */
  --bg:        #0e0e0d;   /* app canvas */
  --panel-3:   #0d0d0c;   /* inset: text areas, preview wells, side rails */
  --panel-2:   #111110;   /* modal body */
  --panel:     #131312;   /* raised: stat tiles, cards, calendar cells */
  --raise:     #1a1a17;   /* chips, kanban cards, calendar post chips */
  --raise-2:   #1c1b18;   /* highlighted: today, approval band, attention tile */

  /* hairlines, quietest to loudest */
  --line:      #23231f;
  --line-2:    #2b2b26;
  --line-3:    #3a3833;
  /* the handoff's names for the same three, kept live so either reads correctly */
  --border:    #2b2b26;
  --border-hi: #3a3833;
  --panel-hi:  #1c1b18;
  --faint:     #6e6a63;

  /* ink, brightest to quietest */
  --text:      #ece9e3;   /* bone — headings, primary */
  --text-2:    #e4e0d9;   /* body copy */
  --text-3:    #c9c4bc;   /* secondary controls */
  --muted:     #8f8b83;   /* labels, meta, counts */
  --muted-2:   #6e6a63;   /* disabled / not-applicable */

  /* the "primary button" is inverted bone, not a colour */
  --accent:      #ece9e3;
  --accent-soft: #26261f;
  --on-accent:   #0e0e0d;

  /* the only non-status colours in the system */
  --sel:         #6f9de0;   /* editor selection AND the keyboard focus ring */
  --danger:      #c98b82;
  --danger-line: #3a2b28;
  --ok:          #7d9c7a;

  /* pipeline status — the one place colour is allowed */
  --st-idea:      #6b7280;
  --st-drafted:   #b45309;
  --st-inbrief:   #2563eb;
  --st-scheduled: #7c3aed;
  --st-published: #16a34a;
  --st-killed:    #dc2626;

  /* Added when the last 29 literals were tokenised. Dark values are exactly what
     those literals were, so tokenising could not move the dark theme. */
  --hover:       #161614;   /* nav hover, the active nav item, hatch stripes */
  --card:        #121211;   /* card + drawer-head surface */
  --sunk:        #0b0b0a;   /* a calendar cell with no day in it */
  --raise-hover: #20201c;   /* hover on an already-raised surface */
  --line-4:      #4a4740;   /* the quietest ring: today, an n/a checkbox */
  /* Was #5a5751, which the contrast audit put at 2.68:1 on the canvas. Lifted to
     clear 3:1. This is the one place tokenising changed how DARK looks, and it is
     deliberate: the audit found a pre-existing problem rather than causing one. */
  --dim:         #6b675b;   /* past-day numerals, a completed step's line */
  --text-hi:     #ffffff;   /* the brightest ink: active tab, attention stat */
  --accent-hi:   #ffffff;   /* primary button, hovered */

  /* type */
  --font-display: 'Jost', 'Public Sans', -apple-system, sans-serif;
  --font-ui:      'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Aperture is a square-cornered system. Kept as a token so the few places that
     genuinely need a curve (avatars, the FAB) can opt out explicitly. */
  --radius: 0;
  --shadow: 0 1px 3px rgba(0,0,0,.5);

  font-size: 15px;
  color-scheme: dark;
}

/* ---------------------------------------------------------------------------
   Light. The default, per the 20 August meeting — black text on white.

   Not an inversion. A straight flip of a dark palette reads as grey mush: dark
   UIs separate surfaces by making them LIGHTER as they come forward, and light
   UIs do it with hairlines and a single step of shadow, because a white page has
   nowhere brighter to go. So the surface ramp compresses to near-white and the
   line ramp does the work the elevation ramp did.

   The Aperture discipline is unchanged: monochrome, radius 0, colour reserved
   for status. This is the same system in the other polarity, not a new one.
   --------------------------------------------------------------------------- */
:root[data-theme="light"] {
  --bg-deep:   #f1efea;   /* nav rail — the one surface that recedes */
  --bg:        #faf9f6;   /* app canvas: warm paper, not clinical white */
  --panel-3:   #f4f2ed;   /* inset: text areas, preview wells */
  --panel-2:   #fbfaf8;   /* modal body */
  --panel:     #ffffff;   /* raised: tiles, cards, calendar cells */
  --raise:     #f6f4ef;   /* chips, kanban cards, calendar post chips */
  --raise-2:   #f0ede6;   /* highlighted: today, approval band */
  --hover:     #f1efea;
  --card:      #ffffff;
  --sunk:      #f4f2ed;
  --raise-hover: #ebe8e1;

  --line:      #e3e0d8;
  --line-2:    #d6d2c8;
  --line-3:    #bdb8ab;
  --line-4:    #cfcabd;
  --border:    #d6d2c8;
  --border-hi: #bdb8ab;
  --panel-hi:  #f0ede6;
  --faint:     #8b8579;

  --text:      #17160f;   /* ink */
  --text-2:    #2a2820;
  --text-3:    #4c493f;
  --text-hi:   #000000;   /* the darkest ink, where dark used the brightest */
  --muted:     #6f6b60;
  --muted-2:   #8b8579;
  /* Past-day numerals and completed step lines. Quiet, but a contrast audit put
     the first value at 2.47:1 on the canvas — de-emphasised is not the same as
     unreadable, and a date you cannot read is a date. */
  --dim:       #8a8478;

  /* The primary button inverts the other way: ink on paper becomes paper on ink. */
  --accent:      #17160f;
  --accent-hi:   #000000;
  --accent-soft: #eceae3;
  --on-accent:   #faf9f6;

  /* Darkened so they hold their meaning against white rather than glowing on it. */
  --sel:         #2f5fa8;
  --danger:      #a3402f;
  --danger-line: #e6c9c2;
  --ok:          #3f7a4f;

  /* Status keeps its hues — these are already mid-tone and legible either way. */
  --st-drafted:   #b45309;
  --st-inbrief:   #1d4ed8;
  --st-scheduled: #6d28d9;
  --st-published: #15803d;
  --st-killed:    #b91c1c;

  --shadow: 0 1px 2px rgba(23,22,15,.06), 0 1px 3px rgba(23,22,15,.08);
  color-scheme: light;
}

/* There is no media query resolving "system" here on purpose. The inline script in
   the page head reads the stored preference (light | dark | system), resolves system
   against prefers-color-scheme, and stamps the EFFECTIVE theme on <html> before the
   first paint. One attribute, two palettes, no duplicated token block — and no flash
   of the wrong theme on load, which a CSS-only version cannot avoid once a stored
   preference has to beat the OS. */

* { box-sizing: border-box; }
/* One ring for the whole app, in the same blue as editor selection — the only
   non-status colour in the system. Nothing below may set outline:none. */
:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui);
  display: flex; height: 100vh; overflow: hidden;
}

/* A label: mono, uppercase, tracked out. Used everywhere a field is named. */
.lbl {
  font: 500 .63rem var(--font-mono); letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}

/* ================= left nav ================= */
.nav {
  width: 236px; min-width: 236px; background: var(--bg-deep);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px 12px; gap: 1px;
  height: 100vh; min-height: 0;    /* so the middle is what scrolls, not the whole column */
}
/* The page list scrolls; the account block below it does not. Signing out must never be
   the thing that scrolls off the bottom — and with enough tables, it was. */
.nav .nav-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -12px; padding: 0 12px; display: flex; flex-direction: column; gap: 1px; }
.nav .nav-scroll::-webkit-scrollbar { width: 8px; }
.nav .nav-scroll::-webkit-scrollbar-thumb { background: var(--line-2); }
.nav .nav-scroll::-webkit-scrollbar-thumb:hover { background: var(--line-3); }
.nav .whoami { flex: none; }

/* brand: the aperture mark + wordmark, tracked wide */
.nav .app-name {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 20px; font-family: var(--font-display); font-weight: 400;
  font-size: 15px; letter-spacing: .26em; text-transform: uppercase; color: var(--text);
}
.nav .app-name svg { width: 26px; height: 26px; flex: none; }

.nav .draft-pill {
  margin: 0 2px 10px; padding: 4px 8px; font: 500 .62rem var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid var(--st-drafted); color: var(--st-drafted);
  width: fit-content; display: none;
}

/* client switcher — the one control above the table list */
.client-switch {
  all: unset; cursor: pointer; margin: 0 2px 18px; padding: 9px 10px;
  border: 1px solid var(--line-2); display: flex; align-items: center; gap: 9px;
}
.client-switch:hover { border-color: var(--line-3); }
.client-switch .cs-lbl { font: 500 .63rem var(--font-mono); letter-spacing: .1em; color: var(--muted); }
.client-switch .cs-val { flex: 1; font-size: .87rem; font-weight: 600; color: var(--text); }
.client-switch .cs-caret { color: var(--muted); font-size: .7rem; }

/* section headers inside the nav: THE MONTH / THE ENGINE */
.nav-section {
  padding: 20px 10px 8px; font: 500 .63rem var(--font-mono);
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.nav-section:first-of-type { padding-top: 4px; }

.nav button.table-link {
  all: unset; cursor: pointer; padding: 8px 10px; font-size: .9rem;
  display: flex; align-items: center; gap: 10px; color: var(--text-3);
}
.nav button.table-link:hover { background: var(--hover); color: var(--text-2); }
.nav button.table-link.active {
  background: var(--hover); color: var(--text-hi); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-count {
  margin-left: auto; font: 500 .7rem var(--font-mono); color: var(--muted);
  background: none; border-radius: 0; padding: 0;
}
.table-link.active .nav-count { color: var(--text); background: none; }

.nav .spacer { flex: 1; }
/* Two rows, not one wrapping row. Adding the theme switch to a 236px rail made a
   four-item flex line wrap mid-item and collide with the role label: identity on
   top, controls underneath. */
.nav .whoami {
  padding: 14px 10px 8px; font-size: .8rem; color: var(--muted);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr; gap: 9px 9px; align-items: center;
}
.nav .whoami .theme-switch { grid-column: 1 / 2; justify-self: start; }
.nav .whoami > .btn.small { grid-column: 2 / 3; justify-self: end; }
.nav .whoami .who-avatar {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-3);
  color: var(--text-3); display: flex; align-items: center; justify-content: center;
  font: 600 .62rem var(--font-mono); flex: none;
}
.nav .whoami .who-id { flex: 1; min-width: 0; }
.nav .whoami .who-name {
  display: block; font-size: .8rem; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav .whoami .who-role {
  display: block; font: 500 .62rem var(--font-mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.nav select {
  width: 100%; margin-top: 6px; padding: 5px; border: 1px solid var(--line-2);
  background: var(--panel-3); color: var(--text-3); font-family: var(--font-ui); font-size: .8rem;
}

/* links to surfaces outside the grid (editor, admin, spec, reports) */
.nav-surfaces { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.nav-surfaces-h {
  font: 500 .63rem var(--font-mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); padding: 0 10px 6px;
}
a.nav-surface {
  display: block; padding: 6px 10px; font-size: .82rem; color: var(--muted); text-decoration: none;
}
a.nav-surface:hover { background: var(--raise); color: var(--text-2); }

.nav-system { margin-top: 8px; }
.nav-system summary {
  cursor: pointer; font: 500 .63rem var(--font-mono); letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); padding: 6px 10px; list-style: none;
}
.nav-system summary::-webkit-details-marker { display: none; }

/* ================= main column ================= */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.toolbar {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 30px 0; background: var(--bg); flex: none;
}

/* the page head: eyebrow over a wide, light, uppercase display title */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-eyebrow {
  font-family: var(--font-display); font-size: .72rem; font-weight: 500;
  letter-spacing: .3em; text-transform: uppercase; color: var(--muted);
}
.toolbar h1, .page-title {
  margin: 6px 0 0; font-family: var(--font-display); font-size: 34px; font-weight: 300;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text); line-height: 1.05;
}
.head-actions { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; flex-wrap: wrap; }

/* month stepper next to the title */
.month-nav { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; }
.month-nav .btn { width: 30px; height: 30px; padding: 0; justify-content: center; }
.month-nav .btn.today { width: auto; padding: 0 12px; font: 500 .7rem var(--font-mono); letter-spacing: .1em; }

/* the stat strip — hairline gaps done with background bleed-through */
.stat-strip { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); flex-wrap: wrap; }
.stat { flex: 1; min-width: 120px; background: var(--panel); padding: 10px 14px; display: flex; align-items: baseline; gap: 9px; }
.stat-n { font-family: var(--font-display); font-weight: 400; font-size: 22px; color: var(--text); }
.stat-label { font: 500 .66rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat.attention { flex: 1.7; background: var(--raise-2); align-items: center; }
.stat.attention .stat-n { color: var(--text-hi); }
.stat.attention .stat-label { flex: 1; color: var(--text-3); }

.view-tabs { display: flex; align-items: center; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.view-tabs button {
  all: unset; cursor: pointer; padding: 10px 2px; margin-right: 22px;
  font-family: var(--font-display); font-size: 13px; font-weight: 500; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
}
.view-tabs button:hover { color: var(--text-3); }
.view-tabs button.active { color: var(--text-hi); font-weight: 500; box-shadow: inset 0 -2px 0 var(--accent); }
.toolbar .grow { flex: 1; }

.toolbar input[type=search] {
  padding: 7px 11px; border: 1px solid var(--line-2); background: var(--panel-3);
  color: var(--text-2); width: 200px; font-family: var(--font-ui); font-size: .87rem;
}
.toolbar input[type=search]::placeholder { color: var(--muted); }
.toolbar input[type=search]:focus { border-color: var(--line-3); }

.btn {
  cursor: pointer; border: 1px solid var(--line-2); background: transparent; color: var(--text-3);
  padding: 7px 11px; font-family: var(--font-ui); font-size: .85rem;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--line-3); color: var(--text); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; padding: 8px 15px;
}
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.small { padding: 4px 9px; font-size: .76rem; }
.btn.danger { border-color: var(--danger-line); color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: default; }

.row-count { color: var(--muted); font: 500 .7rem var(--font-mono); letter-spacing: .06em; white-space: nowrap; }
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-clear {
  position: absolute; right: 6px; border: 0; background: var(--line-2); color: var(--text-3);
  width: 18px; height: 18px; line-height: 1; border-radius: 0; cursor: pointer; font-size: .78rem; padding: 0;
}
.search-clear:hover { background: var(--accent); color: var(--on-accent); }

/* Filters: one control, a count of what's active, and the active ones repeated
   as removable tokens — six dropdowns in a row was the whole toolbar. */
.filter-wrap { position: relative; }
.filter-badge {
  font: 600 .62rem var(--font-mono); background: var(--accent); color: var(--on-accent);
  padding: 1px 5px; margin-left: 2px;
}
.ms-panel.filter-panel {
  left: auto; right: 0; min-width: 260px;
  /* Beats .ms-panel's own max-height, which is declared LATER in this file and would
     otherwise clip the panel to 260px and make you scroll for the second control. */
  max-height: min(70vh, 640px); overflow: visible auto;
  /* No display here, deliberately. This selector (0,2,0) outranks the display:none on
     .ms-panel (0,1,0), so declaring display:flex on it held the panel open in every
     state — the close button, Escape and click-away all dropped .open and nothing on
     screen changed. Only the .open rule below may set display for this panel. */
  flex-direction: column; align-items: stretch; gap: 8px; padding: 10px;
}
.filter-panel > .btn, .filter-panel > .ms > .btn { width: 100%; justify-content: space-between; }
.filter-head {
  display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  font: 600 .62rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.filter-head button.filter-close {
  all: unset; cursor: pointer; margin-left: auto; width: 20px; height: 20px; line-height: 20px;
  text-align: center; border: 1px solid var(--line-2); color: var(--text-3); font-size: .8rem;
}
.filter-head button.filter-close:hover { border-color: var(--line-3); color: var(--text); }
.filter-tokens { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.filter-token {
  cursor: pointer; border: 1px solid var(--line-3); background: var(--raise); color: var(--text-3);
  padding: 3px 7px; font: 500 .66rem var(--font-mono); letter-spacing: .06em;
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-token:hover { color: var(--text); border-color: var(--text-3); }
.filter-token .x { color: var(--muted); }

/* status legend — the key to the only colour on screen */
.cal-legend, .status-legend { display: inline-flex; gap: 14px; margin-left: auto; flex-wrap: wrap; padding-bottom: 7px; }
.cal-legend-item, .status-legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 .62rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.cal-legend-item i, .status-legend-item i { width: 6px; height: 6px; flex: none; }

/* multiselect dropdown */
.ms { position: relative; }
.ms-trigger { min-width: 130px; justify-content: space-between; }
.ms-trigger.small { min-width: 0; padding: 1px 8px; gap: 2px; align-self: flex-start; }
.ms-panel {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line-2);
  padding: 6px; min-width: 180px; max-height: 340px; overflow: auto;
}
.ms.open > .ms-panel { display: block; }
/* …and the filter panel is a column, not a block — restated at matching
   specificity so the rule above cannot flatten it back. */
.ms.open > .ms-panel.filter-panel { display: flex; }
.ms-option {
  display: flex; gap: 8px; align-items: center; padding: 6px 8px; cursor: pointer;
  font-size: .85rem; color: var(--text-3);
}
.ms-option:hover { background: var(--raise); color: var(--text); }

/* ================= content ================= */
.content { flex: 1; overflow: auto; padding: 14px 30px 24px; min-height: 0; }

/* ---- table view ---- */
table.grid {
  border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); min-width: 100%;
}
.grid th {
  text-align: left; font: 500 .63rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line);
  background: var(--panel-3); cursor: pointer; white-space: nowrap;
}
.grid th .draft-badge, .field-draft {
  font: 500 .58rem var(--font-mono); letter-spacing: .08em; color: var(--st-drafted);
  border: 1px solid var(--st-drafted); padding: 1px 5px; margin-left: 6px; text-transform: uppercase;
}
.grid th.col-head { position: relative; padding-right: 16px; user-select: none; }
.grid th.col-head:hover { background: var(--raise); color: var(--text-3); }
.grid th.col-head.sorted { color: var(--text); }
.grid .col-name { vertical-align: middle; }
.grid .sort-arrow { font-size: .58rem; margin-left: 4px; }
.grid .col-help {
  all: unset; cursor: help; display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 5px; border-radius: 0; border: 1px solid var(--line-2);
  color: var(--muted); font-size: .55rem; font-style: italic; font-weight: 700; line-height: 1; vertical-align: middle;
}
.grid .col-help:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.grid .col-grip { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; }
.grid .col-grip:hover { background: var(--accent); opacity: .45; }
.grid.sized { table-layout: fixed; }
.grid.sized td { overflow: hidden; }
body.resizing { cursor: col-resize; user-select: none; }

.grid td {
  padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle;
  max-width: 320px; color: var(--text-2); font-size: .87rem;
}
.grid tr:last-child td { border-bottom: none; }
.grid tbody tr:hover td { background: var(--raise); }
.grid tr.group-row td {
  background: var(--panel-3); border-top: 1px solid var(--line-2);
  font: 500 .66rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: .5rem .75rem;
}
.grid tr.group-row .group-count { margin-left: .6rem; opacity: .7; }
.grid tr.row-pending { opacity: .5; }
.grid tr.row-pending textarea, .grid tr.row-pending .ms,
.grid tr.row-pending button, .grid tr.row-pending select { pointer-events: none; }
.grid td.name-cell { min-width: 130px; }

/* tables scroll inside their own wrapper rather than blowing out the page */
.grid-wrap { position: relative; overflow-x: auto; }

/* ---- cells ---- */
.cell-input {
  all: unset; width: 100%; padding: 2px 0; font-size: .87rem;
  font-family: var(--font-ui); color: var(--text-2);
}
.cell-input:focus { outline: 1px solid var(--line-3); }
.cell-text {
  display: block; white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word;
  resize: none; max-height: 104px; overflow-y: auto; line-height: 1.4; box-sizing: border-box;
}
.cell-ro { display: block; white-space: pre-wrap; overflow-wrap: break-word; }
td .cell-text { max-height: 6.4em; overflow: hidden; }
td:focus-within .cell-text { max-height: none; }
td .cell-text:not(:focus) {
  -webkit-mask-image: linear-gradient(180deg, #000 68%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 68%, transparent 100%);
}
td:focus-within .cell-text { -webkit-mask-image: none; mask-image: none; }
.cell-text::placeholder { color: var(--muted-2); font-style: normal; }

.chip {
  display: inline-flex; align-items: center; padding: 2px 9px; font-size: .76rem; font-weight: 600;
  background: var(--raise); color: var(--text-2); gap: 5px; border: 1px solid var(--line-2);
}
.chip.mini { font-size: .7rem; padding: 1px 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-empty { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); }
select.cell-select {
  border: none; background: transparent; font-size: .85rem; cursor: pointer;
  max-width: 100%; color: inherit; font-family: var(--font-ui);
}
select.cell-select option { background: var(--panel); color: var(--text-2); }

.person { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; background: transparent;
  border: 1px solid var(--line-3); color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center;
  font: 600 .6rem var(--font-mono); flex: none;
}
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
tr:hover .row-actions, .card:hover .row-actions { opacity: 1; }
.row-actions .btn.is-done { opacity: .45; cursor: default; }
.btn-delete { color: var(--danger); border-color: var(--danger-line); display: inline-flex; align-items: center; justify-content: center; }
.btn-delete:hover { background: var(--danger-line); border-color: var(--danger); color: var(--danger); }

.rel-cell { display: inline-flex; align-items: center; gap: 4px; }
.rel-link { color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; }
.rel-link:hover { text-decoration: underline; }
.rel-chip, a.chip.rel-link {
  color: var(--text-3); background: var(--raise); border: 1px solid var(--line-2);
  border-radius: 0; padding: 1px 9px; font-weight: 600; font-size: .76rem; text-decoration: none;
}
.rel-chip:hover, a.chip.rel-link:hover { background: var(--line-2); color: var(--text); text-decoration: none; }
.rel-edit {
  all: unset; cursor: pointer; color: var(--muted); font-size: .7rem; padding: 2px;
  opacity: 0; transition: opacity .1s;
}
td:hover .rel-edit, .drawer-field:hover .rel-edit { opacity: 1; }
.rel-empty { color: var(--muted); }
.placeholder-val { color: var(--muted-2); font-style: italic; }

.date-display {
  border: 0; background: none; font: inherit; color: var(--text-2);
  cursor: pointer; padding: 2px 4px; white-space: nowrap;
}
.date-display:hover { background: var(--raise); }
.date-display.empty { color: var(--muted-2); }

.name-cell { position: relative; padding-left: 30px !important; }
.expand-btn {
  all: unset; cursor: pointer; position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .85rem; opacity: .35; transition: opacity .1s; padding: 2px;
}
tr:hover .expand-btn { opacity: 1; color: var(--text); }

/* ---- calendar (artboard 01) ---- */
.cal-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-month {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 300; letter-spacing: .06em;
  text-transform: uppercase; min-width: 165px; text-align: center; color: var(--text);
}
.cal-count { color: var(--muted); font: 500 .7rem var(--font-mono); margin-left: auto; }
.cal-wrap { height: 100%; min-height: 0; }
.cal-grid {
  height: 100%;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto repeat(6, minmax(96px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.cal-dow {
  background: var(--bg); color: var(--muted);
  font: 500 .62rem var(--font-mono); letter-spacing: .18em; text-transform: uppercase;
  padding: 7px 8px;
}
.cal-cell {
  background: var(--panel); min-height: 0; padding: 6px 7px;
  display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow: hidden;
}
.cal-cell.cal-empty { background: var(--sunk); }
.cal-cell.cal-today { background: var(--raise-2); box-shadow: inset 0 0 0 1px var(--line-4); }
.cal-cell.cal-past { background: var(--bg); }
.cal-cell.cal-past .cal-daynum { color: var(--dim); }
.cal-cell.cal-past:hover { background: var(--panel); }
.cal-head { display: flex; align-items: center; gap: 6px; }
.cal-daynum { font: 500 .72rem var(--font-mono); color: var(--text-3); font-variant-numeric: tabular-nums; }
.cal-tag { margin-left: auto; font: 500 .58rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.cal-post {
  all: unset; cursor: pointer; background: var(--raise); border-left: 2px solid var(--muted);
  padding: 5px 7px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.cal-post:hover { background: var(--raise-hover); }
/* Overflow affordance: a day cell is a fixed height, so posts past the third had
   nowhere to go and simply were not drawn. Silently invisible data is worse than
   ugly data — nothing told you it happened. */
.cal-more {
  all: unset; cursor: pointer; flex: none; margin-top: auto;
  font: 500 .58rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); border-top: 1px solid var(--line-2); padding: 3px 1px 0;
}
.cal-more:hover { color: var(--text); border-top-color: var(--line-3); }
/* drag a post between days (ticket 186) */
.cal-post[draggable="true"] { cursor: grab; }
.cal-post.dragging { opacity: .45; }
.cal-post.no-drag { cursor: default; }
.cal-cell.drop-target { outline: 2px dashed var(--text-2); outline-offset: -3px; }
.cal-cell.cal-expanded { overflow: visible; z-index: 5; }
.cal-cell.cal-expanded .cal-posts { overflow: visible; }
.cal-posts { display: flex; flex-direction: column; gap: 5px; min-height: 0; overflow: hidden; }
.cal-post-title {
  font-size: 11.5px; font-weight: 500; line-height: 1.25; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cal-post-meta { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.cal-post-meta .fmt {
  font: 500 .58rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.cal-post-meta .tick { flex: none; }
.tick { font: 500 .58rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.tick.ok { color: var(--ok); }
.tick.pending { color: var(--text-2); }

/* ---- pipeline / kanban (artboard 02) ---- */
.kanban { display: flex; gap: 12px; align-items: stretch; min-height: 100%; }
.lane {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 0;
}
.lane-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--text-2);
}
.lane-dot { width: 7px; height: 7px; border-radius: 0; flex: none; }
.lane-name { flex: 1; min-width: 0; }
.lane-count { color: var(--muted); font: 500 .7rem var(--font-mono); letter-spacing: normal; }
.lane-body { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.card {
  background: var(--raise); border: 1px solid var(--line-2); border-top: 2px solid var(--muted);
  padding: 9px 10px; margin: 0; cursor: grab; font-size: .85rem;
  display: flex; flex-direction: column; gap: 7px;
}
.card:hover { background: var(--raise-hover); border-color: var(--line-3); }
.card.dragging { opacity: .4; }
.lane.dragover { outline: 1px dashed var(--accent); outline-offset: -1px; }
.card .card-title { font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--text); margin: 0; }
.card .card-meta {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  color: var(--muted); font: 500 .62rem var(--font-mono); letter-spacing: .06em;
}
.card .card-meta .fmt {
  border: 1px solid var(--line-3); padding: 1px 5px; color: var(--text-3);
  letter-spacing: .1em; text-transform: uppercase;
}
.card-meta .card-text-clamp {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 100%;
}

/* ---- cards / briefs (artboard 04) ---- */
.cards-wrap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1180px) { .cards-wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .cards-wrap { grid-template-columns: 1fr; } }
.cards-wrap .card {
  background: var(--panel); border: 1px solid var(--line); border-top-width: 1px;
  padding: 15px 16px; min-height: 220px; cursor: pointer; gap: 12px;
}
.cards-wrap .card .card-title { font-size: 16px; line-height: 1.3; }
.card-status { display: flex; align-items: center; gap: 8px; }
.card-status .lane-dot { width: 6px; height: 6px; }
.card-status .st-name { font: 600 .63rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
.card-status .st-when { margin-left: auto; font: 500 .63rem var(--font-mono); letter-spacing: .08em; color: var(--muted); }
.card-eyebrow {
  font-family: var(--font-display); font-size: .72rem; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
}
.card-body {
  font-size: .82rem; line-height: 1.55; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot {
  display: flex; align-items: flex-start; gap: 10px; margin-top: auto;
  padding-top: 11px; border-top: 1px solid var(--line);
  font: 500 .63rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.card-foot .card-state {
  min-width: 0; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot .row-actions { margin-left: auto; }
.card-foot .card-action { margin-left: auto; color: var(--text-3); border-bottom: 1px solid var(--text-3); }

/* ---- chart ---- */
.chart-panel { background: var(--panel); border: 1px solid var(--line); padding: 20px; max-width: 720px; }
.chart-panel h3 {
  margin: 0 0 16px; font-family: var(--font-display); font-size: .9rem;
  font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--text);
}
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { width: 110px; font: 500 .66rem var(--font-mono); letter-spacing: .06em; color: var(--muted); text-align: right; flex: none; }
.bar-track { flex: 1; background: var(--panel-3); border: 1px solid var(--line); height: 26px; }
.bar-fill {
  height: 100%; display: flex; align-items: center; padding-left: 8px;
  color: var(--on-accent); font: 600 .66rem var(--font-mono); min-width: 26px;
}

/* ================= row modal ================= */
.drawer {
  position: fixed; inset: 0; background: rgba(6,6,5,.74); z-index: 40;
  display: none; align-items: center; justify-content: center; padding: 4vh 16px;
}
.drawer.open { display: flex; }
.drawer-card {
  background: var(--panel-2); border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px rgba(0,0,0,.6); width: 1240px; max-width: 100%;
  max-height: 92vh; display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--line); gap: 14px;
}
.drawer-head strong {
  font-family: var(--font-display); font-size: 22px; font-weight: 400;
  letter-spacing: .03em; color: var(--text);
}
.drawer-head-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.drawer-head-actions:empty { display: none; }
.modal-dot { display: inline-block; width: 7px; height: 7px; margin-right: 9px; vertical-align: middle; }
.modal-context {
  display: block; color: var(--muted); font: 500 .63rem var(--font-mono);
  letter-spacing: .16em; text-transform: uppercase; margin-bottom: 5px;
}
.drawer-body { padding: 18px 20px; overflow: auto; }
.remind-preset { margin-left: 8px; font-size: .68rem; padding: 1px 4px; border: 1px solid var(--line-2); background: var(--panel-3); color: var(--text-2); }
/* a built brief is an archive, and looks like one (ticket 185) */
.brief-built-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; margin-bottom: 14px; font-size: .8rem; line-height: 1.45;
  border: 1px solid var(--line-2); border-left: 3px solid var(--ok, #187b34);
  background: var(--panel-2, rgba(0,0,0,.03)); color: var(--text-2);
}
.drawer-field.locked textarea, .drawer-field.locked .md-view { opacity: .75; cursor: default; }
.drawer-field { margin-bottom: 14px; }
.drawer-field label {
  display: flex; align-items: center; gap: 8px;
  font: 500 .63rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}
.drawer-field input, .drawer-field select, .drawer-field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2);
  font-size: .87rem; background: var(--panel-3); color: var(--text-2);
  font-family: var(--font-ui); line-height: 1.6;
}
.drawer-field textarea { resize: vertical; }
.drawer-field input:focus, .drawer-field select:focus, .drawer-field textarea:focus {
  border-color: var(--line-3);
}
.drawer-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); margin-bottom: 16px;
}
.drawer-grid .drawer-field { margin: 0; min-width: 0; background: var(--panel); padding: 9px 11px; }
.drawer-grid .drawer-field label { margin-bottom: 4px; }
.drawer-grid .drawer-field input,
.drawer-grid .drawer-field select,
.drawer-grid .drawer-field textarea { border: none; background: transparent; padding: 0; font-size: .85rem; }
.drawer-tech {
  margin: 6px 0 12px; border: 1px solid var(--line); padding: 8px 12px; background: var(--panel-3);
}
.drawer-tech summary {
  cursor: pointer; font: 500 .66rem var(--font-mono); letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.drawer-tech .drawer-field { margin-top: 10px; }
.drawer-actions {
  border-top: 1px solid var(--line); padding: 13px 20px; margin: 0;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.drawer-saved { font: 500 .63rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.drawer-actions .grow { flex: 1; }

/* The post card takes the whole card and lays itself out in three columns;
   every other table keeps the narrower scrolling drawer above. */
.drawer-card { width: 640px; }
.drawer-card.post-card-wide { width: 1240px; height: 820px; max-height: 92vh; }
.drawer-body.post-card { flex: 1; padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.drawer-body.post-card .drawer-field { margin-bottom: 0; }

/* the status pipeline across the top of a post card (artboard 06) */
.post-stepper { display: flex; align-items: center; padding: 14px 20px 15px; gap: 0; }
.step { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.step:last-child { flex: 0 0 auto; }
.step-dot { width: 9px; height: 9px; flex: none; background: var(--line-3); }
.step-name {
  font: 500 .63rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}
.step-line { flex: 1; height: 1px; background: var(--accent-soft); min-width: 8px; }
.step.done .step-dot { background: var(--accent); }
.step.done .step-name { color: var(--text-3); }
.step.done .step-line { background: var(--dim); }
.step.now .step-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(236,233,227,.18); }
.step.now .step-name { color: var(--text); font-weight: 600; }

/* the three-column body of the post card */
.post-body { flex: 1; min-height: 0; display: flex; border-top: 1px solid var(--line); }
.post-preview-col {
  width: 392px; flex: none; border-right: 1px solid var(--line); background: var(--panel-3);
  display: flex; flex-direction: column; min-height: 0;
}
.post-main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); overflow: auto; }
.post-side-col { width: 326px; flex: none; display: flex; flex-direction: column; background: var(--panel-3); overflow: auto; }

.platform-tabs { display: flex; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.platform-tab {
  all: unset; cursor: pointer; flex: 1; text-align: center; background: var(--panel-3);
  padding: 9px 6px; font: 500 .63rem var(--font-mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.platform-tab.active { background: var(--panel); color: var(--text); }

.preview-label { font: 500 .63rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
iframe.html-preview { width: 100%; height: 320px; border: 1px solid var(--line-2); background: var(--panel-3); }
iframe.post-live-preview { width: 100%; flex: 1; min-height: 320px; border: 1px solid var(--line-2); background: var(--panel-3); }
.preview-well {
  flex: 1; min-height: 0; border: 1px solid var(--line-2);
  background: repeating-linear-gradient(135deg, var(--hover) 0 8px, var(--panel) 8px 16px);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
  font: 500 .66rem var(--font-mono); letter-spacing: .08em; line-height: 1.8; color: var(--muted);
}
.preview-pad { flex: 1; min-height: 0; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.preview-src { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.preview-src .lbl { flex: 1; }
.link-btn {
  all: unset; cursor: pointer; font: 500 .63rem var(--font-mono); letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line-3);
}
.link-btn:hover { color: var(--text); border-color: var(--text); }

/* Drive picker (ticket 191): browse or search Drive, click to import — same tokens as
   the card, one accent nowhere: the files are the content */
.drive-pick {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 19, 15, .38);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.drive-pick-card {
  width: min(880px, 100%); max-height: min(80vh, 720px); display: flex; flex-direction: column; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); padding: 16px 18px 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
}
.drive-pick-head { display: flex; align-items: center; gap: 8px; }
.drive-pick-head .lbl { color: var(--text); font-weight: 600; }
.drive-q { flex: 0 1 320px; min-width: 120px; border: 1px solid var(--line-2); background: var(--panel-3); padding: 6px 9px; font-size: .85rem; }
.drive-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 18px; }
.drive-crumbs .sep { color: var(--muted); font-size: .8rem; }
.drive-grid {
  flex: 1; min-height: 160px; overflow: auto; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); align-content: start;
}
.drive-tile {
  all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  border: 1px solid var(--line-2); background: var(--panel-3); padding: 6px; position: relative;
}
.drive-tile:hover { border-color: var(--text); }
.drive-tile:disabled { opacity: .5; cursor: progress; }
.drive-tile.busy { border-color: var(--text); }
.drive-tile img, .drive-thumb-empty { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--panel); }
.drive-thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: 1.4rem; }
.drive-tile.folder .drive-thumb-empty { aspect-ratio: 3; font-size: 1.1rem; }
.drive-tile .nm { font: 500 .66rem var(--font-mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-badge {
  position: absolute; top: 10px; right: 10px; font: 600 .55rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: rgba(0, 0, 0, .6); padding: 2px 6px;
}
.drive-empty { grid-column: 1 / -1; padding: 28px 12px; text-align: center; font: 500 .66rem var(--font-mono); letter-spacing: .06em; line-height: 1.8; color: var(--muted); }

/* setup strip (ticket 191): title · client · date · platform · format, editable on the
   card itself — the five facts everything below depends on */
.post-setup {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1px; background: var(--line); border-bottom: 1px solid var(--line);
}
.post-setup .drawer-field { margin: 0; min-width: 0; background: var(--panel); padding: 10px 14px 9px; }
.post-setup .drawer-field label { margin-bottom: 4px; }
.post-setup .drawer-field input,
.post-setup .drawer-field select,
.post-setup .drawer-field textarea { border: none; background: transparent; padding: 0; font-size: .85rem; }
@media (max-width: 1100px) { .post-setup { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .post-setup { grid-template-columns: minmax(0, 1fr); } }

/* media source (ticket 191): what the post's Format actually needs — one image, a
   video, or 2–10 slides — with the current file(s) shown, not a bare URL cell */
.media-src { display: flex; flex-direction: column; gap: 8px; }
.media-src-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.media-src-head .lbl { flex: 1; }
.media-file {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font: 500 .63rem var(--font-mono); letter-spacing: .04em; color: var(--text-3);
}
.media-file .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-file .link-btn { flex: none; }
.media-hint { font: 500 .6rem var(--font-mono); letter-spacing: .06em; line-height: 1.7; text-transform: uppercase; color: var(--muted); }
.media-progress { display: flex; flex-direction: column; gap: 5px; }
.media-progress .bar { height: 3px; width: 0; background: var(--text); transition: width .2s linear; }
.media-progress .pct { font: 500 .6rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.media-src button:disabled, .media-src .link-btn:disabled { opacity: .45; cursor: progress; }
.media-hint.warn { color: #a3402f; }
.media-slides { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.media-slide { position: relative; aspect-ratio: 1; border: 1px solid var(--line-2); background: var(--panel); overflow: hidden; }
.media-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-slide .n { position: absolute; left: 4px; bottom: 3px; font: 600 .55rem var(--font-mono); color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.8); }
.media-slide .rm {
  all: unset; cursor: pointer; position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  display: grid; place-items: center; font: 600 .7rem var(--font-mono); line-height: 1;
  color: #fff; background: rgba(0,0,0,.55); border-radius: 50%;
}
.media-slide .rm:hover { background: #a3402f; }
.media-slide.add {
  all: unset; cursor: pointer; aspect-ratio: 1; display: grid; place-items: center;
  border: 1px dashed var(--line-3); color: var(--muted); font: 500 .9rem var(--font-mono);
}
.media-slide.add:hover { color: var(--text); border-color: var(--text); }

/* "ready to publish" checks */
.checks { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 11px; }
.checks-head { display: flex; align-items: center; gap: 9px; }
.checks-head .lbl { color: var(--text); font-weight: 600; }
.checks-head .checks-n { margin-left: auto; font: 500 .63rem var(--font-mono); color: var(--muted); }
.check { display: flex; align-items: flex-start; gap: 9px; }
.check-box {
  width: 13px; height: 13px; flex: none; margin-top: 1px; border: 1px solid var(--line-3);
  background: transparent; display: flex; align-items: center; justify-content: center;
  font: 600 .53rem var(--font-mono); color: var(--on-accent);
}
.check.pass .check-box { border-color: var(--ok); background: var(--ok); }
.check.na .check-box { border-color: var(--line-4); color: var(--muted); }
.check-txt { flex: 1; min-width: 0; }
.check-label { display: block; font-size: .8rem; line-height: 1.35; color: var(--text-2); }
.check.na .check-label { color: var(--muted); }
.check-note { display: block; font: 500 .6rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

/* the human-approval gate */
.approval-gate {
  padding: 15px 18px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; background: var(--raise-2);
}
.approval-row { display: flex; align-items: center; gap: 12px; }
.approval-txt { flex: 1; }
.approval-title { display: block; font-size: .87rem; font-weight: 600; color: var(--text); }
.approval-by { display: block; font: 500 .6rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.approval-note { font: 500 .6rem var(--font-mono); letter-spacing: .06em; line-height: 1.7; text-transform: uppercase; color: var(--muted); }
/* a square switch — off is an empty outline, on is a filled block */
.toggle {
  all: unset; cursor: pointer; width: 38px; height: 22px; flex: none; position: relative;
  border: 1px solid var(--line-3); background: transparent;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: var(--line-3); transition: left .12s, background .12s;
}
.toggle[aria-checked="true"] { background: var(--st-published); border-color: var(--st-published); }
.toggle[aria-checked="true"]::after { left: 18px; background: var(--bg); }
.toggle[disabled] { opacity: .5; cursor: not-allowed; }

/* activity rail */
.activity { flex: 1; min-height: 0; padding: 15px 18px; display: flex; flex-direction: column; gap: 10px; }
.activity-head { display: flex; align-items: center; gap: 9px; }
.activity-head .lbl { color: var(--text); font-weight: 600; }
.activity-item { display: flex; gap: 10px; align-items: flex-start; }
.activity-when { font: 500 .6rem var(--font-mono); color: var(--muted); width: 44px; flex: none; padding-top: 1px; }
.activity-dot { width: 5px; height: 5px; flex: none; margin-top: 5px; background: var(--muted); }
.activity-text { flex: 1; min-width: 0; font-size: .8rem; line-height: 1.45; color: var(--text-3); }

/* comments */
.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { display: flex; gap: 11px; align-items: flex-start; }
.comment-rail { width: 2px; align-self: stretch; background: var(--line-2); flex: none; }
.comment.client .comment-rail { background: var(--line-3); }
.comment-who { display: flex; align-items: baseline; gap: 8px; }
.comment-name { font: 600 .63rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.comment.client .comment-name { color: var(--text-3); }
.comment-when { font: 500 .6rem var(--font-mono); color: var(--muted); }
.comment-text { display: block; margin-top: 4px; font-size: .82rem; line-height: 1.55; color: var(--text-3); }

/* full-screen long-text editor */
.field-expand {
  margin-left: auto; border: 1px solid var(--line-2); background: transparent; color: var(--text-3);
  cursor: pointer; font: 500 .63rem var(--font-mono); letter-spacing: .1em; padding: 1px .4rem; line-height: 1.5;
}
.field-expand:hover { border-color: var(--line-3); color: var(--text); }
.field-overlay {
  position: fixed; inset: 0; z-index: 120; background: var(--bg);
  display: flex; flex-direction: column; padding: 1rem clamp(1rem, 6vw, 4rem);
}
.field-overlay-head {
  display: flex; justify-content: space-between; align-items: center;
  font: 500 .7rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--text); padding: .4rem 0 .8rem;
}
.field-overlay-body { flex: 1; display: flex; min-height: 0; }
.field-overlay-body textarea, .field-overlay-body > * {
  flex: 1; width: 100%; height: 100%; min-height: 0; font-size: 1rem; line-height: 1.6;
}
.field-overlay textarea, .field-overlay .cell-text { height: 100% !important; max-height: none !important; }

/* ================= assistant ================= */
.chat {
  width: 360px; min-width: 300px; background: var(--panel-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.chat.floating {
  position: fixed; right: 20px; bottom: 88px; z-index: 60;
  width: 390px; height: min(640px, calc(100vh - 130px));
  min-width: 0; border: 1px solid var(--line-2); border-radius: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.7); overflow: hidden;
}
.chat.floating.closed { display: none; }
.chat-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 61;
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line-3); cursor: pointer;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 30px rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
.chat-fab:hover { filter: brightness(1.08); }
.chat-fab svg { width: 24px; height: 24px; }
.chat-head {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font: 600 .7rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text);
}
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg {
  max-width: 92%; padding: 8px 11px; font-size: .85rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); }
.msg.bot { align-self: flex-start; background: var(--raise); color: var(--text-2); white-space: normal; }
.msg.bot code { background: var(--line-2); padding: 1px 4px; font-size: .82rem; }
.msg.bot strong { font-weight: 700; color: var(--text); }
.tool-card {
  align-self: flex-start; max-width: 92%; font: 500 .68rem var(--font-mono); color: var(--muted);
  border: 1px dashed var(--line-2); padding: 4px 9px;
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
}
.tool-card .tool-name { font-size: .64rem; color: var(--text); background: var(--line-2); padding: 0 5px; }
.tool-card .tool-desc { color: var(--text-3); }
.tool-card.ok::before { content: ""; width: 7px; height: 7px; background: var(--st-published); align-self: center; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.pill {
  cursor: pointer; border: 1px solid var(--line-2); background: transparent; color: var(--text-3);
  padding: 5px 11px; font-size: .78rem;
}
.pill:hover { border-color: var(--line-3); color: var(--text); }
/* The box grows with the message. flex-end keeps Send and + pinned to the bottom
   edge as it does, rather than floating in the middle of a tall box. */
.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-input textarea {
  flex: 1; padding: 9px 11px; border: 1px solid var(--line-2); background: var(--panel-3);
  color: var(--text-2); font-family: var(--font-ui); font-size: .85rem; min-width: 0;
  /* Height is set from scrollHeight as you type, so the manual resize grip would
     fight it on the next keystroke. line-height must be a number the script can
     reason about, and overflow-y:auto only bites once max-height is reached. */
  resize: none; overflow-y: auto; line-height: 1.45; max-height: 40vh;
  display: block; box-sizing: border-box;
}
.chat-input textarea::placeholder { color: var(--muted); }
.chat-input textarea:focus { border-color: var(--line-3); }
.chat-input button { flex: none; }

/* --- prose fields: rendered when read, raw when edited --------------------- */
.md-field { position: relative; }
.md-field .md-view {
  cursor: text; padding: 9px 11px; border: 1px solid var(--line-2); background: var(--panel-3);
  color: var(--text-2); font-size: .87rem; line-height: 1.6; min-height: 38px;
  max-height: 260px; overflow: auto;
}
.md-field .md-view:hover { border-color: var(--line-3); }
.md-field .md-view.is-empty { color: var(--muted); }
.md-field .md-view > :first-child { margin-top: 0; }
.md-field .md-view > :last-child { margin-bottom: 0; }
.md-field .md-view p { margin: 0 0 .5em; }
.md-field .md-view strong { color: var(--text); font-weight: 700; }
.md-field .md-view .md-list { margin: .3em 0 .5em 1.1em; padding: 0; }
.md-field .md-view .md-h { color: var(--text); font-weight: 700; margin: .6em 0 .3em; }
.md-field .md-view .md-quote { border-left: 2px solid var(--line-3); padding: .1em .8em; color: var(--muted); margin: .4em 0; }
.md-field .md-view code, .md-field .md-view .md-code { background: var(--line); padding: 1px 4px; font-family: var(--font-mono); font-size: .85em; }
/* The textarea is the exception: it appears only while you are actually editing. */
.md-field > textarea { display: none; }
.md-field.editing > .md-view { display: none; }
.md-field.editing > textarea { display: block; }

/* an in-flight write is legible, without a spinner that blocks anything */
.saving-chip {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 80;
  background: var(--raise-2); border: 1px solid var(--line-3); color: var(--text-3);
  font: 500 .64rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 12px; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.saving-chip.on { opacity: 1; }
/* Approval never claims more than Coda has confirmed. */
.approve-block.unconfirmed { opacity: .6; }
.approve-block.unconfirmed .toggle { outline: 1px dashed var(--line-3); outline-offset: 2px; }
.approve-block.unconfirmed .approve-when::after { content: " · confirming with Coda…"; color: var(--muted); }

/* the assistant is thinking — three dots and, once a tool starts, what it is doing */
.msg.bot.thinking {
  display: flex; align-items: center; gap: 9px; color: var(--muted);
  font: 500 .66rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
}
.think-secs { color: var(--muted); font-variant-numeric: tabular-nums; }
/* 30s with no event from the server: stop pretending, say so (ticket 172) */
.msg.bot.thinking.stalled .think-label, .msg.bot.thinking.stalled .think-secs { color: #b45309; }
.msg.bot.thinking.stalled .think-dots i { background: #b45309; animation-duration: 2.2s; }
.think-dots { display: inline-flex; gap: 4px; }
.think-dots i { width: 5px; height: 5px; background: var(--muted); display: block; animation: think 1.1s infinite; }
.think-dots i:nth-child(2) { animation-delay: .16s; }
.think-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes think { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .think-dots i { animation: none; opacity: .6; } }
.think-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

/* markdown inside chat bubbles */
.msg .md-h { margin: .7em 0 .3em; font-size: 1.02em; font-weight: 700; color: var(--text); }
.msg h3.md-h { font-size: 1.1em; }
.msg p { margin: 0 0 .5em; }
.msg p:last-child { margin-bottom: 0; }
.msg .md-list { margin: .3em 0 .5em 1.2em; padding: 0; }
.msg .md-list li { margin: .14em 0; }
.msg .md-quote { border-left: 2px solid var(--line-3); margin: .4em 0; padding: .1em .8em; color: var(--muted); }
.msg .md-code { background: var(--line-2); padding: .05em .35em; font-size: .92em; }
.msg .md-pre {
  background: var(--bg-deep); border: 1px solid var(--line); color: var(--text-2);
  padding: .6em .8em; overflow-x: auto; font-size: .8rem; margin: .45em 0;
}
.msg .md-pre code { background: none; padding: 0; color: inherit; }
.msg .md-hr { border: 0; border-top: 1px solid var(--line); margin: .7em 0; }
.msg .md-tbl-wrap { overflow-x: auto; margin: .5em 0; }
.msg .md-tbl { border-collapse: collapse; font-size: .93em; min-width: 60%; }
.msg .md-tbl th, .msg .md-tbl td { border: 1px solid var(--line-2); padding: .35em .6em; text-align: left; }
.msg .md-tbl th { background: var(--line); font-weight: 700; color: var(--text); }
.msg a { color: var(--text); text-decoration: underline; }
.msg del { opacity: .65; }

/* ================= chrome ================= */
.login-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: none; align-items: center; justify-content: center; }
.login-overlay.show { display: flex; }
.login-card {
  background: var(--panel-2); border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px rgba(0,0,0,.6); padding: 34px 38px; text-align: center; max-width: 340px;
}
.login-card h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 300; letter-spacing: .06em; text-transform: uppercase; color: var(--text); }
.login-brand {
  color: var(--text); font-family: var(--font-display); font-size: .8rem;
  font-weight: 400; letter-spacing: .28em; margin-bottom: 10px;
}
.login-sub { color: var(--muted); font-size: .85rem; margin: 0 0 18px; line-height: 1.6; }
.login-error { color: var(--danger); font-size: .8rem; min-height: 1em; margin: 10px 0 0; }
.login-alt { margin-top: 14px; }
#googleBtn { display: flex; justify-content: center; min-height: 44px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--on-accent); padding: 9px 16px;
  font: 500 .72rem var(--font-mono); letter-spacing: .08em; z-index: 130;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

.empty-table {
  padding: 46px 20px; text-align: center; color: var(--muted); background: var(--panel);
  border: 1px dashed var(--line-2); font-size: .9rem;
}
.fab-hint {
  position: fixed; right: 86px; bottom: 30px; z-index: 61; background: var(--accent);
  color: var(--on-accent); border: 0; padding: 9px 16px;
  font: 600 .68rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.fab-hint::after {
  content: ''; position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
  border: 7px solid transparent; border-left-color: var(--accent);
}
.boot-loading { display: flex; align-items: center; gap: 10px; padding: 48px 24px; color: var(--muted); font-size: .9rem; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--text-3);
  border-radius: 50%; animation: bp-spin .8s linear infinite; flex: none;
}
@keyframes bp-spin { to { transform: rotate(360deg); } }

/* per-page About */
.page-about { margin: 12px 30px 0; border: 1px solid var(--line); background: var(--panel); font-size: .85rem; }
.page-about summary {
  cursor: pointer; padding: 8px 12px; color: var(--muted);
  font: 500 .66rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  display: flex; align-items: center; gap: 7px; list-style: none;
}
.page-about summary::-webkit-details-marker { display: none; }
.page-about summary svg { width: 14px; height: 14px; flex: none; }
.page-about[open] summary { border-bottom: 1px solid var(--line); color: var(--text-3); }
.page-about .about-body { padding: 12px 14px; color: var(--text-3); line-height: 1.6; }
.page-about .about-body p { margin: 0 0 .6em; }
.page-about .about-body p:last-child { margin-bottom: 0; }
.drive-panel { border-top: 1px dashed var(--line-2); margin-top: 10px; padding-top: 10px; }
.drive-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-2); }
.drive-status .dot { width: 8px; height: 8px; background: var(--muted); }
.drive-status.ok .dot { background: var(--st-published); }
.drive-status.err .dot { background: var(--st-killed); }
.drive-email {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel-3);
  border: 1px solid var(--line-2); padding: 3px 8px;
  font-family: var(--font-mono); font-size: .74rem; word-break: break-all; color: var(--text-3);
}
.drive-shared { margin: 8px 0 0; padding-left: 1.2em; }
.drive-shared li { margin: 2px 0; }

/* ================= mobile (artboard 05) ================= */
.mobile-bar { display: none; }
.nav-backdrop { display: none; }
.tabbar { display: none; }

/* the month agenda: a phone can't read a 7-column grid, so the calendar
   becomes a day-grouped list of the posts that actually exist. */
.agenda { display: flex; flex-direction: column; }
.agenda-day {
  display: flex; align-items: center; gap: 9px; padding: 9px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.agenda-daynum { font: 600 .72rem var(--font-mono); letter-spacing: .08em; color: var(--text); }
.agenda-weekday { font: 500 .63rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.agenda-tag { margin-left: auto; font: 500 .63rem var(--font-mono); color: var(--muted); }
.agenda-day.past .agenda-daynum { color: var(--muted); }
.agenda-post {
  all: unset; cursor: pointer; display: flex; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--raise); align-items: flex-start;
}
.agenda-post:hover { background: var(--raise); }
.agenda-rail { width: 3px; align-self: stretch; flex: none; background: var(--muted); }
.agenda-txt { flex: 1; min-width: 0; }
.agenda-title { display: block; font-size: .9rem; font-weight: 600; line-height: 1.35; color: var(--text); }
.agenda-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.agenda-meta span { font: 500 .63rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.agenda-thumb {
  width: 44px; height: 44px; flex: none; border: 1px solid var(--line-2);
  background: repeating-linear-gradient(135deg, var(--hover) 0 6px, var(--panel) 6px 12px);
  object-fit: cover;
}

@media (max-width: 1100px) { .chat { width: 300px; } }

@media (max-width: 1180px) {
  /* the post card's three columns can't hold below this — stack them */
  .post-body { flex-direction: column; overflow: auto; }
  .post-preview-col, .post-side-col { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--line); }
  .post-main-col { border-right: none; overflow: visible; }
  .preview-well { min-height: 300px; }
}

@media (max-width: 860px) {
  body { flex-direction: column; overflow: auto; height: auto; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 70;
    background: var(--bg-deep); border-bottom: 1px solid var(--line); padding: 8px 12px;
  }
  .mobile-bar .mobile-mark { width: 20px; height: 20px; flex: none; }
  .mobile-title {
    font-family: var(--font-display); font-size: .82rem; font-weight: 400;
    letter-spacing: .24em; text-transform: uppercase; color: var(--text); white-space: nowrap;
  }
  .mobile-page {
    color: var(--muted); font: 500 .66rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mobile-page:not(:empty)::before { content: '·'; margin-right: 10px; }
  .hamburger {
    all: unset; cursor: pointer; display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; min-height: 44px; min-width: 44px;
    border: 1px solid var(--line-2); color: var(--text-3);
  }
  .hamburger:active { background: var(--raise); }
  .hamburger svg { width: 20px; height: 20px; }
  .nav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 92;
    width: min(300px, 85vw); min-width: 0;
    transform: translateX(-103%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.6); overflow-y: auto;
  }
  body.nav-open .nav { transform: none; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 91;
    background: rgba(6,6,5,.7); opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav .whoami { margin-top: auto; }
  .main { min-height: 60vh; }
  .toolbar { padding: 12px 16px 0; gap: 10px; }
  .toolbar h1, .page-title { font-size: 26px; }
  .page-head { gap: 10px; }
  .head-actions {
    width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .head-actions::-webkit-scrollbar { display: none; }
  .head-actions > * { flex: none; }
  .toolbar input[type=search] { width: 150px; }
  .month-nav { padding-bottom: 0; }
  /* Configure is an admin control; it does not earn a slot on a phone. */
  .head-actions .btn.configure { display: none; }
  .content { padding: 12px 16px 96px; }
  .page-about { margin: 12px 16px 0; }
  .chat { width: 100%; border-left: none; border-top: 1px solid var(--line); height: 45vh; }
  .drawer { padding: 0; }
  .drawer-card { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border: none; }
  .kanban { flex-direction: column; }
  .lane { min-width: 0; }

  /* the bottom tab bar replaces the desktop view tabs on a phone */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 75;
    border-top: 1px solid var(--line); background: var(--bg-deep); padding: 9px 8px calc(16px + env(safe-area-inset-bottom));
  }
  .tabbar button {
    all: unset; cursor: pointer; flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 5px; padding: 6px 0; min-height: 44px;
  }
  .tabbar .tb-mark { width: 16px; height: 16px; border: 1.5px solid var(--muted); }
  .tabbar .tb-name { font: 500 .6rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .tabbar button.active .tb-mark { border-color: var(--text); }
  .tabbar button.active .tb-name { color: var(--text); }
  body.has-tabbar .content { padding-bottom: 110px; }
  body.has-tabbar .chat-fab, body.has-tabbar .fab-hint { display: none; }
  body.has-tabbar .chat.floating {
    right: 0; left: 0; bottom: 0; width: 100%;
    height: min(70vh, calc(100vh - 120px)); border-left: 0; border-right: 0; border-bottom: 0;
  }
}

@media (max-width: 640px) {
  .grid-wrap::after {
    content: ''; position: sticky; left: 100%; top: 0; width: 26px; height: 100%;
    margin-left: -26px; background: linear-gradient(90deg, transparent, rgba(0,0,0,.55));
    pointer-events: none; display: block; float: right;
  }
}

@media (max-width: 560px) {
  .drawer-grid { grid-template-columns: 1fr; }
  .chat.floating { inset: 0 !important; width: 100% !important; height: 100% !important; max-height: none !important; border-radius: 0; z-index: 80; }
  .head-actions { width: 100%; }
  .stat { min-width: 100%; }
}

/* Touch targets: on a coarse pointer every control clears 44px, per artboard 05. */
@media (pointer: coarse) {
  .btn, .platform-tab, .link-btn, .view-tabs button { min-height: 44px; }
  .cal-post, .agenda-post, .nav button.table-link { min-height: 44px; }
}

/* --- Publishing. Deliberately quiet: these buttons do something irreversible and
   public, so they get no colour that invites a reflexive click. --- */
.publish-box { display: flex; flex-direction: column; gap: 8px; padding-top: 14px;
  margin-top: 14px; border-top: 1px solid var(--line); }
.publish-box .btn.pub-btn { width: 100%; justify-content: center; }
.publish-box .btn.pub-btn:disabled { opacity: .45; cursor: not-allowed; }
.pub-done { display: flex; align-items: center; gap: 8px;
  font: 500 11px 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ok); }
.pub-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* --- Images in the chat. The strip sits between the pills and the input so an
   attached image reads as part of the message you are about to send. --- */
.chat-attachments { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 0; }
.attach-chip { position: relative; width: 48px; height: 48px; border: 1px solid var(--line); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; line-height: 1;
  border: 1px solid var(--line); background: var(--bg-deep); color: var(--text); cursor: pointer;
  font-size: 12px; padding: 0; }
.chat-input .icon-btn { padding: 0 10px; font-size: 15px; line-height: 1; }
.drop-target { outline: 2px dashed var(--line-3, var(--line)); outline-offset: -4px; }

/* The month picker. A native month input, dressed to match the buttons beside it —
   it gives month AND year in one control, so a date years out is one action. */
.month-nav .month-pick {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text-3);
  padding: 5px 8px; font: 500 11px 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .04em; color-scheme: dark;
}
.month-nav .month-pick:hover { border-color: var(--line-3); color: var(--text); }
.month-nav .month-pick:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }

/* A month with nothing in it says why. An empty grid alone is ambiguous — nothing
   planned, a filter hiding it, and the wrong client scope all look identical. */
.cal-note { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted);
  font: 500 11px 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .05em;
  text-transform: uppercase; }
.cal-note .btn { margin-left: auto; }

/* The theme control. Three glyphs, no labels — it sits in a 236px rail beside the
   sign-out button, and the tooltips carry the words. */
.theme-switch { display: flex; border: 1px solid var(--line-2); flex: none; }
.theme-switch .theme-opt {
  background: none; border: 0; cursor: pointer; padding: 3px 7px;
  color: var(--muted-2); font-size: 11px; line-height: 1.4;
}
.theme-switch .theme-opt + .theme-opt { border-left: 1px solid var(--line-2); }
.theme-switch .theme-opt:hover { color: var(--text-3); background: var(--hover); }
.theme-switch .theme-opt.on { color: var(--text); background: var(--raise-2); }

/* previous-chats drawer (ticket 174) */
.chat-sessions {
  position: absolute; top: 44px; left: 8px; right: 8px; max-height: 60%;
  overflow: auto; z-index: 30; background: var(--panel-1, #fff);
  border: 1px solid var(--line-2); box-shadow: 0 10px 28px rgba(0,0,0,.14);
}
.chat-sessions .cs-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--line-2);
  font: 600 .68rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.cs-item { display: flex; align-items: stretch; border-bottom: 1px solid var(--line-2); }
.cs-item.active { background: var(--panel-3, rgba(0,0,0,.04)); }
.cs-title {
  flex: 1; display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 9px 10px; text-align: left; background: none; border: 0; cursor: pointer;
  font-size: .8rem; color: var(--text-1); min-width: 0;
}
.cs-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-title:hover { background: var(--panel-3, rgba(0,0,0,.04)); }
.cs-when { flex: none; font-size: .68rem; color: var(--muted); }
.cs-del { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 10px; }
.cs-del:hover { color: #b91c1c; }
.cs-empty { padding: 14px 12px; font-size: .8rem; color: var(--muted); }

/* a chat with a live background run (ticket 175) */
.cs-running { width: 7px; height: 7px; border-radius: 50%; background: #187b34; flex: none; align-self: center; animation: think 1.4s infinite; }

/* Social Media Layout (ticket 184): the feed, with the fields beside it */
.social-feed { display: flex; flex-direction: column; gap: 18px; max-width: 1060px; margin: 0 auto; }
.social-day {
  font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 10px 2px 0; border-bottom: 1px solid var(--line-2);
}
.social-card {
  display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 18px;
  border: 1px solid var(--line-2); background: var(--panel-2); padding: 14px;
}
.social-frame-wrap { min-height: 420px; }
.social-preview { width: 100%; height: 560px; border: 0; background: #fff; }
.social-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.social-open { margin-top: auto; }
@media (max-width: 900px) { .social-card { grid-template-columns: 1fr; } .social-preview { height: 480px; } }

/* standing preferences panel (ticket 187) */
.pref-group { margin-bottom: 18px; }
.pref-row { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.pref-text { flex: 1; font-size: .84rem; line-height: 1.45; }
.pref-empty { font-size: .8rem; color: var(--muted); padding: 4px 0; }
.pref-add { display: flex; gap: 8px; flex-wrap: wrap; }
.pref-input { flex: 1; min-width: 220px; padding: 7px 10px; border: 1px solid var(--line-2); background: var(--panel-3); color: var(--text-1); }
.pref-scope { padding: 6px 8px; border: 1px solid var(--line-2); background: var(--panel-3); color: var(--text-1); }
.social-undated { display: flex; flex-direction: column; }
.social-undated-row { border-bottom: 1px solid var(--line-2); }

/* client-card documents (ticket 176) */
.client-docs .doc-row { border-bottom: 1px solid var(--line-2); padding-bottom: 4px; margin-bottom: 4px; }
.client-docs .doc-desc { font-size: .76rem; color: var(--muted); padding: 0 10px 6px; line-height: 1.45; }

/* ── Ticket 137: tables become a card list on a phone ──────────────────────────
   A grid with eleven columns is a horizontal scroll on a 375px screen, and the
   only thing an approver can actually do with it is give up. Below 560px each ROW
   becomes a card: the name is the title, every other field is labelled with its own
   column name, and anything empty is dropped rather than printed as a dash. */
@media (max-width: 560px) {
  /* Five view names do not fit across a phone, and wrapping them drops the last one
     onto the row-count line. Scroll them instead — the same treatment .head-actions
     already gets. */
  .view-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
  .view-tabs::-webkit-scrollbar { display: none; }
  .view-tabs > button { flex: none; }
  .row-count { flex: none; }
  .grid-wrap { overflow-x: visible; }
  .grid-wrap::after { display: none; }              /* the edge-fade hint has no job here */
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: auto; }
  .grid thead { display: none; }
  .grid.sized td { overflow: visible; }
  .grid tr {
    background: var(--panel-2); border: 1px solid var(--line-2);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
  }
  .grid tr.group-row { background: none; border: 0; padding: 12px 2px 4px; margin: 0; }
  .grid td { border: 0; padding: 0; }
  .grid td[data-empty="1"] { display: none; }
  /* every field says what it is, since the header row is gone */
  .grid td::before {
    content: attr(data-col); display: block;
    font: 700 .58rem var(--font-mono); letter-spacing: .11em; text-transform: uppercase;
    color: var(--muted); margin: 10px 0 3px;
  }
  /* the name cell is the card's title, not another labelled field */
  .grid td.name-cell { display: flex; align-items: flex-start; gap: 8px; }
  .grid td.name-cell::before { display: none; }
  .grid td.name-cell .cell-text, .grid td.name-cell .cell-input {
    font-size: 1rem; font-weight: 600; max-height: none; -webkit-line-clamp: unset;
  }
  .grid td.name-cell .expand-btn { min-width: 44px; min-height: 44px; flex: none; order: 2; margin-left: auto; }
  .grid td .cell-text, .grid td .cell-ro { max-height: 7.5em; }
  .grid td:last-child { margin-top: 10px; }
  .grid td:last-child::before { display: none; }
  .grid .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
}
