/* =========================================================================
   Design tokens
   ========================================================================= */
:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: 'JetBrains Mono', ui-monospace, monospace;

  /* Overlay ink channel — hardcoded overlays throughout the stylesheet
     use rgba(var(--ink-rgb), X). Flip this one value and every subtle
     surface/border/text layer flips with the theme. */
  --ink-rgb: 0, 0, 0;

  /* Light canvas — Sendel Mist */
  --bg: #F2F5F3;
  --bg2: rgba(var(--ink-rgb), 0.03);
  --bg3: rgba(var(--ink-rgb), 0.05);

  /* Text — tx3 bumped to 0.55 for WCAG AA (4.5:1) on light bg.
     The --ink-rgb flip means dark mode gets the equivalent boost
     automatically (lighter alpha = brighter white on the dark canvas). */
  --tx:  rgba(var(--ink-rgb), 0.88);
  --tx2: rgba(var(--ink-rgb), 0.58);
  --tx3: rgba(var(--ink-rgb), 0.55);

  /* Borders */
  --bd:  rgba(var(--ink-rgb), 0.1);
  --bd2: rgba(var(--ink-rgb), 0.18);

  /* Accent (Sendel Moss) — darker for contrast on light */
  --acc:    #2E6B4A;
  --acc-tx: #2E6B4A;
  --acc-bg: rgba(46, 159, 98, 0.14);
  --acc-bg-soft: rgba(46, 159, 98, 0.07);
  --btn-primary-bg: rgba(46, 159, 98, 0.18);
  --btn-primary-tx: #2E6B4A;

  /* Account tag palettes — saturated text for light bg */
  --blue-bg:   rgba(55, 138, 221, 0.14);
  --blue-tx:   #1e5ca0;
  --amber-bg:  rgba(186, 117, 23, 0.16);
  --amber-tx:  #8a5f10;
  --coral-bg:  rgba(216, 90, 48, 0.16);
  --coral-tx:  #b54a20;
  --purple-bg: rgba(125, 115, 220, 0.14);
  --purple-tx: #4d42a8;

  /* Full-screen regen dim: sits over the three analysis cards. */
  --overlay-backdrop: rgba(242, 245, 243, 0.6);

  /* Radius scale (FINDING-T8). Use these tokens for new components;
     the codebase still has some literal 6px / 10px / 14px values from
     before the token system landed. Don't add new ones. */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Type scale (FINDING-T7). The codebase still has some literal sizes
     (12px is the most common body weight, 10px appears 34× mostly for
     mono labels). Use these tokens for new components. Hard floor:
     nothing smaller than 11px in body content. Half-pixels (10.5, 11.5,
     12.5, 13.5) are forbidden — they're pixel-pushing, not a scale. */
  --text-xs:   11px;  /* mono labels, captions, account-name chips */
  --text-sm:   12px;  /* body baseline, chips, secondary text */
  --text-base: 13px;  /* primary body text on dense surfaces */
  --text-md:   14px;  /* primary body text on light/comfortable surfaces */
  --text-lg:   17px;  /* section headings (H2) */
  --text-xl:   22px;  /* page headings (H1) */

  --topbar-h: 60px;
  --subnav-h: 65px;
}

[data-theme="dark"] {
  --ink-rgb: 255, 255, 255;

  --bg: #0D1A12;

  --acc:    #2E9F62;
  --acc-tx: #6FC893;
  --acc-bg: rgba(46, 159, 98, 0.18);
  --acc-bg-soft: rgba(46, 159, 98, 0.08);
  --btn-primary-bg: rgba(46, 159, 98, 0.32);
  --btn-primary-tx: #EAF6EE;

  --blue-bg:   rgba(55, 138, 221, 0.18);
  --blue-tx:   #9AC4F0;
  --amber-bg:  rgba(186, 117, 23, 0.2);
  --amber-tx:  #E8B978;
  --coral-bg:  rgba(216, 90, 48, 0.2);
  --coral-tx:  #F2A589;
  --purple-bg: rgba(125, 115, 220, 0.18);
  --purple-tx: #AFA9EC;

  --overlay-backdrop: rgba(13, 14, 12, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: var(--font-main);
  color: var(--tx);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

.page-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem;
}

.page-heading {
  margin: 0 0 1.25rem;
}
.page-heading h1 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--tx);
  margin: 0 0 4px;
}
.page-heading .subtitle {
  font-size: 13px;
  color: var(--tx3);
}

/* =========================================================================
   Topbar — brand · primary tabs · status pills · avatar
   ========================================================================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--bd);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--acc);
  text-decoration: none;
  flex-shrink: 0;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .brand-mark {
  display: block;
  flex-shrink: 0;
}
.topbar .brand:hover { text-decoration: none; opacity: 0.85; }

.topbar .nav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: 8px;
}

.nav-tab {
  background: none;
  border: 0;
  padding: 0 16px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 400;
  color: var(--tx2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
  position: relative;
}
.nav-tab:hover { color: var(--tx); }
.nav-tab.active {
  color: var(--tx);
  font-weight: 500;
  border-bottom-color: var(--acc);
}
.nav-tab .nav-count {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  background: var(--acc-bg);
  color: var(--acc-tx);
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.5;
}
.nav-tab .nav-count.zero { display: none; }

.topbar .filler { flex: 1; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-main);
  white-space: nowrap;
}
.status-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.status-pill-icon.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 0 3px rgba(46, 159, 98, 0.18);
}
.status-pill-icon.dot.err {
  background: var(--coral-tx);
  box-shadow: 0 0 0 3px rgba(216, 90, 48, 0.2);
}
.status-pill-icon svg {
  width: 14px;
  height: 14px;
  color: var(--tx3);
}
.status-pill-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.status-pill-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--tx);
}
.status-pill-sub {
  font-size: 11px;
  color: var(--tx3);
}

.avatar-trigger {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--acc-bg);
  color: var(--acc-tx);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
  margin-left: 4px;
}
.avatar-trigger:hover { background: rgba(46, 159, 98, 0.22); }
.avatar-trigger::after {
  content: "▾";
  font-size: 9px;
  margin-left: 2px;
  opacity: 0.7;
  position: absolute;
  margin-top: 24px;
}
.avatar-trigger { position: relative; }

/* =========================================================================
   Sub-nav — view-specific filter row directly under the topbar
   ========================================================================= */
.subnav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--bd);
  position: sticky;
  top: var(--topbar-h);
  z-index: 9;
}
.subnav:empty { display: none; }

.subnav-pills {
  display: inline-flex;
  background: var(--bg2);
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 0;
}
.subnav-pill {
  background: none;
  border: 0;
  padding: 6px 14px;
  font: inherit;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 400;
  color: var(--tx2);
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, color 0.12s;
}
.subnav-pill:hover:not(.active) { color: var(--tx); }
.subnav-pill.active {
  background: var(--bg);
  color: var(--tx);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.subnav-pill .pill-count {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 500;
  background: var(--acc-bg);
  color: var(--acc-tx);
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.5;
}
.subnav-pill:not(.active) .pill-count {
  background: var(--bg3);
  color: var(--tx2);
}
.subnav-pill .pill-count.zero { display: none; }

.subnav-filler { flex: 1; }
.subnav-actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

/* Filter dropdowns: flat select that reads as a tappable text label with
   a small caret. */
.subnav-select {
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--tx2);
  background: transparent;
  border: 0;
  padding: 0 18px 0 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23999' stroke-width='1.4' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right center;
  height: 34px;
}
.subnav-select:hover { color: var(--tx); }
.subnav-select:focus { outline: none; }

/* Primary green button (Sync now / Apply N selected). Bigger, filled, calls
   for action — distinct from .action-btn.primary which is pill-shaped. */
.btn-primary {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 0;
  background: var(--acc);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, opacity 0.12s;
  height: 34px;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: #0a6347; }
[data-theme="dark"] .btn-primary { background: var(--acc); color: #052e21; }
[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: #4cc097; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-primary svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-primary.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  height: 28px;
  border-radius: 6px;
}
/* Sync-now spinner: rotate the refresh-arrow SVG while a sync is in
   flight. Opacity stays at the .btn-primary:disabled value so the
   button still reads as "busy", and the motion communicates progress
   without a layout shift. Reuses @keyframes btn-spinner-rotate below. */
#syncLink.is-syncing svg {
  animation: btn-spinner-rotate 0.9s linear infinite;
  transform-origin: 50% 50%;
}

/* Secondary button used in compare/pending-review */
.btn-secondary {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--bd2);
  background: var(--bg);
  color: var(--tx);
  cursor: pointer;
  height: 34px;
  white-space: nowrap;
  transition: background 0.12s;
}
.btn-secondary:hover:not(:disabled) { background: var(--bg2); }
.btn-secondary:disabled { opacity: 0.5; cursor: default; }

/* =========================================================================
   Avatar dropdown menu (replaces the floating settings gear)
   ========================================================================= */
.avatar-menu {
  position: fixed;
  top: 56px;
  right: 24px;
  /* Clamp on narrow viewports so the popover never overflows the right
     edge of the screen. */
  width: min(380px, calc(100vw - 32px));
  /* If the calendar list grows (many accounts) or the viewport is short,
     scroll inside the popover rather than pushing past the viewport. */
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--bg);
  border: 0.5px solid var(--bd2);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 8px;
  z-index: 1000;
  display: none;
}
.avatar-menu.open { display: block; }

/* Header — gear-in-circle + title/subtitle. Replaces the old uppercase
   "Settings" mono label; the role="dialog" + aria-label on .avatar-menu
   keeps it accessibly named. */
:is(.avatar-menu, .settings-view) .menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 10px;
}
:is(.avatar-menu, .settings-view) .menu-header-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--acc-bg);
  color: var(--acc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
:is(.avatar-menu, .settings-view) .menu-header-icon svg { width: 22px; height: 22px; }
:is(.avatar-menu, .settings-view) .menu-header-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
:is(.avatar-menu, .settings-view) .menu-header-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--tx);
  line-height: 1.2;
}
:is(.avatar-menu, .settings-view) .menu-header-sub {
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.3;
}

:is(.avatar-menu, .settings-view) .menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
}
:is(.avatar-menu, .settings-view) .menu-row:hover { background: var(--bg2); }
:is(.avatar-menu, .settings-view) .menu-label { font-size: 13px; color: var(--tx); }
/* Row icon — 32px rounded square. SVG inherits color via currentColor
   so it picks up --tx2. Uses --acc-bg-soft (the accent-tinted softer
   alternative) instead of --bg3 because plain --bg3 at 5% ink
   disappears against dark backgrounds; --acc-bg-soft is designed to
   read in both light and dark themes. */
