/* run.css — App Runtime SPA (Design 042 §5.5, the generic CRUD app).
 *
 * Theme tokens ONLY (AI_CONTEXT rule 2 / Prime Directive #7): every colour comes
 * from a --color-* token so the surface works in light AND dark. The two themes are
 * token sets on body.theme-light / body.theme-dark; run.js toggles the class and
 * respects prefers-color-scheme on first load. Token NAMES mirror the site + the
 * App Builder so a tenant's app reads as part of the same product. No hard-coded
 * colours, no per-app CSS — one renderer over the schema. */

/* Design 155 — a smooth cross-document CROSS-FADE between the home and an app (and app↔app) instead
   of the white page-blank of a full navigation. Progressive: browsers without cross-document view
   transitions (Safari/Firefox today) simply navigate as before — zero regression, no JS. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

/* Design 156 P2 (iter 2) — when hosted in the HOME shell, the app body fills the space BELOW the ONE
   persistent header (.hub-top). In app mode the body becomes a flex column [ header | app ] and the
   home's own <main> is hidden — so the header stays put and only the content region swaps (no blank).
   run.css is ENABLED only while an app shows, so these never touch the home. Standalone /apps/run/<id>
   has no #ar-runtime and no .suite-app-mode — unaffected. */
#ar-runtime { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--color-bg); }
#ar-runtime[hidden] { display: none; }
body.suite-app-mode { overflow: hidden; display: flex; flex-direction: column; min-height: 100dvh; }
body.suite-app-mode > main { display: none; }                    /* hide the home content region */
body.suite-app-mode .hub-top { flex: 0 0 auto; }                 /* header keeps its intrinsic height */
/* Header re-labels for app mode: reveal the app context (← Apps · [App ▾] · Customize), hide the home
   brand + the home theme toggle (the app's own toggle drives the runtime theme). */
body.suite-app-mode .hub-app-ctx { display: inline-flex; align-items: center; }
body.suite-app-mode .ar-brand.hub-app-ctx { display: flex; }
body.suite-app-mode #hubBrand, body.suite-app-mode #tenantLabel, body.suite-app-mode #planChip { display: none !important; }
body.suite-app-mode #themeToggle { display: none; }

:root {
  --radius: 10px;
  --radius-sm: 7px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);

  /* ── Design 057 §4 — Gen-Z/Alpha page-widget aesthetic tokens. ──────────────
     PLAIN CSS VARS, not theme-controlled. run.css owns an independent token set,
     separate from the website's styles.css ↔ themeVars (VAR_MAP) ↔ themeDefaults
     parity loop (check-renderer-sync only parses styles.css), so defining these
     here triggers ZERO theme-parity work.
     The STRUCTURAL tokens (radius/space/type/motion) are theme-agnostic and live
     here. The accent-derived tokens (--accent-grad/--surface-glow/--ring) are
     defined per-theme on body.theme-light / body.theme-dark below: a custom
     property's inner var() resolves against the element it is DECLARED on, and
     --color-accent/--color-text live on the theme class (not :root), so these
     must be declared there to pick up the live theme palette. Every accent value
     is derived via color-mix() from the theme tokens, so a tenant's Design-019
     theme re-skins the whole aesthetic for free — no hard-coded colour (PD #7). */
  --radius-lg:    18px;     /* soft squircle surfaces */
  --radius-pill:  999px;
  --space-w:      clamp(14px, 2.4vw, 22px);              /* fluid widget padding */
  --type-display: clamp(28px, 4.5vw, 44px);             /* hero number scale */
  --motion-fast:  140ms cubic-bezier(.2, .7, .2, 1);

  /* Design 104 Phase 1 — a space scale shared with the hub's vocabulary so the runtime
     workhorse surfaces (list/detail/form/board) rhythm exactly like the suite chrome. */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 22px; --space-6: 32px;
}

/* Accent-derived aesthetic tokens — declared per theme so their inner
   var(--color-accent)/var(--color-text) resolve against the active palette.
   The color-mix recipe is identical in both; only the inputs differ. */
body.theme-light, body.theme-dark {
  --accent-grad:  linear-gradient(135deg, var(--color-accent),
                    color-mix(in srgb, var(--color-accent) 58%, #a855f7));
  --surface-glow: 0 1px 2px color-mix(in srgb, var(--color-text) 6%, transparent),
                  0 8px 24px color-mix(in srgb, var(--color-accent) 14%, transparent);
  --ring:         0 0 0 3px color-mix(in srgb, var(--color-accent) 35%, transparent);

  /* Design 104 Phase 1 — a layered depth set mirroring the hub (--shadow-sm/-md/-lg).
     Derived from --color-text via color-mix so it flips per theme (a dark surface needs
     a deeper, lower-alpha shadow). The legacy flat --shadow stays as a fallback. */
  --shadow-sm: 0 1px 2px color-mix(in srgb, var(--color-text) 6%, transparent);
  --shadow-md: 0 1px 2px color-mix(in srgb, var(--color-text) 6%, transparent),
               0 6px 18px color-mix(in srgb, var(--color-text) 7%, transparent);
  --shadow-lg: 0 8px 30px color-mix(in srgb, var(--color-text) 12%, transparent);
}

/* Design 102 — the runtime palette is ALIGNED to the App Suite hub (apps/index.html) so an app
   matches the suite chrome exactly. Core tokens (bg/surface/border/text/text-muted/accent) mirror
   the hub's light + dark values; the runtime-only shades (surface-alt/hover, border-subtle,
   accent-hover/subtle, red/green) are derived to stay consistent. */
body.theme-light {
  --color-bg:            #f5f6f9; /* hub */
  --color-surface:       #ffffff; /* hub */
  --color-surface-alt:   #f0f2f6; /* hub --color-surface-2 */
  --color-surface-hover: #e9ecf2;
  --color-border:        #e2e5ec; /* hub */
  --color-border-subtle: #eef0f4;
  --color-text:          #1a1d24; /* hub */
  --color-text-muted:    #5b6472; /* hub */
  --color-text-on-accent:#ffffff;
  --color-accent:        #6366f1; /* hub */
  --color-accent-hover:  #4f46e5;
  --color-accent-subtle: #eef2ff;
  --color-red:           #dc2626;
  --color-red-subtle:    #fef2f2;
  --color-green:         #16a34a;
}

body.theme-dark {
  --color-bg:            #0b0d12; /* hub */
  --color-surface:       #14171f; /* hub */
  --color-surface-alt:   #1b1f29; /* hub --color-surface-2 */
  --color-surface-hover: #232836;
  --color-border:        #2a2f3a; /* hub */
  --color-border-subtle: #20242e;
  --color-text:          #e7e9ee; /* hub */
  --color-text-muted:    #9aa1ad; /* hub */
  --color-text-on-accent:#ffffff;
  --color-accent:        #6366f1; /* hub (was #818cf8 — now matches the suite accent) */
  --color-accent-hover:  #818cf8;
  --color-accent-subtle: #1e2236;
  --color-red:           #f87171;
  --color-red-subtle:    #2a1a1c;
  --color-green:         #4ade80;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }

/* ── top bar ─────────────────────────────────────────────────────────────── */
.ar-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 30;
}
.ar-brand { display: flex; align-items: center; gap: 10px; }
/* persistent "back to your apps" link — token-styled, before the logo */
.ar-back {
  display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--color-text-muted);
  padding: 4px 8px; border-radius: var(--radius-sm); margin-right: 2px;
}
.ar-back:hover { color: var(--color-text); background: var(--color-surface-hover); }
/* Design 104 §7.4 — on desktop the suite rail's ⌂ is the back-to-suite affordance, so the
   header's "← Apps" link is redundant chrome. Hide it ONLY when the rail is present (degrade-
   safe: no rail → the link stays as the sole way home). It returns on mobile (≤640px) below,
   where the rail is the bottom bar and the header has room. */
body.has-suite-rail .ar-back { display: none; }
.ar-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--color-accent); color: var(--color-text-on-accent);
  font-weight: 700; font-size: 15px;
}
.ar-logo svg { width: 18px; height: 18px; }
.ar-title { font-weight: 600; }
.ar-top-right { display: flex; align-items: center; gap: 12px; }
/* mobile menu toggle — hidden on desktop, shown ≤720px to open the nav drawer (mobile pass) */
.ar-nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-right: 2px; padding: 0;
  font-size: 20px; line-height: 1; cursor: pointer;
  background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  color: var(--color-text);
}
.ar-nav-toggle:hover { background: var(--color-surface-hover); }

/* ── shell: nav + main ───────────────────────────────────────────────────── */
.ar-shell { display: flex; flex: 1; min-height: 0; }
.ar-nav {
  width: 220px; flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 14px 10px; overflow-y: auto;
}
.ar-nav-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted); padding: 4px 10px 8px; font-weight: 600;
}
.ar-nav-item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--color-text); font-size: 14px; font-weight: 500;
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.ar-nav-item:hover { background: var(--color-surface-hover); }
.ar-nav-item.is-active { background: var(--color-accent-subtle); color: var(--color-accent); }
.ar-nav-item:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-nav-item-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Design 104 §4.8 — a small leading monogram (no per-model icon field yet) so the nav reads as
   more than a text wall; the active item tints its monogram to the accent. */
.ar-nav-ic {
  flex: none; width: 22px; height: 22px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
  background: var(--color-surface-hover); color: var(--color-text-muted);
}
.ar-nav-item.is-active .ar-nav-ic { background: var(--color-accent); color: var(--color-text-on-accent); }
/* Design 123 — a model's typed views (Calendar, Board, …) listed as indented sub-items under it.
   Slightly inset + lighter so they read as children of the model above, not peers. */
.ar-nav-subitem { padding-left: 22px; font-weight: 450; }
.ar-nav-subitem .ar-nav-ic { width: 18px; height: 18px; }

.ar-main { flex: 1; min-width: 0; padding: 22px 26px; overflow-y: auto; }
/* Design 130 — premium read-only PREVIEW: a sticky banner + hidden write affordances + an upgrade gate. */
.ar-preview-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--color-accent-subtle); border-bottom: 1px solid var(--color-border); font-size: 13px; }
.ar-preview-tag { font-weight: 700; color: var(--color-accent); white-space: nowrap; }
.ar-preview-msg { color: var(--color-text); flex: 1; min-width: 120px; }
.ar-preview-cta { margin-left: auto; }
body.is-preview .ar-head .ar-btn,
body.is-preview .ar-row-edit,
body.is-preview .aia-trigger,
body.is-preview #ar-customize { display: none !important; }
body.is-preview .ar-cal-cell:not(.is-empty) { cursor: default; }
.ar-preview-gate { text-align: center; max-width: 520px; margin: 48px auto; }
.ar-preview-gate-star { font-size: 40px; line-height: 1; color: var(--color-accent); margin-bottom: 10px; }

/* ── headings + buttons ──────────────────────────────────────────────────── */
.ar-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap;
}
.ar-h1 { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
/* Design 104 §4.1.3 — a confident display title for the single-record surfaces
   (detail/form). A collection title (list) stays at 20px — it shouldn't shout. */
.ar-h1--display { font-size: clamp(22px, 2.6vw, 28px); }
.ar-sub { color: var(--color-text-muted); font-size: 13px; }

.ar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  background: var(--color-accent); color: var(--color-text-on-accent);
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.ar-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-btn:hover { background: var(--color-accent-hover); }
.ar-btn-ghost { background: none; color: var(--color-text); border-color: var(--color-border); }
.ar-btn-ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }
.ar-btn-danger { background: none; color: var(--color-red); border-color: var(--color-border); }
.ar-btn-danger:hover { background: var(--color-red-subtle); }
.ar-btn-sm { padding: 5px 10px; font-size: 13px; }

