/* ============================================================================
   ALMA — Quiet Intelligence
   Governed by docs/DESIGN.md. Every value below comes from the token system;
   if a number is not on the 4px grid or in the radius/type scale, it is a bug.
   The 2026-10-22 redesign (five places: Today, Inbox, Calendar, Work, ALMA)
   keeps the foundation and adds semantic tokens measured for WCAG 2.2 AA:
   every text pair here is 4.5:1 or better, every control boundary 3:1.
   ============================================================================ */

/* ---- tokens ---------------------------------------------------------------- */
:root {
  /* color — light (designed, not inverted-from-dark) */
  --bg:               #F6F5F2;
  --surface:          #FFFFFF;
  --surface-sunken:   #EFEDE8;
  --surface-elevated: #FFFFFF;
  --surface-side:     #F1EFEB;   /* the sidebar: one step under the page */
  --surface-hover:    rgba(29, 27, 24, 0.05);
  --surface-pressed:  rgba(29, 27, 24, 0.09);
  --text-primary:     #1D1B18;
  --text-secondary:   #5C5850;   /* 6.5:1 on the page */
  --text-tertiary:    #6F6A61;   /* 4.6:1 on sunken, 5.4:1 on white (was #8B867C, 3.3:1) */
  --border-subtle:    rgba(29, 27, 24, 0.08);
  --border-strong:    rgba(29, 27, 24, 0.18);
  --border-control:   #8F8A81;   /* a field's edge: 3.1:1 on the page */

  /* one accent family: ALMA blue, her flame (web/avatar) deepened for contrast */
  --accent:         #246BD6;     /* fills, focus, selection marks */
  --accent-hover:   #1F5EBD;
  --accent-pressed: #1A51A3;
  --accent-fill:    #246BD6;     /* button backgrounds: white text 5.1:1 */
  --accent-text:    #1F5EBD;     /* accent words: 5.4:1 on the soft tint */
  --accent-soft:    rgba(36, 107, 214, 0.10);
  --on-accent:      #FFFFFF;
  --focus:          #246BD6;

  /* semantic: the word is always there too, never the color alone */
  --success:      #2C6B49;
  --success-soft: rgba(51, 122, 84, 0.12);
  --warning:      #7E5B0E;
  --warning-soft: rgba(158, 116, 24, 0.14);
  --warning-mark: #9E7418;
  --destructive:  #B0352F;
  --destructive-soft: rgba(190, 59, 54, 0.10);
  --info:         #1A6878;  /* teal, so info never reads as the blue accent */
  --info-soft:    rgba(31, 122, 140, 0.12);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", "Segoe UI", sans-serif;
  --fs-title:   28px;  /* page title */
  --fs-section: 20px;  /* section heading */
  --fs-lead:    17px;  /* the line a detail screen is about */
  --fs-body:    16px;
  --fs-secondary: 14px;
  --fs-caption: 13px;
  --fs-micro:   12px;

  /* space: 4 8 12 16 24 32 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  /* geometry */
  --r-sm: 8px;   /* small controls */
  --r-md: 12px;  /* inputs, buttons */
  --r-lg: 16px;  /* cards, grouped lists */
  --r-xl: 20px;  /* sheets, large surfaces */
  --r-pill: 999px;

  /* motion */
  --dur-fast: 120ms;
  --dur:      180ms;
  --dur-slow: 220ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* elevation — used only where layering is real */
  --shadow-1:   0 1px 2px rgba(29, 27, 24, 0.06);
  --shadow-pop: 0 8px 24px rgba(29, 27, 24, 0.12), 0 2px 8px rgba(29, 27, 24, 0.06);

  /* chart — emphasis form: this year in ALMA blue, last year in de-emphasis grey.
     Both validated (dataviz six checks) against the light surface. */
  --chart-current: #246BD6;
  --chart-context: #B3AFA8;

  /* shell */
  --side-w: 248px;
  --rail-w: 80px;
  --topbar-h: 52px;
  --tabbar-h: 56px;
  --read-w: 760px;
  --wide-w: 1280px;
  --panel-w: 400px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:               #131211;
    --surface:          #1C1A18;
    --surface-sunken:   #0E0D0C;
    --surface-elevated: #232120;
    --surface-side:     #171615;
    --surface-hover:    rgba(255, 255, 255, 0.05);
    --surface-pressed:  rgba(255, 255, 255, 0.09);
    --text-primary:     #F1EFEA;
    --text-secondary:   #A6A198;
    --text-tertiary:    #928D83;   /* 5.3:1 on the surface (was #726E66, 3.4:1) */
    --border-subtle:    rgba(255, 255, 255, 0.08);
    --border-strong:    rgba(255, 255, 255, 0.18);
    --border-control:   #77736B;

    --accent:         #4D8AF0;
    --accent-hover:   #66A0F5;
    --accent-pressed: #3F7BE0;
    --accent-fill:    #2A66CC;     /* white text 5.4:1 (on #4D8AF0 it was 3.4:1) */
    --accent-text:    #7AAEF7;
    --accent-soft:    rgba(77, 138, 240, 0.16);
    --on-accent:      #FFFFFF;
    --focus:          #66A0F5;

    --success:      #58B183;
    --success-soft: rgba(88, 177, 131, 0.14);
    --warning:      #D9A03C;
    --warning-soft: rgba(217, 160, 60, 0.14);
    --warning-mark: #D9A03C;
    --destructive:  #EE7C74;
    --destructive-soft: rgba(224, 96, 88, 0.12);
    --info:         #6BB8C6;
    --info-soft:    rgba(107, 184, 198, 0.14);

    --shadow-1:   0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);

    /* validated against the dark surface — selected, not flipped */
    --chart-current: #4D8AF0;
    --chart-context: #6B665E;
  }
}