:is(.avatar-menu, .settings-view) .menu-row-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--acc-bg-soft);
  color: var(--tx2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
:is(.avatar-menu, .settings-view) .menu-row-icon svg { width: 16px; height: 16px; }
:is(.avatar-menu, .settings-view) .menu-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
:is(.avatar-menu, .settings-view) .menu-sub {
  font-size: 12px;
  color: var(--tx2);
  line-height: 1.35;
}

/* Segmented pill control — for a mutually-exclusive choice that
   should sit alongside `.setting-toggle` switches without changing
   the row's visual weight. Outer pill matches the toggle's resting
   background (--bg3) and 0.5px border; inner buttons reveal the
   active selection by filling with --bg and bumping color to --tx.
   Heights chosen so the control aligns with `.setting-toggle`
   (20px tall) on the same row. */
:is(.avatar-menu, .settings-view) .menu-segment {
  display: inline-flex;
  align-items: center;
  background: var(--bg3);
  border: 0.5px solid var(--bd);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  height: 20px;
  flex-shrink: 0;
}
:is(.avatar-menu, .settings-view) .menu-segment-btn {
  font-family: var(--font-main);
  font-size: 11px;
  color: var(--tx2);
  background: transparent;
  border: 0;
  padding: 0 10px;
  height: 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
:is(.avatar-menu, .settings-view) .menu-segment-btn:hover:not(.active) { color: var(--tx); }
:is(.avatar-menu, .settings-view) .menu-segment-btn.active {
  background: var(--bg);
  color: var(--tx);
}
/* Keyboard-only focus ring — uses :focus-visible so the ring shows for
   tab navigation but NOT for mouse clicks. Replaces a prior
   `outline: none` rule which suppressed the ring entirely. */
:is(.avatar-menu, .settings-view) .menu-segment-btn:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}
:is(.avatar-menu, .settings-view) .menu-section-divider {
  height: 1px;
  background: var(--bd);
  margin: 6px 4px;
}
:is(.avatar-menu, .settings-view) .menu-section-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--tx3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
:is(.avatar-menu, .settings-view) .menu-section-icon {
  color: var(--acc);
  display: inline-flex;
  align-items: center;
}
:is(.avatar-menu, .settings-view) .menu-section-icon svg { width: 14px; height: 14px; }
/* Single-select picker — used for the Investment-memo upload destination.
   Renders below the Skills toggle row as a small section: caps label,
   a card that shows the current value + a right chevron, and a helper
   line. Clicking the card opens an inline options list (rotates the
   chevron 90° to point down). One option click closes the list and
   saves. Sits at the same left edge as menu-row so it reads as part
   of the same panel. */
:is(.avatar-menu, .settings-view) .menu-picker {
  background: var(--bg2);
  border: 0.5px solid var(--bd);
  border-radius: 10px;
  overflow: hidden;
}
:is(.avatar-menu, .settings-view) .menu-picker-value {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
:is(.avatar-menu, .settings-view) .menu-picker-value:hover { background: var(--bg3); }
:is(.avatar-menu, .settings-view) .menu-picker-value:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: -2px;
}
:is(.avatar-menu, .settings-view) .menu-picker-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--tx2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
:is(.avatar-menu, .settings-view) .menu-picker-icon svg { width: 18px; height: 18px; }
:is(.avatar-menu, .settings-view) .menu-picker-name {
  flex: 1;
  font-size: 13px;
  color: var(--tx);
}
:is(.avatar-menu, .settings-view) .menu-picker-placeholder {
  color: var(--tx3);
}
:is(.avatar-menu, .settings-view) .menu-picker-chevron {
  flex: 0 0 auto;
  color: var(--tx3);
  display: inline-flex;
  align-items: center;
  transition: transform 0.15s ease;
}
:is(.avatar-menu, .settings-view) .menu-picker-chevron svg { width: 16px; height: 16px; }
:is(.avatar-menu, .settings-view) .menu-picker[data-open="true"] .menu-picker-chevron {
  transform: rotate(90deg);
}
:is(.avatar-menu, .settings-view) .menu-picker-options {
  display: none;
  border-top: 0.5px solid var(--bd);
}
:is(.avatar-menu, .settings-view) .menu-picker[data-open="true"] .menu-picker-options {
  display: block;
}
:is(.avatar-menu, .settings-view) .menu-picker-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
:is(.avatar-menu, .settings-view) .menu-picker-option:hover { background: var(--bg3); }
:is(.avatar-menu, .settings-view) .menu-picker-option.active .menu-picker-name { color: var(--acc); }
:is(.avatar-menu, .settings-view) .menu-picker-option.active .menu-picker-icon { color: var(--acc); }

/* Footer — disabled Help & Sign out buttons on a single line. These are
   "meta" actions about the menu itself (not settings), so they live on
   one horizontal row with space-between, visually separated from the
   stacked settings rows above. Real <button disabled> keeps them
   focusable for screen readers; the browser blocks clicks natively.
   Don't use pointer-events: none — it would remove them from the tab
   order. */
:is(.avatar-menu, .settings-view) .menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--bd);
  margin-top: 4px;
  padding: 4px 4px 0;
}
:is(.avatar-menu, .settings-view) .menu-row-footer {
  /* Override the base .menu-row's width:auto + space-between layout so
     each footer button hugs its content and sits side-by-side. */
  width: auto;
  flex: 0 1 auto;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
  justify-content: flex-start;
  gap: 8px;
}
:is(.avatar-menu, .settings-view) .menu-row-footer:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
:is(.avatar-menu, .settings-view) .menu-row-footer:disabled:hover {
  background: transparent;
}
/* Footer icons are bare (no tinted square) so the disabled rows read as
   de-emphasized affordances vs. the active settings rows above. */
:is(.avatar-menu, .settings-view) .menu-row-footer .menu-row-icon {
  background: transparent;
  width: 20px;
  height: 20px;
  color: var(--tx3);
}

.sync-error {
  display: flex;
  margin: -0.75rem 0 1rem;
  font-size: 12px;
  color: var(--coral-tx);
  background: var(--coral-bg);
  border: 0.5px solid rgba(216, 90, 48, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

/* System-level setup issues — sibling of sync-error but visually distinct
   (amber instead of coral) because the action sits outside the app (GCP
   console / config edit), not inside (OAuth re-grant). */
.setup-issue {
  display: flex;
  margin: 0 0 0.75rem;
  font-size: 12px;
  color: #6e4423;
  background: #fbe9c8;
  border: 0.5px solid rgba(184, 124, 38, 0.35);
  border-radius: 6px;
  padding: 6px 10px;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

/* v4 attachment pipeline health. Same shape as setup-issue; amber for
   the warn tier (80–95% read), red for err (<80%). Hidden entirely when
   health is good. */
.attachments-health {
  display: flex;
  margin: 0 0 0.75rem;
  font-size: 12px;
  border-radius: 6px;
  padding: 6px 10px;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.attachments-health.warn {
  color: #6e4423;
  background: #fbe9c8;
  border: 0.5px solid rgba(184, 124, 38, 0.35);
}
.attachments-health.err {
  color: #7a1d22;
  background: #fbd7d7;
  border: 0.5px solid rgba(184, 38, 38, 0.45);
}
.attachments-health-label {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.attachments-health-hint {
  width: 100%;
  font-size: 11px;
  opacity: 0.85;
}
.attachments-health-hint code {
  font-family: var(--font-code);
  font-size: 11px;
  padding: 0 3px;
  border-radius: var(--radius-sm);
  background: rgba(var(--ink-rgb), 0.08);
}

/* v4.x drafter-coverage misses. Surfaces rules the analyzer flagged as
   "drafter missed an existing rule" in the last 7 days. Same amber
   palette as attachments-health.warn; informational rather than
   actionable, so no err tier. Hidden entirely when the list is empty
   (renderDrafterCoverageMisses returns ''). */
.drafter-coverage {
  margin: 0 0 0.75rem;
  font-size: 12px;
  border-radius: 6px;
  padding: 6px 10px;
  color: #6e4423;
  background: #fbe9c8;
  border: 0.5px solid rgba(184, 124, 38, 0.35);
}
.drafter-coverage-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.drafter-coverage-label {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.drafter-coverage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.drafter-coverage-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  padding: 2px 0;
  overflow: hidden;
}
.drafter-coverage-count {
  font-family: var(--font-code);
  font-weight: 600;
  min-width: 2ch;
  text-align: right;
  flex-shrink: 0;
}
.drafter-coverage-file {
  font-family: var(--font-code);
  font-size: 10px;
  opacity: 0.75;
  flex-shrink: 0;
}
.drafter-coverage-anchor {
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drafter-coverage-overflow {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}

/* Git auto-push state. Amber when local is ahead of origin (push may
   still be in flight); red when the last push explicitly failed. Mirrors
   the attachments-health visual. */
.git-sync {
  display: flex;
  margin: 0 0 0.75rem;
  font-size: 12px;
  border-radius: 6px;
  padding: 6px 10px;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.git-sync.warn {
  color: #6e4423;
  background: #fbe9c8;
  border: 0.5px solid rgba(184, 124, 38, 0.35);
}
.git-sync.err {
  color: #7a1d22;
  background: #fbd7d7;
  border: 0.5px solid rgba(184, 38, 38, 0.45);
}
.git-sync-label {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.git-sync code {
  font-family: var(--font-code);
  font-size: 11px;
  padding: 0 3px;
  border-radius: var(--radius-sm);
  background: rgba(var(--ink-rgb), 0.08);
}
.git-sync-hint {
  width: 100%;
  font-size: 11px;
  opacity: 0.85;
}
.setup-issue-label {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.setup-issue-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}
.setup-issue-msg {
  min-width: 0;
  word-break: break-word;
}
.setup-issue-link {
  margin-left: auto;
  color: #6e4423;
  border: 0.5px solid rgba(184, 124, 38, 0.5);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  text-decoration: none;
  font-family: var(--font-code);
  font-size: 11px;
  white-space: nowrap;
}
.setup-issue-link:hover {
  background: rgba(184, 124, 38, 0.12);
}

/* Onboarding (T8) — top-of-page banner + the Settings "Finish setting up"
   card. Uses the Sendel Moss accent (positive/guiding, not a warning). All
   tokens, so it flips with the theme. */
.onboarding-banner {
  display: flex;
  margin: 0 0 0.75rem;
  font-size: var(--text-sm);
  color: var(--tx);
  background: var(--acc-bg-soft);
  border: 0.5px solid var(--acc-bg);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.onboarding-banner-label {
  font-family: var(--font-code);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--acc-tx);
  flex-shrink: 0;
}
.onboarding-banner-msg { min-width: 0; flex: 1; word-break: break-word; }
.onboarding-banner-link {
  margin-left: auto;
  color: var(--acc-tx);
  background: transparent;
  border: 0.5px solid var(--acc);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-family: var(--font-code);
  font-size: var(--text-xs);
  white-space: nowrap;
  cursor: pointer;
}
.onboarding-banner-link:hover { background: var(--acc-bg); }

.onboarding-intro { margin: 0 0 12px; color: var(--tx2); font-size: var(--text-base); }
.onboarding-checklist {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.onboarding-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-base);
}
.onboarding-step-mark {
  font-family: var(--font-code);
  width: 1.2em;
  text-align: center;
  flex-shrink: 0;
}
.onboarding-step.is-done .onboarding-step-mark { color: var(--acc-tx); }
.onboarding-step.is-done .onboarding-step-label {
  color: var(--tx2);
  text-decoration: line-through;
  text-decoration-color: var(--bd2);
}
.onboarding-step.is-todo .onboarding-step-mark { color: var(--tx3); }
.onboarding-action { padding: 10px 0; border-top: 0.5px solid var(--bd); }
.onboarding-action-title {
  font-family: var(--font-code);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tx3);
  margin-bottom: 8px;
}
.onboarding-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.onboarding-hint { color: var(--tx3); font-size: var(--text-sm); min-width: 0; flex: 1; }
.onboarding-ok { color: var(--acc-tx); font-size: var(--text-base); font-weight: 500; }
.onboarding-err { color: var(--coral-tx); font-size: var(--text-sm); min-width: 0; flex: 1; }

.sync-error-label {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.sync-error-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
  min-width: 0;
}
.sync-error-acct {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  flex-shrink: 0;
}
.sync-error-msg {
  min-width: 0;
  word-break: break-word;
}
.sync-error-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}
.reauth-link {
  background: none;
  border: 0.5px solid rgba(216, 90, 48, 0.4);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font: inherit;
  font-size: 11px;
  color: var(--coral-tx);
  cursor: pointer;
  transition: background 100ms ease;
}
.reauth-link:hover:not(:disabled) {
  background: rgba(216, 90, 48, 0.12);
}
.reauth-link:disabled {
  opacity: 0.6;
  cursor: default;
}

/* (Old action-email tab styles removed — primary nav lives in `.nav-tabs`
   in the topbar; sub-view tabs live in `.subnav-pills`.) */

/* =========================================================================
   Email rows
   ========================================================================= */
.email-list {
  display: flex;
  flex-direction: column;
}

.email-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 0;
  padding: 14px 8px;
  border-bottom: 0.5px solid var(--bd);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  align-items: start;
}

.email-row:hover {
  background: rgba(var(--ink-rgb), 0.02);
}

.email-row.focused {
  outline: none;
  border-left: 2px solid var(--acc);
  background: rgba(46, 159, 98, 0.05);
  border-radius: 0 8px 8px 0;
}

.email-row.expanded {
  background: rgba(46, 159, 98, 0.05);
}

/* Shuffle tint — warmer/more saturated than the default hover so the
   surfaced candidate reads as a gentle nudge. Placed after .focused /
   .expanded so equal-specificity cascade wins when both apply. */
.email-row.shuffle-tinted,
.email-row.shuffle-tinted.focused,
.email-row.shuffle-tinted.expanded {
  background: rgba(46, 159, 98, 0.12);
}

.acct-badge {
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  align-self: start;
  margin-top: 2px;
  display: inline-block;
  letter-spacing: 0.04em;
}

.acct-personal {
  background: var(--purple-bg);
  color: var(--purple-tx);
}

.acct-goodrx {
  background: var(--blue-bg);
  color: var(--blue-tx);
}

.acct-am {
  background: var(--acc-bg);
  color: var(--acc-tx);
}

.email-main {
  min-width: 0;
  padding-right: 12px;
}

.email-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
  min-width: 0;
}

.email-from {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  max-width: 200px;
}

.email-subject {
  font-size: 13px;
  color: var(--tx2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.email-preview {
  font-size: 12px;
  color: var(--tx3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.email-time {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx3);
}

/* =========================================================================
   Action buttons
   ========================================================================= */
.action-btn {
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-main);
  padding: 6px 14px;
  border-radius: 6px;
  border: 0.5px solid rgba(46, 159, 98, 0.35);
  background: var(--acc-bg);
  color: var(--acc-tx);
  cursor: pointer;
  transition: all 0.1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.action-btn:hover {
  background: rgba(46, 159, 98, 0.28);
  border-color: rgba(46, 159, 98, 0.55);
}

.action-btn.primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-tx);
  border-color: rgba(46, 159, 98, 0.55);
}

.action-btn.primary:hover {
  background: rgba(46, 159, 98, 0.42);
}

.draft-status {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--acc-tx);
  background: var(--acc-bg);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

/* =========================================================================
   Detail panel (expand on click)
   ========================================================================= */
.detail-panel {
  padding: 12px 0 16px 100px;
  animation: slideDown 0.15s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Full email card spans both columns so the analysis cards below share
   row 2 evenly. Tasks reuse `.detail-cards` without a full-email card,
   so their What's happening / Worth doing? sit side-by-side. */
.detail-cards > .full-email-card {
  grid-column: 1 / -1;
}

.detail-card {
  background: rgba(var(--ink-rgb), 0.015);
  border: 0.5px solid rgba(var(--ink-rgb), 0.1);
  border-radius: 10px;
  padding: 14px 16px;
}

.detail-card-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: rgba(var(--ink-rgb), 0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.detail-card-content {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(var(--ink-rgb), 0.75);
}

/* Full email card has its own header row that contains the view toggle.
   Override the card padding so the header sits flush. */
.full-email-card { padding: 0; overflow: hidden; }

.full-email-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(var(--ink-rgb), 0.015);
  border-bottom: 0.5px solid rgba(var(--ink-rgb), 0.08);
}

.full-email-header .detail-card-label { margin-bottom: 0; }

.full-email-body { padding: 14px 16px; }

.view-toggle {
  display: inline-flex;
  background: rgba(var(--ink-rgb), 0.05);
  border-radius: 6px;
  padding: 2px;
  gap: 0;
}

.view-toggle button {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  font-size: 11px;
  color: rgba(var(--ink-rgb), 0.5);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 500;
}

.view-toggle button.active {
  background: rgba(var(--ink-rgb), 0.12);
  color: rgba(var(--ink-rgb), 0.95);
}

.email-html-frame {
  width: 100%;
  height: 420px;
  border: 0;
  background: #fff;
  border-radius: 6px;
}

/* Clean (parsed dark) view */
.clean-view { padding: 18px 20px; }

.clean-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 0.5px solid rgba(var(--ink-rgb), 0.08);
  margin-bottom: 14px;
}

.clean-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(46, 159, 98, 0.15);
  color: var(--acc-tx);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  font-family: var(--font-main);
  letter-spacing: 0.5px;
}

.clean-from {
  font-size: 13px;
  font-weight: 500;
  color: rgba(var(--ink-rgb), 0.92);
}

.clean-from-email {
  font-size: 11px;
  color: rgba(var(--ink-rgb), 0.5);
  margin-left: 6px;
}

.clean-meta {
  font-size: 11px;
  color: rgba(var(--ink-rgb), 0.45);
  margin-top: 3px;
}

.clean-body p {
  font-size: 14px;
  line-height: 1.65;
  color: rgba(var(--ink-rgb), 0.82);
  margin-bottom: 12px;
}

.clean-body p:last-child { margin-bottom: 0; }

.clean-sig {
  border-top: 0.5px solid rgba(var(--ink-rgb), 0.08);
  margin-top: 16px;
  padding-top: 12px;
}

.clean-sig .name {
  font-size: 13px;
  color: rgba(var(--ink-rgb), 0.85);
  font-weight: 500;
}

.clean-sig .title {
  font-size: 12px;
  color: rgba(var(--ink-rgb), 0.6);
  font-style: italic;
  margin-top: 2px;
  white-space: pre-line;
}

.attachments {
  margin-top: 10px;
}

.attachments-summary {
  font-size: 11px;
  color: var(--tx3);
  margin-bottom: 6px;
  font-style: italic;
}

.attachments-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 0.5px solid var(--bd);
  border-left: 3px solid var(--bd);
  border-radius: var(--radius-pill);
  background: var(--bg2);
  color: var(--tx);
  font-size: 11px;
  max-width: 100%;
}

.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}

.attachment-chip:hover {
  background: var(--bg3);
  border-color: var(--bd2);
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.attachment-size {
  color: var(--tx3);
  font-family: var(--font-code);
  font-size: 10px;
}

/* v4 outcome badges. Left border carries the color so the chip stays
   readable on both light + dark themes; the same hue tints background
   subtly so a glance at the inbox row tells you the health story. */
.attachment-outcome-read {
  border-left-color: #2da44e;
  background: linear-gradient(90deg, rgba(45,164,78,0.10), var(--bg2) 40%);
}
.attachment-outcome-filtered {
  border-left-color: #bf8700;
  background: linear-gradient(90deg, rgba(191,135,0,0.10), var(--bg2) 40%);
}
.attachment-outcome-blocked {
  border-left-color: #cf222e;
  background: linear-gradient(90deg, rgba(207,34,46,0.12), var(--bg2) 40%);
}
.attachment-outcome-pending {
  border-left-color: var(--tx3);
}

.attachment-eye {
  text-decoration: none;
  font-size: 12px;
  opacity: 0.6;
}
.attachment-eye:hover {
  opacity: 1.0;
}

.attachment-retry {
  background: transparent;
  border: 0.5px solid var(--bd);
  border-radius: 6px;
  color: var(--tx2);
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
}
.attachment-retry:hover:not(:disabled) {
  background: var(--bg3);
}
.attachment-retry:disabled {
  opacity: 0.6;
  cursor: default;
}

.worth-badge {
  display: inline-block;
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
}

.worth-yes {
  background: rgba(46, 159, 98, 0.18);
  color: var(--acc-tx);
  font-weight: 500;
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 10px;
}

.worth-delegate {
  background: var(--amber-bg);
  color: var(--amber-tx);
}

.worth-maybe {
  background: var(--coral-bg);
  color: var(--coral-tx);
}

.worth-no {
  background: var(--bg3);
  color: var(--tx2);
}

.detail-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Clarifying questions panel */
.clarify-btn {
  background: none;
  border: 0.5px solid rgba(46, 159, 98, 0.35);
  color: var(--acc-tx);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-main);
}
.clarify-btn:hover { background: rgba(46, 159, 98, 0.08); }
.clarify-btn[disabled] { opacity: 0.4; cursor: default; }

.regen-badge {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--acc-tx);
  background: var(--acc-bg);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  cursor: help;
  border: 0.5px dashed rgba(46, 159, 98, 0.3);
}