/* ── search/filter bar ───────────────────────────────────────────────────── */
.ar-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.ar-search {
  flex: 1; min-width: 180px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); font-family: inherit; font-size: 14px;
}
.ar-search::placeholder { color: var(--color-text-muted); }

/* ── table (list view) ───────────────────────────────────────────────────── */
.ar-table-wrap {
  background: var(--color-surface); border: 1px solid var(--color-border);
  /* overflow-x:auto (was hidden) so a wide table — especially a RELATED list inside the
     narrower detail aside — SCROLLS horizontally instead of being clipped/cut off. */
  border-radius: var(--radius-lg); overflow-x: auto; box-shadow: var(--shadow-sm);
}
table.ar-table { width: 100%; border-collapse: collapse; }
/* Design 104 §4.2.3 — Attio/Linear row rhythm (~33px) via the space scale. */
.ar-table th, .ar-table td {
  text-align: left; padding: var(--space-2) var(--space-3); font-size: 14px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.ar-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--color-text-muted); font-weight: 600;
  background: var(--color-surface-alt);
  position: sticky; top: 0; z-index: 1;
}
.ar-table tbody tr { cursor: pointer; transition: background var(--motion-fast); }
.ar-table tbody tr:hover { background: var(--color-surface-hover); }
.ar-table tbody tr:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-table tbody tr:last-child td { border-bottom: none; }

/* Design 104 §4.2 — typed cell treatments (shared by the table + the kanban card). */
.ar-cell-bool { color: var(--color-text-muted); font-weight: 600; }
.ar-cell-bool.is-on { color: var(--color-green); }
/* the title column LEADS: semibold, with an optional leading identity glyph */
.ar-td-primary { color: var(--color-text); }
.ar-cell-primary { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.ar-cell-primary-text { font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-cell-primary-emoji { font-size: 1.05rem; line-height: 1; flex: none; }
.ar-cell-primary-thumb { width: 22px; height: 22px; border-radius: var(--radius-sm); object-fit: cover; flex: none; }
/* a calm, single-style status pill for a select value (one accent — colour is reserved) */
.ar-cell-pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 2px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500;
  background: var(--color-surface-alt); border: 1px solid var(--color-border); color: var(--color-text);
}
.ar-cell-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); flex: none; }
/* an initial-chip avatar + name for a user value */
.ar-user-cell { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.ar-avatar {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
  background: var(--color-accent-subtle); color: var(--color-accent);
}
.ar-user-cell-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* recency colour — applied ONLY to a flagged "due" date (founder decision) */
.ar-cell-date--over { color: var(--color-red); font-weight: 600; }
.ar-cell-date--today { color: var(--color-accent); font-weight: 600; }
.ar-cell-date--soon { color: var(--color-text); }
.ar-cell-ref a { font-weight: 500; }
.ar-cell-muted { color: var(--color-text-muted); }

.ar-pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; justify-content: flex-end; }
.ar-pager .ar-page-info { color: var(--color-text-muted); font-size: 13px; }

.ar-empty {
  padding: 40px 20px; text-align: center; color: var(--color-text-muted);
  background: var(--color-surface); border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}
/* Design 104 §4.6 — the richer empty state: icon + sentence + one action, centred. */
.ar-empty--rich {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
}
.ar-empty-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-bottom: var(--space-1);
  color: var(--color-accent); border-radius: var(--radius);
  background: var(--color-accent-subtle);
}
.ar-empty-ic svg { width: 22px; height: 22px; }
.ar-empty-title { color: var(--color-text); font-weight: 600; font-size: 15px; }
.ar-empty-text { color: var(--color-text-muted); font-size: 13px; max-width: 30ch; }
.ar-empty--rich .ar-btn { margin-top: var(--space-2); }

/* ── detail view (Design 104 §4.4 — content-first) ───────────────────────── */
.ar-detail {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 0; max-width: 720px; overflow: hidden;
}
.ar-head--detail { margin-bottom: var(--space-2); }
/* a header band that owns the title (it belongs to the card, not floating above it) */
.ar-detail-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border-subtle);
  flex-wrap: wrap; /* actions drop below the title on a narrow phone */
}
.ar-detail-header-main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.ar-detail-header-emoji { font-size: 1.6rem; line-height: 1; flex: none; }
.ar-detail-header-thumb { width: 38px; height: 38px; border-radius: var(--radius); object-fit: cover; flex: none; }
.ar-detail-actions { display: flex; gap: var(--space-2); flex: none; flex-wrap: wrap; justify-content: flex-end; }
/* a body-shaped field (markdown/longtext) renders full-width above the property grid */
.ar-detail-body { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border-subtle); }
.ar-detail-body-content { margin-top: var(--space-2); font-size: 14px; }
.ar-detail-longtext { white-space: pre-wrap; word-break: break-word; }
.ar-detail-grid { padding: var(--space-1) 0; }
.ar-detail-row {
  display: grid; grid-template-columns: 200px 1fr; gap: var(--space-4);
  padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--color-border-subtle);
}
.ar-detail-row:last-child { border-bottom: none; }
/* quiet property labels — table-header rhythm (11px uppercase muted) for a calm, scannable read */
.ar-detail-label { color: var(--color-text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.ar-detail-value { font-size: 14px; word-break: break-word; }

/* ── Design 159 — inline click-to-edit of a detail value ─────────────────────────
   The read view stays calm; editability is surfaced ONLY on hover/focus (no pencils at
   rest). Click a value → it swaps to the field type's editor in place. Token-only. */
.ar-inline-editable {
  position: relative; cursor: text; border-radius: var(--radius-sm);
  margin: -2px calc(-1 * var(--space-2)); padding: 2px var(--space-2);
  transition: background .12s ease;
}
.ar-inline-editable.ar-inline-toggle,
.ar-inline-editable.ar-inline-promote { cursor: pointer; }
.ar-inline-editable:hover,
.ar-inline-editable:focus-visible { background: var(--color-surface-hover); outline: none; }
.ar-inline-editable:focus-visible { box-shadow: 0 0 0 2px var(--color-accent-subtle); }
/* the trailing edit glyph — hidden at rest, revealed on hover/focus of the value */
.ar-inline-pencil {
  margin-left: var(--space-2); color: var(--color-text-muted); font-size: 12px;
  opacity: 0; transition: opacity .12s ease; pointer-events: none;
}
.ar-inline-editable:hover .ar-inline-pencil,
.ar-inline-editable:focus-visible .ar-inline-pencil { opacity: .7; }
.ar-inline-editable.is-editing { background: transparent; cursor: default; box-shadow: none; }
.ar-inline-editable.is-editing:hover { background: transparent; }
/* the mounted editor — the form widgets keep their own styling; just lay them out */
.ar-inline-editor { display: flex; flex-direction: column; gap: var(--space-1); }
.ar-inline-editor .ar-input,
.ar-inline-editor .ar-select,
.ar-inline-editor .ar-textarea { width: 100%; }
.ar-inline-editor .ar-field-error { color: var(--color-red); font-size: 12px; }
/* a brief, quiet "saved" tick after a successful commit */
.ar-inline-saved {
  margin-left: var(--space-2); color: var(--color-green); font-size: 12px; font-weight: 600;
  transition: opacity .3s ease;
}

/* ── the PEEK dock (Design 148 P2 / Model C) — hold a record beside your list ────────────────
   A right-side dock that PUSHES the shell content (body.ar-peeking) so it sits BESIDE the list,
   not over it; a bottom sheet on a phone. Read-mostly; "Open full ↗" promotes to the real detail. */
.ar-peek {
  position: fixed; z-index: 55; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 92vw;
  display: none; flex-direction: column;
  background: var(--color-surface); border-left: 1px solid var(--color-border);
  box-shadow: -8px 0 30px color-mix(in srgb, var(--color-text, #0b1020) 12%, transparent);
}
.ar-peek.is-open { display: flex; }
@media (min-width: 641px) {
  .ar-shell, .ar-top { transition: padding-right .18s ease; }
  body.ar-peeking .ar-shell, body.ar-peeking .ar-top { padding-right: 380px; }
  /* Shell mode (156 P2 iter 2): the app header is the persistent .hub-top — push it too so the peek
     dock doesn't cover the right-hand tools. */
  body.suite-app-mode.ar-peeking .hub-top { transition: padding-right .18s ease; padding-right: 380px; }
}
.ar-peek-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--color-border);
}
.ar-peek-title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-peek-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.ar-peek-close {
  border: none; background: none; cursor: pointer; font-size: 15px;
  color: var(--color-text-muted); padding: 4px 7px; border-radius: 6px;
}
.ar-peek-close:hover { background: var(--color-surface-alt, rgba(0,0,0,.04)); color: var(--color-text); }
.ar-peek-body { flex: 1; overflow-y: auto; padding: 14px; }
.ar-peek-grid { display: flex; flex-direction: column; gap: 12px; }
.ar-peek-row { display: flex; flex-direction: column; gap: 3px; }
.ar-peek-empty { color: var(--color-text-muted); font-size: 13px; }
/* Design 153 P2 — the peek's bounded action bar (Complete/Advance) + the log-a-note composer. */
.ar-peek-actions-bar { margin: 4px 0 12px; }
.ar-peek .ar-parent-card { margin-bottom: 12px; }
.ar-peek-note { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--color-border-subtle); }
.ar-peek-note .ar-detail-label { margin-bottom: 6px; }
@media (max-width: 640px) {
  .ar-peek {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none;
    height: 72vh; border-left: none; border-top: 1px solid var(--color-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px color-mix(in srgb, var(--color-text, #0b1020) 20%, transparent);
  }
  /* The suite rail becomes a 54px bottom bar on mobile — sit the peek sheet ABOVE it so the bar
     stays visible + tappable (switch apps while peeking) and the sheet's bottom isn't clipped. */
  body.has-suite-rail .ar-peek { bottom: 54px; }
}
/* Touch: long-press a row to PEEK it (Design 148 P2). Suppress the iOS callout / text-selection
   flash so the gesture reads as a peek, not a copy menu. Touch-only (hover:none). */
@media (hover: none) {
  .ar-table tbody tr { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

/* Design 140 (detail layout) — the record's OWN data leads the MAIN column (column 1): its body
   content + its standard property grid. RELATED (linked-to + related lists / the conversation thread)
   sits in the SIDE column (column 2). Source order is main-first → on a phone the record stacks above
   its related lists. Collapses to a single column when the record has no related content. */
.ar-detail--cols { max-width: 1180px; }
.ar-detail-cols { display: grid; grid-template-columns: 1fr; }
.ar-detail-main { min-width: 0; }
.ar-detail-aside { min-width: 0; border-top: 1px solid var(--color-border-subtle); }
/* the related panel fills the side column (no narrow 960 cap, aligned padding) */
.ar-detail-aside .ar-related { max-width: none; margin: 0; padding: var(--space-4) var(--space-5); }
/* Related-list tables sit in a FIXED 360px aside — width:100% crushed up-to-5 columns into 360px
   (cut off, nothing to scroll). Size them to CONTENT so a multi-column list OVERFLOWS the aside and
   scrolls horizontally (via .ar-table-wrap's overflow-x:auto); cap each cell so one long value can't
   make the scroll absurd, and let the primary cell wrap instead of nowrap-overflowing. */
.ar-detail-aside .ar-table-wrap table.ar-table { width: max-content; min-width: 100%; }
.ar-detail-aside .ar-table-wrap .ar-table th,
.ar-detail-aside .ar-table-wrap .ar-table td { max-width: 240px; }
.ar-detail-aside .ar-table-wrap .ar-cell-primary-text { white-space: normal; }
/* no related content → one full-width column, no empty aside */
.ar-detail-cols--solo { grid-template-columns: 1fr; }
.ar-detail-cols--solo .ar-detail-aside { display: none; }
@media (min-width: 880px) {
  .ar-detail-cols { grid-template-columns: minmax(0, 1fr) 360px; }
  .ar-detail-cols--solo { grid-template-columns: 1fr; }
  .ar-detail-aside { border-top: none; border-left: 1px solid var(--color-border-subtle); }
}

/* ── form ────────────────────────────────────────────────────────────────── */
.ar-form {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-5); max-width: 640px;
}
/* Design 104 §4.5 — the record form's inputs adopt the page-widget treatment so the SAME input
   looks the same everywhere: a quiet surface-alt fill, soft radius, and the shared --ring focus. */
.ar-form .ar-input, .ar-form .ar-select, .ar-form .ar-textarea {
  background: var(--color-surface-alt); border-radius: var(--radius);
  transition: background var(--motion-fast), border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.ar-form .ar-input:focus, .ar-form .ar-select:focus, .ar-form .ar-textarea:focus {
  outline: none; background: var(--color-surface);
  border-color: var(--color-accent); box-shadow: var(--ring);
}

/* ── form ────────────────────────────────────────────────────────────────── */
.ar-form {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-5); max-width: 640px;
}
.ar-field { margin-bottom: var(--space-4); }
/* Design 087 L1 — the "More details" disclosure on the record form (progressive disclosure). */
/* Design 144 — a labelled form section header (e.g. "Relationships"), separating the record's own
   data from its links + secondary details. */
.ar-form-section {
  margin: 16px 0 6px; padding-top: 12px; border-top: 1px solid var(--color-border-subtle);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted);
}
.ar-form-more { margin: 4px 0 8px; border-top: 1px solid var(--color-border-subtle); padding-top: 12px; }
.ar-form-more__summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--color-text-muted);
  list-style: none; display: inline-flex; align-items: center; gap: 6px; user-select: none;
}
.ar-form-more__summary::before { content: '▸'; font-size: 11px; transition: transform .12s ease; }
.ar-form-more[open] .ar-form-more__summary::before { transform: rotate(90deg); }
.ar-form-more__summary:hover { color: var(--color-text); }
.ar-form-more__summary::-webkit-details-marker { display: none; }
.ar-form-more__body { padding-top: 14px; }
.ar-field label.ar-label {
  display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600;
}
.ar-req { color: var(--color-red); margin-left: 2px; }
.ar-input, .ar-textarea, .ar-select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); font-family: inherit; font-size: 14px;
}
/* Design 124 §2 — native form controls (the date/time PICKER icon, dropdown arrows, scrollbars)
   must follow the app theme, else the dark-on-dark calendar-picker-indicator is invisible and a
   date field looks like it has no picker. `color-scheme` on the theme'd body fixes every native
   control at once; a per-input belt-and-suspenders keeps it correct inside any stacking context. */