/* ---- base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
::selection { background: var(--accent-soft); }
a { color: var(--accent-text); }
/* the icon family: every <svg><use href="#i-…"></svg> draws as a 1.7 stroke in the text color */
svg:has(> use) { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
kbd { font-family: var(--font); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.skip {
  position: fixed; left: 8px; top: 8px; z-index: 200;
  padding: 8px 16px; border-radius: var(--r-md);
  background: var(--accent-fill); color: var(--on-accent); font-weight: 600; text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* screen-reader-only text */
.vh {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ============================================================================
   The shell: sidebar (wide), rail (tablet), top bar + tab bar (phones)
   ============================================================================ */
.app { display: flex; min-height: 100dvh; }
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
main { flex: 1; width: 100%; padding: var(--s6) var(--s6) 48px; outline: none; }
.view { display: none; max-width: var(--read-w); margin: 0 auto; }
.view.wide { max-width: var(--wide-w); }
/* No fade on a place change: switching is instant, so nothing replays on every tap. */
.view.on { display: block; }
@keyframes view-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- the sidebar ---- */
.side {
  position: sticky; top: 0; height: 100dvh; flex: 0 0 var(--side-w);
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s4) var(--s3) var(--s4);
  background: var(--surface-side);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}
.side-brand {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 44px; padding: 0 var(--s2); margin-bottom: var(--s1);
  color: var(--text-primary); text-decoration: none; border-radius: var(--r-md);
}
.side-brand b { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.side-search {
  display: flex; align-items: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s3); margin-bottom: var(--s2);
  border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-tertiary);
  font: inherit; font-size: var(--fs-secondary); text-align: left; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.side-search svg { width: 18px; height: 18px; flex: none; }
.side-search span { flex: 1; }
.side-search:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.kbd-hint { font-size: var(--fs-micro); color: var(--text-tertiary); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 0 6px; line-height: 20px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 var(--s1); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--border-subtle); }
.side-status { display: flex; flex-direction: column; gap: var(--s1); margin: 0; padding: 0 var(--s2); }
.side-status small, .menu-note small { color: var(--text-tertiary); font-size: var(--fs-micro); }

.nav {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 40px;
  padding: 0 var(--s3);
  border: 0; background: none; border-radius: var(--r-md);
  color: var(--text-secondary); text-decoration: none;
  font-family: var(--font); font-size: 15px; font-weight: 500;
  text-align: left; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav svg { width: 20px; height: 20px; flex: 0 0 20px; }
.nav:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav:active { background: var(--surface-pressed); }
.nav[aria-current="page"], .nav.on { background: var(--accent-soft); color: var(--accent-text); }
.nav.sub { min-height: 36px; padding-left: 44px; font-size: var(--fs-secondary); }
.nav.sub[aria-current="page"] { background: none; color: var(--accent-text); font-weight: 600; }
.nav.sub[aria-current="page"]::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); margin-left: -16px; margin-right: 12px; }

.nav-count {
  margin-left: auto;
  min-width: 22px; padding: 0 var(--s2);
  border-radius: var(--r-pill);
  background: var(--surface-sunken); color: var(--text-secondary);
  font-size: var(--fs-micro); font-weight: 600; line-height: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-count.hot { background: var(--accent-fill); color: var(--on-accent); }

/* ---- the face: the avatar is the one place character lives (docs/DESIGN.md).
   The art carries its own white backing, so it always sits on a white tile with
   a hairline ring, in both themes: a deliberate badge, never a white hole. ---- */
.face {
  position: relative; display: inline-block; flex: none;
  border-radius: 50%; overflow: hidden;
  background: #FFFFFF; box-shadow: 0 0 0 1px var(--border-subtle);
}
.face-sm { width: 32px; height: 32px; }
.face-md { width: 40px; height: 40px; }
.face-lg { width: 88px; height: 88px; }
.face .pose { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 200ms var(--ease); }
.face .pose:first-child { opacity: 1; }
.face[data-pose="working"] .pose[data-pose="resting"],
.face[data-pose="concerned"] .pose[data-pose="resting"] { opacity: 0; }
.face[data-pose="working"] .pose[data-pose="working"],
.face[data-pose="concerned"] .pose[data-pose="concerned"] { opacity: 1; }

/* ---- phones: top bar and tab bar (hidden on wide screens) ---- */
.topbar { display: none; }
.tabbar { display: none; }
.askpanel { display: none; }

/* ---- Work's switcher ---- */
.worknav {
  display: flex; gap: var(--s1);
  max-width: var(--wide-w); margin: 0 auto var(--s5);
  padding: var(--s1); border-radius: var(--r-md);
  background: var(--surface-sunken);
  overflow-x: auto; scrollbar-width: none;
}
.worknav::-webkit-scrollbar { display: none; }
.worknav a {
  flex: 0 0 auto; display: inline-flex; align-items: center;
  min-height: 36px; padding: 0 var(--s4);
  border-radius: var(--r-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: var(--fs-secondary); font-weight: 500; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.worknav a:hover { color: var(--text-primary); }
.worknav a[aria-current="page"] { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-1); font-weight: 600; }
/* on wide screens the sidebar already lists Work's sections */
@media (min-width: 1024px) { .worknav { display: none !important; } }

/* ============================================================================
   Page structure
   ============================================================================ */
main h1 {
  margin: 0;
  font-size: var(--fs-title); font-weight: 600;
  letter-spacing: -0.4px; line-height: 1.2;
}
/* the studio and service screens open with <header><h1>…</h1><p>…</p></header> */
.view header:not(.chat-head):not(.page-head) h1 { margin: 0 0 var(--s1); }
.view header:not(.chat-head):not(.page-head) > p { margin: 0 0 var(--s5); color: var(--text-secondary); font-size: var(--fs-secondary); }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4);
  margin-bottom: var(--s5);
}
.page-head > div { min-width: 0; }
.page-sub { margin: var(--s1) 0 0; color: var(--text-secondary); font-size: var(--fs-secondary); }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; flex: none; }
h2 {
  font-size: var(--fs-micro); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-tertiary);
  margin: 0 0 var(--s3);
}
.section { margin: 0 0 var(--s6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin: 0 0 var(--s3); }
.section-head h2 { margin: 0; }
.section-head .note { font-size: var(--fs-caption); color: var(--text-tertiary); }
.section-head a, .section-head .linkbtn { font-size: var(--fs-caption); }

/* ---- surfaces ---------------------------------------------------------------- */
.panel, .card, .tile {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
}
.panel { padding: var(--s5); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-bottom: var(--s4); }

/* grouped rows: the default for any list of records */
.group {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.group > * + * { border-top: 1px solid var(--border-subtle); }
.item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 56px; padding: var(--s3) var(--s4);
  border: 0; background: none; text-align: left;
  color: var(--text-primary); text-decoration: none;
  font: inherit; font-size: var(--fs-body);
}
a.item, button.item { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
a.item:hover, button.item:hover { background: var(--surface-hover); }
a.item:active, button.item:active { background: var(--surface-pressed); }
a.item:focus-visible, button.item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0; }
.item-icon {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--surface-sunken); color: var(--text-secondary);
}
.item-icon svg { width: 18px; height: 18px; }
.item-icon.hot { background: var(--destructive-soft); color: var(--destructive); }
.item-icon.acc { background: var(--accent-soft); color: var(--accent-text); }
.item-icon.ok { background: var(--success-soft); color: var(--success); }
.item-icon.warn { background: var(--warning-soft); color: var(--warning); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-title { font-weight: 600; font-size: 15px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--text-secondary); font-size: var(--fs-secondary); line-height: 1.4; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); color: var(--text-tertiary); font-size: var(--fs-caption); }
.item-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s1); font-size: var(--fs-caption); color: var(--text-tertiary); text-align: right; }
.item-next { color: var(--accent-text); font-size: var(--fs-caption); font-weight: 600; white-space: nowrap; }
.item-chev { width: 16px; height: 16px; flex: none; color: var(--text-tertiary); }

/* ---- buttons ------------------------------------------------------------------ */
.btn, button[type="submit"], .toolbar button, .lookup button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s4);
  border: 0;
  border-radius: var(--r-md);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform 100ms var(--ease);
  background: var(--accent-fill); color: var(--on-accent);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover, button[type="submit"]:hover { background: var(--accent-hover); }
.btn:active, button[type="submit"]:active { background: var(--accent-pressed); transform: scale(0.98); }
.btn:disabled, button:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }

.toolbar button, .lookup button, .btn.ghost {
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border-strong);
  font-weight: 500;
}
.toolbar button:hover, .lookup button:hover, .btn.ghost:hover {
  border-color: var(--border-control);
  background: var(--surface-sunken);
}
.toolbar button:active, .lookup button:active, .btn.ghost:active { transform: scale(0.98); }
.btn.quiet { background: none; border: 0; color: var(--accent-text); font-weight: 600; padding: 0 var(--s2); }
.btn.quiet:hover { background: var(--accent-soft); }
.btn.danger { background: none; border: 1px solid var(--border-strong); color: var(--destructive); font-weight: 500; }
.btn.danger:hover { background: var(--destructive-soft); border-color: var(--destructive); }
.btn.sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-secondary); }

.btn.send { background: var(--accent-fill); }
.btn.draft { background: var(--accent-fill); color: var(--on-accent); font-weight: 600; }

.linkbtn {
  border: 0; background: none; padding: 0; margin: 0;
  font: inherit; color: var(--accent-text); cursor: pointer; text-decoration: none;
}
.linkbtn:hover { text-decoration: underline; text-underline-offset: 2px; }

.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s5); }

.iconbtn {
  width: 44px; height: 44px; padding: 0; flex: none;
  display: grid; place-items: center; position: relative;
  border: 1px solid var(--border-subtle); border-radius: 50%;
  background: var(--surface); color: var(--text-primary);
  text-decoration: none; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform 100ms var(--ease);
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:hover { background: var(--surface-sunken); border-color: var(--border-strong); }
.iconbtn:active { transform: scale(0.96); }
.iconbtn.quiet { border-color: transparent; background: none; }
.iconbtn.quiet:hover { background: var(--surface-hover); }

/* ---- forms ------------------------------------------------------------------ */
input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="date"], input[type="datetime-local"], input[type="password"], input:not([type]), textarea, select {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-control);
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font); font-size: var(--fs-body);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--s4); }
.field > span { font-size: var(--fs-secondary); font-weight: 600; color: var(--text-primary); }
.field > span small { font-weight: 400; color: var(--text-tertiary); }
.field input, .field textarea, .field select { width: 100%; }
.field .ro { min-height: 44px; display: flex; align-items: center; padding: 0 14px; border-radius: var(--r-md); background: var(--surface-sunken); color: var(--text-secondary); font-size: var(--fs-body); overflow-wrap: anywhere; }
.field .help { font-size: var(--fs-caption); color: var(--text-tertiary); }
.lookup { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s5); }
.lookup input { width: 260px; max-width: 100%; }