.clarify-panel {
  margin-top: 14px;
  background: rgba(46, 159, 98, 0.035);
  border: 0.5px solid rgba(46, 159, 98, 0.3);
  border-radius: 10px;
  padding: 14px 16px;
  animation: slideDown 0.15s ease;
}

.clarify-panel-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: rgba(var(--ink-rgb), 0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.clarify-panel-hint {
  font-size: 12px;
  color: var(--tx3);
  margin-bottom: 12px;
  font-style: italic;
}

.clarify-question {
  margin-bottom: 12px;
}

.clarify-question-text {
  font-size: 13px;
  color: rgba(var(--ink-rgb), 0.85);
  margin-bottom: 6px;
  line-height: 1.45;
}

.clarify-answer-input {
  width: 100%;
  background: rgba(var(--ink-rgb), 0.04);
  border: 0.5px solid rgba(var(--ink-rgb), 0.12);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--tx1);
  font-family: var(--font-main);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
  min-height: 34px;
  box-sizing: border-box;
}

.clarify-answer-input:focus {
  outline: none;
  border-color: rgba(46, 159, 98, 0.6);
}

.clarify-panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.detail-cards.regenerating {
  position: relative;
}
.detail-cards.regenerating::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-backdrop);
  border-radius: 10px;
  z-index: 1;
}
.regen-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--acc-tx);
  background: var(--bg);
  padding: 8px 16px;
  border-radius: 20px;
  border: 0.5px solid rgba(46, 159, 98, 0.4);
  z-index: 2;
}

/* =========================================================================
   Proposed actions section (inside the email detail panel)
   ========================================================================= */
.proposal-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 10px;
}
.proposal-divider-line {
  flex: 1;
  height: 0.5px;
  background: var(--bd);
}
.proposal-divider-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--tx3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.proposal-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proposal-card {
  background: rgba(var(--ink-rgb), 0.015);
  border: 0.5px solid rgba(var(--ink-rgb), 0.1);
  border-left-width: 2px;
  border-radius: 10px;
  padding: 12px 14px;
  transition: opacity 0.15s;
}
.proposal-card.email {
  border-left-color: rgba(46, 159, 98, 0.85);
}
.proposal-card.task {
  border-left-color: rgba(186, 117, 23, 0.85);
}
[data-theme="dark"] .proposal-card.task {
  border-left-color: rgba(232, 185, 120, 0.85);
}
.proposal-card.dim {
  opacity: 0.65;
  background: rgba(var(--ink-rgb), 0.008);
}
.proposal-card.dim .proposal-card-label,
.proposal-card.dim .proposal-email-body {
  opacity: 0.7;
}

.proposal-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.proposal-card-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: rgba(var(--ink-rgb), 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.proposal-edit-link {
  font-size: 11px;
  color: var(--tx2);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.proposal-card-error strong {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  font-weight: 600;
}
.proposal-card-error-msg {
  margin-top: 4px;
  font-family: var(--font-code);
  font-size: 11px;
  color: rgba(var(--ink-rgb), 0.65);
  word-break: break-word;
}
/* v6 find-availability verification badges. One palette per outcome
   class — see Component 9 of PLAN_find_availability_enforcement.md. */
.verification-badge {
  display: inline-block;
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.verification-override {
  background: rgba(80, 130, 200, 0.10);
  color: rgba(50, 100, 170, 0.95);
  border: 0.5px solid rgba(80, 130, 200, 0.35);
}
.verification-stale {
  background: rgba(180, 180, 180, 0.12);
  color: rgba(var(--ink-rgb), 0.75);
  border: 0.5px solid rgba(160, 160, 160, 0.40);
  font-style: italic;
}
.verification-held-amber {
  background: rgba(220, 160, 60, 0.12);
  color: rgba(170, 110, 30, 0.95);
  border: 0.5px solid rgba(220, 160, 60, 0.40);
}
.verification-held-red {
  background: rgba(220, 80, 80, 0.12);
  color: rgba(170, 50, 50, 0.95);
  border: 0.5px solid rgba(220, 80, 80, 0.40);
}
.proposal-edit-link:hover {
  color: var(--tx);
  text-decoration: underline;
}

/* Copy-to-clipboard button on the Proposed Email Draft card. Sits in the
   top-right of the card header, aligned with the PROPOSED EMAIL DRAFT label.
   Default state: 16px icon in muted gray inside a 32px hit target. Mobile
   widens to 44px per accessibility tap-target guidance. */
.proposal-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: rgba(var(--ink-rgb), 0.5);
  transition: background 0.15s, color 0.15s, opacity 0.2s;
  min-width: 32px;
  min-height: 32px;
  justify-content: center;
  font-family: inherit;
}
.proposal-copy-btn:hover {
  background: rgba(var(--ink-rgb), 0.08);
  color: var(--tx);
}
.proposal-copy-btn:focus-visible {
  outline: 1px solid rgba(var(--ink-rgb), 0.3);
  outline-offset: 1px;
}
.proposal-copy-btn.copied {
  color: var(--acc-tx);
}
.proposal-copy-btn.error {
  color: var(--coral-tx);
}
.proposal-copy-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  display: block;
}
.proposal-copy-btn-label {
  font-family: var(--font-code);
  font-size: 11px;
  letter-spacing: 0.02em;
}
@media (max-width: 720px) {
  .proposal-copy-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 14px;
  }
}