body.theme-dark { color-scheme: dark; }
body.theme-light { color-scheme: light; }
.ar-input[type="date"], .ar-input[type="datetime-local"], .ar-input[type="time"],
.ar-input[type="month"], .ar-input[type="week"] { color-scheme: inherit; }
.ar-input:focus, .ar-textarea:focus, .ar-select:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}
.ar-textarea { min-height: 96px; resize: vertical; }
/* Design 125 — event end-time duration quick-picks (Teams-style "adjust the end fast"). */
.ar-dur-picks { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ar-dur-label { font-size: 12px; color: var(--color-text-muted); margin-right: 2px; }
.ar-dur-pick {
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}
.ar-dur-pick:hover { border-color: var(--color-accent); background: var(--color-accent-subtle); color: var(--color-accent); }
.ar-dur-pick:focus-visible { outline: none; box-shadow: var(--ring); }
/* Design 131 — the "✨ Suggest" affordance: a ghost button + AI-drafted option chips you pick to fill. */
.ar-ai-suggest { margin-top: 6px; }
.ar-ai-suggest-btn { color: var(--color-accent); }
.ar-ai-suggest-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ar-ai-suggest-chip { text-align: left; border: 1px solid var(--color-border); background: var(--color-surface);
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; font: inherit; font-size: 13px;
  color: var(--color-text); line-height: 1.45; white-space: normal; transition: background var(--motion-fast), border-color var(--motion-fast); }
.ar-ai-suggest-chip:hover { border-color: var(--color-accent); background: var(--color-accent-subtle); }
.ar-ai-suggest-chip:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-ai-suggest-empty { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }
/* money input (Design 064 §2.5): a currency-symbol affix beside the masked amount input. Token-
   driven only (no hard-coded colour) — works light + dark. */
.ar-input-money { display: flex; align-items: stretch; gap: 6px; }
.ar-input-money .ar-input { flex: 1; }
.ar-input-affix {
  display: inline-flex; align-items: center; padding: 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--color-surface-2, var(--color-surface)); color: var(--color-text-muted);
  font-size: 14px; white-space: nowrap;
}
.ar-checkbox-row { display: flex; align-items: center; gap: 8px; }
.ar-checkbox { width: 16px; height: 16px; accent-color: var(--color-accent); }
/* multi_select (Design 085): the tags chip-group editor + the list/detail chips. Theme tokens only. */
.ar-multiselect { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 2px 0; }
.ar-multiselect__opt { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.ar-multiselect__cb { width: 16px; height: 16px; accent-color: var(--color-accent); }
.ar-cell-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ar-tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--color-accent-subtle); color: var(--color-accent);
}
.ar-tag--more { background: var(--color-surface-alt, transparent); color: var(--color-text-muted); }
/* emoji field (tree page icons): a small centred glyph input; the per-node icon in the tree. */
.ar-emoji-input { width: 4.5rem; text-align: center; font-size: 18px; line-height: 1.2; }
.ar-tree-icon { display: inline-block; margin-right: 6px; font-size: 0.95em; }
/* rollup (Design 086): a self-ref subtree assembled into one readable document. Theme tokens only. */
.ar-rollup { max-width: 820px; }
.ar-rollup__node { padding: 4px 0 10px; border-left: 2px solid transparent; }
.ar-rollup__node + .ar-rollup__node { border-top: 1px solid var(--color-border-subtle); margin-top: 10px; padding-top: 14px; }
.ar-rollup__title { margin: 6px 0 4px; }
.ar-rollup__titlelink { color: var(--color-text); text-decoration: none; }
.ar-rollup__titlelink:hover { color: var(--color-accent); text-decoration: underline; }
.ar-rollup__traces { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 8px; font-size: 12px; }
.ar-rollup__trace { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ar-rollup__tracelabel { color: var(--color-text-muted); }
.ar-rollup__empty { font-size: 13px; }
.ar-field-error { color: var(--color-red); font-size: 12px; margin-top: 5px; }
.ar-input.is-error, .ar-textarea.is-error, .ar-select.is-error { border-color: var(--color-red); }
/* Design 066: relationship-field inline guidance — a help/description line + an empty-FIELD
   "+ Link <Plural>" prompt rendered under the picker. Token-driven only (light + dark). */
.ar-field-guide { margin-top: 6px; }
.ar-field-help { font-size: 12px; color: var(--color-text-muted); line-height: 1.4; }
.ar-ref-empty {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 13px; color: var(--color-text-muted);
}
.ar-ref-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-sm);
  border: 1px dashed var(--color-accent); background: transparent;
  color: var(--color-accent); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.ar-ref-link:hover { background: var(--color-accent-subtle); }
.ar-ref-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-accent-subtle); }
/* Pre-write required-validation mark (Design 057 §1): a blocked required write tags the feeding
   input widget `.is-invalid` + appends an `.ar-w-field-error` "Required" line. Token-driven so it
   works in light AND dark; cleared on the next edit. */
.ar-w-field.is-invalid .ar-input,
.ar-w-field.is-invalid .ar-checkbox,
.ar-w-picker.is-invalid .ar-w-picker-chips,
.ar-w-picker.is-invalid .ar-w-picker-select,
.ar-w-picker.is-invalid .ar-select { border-color: var(--color-red); }
.ar-w-picker.is-invalid > .ar-w-field-label,
.ar-w-field.is-invalid > .ar-w-field-label { color: var(--color-red); }
.ar-w-field-error { color: var(--color-red); font-size: 12px; margin-top: 5px; }
/* Design 132 — speedy entry: the Save/Cancel bar STICKS to the bottom so you never scroll to save. */
.ar-form-actions { display: flex; gap: 10px; position: sticky; bottom: 0; z-index: 5;
  margin: 20px -26px 0; padding: 13px 26px;
  background: var(--color-surface); border-top: 1px solid var(--color-border); }
@media (max-width: 640px) { .ar-form-actions { margin: 16px -14px 0; padding: 11px 14px; } }

/* Unsaved-draft restored notice (Design 102 P3) — token-only; sits atop the form. */
.ar-draft-note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; padding: 9px 12px;
  background: var(--color-accent-subtle); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: .86rem; color: var(--color-text-muted);
}
.ar-draft-discard {
  flex: none; cursor: pointer; font: inherit; font-weight: 600;
  background: transparent; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 4px 10px; color: var(--color-accent);
}
.ar-draft-discard:hover { background: var(--color-surface-hover); }

/* ── loading / spinner / toasts ──────────────────────────────────────────── */
.ar-loading { display: flex; justify-content: center; padding: 60px 0; }
.ar-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--color-border); border-top-color: var(--color-accent);
  animation: ar-spin .8s linear infinite;
}
@keyframes ar-spin { to { transform: rotate(360deg); } }

/* ── launch skeleton (Design 053 §4.5) — token-styled nav+list placeholder ──────
   Painted instantly on boot so a cold launch is never a blank screen; reuses the
   launcher's `.sk-*` shimmer idiom (the 049 parity-of-idioms principle). Tokens only
   (light + dark); reduced-motion drops the shimmer below. */
.ar-sk-box {
  background: var(--color-surface-hover); border-radius: var(--radius-sm);
  position: relative; overflow: hidden;
}
.ar-sk-box::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--color-text) 7%, transparent), transparent);
  transform: translateX(-100%); animation: ar-sk-shimmer 1.3s infinite;
}
.ar-sk-navhead { display: inline-block; width: 60%; height: .8em; vertical-align: middle; }
.ar-sk-navitem { height: 1.9rem; margin: 6px 0; }
.ar-sk-list { padding: 4px 0; }
.ar-sk-title { width: 36%; height: 1.6rem; margin-bottom: 18px; }
.ar-sk-row { height: 2.6rem; margin-bottom: 10px; }
@keyframes ar-sk-shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .ar-sk-box::after { animation: none; } }

.ar-toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
}
.ar-toast {
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px;
  box-shadow: var(--shadow); transition: opacity .3s; max-width: 360px;
}
.ar-toast-error { border-left-color: var(--color-red); }
.ar-toast-success { border-left-color: var(--color-green); }

/* ── saved views / filters / column config (§10 #4) ──────────────────────── */
.ar-view-select { flex: 0 0 auto; width: auto; min-width: 150px; }
.ar-th-sort { cursor: pointer; user-select: none; }
.ar-th-sort:hover { color: var(--color-text); }
/* Design 124 §1 — the per-row one-click edit. A compact ghost pencil, right-aligned, that
   firms up on row hover/focus so it's discoverable without shouting. Touch: always visible. */