/* ---- status: a tag always carries its word ---- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-micro); font-weight: 600; line-height: 1;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  white-space: nowrap;
}
.tag .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 8px; }
.tag.hot, .tag.bad  { background: var(--destructive-soft); color: var(--destructive); }
.tag.age, .tag.warn { background: var(--warning-soft); color: var(--warning); }
.tag.acc, .tag.accent { background: var(--accent-soft); color: var(--accent-text); }
.tag.ok   { background: var(--success-soft); color: var(--success); }
.tag.info { background: var(--info-soft); color: var(--info); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-micro); font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  width: fit-content;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); }
.pill.ok  { color: var(--success); background: var(--success-soft); }
.pill.ok::before  { background: var(--success); }
.pill.bad { color: var(--destructive); background: var(--destructive-soft); }
.pill.bad::before { background: var(--destructive); }
.pill.warn-pill { color: var(--warning); background: var(--warning-soft); }
.pill.warn-pill::before { background: var(--warning); }

/* category + urgency dots — always beside a text label, never color alone */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: baseline; }
.dot-p1, .dot-order_problem { background: var(--destructive); }
.dot-p2                     { background: var(--accent); }
.dot-p3, .dot-service       { background: var(--warning-mark); }
.dot-p4, .dot-product       { background: var(--info); }
.dot-price                  { background: var(--success); }
.dot-cutco_action           { background: var(--info); }
.dot-customer_other         { background: var(--text-tertiary); }
.mark-ok   { color: var(--success); font-weight: 600; }
.mark-warn { color: var(--warning); font-weight: 600; }

/* notes: a state said in words, on its own tint */
.warn:not(.tag), .note-warn {
  background: var(--warning-soft); color: var(--warning);
  border-radius: var(--r-md); padding: var(--s3) var(--s4);
  font-size: var(--fs-secondary); margin: var(--s3) 0;
}
.note-bad { background: var(--destructive-soft); color: var(--destructive); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: var(--fs-secondary); margin: var(--s3) 0; }
.note-ok { background: var(--success-soft); color: var(--success); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: var(--fs-secondary); margin: var(--s3) 0; }
.note-info { background: var(--surface-sunken); color: var(--text-secondary); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: var(--fs-secondary); margin: var(--s3) 0; }
.note-warn b, .note-bad b, .note-ok b { font-weight: 600; }
.sent { display: flex; align-items: center; gap: var(--s2); color: var(--success); font-size: var(--fs-secondary); font-weight: 600; }
.sent svg { width: 18px; height: 18px; }
.draftmeta { font-size: var(--fs-caption); color: var(--text-tertiary); margin: var(--s3) 0; }
.scan-note { color: var(--text-tertiary); font-size: var(--fs-caption); margin: 0 0 var(--s4); }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s3); }

/* ---- chips ---- */
.chip {
  min-height: 40px;
  padding: var(--s2) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: var(--r-pill);
  font-family: var(--font); font-size: var(--fs-secondary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease), transform 100ms var(--ease);
}
.chip:hover { border-color: var(--border-control); color: var(--text-primary); background: var(--surface-sunken); }
.chip:active { transform: scale(0.98); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 600; }

/* ---- segmented control ---- */
.seg {
  display: flex; gap: var(--s1); padding: var(--s1); margin: 0 0 var(--s4);
  background: var(--surface-sunken); border-radius: var(--r-md);
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg a {
  flex: 1 0 auto; min-height: 36px; padding: 0 var(--s4);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: var(--r-sm); background: none;
  font-family: var(--font); font-size: var(--fs-secondary); font-weight: 500;
  color: var(--text-secondary); text-decoration: none; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg button:hover { color: var(--text-primary); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-1); font-weight: 600; }
.seg .n { color: var(--text-tertiary); font-variant-numeric: tabular-nums; font-weight: 500; }
.seg-top { margin-bottom: var(--s5); }

/* ---- skeleton + empty ------------------------------------------------------------ */
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--border-subtle) 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-rows .item { pointer-events: none; }

.empty {
  text-align: center;
  padding: var(--s6) var(--s5);
  color: var(--text-secondary);
}
.empty svg { width: 32px; height: 32px; color: var(--text-tertiary); margin-bottom: var(--s3); }
.empty p { margin: 0; }
.empty small { color: var(--text-tertiary); font-size: var(--fs-caption); }
.group .empty { padding: var(--s5) var(--s4); text-align: left; }

/* thinking: three quiet dots, not spinning chrome */
.thinking { display: flex; align-items: center; gap: var(--s2); color: var(--text-tertiary); font-size: 15px; }
.thinking::before {
  content: ""; width: 32px; height: 8px; flex: 0 0 32px;
  background:
    radial-gradient(circle 3px, var(--text-tertiary) 100%, transparent) 4px 50%/8px 8px no-repeat,
    radial-gradient(circle 3px, var(--text-tertiary) 100%, transparent) 16px 50%/8px 8px no-repeat,
    radial-gradient(circle 3px, var(--text-tertiary) 100%, transparent) 28px 50%/8px 8px no-repeat;
  animation: think 1.2s ease-in-out infinite;
}
@keyframes think { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- cards (the server's Block Kit cards, src/web/render.js) ---- */
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card { padding: var(--s4) var(--s5); }
.card p { margin: 0 0 var(--s3); font-size: 15px; }
.card p:last-child { margin-bottom: 0; }
.card .ctx { font-size: var(--fs-caption); color: var(--text-tertiary); }
.card hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--s3) 0; }
.card code { background: var(--surface-sunken); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.card a { color: var(--accent-text); text-decoration: none; }
.card a:hover { text-decoration: underline; }

/* ---- source card: a record ALMA read, with where it came from ---- */
.source { border: 1px solid var(--border-subtle); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.source-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border-subtle); }
.source-head b { font-size: var(--fs-secondary); }
.source-head small { color: var(--text-tertiary); font-size: var(--fs-caption); }
.source .card { border: 0; border-radius: 0; animation: none; }
.source-actions { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0 var(--s4) var(--s4); }

/* ---- dashboard ------------------------------------------------------------------ */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.tile { padding: var(--s4) var(--s5); }
.tile .k { font-size: var(--fs-caption); font-weight: 500; color: var(--text-secondary); }
.tile .v { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; margin-top: var(--s1); font-variant-numeric: tabular-nums; }
.tile .s { font-size: var(--fs-caption); color: var(--text-tertiary); margin-top: var(--s1); }
.tile .s.up   { color: var(--success); }
.tile .s.down { color: var(--destructive); }
a.tile { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur-fast) var(--ease); }
a.tile:hover { border-color: var(--border-strong); }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4);
  font-size: var(--fs-secondary);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.row:first-child { padding-top: 0; }