.proposal-email-body {
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: rgba(var(--ink-rgb), 0.78);
}
.proposal-email-subject {
  font-family: var(--font-main);
  font-size: 12px;
  color: rgba(var(--ink-rgb), 0.6);
  margin-bottom: 6px;
}
/* When Subject is the last metadata row (email-section card has no To row),
   carry the divider + bottom spacing here. On task cards Subject is followed
   by .proposal-email-to, which already owns the divider, so this rule
   doesn't fire and Subject keeps its tight 6px gap to the To row. */
.proposal-email-subject:has(+ .proposal-email-body) {
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 10px;
}
.proposal-email-subject strong {
  color: rgba(var(--ink-rgb), 0.8);
  font-weight: 500;
  margin-right: 6px;
}

.proposal-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Tan-tinted primary for task commit action — parallels the green primary
   on the email card, so the two commit buttons never read identical. Uses
   the amber palette that already exists in the design tokens. */
.action-btn.primary-tan {
  background: var(--amber-bg);
  color: var(--amber-tx);
  border-color: rgba(186, 117, 23, 0.55);
}
.action-btn.primary-tan:hover {
  background: rgba(186, 117, 23, 0.28);
  border-color: rgba(186, 117, 23, 0.75);
}
[data-theme="dark"] .action-btn.primary-tan {
  border-color: rgba(232, 185, 120, 0.5);
}

/* Secondary button — outlined, neutral. Used for dismiss + add affordances. */
.action-btn.secondary {
  background: transparent;
  color: var(--tx2);
  border-color: var(--bd2);
}
.action-btn.secondary:hover {
  background: var(--bg3);
  color: var(--tx);
  border-color: rgba(var(--ink-rgb), 0.3);
}

/* Empty-state variant of proposal-card — shown when the agent suppressed a
   slot. Muted body + single "+ add ..." button so the user can manually fill
   it in (user-adds here are the highest-signal training data). */
.proposal-empty-body {
  font-size: 13px;
  color: var(--tx3);
  font-style: italic;
  margin-bottom: 10px;
}
.proposal-empty-reason {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx3);
  opacity: 0.85;
  margin-top: 4px;
  font-style: normal;
}

/* Inline composer / editor panels inside a proposal card */
.proposal-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}
.proposal-editor input,
.proposal-editor textarea {
  background: rgba(var(--ink-rgb), 0.04);
  border: 0.5px solid rgba(var(--ink-rgb), 0.12);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--tx);
  font-family: var(--font-main);
  font-size: 13px;
  line-height: 1.45;
  box-sizing: border-box;
  width: 100%;
}
.proposal-editor textarea.draft-body {
  font-family: var(--font-code);
  font-size: 12px;
  min-height: 120px;
  resize: vertical;
}
/* Text-draft body: short messages, so override the 120px min-height. */
.proposal-text-editor textarea.draft-body {
  min-height: 44px;
}
.proposal-text-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--tx3);
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.04em;
  vertical-align: middle;
  text-transform: none;  /* preserve "iMessage" casing under the parent label's uppercase rule */
}
.proposal-text-counter {
  margin-top: 6px;
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx3);
  text-align: right;
}
.proposal-text-counter.over {
  color: #c0392b;
}
.proposal-editor input:focus,
.proposal-editor textarea:focus {
  outline: none;
  border-color: rgba(var(--ink-rgb), 0.3);
}
.proposal-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.proposal-status-chip {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--tx3);
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(var(--ink-rgb), 0.05);
  display: inline-block;
  letter-spacing: 0.04em;
}
.proposal-status-chip.done {
  color: var(--acc-tx);
  background: var(--acc-bg);
}

/* =========================================================================
   Group / sub-group headers (new design)
   ----------------------------------------------------------------------
   `.action-section-header` retains its name so existing render code keeps
   working without rewrites; the styling matches the new mockup — colored
   dot · count + label + sublabel + count bubble · "Collapse all" button.
   ========================================================================= */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 12px;
}

.action-section {
  margin-bottom: 28px;
}
.action-section:last-child { margin-bottom: 0; }

.action-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 12px;
}
.action-section-header.clickable { cursor: pointer; }

.action-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
  margin-right: 4px;
}
.action-section-dot.worth-doing { background: #2E9F62; }
.action-section-dot.maybe { background: #EF9F27; }
.action-section-dot.skip { background: #B4B2A9; }
.action-section-dot.captured-dot { background: #6DA8D6; }

.action-section-label {
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--tx);
  font-weight: 500;
}
.action-section-label.secondary {
  color: var(--tx2);
  font-weight: 400;
}

.action-section-count {
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--tx2);
  font-weight: 400;
}

/* Inline middot separator inside group headers */
.action-section-sep {
  color: var(--tx3);
  margin: 0 2px;
  font-size: 13px;
}

/* Bubble-style count next to "RTM inbox" — distinguishes the source label
   from the chronological group total. */
.group-count-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 500;
  background: var(--acc-bg);
  color: var(--acc-tx);
  padding: 1px 8px;
  border-radius: 10px;
  min-width: 20px;
  line-height: 1.5;
}

.action-section-expand {
  margin-left: auto;
  font-family: var(--font-main);
  font-size: 12px;
  color: var(--tx2);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: none;
  border: 0;
  cursor: pointer;
}
.action-section-expand:hover { background: var(--bg2); color: var(--tx); }

.action-section-skip-condensed {
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--tx3);
  padding: 10px 8px 4px;
  line-height: 1.6;
  word-break: break-word;
}
.action-section-skip-condensed .sep {
  margin: 0 6px;
  opacity: 0.5;
}

.captured-list {
  margin-bottom: 0.5rem;
}
.captured-row {
  opacity: 0.82;
  padding: 10px 8px;
}
.captured-row:hover {
  opacity: 1;
}
.captured-row .task-text {
  color: var(--tx2);
}

.task-pending-badge {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--tx3);
  padding: 2px 6px;
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-sm);
  margin-right: 6px;
}
.task-context {
  margin-bottom: 1.25rem;
}

.context-header {
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 500;
  color: var(--tx2);
  padding: 6px 8px;
  margin-bottom: 2px;
}

/* 32px breathing room between consecutive @-lists. :first-child already
   has margin-top:0 by default; the adjacent combinator only fires on the
   2nd+ context, so the top of the tasks list stays flush against the
   captured section or the "tasks" divider. */
.task-context + .task-context {
  margin-top: 32px;
}

.task-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 12px 8px;
  border-bottom: 0.5px solid var(--bd);
  cursor: pointer;
  transition: background 100ms ease;
  position: relative;
}

.task-row:hover,
.task-row.focused {
  background: var(--bg2);
}

.task-row.focused {
  box-shadow: inset 3px 0 0 var(--acc);
}

.task-row.shuffle-tinted,
.task-row.shuffle-tinted.focused {
  background: rgba(46, 159, 98, 0.12);
}

.task-body {
  min-width: 0;  /* lets the text column shrink so long titles wrap cleanly */
}

.task-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--bd2);
  margin-top: 1px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.task-check:hover {
  border-color: var(--acc);
  background: var(--acc-bg);
}

.task-check.done {
  border-color: var(--acc);
  background: var(--acc);
}

.task-check.done::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.task-text {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.task-text.done {
  text-decoration: line-through;
  color: var(--tx3);
}

.task-meta-inline {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx3);
  margin-top: 3px;
  letter-spacing: 0.01em;
}
.task-meta-inline .sep {
  margin: 0 6px;
  opacity: 0.5;
}

.task-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.task-source {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--tx3);
  white-space: nowrap;
}

.task-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.1s;
}

.task-row:hover .task-actions,
.task-row.focused .task-actions {
  opacity: 1;
}

/* Kebab `⋮` action button on email rows — always visible, opens a popover menu. */
.email-kebab {
  background: none;
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--tx3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.email-kebab:hover {
  background: var(--bg2);
  color: var(--tx);
}

.kebab-menu {
  position: absolute;
  background: var(--bg);
  border: 0.5px solid var(--bd2);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  min-width: 180px;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.kebab-menu button {
  background: none;
  border: 0;
  padding: 7px 12px;
  font: inherit;
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--tx);
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.kebab-menu button:hover { background: var(--bg2); }
.kebab-menu button:disabled { color: var(--tx3); cursor: default; }

.task-detail {
  padding: 8px 0 8px 28px;
  animation: slideDown 0.15s ease;
}

.task-detail-content {
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-detail-row {
  margin-bottom: 6px;
}
.task-detail-row:last-child {
  margin-bottom: 0;
}
.task-detail-row .sep {
  margin: 0 6px;
  opacity: 0.5;
}

.due-chip {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 500;
  color: var(--tx2);
  padding: 2px 8px;
  background: var(--bg2);
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: 0;
}
.due-chip.today {
  color: var(--acc-tx);
  background: var(--acc-bg);
  border-color: rgba(46, 159, 98, 0.35);
}
/* Overdue is the only FILLED chip on the row by design — per the
   T14 chip-system rule, filled is reserved for urgent/exception
   states. Solid coral + white text makes it pop against the muted
   sea of outlined/tinted metadata chips. Tracks both themes via
   the --coral-* tokens. */
.due-chip.overdue {
  color: #fff;
  background: var(--coral-tx);
  border-color: var(--coral-tx);
  font-weight: 600;
}
[data-theme="dark"] .due-chip.overdue {
  color: #1A0F0B;
  background: var(--coral-tx);
  border-color: var(--coral-tx);
}

/* Row-level verdict chip — muted pill, matches `.due-chip` dimensions so
   the two sit as peers in hierarchy. Only renders for non-YES verdicts;
   YES stays silent (absence of chip = "worth doing," the default). */
.verdict-chip {
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  text-transform: uppercase;
  border: 0.5px solid transparent;
}
.verdict-chip.verdict-delegate {
  background: #EEF2FF;
  color: #4338CA;
  border-color: rgba(79, 70, 229, 0.35);
}
/* MAYBE: was filled saturated #F4B95F — violated the chip-system
   rule (filled only for urgent). Switched to the same outlined-tinted
   pattern used by every other non-urgent chip on the row.

   Alpha dialed to 0.10 (lighter than --amber-bg's 0.16) to compensate
   for amber's higher base saturation — at the same alpha, amber reads
   noticeably more saturated than green (today, --acc-bg at 0.14). The
   lower alpha makes MAYBE match today's perceptual weight on the row.
   Token --amber-bg stays at 0.16 because warning banners and account
   tags need the extra punch in their own contexts. */
.verdict-chip.verdict-maybe {
  background: rgba(186, 117, 23, 0.10);
  color: var(--amber-tx);
  border-color: rgba(186, 117, 23, 0.32);
}
[data-theme="dark"] .verdict-chip.verdict-maybe {
  background: rgba(186, 117, 23, 0.15);
  color: var(--amber-tx);
  border-color: rgba(186, 117, 23, 0.4);
}
.verdict-chip.verdict-later {
  background: #F1F1EF;
  color: #6B6B6B;
  border-color: rgba(107, 107, 107, 0.35);
}
.verdict-chip.verdict-no {
  background: #FDE8E8;
  color: #B91C1C;
  border-color: rgba(185, 28, 28, 0.35);
}
.verdict-chip.verdict-other {
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--tx2);
  border-color: var(--bd);
}

/* Dark-mode overrides: light-alpha fills + brighter text so the pills
   stay legible on the dark row bg without being garish. */
[data-theme="dark"] .verdict-chip.verdict-delegate {
  background: rgba(99, 102, 241, 0.14);
  color: #A5B4FC;
  border-color: rgba(99, 102, 241, 0.35);
}
[data-theme="dark"] .verdict-chip.verdict-later {
  background: rgba(var(--ink-rgb), 0.08);
  color: rgba(var(--ink-rgb), 0.6);
  border-color: rgba(var(--ink-rgb), 0.18);
}
[data-theme="dark"] .verdict-chip.verdict-no {
  background: rgba(185, 59, 59, 0.14);
  color: #E88A8A;
  border-color: rgba(185, 59, 59, 0.4);
}

/* Refinement chip — pending rewrite proposed by the analyzer. Goes silent
   once accepted or dismissed. Matches `.verdict-chip` dimensions and sits
   in the same chip row. Muted violet so it reads as "could be sharper"
   without competing with verdict (worth-doing) or due-date urgency. */
.refinement-chip {
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  text-transform: uppercase;
  background: #EFE9FE;
  color: #5B21B6;
  border: 0.5px solid rgba(91, 33, 182, 0.35);
}
[data-theme="dark"] .refinement-chip {
  background: rgba(124, 58, 237, 0.14);
  color: #C4B5FD;
  border-color: rgba(124, 58, 237, 0.35);
}

/* Right-column chip row: verdict then due, 8px apart, top-aligned with
   the first line of the task title. */
.task-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 1px;
}

/* v2.1 task analysis blocks -----------------------------------------------
   Analysis cards (What's happening / Worth doing?) reuse `.detail-card`,
   so they share font sizing and padding with email analysis cards. The
   blocks below cover only task-specific surfaces: the cleaner-version
   editor inside the PROPOSED REFINEMENT card, the original-note source
   block, and miscellaneous status rows. */
.task-analysis-row {
  margin-bottom: 0;
}

.task-analysis-heading {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.task-analysis-blocker {
  color: var(--coral-tx);
  font-size: 13px;
}

/* Cleaner version — editable text surface inside the PROPOSED REFINEMENT
   card. The card itself uses `.proposal-card`; the editor is just the
   inline-edited text + the italic rationale. */
.task-rewrite-text {
  font-size: 13px;
  color: var(--tx);
  padding: 8px 10px;
  min-height: 18px;
  background: rgba(var(--ink-rgb), 0.04);
  border: 0.5px solid rgba(var(--ink-rgb), 0.12);
  border-radius: 6px;
  outline: none;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.task-rewrite-text:hover {
  border-color: rgba(var(--ink-rgb), 0.2);
}
.task-rewrite-text:focus {
  border-color: rgba(46, 159, 98, 0.6);
  background: rgba(46, 159, 98, 0.04);
}
.task-rewrite-reason {
  margin-top: 8px;
  font-size: 12px;
  color: var(--tx3);
  font-style: italic;
  line-height: 1.5;
}
/* Move-task picker: strip OS chrome from the <select> so it reads as the
   same italic gray prose as the refinement card's reason line. The element
   stays a real <select> — keyboard nav, native picker, screen-reader role
   are all preserved; only the appearance changes. The ▾ caret is inlined
   as an SVG data URL so it renders against any theme background. */
.task-rewrite-reason select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0 14px 0 0;
  margin: 0;
  font: inherit;
  font-style: italic;
  color: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%23999' stroke-width='1.2' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right center;
}
.task-rewrite-reason select:focus {
  outline: none;
  box-shadow: 0 0 0 1px rgba(46, 159, 98, 0.6);
  border-radius: 2px;
}
/* Disabled action-buttons across the app: faded but still using the
   same palette, not the browser's default washed-out gray. Matches the
   .clarify-btn[disabled] treatment. */
.action-btn[disabled],
.action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.action-btn[disabled]:hover,
.action-btn:disabled:hover {
  background: var(--acc-bg);
  border-color: rgba(46, 159, 98, 0.35);
}
.action-btn.primary[disabled]:hover,
.action-btn.primary:disabled:hover {
  background: var(--btn-primary-bg);
  border-color: rgba(46, 159, 98, 0.55);
}

/* In-flight create-draft button — pairs with `.btn-spinner` to show
   the click is being processed. Opacity drop + wait cursor signal
   "busy"; the spinner provides motion so it doesn't read as a
   static disabled state. */
.action-btn.is-loading,
.action-btn.is-loading:hover {
  opacity: 0.7;
  cursor: wait;
}
.btn-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  animation: btn-spinner-rotate 0.7s linear infinite;
  margin-right: 4px;
  vertical-align: -1px;
}
@keyframes btn-spinner-rotate {
  to { transform: rotate(360deg); }
}

/* Notes — muted source material with inline editor --------------------- */
.original-note .original-note-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.original-note .original-note-header .task-analysis-heading {
  margin-bottom: 0;
}
.original-note .original-note-body {
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.original-note .original-note-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--tx3);
}
.original-note .original-note-meta .sep {
  margin: 0 6px;
  opacity: 0.5;
}
.original-note .original-note-url {
  margin-top: 4px;
  font-size: 11px;
}
.original-note .original-note-url a {
  color: var(--tx3);
  text-decoration: none;
  border-bottom: 0.5px solid var(--bd);
  word-break: break-all;
}
.original-note .original-note-url a:hover {
  color: var(--tx2);
}
.original-note .original-note-editor {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--tx);
  padding: 8px 10px;
  background: rgba(var(--ink-rgb), 0.04);
  border: 0.5px solid rgba(var(--ink-rgb), 0.12);
  border-radius: 6px;
  outline: none;
  resize: vertical;
}
.original-note .original-note-editor:hover {
  border-color: rgba(var(--ink-rgb), 0.2);
}
.original-note .original-note-editor:focus {
  border-color: rgba(46, 159, 98, 0.6);
  background: rgba(46, 159, 98, 0.04);
}
.original-note .original-note-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Footer row — `Clarifying questions` on the left, `dismiss task` on the
   right. */
