@layer tokens, base, ui, shell, surface;
@layer ui {
  /* The shared components (docs/signal.md): what client/ui/*.js builds, and the few generic classes every
     place shares. Recipes come from tokens.css; nothing here knows which shell or surface it's in. */

  /* ---- buttons (ui/button.js) ------------------------------------------------------------------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
    height: var(--h-md); padding: 0 11px; border-radius: var(--r-md);
    background: var(--s-glass); box-shadow: var(--e-raise); color: var(--color-ink);
    font-size: 12.5px; font-weight: 500; white-space: nowrap;
    transition: background var(--d) var(--ease), box-shadow var(--d) var(--ease), color var(--d) var(--ease), transform var(--d-fast) var(--ease);
  }
  .btn:hover { background: var(--s-spot), var(--s-glass-strong); }
  .btn:active { transform: scale(var(--press)); }
  .btn svg { width: 15px; height: 15px; }
  .btn .kbd { margin-left: 2px; margin-right: -4px; }
  .btn:is(.btn--primary, .btn--act) { background: var(--color-accent-fill); color: var(--color-on-accent); box-shadow: var(--s-act-rim); }
  .btn:is(.btn--primary, .btn--act):hover { background: var(--s-spot-lit), var(--color-accent-fill); }
  .btn:is(.btn--primary, .btn--act) .kbd { background: rgba(255, 255, 255, 0.18); box-shadow: none; color: inherit; }
  .btn--tonal { background: var(--s-tint-2); box-shadow: none; }
  .btn--tonal:hover { background: var(--s-spot), var(--s-tint-3); }
  .btn:is(.btn--quiet, .btn--ghost) { background: none; box-shadow: none; color: var(--color-ink-secondary); }
  .btn:is(.btn--quiet, .btn--ghost):hover { background: var(--s-spot), var(--s-tint-2); color: var(--color-ink); }
  .btn--danger { background: var(--color-danger); color: var(--color-on-danger); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 0 1px color-mix(in srgb, var(--color-danger) 70%, black); }
  .btn--danger:hover { background: var(--s-spot-lit), var(--color-danger-hover); }
  .btn--sm { height: 24px; padding: 0 9px; font-size: 12px; border-radius: var(--r-sm); }
  .btn--xs { height: 20px; padding: 0 7px; gap: 4px; font-size: 11.5px; border-radius: var(--r-sm); }
  .btn--xs svg { width: 12px; height: 12px; }
  .btn--icon { width: var(--h-md); padding: 0; }
  .btn--full { width: 100%; }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

  .icon-btn {
    display: inline-grid; place-items: center; flex: none;
    width: var(--h-md); height: var(--h-md); border-radius: var(--r-md);
    color: var(--color-ink-secondary);
    transition: background var(--d) var(--ease), color var(--d) var(--ease);
  }
  .icon-btn:hover, .icon-btn.is-on, .icon-btn.is-open, .icon-btn[aria-pressed="true"] { background: var(--s-spot), var(--s-tint-2); color: var(--color-ink); }
  .icon-btn svg { width: 16px; height: 16px; }
  .icon-btn--danger:hover { color: var(--color-danger); }
  .icon-btn:disabled { opacity: 0.4; pointer-events: none; }

  /* ---- fields (ui/field.js) --------------------------------------------------------------------- */
  .field { display: grid; gap: 5px; min-width: 0; }
  .field__label { font-size: var(--t-12); font-weight: 500; color: var(--color-ink-secondary); }
  .input, select.input, textarea.input {
    width: 100%; min-width: 0; height: var(--h-lg); padding: 0 10px;
    border: 0; border-radius: var(--r-lg);
    background: var(--field-paint, var(--s-tint-2)); box-shadow: var(--field-shadow, none);
    color: var(--color-ink); font-size: var(--t-13); outline: none;
    transition: background var(--d) var(--ease), box-shadow var(--d) var(--ease);
  }
  .input.input--xs { height: var(--h-sm); padding: 0 7px; border-radius: var(--r-sm); font-size: var(--t-12); }
  textarea.input { height: auto; min-height: 72px; padding: 8px 10px; line-height: var(--lh); resize: vertical; }
  .input:hover { background: var(--field-paint, var(--s-tint-3)); }
  .input:focus, .input:focus-visible { background: var(--field-paint, var(--s-glass-strong)); box-shadow: var(--field-shadow, var(--e-focus)); outline: none; }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--color-accent-fill); }

  .search {
    display: flex; align-items: center; gap: 7px; min-width: 0;
    height: var(--h-lg); padding: 0 6px 0 9px; border-radius: var(--r-lg);
    background: var(--field-paint, var(--s-tint-2)); box-shadow: var(--field-shadow, none); color: var(--color-ink-faint);
    transition: background var(--d) var(--ease), box-shadow var(--d) var(--ease);
  }
  .search:focus-within { background: var(--field-paint, var(--s-glass-strong)); box-shadow: var(--field-shadow, var(--e-focus)); }
  .search > svg { width: 14px; height: 14px; }
  .search__input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--color-ink); font-size: var(--t-13); outline: none; }
  .search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
  .search .kbd { flex: none; }

  /* ---- segmented (ui/seg.js) -------------------------------------------------------------------- */
  .seg { display: inline-flex; flex: none; gap: 2px; padding: 2px; border-radius: var(--r-lg); background: var(--s-tint-2); }
  .seg > button {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    height: 24px; padding: 0 10px; border-radius: var(--r-sm);
    font-size: var(--t-12); font-weight: 500; color: var(--color-ink-faint); white-space: nowrap;
    transition: background var(--d) var(--ease), color var(--d) var(--ease), box-shadow var(--d) var(--ease);
  }
  .seg > button:hover { color: var(--color-ink); }
  .seg > button:is(.is-on, [aria-checked="true"], [aria-pressed="true"]) { background: var(--color-surface-raised); color: var(--color-ink); box-shadow: var(--e-raise); }
  .seg > button svg { width: 14px; height: 14px; }
  .seg--xs > button { height: 20px; padding: 0 7px; font-size: 11.5px; }
  .seg--full { display: flex; } .seg--full > button { flex: 1; }

  /* The level (ui/seg.js levels): "Low ▾", a menu of three. */
  .chat__levels {
    display: inline-flex; align-items: center; gap: 2px; flex: none;
    height: var(--h-sm); padding: 0 5px 0 7px; border-radius: var(--r-sm);
    font-size: 11.5px; font-weight: 500; color: var(--color-ink-faint);
    transition: background var(--d) var(--ease), color var(--d) var(--ease);
  }
  .chat__levels:hover, .chat__levels.is-open { background: var(--s-tint-2); color: var(--color-ink); }
  .chat__levels svg { width: 11px; height: 11px; }
  .chat__levels:disabled { opacity: 0.5; }

  /* ---- keys ------------------------------------------------------------------------------------- */
  .kbd {
    display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: var(--r-xs); background: var(--s-tint-2); box-shadow: inset 0 -1px 0 var(--s-edge);
    font: 500 var(--t-10) / 1 var(--font-mono); color: var(--color-ink-secondary); letter-spacing: 0; white-space: nowrap;
  }

  /* ---- floating layers: popover, menu (ui/menu.js) ---------------------------------------------- */
  .popover {
    position: fixed; z-index: var(--z-popover); min-width: 190px; max-width: min(340px, calc(100vw - 16px));
    max-height: min(480px, calc(100vh - 16px)); overflow: auto; overscroll-behavior: contain;
    padding: 5px; border-radius: var(--r-xl);
    background: var(--s-float); -webkit-backdrop-filter: var(--s-blur); backdrop-filter: var(--s-blur); box-shadow: var(--e-pop);
    transition: opacity var(--d) var(--ease), transform var(--d-slow) var(--ease);
  }
  .popover.is-enter { opacity: 0; transform: translateY(calc(-1 * var(--rise))) scale(0.985); }
  .popover.is-enter[data-side="above"] { transform: translateY(var(--rise)) scale(0.985); }
  .popover.is-enter[data-side="beside"] { transform: translateX(calc(-1 * var(--rise))) scale(0.985); }
  .popover.is-leave { opacity: 0; transition-duration: var(--d-fast); pointer-events: none; }
  .menu { display: grid; gap: 1px; }
  .menu__label { padding: 7px 8px 3px; font-size: 11px; font-weight: 500; color: var(--color-ink-faint); }
  .menu__item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
    min-height: 30px; padding: 4px 8px; border-radius: var(--r-md);
    font-size: var(--t-13); color: var(--color-ink); text-align: left;
  }
  .menu__item > span:first-child { display: flex; align-items: center; gap: 9px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu__item > span:first-child svg { width: 15px; height: 15px; color: var(--color-ink-secondary); }
  .menu__item:is(:hover, :focus-visible) { background: var(--s-tint-2); outline: none; }
  .menu__item[aria-checked="true"] { font-weight: 500; }
  .menu__item--danger, .menu__item--danger > span:first-child svg { color: var(--color-danger); }
  .menu__item-hint { display: inline-flex; align-items: center; gap: 3px; flex: none; font-size: 11.5px; color: var(--color-ink-faint); font-variant-numeric: tabular-nums; }
  .menu__item-hint svg { width: 14px; height: 14px; color: var(--color-ink); }
  .menu__swatch { flex: none; width: 15px; height: 15px; border-radius: 4px; background: var(--swatch); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-ink) 18%, transparent); }
  .menu__sep { height: 1px; margin: 4px 6px; background: var(--s-edge); }
  .menu__empty { padding: 12px 10px; font-size: var(--t-12); color: var(--color-ink-faint); }

  /* @ mentions in the composer (ui/composer.js) */
  .mention-menu {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: var(--z-popover);
    display: grid; gap: 1px; padding: 5px; border-radius: var(--r-xl);
    background: var(--s-float); -webkit-backdrop-filter: var(--s-blur); backdrop-filter: var(--s-blur); box-shadow: var(--e-pop);
    animation: sg-drop var(--d) var(--ease);
  }
  .mention-menu__item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; padding: 4px 8px; border-radius: var(--r-md); font-size: var(--t-13); text-align: left; }
  .mention-menu__item > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mention-menu__item:hover, .mention-menu__item[aria-selected="true"] { background: var(--s-tint-2); }
  .mention-menu__type { flex: none; font-size: 11.5px; color: var(--color-ink-faint); }

  /* ---- themes (ui/themes.js): Settings → Profile and appearance, and the extension's This browser ---- */
  .profile__themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .profile__theme {
    display: flex; align-items: center; gap: 10px; min-width: 0; height: 40px; padding: 0 10px 0 8px; border-radius: var(--r-lg);
    background: var(--s-glass); box-shadow: var(--e-flat); font-size: 12.5px; font-weight: 500; color: var(--color-ink-secondary); text-align: left;
    transition: background var(--d) var(--ease), box-shadow var(--d) var(--ease), color var(--d) var(--ease);
  }
  .profile__theme:hover { background: var(--s-spot), var(--s-glass-strong); color: var(--color-ink); }
  .profile__theme.is-selected { background: var(--s-glass-strong); color: var(--color-ink); box-shadow: var(--s-hi), 0 0 0 1px color-mix(in srgb, var(--color-accent-fill) 60%, transparent); }
  /* A theme's own swatch: its desk, its face, its raised surface and its act. These paint other themes,
     so they're the themes' literal colours (tokens.css), not this theme's tokens. */
  .profile__theme-preview {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; flex: none; width: 30px; height: 22px; padding: 3px;
    border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px var(--s-edge);
  }
  .profile__theme-preview i { display: block; border-radius: 2px; }
  .profile__theme-preview i:nth-child(1) { background: var(--pv-face); }
  .profile__theme-preview i:nth-child(2) { background: var(--pv-raised); }
  .profile__theme-preview i:nth-child(3) { background: var(--pv-act); }
  .profile__theme-preview--signal-dawn { background: linear-gradient(160deg, #cfd9e0, #eaeff4); --pv-face: rgba(249, 250, 251, 0.78); --pv-raised: #fff; --pv-act: #1a1d21; }
  .profile__theme-preview--signal-day { background: linear-gradient(160deg, #f0f4f7, #fafcfe); --pv-face: rgba(249, 250, 251, 0.78); --pv-raised: #fff; --pv-act: #1a1d21; }
  .profile__theme-preview--signal-dusk { background: linear-gradient(160deg, #3d434d, #727c85); --pv-face: rgba(37, 41, 46, 0.8); --pv-raised: #43484e; --pv-act: #e3e5e7; }
  .profile__theme-preview--signal-night { background: linear-gradient(160deg, #06090e, #151b22); --pv-face: rgba(37, 41, 46, 0.8); --pv-raised: #43484e; --pv-act: #e3e5e7; }
  .profile__theme-preview--orbit-dawn { background: linear-gradient(160deg, #7485da, #9bbeff, #d8eafe); --pv-face: rgba(248, 250, 255, 0.78); --pv-raised: #fff; --pv-act: #0c1b3c; }
  .profile__theme-preview--orbit-day { background: linear-gradient(160deg, #c7d7fd, #e1ecff, #f7faff); --pv-face: rgba(248, 250, 255, 0.78); --pv-raised: #fff; --pv-act: #0c1b3c; }
  .profile__theme-preview--orbit-dusk { background: linear-gradient(160deg, #092661, #39489e, #7b73ca); --pv-face: rgba(18, 38, 82, 0.8); --pv-raised: #304675; --pv-act: #dce5f6; }
  .profile__theme-preview--orbit-night { background: linear-gradient(160deg, #020b1c, #08183b, #202d65); --pv-face: rgba(18, 38, 82, 0.8); --pv-raised: #304675; --pv-act: #dce5f6; }
  .profile__theme-preview--millennium { background: linear-gradient(#3d7fe6 55%, #5aa232 55%); --pv-face: #ece9d8; --pv-raised: #0b58e0; --pv-act: #3fa22c; }
  .profile__theme-preview--retro { background: #008080; --pv-face: #c0c0c0; --pv-raised: #000080; --pv-act: #808080; }

  /* ---- dialogs (ui/dialog.js, ui/report.js) ----------------------------------------------------- */
  .dialog-overlay {
    position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: 20px;
    background: color-mix(in srgb, var(--color-bg) 45%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    animation: sg-fade var(--d) var(--ease);
  }
  .dialog {
    display: grid; gap: 12px; width: min(420px, 100%); max-height: calc(100vh - 40px); overflow: auto;
    padding: 18px; border-radius: var(--r-2xl);
    background: var(--s-float); -webkit-backdrop-filter: var(--s-blur); backdrop-filter: var(--s-blur); box-shadow: var(--e-modal);
    animation: sg-rise var(--d-slow) var(--ease);
  }
  .dialog--wide { width: min(620px, 100%); }
  .dialog-overlay.is-leave { opacity: 0; transition: opacity var(--d-fast) var(--ease-out); }
  /* Find anything as a modal (shells/finder.js): the Find sheet (surfaces/find/find.css) over a light scrim. */
  .gf-modal {
    position: fixed; inset: 0; z-index: var(--z-overlay); display: flex;
    background: color-mix(in srgb, var(--color-bg) 35%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    animation: sg-fade var(--d) var(--ease);
  }
  .gf-modal.is-leave { opacity: 0; transition: opacity var(--d-fast) var(--ease-out); }
  .gf-modal__host { display: flex; flex: 1 1 auto; min-width: 0; min-height: 0; }
  .dialog__title { font: var(--w-title) var(--t-16) / var(--lh-tight) var(--font-display); letter-spacing: var(--track-display); }
  .dialog__body { font-size: var(--t-13); line-height: var(--lh); color: var(--color-ink-secondary); }
  .dialog__body--warn { color: var(--color-measure-text); }
  .dialog__section { display: grid; gap: 6px; padding-top: 10px; box-shadow: 0 -1px 0 var(--s-edge); }
  .dialog__section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .dialog__section-label, .dialog__hint { font-size: var(--t-12); color: var(--color-ink-faint); }
  .dialog__field { display: grid; gap: 5px; }
  .dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
  .report__reasons { display: grid; gap: 2px; }
  .report__reason { display: flex; align-items: center; gap: 9px; min-height: 30px; padding: 0 8px; border-radius: var(--r-md); font-size: var(--t-13); cursor: pointer; }
  .report__reason:hover { background: var(--s-tint-2); }
  .report__err:empty { display: none; }
  .report__err { color: var(--color-danger); }

  /* ---- sheets: the phone's overlay (ui/sheet.js) ------------------------------------------------ */
  .mk-sheet-layer { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; flex-direction: column; justify-content: flex-end; }
  .mk-scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--color-bg) 40%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: sg-fade var(--d) var(--ease); }
  .mk-sheet {
    position: relative; display: flex; flex-direction: column; max-height: 88vh; min-height: 30vh;
    padding-bottom: env(safe-area-inset-bottom); border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    background: var(--s-float); -webkit-backdrop-filter: var(--s-blur); backdrop-filter: var(--s-blur); box-shadow: var(--e-modal);
    animation: sg-sheet var(--d-panel) var(--ease); outline: none;
  }
  .mk-sheet.is-full { height: calc(100vh - env(safe-area-inset-top) - 12px); max-height: none; }
  .mk-sheet__grab { display: grid; place-items: center; height: 18px; flex: none; touch-action: none; cursor: grab; }
  .mk-sheet__grab::before { content: ""; width: 36px; height: 4px; border-radius: var(--r-round); background: var(--s-tint-4); }
  .mk-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 10px 8px 16px; flex: none; }
  .mk-sheet__title { font: var(--w-title) 17px / var(--lh-tight) var(--font-display); letter-spacing: var(--track-display); }
  .mk-sheet__body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }

  /* ---- toasts (ui/toast.js) and tooltips (ui/signal.js) ----------------------------------------- */
  .gx-toast {
    position: absolute; left: 50%; bottom: 16px; z-index: var(--z-toast); display: flex; align-items: center; gap: 10px;
    max-width: calc(100% - 32px); min-height: 34px; padding: 7px 12px; border-radius: var(--r-lg);
    background: var(--s-float); -webkit-backdrop-filter: var(--s-blur); backdrop-filter: var(--s-blur); box-shadow: var(--e-pop);
    font-size: 12.5px; color: var(--color-ink);
    opacity: 0; transform: translate(-50%, var(--rise)); pointer-events: none;
    transition: opacity var(--d) var(--ease), transform var(--d-slow) var(--ease);
  }
  .gx-toast.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
  .sg-tip {
    position: fixed; z-index: var(--z-tip); display: flex; align-items: center; gap: 7px; max-width: 280px;
    padding: 4px 8px; border-radius: var(--r-md); background: var(--color-ink); color: var(--color-bg);
    font-size: 11.5px; font-weight: 500; line-height: 1.35; box-shadow: 0 6px 16px var(--color-shadow-strong);
    pointer-events: none; opacity: 0; transform: translateY(2px);
    transition: opacity var(--d-fast) var(--ease), transform var(--d) var(--ease);
  }
  .sg-tip.is-on { opacity: 1; transform: none; }
  .sg-tip .kbd { margin-right: -4px; background: color-mix(in srgb, var(--color-bg) 18%, transparent); box-shadow: none; color: inherit; }

  /* ---- pills: things in the tank (ui/pill.js) --------------------------------------------------- */
  .pill {
    --pill-dot: transparent;
    display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%;
    height: 19px; padding: 0 6px; margin: 0 1px; border-radius: var(--r-sm);
    background: var(--s-tint-2); color: var(--color-ink);
    font-size: var(--t-12); font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: 1px;
    transition: background var(--d) var(--ease);
  }
  .pill::before { content: ""; display: none; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--pill-dot); }
  .pill:is(.pill--card, .pill--highlight, .pill--latent, .pill--view, .pill--app, .pill--folder, .pill--group, .pill--canvas, .pill--element, .pill--asset, [data-job-state])::before { display: block; }
  .pill__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pill svg { width: 12px; height: 12px; color: var(--color-ink-secondary); }
  .pill--card { --pill-dot: var(--entity-card); }
  .pill--highlight, .pill--latent { --pill-dot: var(--entity-highlight); }
  .pill--view { --pill-dot: var(--entity-view); }
  .pill--app { --pill-dot: var(--entity-app); }
  .pill--folder, .pill--group { --pill-dot: var(--kind-folder); }
  .pill--canvas, .pill--element { --pill-dot: var(--entity-comp); }
  .pill--asset { --pill-dot: var(--color-ink-faint); }
  .pill--latent, .pill--asset, .pill--more { background: none; box-shadow: inset 0 0 0 1px var(--s-edge-2); }
  .pill--coord { font-family: var(--font-mono); font-weight: 400; }
  .pill--more { color: var(--color-ink-faint); }
  .pill--nav { cursor: pointer; max-width: 50ch; }
  .pill--nav:hover { background: var(--s-tint-4); }
  .pill--stale { opacity: 0.45; text-decoration: line-through; }
  .pill--stale.pill--nav { cursor: default; }
  .pill--busy { animation: sg-breathe 1.2s ease-in-out infinite; }
  .pill[data-job-state="running"]::before { background: var(--s-live); animation: sg-breathe 1.6s ease-in-out infinite; }
  .pill[data-job-state="failed"] { color: var(--color-danger); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-danger) 35%, transparent); }
  :is(.msg-ai__text, .msg-user) .pill:not(.pill--quote) { font-size: 0.88em; }
  /* A quoted part reads as underlined words in the sentence, not a box. */
  .pill.pill--quote { display: inline; height: auto; padding: 0; margin: 0; background: none; box-shadow: none; font: inherit; white-space: normal; overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer; vertical-align: baseline; }
  .pill.pill--quote::before { display: none; }
  .pill.pill--quote:hover { text-decoration-color: currentColor; }
  .pill.pill--quote .pill__text { overflow: visible; white-space: normal; }

  /* ---- generic Signal pieces surfaces share ----------------------------------------------------- */
  /* A glass card: tiles, wells you act in, result cards. */
  .sg-card { border-radius: var(--r-xl); background: var(--s-glass); box-shadow: var(--e-flat); }
  /* A section label: sentence case, small, faint (never mono capitals). */
  .sg-label, .gx-eyebrow { font-size: 11.5px; font-weight: 500; letter-spacing: 0; color: var(--color-ink-faint); }
  /* A number that changes. */
  .sg-count { font: 500 11px var(--font-mono); color: var(--color-ink-faint); font-variant-numeric: tabular-nums; letter-spacing: 0; }
  /* A chip: a small tinted label or filter; --line is outlined. */
  .sg-chip {
    display: inline-flex; align-items: center; gap: 5px; flex: none; height: var(--h-sm); padding: 0 7px; border-radius: var(--r-sm);
    background: var(--s-tint-2); font-size: 11.5px; font-weight: 500; color: var(--color-ink-secondary); white-space: nowrap;
  }
  .sg-chip svg { width: 12px; height: 12px; }
  button.sg-chip:hover, .sg-chip.is-on { background: var(--s-spot), var(--s-tint-3); color: var(--color-ink); }
  .sg-chip--line { background: none; box-shadow: inset 0 0 0 1px var(--s-edge-2); }
  /* Status pies, Linear style: data-st = idle | live | needs | failed | done. */
  .sg-st { --p: 90deg; display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--color-ink-faint); }
  .sg-st[data-st="live"] { box-shadow: inset 0 0 0 1.5px var(--s-live); background: conic-gradient(var(--s-live) var(--p), transparent 0) center / 6px 6px no-repeat; border-radius: 50%; animation: sg-pie 2.4s linear infinite; }
  .sg-st[data-st="needs"] { box-shadow: inset 0 0 0 1.5px var(--color-measure); background: radial-gradient(circle, var(--color-measure) 2.5px, transparent 3px); }
  .sg-st[data-st="failed"] { box-shadow: inset 0 0 0 1.5px var(--color-danger); background: linear-gradient(45deg, transparent 44%, var(--color-danger) 44% 56%, transparent 56%) center / 6px 6px no-repeat, linear-gradient(-45deg, transparent 44%, var(--color-danger) 44% 56%, transparent 56%) center / 6px 6px no-repeat; }
  .sg-st[data-st="done"] { background: var(--s-live); box-shadow: none; -webkit-mask: radial-gradient(circle, #000 70%, transparent 71%); }
  /* A live dot: Geist working on this, now. */
  .sg-live { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--s-live); box-shadow: 0 0 6px var(--s-live); animation: sg-breathe 1.6s ease-in-out infinite; }

  /* ---- rows (ui/row.js) ------------------------------------------------------------------------- */
  .row {
    display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0;
    min-height: 30px; padding: 4px 8px; border-radius: var(--r-md); text-align: left; color: var(--color-ink);
    transition: background var(--d) var(--ease);
  }
  button.row:hover, a.row:hover { background: var(--s-spot), var(--s-tint-2); }
  .row.is-on { background: var(--s-tint-3); }
  .row__glyph, .gx-glyph { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; color: var(--kind, var(--color-ink-secondary)); }
  .row__glyph svg { width: 15px; height: 15px; }
  .row__main { display: flex; align-items: baseline; gap: 7px; flex: 1; min-width: 0; }
  .row__title, .row__sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row__title { font-weight: 500; flex: none; max-width: 100%; }
  .row__sub { flex: 1; font-size: var(--t-12); color: var(--color-ink-faint); }
  .row__meta { flex: none; font-size: 11.5px; color: var(--color-ink-faint); font-variant-numeric: tabular-nums; }

  /* ---- avatars (ui/avatar.js) ------------------------------------------------------------------- */
  .avatar {
    display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; overflow: hidden;
    border-radius: 50%; background: var(--s-tint-3); color: var(--color-ink);
    font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: uppercase;
  }
  .avatar img, .gx-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .gx-avatar { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; overflow: hidden; border-radius: var(--r-sm); background: var(--color-ink); color: var(--color-bg); font-size: 10px; font-weight: 600; }

  /* ---- empty states (ui/empty.js) and placeholders ---------------------------------------------- */
  .empty, .empty-hint, .surface-empty { font-size: var(--t-13); color: var(--color-ink-faint); }
  .empty { display: grid; justify-items: start; gap: 6px; padding: 16px 0; }
  .empty__title { font-weight: 500; color: var(--color-ink-secondary); }
  .surface-empty { display: grid; place-content: center; height: 100%; min-height: 200px; padding: 24px; text-align: center; }
  .surface-error { padding: 24px; font-size: var(--t-13); color: var(--color-danger); }
  .plate-empty { display: flex; flex: 1; align-items: center; justify-content: center; min-height: 240px; padding: 32px 22px; }
  .plate-empty__body { display: grid; justify-items: center; max-width: 320px; text-align: center; }
  .plate-empty__title { font: var(--w-title) 19px / 1.3 var(--font-display); letter-spacing: -0.022em; color: var(--color-ink); }
  .engine-empty__ask { color: var(--color-ink-faint); font-weight: 500; }

  /* ---- drop and drag (ui/drop.js, ui/drag.js) --------------------------------------------------- */
  .is-dropping { position: relative; }
  .gx-drop {
    position: absolute; inset: 6px; z-index: var(--z-panel); display: grid; place-items: center; pointer-events: none;
    border-radius: var(--r-xl); background: color-mix(in srgb, var(--color-surface-raised) 70%, transparent);
    box-shadow: inset 0 0 0 1.5px var(--s-edge-focus); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    animation: sg-fade var(--d) var(--ease);
  }
  .gx-drop__label { padding: 6px 10px; border-radius: var(--r-md); background: var(--color-ink); color: var(--color-bg); font-size: 12.5px; font-weight: 500; }
  .gx-draggable { cursor: grab; }
  .gx-draggable.is-dragging { opacity: 0.5; }

  /* ---- the composer (ui/composer.js) ------------------------------------------------------------ */
  .assistant-composer {
    position: relative; display: flex; flex-direction: column; gap: 4px; flex: none; min-width: 0;
    padding: 9px 6px 5px 11px; border-radius: var(--r-xl);
    background: var(--s-glass); -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
    box-shadow: var(--e-float); transition: box-shadow var(--d) var(--ease);
  }
  .assistant-composer:focus-within { box-shadow: var(--s-hi), 0 0 0 1px var(--s-edge-focus), 0 8px 28px var(--color-shadow); }
  .assistant-composer > .chat { display: flex; align-items: flex-end; gap: 4px; min-width: 0; }
  .assistant-composer > .chat > :is(.chat__attach--field, .chat__mark--field, .chat__mic--field) { display: none; }
  .chat__input {
    flex: 1; min-width: 0; min-height: 20px; max-height: calc(1.45em * 8); overflow-y: auto; overflow-x: hidden;
    padding: 1px 0; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; cursor: text; outline: none;
  }
  .chat__input--rich:empty::before { content: attr(data-placeholder); color: var(--color-ink-faint); pointer-events: none; }
  .chat__input .chat-pill { max-width: min(26ch, 100%); height: 18px; margin: 0 1px; font-size: 0.88em; vertical-align: 1px; cursor: default; user-select: none; -webkit-user-select: none; }
  .chat__send {
    display: grid; place-items: center; flex: none; width: 26px; height: 26px; margin: -2px 0 -1px; border-radius: var(--r-md);
    background: var(--s-tint-3); color: var(--color-ink-faint);
    transition: background var(--d) var(--ease), color var(--d) var(--ease), box-shadow var(--d) var(--ease), transform var(--d-fast) var(--ease);
  }
  .chat__send svg { width: 14px; height: 14px; }
  .chat.has-draft .chat__send { background: var(--color-accent-fill); color: var(--color-on-accent); box-shadow: var(--s-act-rim); }
  .chat.has-draft .chat__send:hover { background: var(--s-spot-lit), var(--color-accent-fill); }
  .chat__send:active { transform: scale(var(--press)); }
  .chat__tray { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; margin-left: -5px; }
  .chat__tray-start { display: flex; align-items: center; gap: 1px; min-width: 0; }
  :is(.chat__attach, .chat__mark, .chat__mic) {
    display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: var(--r-md);
    color: var(--color-ink-secondary); transition: background var(--d) var(--ease), color var(--d) var(--ease);
  }
  :is(.chat__attach, .chat__mark, .chat__mic) svg { width: 15px; height: 15px; }
  :is(.chat__attach, .chat__mark, .chat__mic):hover, :is(.chat__attach, .chat__mark, .chat__mic).is-open { background: var(--s-spot), var(--s-tint-2); color: var(--color-ink); }
  .chat__mark.is-on { background: var(--color-wash); color: var(--color-accent-text); }
  .chat__mic.is-recording { color: var(--color-danger); background: var(--color-danger-fill); }
  .chat__mic.is-recording::after { content: ""; position: absolute; width: 5px; height: 5px; margin: -12px -12px 0 0; border-radius: 50%; background: var(--color-danger); animation: sg-breathe 1s ease-in-out infinite; }
  .chat__mic { position: relative; }
  .chat__mic.is-busy { pointer-events: none; cursor: wait; opacity: 0.6; }
  .chat__pictures { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 4px 4px -4px; }
  .chat__picture { position: relative; width: 76px; height: 56px; overflow: hidden; border-radius: var(--r-lg); background: var(--s-tint-2); box-shadow: inset 0 0 0 1px var(--s-edge); }
  .chat__picture img { width: 100%; height: 100%; object-fit: cover; }
  .chat__picture-x { position: absolute; top: 3px; right: 3px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: var(--r-sm); background: rgba(0, 0, 0, 0.55); color: #fff; }
  .chat__picture-x svg { width: 11px; height: 11px; }
  .chat__card { position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 220px; height: 28px; padding: 0 28px 0 9px; border-radius: var(--r-md); background: var(--s-tint-2); font-size: var(--t-12); }
  .chat__card svg { width: 13px; height: 13px; color: var(--color-ink-secondary); }
  .chat__card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat__card.is-pending { padding-right: 9px; color: var(--color-ink-faint); }
  .chat__card .chat__picture-x { top: 5px; right: 5px; background: none; color: var(--color-ink-faint); }
  .chat__card .chat__picture-x:hover { background: var(--s-tint-3); color: var(--color-ink); }
  .assistant-composer.is-busy .chat__send { background: var(--s-tint-3); color: var(--color-ink); box-shadow: none; }

  /* ---- reply text (ui/prose.js) ----------------------------------------------------------------- */
  .msg-ai__text--md { font-size: 13.5px; line-height: var(--lh-read); color: var(--color-ink); overflow-wrap: anywhere; }
  .msg-ai__text--md > :first-child { margin-top: 0; }
  .msg-ai__text--md :is(p, ul, ol, blockquote, pre, .md-table, .md-picture, hr) { margin: 0 0 9px; }
  .msg-ai__text--md > :last-child { margin-bottom: 0; }
  .msg-ai__text--md :is(ul, ol) { padding-left: 20px; }
  .msg-ai__text--md li + li { margin-top: 3px; }
  .msg-ai__text--md li::marker { color: var(--color-ink-faint); }
  .msg-ai__text--md ol li::marker { font: 500 11.5px var(--font-mono); }
  .msg-ai__text--md strong { font-weight: 600; }
  .msg-ai__text--md a { color: var(--color-accent-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
  .msg-ai__text--md a:hover { text-decoration-color: currentColor; }
  .msg-ai__text--md code { padding: 1px 4px; border-radius: var(--r-xs); background: var(--s-tint-2); font-size: 12px; }
  .msg-ai__text--md :is(h2, h3, h4) { margin: 14px 0 5px; font-family: var(--font-display); font-weight: var(--w-title); letter-spacing: var(--track-display); line-height: 1.3; }
  .msg-ai__text--md h2 { font-size: 16px; }
  .msg-ai__text--md h3 { font-size: 14.5px; }
  .msg-ai__text--md h4 { font-size: 13.5px; }
  .msg-ai__text--md :is(h2, h3, h4):first-child { margin-top: 0; }
  .msg-ai__text--md .md-table { overflow-x: auto; border-radius: var(--r-lg); background: var(--s-glass); box-shadow: var(--e-flat); }
  .msg-ai__text--md table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
  .msg-ai__text--md :is(th, td) { padding: 6px 10px; text-align: left; vertical-align: top; box-shadow: inset 0 -1px 0 var(--s-edge); }
  .msg-ai__text--md th { font-size: 11.5px; font-weight: 500; color: var(--color-ink-faint); white-space: nowrap; }
  .msg-ai__text--md tbody tr:last-child td { box-shadow: none; }
  .msg-ai__text--md pre.md-code { overflow-x: auto; padding: 9px 11px; border-radius: var(--r-lg); background: var(--s-tint-1); box-shadow: inset 0 0 0 1px var(--s-edge); }
  .msg-ai__text--md pre.md-code code { padding: 0; background: none; font-size: 12px; line-height: 1.55; white-space: pre; }
  .msg-ai__text--md blockquote { padding: 1px 0 1px 12px; box-shadow: inset 1px 0 0 var(--color-ink-faint); color: var(--color-ink-secondary); }
  .msg-ai__text--md hr { height: 1px; border: 0; background: var(--s-edge); }
  .msg-ai__text--md s { color: var(--color-ink-faint); }
  .msg-ai__text--md .md-tasks { list-style: none; padding-left: 2px; }
  .msg-ai__text--md .md-check { display: inline-grid; place-items: center; width: 13px; height: 13px; margin-right: 7px; vertical-align: -1px; border-radius: var(--r-xs); box-shadow: inset 0 0 0 1.5px var(--color-ink-faint); }
  .msg-ai__text--md .md-check.is-done { background: var(--color-accent-fill); box-shadow: none; color: var(--color-on-accent); }
  .msg-ai__text--md .md-check svg { width: 9px; height: 9px; }
  .msg-ai__text--md .md-picture img { max-height: 320px; border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--s-edge); }
  .msg-ai__text--md .md-picture figcaption { margin-top: 5px; font-size: var(--t-12); color: var(--color-ink-faint); }
  .msg-ai__text--md .md-picture.is-missing img { display: none; }
  /* A block of a streaming reply arriving: it fades up, no mask left behind. */
  .msg-ai__text--md > .is-sweeping { animation: sg-rise-sm var(--d-slow) var(--ease) backwards; }
  .msg-ai__more { display: flex; gap: 4px; padding: 6px 0 2px; }
  .msg-ai__more i { width: 4px; height: 4px; border-radius: 50%; background: var(--color-ink-faint); animation: sg-more 1.2s ease-in-out infinite; }
  .msg-ai__more i:nth-child(2) { animation-delay: 0.15s; }
  .msg-ai__more i:nth-child(3) { animation-delay: 0.3s; }

  /* ---- icons ------------------------------------------------------------------------------------ */
  .icon { display: inline-block; vertical-align: middle; }

  /* ---- motion ----------------------------------------------------------------------------------- */
  @keyframes sg-fade { from { opacity: 0; } }
  @keyframes sg-drop { from { opacity: 0; transform: translateY(calc(-1 * var(--rise))); } }
  @keyframes sg-rise { from { opacity: 0; transform: translateY(var(--rise)) scale(0.99); } }
  @keyframes sg-rise-sm { from { opacity: 0; transform: translateY(3px); } }
  @keyframes sg-sheet { from { transform: translateY(24px); opacity: 0; } }
  @keyframes sg-slide-r { from { opacity: 0; transform: translateX(10px); } }
  @keyframes sg-slide-l { from { opacity: 0; transform: translateX(-10px); } }
  @keyframes sg-breathe { 50% { opacity: 0.35; } }
  @keyframes sg-more { 0%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
  @keyframes sg-pie { from { --p: 0deg; } to { --p: 360deg; } }
}
@property --p { syntax: "<angle>"; inherits: false; initial-value: 90deg; }