.row:last-child { border: 0; padding-bottom: 0; }
.row .lbl { color: var(--text-secondary); min-width: 0; }
.row .lbl small { color: var(--text-tertiary); font-size: var(--fs-micro); }
.row b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* ---- year chart (emphasis form) ---------------------------------------------- */
.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: var(--s4); align-items: center; margin-bottom: var(--s3); font-size: var(--fs-micro); color: var(--text-secondary); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.chart-legend .swatch.cur { background: var(--chart-current); }
.chart-legend .swatch.ctx { background: var(--chart-context); }
.chart-wrap svg { display: block; width: 100%; stroke-width: 1; }
.chart-wrap .grid { stroke: var(--border-subtle); stroke-width: 1; }
.chart-wrap .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-wrap .tick, .chart-wrap .mlabel { fill: var(--text-tertiary); stroke: none; font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-wrap .dlabel { fill: var(--text-secondary); stroke: none; font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart-wrap .bar { stroke: none; }
.chart-wrap .bar.cur { fill: var(--chart-current); }
.chart-wrap .bar.ctx { fill: var(--chart-context); }
.chart-wrap .bar { transition: filter var(--dur-fast) var(--ease); }
.chart-wrap .bandwash { fill: transparent; stroke: none; }
.chart-wrap .band { fill: transparent; stroke: none; cursor: default; }
.chart-wrap .band:focus-visible { outline: none; }
.chart-wrap .is-hot .bandwash { fill: var(--surface-sunken); }
.chart-wrap .is-hot .bar { filter: brightness(1.1); }
.chart-tip {
  position: absolute; min-width: 148px;
  background: var(--surface-elevated); border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: var(--s3) 14px;
  pointer-events: none; z-index: 20; opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.chart-tip.on { opacity: 1; }
.chart-tip h4 { margin: 0 0 var(--s2); font-size: var(--fs-micro); font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.6px; }
.chart-tip .trow { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); font-size: var(--fs-caption); color: var(--text-secondary); padding: 2px 0; }
.chart-tip .trow .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-tip .trow .swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-tip .trow b { color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-tip .delta { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-subtle); font-size: var(--fs-micro); }
.chart-tip .delta.up { color: var(--success); }
.chart-tip .delta.down { color: var(--destructive); }

/* ---- memory + connections ------------------------------------------------------- */
.panel.mem { margin-bottom: var(--s4); }
.panel.mem .scan-note { margin: -8px 0 var(--s4); }
.mem-row { align-items: center; transition: opacity var(--dur) var(--ease); }
.mem-row .lbl { color: var(--text-primary); font-size: var(--fs-secondary); line-height: 1.5; }
.mem-row .lbl small { color: var(--text-tertiary); }
.mem-none { margin: 0; color: var(--text-tertiary); font-size: var(--fs-secondary); }
.btn.ghost.del { min-height: 36px; padding: 0 14px; font-size: var(--fs-caption); }
@media (max-width: 767px) { .btn.ghost.del { min-height: 44px; } }
.btn.ghost.del:hover { border-color: var(--destructive); color: var(--destructive); background: var(--destructive-soft); }
/* Notifications (web/notify.js): this device, the kinds it gets, the other devices */
.nt-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); flex: none; }
.nt-acts .btn.ghost { min-height: 36px; padding: 0 14px; font-size: var(--fs-caption); }
.nt-kind { cursor: pointer; }
.nt-kind:has(.switch:disabled) { cursor: default; }
.mem-row .tag { vertical-align: 1px; margin-left: var(--s1); }
@media (max-width: 767px) {
  .nt-acts .btn.ghost { min-height: 44px; }
  .mem-row:has(.nt-acts) { flex-wrap: wrap; }
}
/* the one on/off switch: the knob's side says it as well as the color does */
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 46px; height: 28px; border-radius: var(--r-pill);
  background: var(--border-control); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #FFFFFF; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease);
}
.switch:checked { background: var(--accent-fill); }
.switch:checked::after { transform: translateX(18px); }
.switch:active:not(:disabled)::after { width: 26px; }
.switch:checked:active:not(:disabled)::after { transform: translateX(14px); }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch:disabled { opacity: 0.45; cursor: default; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
.panel.conn-change { margin-bottom: var(--s4); }
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.conn-head h2 { margin: 0; }
.conn-head .pill { flex: none; white-space: nowrap; }
.conn-effect { margin: 0 0 var(--s2); font-size: var(--fs-body); }
.conn-why { margin: 0 0 var(--s4); color: var(--text-secondary); font-size: var(--fs-secondary); }
.conn-lines { margin: var(--s4) 0; }
.conn-lines .row b { white-space: normal; text-align: right; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .conn-lines .row { flex-direction: column; align-items: flex-start; gap: var(--s1); }
  .conn-lines .row .lbl { font-size: var(--fs-caption); }
  .conn-lines .row b { text-align: left; }
}
details > summary { cursor: pointer; }
.conn-exact summary { display: list-item; padding: var(--s3) 0; color: var(--text-secondary); font-size: var(--fs-caption); line-height: 20px; border-radius: var(--r-sm); }
.conn-exact summary:hover { color: var(--text-primary); }
.conn-exact pre {
  margin: 0 0 var(--s3); padding: var(--s3) var(--s4); max-height: 240px; overflow: auto;
  background: var(--surface-sunken); border-radius: var(--r-md);
  font-size: var(--fs-micro); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.conn-ok { background: var(--success-soft); color: var(--success); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin: 0 0 var(--s4); font-size: var(--fs-secondary); }
.conn-bad { color: var(--warning) !important; }
.mem-row .lbl a { overflow-wrap: anywhere; }
/* An app that connects with a key the rep pastes (Acuity): its row, then the two boxes. */
.mem-row:has(+ .conn-keyform) { border-bottom: 0; }
.conn-keyform { padding: 0 0 var(--s4); border-bottom: 1px solid var(--border-subtle); }
.conn-keyform .field-pair { display: grid; grid-template-columns: 1fr 2fr; gap: 0 var(--s3); }
@media (max-width: 560px) { .conn-keyform .field-pair { grid-template-columns: 1fr; } }
.conn-keyform .help { margin: 0 0 var(--s3); font-size: var(--fs-caption); color: var(--text-tertiary); line-height: 1.5; }
.conn-keyform .actions { margin: 0; }

/* ---- disclosure: "Why this is here" and the like ---- */
.disclose { border-top: 1px solid var(--border-subtle); }
.disclose > summary {
  list-style: none; display: flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s1);
  color: var(--text-secondary); font-size: var(--fs-secondary); font-weight: 500;
}
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary svg { width: 16px; height: 16px; transition: transform var(--dur-fast) var(--ease); }
.disclose[open] > summary svg { transform: rotate(90deg); }
.disclose > summary:hover { color: var(--text-primary); }
.disclose > summary .n { margin-left: auto; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.disclose-body { padding: 0 var(--s1) var(--s4); font-size: var(--fs-secondary); color: var(--text-secondary); }

/* ============================================================================
   ALMA: conversations, the conversation, the request library
   ============================================================================ */
body[data-view="alma"] main { padding: 0; }
.view.alma.on { display: grid; grid-template-columns: 272px minmax(0, 1fr); max-width: none; height: 100dvh; }
.convs {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s4) var(--s3);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto; min-height: 0;
}
.convs-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 var(--s2); }
.convs-title { margin: 0; }
.convs-close { display: none; }
.convs-new { width: 100%; justify-content: flex-start; margin-bottom: var(--s2); }
#chatlist { display: flex; flex-direction: column; gap: 2px; padding: 4px; margin: -4px; }
#chatlist .nav { min-height: 44px; }
#chatlist .nav small { margin-left: auto; color: var(--text-tertiary); font-size: var(--fs-micro); font-weight: 400; }
.convs-req { margin-top: auto; }
.alma-main { min-width: 0; min-height: 0; display: flex; justify-content: center; }
.requests { grid-column: 2; padding: var(--s6); overflow-y: auto; max-width: calc(var(--read-w) + 64px); width: 100%; justify-self: center; }
.view.alma.reqs .alma-main { display: none; }

.chat { width: 100%; max-width: var(--read-w); display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
.chat-head {
  position: relative;
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border-subtle);
}
.chat-head [data-convs-open] { display: none; }
.who { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3); }
.who-text { min-width: 0; display: flex; flex-direction: column; }
.who-text b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#who-status { min-height: 18px; font-size: var(--fs-caption); line-height: 18px; color: var(--text-secondary); }
.panel-only { display: none !important; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s5) var(--s5) var(--s4); }