.task-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 0.5px solid var(--bd);
}
.task-detail-footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-detail-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-clarify-block .task-clarify-q {
  margin-bottom: 8px;
}
.task-clarify-block .task-clarify-q label {
  display: block;
  font-size: 12px;
  color: var(--tx2);
  margin-bottom: 3px;
}
.task-clarify-block textarea.task-clarify-a {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--tx);
  resize: vertical;
}
.task-clarify-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.task-detail-status {
  color: var(--tx3);
  font-style: italic;
  font-size: 12px;
}

/* Proposed email draft on tasks reuses `.proposal-card.email`. The two
   metadata rows (Subject, To) sit above the body — same pattern as the
   email card, with To added since tasks render outbound drafts. The To
   row carries the divider + bottom spacing for the whole metadata block
   so subject+to read as a distinct header rather than the body's first
   paragraph. (Email-section card has no .proposal-email-to row.) */
.proposal-email-to {
  font-family: var(--font-main);
  font-size: 12px;
  color: rgba(var(--ink-rgb), 0.6);
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 10px;
}
.proposal-email-to strong {
  color: rgba(var(--ink-rgb), 0.8);
  font-weight: 500;
  margin-right: 6px;
}

.setting-toggle {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg3);
  cursor: pointer;
  border: 0.5px solid var(--bd);
  transition: background 0.15s, border-color 0.15s;
}

.setting-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--tx3);
  transition: left 0.15s, background 0.15s;
}

.setting-toggle.on {
  background: var(--acc-bg);
  border-color: rgba(46, 159, 98, 0.55);
}

.setting-toggle.on::after {
  left: 19px;
  background: var(--acc-tx);
}

/* Empty-state — centered icon + heading + subtext, used for "you are
   caught up" / "nothing in the archive" messages. No card chrome —
   floats on the canvas (the warm bg already provides separation). */
.empty-card {
  margin: 120px auto 0;
  max-width: 480px;
  text-align: center;
  padding: 0;
  background: transparent;
  border: 0;
}
.empty-card-icon {
  display: flex;
  justify-content: center;
  margin: 0 auto 22px;
  color: var(--acc-tx);
}
.empty-card-icon svg {
  display: block;
}
/* Front-page occluder on _compareCheckIcon: fills with the page bg so
   it cleanly occludes the back page in both light and dark themes. */
.empty-card-icon svg .occluder {
  fill: var(--bg);
}
.empty-card h2 {
  font-size: 22px;
  font-weight: 500;
  color: var(--tx);
  margin: 0;
  letter-spacing: -0.015em;
}
.empty-card p {
  margin: 10px auto 0;
  max-width: 380px;
  font-size: 13px;
  color: var(--tx3);
  line-height: 1.55;
}
/* Inline CTA in the empty state — only used where the empty state has
   one obvious next action (e.g. Compare's "Check for new pairs"). The
   subnav still carries the same action for users with active filters;
   this version is the primary call because there is nothing else to do
   on the page. Margin-top sits the button comfortably below the
   subtitle without making the card feel cramped. */
.empty-card-cta {
  margin: 20px auto 0;
  display: flex;
  justify-content: center;
}

/* Filter select picks up an accent tint when a non-empty value is selected
   so the user can see at a glance that the list is narrowed. */
.subnav-select.is-active {
  color: var(--acc-tx);
  background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%232E6B4A' stroke-width='1.4' d='M1 1l4 4 4-4'/></svg>");
}

/* Small secondary button used for Shuffle (and any future low-chrome
   actions next to a primary button). Matches Sync now's height. */
.btn-secondary.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary.btn-sm svg {
  flex-shrink: 0;
}
.shuffle-btn:disabled { opacity: 0.45; }

/* Toast (Compare/Pending Review notifications) */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(var(--ink-rgb), 0.9);
  color: var(--bg);
  font-family: var(--font-code);
  font-size: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 60vw;
}

/* =========================================================================
   Responsive — mobile design pass (FINDING-T9)

   The topbar at <720px collapses progressively. Two real breakpoints:

   720px (tablet / small laptop): hide pill labels, shrink padding.
     All status pills still show as icon-only. Tabs and Sync now
     stay full-size. Full Compose / All-accounts / Shuffle controls
     remain in the subnav.

   480px (phone): the topbar fits on ONE row by hiding the
     informational status pills entirely. Polling/Accounts/Last-sync
     are info-only; users on a phone don't need them in-frame.
     If the system is failing, the existing .sync-error banner
     surfaces it. Sync now compresses to icon-only. Shuffle and the
     All-accounts filter disappear (low-value on a phone — the user
     is scanning, not filtering).

   Touch targets sized to 44×44 on every interactive element below
   720px per WCAG AAA / Apple HIG.
   ========================================================================= */
@media (max-width: 720px) {
  .page-shell { padding: 1rem 1rem 3rem; }
  .detail-cards { grid-template-columns: 1fr; }
  .detail-panel { padding-left: 0; }
  .email-row { grid-template-columns: 1fr auto; }
  .email-row .acct-badge { grid-column: 1 / -1; margin-bottom: 4px; }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
  }
  .topbar .nav-tabs {
    gap: 6px;
    /* Allow tabs to scroll horizontally if they overflow the row —
       prevents Settings from getting clipped at 375px while keeping
       the tabs visible and tappable. The scroll edge is silent
       (no scrollbar chrome on mobile by default in iOS/Android). */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar .nav-tabs::-webkit-scrollbar { display: none; }
  .topbar .nav-tab {
    padding: 6px 10px;
    min-height: 44px;
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .topbar-status { gap: 8px; }
  .status-pill-text { display: none; }
  .status-pill {
    padding: 6px;
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
  }
  .avatar-trigger {
    min-width: 36px;
    min-height: 36px;
  }
  .compare-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .compare-rail.left, .compare-rail.right { display: none; }
  .subnav {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
  }
  .subnav-pill {
    min-height: 36px;
  }
}

/* Phone-narrow — the topbar fits on one row by dropping informational
   pills. Keeps the essential ones: tabs (navigation), Sync now
   (manual action), Avatar (account access). */
@media (max-width: 480px) {
  /* Drop the informational status pills — Polling/Accounts/Last-sync
     are "is it working?" signals that don't need pixels on a phone.
     Errors surface via the sync-error banner already. */
  .topbar-status .status-pill { display: none; }

  /* Sync now compresses to icon-only — saves ~80px. The icon still
     reads as "refresh / sync" and the button keeps its full hit area. */
  .topbar .btn-primary .sync-label { display: none; }
  .topbar .btn-primary {
    padding: 8px;
    min-width: 36px;
    min-height: 36px;
  }

  /* Tighter tab padding on phone-narrow so all 4 tabs fit without
     horizontal scroll (the scroll is still available as a fallback
     if a longer tab label gets added later). */
  .topbar .nav-tab {
    padding: 6px 6px;
    font-size: 13px;
  }
  .topbar .nav-tabs { gap: 2px; }

  /* Subnav: prioritize primary controls (filter pills + Compose).
     Drop low-value mobile controls (Shuffle, All-accounts filter)
     that users rarely reach for on a phone. */
  .subnav-actions .shuffle-btn { display: none; }
  .subnav-actions .subnav-select { display: none; }

  /* Page-shell padding tighter on phone */
  .page-shell { padding: 0.75rem 0.75rem 3rem; }
}

/* ============================================================================
   v5.0 — Investment memo card
   ============================================================================
   The card slots into the existing `.detail-cards` stack (same width / spacing
   as What's Happening + Worth Doing). A 4px left stripe communicates state
   at a glance: orange=running, green=done, coral=error, grey=race-discarded.
   The verdict pill is bigger than the worth-badge so the headline judgment
   is the dominant element when the memo lands. */
.memo-card {
  position: relative;
  padding-left: 16px;
}
.memo-card .memo-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
}
/* Memo state colors — tokenized so light/dark themes flip correctly.
   The stripe + matching text variant pair up: running=amber, done=acc,
   error=coral, race-discarded=neutral-gray. */