.ar-th-actions, .ar-td-actions { width: 44px; text-align: right; }
.ar-row-edit {
  border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1;
  padding: 4px 6px; border-radius: var(--radius-sm); color: var(--color-text-muted);
  opacity: .55; transition: opacity var(--motion-fast), background var(--motion-fast), color var(--motion-fast);
}
.ar-table tbody tr:hover .ar-row-edit, .ar-table tbody tr:focus-within .ar-row-edit { opacity: 1; }
.ar-row-edit:hover { background: var(--color-accent-subtle); color: var(--color-accent); opacity: 1; }
.ar-row-edit:focus-visible { outline: none; box-shadow: var(--ring); opacity: 1; }
/* Design 153 P3 — the compact inline ✓ complete on a list row (tick a task off without opening it). */
.ar-row-complete {
  border: none; background: none; cursor: pointer; font-size: 14px; line-height: 1; margin-right: 2px;
  padding: 4px 6px; border-radius: var(--radius-sm); color: var(--color-text-muted); opacity: .55;
  transition: opacity var(--motion-fast), background var(--motion-fast), color var(--motion-fast);
}
.ar-table tbody tr:hover .ar-row-complete, .ar-table tbody tr:focus-within .ar-row-complete { opacity: 1; }
.ar-row-complete:hover { background: var(--color-success-subtle, var(--color-accent-subtle)); color: var(--color-success, var(--color-accent)); opacity: 1; }
.ar-row-complete:focus-visible { outline: none; box-shadow: var(--ring); opacity: 1; }
@media (hover: none) { .ar-row-edit { opacity: .8; } } /* touch: no hover, keep it visible */

.ar-colmenu { position: relative; flex: 0 0 auto; }
.ar-colmenu > summary { list-style: none; cursor: pointer; }
.ar-colmenu > summary::-webkit-details-marker { display: none; }
.ar-colmenu-list {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  min-width: 200px; max-height: 280px; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px;
}
.ar-colmenu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer;
}
.ar-colmenu-item:hover { background: var(--color-surface-hover); }
.ar-colmenu-item input { accent-color: var(--color-accent); }

/* ── related child lists (§10 #3) ────────────────────────────────────────── */
.ar-related { max-width: 960px; margin-top: 26px; }
/* Design 110 — the conversation/activity timeline: a connected THREAD (a vertical rail through
   the author avatars + chat-style bubbles), not a stack of record cards. Token-only, generic. */
.ar-timeline { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-3); padding-left: 2px; }
.ar-tl-item { position: relative; display: flex; gap: var(--space-3); align-items: flex-start; }
/* the rail — a line behind the avatars linking each entry to the next */
.ar-tl-item:not(:last-child)::before {
  content: ''; position: absolute; left: 13px; top: 26px; bottom: calc(-1 * var(--space-4));
  width: 2px; background: var(--color-border); border-radius: 1px;
}
.ar-tl-item .ar-avatar { flex: none; position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--color-bg); }
/* the bubble — a tinted speech bubble (surface-alt), distinct from a white record card */
.ar-tl-main {
  flex: 1; min-width: 0; position: relative;
  background: var(--color-surface-alt); border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius); padding: var(--space-2) var(--space-3);
}
/* a small tail pointing at the avatar — the chat cue */
.ar-tl-main::before {
  content: ''; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px;
  background: var(--color-surface-alt); border-left: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle); transform: rotate(45deg);
}
.ar-tl-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-1); }
.ar-tl-author { font-weight: 600; color: var(--color-text); font-size: 13px; }
.ar-tl-when { color: var(--color-text-muted); font-size: 12px; margin-left: auto; }
.ar-tl-body { font-size: 14px; color: var(--color-text); word-break: break-word; }
.ar-tl-body-text { white-space: pre-wrap; }
/* Design 110 §5 — the inline composer (add a note/reply on the record, no deep-link). Token-only. */
.ar-tl-wrap { display: flex; flex-direction: column; gap: var(--space-3); }
.ar-tl-composer {
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: var(--space-2) var(--space-3); box-shadow: var(--shadow-sm);
}
.ar-tl-input { resize: vertical; min-height: 2.6rem; }
.ar-tl-composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.ar-tl-kind { width: auto; min-width: 9rem; margin-right: auto; }
/* the unified "Related" region heading (Design 096 Phase 1) */
.ar-related-region-head { font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-muted); padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border); }
.ar-related-region-head[hidden] { display: none; }
.ar-related-section { margin-top: 22px; }
/* "Linked to" — this record's outgoing references (its associations/parents) */
.ar-linked { display: flex; flex-direction: column; gap: 8px; }
.ar-linked-row { display: flex; align-items: baseline; gap: 12px; }
.ar-linked-label { flex: 0 0 140px; font-size: 13px; color: var(--color-text-muted); font-weight: 600; }
.ar-linked-vals { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-linked-chip { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; text-decoration: none;
  background: var(--color-accent-subtle); color: var(--color-accent); border: 1px solid transparent; }
a.ar-linked-chip:hover { border-color: var(--color-accent); }
.ar-linked-chip.is-crossapp { background: var(--color-surface-alt); color: var(--color-text-muted); border-color: var(--color-border); }

/* Design 153 A — the parent-context card (contact/company details inline on the detail aside). */
.ar-parent-card { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4); background: var(--color-surface); }
.ar-parent-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.ar-parent-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
.ar-parent-title { font-size: 1.05rem; font-weight: 700; color: var(--color-text); text-decoration: none; }
a.ar-parent-title:hover { color: var(--color-accent); }
.ar-parent-row { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; font-size: 14px; }
.ar-parent-fl { flex: 0 0 auto; min-width: 64px; color: var(--color-text-muted); font-size: 12px; font-weight: 600; }
.ar-parent-fv { color: var(--color-text); word-break: break-word; }
a.ar-parent-action { color: var(--color-accent); text-decoration: none; font-weight: 600; }
a.ar-parent-action:hover { text-decoration: underline; }

/* Design 153 B — the one-click Complete / advance action + its terminal picker + the Undo toast. */
.ar-btn.ar-btn-primary { background: var(--color-accent); color: var(--color-on-accent, #fff); border-color: transparent; }
.ar-btn.ar-btn-primary:hover { filter: brightness(1.05); }
.ar-complete-choose { position: relative; display: inline-block; }
.ar-complete-menu { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 160px; padding: 5px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.ar-complete-mi { display: block; width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  padding: 8px 10px; border-radius: 7px; font: inherit; font-size: 13px; color: var(--color-text); }
.ar-complete-mi:hover { background: var(--color-surface-alt); color: var(--color-accent); }
.ar-toast-undo { margin-left: 12px; border: none; background: none; cursor: pointer; font: inherit; font-weight: 700;
  color: var(--color-on-accent, #fff); text-decoration: underline; }
.ar-related-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.ar-related-title { font-size: 15px; font-weight: 700; }
.ar-related-count {
  color: var(--color-text-muted); font-weight: 600; font-size: 13px; margin-left: 2px;
}
/* a CROSS-APP related block badge (Design 090 Phase 2): records that live in a linked app */
.ar-related-app {
  margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  color: var(--color-accent); background: var(--color-accent-soft, var(--color-surface));
  border: 1px solid var(--color-accent); vertical-align: middle;
}
.ar-related-empty {
  padding: 16px 18px; color: var(--color-text-muted); font-size: 14px;
  background: var(--color-surface); border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}

/* ════════════════════════════════════════════════════════════════════════════
   View types (Design 046) — the typed-view switcher + the four renderers.
   Tokens ONLY (var(--color-*)); legible in light AND dark.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── view switcher (chip bar) ──────────────────────────────────────────────── */
.ar-viewbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ar-viewchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface);
  color: var(--color-text); font: inherit; font-size: 13px; cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast); }
.ar-viewchip:hover { background: var(--color-surface-hover); }
.ar-viewchip:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-viewchip.is-active { background: var(--color-accent); color: var(--color-text-on-accent);
  border-color: var(--color-accent); }
.ar-viewchip.is-active .ar-vt-icon { color: var(--color-text-on-accent); }
.ar-vt-icon { display: inline-flex; width: 16px; height: 16px; color: var(--color-text-muted); }
/* Design 087 L2 — the "Views ▾" overflow menu (power views collapse here, off the bar). */
.ar-viewmenu { position: relative; }
.ar-viewmenu__summary { list-style: none; }
.ar-viewmenu__summary::-webkit-details-marker { display: none; }
.ar-viewmenu__summary::after { content: '▾'; font-size: 11px; color: var(--color-text-muted); }
.ar-viewmenu__list {
  position: absolute; z-index: 20; margin-top: 6px; min-width: 200px; padding: 6px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.ar-viewmenu__item {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; width: 100%;
  border: 0; background: transparent; color: var(--color-text); font: inherit; font-size: 13px;
  text-align: left; cursor: pointer; border-radius: var(--radius-sm, 6px);
}
.ar-viewmenu__item:hover { background: var(--color-surface-hover); }
.ar-vt-icon svg { width: 16px; height: 16px; }
.ar-grid-hint { margin-top: 10px; font-size: 12px; color: var(--color-text-muted); }

/* ── grid (quick entry) ────────────────────────────────────────────────────── */
.ar-grid-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); }
.ar-grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ar-grid-table th { text-align: left; padding: 8px 10px; background: var(--color-surface-alt);
  color: var(--color-text-muted); font-weight: 600; border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; }
.ar-grid-table td { padding: 4px 6px; border-bottom: 1px solid var(--color-border-subtle); }
.ar-grid-newrow td { background: var(--color-accent-subtle); }
.ar-grid-input, .ar-grid-cell-input.ar-select, .ar-grid-cell-input { width: 100%; box-sizing: border-box;
  padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--color-text); font: inherit; }
.ar-grid-input:focus, .ar-grid-cell-input:focus { outline: none; border-color: var(--color-accent);
  background: var(--color-bg); }
.ar-grid-cell-input.is-error { border-color: var(--color-red); }

/* ── kanban ────────────────────────────────────────────────────────────────── */
.ar-kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.ar-kan-col { flex: 0 0 260px; background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: var(--radius); display: flex; flex-direction: column; }
/* Design 104 §4.3 — a calmer dashed accent ring on the drop target (was a fill-swap). */
.ar-kan-col.is-dropzone { border-color: transparent; box-shadow: 0 0 0 2px var(--color-accent); }
.ar-kan-col.is-dropzone .ar-kan-col-body { outline: 2px dashed var(--color-accent); outline-offset: -6px; border-radius: var(--radius); }
.ar-kan-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; font-weight: 600; color: var(--color-text); border-bottom: 1px solid var(--color-border); }
.ar-kan-count { font-size: 12px; color: var(--color-text-muted); background: var(--color-surface);
  border-radius: 999px; padding: 1px 8px; }
.ar-kan-col-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 60px; }
.ar-kan-card { position: relative; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 10px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast); }
.ar-kan-card:hover { border-color: var(--color-accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ar-kan-card:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-kan-card.is-dragging { opacity: 0.5; }
/* Design 098 §3 Phase B — attachment widget (image upload + paste) + cell + kanban cover. */
.ar-attach { display: block; border: 1px dashed var(--color-border); border-radius: 8px; padding: 10px; }
.ar-attach.is-dropzone { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.ar-attach:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 35%, transparent); }
.ar-attach-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-attach-grid:empty { display: none; }
.ar-attach-thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--color-border); }
.ar-attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ar-attach-rm { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; line-height: 1; border: none; border-radius: 6px;
  background: color-mix(in srgb, var(--color-bg) 70%, transparent); color: var(--color-text); cursor: pointer; font-size: 12px; }