.popmenu {
  position: absolute; right: var(--s4); top: calc(100% - 4px); z-index: 20;
  min-width: 240px; padding: var(--s2);
  display: flex; flex-direction: column; gap: var(--s1);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.popmenu form { display: flex; gap: var(--s2); padding-bottom: var(--s2); border-bottom: 1px solid var(--border-subtle); }
.popmenu form input { flex: 1; min-width: 0; }
.popmenu > button {
  min-height: 44px; padding: 0 var(--s3);
  border: 0; border-radius: var(--r-sm); background: none;
  font-family: var(--font); font-size: 15px; font-weight: 500; text-align: left;
  color: var(--text-primary); cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.popmenu > button:hover { background: var(--surface-sunken); }
.popmenu > button[data-chat-act="delete"] { color: var(--destructive); }

/* ---- thread ---- */
.thread { display: flex; flex-direction: column; gap: var(--s3); min-height: 100%; }
.day { align-self: center; margin: var(--s2) 0 0; font-size: var(--fs-micro); color: var(--text-tertiary); }
.msg {
  max-width: 86%; padding: 10px var(--s4);
  border-radius: var(--r-xl);
  font-size: 15px; line-height: 1.55; overflow-wrap: anywhere;
}
.msg.new { animation: msg-in var(--dur) var(--ease); }
.msg.me { align-self: flex-end; background: var(--accent-fill); color: var(--on-accent); border-bottom-right-radius: var(--r-sm); }
.msg.alma { align-self: flex-start; background: var(--surface); border: 1px solid var(--border-subtle); border-bottom-left-radius: var(--r-sm); }
.msg.alma.ack { color: var(--text-secondary); }
.msg.alma.err { border-color: var(--destructive); }
.msg strong { font-weight: 600; }
.msg a { color: var(--accent-text); }
.msg-ctx { align-self: flex-end; margin-bottom: -6px; font-size: var(--fs-caption); color: var(--text-tertiary); max-width: 86%; text-align: right; }
.msg-ctx b { color: var(--text-secondary); font-weight: 600; }
.earlier { align-self: center; }
.msg-actions { align-self: flex-start; display: flex; flex-wrap: wrap; gap: var(--s2); }
.msg-actions .btn { min-height: 40px; text-decoration: none; }

/* the records ALMA read: one labelled source each, closed until asked for */
.evidence { align-self: stretch; display: flex; flex-direction: column; gap: var(--s2); }
.evchips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.evchip { min-height: 40px; font-size: var(--fs-caption); display: inline-flex; align-items: center; gap: 6px; }
.evchip svg { width: 14px; height: 14px; transition: transform var(--dur-fast) var(--ease); }
.evchip[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.evchip[aria-expanded="true"] svg { transform: rotate(90deg); }

.chat-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); margin: auto 0; padding: var(--s6) 0; }
.chat-empty h2 { text-transform: none; letter-spacing: -0.2px; font-size: var(--fs-section); color: var(--text-primary); margin: var(--s2) 0 0; }
.chat-empty p { margin: 0; color: var(--text-secondary); font-size: var(--fs-secondary); max-width: 420px; }
.suggests { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s2); }

/* ---- composer: the most refined control on the page ---- */
#composer {
  margin: 0 var(--s5) var(--s5);
  display: flex; flex-direction: column; gap: var(--s2);
  padding: 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-control); border-radius: 24px;
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
#composer:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-row { display: flex; align-items: flex-end; gap: var(--s2); }
#q {
  flex: 1; min-width: 0; min-height: 44px; max-height: 200px;
  padding: 11px var(--s3); border: 0; background: transparent; box-shadow: none;
  resize: none; line-height: 22px;
}
#q:focus { outline: none; box-shadow: none; }
/* #send carries its own button basics: it is type="submit" while idle and
   type="button" while it is the Stop button. */
#send {
  width: 44px; min-height: 44px; height: 44px; flex: 0 0 44px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--accent-fill); color: var(--on-accent);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
#send:hover { background: var(--accent-hover); }
#send:active { background: var(--accent-pressed); transform: scale(0.96); }
#send svg { width: 20px; height: 20px; stroke-width: 2; }
#send[data-mode="stop"] { background: var(--text-primary); color: var(--bg); }

/* the context chip: what this message is about, removable */
.ctxchip {
  display: flex; align-items: center; gap: var(--s2); align-self: flex-start;
  max-width: 100%; min-height: 32px; margin: 2px 2px 0; padding: 0 4px 0 var(--s3);
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-text);
  font-size: var(--fs-caption);
}
.ctxchip-k { font-weight: 600; flex: none; }
.ctxchip-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.ctxchip-x { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.ctxchip-x:hover { background: var(--accent-soft); }
.ctxchip-x svg { width: 14px; height: 14px; }

/* ---- the request library ---- */
.idea-group { margin-bottom: var(--s5); }
.idea-group .group .item { font-size: 15px; }

/* ---- Ask ALMA beside the work (≥1280px) ---- */
@media (min-width: 1280px) {
  body.asking .askpanel {
    display: flex; position: sticky; top: 0; height: 100dvh;
    flex: 0 0 var(--panel-w); width: var(--panel-w); min-width: 0; max-width: var(--panel-w); overflow: hidden;
    border-left: 1px solid var(--border-subtle); background: var(--bg);
  }
  .askpanel .chat { max-width: none; min-width: 0; }
  .askpanel .msg, .askpanel .evidence { min-width: 0; }
  /* the work beside the panel keeps a readable pane */
  body.asking .ib { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  body.asking .ib-detailpane { padding-left: var(--s5); padding-right: var(--s5); }
  body.asking .cal-grid { grid-template-columns: minmax(0, 1fr); }
  .askpanel .panel-only { display: grid !important; }
  .askpanel [data-newchat].iconbtn { display: none; }
  .askpanel .chat-scroll { padding: var(--s4); }
  .askpanel #composer { margin: 0 var(--s4) var(--s4); }
}

/* ============================================================================
   Overlays: search, the settings menu, the toast
   ============================================================================ */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.32); animation: view-in var(--dur) var(--ease); }
.dialog-wrap {
  position: fixed; inset: 0; z-index: 90;
  display: flex; justify-content: center; align-items: flex-start;
  padding: max(10vh, calc(16px + env(safe-area-inset-top))) var(--s4) var(--s4);
  background: rgba(0, 0, 0, 0.32);
  animation: view-in var(--dur) var(--ease);
}
.dialog {
  width: min(640px, 100%); max-height: min(560px, 80dvh);
  display: flex; flex-direction: column;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle); border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop); overflow: hidden;
  animation: pop-in var(--dur) var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(0.99); } to { opacity: 1; transform: none; } }