.memo-running .memo-stripe { background: var(--amber-tx); }
.memo-done    .memo-stripe { background: var(--acc); }
.memo-error   .memo-stripe { background: var(--coral-tx); }
.memo-race-discarded .memo-stripe { background: var(--tx3); }

.memo-running-text {
  color: var(--amber-tx);
  font-size: 13px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.memo-error-text {
  color: var(--coral-tx);
  font-size: 13px;
  margin-top: 4px;
  white-space: pre-wrap;
}
.memo-skip-text {
  color: var(--tx2);
  font-size: 13px;
  margin-top: 4px;
}

.memo-verdict-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.memo-verdict-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1;
}
/* Verdict color pairs use the same palette tokens as other status
   chips throughout the app so memo verdicts read as part of the same
   visual language. */
.memo-verdict-pass {
  background: var(--acc-bg);
  color: var(--acc-tx);
}
.memo-verdict-fail {
  background: var(--coral-bg);
  color: var(--coral-tx);
}
.memo-verdict-neutral {
  background: var(--bg3);
  color: var(--tx2);
}
.memo-delivered-chip {
  font-size: 11px;
  color: var(--tx2);
  letter-spacing: 0.3px;
}

.memo-numbers-row {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.memo-number {
  min-width: 96px;
}
.memo-number-label {
  font-size: 11px;
  color: var(--tx2);
  letter-spacing: 0.3px;
}
.memo-number-value {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.memo-downloads {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.memo-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  font-size: 13px;
  background: rgba(var(--ink-rgb), 0.02);
  transition: background 120ms ease;
}
.memo-download:hover { background: rgba(var(--ink-rgb), 0.05); }

.memo-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.action-btn.ghost {
  background: transparent;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  color: var(--tx2);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
}
.action-btn.ghost:hover { background: rgba(var(--ink-rgb), 0.04); }

/* Topbar memo chip — sits next to the existing status pills */
.memo-counter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-lg);
  background: rgba(46, 159, 98, 0.12);
  color: #2E6B4A;
  font-size: 12px;
  letter-spacing: 0.3px;
  cursor: pointer;
  user-select: none;
}
.memo-counter-chip:hover { filter: brightness(0.96); }
.memo-counter-chip.empty { display: none; }
.memo-counter-chip .memo-counter-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2E9F62;
  box-shadow: 0 0 0 0 rgba(46, 159, 98, 0.6);
  animation: memoPulse 1.6s ease-out infinite;
}
@keyframes memoPulse {
  0%   { box-shadow: 0 0 0 0   rgba(46, 159, 98, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(46, 159, 98, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(46, 159, 98, 0);   }
}

/* Memos sub-view (inventory list) */
.memos-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}
.memos-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid rgba(var(--ink-rgb), 0.08);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 120ms ease;
}
.memos-row:hover {
  border-color: rgba(var(--ink-rgb), 0.2);
}
.memos-row-pill {
  display: flex;
  align-items: flex-start;
}
.memos-row-subject {
  font-weight: 600;
  font-size: 14px;
}
.memos-row-sub {
  color: var(--tx2);
  font-size: 12px;
  margin-top: 2px;
}

/* ===========================================================================
   Settings view — centered max-width column of cards.
   Each section (Preferences, Setup, Skills) is its own card; rows put labels
   and controls in tight proximity inside the narrower container.
   Calendar access is a recessed sub-group (per-account permissions),
   and Skills' Upload destination uses the same sub-group treatment when on.
   =========================================================================== */
.settings-view {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-card {
  background: var(--bg);
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: 4px 24px 20px;
}
.settings-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 0 16px;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 16px;
}
.settings-card-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--acc-bg-soft);
  color: var(--acc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.settings-card-icon svg { width: 18px; height: 18px; }
.settings-card-heading {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.settings-card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--tx);
  line-height: 1.3;
}
.settings-card-subtitle {
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.4;
}
.settings-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}
.settings-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.settings-row-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--tx);
  line-height: 1.3;
}
.settings-row-sub {
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.4;
}
.settings-row-control { flex-shrink: 0; }
/* Stacked variant — label/sub on top, control (e.g. wide table) below.
   Same horizontal indent as .settings-row so siblings line up at the
   same level (e.g. Draft target and Calendar access as peers). */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}
/* ===========================================================================
   Settings collapsible — used by Calendar access + Task lists subsections
   inside the Account setup card.

   Native <details>/<summary> for free keyboard a11y. Custom chevron replaces
   the dated native triangle. The summary line shows status (counts +
   captured/disabled) so the operator doesn't have to expand to read state.
   A warning dot appears in the summary when the section needs attention
   (empty config, unassigned lists, zero calendars enabled).

   data-warn="true" on <details> drives the dot visibility — set by the
   render path when needed.
   =========================================================================== */
.settings-collapsible {
  border-top: 0.5px solid var(--bd);
  padding: 8px 0;
}
.settings-collapsible[open] {
  padding-bottom: 16px;
}
.settings-collapsible summary {
  list-style: none;       /* hide native marker (Firefox) */
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  user-select: none;
  border-radius: var(--radius-sm);
}
.settings-collapsible summary::-webkit-details-marker {
  display: none;          /* hide native marker (WebKit) */
}
.settings-collapsible summary:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}
.settings-collapsible-chevron {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--tx2);
  transition: transform 0.15s ease;
}
.settings-collapsible-chevron svg {
  width: 14px;
  height: 14px;
}
.settings-collapsible[open] .settings-collapsible-chevron {
  transform: rotate(90deg);
}
.settings-collapsible-heading {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 500;
  color: var(--tx);
}
.settings-collapsible-summary-text {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--tx2);
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.settings-collapsible-summary-text .count {
  font-variant-numeric: tabular-nums;
  color: var(--tx);
  font-weight: 500;
}
.settings-collapsible-summary-text .label {
  color: var(--tx2);
}
.settings-collapsible-summary-text .captured-value {
  color: var(--tx);
  font-weight: 500;
}
.settings-collapsible-summary-text .sep {
  color: var(--bd2);
  margin: 0 2px;
}
/* Warning dot: 8px round, shown when [data-warn="true"] on the <details>.
   Color uses the existing #b45309 from .admin-preflight-row.status.missing
   to keep the design system consistent without adding a new --warn token. */
.settings-collapsible-warn-dot {
  flex: 0 0 auto;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b45309;
  margin-right: 2px;
}
.settings-collapsible:not([data-warn="true"]) .settings-collapsible-warn-dot {
  display: none;
}
.settings-collapsible-body {
  padding: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Empty-state block — shown in expanded Task lists body when no roles are
   configured. Warmth + clear primary action, not an error banner. */
.settings-collapsible-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px 16px;
  background: var(--acc-bg-soft);
  border-radius: var(--radius-lg);
}
.settings-collapsible-empty-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--acc-bg);
  color: var(--acc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.settings-collapsible-empty-icon svg { width: 18px; height: 18px; }
.settings-collapsible-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tx);
}
.settings-collapsible-empty-sub {
  font-size: 13px;
  color: var(--tx2);
  max-width: 360px;
}
.settings-collapsible-empty-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
/* Task lists per-row layout — 3 columns (name, role select, save button)
   on desktop, stacked 2-line on mobile. cal-table follows the same
   stacked pattern in its own @media block below. */
.task-list-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 0.5px solid var(--bd);
}
.task-list-row:last-child { border-bottom: none; }
.task-list-row-name {
  font-size: 13px;
  color: var(--tx);
  min-width: 0;
}
.task-list-row-name .meta {
  display: block;
  font-size: 12px;
  color: var(--tx2);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-list-row-name .captured-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--acc);
  background: var(--acc-bg);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  vertical-align: middle;
}
.task-list-row-name .stale-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: #b45309;
  background: rgba(180, 83, 9, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  vertical-align: middle;
}
.task-list-row-captured-note {
  font-size: 12px;
  color: var(--tx2);
  font-style: italic;
}
.task-list-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.task-list-status-line {
  font-size: 12px;
  color: var(--tx2);
  margin-bottom: 4px;
}
.task-list-captured-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
  align-items: center;
  padding: 8px 0 12px;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 4px;
}
.task-list-captured-row .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--tx);
}
.task-list-captured-row .sub {
  font-size: 12px;
  color: var(--tx2);
  margin-top: 1px;
}
.task-list-button {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 6px;
  border: 0.5px solid var(--bd2);
  background: transparent;
  color: var(--tx);
  cursor: pointer;
  font-family: inherit;
}
.task-list-button:hover { background: var(--acc-bg-soft); }
.task-list-button:disabled { opacity: 0.5; cursor: wait; }
.task-list-button.primary {
  background: var(--acc);
  color: white;
  border-color: var(--acc);
}
.task-list-button.primary:hover { background: var(--acc-tx); }
.task-list-select {
  padding: 5px 8px;
  font-size: 13px;
  border-radius: 6px;
  border: 0.5px solid var(--bd2);
  background: transparent;
  color: var(--tx);
  font-family: inherit;
  width: 100%;
}
.task-list-select:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}

/* Visually-hidden utility (sr-only) — for screen-reader-only text like the
   "Setup needed" sibling of the warning dot. Standard pattern. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Mobile breakpoint — stack rows below 480px. Both cal-table and
   task-list-row need this; the existing cal-table is 4-col on desktop
   and would otherwise horizontal-scroll on phone. */
@media (max-width: 480px) {
  .task-list-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .task-list-row > .task-list-row-controls {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .task-list-captured-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .cal-table thead {
    display: none;       /* drop the header row in stacked mode */
  }
  .cal-table,
  .cal-table tbody,
  .cal-table tr,
  .cal-table td {
    display: block;
    width: 100%;
  }
  .cal-table tr {
    padding: 8px 0;
    border-bottom: 0.5px solid var(--bd);
  }
  .cal-table tr:last-child { border-bottom: none; }
  .cal-table td {
    padding: 2px 0;
  }
  .cal-table .cal-table-check {
    display: inline-block;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
  }
  .cal-table .cal-table-name {
    display: inline-block;
    width: auto;
    font-weight: 500;
    vertical-align: middle;
  }
  .cal-table .cal-table-account,
  .cal-table .cal-table-email {
    font-size: 12px;
    color: var(--tx2);
  }
}
/* Prompt-file cards — Memory + Judgement on /settings. Shared primitives
   for two cards that paste-and-save markdown prompt files. View/Edit
   pattern: in view mode the textarea reads as document content (no
   border, no input bg, transparent); in edit mode it gains the form
   chrome so you can type into it.

   data-mode=view  → "this is content; click Edit to change"
   data-mode=edit  → "you can type here now" */
.prompt-file-textarea {
  width: 100%;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: rgb(var(--ink-rgb));
  resize: vertical;
  box-sizing: border-box;
  margin-top: 4px;
}
.prompt-file-textarea[data-mode="view"] {
  background: transparent;
  border: 1px solid transparent;
  padding: 0;
  resize: none;
  cursor: default;
  opacity: 1;
}
.prompt-file-textarea[data-mode="view"]:disabled {
  /* Override the browser's default disabled greying — in view mode the
     content is real, just not editable. */
  color: rgb(var(--ink-rgb));
  opacity: 1;
}
.prompt-file-textarea[data-mode="edit"] {
  border: 1px solid rgba(var(--ink-rgb), 0.18);
  background: var(--bg);
}
.prompt-file-textarea[data-mode="edit"]:focus {
  outline: 2px solid var(--acc);
  outline-offset: -2px;
}
.prompt-file-textarea[data-mode="edit"]:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Card-header action button slot (Edit / Cancel + Save buttons). The
   header gets a third grid column on the right; the action area
   sits there. */
.settings-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.settings-card-heading {
  flex: 1 1 auto;
  min-width: 0;
}
.settings-card-action {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.prompt-file-card-action-btn {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(var(--ink-rgb), 0.2);
  background: transparent;
  color: rgb(var(--ink-rgb));
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.prompt-file-card-action-btn:hover:not(:disabled) {
  background: rgba(var(--ink-rgb), 0.05);
  border-color: rgba(var(--ink-rgb), 0.35);
}
.prompt-file-card-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.prompt-file-save {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--acc);
  background: var(--acc);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.prompt-file-save:hover:not(:disabled) {
  filter: brightness(0.92);
}
.prompt-file-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
[data-theme="dark"] .prompt-file-save {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-tx);
  border-color: var(--acc);
}

.prompt-file-status {
  font-size: 12px;
  color: rgba(var(--ink-rgb), 0.55);
  margin-top: 4px;
}

/* Lock-conflict banner (Judgement card; another tab is editing). */
.prompt-file-lock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(186, 117, 23, 0.12);
  color: rgba(var(--ink-rgb), 0.85);
  border: 1px solid rgba(186, 117, 23, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 13px;
}
.prompt-file-lock-banner-msg {
  flex: 1 1 auto;
}

/* Empty-state hint (Memory card, when memory-snapshot.md doesn't exist). */
.prompt-file-empty-hint {
  font-size: 12px;
  background: rgba(186, 117, 23, 0.12);
  color: rgba(var(--ink-rgb), 0.85);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
/* Nested account-permission group: recessed background, slight indent. */
.settings-subgroup {
  background: var(--bg2);
  border-radius: 10px;
  padding: 12px 14px;
}
.settings-subgroup-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 8px;
}
.settings-subgroup-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--tx);
}
.settings-subgroup-sub {
  font-size: 12px;
  color: var(--tx2);
  line-height: 1.4;
}
/* Calendar-access table: one row per configured calendar. Plain tabular
   layout — toggle | name | account | email. Account column makes the
   routing visible (e.g. "GoodRx (work)" with account=personal). */