.ar-attach-rm:hover { background: var(--color-bg); }
.ar-attach-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ar-attach-status { font-size: 12px; color: var(--color-text-muted); }
.ar-attach-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }
.ar-attach-file { display: none; }
.ar-attach-cell { display: inline-flex; align-items: center; gap: 4px; }
.ar-attach-cell-img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; border: 1px solid var(--color-border); }
.ar-attach-cell-more { font-size: 12px; color: var(--color-text-muted); }
.ar-kan-card-cover { margin: -10px -10px 8px; border-radius: 8px 8px 0 0; overflow: hidden; max-height: 120px; }
.ar-kan-card-cover img { width: 100%; height: 100%; max-height: 120px; object-fit: cover; display: block; }
/* Design 098 §2 — quiet one-click archive (✕), revealed on card hover; token-styled. */
.ar-kan-card-archive { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: 12px;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--color-text-muted);
  cursor: pointer; opacity: 0; transition: opacity .12s ease, color .12s ease, border-color .12s ease; }
.ar-kan-card:hover .ar-kan-card-archive { opacity: 1; }
.ar-kan-card-archive:hover { color: var(--color-text); border-color: var(--color-border); }
.ar-kan-card-archive:focus-visible { opacity: 1; outline: none; border-color: var(--color-accent); }
.ar-kan-card-title { font-weight: 600; color: var(--color-text); font-size: 14px; padding-right: 22px; }
/* Design 104 §4.3 — a tidy wrap of typed chips (select pill / user avatar / typed text) replaces
   the old "key: value" lines. The shared §4.2 cell helpers render the chip contents. */
.ar-kan-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; }
.ar-kan-card-chip { display: inline-flex; align-items: center; color: var(--color-text-muted); }
/* a quiet inline per-column create */
.ar-kan-add {
  margin-top: 2px; padding: 6px 8px; width: 100%; text-align: left;
  background: transparent; border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
  color: var(--color-text-muted); font: inherit; font-size: 13px; cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.ar-kan-add:hover { color: var(--color-accent); border-color: var(--color-accent); background: var(--color-accent-subtle); }
.ar-kan-add:focus-visible { outline: none; box-shadow: var(--ring); }
/* Design 152 — "Load more" per column on a scalable board (windowed columns). */
.ar-kan-more {
  margin-top: 4px; padding: 6px 8px; width: 100%; text-align: center;
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  color: var(--color-text-muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.ar-kan-more:hover { color: var(--color-accent); border-color: var(--color-accent); }
.ar-kan-more[disabled] { opacity: .6; cursor: default; }

/* ── calendar ──────────────────────────────────────────────────────────────── */
.ar-cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ar-cal-title { font-weight: 600; font-size: 16px; color: var(--color-text); }
/* Design 124 §4 — the Month / Week toggle (reuses the view-chip look). */
.ar-cal-modes { display: inline-flex; gap: 4px; }
/* minmax(0, 1fr) — NOT 1fr — so a nowrap event label can't force a column wider than 1/7 of the
   width (the grid-blowout that broke resize on mobile when a day had an item). */
.ar-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--color-border);
  border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.ar-cal-dow { background: var(--color-surface-alt); color: var(--color-text-muted); font-size: 12px;
  font-weight: 600; text-align: center; padding: 8px 0; }
.ar-cal-cell { background: var(--color-surface); min-height: 92px; padding: 4px; display: flex;
  flex-direction: column; gap: 3px; min-width: 0; overflow: hidden; }
/* Design 124 §4 — week view: the 7 day columns get much taller, room-to-breathe cells (one row,
   not a month's 5–6). Events no longer truncate to a sliver. */
.ar-cal-grid.is-week .ar-cal-cell { min-height: 320px; overflow-y: auto; }
.ar-cal-cell.is-empty { background: var(--color-surface-alt); }
/* Design 128 — the whole day cell is a click target to add an appointment (events stop propagation
   and edit instead). Pointer + a faint hover signal it; the month's leading/trailing pad days aren't. */
.ar-cal-cell:not(.is-empty) { cursor: pointer; }
.ar-cal-cell:not(.is-empty):hover { background: var(--color-surface-hover); }
.ar-cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--color-accent); }
.ar-cal-cell.is-dropzone { background: var(--color-accent-subtle); }
.ar-cal-daynum { font-size: 12px; color: var(--color-text-muted); cursor: pointer; align-self: flex-start;
  border-radius: 5px; padding: 1px 5px; }
.ar-cal-daynum:hover { background: var(--color-accent-subtle); color: var(--color-accent); }
.ar-cal-event { background: var(--color-accent-subtle); color: var(--color-accent); border-radius: 5px;
  padding: 2px 6px; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border: 1px solid var(--color-border-subtle); max-width: 100%; }
.ar-cal-event:hover { background: var(--color-accent); color: var(--color-text-on-accent); }
/* Design 100 §1 — all-day events read as a filled bar; multi-day continuation segments are
   flush-left (no rounded start) so a span reads as one event across days. */
.ar-cal-event.is-allday { background: var(--color-accent); color: var(--color-text-on-accent); border-color: transparent; }
.ar-cal-event.is-continuation { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .85; cursor: default; }
/* Design 100 §2.5 — the source-app hint on a unified cross-app calendar event. */
.ar-cal-event-app { font-weight: 700; opacity: .7; font-size: 11px; }

/* ── diagram ───────────────────────────────────────────────────────────────── */
.ar-diagram-wrap { overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); padding: 8px; }
.ar-diagram-svg { display: block; }
.ar-diagram-edge { stroke: var(--color-border); stroke-width: 1.5; }
.ar-diagram-rect { fill: var(--color-surface-alt); stroke: var(--color-border); }
.ar-diagram-node:hover .ar-diagram-rect { stroke: var(--color-accent); fill: var(--color-accent-subtle); }
.ar-diagram-label { fill: var(--color-text); font-size: 12px; font-family: inherit; }

/* relationship_diagram (Design 066) — the Mermaid render surface. Token-only; Mermaid's
   themeVariables are derived from the live --color-* tokens so it follows light + dark. */
.ar-mermaid-wrap-outer { overflow: auto; }
.ar-mermaid-wrap { overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); padding: 8px; }
.ar-mermaid-wrap svg { display: block; max-width: 100%; height: auto; }
.ar-mermaid-loading { color: var(--color-text-muted, var(--color-text)); padding: 16px; font-size: 0.85rem; }

/* ════════════════════════════════════════════════════════════════════════════
   THE INTERACTION DSL — page widgets (Design 047 + 057 §4 visual refresh).
   Token-only; light + dark; AA-contrast; honours prefers-reduced-motion.
   CSS-only over the EXISTING .ar-w-* classes — no markup change, so renderer
   parity (server-preview ↔ client-runtime) is untouched (057 §4.5).
   ════════════════════════════════════════════════════════════════════════════ */
.ar-page { display: flex; flex-direction: column; gap: 22px; }
.ar-w { display: block; }
/* friendly fade-in-up on first widget paint (reduced-motion neutralised below) */
.ar-page > .ar-w { animation: ar-w-in var(--motion-fast) both; }
@keyframes ar-w-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ar-w-placeholder { border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
  padding: 10px 12px; color: var(--color-text-muted); font-size: 13px; background: var(--color-surface-alt); }

/* container layouts */
.ar-w-container { display: flex; }
.ar-w-container.ar-w-stack { flex-direction: column; }
.ar-w-container.ar-w-row { flex-direction: row; flex-wrap: wrap; align-items: center; }
.ar-w-container.ar-w-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ar-w-container[data-gap="sm"] { gap: 8px; }
.ar-w-container[data-gap="md"] { gap: 14px; }
.ar-w-container[data-gap="lg"] { gap: 22px; }

/* text */
.ar-w-text-title { font-size: clamp(20px, 3vw, 26px); font-weight: 800; letter-spacing: -.01em;
  color: var(--color-text); }
.ar-w-text-body { font-size: 15px; color: var(--color-text); }
.ar-w-text-caption { font-size: 13px; color: var(--color-text-muted); }

/* field — confident ring focus on the shared form inputs (reuses .ar-input/.ar-select/.ar-textarea) */
.ar-w-field { display: flex; flex-direction: column; gap: 6px; }
.ar-w-field-label { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.ar-w-field .ar-input, .ar-w-field .ar-select, .ar-w-field .ar-textarea {
  background: var(--color-surface-alt); border-radius: var(--radius); }
.ar-w-field .ar-input:focus, .ar-w-field .ar-select:focus, .ar-w-field .ar-textarea:focus {
  border-color: var(--color-accent); box-shadow: var(--ring); }
/* generic required-block inline mark (Design 057 §1.2 / §4.2). The interpreter
   tags an offending field/picker/form wrapper with .is-invalid and appends an
   .ar-w-field-error "Required" line; this styles both light + dark. */
.ar-w-field.is-invalid .ar-input, .ar-w-field.is-invalid .ar-select, .ar-w-field.is-invalid .ar-textarea {
  border-color: var(--color-red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-red) 22%, transparent); }
.ar-w-field-error { color: var(--color-red); font-size: 12px; font-weight: 600; margin-top: 2px; }
.ar-w-field.is-invalid .ar-w-field-label, .is-invalid > .ar-w-field-label { color: var(--color-red); }

/* picker — friendly, thumb-sized pills with springy hover + ring focus */
.ar-w-picker { display: flex; flex-direction: column; gap: 8px; }
.ar-w-picker-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-w-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-w-chip { border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); border-radius: var(--radius-pill); padding: 9px 16px;
  min-height: 40px; font-size: 14px; font-weight: 600; line-height: 1.1;
  font-family: inherit; cursor: pointer;
  transition: transform var(--motion-fast), background var(--motion-fast),
    border-color var(--motion-fast), box-shadow var(--motion-fast); }
.ar-w-chip:hover { background: var(--color-surface-hover); transform: translateY(-1px); }
.ar-w-chip:active { transform: translateY(0); }
.ar-w-chip:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-w-chip.is-active { background: var(--accent-grad); color: var(--color-text-on-accent);
  border-color: transparent; box-shadow: var(--surface-glow); }
.ar-w-chip.is-active:hover { transform: translateY(-1px); }
/* picker search + typeahead results (recent pills + search — scales past a chip wall) */
.ar-w-picker-search { width: 100%; box-sizing: border-box; font: inherit; font-size: 15px;
  color: var(--color-text); background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 9px 12px; }
.ar-w-picker-search::placeholder { color: var(--color-text-muted); }
.ar-w-picker-results { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 4px; background: var(--color-surface); }
.ar-w-picker-results[hidden] { display: none; }
.ar-w-picker-result { text-align: left; font: inherit; font-size: 14px; cursor: pointer;
  background: none; border: none; border-radius: var(--radius-sm); padding: 9px 11px; color: var(--color-text); }
.ar-w-picker-result:hover { background: var(--color-surface-hover); }
.ar-w-picker-noresult { padding: 9px 11px; font-size: 13px; color: var(--color-text-muted); }
.ar-w-picker-recent-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--color-text-muted); font-weight: 600; align-self: center; margin-right: 2px; }

/* timer — the energetic hero: a large squircle card, hero display type, an
   accent-gradient running border + soft pulsing glow (static ring when
   reduced-motion), and a running-state pill. */
.ar-w-timer { display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: var(--space-w) calc(var(--space-w) + 6px); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--surface-glow);
  font-variant-numeric: tabular-nums; text-align: center;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast); }
.ar-w-timer.is-running {
  border-color: transparent;
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    var(--accent-grad) border-box;
  border: 2px solid transparent;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 18%, transparent), var(--surface-glow);
  animation: ar-timer-pulse 1.9s ease-in-out infinite; }