.search-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-bottom: 1px solid var(--border-subtle); }
.search-row > svg { width: 20px; height: 20px; color: var(--text-tertiary); flex: none; }
.search-row input { flex: 1; min-width: 0; border: 0; box-shadow: none; background: none; font-size: 17px; padding: 10px var(--s1); }
.search-row input:focus { box-shadow: none; }
.search-results { list-style: none; margin: 0; padding: var(--s2); overflow-y: auto; }
.search-results .sr-group { padding: var(--s2) var(--s3) var(--s1); font-size: var(--fs-micro); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-tertiary); }
.search-results [role="option"] {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 48px; padding: var(--s2) var(--s3); border-radius: var(--r-md);
  cursor: pointer; color: var(--text-primary);
}
.search-results [role="option"] svg { width: 18px; height: 18px; color: var(--text-tertiary); flex: none; }
.search-results [role="option"] .sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-results [role="option"] .sr-main b { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results [role="option"] .sr-main small { color: var(--text-tertiary); font-size: var(--fs-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results [role="option"][aria-selected="true"] { background: var(--accent-soft); }
.search-results [role="option"][aria-selected="true"] svg { color: var(--accent-text); }
.search-results .sr-none { padding: var(--s4) var(--s3); color: var(--text-tertiary); font-size: var(--fs-secondary); }

.menu-pop {
  position: fixed; z-index: 80;
  left: var(--s3); bottom: 88px; width: calc(var(--side-w) - 24px);
  padding: var(--s2);
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--dur) var(--ease);
}
.menu-pop a {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-sm);
  color: var(--text-primary); text-decoration: none; font-size: 15px; font-weight: 500;
}
.menu-pop a svg { width: 20px; height: 20px; color: var(--text-secondary); }
.menu-pop a:hover, .menu-pop a:focus-visible { background: var(--surface-hover); }
.menu-note { display: flex; flex-direction: column; gap: var(--s1); margin: var(--s1) 0 0; padding: var(--s3) var(--s3) var(--s1); border-top: 1px solid var(--border-subtle); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 120;
  display: flex; align-items: center; gap: var(--s3);
  /* its own width, not what is left right of the middle (a phone squeezed it to half the screen) */
  width: max-content; max-width: min(560px, calc(100vw - 32px));
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--text-primary); color: var(--bg);
  font-size: var(--fs-secondary);
  box-shadow: var(--shadow-pop);
  transform: translate(-50%, 16px); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.toast.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.toast.bad { background: var(--destructive); color: #FFFFFF; }
.toast button { min-height: 36px; padding: 0 var(--s3); border: 0; border-radius: var(--r-sm); background: rgba(127, 127, 127, 0.25); color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
/* "ALMA was updated": stays until Reload or Later (web/app.js checkBuild) */
.update-bar {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 119;
  display: flex; align-items: center; gap: var(--s2);
  width: max-content; max-width: min(560px, calc(100vw - 32px));
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  background: var(--surface-elevated); color: var(--text-primary);
  font-size: var(--fs-secondary); box-shadow: var(--shadow-pop);
  transform: translate(-50%, 16px); opacity: 0;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.update-bar.on { transform: translate(-50%, 0); opacity: 1; }
.update-bar[hidden] { display: none; }
.update-bar span { flex: 1 1 auto; min-width: 0; }
.update-bar .btn { flex: none; }
@media (max-width: 767px) { .update-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3)); } }
@media (prefers-reduced-motion: reduce) { .update-bar { transition: none; } }

/* ============================================================================
   Responsive: tablet rail, phones
   ============================================================================ */
@media (min-width: 1024px) {
  body { font-size: 15px; }
  :root { --fs-body: 15px; }
}

/* tablets: the sidebar becomes a rail of icons with short labels */
@media (min-width: 768px) and (max-width: 1023px) {
  main { padding: var(--s5) var(--s5) 48px; }
  .side { flex-basis: var(--rail-w); padding: var(--s3) var(--s2); align-items: stretch; }
  .side-brand { justify-content: center; padding: 0; }
  .side-brand b, .side-search span, .side-search .kbd-hint, .side-sub, .side-status small { display: none; }
  .side-search { justify-content: center; padding: 0; min-height: 44px; }
  .side .nav { flex-direction: column; gap: 2px; justify-content: center; min-height: 56px; padding: var(--s1) 0; font-size: 11px; text-align: center; position: relative; }
  .side .nav .nav-count { position: absolute; top: 4px; right: 8px; margin: 0; min-width: 18px; padding: 0 5px; line-height: 16px; font-size: 10px; }
  .side-status { align-items: center; padding: 0; }
  .side-status .pill { padding: 4px 8px; font-size: 10px; }
  .menu-pop { left: calc(var(--rail-w) + 8px); bottom: 16px; width: 260px; }
  .view.alma.on { grid-template-columns: 240px minmax(0, 1fr); }
}

/* phones: designed, not shrunk */
@media (max-width: 767px) {
  :root { --fs-title: 24px; --fs-body: 16px; }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; gap: var(--s1);
    position: sticky; top: 0; z-index: 30;
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--s2) 0 var(--s4);
    background: var(--bg);
    border-bottom: 1px solid transparent;
  }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .topbar { background: color-mix(in srgb, var(--bg) 85%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); }
  }
  body.scrolled .topbar { border-bottom-color: var(--border-subtle); }
  .topbar-title { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar [data-topback]:not([hidden]) + .topbar-title { padding-left: 0; }
  .topbar:has([data-topback]:not([hidden])) { padding-left: var(--s1); }
  .dot-count { position: absolute; top: 8px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent-fill); color: var(--on-accent); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }

  main { padding: var(--s4) var(--s4) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s6)); }
  main h1 { font-size: var(--fs-title); }
  /* the page title is in the top bar on phones; a screen's own h1 is for wide screens */
  .page-head h1.dup { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 var(--s1) env(safe-area-inset-bottom);
    background: var(--surface-elevated);
    border-top: 1px solid var(--border-subtle);
  }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .tabbar { background: color-mix(in srgb, var(--surface-elevated) 88%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); }
  }
  .tab {
    flex: 1; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 44px; color: var(--text-secondary); text-decoration: none;
    font-size: 11px; font-weight: 500;
    transition: color var(--dur-fast) var(--ease);
  }
  .tab svg { width: 24px; height: 24px; }
  .tab:active { opacity: 0.7; }
  .tab[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
  .tab[aria-current="page"] svg { stroke-width: 2; }
  .tab .dot-count { top: 4px; right: calc(50% - 22px); }

  /* A control reached with Tab or by a link scrolls clear of the top bar, the tab bar and
     the composer, so its focus ring is never hidden under one of them (WCAG 2.4.11). */
  main :is(a[href], button, input, textarea, select, summary, [tabindex]) {
    scroll-margin-top: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--s2));
    scroll-margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s2));
  }
  #view-alma :is(a[href], button, [tabindex]) { scroll-margin-top: 80px; scroll-margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 96px); }
  #composer :is(button, textarea) { scroll-margin: 0; }
  /* the keyboard is up: nothing fixed sits over the field being typed in */
  body.typing .tabbar { display: none; }
  body.typing main { padding-bottom: var(--s4); }
  /* the studio's editor brings its own action bar */
  body.mk-editing .tabbar { display: none; }

  /* a row's next step goes under its text, so the text keeps the width */
  .item { flex-wrap: wrap; row-gap: var(--s1); padding: var(--s3); }
  .item-main { flex: 1 1 0; }
  .item-chev { order: 2; }
  .item-side { order: 3; flex: 1 0 100%; flex-direction: row; justify-content: flex-start; padding-left: 48px; }
  .split { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
  .tile { padding: var(--s3) var(--s4); }
  .tile .v { font-size: 22px; }
  .lookup input { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  /* the words take the row and an icon stays beside them; buttons too wide to fit beside the
     words drop to their own line (one rule once halved every phone header and pushed a wide
     button off the screen) */
  .page-head { flex-wrap: wrap; align-items: center; row-gap: var(--s3); margin-bottom: var(--s4); }
  .page-head > div:not(.page-actions) { flex: 1 1 200px; }
  .page-head > .page-actions { flex: 0 1 auto; max-width: 100%; }
  .section-head { flex-wrap: wrap; row-gap: 2px; }
  .section-head .note { flex-basis: 100%; }
  .worknav { margin: 0 calc(-1 * var(--s4)) var(--s4); border-radius: 0; padding: var(--s1) var(--s4); background: none; gap: var(--s2); }
  .worknav a { border: 1px solid var(--border-strong); border-radius: var(--r-pill); min-height: 44px; }

  /* every tap target at least 44px tall on a phone (docs/DESIGN.md); a text link keeps its
     look and gets the height as an invisible margin */
  .btn.sm, .seg button, .seg a, .chip { min-height: 44px; }
  .linkbtn, .ctxchip-x { position: relative; }
  .linkbtn::after { content: ""; position: absolute; inset: -12px -4px; }
  .ctxchip-x::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; }
  /* text that names the thing wraps to two lines instead of losing its end */
  .item-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .search-results [role="option"] .sr-main b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  /* iOS zooms into any field under 16px when it gets focus */
  .os-brief { font-size: 16px; }
  .worknav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; box-shadow: none; }

  /* ALMA on a phone: the conversation's own header is the top bar, the page scrolls,
     and the composer rides above the tab bar (or the keyboard) */
  body[data-view="alma"] .topbar { display: none; }
  .view.alma.on { display: block; height: auto; }
  .convs {
    position: fixed; inset: 0; z-index: 85; display: none;
    padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom));
    background: var(--bg); border: 0;
  }
  .convs.open { display: flex; animation: view-in var(--dur) var(--ease); }
  .convs-close { display: grid; }
  .chat { height: auto; min-height: 100dvh; max-width: none; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  body.typing .chat { padding-bottom: 0; }
  .chat-head {
    position: sticky; top: 0; z-index: 20;
    padding: calc(var(--s2) + env(safe-area-inset-top)) var(--s2) var(--s2);
    background: var(--bg);
  }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .chat-head { background: color-mix(in srgb, var(--bg) 85%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); }
  }
  .chat-head [data-convs-open] { display: grid; }
  .chat-scroll { overflow: visible; flex: 1; padding: var(--s4); }
  #composer {
    position: sticky; z-index: 25;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s2));
    margin: 0 var(--s3) var(--s3);
    box-shadow: var(--shadow-pop);
  }
  body.typing #composer { bottom: var(--s2); }
  .requests { padding: var(--s4); }
  .msg { max-width: 92%; }
  .menu-pop {
    left: var(--s2); right: var(--s2); top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: auto; width: auto;
  }
  .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3)); }
  body.typing .toast { bottom: var(--s3); }
  .dialog-wrap { padding-top: calc(var(--s2) + env(safe-area-inset-top)); }
  .dialog { max-height: calc(100dvh - 96px); }
}