.cal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.cal-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--tx2);
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--bd);
  background: var(--bg2);
}
.cal-table tbody td {
  font-size: 13px;
  color: var(--tx);
  padding: 10px;
  border-bottom: 0.5px solid var(--bd);
  vertical-align: middle;
}
.cal-table tbody tr:last-child td { border-bottom: 0; }
.cal-table .cal-table-check {
  width: 48px;
  padding-right: 4px;
}
.cal-table .cal-table-name {
  font-weight: 500;
  white-space: nowrap;
}
.cal-table .cal-table-account {
  color: var(--tx2);
  text-transform: capitalize;
  white-space: nowrap;
  width: 1%;
}
.cal-table .cal-table-email {
  font-size: 12px;
  word-break: break-all;
}
.cal-table .cal-table-email code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--tx);
}
.cal-table-empty {
  color: var(--tx2);
  text-align: center;
  font-style: italic;
  padding: 14px !important;
}
/* Drive picker inside the Skills sub-group: drop the original popover-style
   chrome since the sub-group already frames it. */
.settings-subgroup .menu-picker {
  width: 100%;
}
.settings-subgroup .menu-picker-value {
  width: 100%;
  justify-content: flex-start;
}
/* Analytics card — month-to-date Anthropic token cost. */
.analytics-headline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0 8px;
  border-bottom: 0.5px solid var(--bd);
  margin-bottom: 6px;
}
.analytics-total {
  font-size: 28px;
  font-weight: 600;
  color: var(--tx);
  letter-spacing: -0.02em;
}
.analytics-month {
  font-size: 13px;
  color: var(--tx2);
}
.analytics-model-cost {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--tx);
}
.analytics-prev {
  padding-top: 4px;
  font-variant-numeric: tabular-nums;
}
.analytics-footnote {
  font-size: 12px;
  color: var(--tx2);
  opacity: 0.85;
  line-height: 1.45;
}

/* ---------------------------------------------------------------------------
   v6.1 detail-panel rework — inverted-pyramid layout
   ---------------------------------------------------------------------------
   NEXT STEP at the top (raised + green accent), WORTH NOTING amber callout
   below it (conditional), demoted single-line WORTH DOING, and AGENT
   DIAGNOSTICS as a collapsed <details>. The new components share the
   existing token palette (acc-tx green, amber-bg/tx, coral-bg/tx, bg2/bg3,
   tx2/tx3, font-code) so nothing about the look-and-feel diverges.
   --------------------------------------------------------------------------- */

/* NEXT STEP card — the visual anchor. Raised treatment beyond
   .proposal-card.email: stronger green accent, deeper padding, soft
   shadow so the card pops above the conditional callout + memo + worth
   line below. */
.next-step-card {
  background: rgba(46, 159, 98, 0.045);
  border: 0.5px solid rgba(var(--ink-rgb), 0.1);
  border-left: 4px solid rgba(46, 159, 98, 0.9);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .next-step-card {
  background: rgba(46, 159, 98, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.next-step-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--acc-tx);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 6px;
}
.next-step-sentence {
  font-size: 15px;
  line-height: 1.4;
  color: var(--tx);
  margin-bottom: 12px;
  font-weight: 500;
}

/* Inset frames — the draft/task previews live inside NEXT STEP without
   their own .proposal-card chrome. Border colors mirror the existing
   .proposal-card.email / .proposal-card.task accents so the user keeps
   the green=email / amber=task association. */
.next-step-inset {
  background: rgba(var(--ink-rgb), 0.015);
  border: 0.5px solid rgba(var(--ink-rgb), 0.08);
  border-left-width: 2px;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.next-step-inset.email {
  border-left-color: rgba(46, 159, 98, 0.7);
}
.next-step-inset.task {
  border-left-color: rgba(186, 117, 23, 0.75);
}
[data-theme="dark"] .next-step-inset.task {
  border-left-color: rgba(232, 185, 120, 0.75);
}
.next-step-inset.dim {
  opacity: 0.65;
}

/* Unified action row — bottom of the NEXT STEP card. Wraps if the
   button count grows. Buttons reuse .action-btn primary/secondary/tan
   so the visual language matches the rest of the inbox. */
.next-step-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* WORTH NOTING — conditional amber callout. Renders only when the
   model emitted {"suppressed": false}. Caps label header + body text
   so it parallels NEXT STEP / AGENT DIAGNOSTICS visual treatment. */
.callout-worth-noting {
  background: var(--amber-bg);
  border-left: 4px solid rgba(186, 117, 23, 0.7);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
[data-theme="dark"] .callout-worth-noting {
  border-left-color: rgba(232, 185, 120, 0.75);
}
.callout-worth-noting-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--amber-tx);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 4px;
}
.callout-worth-noting-text {
  color: var(--tx);
  font-size: 14px;
  line-height: 1.45;
}
/* BLOCKER callout — v6.1 task-detail variant of the worth-noting callout
   in red. Used by renderTaskBlockerCallout for the red callout above the
   NEXT STEP card when a blocker is present (design D2 — pre-empts
   action affordances visually). */
.callout-blocker {
  background: var(--coral-bg);
  border-left: 4px solid rgba(216, 90, 48, 0.7);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
[data-theme="dark"] .callout-blocker {
  border-left-color: rgba(242, 165, 137, 0.75);
}
.callout-blocker-label {
  font-family: var(--font-code);
  font-size: 10px;
  color: var(--coral-tx);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 4px;
}
.callout-blocker-text {
  color: var(--tx);
  font-size: 14px;
  line-height: 1.45;
}
/* TASK HANDLING caption — single-line quiet reason below the proposals
   stack. Carries the WORTH REASON prose without the verb (the status chip
   on the NEXT STEP card already names the verb). Design D5. */
.task-handling-caption {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin: 8px 2px 12px;
  line-height: 1.4;
}
/* ORIGINAL NOTE collapse wrapper — wraps renderOriginalNoteBlock in a
   <details> with a summary line "P<priority> · <list>". Auto-expanded
   when a proposal card is rendered (design D6); collapsed otherwise. */
.task-original-note-collapse {
  margin: 4px 0 8px;
  border-top: 0.5px solid rgba(var(--ink-rgb), 0.08);
  padding-top: 10px;
}
.task-original-note-collapse summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--muted);
}
.task-original-note-collapse summary::-webkit-details-marker { display: none; }
.task-original-note-collapse summary::before {
  content: "▸";
  font-size: 9px;
  margin-right: 4px;
  transition: transform 120ms;
}
.task-original-note-collapse[open] summary::before {
  transform: rotate(90deg);
}
.task-original-note-collapse summary:hover { color: var(--tx); }
.task-original-note-label {
  font-family: var(--font-code);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.task-original-note-summary {
  font-size: 12px;
  font-family: var(--font-code);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.task-original-note-body {
  margin-top: 6px;
}
/* RESEARCH collapse wrapper — same pattern as original note. Collapsed by
   default when results exist; hidden entirely when no research has run. */
.task-research-collapse {
  margin: 4px 0 8px;
  border-top: 0.5px solid rgba(var(--ink-rgb), 0.08);
  padding-top: 10px;
}
.task-research-collapse summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--muted);
}
.task-research-collapse summary::-webkit-details-marker { display: none; }
.task-research-collapse summary::before {
  content: "▸";
  font-size: 9px;
  margin-right: 4px;
  transition: transform 120ms;
}
.task-research-collapse[open] summary::before {
  transform: rotate(90deg);
}
.task-research-collapse summary:hover { color: var(--tx); }
.task-research-label {
  font-family: var(--font-code);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.task-research-body {
  margin-top: 6px;
}
/* Compact modifier — reduces vertical padding on the NEXT STEP card when
   the task title is short (≤40 chars), so a 3-word verb-phrase doesn't
   feel ceremonial. Design D10. */
.next-step-card.compact {
  padding-top: 10px;
  padding-bottom: 10px;
}
.next-step-card.compact .next-step-sentence {
  margin-top: 4px;
  margin-bottom: 2px;
}
/* analysis-failed status row variant — red text instead of muted gray. */
.task-detail-status-error {
  color: var(--coral-tx);
}
/* AGENT DIAGNOSTICS — collapsed <details> at the bottom of the panel.
   Quiet, secondary type. Independent of styles-compare.css's existing
   <details> rules (those are gated to .incoming-block / .inline-diff
   ancestors). */
.agent-diagnostics {
  margin-top: 4px;
  margin-bottom: 8px;
  border-top: 0.5px solid rgba(var(--ink-rgb), 0.08);
  padding-top: 10px;
}
.agent-diagnostics summary {
  cursor: pointer;
  font-family: var(--font-code);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tx3);
  list-style: none;
  padding: 2px 0;
}
.agent-diagnostics summary::-webkit-details-marker { display: none; }
.agent-diagnostics summary::before {
  content: "▸  ";
  color: var(--tx3);
}
.agent-diagnostics[open] summary::before {
  content: "▾  ";
}
.agent-diagnostics summary:hover {
  color: var(--tx2);
}
.agent-diagnostics-body {
  padding-top: 8px;
}
.diagnostics-prose {
  color: var(--tx2);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.diagnostics-meta {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx3);
  margin-bottom: 8px;
}
.diagnostics-meta code {
  background: rgba(var(--ink-rgb), 0.05);
  padding: 0 4px;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

/* Panel-level footer — sits outside the AGENT DIAGNOSTICS <details> so
   Clarify + the regenerated badge stay visible even when diagnostics
   is collapsed. */
.detail-panel-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ---------------------------------------------------------------------------
   v6.2 status chips + email-handling line + attachments + collapsed body
   --------------------------------------------------------------------------- */

/* Status chips at the top of the NEXT STEP card. Tight, monospace,
   color-coded by category so the user sees the recommendation at a
   glance: green = action available, neutral = no action, amber/coral =
   tentative judgment. */
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.status-chip {
  display: inline-block;
  font-family: var(--font-code);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.status-chip.chip-action {
  background: rgba(46, 159, 98, 0.18);
  color: var(--acc-tx);
}
.status-chip.chip-neutral {
  background: var(--bg3);
  color: var(--tx2);
}
.status-chip.chip-confident {
  background: rgba(46, 159, 98, 0.10);
  color: var(--acc-tx);
}
.status-chip.chip-tentative {
  background: var(--amber-bg);
  color: var(--amber-tx);
}
.status-chip.chip-uncertain {
  background: var(--coral-bg);
  color: var(--coral-tx);
}

/* Compact task-metadata sub-line — replaces the redundant proposal-card
   task row inside NEXT STEP. Code typography keeps it visually quiet
   while preserving context · due · person info. */
.next-step-meta {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx2);
  margin-bottom: 12px;
  margin-top: -4px;
}
.next-step-card .next-step-sentence + .next-step-meta {
  margin-top: -8px;
}

/* EMAIL HANDLING line — derived disposition + agent reason. Single
   plain-English row that replaces the colored-dot WORTH DOING. */
.email-handling-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.45;
  flex-wrap: wrap;
}
.email-handling-label {
  font-family: var(--font-code);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tx3);
  flex-shrink: 0;
}
.email-handling-value {
  color: var(--tx);
}

/* Attachments — compact one-line summary + collapsible chip list.
   Failed-attachment branch (.has-failed) draws an amber accent so
   silent conversion failures don't hide. */