@keyframes ar-timer-pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 14%, transparent), var(--surface-glow); }
  50%      { box-shadow: 0 0 0 9px color-mix(in srgb, var(--color-accent) 22%, transparent), var(--surface-glow); } }
.ar-w-timer-display { font-size: var(--type-display); font-weight: 800; color: var(--color-text);
  letter-spacing: 1px; line-height: 1; }
/* hero timer (timer size:'hero') — the centered focal point of an action-shaped Screen. Larger
   display, centered in its row, with breathing room so it reads as the main thing. */
.ar-w-timer-hero { align-self: center; max-width: 420px; width: 100%; margin: 4px auto;
  padding: calc(var(--space-w) + 10px); }
.ar-w-timer-hero .ar-w-timer-display { font-size: calc(var(--type-display) * 1.6); }
.ar-w-timer-state { display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--color-text-muted); background: var(--color-surface-alt);
  border-radius: var(--radius-pill); padding: 4px 12px; }
.ar-w-timer-state::before { content: '●'; font-size: 9px; color: var(--color-text-muted); line-height: 1; }
.ar-w-timer.is-running .ar-w-timer-state { color: var(--color-accent);
  background: var(--color-accent-subtle); }
.ar-w-timer.is-running .ar-w-timer-state::before { color: var(--color-accent); }
.ar-w-timer-controls { display: inline-flex; gap: 8px; align-self: center; margin-top: 2px; }

/* button (secondary maps to the ghost/border style) */
.ar-btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.ar-btn-secondary:hover { background: var(--color-surface-hover); }

/* page-context buttons — gradient primary + glow + a springy micro-press.
   Scoped to .ar-page / .ar-w-timer / .ar-w-form so the list-view chrome buttons
   (top bar, pager, toolbars) keep their flat admin look. A page "primary" button
   is the bare .ar-btn (no -ghost/-secondary/-danger modifier). */
.ar-page .ar-btn, .ar-w-timer .ar-btn, .ar-w-form .ar-btn {
  border-radius: var(--radius); transition: transform var(--motion-fast),
    background var(--motion-fast), box-shadow var(--motion-fast); }
.ar-page .ar-btn:not(.ar-btn-ghost):not(.ar-btn-secondary):not(.ar-btn-danger),
.ar-w-timer .ar-btn:not(.ar-btn-ghost):not(.ar-btn-secondary):not(.ar-btn-danger),
.ar-w-form .ar-btn:not(.ar-btn-ghost):not(.ar-btn-secondary):not(.ar-btn-danger) {
  background: var(--accent-grad); border-color: transparent;
  color: var(--color-text-on-accent); box-shadow: var(--surface-glow); }
.ar-page .ar-btn:active, .ar-w-timer .ar-btn:active, .ar-w-form .ar-btn:active {
  transform: translateY(1px) scale(.99); }
.ar-page .ar-btn:focus-visible, .ar-w-timer .ar-btn:focus-visible, .ar-w-form .ar-btn:focus-visible {
  outline: none; box-shadow: var(--ring); }

/* form */
.ar-w-form { display: flex; flex-direction: column; gap: 14px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--surface-glow); padding: var(--space-w); }

/* stat — hero value with an accent-gradient text clip (falls back to a solid
   accent colour where background-clip:text is unsupported). */
.ar-w-stat { display: inline-flex; flex-direction: column; gap: 4px; padding: var(--space-w);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--surface-glow); }
.ar-w-stat-value { font-size: var(--type-display); font-weight: 800; line-height: 1;
  color: var(--color-accent); /* fallback */
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; }
.ar-w-stat-label { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }

/* summary (Design 135 Phase 2b) — the weekly "my hours" aggregate. Token-only; calm + compact. */
.ar-w-summary { border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--surface-glow); padding: var(--space-w); }
.ar-w-summary-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ar-w-summary-title { font-size: 13px; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ar-w-summary-total { font-size: var(--type-h2, 22px); font-weight: 800; color: var(--color-text); }
.ar-w-summary-total .ar-w-summary-split { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.ar-w-summary-muted { font-size: 14px; font-weight: 600; color: var(--color-text-muted); }
.ar-w-summary-days { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.ar-w-summary-day { display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; border-top: 1px solid var(--color-border); font-size: 14px; }
.ar-w-summary-day:first-child { border-top: none; }
.ar-w-summary-day-label { color: var(--color-text-muted); font-weight: 600; }
.ar-w-summary-day-hrs { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--color-text); }
.ar-w-summary-loading, .ar-w-summary-empty { font-size: 13px; color: var(--color-text-muted); }

/* Design 168 — the language-learning study widgets. Token-driven only (light + dark). */
.ar-w-flashcard { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 200px; padding: var(--space-6, 24px); border: 1px solid var(--color-border); border-radius: var(--radius-lg, 16px);
  background: var(--color-surface); cursor: pointer; user-select: none; transition: border-color .12s ease, box-shadow .12s ease; }
.ar-w-flashcard:hover { border-color: var(--color-accent, #6366f1); box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.ar-w-flashcard-empty { min-height: 120px; cursor: default; }
.ar-w-flashcard-audio, .ar-w-compose-audio { position: absolute; top: 8px; right: 8px; background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; border-radius: 8px; }
.ar-w-flashcard-audio:hover, .ar-w-compose-audio:hover { background: var(--color-surface-hover, rgba(0,0,0,.05)); }
.ar-w-flashcard-face { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.ar-w-flashcard-front { font-size: 64px; font-weight: 700; color: var(--color-text); line-height: 1.1; }
.ar-w-flashcard-back { font-size: 22px; font-weight: 600; color: var(--color-text); }
.ar-w-flashcard-detail { font-size: 15px; color: var(--color-text-muted); }
.ar-w-flashcard-note { font-size: 13px; color: var(--color-text-muted); }
.ar-w-flashcard-lbl { color: var(--color-text-muted); font-weight: 400; font-size: 0.72em; text-transform: uppercase; letter-spacing: .04em; }
.ar-w-flashcard-rate { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.ar-w-compose { display: flex; align-items: center; gap: 10px; position: relative; padding: var(--space-4, 16px); }
.ar-w-compose-block { font-size: 72px; font-weight: 700; color: var(--color-text); min-width: 1.4em; text-align: center; line-height: 1.1; }
.ar-w-compose-empty { color: var(--color-text-muted); font-size: 13px; }
/* Design 170 — the letter→word breakdown (record → parts → subparts) */
.ar-w-breakdown { display: flex; flex-direction: column; gap: 8px; }
.ar-w-breakdown-caption { font-size: 14px; color: var(--color-text-muted); }
.ar-w-breakdown-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.ar-w-breakdown-part { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ar-w-breakdown-part-label { font-size: 32px; font-weight: 700; color: var(--color-text); line-height: 1.1; }
.ar-w-breakdown-subparts { font-size: 13px; color: var(--color-text-muted); }
.ar-w-breakdown-empty { color: var(--color-text-muted); font-size: 13px; }
/* Design 172 — composition mode: "part + part = whole" on one baseline (ㄴ + ㅏ = 나). */
.ar-w-breakdown-compose { align-items: center; gap: 10px; }
.ar-w-breakdown-op { font-size: 24px; font-weight: 400; color: var(--color-text-muted); }
.ar-w-breakdown-whole { font-size: 40px; font-weight: 800; color: var(--color-text); line-height: 1.1; }
.ar-w-compose-audio { position: static; }

/* repeater (Design 064 §3.3) — line-items input rows. Token-driven only (no hard-coded colour). */
.ar-w-repeater { display: flex; flex-direction: column; gap: 6px; }
.ar-rep-head, .ar-rep-row { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: center; }
.ar-rep-head { grid-auto-flow: column; grid-auto-columns: 1fr; }
.ar-rep-row { grid-auto-flow: column; grid-auto-columns: 1fr; }
.ar-rep-head-cell { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.ar-rep-actions-h, .ar-rep-actions { width: 40px; flex: none; }
.ar-rep-cell .ar-input, .ar-rep-cell .ar-grid-input { width: 100%; }
.ar-rep-computed { display: inline-flex; align-items: center; padding: 6px 8px; font-weight: 600;
  color: var(--color-text); }
.ar-rep-add { margin-top: 4px; }

/* statusBar (Design 064 §4.3) — ordered status chips, current highlighted. Token-driven. */
.ar-w-statusbar { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-status-chip { padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); }
.ar-status-chip.is-active { background: var(--color-accent); border-color: var(--color-accent);
  color: #fff; }

/* embedded list widget — hover-lift rows + a friendly empty state (scoped so the
   global list-view chrome is unchanged). */
.ar-w-list { margin-top: 4px; }
.ar-w-list .ar-table-wrap { border-radius: var(--radius-lg); }
.ar-w-list .ar-table tbody tr { transition: background var(--motion-fast); }
.ar-w-list .ar-empty {
  border-radius: var(--radius-lg); border-style: dashed; padding: 36px 22px;
  font-size: 15px; font-weight: 600; color: var(--color-text-muted); }

/* ── reduced motion (Design 057 §4.4) ──────────────────────────────────────────
   Neutralise every transform / pulse / fade-in on the page widgets while keeping
   a static accent state: the running timer keeps its gradient border + static
   ring (no pulse), chips/buttons keep their hover/active colour but no springy
   transform. The page stays fully usable and legible. */
@media (prefers-reduced-motion: reduce) {
  .ar-page > .ar-w { animation: none; }
  .ar-w-chip, .ar-w-chip:hover, .ar-w-chip:active,
  .ar-page .ar-btn, .ar-page .ar-btn:active,
  .ar-w-timer .ar-btn, .ar-w-timer .ar-btn:active,
  .ar-w-form .ar-btn, .ar-w-form .ar-btn:active { transform: none; transition: none; }
  .ar-w-timer { transition: none; }
  .ar-w-timer.is-running { animation: none;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 22%, transparent), var(--surface-glow); }
  /* Design 104 Phase 1 — neutralise the workhorse-chrome motion (keep the static states). */
  .ar-nav-item, .ar-btn, .ar-viewchip, .ar-table tbody tr { transition: none; }
  .ar-kan-card { transition: none; }
  .ar-kan-card:hover { transform: none; }
  /* Design 104 Phase 2/3 — the inline-add + form-input transitions too. */
  .ar-kan-add, .ar-form .ar-input, .ar-form .ar-select, .ar-form .ar-textarea { transition: none; }
}

/* ── responsive ──────────────────────────────────────────────────────────── */
/* ── mobile pass (≤720px): off-canvas nav drawer + de-crowded header ──────────── */
@media (max-width: 720px) {
  .ar-nav-toggle { display: inline-flex; }
  .ar-top { padding: 8px 12px; }
  /* Design 104 §7.4 — the back link RETURNS on mobile (the rail is a bottom bar here, and the
     header has room); compacted to just the ← arrow. Overrides the desktop has-suite-rail hide. */
  body.has-suite-rail .ar-back { display: inline-flex; }
  .ar-back { font-size: 0; padding: 4px 6px; }          /* keep the ← arrow, drop the word */
  .ar-back::before { content: '←'; font-size: 15px; }
  .ar-title { font-size: 15px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #ar-customize { display: none; }                       /* authoring entry — desktop surface */
  .ar-top-right { gap: 8px; }
  .ar-main { padding: 14px 14px; }

  /* The nav becomes an off-canvas DRAWER (run.js toggles .nav-open + appends .ar-nav-scrim). */
  .ar-shell { display: block; }
  .ar-nav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 41;
    width: 82%; max-width: 300px;
    transform: translateX(-100%); transition: transform .2s ease;
    border-right: 1px solid var(--color-border);
    box-shadow: 2px 0 22px color-mix(in srgb, var(--color-text) 22%, transparent);
  }
  .ar-shell.nav-open .ar-nav { transform: none; }
  .ar-nav-scrim {
    display: none; position: fixed; inset: 0; z-index: 40;
    background: color-mix(in srgb, var(--color-text) 38%, transparent);
  }
  .ar-shell.nav-open .ar-nav-scrim { display: block; }
  .ar-nav-item { padding: 11px 12px; }                   /* ~44px touch targets */

  .ar-detail-row { grid-template-columns: 1fr; gap: 4px; }
  /* tree-nav (Design 073 §2.6): bounded, scrollable above the content so it never eats the page. */
  .ar-tree-nav { width: auto; border-right: none; border-bottom: 1px solid var(--color-border);
                 max-height: 34vh; padding: 10px; }
}

/* ── mobile pass (≤640px): list TABLE → stacked CARDS ─────────────────────────── */
/* The read-only list view (.ar-table) is a cramped table on a phone. Turn each row into a card
   and label each value via the data-label run.js stamps on every <td>. Editable grids/matrix keep
   horizontal scroll (a card transform doesn't fit an editable spreadsheet). */
@media (max-width: 640px) {
  .ar-table-wrap { border: none; overflow: visible; }
  .ar-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ar-table, .ar-table tbody, .ar-table tr, .ar-table td { display: block; width: auto; }
  .ar-table tr {
    border: 1px solid var(--color-border); border-radius: 10px;
    margin-bottom: 10px; padding: 6px 12px; background: var(--color-surface);
  }
  .ar-table td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    padding: 7px 0; border: none; border-bottom: 1px solid var(--color-border-subtle); text-align: right;
  }
  .ar-table tr td:last-child { border-bottom: none; }
  .ar-table td::before {
    content: attr(data-label); flex: 0 0 auto; text-align: left;
    font-size: 12px; font-weight: 600; color: var(--color-text-muted);
  }

  /* Calendar (month grid) on a phone: 7 columns must fit the viewport. Denser cells + smaller
     type so a day with an event stays inside its column (with minmax(0,1fr) doing the shrinking). */
  .ar-cal-cell { min-height: 56px; padding: 2px; gap: 2px; }
  .ar-cal-dow { font-size: 10px; padding: 5px 0; }
  .ar-cal-daynum { font-size: 11px; padding: 0 3px; }
  .ar-cal-event { font-size: 10px; padding: 1px 4px; border-radius: 4px; }
  .ar-cal-event-app { display: none; } /* drop the source-app prefix on the unified calendar — no room */
}

/* ── markdown (Design 062 §3.1): viewer + WYSIWYG editor — theme tokens only ─── */
.ar-md { font-size: 14px; line-height: 1.6; color: var(--color-text); word-break: break-word; }
.ar-md > :first-child { margin-top: 0; }
.ar-md > :last-child { margin-bottom: 0; }
.ar-md h2 { font-size: 18px; font-weight: 700; margin: 18px 0 8px; }
.ar-md h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; }
.ar-md p { margin: 8px 0; }
.ar-md ul, .ar-md ol { margin: 8px 0; padding-left: 22px; }
.ar-md li { margin: 3px 0; }
.ar-md a { color: var(--color-accent); text-decoration: underline; }
.ar-md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em;
  background: var(--color-surface-alt); border: 1px solid var(--color-border-subtle);
  border-radius: 4px; padding: 1px 5px; }
.ar-md pre { background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: 8px; padding: 12px; overflow-x: auto; margin: 10px 0; }
.ar-md pre code { background: none; border: none; padding: 0; }
.ar-md blockquote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--color-accent);
  color: var(--color-text-muted); }
.ar-md-plain { white-space: pre-wrap; }

.ar-md-editor { display: flex; flex-direction: column; gap: 0;
  border: 1px solid var(--color-border); border-radius: 10px; overflow: hidden;
  background: var(--color-surface); }
.ar-md-editor:focus-within { border-color: var(--color-accent); box-shadow: var(--ring); }
.ar-md-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px;
  background: var(--color-surface-alt); border-bottom: 1px solid var(--color-border); }
.ar-md-tb-btn { font: inherit; font-size: 12px; font-weight: 600; min-width: 30px; height: 28px;
  padding: 0 8px; border: 1px solid transparent; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--color-text); transition: background .12s ease, border-color .12s ease; }
.ar-md-tb-btn:hover { background: var(--color-surface-hover); }
.ar-md-tb-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-md-tb-btn[aria-pressed="true"] { background: var(--color-accent-subtle); border-color: var(--color-accent); }
.ar-md-tb-btn:disabled { opacity: .45; cursor: default; }
.ar-md-toggle { margin-left: auto; }
.ar-md-surface { min-height: 140px; max-height: 460px; overflow-y: auto; padding: 12px 14px;
  font-size: 14px; line-height: 1.6; color: var(--color-text); outline: none; }
.ar-md-surface:focus { outline: none; }
/* Design 100 §2 — user_many member picker (attendees): chips + search + dropdown. */
.ar-usermany { position: relative; }
.ar-usermany-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-usermany-chips:empty { display: none; }
.ar-usermany-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border-radius: 6px; padding: 2px 4px 2px 8px; }
.ar-usermany-rm { border: none; background: none; color: inherit; cursor: pointer; font-size: 11px; padding: 0 2px; line-height: 1; }
.ar-usermany-input { margin-top: 6px; }
.ar-usermany-menu { position: absolute; left: 0; right: 0; z-index: 1100; margin-top: 2px; max-height: 220px; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px;
  box-shadow: 0 8px 30px color-mix(in srgb, var(--color-text) 18%, transparent); }