/* ============================================================================
   Today, Calendar, Work (web/today.js, web/calendar.js, web/work.js)
   ============================================================================ */
.today-head h1 { font-size: var(--fs-title); }
.today-time { flex: 0 0 64px; display: flex; flex-direction: column; font-size: var(--fs-caption); font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.today-time small { font-weight: 400; color: var(--text-tertiary); font-size: var(--fs-micro); }
.today-next { background: var(--accent-soft); }
.today-next:hover { background: var(--accent-soft) !important; filter: brightness(0.98); }
.today-next .item-meta { color: var(--accent-text); font-weight: 600; }
.today-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.today-nums .tile .v { font-size: 22px; }
@media (max-width: 767px) { .today-nums { grid-template-columns: 1fr 1fr; } .today-nums .tile:last-child { grid-column: 1 / -1; } }

.cal-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
@media (min-width: 1100px) { .cal-grid { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } .cal-side { position: sticky; top: var(--s6); } }
.cal-side .group + .group { margin-top: var(--s3); } /* one per scheduling app (Calendly, Acuity) */
.cal-day { margin-bottom: var(--s4); }
.cal-dayhead { margin: 0 0 var(--s2); font-size: var(--fs-secondary); font-weight: 600; color: var(--text-secondary); }
.cal-open .item-main { gap: var(--s2); }
.cal-open .bk-chip { min-height: 36px; padding: 0 var(--s3); }
@media (max-width: 767px) { .cal-open .bk-chip { min-height: 44px; } }
.cal-book .bk:not([hidden]) { margin-top: var(--s3); }
.cust-card .card { margin-bottom: var(--s3); }
.mk-home .mk-seg { margin-top: 0; }

/* ---- Work › Orders: the order sheet and the New order form (web/work.js) ---- */
.os-back { margin: 0 0 var(--s3) calc(-1 * var(--s2)); }
.os-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (min-width: 1100px) { .os-grid { grid-template-columns: minmax(0, 1fr) 380px; } .os-side { position: sticky; top: var(--s6); } }
.os-side { display: flex; flex-direction: column; gap: var(--s4); }
.os-side .panel h2 { margin-bottom: var(--s2); }
.os { margin: 0; display: grid; gap: var(--s3); }
.os > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--s3); padding-bottom: var(--s3); border-bottom: 1px solid var(--border-subtle); font-size: var(--fs-secondary); }
.os > div:last-child { border-bottom: 0; padding-bottom: 0; }
.os dt { color: var(--text-tertiary); }
.os dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.os dd small, .os-row small, .os-eng small { color: var(--text-tertiary); font-size: var(--fs-caption); }
.os-items { display: flex; flex-direction: column; gap: var(--s2); }
.os-row { display: flex; gap: var(--s2); }
.os-qty { flex: none; min-width: 40px; font-weight: 600; font-variant-numeric: tabular-nums; }
.os-sku { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.os-eng + .os-eng { margin-top: var(--s2); }
.os-miss { color: var(--warning); font-weight: 600; }
.os-brief { width: 100%; font-size: var(--fs-caption); line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-sunken); }
.os-remove { align-self: flex-start; color: var(--text-secondary); }
@media (max-width: 560px) { .os > div { grid-template-columns: 1fr; gap: 2px; } }

/* customer notes: the order page's "About the customer" and Orders › Customer notes (2026-10-29) */
.os-main { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.os-notes h2 { margin-bottom: var(--s1); }
.os-notes > .bk-fine { margin-top: 0; }
.cn-list { list-style: none; margin: var(--s3) 0 var(--s4); padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.cn-list .cn-item { padding: var(--s3) var(--s4); background: var(--surface-sunken); border-radius: var(--r-md); }
.cn-group { list-style: none; margin: 0; padding: 0; }
.cn-group .cn-item { padding: var(--s4); }
.cn-who { margin: 0 0 var(--s1); display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); font-size: var(--fs-secondary); }
.cn-who a { color: var(--text-primary); text-decoration: none; }
.cn-who a:hover { text-decoration: underline; text-underline-offset: 2px; }
.cn-who span { color: var(--text-tertiary); font-size: var(--fs-caption); }
.cn-text { margin: 0; font-size: var(--fs-body); line-height: 1.45; color: var(--text-primary); overflow-wrap: anywhere; white-space: pre-wrap; }
.cn-meta { margin: var(--s2) 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-caption); color: var(--text-tertiary); }
.cn-why { margin: var(--s1) 0 0; font-size: var(--fs-secondary); color: var(--text-secondary); line-height: 1.4; }
.cn-item .actions { margin-top: var(--s2); }
.cn-out:empty, .cn-add-out:empty { display: none; }

.no-form { max-width: 760px; }

/* ---- Connections › Vast Action CRM: signing in from the app (web/app.js) ---- */
.crm-signin { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); align-items: start; }
@media (min-width: 900px) { .crm-signin { grid-template-columns: 400px minmax(0, 1fr); } }
.crm-frame { position: relative; width: 100%; max-width: 400px; aspect-ratio: 400 / 760; border: 1px solid var(--border-subtle); border-radius: var(--r-lg); overflow: hidden; background: var(--surface-sunken); }
.crm-frame .crm-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: var(--s5); margin: 0; }
#crm-live { display: block; width: 100%; height: 100%; object-fit: contain; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.crm-typebar { display: flex; gap: var(--s2); }
.crm-typebar input { flex: 1; min-width: 0; }
.crm-keys { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }
.crm-steps { margin: 0 0 var(--s3); }
.crm-say { margin-top: 0; }