.attachments-row {
  margin-bottom: 12px;
  border-top: 0.5px solid rgba(var(--ink-rgb), 0.08);
  border-bottom: 0.5px solid rgba(var(--ink-rgb), 0.08);
  padding: 6px 0;
}
.attachments-row.has-failed {
  border-color: rgba(186, 117, 23, 0.4);
}
.attachments-row summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 2px 0;
}
.attachments-row summary::-webkit-details-marker { display: none; }
.attachments-row summary::before {
  content: "▸  ";
  color: var(--tx3);
}
.attachments-row[open] summary::before {
  content: "▾  ";
}
.attachments-row-label {
  font-family: var(--font-code);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tx3);
}
.attachments-row-summary {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx2);
}
.attachments-row.has-failed .attachments-row-summary {
  color: var(--amber-tx);
}
.attachments-row-body {
  padding-top: 8px;
}

/* Collapsed email body — collapsed by default so the action is the
   top focus. Summary shows sender + subject + preview snippet so
   the user can decide whether to expand. */
.email-body-collapse {
  margin-bottom: 12px;
  border-top: 0.5px solid rgba(var(--ink-rgb), 0.08);
  border-bottom: 0.5px solid rgba(var(--ink-rgb), 0.08);
  padding: 6px 0;
}
.email-body-collapse summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  flex-wrap: wrap;
}
.email-body-collapse summary::-webkit-details-marker { display: none; }
.email-body-collapse summary::before {
  content: "▸  ";
  color: var(--tx3);
}
.email-body-collapse[open] summary::before {
  content: "▾  ";
}
.email-body-collapse-label {
  font-family: var(--font-code);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tx3);
  flex-shrink: 0;
}
.email-body-collapse-subject {
  font-size: 13px;
  color: var(--tx);
  font-weight: 500;
}
.email-body-collapse-preview {
  font-size: 12px;
  color: var(--tx2);
  font-style: italic;
}
.email-body-collapse-body {
  padding-top: 10px;
}

/* AGENT DIAGNOSTICS summary line — when collapsed, surfaces the
   disposition + confidence + attachment health in monospace. */
.agent-diagnostics summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.agent-diagnostics-label {
  font-family: var(--font-code);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tx3);
}
.agent-diagnostics-summary {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--tx2);
}

/* =========================================================================
   Compose modal — user-prompted email creation.

   Backdrop + centered dialog. Reuses --acc / --bg / --bd tokens so the
   modal tracks theme flips automatically. Width is bounded so it works
   in narrow viewports.
   ========================================================================= */
.compose-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 2000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 16px;
  overflow-y: auto;
}
.compose-backdrop.open { display: flex; }
.compose-modal {
  background: var(--bg);
  border: 0.5px solid var(--bd2);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  width: min(620px, 100%);
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compose-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--tx);
}
.compose-close {
  background: transparent;
  border: 0;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--tx2);
  transition: background 0.12s, color 0.12s;
}
.compose-close:hover { background: var(--bg3); color: var(--tx); }
.compose-section { display: flex; flex-direction: column; gap: 6px; }
.compose-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tx3);
}
.compose-input,
.compose-select,
.compose-textarea {
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--tx);
  background: var(--bg);
  border: 0.5px solid var(--bd2);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  box-sizing: border-box;
  width: 100%;
}
.compose-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--font-main);
}
.compose-textarea.tall { min-height: 220px; }
/* Fade non-body sections during regenerate so attention falls on the
   body overlay (where the actual work is happening). */
.compose-section.is-regenerating-section { opacity: 0.5; transition: opacity 0.2s; }
/* Body wrap holds the textarea + the overlay above it. */
.compose-body-wrap { position: relative; }
.compose-textarea.is-regenerating { opacity: 0.35; }
.compose-body-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--ink-rgb), 0.03);
  border-radius: var(--radius-md);
  pointer-events: none;
}
.compose-body-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.compose-body-overlay-msg {
  font-size: 14px;
  font-weight: 500;
  color: var(--tx);
}
.compose-body-overlay-sub {
  font-size: 12px;
  color: var(--tx3);
}
.compose-spinner-lg {
  width: 22px;
  height: 22px;
  border-width: 2.5px;
  color: var(--acc-tx);
}
/* Top-of-modal banner with the same message in case the overlay scrolls
   off-screen on smaller viewports. */
.compose-regen-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--acc-bg-soft);
  border: 0.5px solid var(--acc-bg);
  color: var(--acc-tx);
  font-size: 13px;
  line-height: 1.4;
}
.compose-regen-sub {
  color: var(--tx3);
  font-weight: 400;
}
/* Make the prompt placeholder visibly disposable: italic + fainter so
   it doesn't read as real content the user has to delete deliberately. */
.compose-textarea.is-prompt { min-height: 96px; }
.compose-textarea.is-prompt::placeholder,
.compose-textarea.is-whynow::placeholder {
  font-style: italic;
  color: var(--tx3);
  opacity: 0.75;
  white-space: pre;
}
.compose-textarea.is-whynow { min-height: 56px; }
.compose-label-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--tx3);
}
.compose-input:focus,
.compose-select:focus,
.compose-textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 2px var(--acc-bg);
}
.compose-hint {
  font-size: 12px;
  color: var(--tx3);
  line-height: 1.4;
}
.compose-banner {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  line-height: 1.45;
}
.compose-banner.error {
  background: rgba(216, 90, 48, 0.16);
  color: #a63a17;
  border: 0.5px solid rgba(216, 90, 48, 0.3);
}
.compose-banner.warn {
  background: rgba(186, 117, 23, 0.16);
  color: #8a5f10;
  border: 0.5px solid rgba(186, 117, 23, 0.3);
}
[data-theme="dark"] .compose-banner.error { color: #f9a386; }
[data-theme="dark"] .compose-banner.warn { color: #e8b95c; }
.compose-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}
.compose-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: compose-spin 0.7s linear infinite;
}
@keyframes compose-spin { to { transform: rotate(360deg); } }
.compose-alts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}
.compose-alts-label {
  font-size: 11px;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.compose-chip {
  font-family: var(--font-main);
  font-size: 12px;
  color: var(--tx2);
  background: var(--bg3);
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.compose-chip:hover:not(:disabled) {
  background: var(--acc-bg);
  color: var(--acc-tx);
  border-color: var(--acc);
}
.compose-pushed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 0 6px;
  text-align: center;
}
.compose-pushed-check {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--acc-bg);
  color: var(--acc-tx);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.compose-link {
  color: var(--acc-tx);
  font-weight: 500;
  text-decoration: none;
}
.compose-link:hover { text-decoration: underline; }
.compose-pushed-id { font-size: 13px; color: var(--tx2); }
.compose-pushed-id code {
  font-family: var(--font-code);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* To-field autocomplete dropdown. Positioned beneath the input via a
   wrapper so the rest of the form layout stays flow-based. */
.compose-to-wrap { position: relative; }
.compose-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 0.5px solid var(--bd2);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 2100;
  max-height: 260px;
  overflow-y: auto;
  display: none;
  padding: 4px;
}
.compose-dropdown.open { display: block; }
.compose-dropdown-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--tx);
  line-height: 1.3;
}
.compose-dropdown-item:hover,
.compose-dropdown-item.active {
  background: var(--acc-bg);
  color: var(--acc-tx);
}
.compose-dropdown-name {
  font-weight: 500;
  flex-shrink: 0;
}
.compose-dropdown-email {
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--tx3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.compose-dropdown-item.active .compose-dropdown-email {
  color: var(--acc-tx);
  opacity: 0.85;
}
.compose-dropdown-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--tx3);
  font-style: italic;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------------
 * On-demand task research panel — surfaces entity resolution, research
 * notes, concrete proposals, and phone-lookup results.
 *
 * Rendered between proposed-actions and the footer when state.taskResearch
 * has a result for this task key. Read-only in v1: the UI shows the
 * data; v1.1 adds interactive entity chip swaps + "use this proposal"
 * actions.
 * --------------------------------------------------------------------------- */
.task-research-panel {
  margin-top: 12px;
  padding: 12px;
  border: 0.5px solid var(--bd);
  border-radius: 6px;
  background: var(--bg-soft, var(--bg2, #f8f7f4));
  font-size: 13px;
}
.task-research-error {
  border-color: #e0a8a8;
  background: #fdf2f2;
}
.task-research-section {
  margin-bottom: 12px;
}
.task-research-section:last-child {
  margin-bottom: 0;
}
.task-research-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tx3);
  margin-bottom: 6px;
}
.task-research-notes {
  line-height: 1.4;
  color: var(--tx);
}
.task-research-entities,
.task-research-proposals {
  margin: 0;
  padding-left: 18px;
}
.task-research-entity {
  margin-bottom: 6px;
  line-height: 1.4;
}
.task-research-entity-name {
  font-weight: 600;
}
.task-research-entity-resolved {
  color: var(--tx2);
}
.task-research-kind {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: var(--radius-md);
  background: var(--bd);
  color: var(--tx2);
  text-transform: lowercase;
}
.task-research-confidence {
  display: inline-block;
  font-size: 11px;
  margin-left: 4px;
  color: var(--tx3);
  font-family: var(--font-code);
}
.task-research-phones {
  margin-top: 4px;
  font-size: 12px;
}
.task-research-phone {
  font-family: var(--font-code);
  color: var(--acc-tx, #0066cc);
  text-decoration: none;
  font-weight: 500;
}
.task-research-phone:hover {
  text-decoration: underline;
}
.task-research-phone-provenance {
  font-size: 11px;
  color: var(--tx3);
  font-style: italic;
}
.task-research-alts {
  margin-top: 4px;
  font-size: 11px;
  color: var(--tx3);
}
.task-research-alt {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 4px;
  border: 0.5px solid var(--bd);
  border-radius: var(--radius-sm);
}
.task-research-proposal {
  margin-bottom: 8px;
}
.task-research-proposal:last-child {
  margin-bottom: 0;
}
.task-research-proposal-title {
  margin-bottom: 2px;
}
.task-research-price {
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--tx2);
  font-weight: normal;
  margin-left: 4px;
}
.task-research-proposal-rationale {
  font-size: 12px;
  color: var(--tx2);
  line-height: 1.4;
}
/* Research clarify prompt — the analyzer is asking for more context.
   Amber styling (caution / needs input) is the right semantic, not the
   green accent that was originally used. The hardcoded #d4a017 fallback
   on var(--acc-tx, #d4a017) reveals the design intent was amber, but
   --acc-tx is Sendel Moss green so it rendered as green border on
   amber bg — visually mismatched. Now fully amber via tokens. */
.task-research-clarify {
  padding: 8px 10px;
  border-left: 3px solid var(--amber-tx);
  background: var(--amber-bg);
  border-radius: var(--radius-sm);
}

/* =========================================================================
   Accessibility — skip link + reduced-motion handling
   ========================================================================= */

/* Skip link: hidden until keyboard focus, then slides into view at the top
   so users can jump past the topbar+subnav to the main content. Standard
   "visually hidden until focused" pattern with explicit, visible focus
   styling (large enough to read, in the brand accent). */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--acc);
  color: #fff;
  text-decoration: none;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transform: translateY(-150%);
  transition: transform 120ms ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* Respect OS-level reduced-motion preference. Users with vestibular
   disorders, motion sensitivity, or low-spec hardware set this — when on,
   we kill every animation/transition rather than asking each rule to
   special-case it. The 0.01ms (not 0) preserves Promise-based animation
   chains that wait for transitionend events. */
@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;
  }
}

/* Catch-all focus ring for keyboard users.

   Previously only a handful of components (settings switches, menu
   segment buttons, the task-list select) had :focus-visible rules; the
   ~100+ other interactive elements fell through to the browser default
   (which Chrome 122+ shows as a thin black ring — but only sometimes,
   depending on whether the click also lit it up). Keyboard users
   tab-navigating the app had to guess where focus was.

   This rule fires only on keyboard focus (not pointer click) so it
   doesn't add noise for mouse users. Component-specific :focus-visible
   rules win on specificity, so existing styling is preserved. Targets
   the same set of selectors as the implicit a11y tree:
   button, a, input/select/textarea, contenteditable, and ARIA-typed
   interactive roles. */
:where(
  button,
  a,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"]),
  [role="button"],
  [role="link"],
  [role="switch"],
  [role="checkbox"],
  [role="radio"],
  [role="tab"],
  [role="menuitem"],
  [role="option"]
):focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