.ar-usermany-opt { padding: 8px 12px; font-size: 14px; cursor: pointer; color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-usermany-opt:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }

/* Design 099 — @mention chip + the @-autocomplete menu (token-only colours). */
.ar-mention { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border-radius: 4px; padding: 0 3px; font-weight: 600; white-space: nowrap; }
.ar-mention-menu { position: fixed; z-index: 1100; min-width: 200px; max-width: 320px; max-height: 240px;
  overflow-y: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px;
  box-shadow: 0 8px 30px color-mix(in srgb, var(--color-text) 18%, transparent); }
.ar-mention-opt { padding: 8px 12px; font-size: 14px; cursor: pointer; color: var(--color-text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.ar-mention-opt.is-sel, .ar-mention-opt:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.ar-md-surface h2 { font-size: 18px; font-weight: 700; margin: 14px 0 6px; }
.ar-md-surface h3 { font-size: 15px; font-weight: 700; margin: 12px 0 4px; }
.ar-md-surface ul, .ar-md-surface ol { padding-left: 22px; }
.ar-md-surface code { font-family: ui-monospace, Menlo, monospace; background: var(--color-surface-alt);
  border: 1px solid var(--color-border-subtle); border-radius: 4px; padding: 1px 5px; }
.ar-md-surface pre { background: var(--color-surface-alt); border: 1px solid var(--color-border);
  border-radius: 8px; padding: 12px; overflow-x: auto; }
.ar-md-surface blockquote { margin: 8px 0; padding: 2px 12px; border-left: 3px solid var(--color-accent);
  color: var(--color-text-muted); }
.ar-md-source { min-height: 140px; max-height: 460px; border: none; outline: none; resize: vertical;
  padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  background: var(--color-surface); color: var(--color-text); }

/* grid markdown cell — a compact button that opens the editor in a modal */
.ar-md-cell { text-align: left; cursor: pointer; background: var(--color-surface);
  color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-md-cell.ar-md-cell-empty { color: var(--color-text-muted); }
.ar-md-modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--color-text) 35%, transparent); }
.ar-md-modal { width: min(720px, 100%); max-height: 86vh; overflow: auto; display: flex;
  flex-direction: column; gap: 12px; padding: 18px; border-radius: 14px;
  background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--surface-glow); }
.ar-md-modal-title { font-size: 15px; font-weight: 700; color: var(--color-text); }
.ar-md-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── version history (Design 062 §9.5): list / diff / restore panel ──────────── */
/* All colour is THEME TOKENS so the panel + diff work in light AND dark; the diff
   add/remove highlight is derived from --color-green / --color-red via color-mix
   (never hard-coded), per AI_CONTEXT rule 2. */
.ar-history-modal { width: min(860px, 100%); }
.ar-history-body { display: flex; flex-direction: column; gap: 14px; }
.ar-history-hint, .ar-history-empty { font-size: 13px; color: var(--color-text-muted); }
.ar-history-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; border: 1px solid var(--color-border-subtle); background: var(--color-surface-alt); }
.ar-history-row + .ar-history-row { margin-top: 6px; }
.ar-history-check { flex: 0 0 auto; }
.ar-history-meta { flex: 1 1 auto; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--color-text); }
.ar-history-ver { font-weight: 700; }
.ar-history-kind { color: var(--color-accent); font-weight: 600; }
.ar-history-who { color: var(--color-text); }
.ar-history-when { color: var(--color-text-muted); }
.ar-history-diff { display: flex; flex-direction: column; gap: 10px; }
.ar-history-diff-head { font-size: 13px; font-weight: 700; color: var(--color-text); }
.ar-diff-fields { display: flex; flex-direction: column; gap: 12px; }
.ar-diff-field-label { font-size: 12px; font-weight: 700; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.ar-diff { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  border: 1px solid var(--color-border); border-radius: 9px; overflow: hidden; }
.ar-diff-line { display: flex; gap: 8px; padding: 1px 8px; white-space: pre-wrap; word-break: break-word; }
.ar-diff-gutter { flex: 0 0 14px; color: var(--color-text-muted); user-select: none; }
.ar-diff-text { flex: 1 1 auto; }
.ar-diff-same { color: var(--color-text); }
.ar-diff-add { background: color-mix(in srgb, var(--color-green) 16%, transparent); color: var(--color-text); }
.ar-diff-del { background: color-mix(in srgb, var(--color-red) 16%, transparent); color: var(--color-text); }
.ar-diff-scalar .ar-diff-add, .ar-diff-scalar .ar-diff-del { padding: 1px 6px; border-radius: 5px; }
.ar-diff-arrow { color: var(--color-text-muted); }

/* ── tree (Design 062 §3.2): indented collapsible hierarchy ─────────────────── */
.ar-tree { font-size: 14px; }
.ar-tree-list { list-style: none; margin: 0; padding: 0; }
.ar-tree-list .ar-tree-list { margin-left: 18px; border-left: 1px solid var(--color-border-subtle); padding-left: 4px; }
.ar-tree-row { display: flex; align-items: center; gap: 4px; border-radius: 7px; }
.ar-tree-row:hover { background: var(--color-surface-hover); }
.ar-tree-twisty { font: inherit; width: 22px; height: 26px; border: none; background: transparent;
  color: var(--color-text-muted); cursor: pointer; border-radius: 6px; flex: 0 0 auto; }
.ar-tree-twisty:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-tree-leaf { cursor: default; }
.ar-tree-label { font: inherit; flex: 1 1 auto; text-align: left; padding: 5px 6px; border: none;
  background: transparent; color: var(--color-text); cursor: pointer; border-radius: 6px; }
.ar-tree-label:hover { color: var(--color-accent); }
.ar-tree-label:focus-visible { outline: none; box-shadow: var(--ring); }
/* "+ sub" affordance (Design 062 §3.2 bonus): a quiet per-node button that opens the create
   form with the parent reference pre-filled. Hidden until the row is hovered/focused so it never
   clutters the tree; token-driven so it reads in light + dark. */
.ar-tree-addsub { font: inherit; width: 24px; height: 24px; flex: 0 0 auto; border: 1px solid transparent;
  background: transparent; color: var(--color-text-muted); cursor: pointer; border-radius: 6px;
  line-height: 1; opacity: 0; transition: opacity 120ms ease; }
.ar-tree-row:hover .ar-tree-addsub, .ar-tree-addsub:focus-visible { opacity: 1; }
.ar-tree-addsub:hover { color: var(--color-accent); border-color: var(--color-border); }
.ar-tree-addsub:focus-visible { outline: none; box-shadow: var(--ring); opacity: 1; }
/* current-page highlight (Design 073 §2.2): the "you are here" node in the pinned rail. */
.ar-tree-label.is-current { background: var(--color-accent-subtle); color: var(--color-accent); font-weight: 600; }
.ar-tree-label.is-current:hover { color: var(--color-accent); }

/* ── persistent tree-nav panel (Design 073): tree pinned left, content right ──── */
/* A second pinned rail between the model nav and the content area, shown only for a
   self-referencing (hierarchical) model. Token-driven (light + dark); collapses to an
   overlay drawer on mobile. Empty/hidden by default ⇒ a flat app's shell is unchanged. */
.ar-tree-nav {
  width: 248px; flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 12px 10px; overflow-y: auto;
}
.ar-tree-nav[hidden] { display: none; }
.ar-tree-nav-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 2px 4px 10px;
}
.ar-tree-nav-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted); font-weight: 600;
}
.ar-tree-nav-empty { color: var(--color-text-muted); font-size: 13px; padding: 6px 4px; }
/* compact rows for the rail (denser than the content-area tree view). */
.ar-tree-compact { font-size: 13px; }
.ar-tree-compact .ar-tree-label { padding: 4px 6px; }
.ar-tree-compact .ar-tree-twisty { height: 24px; }