/* ---- Work › Marketing: CRM send-outs (web/work.js) ---- */
.mk-plan-head { margin-top: var(--s6); }
.so-signin { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.so-who { margin-top: var(--s4); }
.so-who input[type="search"] { width: 100%; margin-bottom: var(--s3); }
.so-people { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; border: 1px solid var(--border-subtle); border-radius: var(--r-md); }
.so-people li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px var(--s3); padding: var(--s2) var(--s3); border-top: 1px solid var(--border-subtle); font-size: var(--fs-secondary); color: var(--text-primary); }
.so-people li:first-child { border-top: 0; }
.so-people li small { color: var(--text-tertiary); font-size: var(--fs-caption); overflow-wrap: anywhere; }
.so-email { display: block; width: 100%; height: 520px; border: 1px solid var(--border-subtle); border-radius: var(--r-md); background: #fff; }
.so-edit .field:last-of-type { margin-bottom: var(--s2); }
.no-set { border: 0; padding: 0; margin: 0 0 var(--s5); }
.no-set legend { padding: 0; margin-bottom: var(--s3); font-size: var(--fs-micro); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-tertiary); }
.no-set .seg { margin-bottom: var(--s2); }
.no-set .seg button[aria-checked="true"] { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-1); font-weight: 600; }
.no-two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (max-width: 560px) { .no-two { grid-template-columns: 1fr; } }
.no-item { position: relative; padding: var(--s3) 0; border-top: 1px solid var(--border-subtle); }
.no-item:first-child { border-top: 0; padding-top: 0; }
.no-item-top { display: flex; align-items: flex-end; gap: var(--s2); }
.no-item-top .field { margin: 0; }
.no-pick { flex: 1; min-width: 0; }
.no-qty { flex: 0 0 72px; }
.no-color { flex: 0 0 150px; }
.no-del { margin-bottom: 0; }
@media (max-width: 560px) { .no-item-top { flex-wrap: wrap; } .no-pick { flex-basis: calc(100% - 52px); } .no-color { flex: 1; } }
.no-suggest { list-style: none; margin: var(--s1) 0 0; padding: var(--s1); border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface-elevated); box-shadow: var(--shadow-pop); max-height: 280px; overflow-y: auto; position: relative; z-index: 5; }
.no-suggest li { display: flex; flex-direction: column; padding: var(--s2) var(--s3); border-radius: var(--r-sm); cursor: pointer; min-height: 44px; justify-content: center; }
.no-suggest li:hover, .no-suggest li:focus { background: var(--accent-soft); outline: none; }
.no-suggest li small { color: var(--text-tertiary); font-size: var(--fs-caption); }
.no-suggest .no-none { cursor: default; color: var(--text-tertiary); font-size: var(--fs-secondary); }
.no-eng { margin-top: var(--s2); }
.no-find .group { margin: 0 0 var(--s3); }
.no-near { margin: 0 0 var(--s3); }
.no-say { margin: 0 0 var(--s2); }
.no-picked { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); margin: 0 0 var(--s3); }
.no-picked .bk-fine { margin: 0; flex: 1 1 220px; }
.no-out:empty { display: none; }
.os-state { margin: var(--s2) 0 0; }
/* Reading a paper order form (Work › Orders › Read an order form) */
.ff-take { max-width: 760px; display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; }
.ff-add { position: relative; cursor: pointer; }
.ff-add:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.ff-photos { display: flex; flex-wrap: wrap; gap: var(--s2); }
.ff-photos:empty { display: none; }
.ff-photos figure { position: relative; margin: 0; width: 132px; }
.ff-photos img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border-subtle); background: var(--surface-sunken); }
.ff-photos figcaption { margin-top: var(--s1); font-size: var(--fs-caption); color: var(--text-secondary); }
.ff-photos .iconbtn { position: absolute; top: var(--s1); right: var(--s1); background: var(--surface-elevated); box-shadow: var(--shadow-1); }
.ff-out:empty { display: none; }
.ff-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (min-width: 1100px) { .ff-grid { grid-template-columns: 300px minmax(0, 1fr); } .ff-side { position: sticky; top: var(--s6); } .ff-side .ff-photos figure { width: 100%; } .ff-side .ff-photos img { aspect-ratio: auto; } }
.ff-form { max-width: 820px; }
.ff-three { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 0.8fr) minmax(0, 1fr); gap: var(--s3); }
@media (max-width: 560px) { .ff-three { grid-template-columns: 1fr 1fr; } .ff-three .field:first-child { grid-column: 1 / -1; } }
.field.unread input { border-color: var(--warning); }
.unread-note { display: block; margin-top: var(--s1); color: var(--warning); font-size: var(--fs-caption); }
.ff-items { display: flex; flex-direction: column; }
.ff-item { display: grid; grid-template-columns: 64px 110px minmax(0, 1fr) 110px 96px auto 44px; gap: var(--s2); align-items: end; padding: var(--s3) 0; border-top: 1px solid var(--border-subtle); }
.ff-item:first-child { border-top: 0; padding-top: 0; }
.ff-item .field { margin: 0; }
.ff-item .ff-bonus { min-height: 44px; margin: 0; white-space: nowrap; }
@media (max-width: 900px) { .ff-item { grid-template-columns: 64px 1fr 1fr 44px; } .ff-desc { grid-column: 1 / -1; grid-row: 2; } .ff-color { grid-column: 1 / 3; grid-row: 3; } .ff-price { grid-column: 3 / 4; grid-row: 3; } .ff-bonus { grid-column: 1 / -1; grid-row: 4; } .ff-item .iconbtn { grid-column: 4; grid-row: 1; } }
.ff-check > * + * { margin-top: var(--s2); }
.os-steps { margin: 0 0 var(--s3); padding-left: 1.2em; color: var(--text-secondary); font-size: var(--fs-secondary); }
.os-steps li + li { margin-top: var(--s1); }
.os-save-out:empty { display: none; }
@media (max-width: 560px) { .no-set .seg { flex-wrap: wrap; } .no-set .seg button { flex: 1 1 40%; } }
/* A stack of order forms (Work › Orders › Read order forms) */
.sk-thumb { padding: 0; overflow: hidden; }
.sk-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sk-side { flex-direction: row; align-items: center; gap: var(--s2); }
.sk-join { min-height: 44px; max-width: 200px; }
.sk-show { width: 100%; max-width: 520px; margin: 0; }
.iconbtn.armed { color: var(--destructive); }
@media (max-width: 760px) { .sk-side { flex-wrap: wrap; justify-content: flex-start; } .sk-join { max-width: none; flex: 1 1 180px; } }

/* ---------- which places this ALMA shows (config.places.layout, 2026-10-29) ----------
   "marketing": Alan's own ALMA, the marketing agent: Home · Messages · Marketing · Studio · ALMA, with
   Orders, Service and Calendar under More. Everything else keeps the five places (classic). */
body:not([data-layout="marketing"]) [data-layout="marketing"],
body[data-layout="marketing"] [data-layout="classic"] { display: none !important; }
[data-place-hidden] { display: none !important; }
.side-more { display: grid; gap: 2px; margin-top: 14px; }
.side-more-h { margin: 0 0 2px; padding: 0 12px; font-size: 12px; font-weight: 600; color: var(--text-tertiary); letter-spacing: .02em; }
.menu-rule { border: 0; border-top: 1px solid var(--border-subtle); margin: 4px 8px; }
body[data-layout="marketing"] .tab[data-dest="today"] { order: 1; }
body[data-layout="marketing"] .tab[data-dest="inbox"] { order: 2; }
body[data-layout="marketing"] .tab[data-dest="marketing"] { order: 3; }
body[data-layout="marketing"] .tab[data-dest="studio"] { order: 4; }
body[data-layout="marketing"] .tab[data-dest="alma"] { order: 5; }
@media (min-width: 768px) and (max-width: 1023px) { .side-more { display: none; } }

/* Home's marketing rows and the marketing profile (2026-10-29) */
.mk-row .item-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mk-heads .group { border-color: color-mix(in srgb, var(--accent) 35%, var(--border-subtle)); }
.pf-field { display: block; cursor: default; }
.pf-field textarea { display: block; width: 100%; margin-top: 8px; font: inherit; font-size: 15px; line-height: 1.45; padding: 10px 12px;
  border: 1px solid var(--border-control); border-radius: 10px; background: var(--surface); color: inherit; resize: vertical; min-height: 64px; }
.pf-field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pf-actions { display: flex; align-items: center; gap: 12px; }
/* Who gets what: the rep's rule for each kind of send, a row each, edited in place (2026-11-09) */
.pf-rules { margin-top: var(--s6); }
.pf-rules > .page-sub { margin: 0 0 var(--s4); max-width: 68ch; }
.pf-rules-more { margin-top: var(--s4); }
.pf-areas-head { margin-top: var(--s6); }
.pf-areas-head + .page-sub { margin: 0 0 var(--s4); max-width: 68ch; }
.pf-rule { align-items: flex-start; }
.pf-rule .item-title { white-space: normal; }
.pf-rule .item-title small { font-weight: 400; color: var(--text-tertiary); font-size: var(--fs-caption); margin-left: var(--s1); }
.pf-rule > .btn { flex: none; margin-top: 2px; }
.pf-rule-edit { background: var(--surface-sunken); }
.pf-rule-edit .item-main { gap: var(--s3); }
.pf-rule-edit .field { margin: 0; }
.pf-rule-edit .field > span { font-weight: 500; }
/* the base field rule names its input types; a number and a web address get the same look here */
.pf-rule-edit input[type="number"], .pf-rule-edit input[type="url"] {
  min-height: 44px; padding: 10px 14px; font-family: var(--font); font-size: var(--fs-body); color: var(--text-primary);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.pf-rule-edit .pf-months { width: 120px; }
.pf-picks { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.pf-picks .chip small { color: var(--text-tertiary); font-weight: 400; margin-left: 2px; }
.pf-add { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.pf-picks .pf-add { flex: 1 1 260px; }
.pf-add input { flex: 1; min-width: 0; }
.pf-ex { list-style: none; margin: 0; padding: 0; }
.pf-ex li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 44px; }
.pf-ex li + li { border-top: 1px solid var(--border-subtle); }
.pf-link { overflow-wrap: anywhere; }
.pf-said { font-size: var(--fs-secondary); color: var(--text-secondary); }
.pf-said:empty { display: none; }
@media (max-width: 767px) {
  .pf-rule > .btn, .pf-add .btn, .pf-ex .btn, .pf-rule-edit .actions .btn { min-height: 44px; }
  .pf-rule-edit input, .pf-rule-edit select { font-size: 16px; }
}