/* reference_many (Design 062 §3.4a): the multi-select picker — theme-token styled, sized so a
   few options are visible without dominating the form. */
.ar-select-multi { min-height: 84px; padding: 4px; }
.ar-select-multi option { padding: 3px 6px; border-radius: 4px; }

/* reference picker states (the empty-dropdown fix): the loading / empty / error status row a
   reference / reference_many picker shows so it is NEVER an unexplained blank box. Token-driven
   (muted text), works light + dark. The empty/error select border is tinted to draw the eye. */
.ar-ref-status { color: var(--color-text-muted); font-style: italic; }
.ar-select.is-empty, .ar-select-multi.is-empty { border-style: dashed; }
.ar-select.is-error, .ar-select-multi.is-error { border-color: var(--color-red); }

/* matrix (Design 062 §3.3): a sticky-header traceability grid. All colours are theme tokens
   so it works in light AND dark; coverage gaps use the red token (never a hard-coded colour). */
.ar-matrix-wrap { overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius); max-height: 70vh; }
.ar-matrix-table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.ar-matrix-table th, .ar-matrix-table td { border-right: 1px solid var(--color-border-subtle); border-bottom: 1px solid var(--color-border-subtle); }
.ar-matrix-corner { position: sticky; left: 0; top: 0; z-index: 3; background: var(--color-surface-alt);
  color: var(--color-text-muted); font-weight: 600; text-align: left; padding: 8px 10px; min-width: 160px; }
.ar-matrix-colhead { position: sticky; top: 0; z-index: 2; background: var(--color-surface-alt);
  padding: 6px; vertical-align: bottom; max-width: 130px; }
.ar-matrix-collabel, .ar-matrix-rowlabel { font: inherit; border: none; background: transparent; color: var(--color-text);
  cursor: pointer; padding: 2px 4px; border-radius: 5px; text-align: left; max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.ar-matrix-collabel:hover, .ar-matrix-rowlabel:hover { color: var(--color-accent); }
.ar-matrix-collabel:focus-visible, .ar-matrix-rowlabel:focus-visible { outline: none; box-shadow: var(--ring); }
.ar-matrix-rowhead { position: sticky; left: 0; z-index: 1; background: var(--color-surface);
  padding: 4px 10px; text-align: left; font-weight: 500; white-space: nowrap; }
.ar-matrix-cell { text-align: center; padding: 4px 8px; min-width: 30px; }
.ar-matrix-on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent);
  font-weight: 600; cursor: pointer; }
.ar-matrix-on:hover { background: color-mix(in srgb, var(--color-accent) 28%, transparent); }
.ar-matrix-empty { background: transparent; }
.ar-matrix-gap { color: var(--color-red); }
.ar-matrix-gap-flag { color: var(--color-red); margin-left: 4px; }
.ar-matrix-rowgap .ar-matrix-rowhead { color: var(--color-red); }

.ar-w-markdown .ar-md { padding: 2px 0; }

@media (prefers-reduced-motion: reduce) {
  .ar-md-tb-btn { transition: none; }
}

/* ── CSV import (Design 113) ─────────────────────────────────────────────────── */
.ar-import { max-width: 860px; }
.ar-import-help { color: var(--color-text-muted); font-size: 14px; margin: 0 0 12px; }
.ar-import-help--warn { color: var(--color-text); border-left: 3px solid var(--color-accent); padding-left: 10px; }
.ar-import-pick { padding: 16px; border: 1px dashed var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-alt); margin-bottom: 20px; }
.ar-import-pick .ar-input { background: var(--color-surface); }
.ar-import-stat { color: var(--color-text-muted); font-size: 13px; margin: 8px 0; }
.ar-import-warn { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--color-warning-bg, #fff4e5); color: var(--color-warning-text, #8a5300); font-size: 13px; margin: 10px 0; border: 1px solid var(--color-border); }
.ar-import-h { font-size: 15px; margin: 24px 0 10px; }
.ar-import-map, .ar-import-preview, .ar-import-errors { width: 100%; border-collapse: collapse; font-size: 13px; }
.ar-import-map th, .ar-import-preview th, .ar-import-errors th { text-align: left; color: var(--color-text-muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--color-border); }
.ar-import-map td, .ar-import-preview td, .ar-import-errors td { padding: 6px 10px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.ar-import-map td .ar-select { width: 100%; }
.ar-import-sample { color: var(--color-text-muted); }
.ar-import-preview { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.ar-import-opts { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.ar-import-opt { display: grid; grid-template-columns: 200px auto; gap: 4px 12px; align-items: center; }
.ar-import-opt--check { grid-template-columns: auto 1fr; }
.ar-import-opt .ar-select { max-width: 280px; }
.ar-import-hint { grid-column: 1 / -1; color: var(--color-text-muted); font-size: 12px; }
.ar-import-opt--check .ar-import-hint { grid-column: 2; }
.ar-import-actions { display: flex; gap: 10px; margin: 24px 0; align-items: center; flex-wrap: wrap; }
.ar-import-tallies { display: flex; gap: 14px; margin: 8px 0 4px; flex-wrap: wrap; }
.ar-import-tally { display: flex; flex-direction: column; padding: 12px 18px; border-radius: var(--radius-md); background: var(--color-surface-alt); border: 1px solid var(--color-border); min-width: 96px; }
.ar-import-tally strong { font-size: 22px; }
.ar-import-tally span { color: var(--color-text-muted); font-size: 12px; }
.ar-import-tally--ok strong { color: var(--color-success-text, #18794e); }
.ar-import-tally--err strong { color: var(--color-danger-text, #cd2b31); }
.ar-import-errors td:first-child { white-space: nowrap; color: var(--color-text-muted); }

/* ── Design 161 — the "Meetings" card on a record detail (past captures, re-openable) ── */
.ar-meetings-card { display: flex; flex-direction: column; gap: 4px; }
.ar-meeting-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  background: none; border: 0; border-radius: 8px; padding: 7px 8px; cursor: pointer; text-align: left;
  color: var(--color-text); font-family: inherit; }
.ar-meeting-row:hover { background: var(--color-surface-hover); }
.ar-meeting-t { font-size: 13px; font-weight: 600; }
.ar-meeting-m { font-size: 11px; color: var(--color-text-muted); }

/* Design 173 §9.2 — richemail email-body editor (basic, extensible) */
.ar-w-richemail { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 720px) { .ar-w-richemail { grid-template-columns: 1fr; } }
/* Design 173 §9.3 — segment builder */
.ar-w-segbuilder { display: flex; flex-direction: column; gap: 8px; }
.ar-w-segbuilder-rows { display: flex; flex-direction: column; gap: 6px; }
.ar-w-segbuilder-row { display: flex; gap: 6px; align-items: center; }
.ar-w-segbuilder-row .ar-input { flex: 1; }
.ar-w-segbuilder-count { padding: 8px 0; font-size: 0.95rem; }
.ar-w-segbuilder-ai { display: flex; gap: 6px; margin-top: 6px; }
.ar-w-segbuilder-ai .ar-input { flex: 1; }
.ar-w-richemail-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ar-w-richemail-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.ar-w-richemail-block { border: 1px solid var(--color-border); border-radius: 8px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.ar-w-richemail-block-head { display: flex; align-items: center; gap: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.ar-w-richemail-block-head .ar-iconbtn { margin-left: 4px; }
.ar-w-richemail-block-head .ar-iconbtn:first-of-type { margin-left: auto; }
.ar-w-richemail-text { width: 100%; font-family: inherit; font-size: 14px; padding: 8px; border: 1px solid var(--color-border); border-radius: 6px; resize: vertical; }
.ar-w-richemail-preview-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); margin-bottom: 6px; }
.ar-w-richemail-preview-frame { width: 100%; min-height: 320px; border: 1px solid var(--color-border); border-radius: 8px; background: #fff; }

/* Design 173 §9.3/§9.4 — segment source picker + campaign preview */
.ar-w-segbuilder-srcrow { display:flex; align-items:center; gap:6px; margin:0 0 8px; }
.ar-w-cp-subject { font-weight:600; margin:0 0 4px; }
.ar-w-cp-count { margin:0 0 8px; }
.ar-w-cp-checklist { list-style:none; padding:0; margin:0 0 12px; display:flex; flex-direction:column; gap:2px; }
.ar-w-cp-checklist .is-ok { color:#15803d; }
.ar-w-cp-checklist .is-bad { color:#b91c1c; }
.ar-w-cp-frame { width:100%; max-width:620px; height:480px; border:1px solid var(--ar-border,#e5e7eb); border-radius:8px; background:#fff; }
.ar-w-cp-send { margin-top:10px; display:flex; align-items:center; gap:8px; }
.ar-w-cp-send button[disabled] { opacity:.5; cursor:not-allowed; }

/* Design 174 §2.5 — read-only email-activity feed on a lead (Tier 1) */
.ar-w-activitylog-list { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:4px; }
.ar-w-activitylog-row { display:flex; flex-wrap:wrap; align-items:baseline; gap:2px; padding:4px 0; border-bottom:1px solid var(--color-border,#e5e7eb); }
.ar-w-activitylog-label { font-weight:600; }

/* Design 174 §3 — 1:1 compose box on a lead (Tier 2) */
.ar-w-sendemail { display:flex; flex-direction:column; gap:8px; }
.ar-w-sendemail-to { padding-bottom:2px; }
.ar-w-sendemail-body { width:100%; font-family:inherit; font-size:14px; padding:8px; border:1px solid var(--color-border,#e5e7eb); border-radius:6px; resize:vertical; }
.ar-w-sendemail-chips { display:flex; flex-wrap:wrap; gap:6px; }
.ar-w-sendemail-actions { display:flex; align-items:center; gap:8px; }
.ar-w-sendemail-actions button[disabled] { opacity:.5; cursor:not-allowed; }
