/* theme.css - the p4pinfo design system foundation (docs/design-system.md).
 *
 * Bundled first into app.<hash>.css by chad-assets (M_THEME in build.sh).
 * Two tiers of tokens: raw scales (--blue-*, --slate-*, --gray-*, --red-*, --green-*), used only
 * in this file, and semantic tokens (--color-*, --space-*, ...), the only
 * ones components may use. Dark mode re-maps the semantic tokens.
 *
 * The reset, base elements and primitives (.btn, form controls) live in
 * @layer base; component CSS is unlayered, so it always wins over them.
 *
 * Contrast (WCAG 2.x) of the text pairs is listed next to each token; all
 * text pairs are >= 4.5:1, control borders >= 3:1.
 */

:root {
  /* ---- raw scales ------------------------------------------------------ */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;

  --slate-0: #ffffff;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Neutral greys (no blue tint): dark mode's surfaces, text and actions. */
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d4d4d4;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;
  --gray-950: #0a0a0a;

  --red-50: #fef2f2;
  --red-400: #f87171;
  --red-700: #b91c1c;
  --green-400: #4ade80;
  --green-700: #15803d;

  /* ---- semantic colors (light) ----------------------------------------- */
  --color-bg: var(--slate-50);
  --color-surface: var(--slate-0);
  --color-surface-sunken: var(--slate-100);
  --color-text: var(--slate-900);           /* 17.1:1 on bg */
  --color-text-muted: var(--slate-600);     /* 7.6:1 on surface, 6.9:1 on sunken */
  --color-border: var(--slate-200);
  --color-border-strong: var(--slate-300);
  --color-control-border: #7c8799;          /* 3.6:1 on surface */

  --color-link: var(--blue-700);            /* 6.7:1 on surface */
  --link-decoration: none;                  /* the link color alone marks links */
  --color-accent: var(--blue-700);
  --color-accent-hover: var(--blue-800);
  --color-on-accent: var(--slate-0);        /* 6.7:1 on accent */
  --color-accent-soft: var(--blue-50);

  /* Pressed toggles (reaction buttons). */
  --color-selected-fg: var(--blue-800);     /* 8.0:1 on selected-bg */
  --color-selected-bg: var(--blue-50);
  --color-selected-border: var(--blue-200);

  --color-tag-fg: var(--blue-800);          /* 8.0:1 on tag-bg */
  --color-tag-bg: var(--blue-50);
  --color-tag-border: var(--blue-200);
  --color-tag-hover-bg: var(--blue-100);    /* 7.2:1 with tag-fg */
  --color-tag-current-fg: var(--slate-0);   /* 8.7:1 on tag-current-bg */
  --color-tag-current-bg: var(--blue-800);

  --color-danger: var(--red-700);           /* 6.5:1 on surface */
  --color-danger-soft: var(--red-50);
  --color-success: var(--green-700);        /* 5.0:1 on surface */

  /* Direct messages (direct_page.chad): your bubbles, theirs, and the
     unread count on the Messages link. */
  --color-bubble-mine-bg: var(--blue-700);
  --color-bubble-mine-fg: var(--slate-0);   /* 6.7:1 on bubble-mine-bg */
  --color-bubble-theirs-bg: var(--slate-100);
  --color-bubble-theirs-fg: var(--slate-900); /* 16.3:1 on bubble-theirs-bg */
  --color-badge-bg: var(--red-700);         /* 6.5:1 on surface */
  --color-badge-fg: var(--slate-0);         /* 6.5:1 on badge-bg */
  --color-focus: var(--blue-600);           /* 5.2:1 on surface */
  /* The header logo (Layout). A dark bubble with light figures here, so it
     stands out on the white header; dark mode uses the logo's own colors.
     The rays are the logo's orange in both modes (a logotype: no contrast
     requirement, and it isn't the only way to read the link). */
  --color-logo-bubble: var(--slate-900);
  --color-logo-figures: var(--slate-0);
  --color-logo-rays: #ff6414;
  /* Over photos (the avatar editor's hover layer): the same in both modes. */
  --color-scrim: rgb(0 0 0 / 0.55);
  --color-on-scrim: #ffffff;                 /* 4.7:1 at worst (scrim over white), more over darker images */

  /* ---- type ------------------------------------------------------------ */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "Noto Sans Hebrew",
    "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.75rem;   /* 12px */
  --text-sm: 0.875rem;  /* 14px */
  --text-base: 1rem;    /* 16px */
  --text-lg: 1.125rem;  /* 18px */
  --text-xl: 1.25rem;   /* 20px */
  --text-2xl: 1.5rem;   /* 24px */
  --text-3xl: 1.875rem; /* 30px */
  --leading-tight: 1.25;
  --leading-normal: 1.6;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ---- space, size, shape ---------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-tag: 6px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-md: 0 1px 3px rgb(15 23 42 / 0.08), 0 6px 16px rgb(15 23 42 / 0.06);

  --content-width: 44rem;
  --control-height: 40px;
  --control-height-sm: 32px;
  --header-height: 60px;   /* the site header (layout.chad), without its border and the safe area */
  --tab-bar-height: 56px;  /* the mobile tab bar (layout.chad), without the safe area */

  /* ---- motion ---------------------------------------------------------- */
  --duration-fast: 120ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  /* Black and grey. Blue is reserved for hashtags (--color-tag-*). */
  :root {
    --color-bg: var(--gray-950);
    --color-surface: var(--gray-900);
    --color-surface-sunken: var(--gray-950);
    --color-text: var(--gray-100);          /* 18.2:1 on bg, 16.4:1 on surface */
    --color-text-muted: var(--gray-400);    /* 7.1:1 on surface, 7.8:1 on sunken */
    --color-border: var(--gray-800);
    --color-border-strong: var(--gray-700);
    --color-control-border: var(--gray-500); /* 3.8:1 on surface */

    --color-link: var(--gray-50);           /* 17.2:1 on surface */
    --link-decoration: underline;           /* links are text-colored, so underline them */
    --color-accent: var(--gray-100);        /* primary buttons: light grey on black */
    --color-accent-hover: var(--gray-300);
    --color-on-accent: var(--gray-950);     /* 18.2:1 on accent, 13.4:1 on accent-hover */
    --color-accent-soft: var(--gray-800);

    --color-selected-fg: var(--gray-50);    /* 9.9:1 on selected-bg */
    --color-selected-bg: var(--gray-700);
    --color-selected-border: var(--gray-500);

    --color-tag-fg: var(--blue-200);        /* 10.3:1 on tag-bg */
    --color-tag-bg: #16284b;
    --color-tag-border: #1f3d73;
    --color-tag-hover-bg: #1b3563;          /* 9.9:1 with blue-100 */
    --color-tag-current-fg: var(--slate-900); /* 9.9:1 on tag-current-bg */
    --color-tag-current-bg: var(--blue-300);

    --color-danger: var(--red-400);         /* 6.5:1 on surface */
    --color-danger-soft: #2a1215;
    --color-success: var(--green-400);      /* 10.3:1 on surface */

    --color-bubble-mine-bg: var(--gray-100);
    --color-bubble-mine-fg: var(--gray-950);   /* 18.2:1 on bubble-mine-bg */
    --color-bubble-theirs-bg: var(--gray-800);
    --color-bubble-theirs-fg: var(--gray-100); /* 13.9:1 on bubble-theirs-bg */
    --color-badge-bg: var(--red-400);          /* 6.5:1 on surface */
    --color-badge-fg: var(--gray-950);         /* 7.2:1 on badge-bg */
    --color-focus: var(--gray-300);         /* 12.1:1 on surface */
    --color-logo-bubble: #fafafa;
    --color-logo-figures: #141414;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 1px 3px rgb(0 0 0 / 0.5), 0 6px 16px rgb(0 0 0 / 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
  }
}

@layer base {
  /* ---- reset ----------------------------------------------------------- */
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, video { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  ul[class], ol[class] { list-style: none; padding: 0; }
  p, h1, h2, h3, li { overflow-wrap: break-word; }

  /* ---- document -------------------------------------------------------- */
  body {
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3 { line-height: var(--leading-tight); font-weight: var(--weight-bold); }
  h1 { font-size: var(--text-2xl); }
  h2 { font-size: var(--text-xl); }
  h3 { font-size: var(--text-lg); }

  a { color: var(--color-link); text-decoration: none; text-underline-offset: 2px; }
  a:hover { text-decoration: underline; }
  /* Plain links in running text (no class). Dark mode underlines them,
     since its link color is a neutral that wouldn't stand out alone. */
  a:not([class]) { text-decoration-line: var(--link-decoration); }

  :focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }

  .visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }

  /* ---- toast ----------------------------------------------------------- */
  /* A short message at the bottom of the page, role="status" (copy-link.ts). */
  .toast {
    position: fixed;
    z-index: 30;
    inset-block-end: calc(var(--space-6) + var(--tab-bar-offset, 0px));
    inset-inline: var(--space-4);
    max-width: 28rem;
    margin-inline: auto;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    font-size: var(--text-sm);
    text-align: center;
  }
  .toast[hidden] { display: none; }

  /* ---- buttons --------------------------------------------------------- */
  /* A loading spinner, in the text color around it. */
  .spinner {
    display: block;
    inline-size: 24px;
    block-size: 24px;
    border: 2.5px solid currentColor;
    border-block-start-color: transparent;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    animation: spinner-turn 800ms linear infinite;
  }
  @keyframes spinner-turn { to { transform: rotate(360deg); } }
  @keyframes spinner-pulse { 50% { opacity: 0.4; } }
  @media (prefers-reduced-motion: reduce) {
    .spinner { animation: spinner-pulse 1.2s ease-in-out infinite; }
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  }
  .btn:hover { text-decoration: none; }
  .btn-sm { min-height: var(--control-height-sm); padding: 0 var(--space-3); }
  .btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
  .btn-primary:hover { background: var(--color-accent-hover); }
  .btn-quiet { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
  .btn-quiet:hover { background: var(--color-surface-sunken); }
  .btn-danger { background: var(--color-surface); color: var(--color-danger); border-color: var(--color-border-strong); }
  .btn-danger:hover { background: var(--color-danger-soft); border-color: var(--color-danger); }

  /* ---- action menu (app/web/action-menu.ts) ----------------------------- */
  /* A native popover. Wide screens: a dropdown, placed under its button by
     the element (inline top/left/right). Narrow screens: a bottom sheet over
     the scrim, with a grab handle and Cancel. */
  .action-menu {
    inset: auto;
    margin: 0;
    min-inline-size: 12rem;
    max-inline-size: calc(100vw - 2 * var(--space-4));
    padding: var(--space-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
  }
  .action-menu:popover-open { display: grid; }
  .action-menu::backdrop { background: transparent; }
  .action-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    inline-size: 100%;
    min-block-size: 44px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--color-text);
    font-size: var(--text-sm);
    text-align: start;
    cursor: pointer;
  }
  .action-menu-item:hover, .action-menu-item:focus-visible { background: var(--color-surface-sunken); }
  .action-menu-item svg { flex: none; color: var(--color-text-muted); }
  /* Sheet only (below). */
  .action-menu-handle, .action-menu-cancel { display: none; }
  @media (max-width: 640px) {
    /* Anchored to the bottom edge only (top: auto), so the height is the
       content's in every engine. inset: 0 + margin-top: auto relied on the
       UA's height: fit-content, which iOS Safari doesn't apply: the sheet
       stretched to the full screen there. */
    .action-menu {
      inset: auto 0 0;
      inline-size: 100%;
      max-inline-size: none;
      block-size: auto;
      max-block-size: 85dvh;
      overflow-y: auto;
      margin: 0;
      padding: var(--space-2) var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom));
      border-width: 1px 0 0;
      border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .action-menu::backdrop { background: var(--color-scrim); }
    .action-menu:popover-open { animation: action-menu-in var(--duration-fast) var(--ease-out); }
    .action-menu-handle {
      display: block;
      justify-self: center;
      inline-size: 36px;
      block-size: 4px;
      margin-block: var(--space-1) var(--space-3);
      border-radius: var(--radius-full);
      background: var(--color-border-strong);
    }
    .action-menu-item { min-block-size: 48px; font-size: var(--text-base); }
    .action-menu-cancel {
      display: flex;
      justify-content: center;
      margin-block-start: var(--space-2);
      border: 1px solid var(--color-border-strong);
      font-weight: var(--weight-semibold);
    }
  }
  @keyframes action-menu-in { from { transform: translateY(100%); } }

  /* ---- sheet ------------------------------------------------------------ */
  /* A native popover (popovertarget, no JS): a centered card on wide screens,
     a sheet from the bottom on narrow ones, over the scrim. */
  .sheet {
    inline-size: min(20rem, 100vw - 2 * var(--space-4));
    max-block-size: calc(100dvh - 2 * var(--space-4));
    margin: auto;
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    overflow-y: auto;
  }
  .sheet:popover-open { display: grid; gap: var(--space-2); }
  .sheet::backdrop { background: var(--color-scrim); }
  @media (max-width: 640px) {
    /* Bottom edge only, like .action-menu: iOS Safari stretched the
       inset: 0 + margin-top: auto version. */
    .sheet {
      inset: auto 0 0;
      inline-size: 100%;
      max-inline-size: none;
      block-size: auto;
      max-block-size: 85dvh;
      margin: 0;
      padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
      border-width: 1px 0 0;
      border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .sheet:popover-open { animation: sheet-in var(--duration-fast) var(--ease-out); }
  }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @media (prefers-reduced-motion: reduce) { .sheet:popover-open { animation: none; } }

  /* ---- token field (app/web/search-bar.ts, app/web/tag-input.ts) -------- */
  /* A field holding picked tokens (#tags, @people) as removable chips, then
     a frameless input, with suggestions in a listbox. The field looks like
     an input; the real input inside it has no frame. Search makes it a
     pill (search_box.chad); the tag field keeps the control radius. */
  .token-field {
    display: flex;
    flex: 1;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    min-height: var(--control-height);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--color-control-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: text;
    transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  }
  .token-field:focus-within {
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-focus) 30%, transparent);
  }
  /* Chips and the input wrap together. */
  .token-list {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
    min-width: 0;
  }
  /* Two classes, to beat the input rule below (its :not() counts). */
  .token-field .token-input {
    flex: 1;
    width: auto;
    min-width: 6rem;
    min-height: 30px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
  }
  .token-field .token-input:focus-visible { outline: none; box-shadow: none; }
  .token-chips { display: contents; }
  .token-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 26px;
    padding-inline: var(--space-2) var(--space-1);
    border: 1px solid var(--color-tag-border);
    border-radius: var(--radius-tag);
    background: var(--color-tag-bg);
    color: var(--color-tag-fg);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: 1;
    white-space: nowrap;
  }
  .token-chip-x {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background: none;
    color: inherit;
    cursor: pointer;
  }
  .token-chip-x:hover { background: var(--color-tag-hover-bg); }

  /* The suggestions. .token-dropdown places the list under its field (the
     nearest positioned ancestor); search's full screen view doesn't. */
  .token-menu { overflow: auto; padding: var(--space-1); }
  .token-dropdown {
    position: absolute;
    z-index: 20;
    inset-block-start: calc(100% + var(--space-1));
    inset-inline: 0;
    max-height: min(24rem, 60vh);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
  }
  .token-group { display: grid; }
  .token-group + .token-group {
    margin-block-start: var(--space-1);
    padding-block-start: var(--space-1);
    border-block-start: 1px solid var(--color-border);
  }
  .token-group-title {
    padding: var(--space-2) var(--space-3) var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
  }
  .token-group-list { display: grid; }
  .token-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 44px;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    cursor: pointer;
  }
  .token-option:hover,
  .token-option[aria-selected="true"] { background: var(--color-surface-sunken); }
  .token-option[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--color-focus); }
  .token-option[aria-selected="true"]:dir(rtl) { box-shadow: inset -3px 0 0 var(--color-focus); }
  .token-tag { color: var(--color-tag-fg); font-weight: var(--weight-medium); }
  .token-tag .hash { opacity: 0.6; }
  .token-count {
    margin-inline-start: auto;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
  }
  .token-empty { padding: var(--space-3); color: var(--color-text-muted); font-size: var(--text-sm); }

  /* ---- form controls --------------------------------------------------- */
  input:not([type="checkbox"], [type="radio"], [type="hidden"]), textarea, select {
    display: block;
    width: 100%;
    min-height: var(--control-height);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-control-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--text-base);
    line-height: var(--leading-tight);
    transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  }
  /* Our own chevron: browsers draw the native arrow flush against the
     border, ignoring padding. Two gradient triangles in the text's muted
     color (so it follows the theme, no image), inset by the same
     --space-3 as the text on the other side, and mirrored in RTL. */
  select {
    appearance: none;
    padding-inline-end: calc(var(--space-3) * 2 + 10px);
    background-image:
      linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
      linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
    background-size: 5px 5px, 5px 5px;
    background-position: right calc(var(--space-3) + 5px) center, right var(--space-3) center;
    background-repeat: no-repeat;
  }
  select:dir(rtl) { background-position: left var(--space-3) center, left calc(var(--space-3) + 5px) center; }
  textarea { line-height: var(--leading-normal); resize: vertical; }
  input::placeholder, textarea::placeholder { color: var(--color-text-muted); opacity: 1; }
  input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-focus) 30%, transparent);
  }
}
/* Avatar (app/components/avatar.chad:13) */
.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-surface-sunken);
}
.avatar.initial {
  display: inline-grid;
  place-items: center;
  background: var(--color-accent-soft);
  color: var(--color-link);
  font-weight: var(--weight-semibold);
  line-height: 1;
}
.avatar.avatar-lg { width: 96px; height: 96px; font-size: var(--text-3xl); }
@media (max-width: 480px) { .avatar.avatar-lg { width: 72px; height: 72px; font-size: var(--text-2xl); } }

/* Own profile and group details: the server-rendered Avatar, then the
   editor island (app/web/avatar-editor.ts, light DOM) stacked on top of
   it. Until the island loads, the plain avatar shows. */
.avatar-stack { display: grid; flex: none; }
.avatar-stack > * { grid-area: 1 / 1; }
avatar-editor { display: block; position: relative; border-radius: var(--radius-full); }
/* Someone else's picture (app/web/avatar-viewer.ts): view it large. */
avatar-viewer { display: block; border-radius: var(--radius-full); }
.avatar-button.avatar-view { cursor: zoom-in; }
.avatar-button {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  cursor: pointer;
}
.avatar-button:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
.avatar-button .avatar { display: grid; }
.avatar-scrim {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-scrim);
  color: var(--color-on-scrim);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.avatar-button:hover .avatar-scrim,
.avatar-button:focus-visible .avatar-scrim { opacity: 1; }
/* Touch screens have no hover: a small pencil badge is always shown. */
.avatar-badge {
  position: absolute;
  inset-block-end: 0;
  inset-inline-end: 0;
  display: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--color-bg);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
@media (hover: none) {
  .avatar-badge { display: grid; }
  .avatar-button .avatar-scrim { opacity: 0; }
}
.avatar-toast {
  position: fixed;
  z-index: 30;
  inset-block-end: calc(var(--space-6) + var(--tab-bar-offset, 0px));
  inset-inline: var(--space-4);
  max-width: 28rem;
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
}
.avatar-toast[hidden] { display: none; }

/* The picture modal (app/web/avatar-dialog.ts): a native <dialog> in the
   top layer, opened from profiles (the avatar editor and viewer) and
   from image posts on any page (photo-viewer). The box itself has no
   padding, so a click on it is a click on the backdrop; the body
   carries the padding. */
.avatar-dialog {
  width: min(24rem, 100vw - 2 * var(--space-4));
  max-height: calc(100dvh - 2 * var(--space-4));
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  overflow: auto;
}
.avatar-dialog::backdrop { background: var(--color-scrim); }
.avatar-dialog[open] { animation: avatar-dialog-in var(--duration-fast) var(--ease-out); }
@keyframes avatar-dialog-in { from { opacity: 0; transform: scale(0.96); } }
@media (prefers-reduced-motion: reduce) { .avatar-dialog[open] { animation: none; } }
.avatar-dialog-body {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  padding: var(--space-6) var(--space-5) var(--space-5);
  text-align: center;
}
.avatar-dialog-x {
  position: absolute;
  z-index: 1;
  inset-block-start: var(--space-3);
  inset-inline-end: var(--space-3);
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.avatar-dialog-x:hover { background: var(--color-surface-sunken); color: var(--color-text); }
.avatar-dialog-x:disabled { opacity: 0.6; cursor: default; }
.avatar-dialog-stage { position: relative; display: grid; border-radius: var(--radius-full); }
.avatar-dialog-face { width: 192px; height: 192px; font-size: var(--text-3xl); }
.avatar-dialog-face.initial { display: grid; font-size: calc(2 * var(--text-3xl)); }
.avatar-dialog-scrim {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-scrim);
  color: var(--color-on-scrim);
}
.avatar-spinner { animation: avatar-spin 0.9s linear infinite; }
@keyframes avatar-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .avatar-spinner { animation: none; } }
.avatar-dialog-error {
  justify-self: stretch;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: var(--text-sm);
}
.avatar-dialog-error[hidden] { display: none; }
/* Two actions side by side, sharing the width; they wrap only if a
   translation can't fit on one line. */
.avatar-dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.avatar-dialog-actions .btn { flex: 1 1 auto; padding-inline: var(--space-3); }
.avatar-dialog-actions .btn:disabled { opacity: 0.6; cursor: default; }
/* theme.css styles every input as display: block, which beats [hidden]. */
.avatar-dialog input[type="file"] { display: none; }
@media (max-width: 480px) {
  .avatar-dialog-face { width: 160px; height: 160px; }
}
/* The photo variant (image posts): the picture at its own aspect ratio,
   as large as the screen allows, with the X over its corner. */
.avatar-dialog.photo { width: fit-content; max-width: calc(100vw - 2 * var(--space-4)); overflow: hidden; }
.avatar-dialog.photo .avatar-dialog-body { padding: 0; gap: 0; }
.avatar-dialog.photo .avatar-dialog-stage { border-radius: 0; }
.avatar-dialog.photo .avatar-dialog-x {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.avatar-dialog.photo .avatar-dialog-x:hover { background: var(--color-surface-sunken); }
.avatar-dialog-photo {
  display: block;
  inline-size: auto;
  block-size: auto;
  max-inline-size: calc(100vw - 2 * var(--space-4) - 2px);
  max-block-size: calc(100dvh - 2 * var(--space-4) - 2px);
  background: var(--color-surface-sunken);
}
/* BotCheck (app/components/bot_check.chad:30) */
/* The widget's height, kept free while it loads. */
turnstile-check { display: block; min-height: 65px; }
.turnstile-note { color: var(--color-text-muted); font-size: var(--text-sm); }
.turnstile-note:empty { display: none; }
/* CategoryField (app/components/category_field.chad:20) */
.category-field { position: relative; display: grid; gap: var(--space-1); }
.category-field category-picker { display: block; min-block-size: 1lh; font-size: var(--text-xs); }
.category-field .category-picker-note { color: var(--color-text-muted); }
.category-field .category-picker-note[hidden] { display: none; }
/* On the label's line, at its end. The 44px button reaches up from
   there, not over the select. */
.category-field .category-info-button {
  position: absolute;
  inset-block-start: calc(1.6 * var(--text-sm) - 44px + var(--space-1));
  inset-inline-end: 0;
  align-items: end;
  justify-items: end;
  padding: 0 0 var(--space-1);
}
.category-field .category-info-button:hover { background: none; }
/* CategoryFilter (app/components/category_filter.chad:68) */
.category-filter { display: flex; align-items: center; min-width: 0; }
.category-filter .chips {
  min-width: 0;
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  /* Room for the chips' focus ring, which the scrolling row clips. */
  padding: var(--space-1);
  margin-inline-start: calc(-1 * var(--space-1));
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}
/* Phones swipe the row; a scrollbar there only draws a stray line. */
@media (max-width: 640px) { .category-filter .chips { scrollbar-width: none; } }
.category-filter li { flex: none; }
.category-filter .chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.category-filter .chip:hover { background: var(--color-surface-sunken); text-decoration: none; }
.category-filter .chip .emoji { margin-inline-end: var(--space-1); }
.category-filter .chip .count {
  margin-inline-start: var(--space-1);
  padding-inline-start: var(--space-2);
  border-inline-start: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.category-filter .chip.current { border-color: var(--color-selected-border); background: var(--color-selected-bg); color: var(--color-selected-fg); }
.category-filter .chip.current .count { border-color: currentColor; color: inherit; }
/* CategoryInfo (app/components/category_info.chad:8) */
.category-info-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-block: -2px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.category-info-button:hover { background: var(--color-surface-sunken); color: var(--color-text); }
/* CategoryLabel (app/components/category_label.chad:17) */
.category-kicker { display: flex; align-items: center; justify-self: start; }
/* Smaller than elsewhere, on a short line: the button reaches past it
   into the gaps around, without moving them. */
.category-kicker .category-info-button { width: 40px; height: 32px; margin-block: -9px; padding-inline-start: var(--space-2); justify-items: start; }
.category-kicker .category-info-button:hover { background: none; }
.category-kicker .category-info-button svg { width: 14px; height: 14px; }
.category-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
}
.category-label:hover { color: var(--color-text); text-decoration: none; }
/* The emoji keeps its colors: the one accent on a muted line. Sized to
   the cap height of the uppercase text, it doesn't make the line taller. */
.category-label .emoji { flex: none; font-size: 1.15em; letter-spacing: 0; }
/* CategoryPage (app/components/category_page.chad:25) */
.category-page { display: grid; gap: var(--space-6); }
.category-page .page-head { display: grid; gap: var(--space-4); }
.category-page .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.category-page h1 { font-size: var(--text-3xl); }
.category-page .about { max-width: 60ch; color: var(--color-text-muted); }
.category-page .title-actions { margin-inline-start: auto; }
.category-page .top-tags { display: grid; gap: var(--space-2); }
.category-page .top-tags h2 { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.category-page .top-tags .tag-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.category-page .posts { display: grid; gap: var(--space-4); }
/* CategorySheet (app/components/category_sheet.chad:8) */
.sheet.category-info { width: min(26rem, 100vw - 2 * var(--space-4)); text-align: start; }
.category-info:popover-open { gap: var(--space-4); }
.category-info h2 { font-size: var(--text-lg); }
.category-info ul { display: grid; gap: var(--space-4); }
.category-info li { display: grid; grid-template-columns: auto 1fr; column-gap: var(--space-3); }
.category-info .emoji { font-size: var(--text-xl); line-height: var(--leading-tight); }
.category-info .name { font-weight: var(--weight-semibold); line-height: var(--leading-tight); }
.category-info .about { grid-column: 2; color: var(--color-text-muted); font-size: var(--text-sm); }
.category-info .btn { min-height: 48px; }
@media (max-width: 640px) { .sheet.category-info { width: 100%; } }
/* CheckInboxPage (app/components/check_inbox_page.chad:23) */
.check-inbox-address { overflow-wrap: anywhere; font-weight: var(--weight-semibold); }
.check-inbox-hint, .check-inbox-note { color: var(--color-text-muted); font-size: var(--text-sm); }
.check-inbox-note { font-variant-numeric: tabular-nums; }
.check-inbox-note[hidden] { display: none; }
#resend-button:disabled { opacity: 0.6; cursor: default; }
.panel form resend-timer { display: contents; }
/* DirectPage (app/components/direct_page.chad:77) */
.direct-page { display: grid; gap: var(--space-6); min-width: 0; }
.direct-page .direct-inbox { display: grid; align-content: start; gap: var(--space-4); min-width: 0; }
.direct-page h1 { font-size: var(--text-2xl); line-height: var(--leading-tight); }
.direct-page .hint { color: var(--color-text-muted); font-size: var(--text-sm); }

/* The inbox (app/web/chat-inbox.ts). */
.direct-page chat-inbox { display: grid; gap: var(--space-3); }
.direct-page .chat-rows {
  display: grid;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
}
.direct-page .chat-rows > li + li { border-block-start: 1px solid var(--color-border); }
.direct-page .chat-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  text-decoration: none;
}
.direct-page .chat-row:hover { background: var(--color-surface-sunken); text-decoration: none; }
.direct-page .chat-row:focus-visible { outline-offset: -3px; }
.direct-page .chat-row[aria-current="page"] { background: var(--color-selected-bg); color: var(--color-selected-fg); }
.direct-page .chat-row .avatar { width: 48px; height: 48px; font-size: var(--text-lg); }
.direct-page .chat-row-text { display: grid; flex: 1; min-width: 0; }
.direct-page .chat-row-who { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
.direct-page .chat-row-name { overflow: hidden; font-weight: var(--weight-semibold); text-overflow: ellipsis; white-space: nowrap; }
.direct-page .chat-row-handle { flex: none; color: var(--color-text-muted); font-size: var(--text-sm); }
.direct-page .chat-row[aria-current="page"] .chat-row-handle { color: inherit; }
.direct-page .chat-row-last { display: flex; gap: var(--space-1); min-width: 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.direct-page .chat-row[aria-current="page"] .chat-row-last { color: inherit; }
.direct-page .chat-row-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.direct-page .chat-row-time { flex: none; }
.direct-page .chat-row.unread .chat-row-name,
.direct-page .chat-row.unread .chat-row-snippet { color: var(--color-text); font-weight: var(--weight-bold); }
.direct-page .chat-row .chat-row-snippet.typing { color: var(--color-text); font-weight: var(--weight-medium); }
.direct-page .chat-row-dot { flex: none; width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--color-bubble-mine-bg); }
.direct-page .chat-empty {
  padding: var(--space-8) var(--space-4);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  text-align: center;
}
/* Where the next page comes in: rows below, older messages above. */
.direct-page .chat-edge {
  display: grid;
  flex: none;
  gap: var(--space-2);
  place-items: center;
  place-content: center;
  min-block-size: var(--control-height);
}
.direct-page .chat-edge-error { color: var(--color-text-muted); font-size: var(--text-sm); text-align: center; }

/* A conversation. */
.direct-page .direct-thread {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
}
.direct-page .thread-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-block-end: 1px solid var(--color-border);
}
.direct-page .thread-head .back {
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-full);
  color: var(--color-text);
}
.direct-page .thread-head .back:hover { background: var(--color-surface-sunken); }
.direct-page .thread-head .back svg { transform: scaleX(1); }
[dir="rtl"] .direct-page .thread-head .back svg { transform: scaleX(-1); }
.direct-page .thread-head .peer { display: flex; align-items: center; gap: var(--space-3); min-width: 0; color: var(--color-text); text-decoration: none; }
.direct-page .thread-head .peer:hover .name { text-decoration: underline; }
.direct-page .thread-head .avatar { width: 36px; height: 36px; font-size: var(--text-sm); }
.direct-page .thread-head .names { display: grid; min-width: 0; }
.direct-page .thread-head .name { overflow: hidden; font-weight: var(--weight-semibold); text-overflow: ellipsis; white-space: nowrap; }
.direct-page .thread-head .handle { color: var(--color-text-muted); font-size: var(--text-xs); }
.direct-page .thread-head h2.name { font-size: var(--text-base); }
/* A group's bar opens its details (members, picture). */
.direct-page .thread-head .group-link { flex: 1; }
.direct-page .thread-head .details-icon { flex: none; margin-inline-start: auto; color: var(--color-text-muted); }
/* A group's two faces, the second overlapping the first. */
.direct-page .thread-head .faces { display: flex; flex: none; }
.direct-page .thread-head .faces .avatar { width: 30px; height: 30px; font-size: var(--text-xs); box-shadow: 0 0 0 2px var(--color-surface); }
.direct-page .thread-head .faces .avatar + .avatar { margin-inline-start: -12px; margin-block-start: 10px; }
.direct-page .direct-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.direct-page .new-chat {
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-full);
  color: var(--color-text);
}
.direct-page .new-chat:hover { background: var(--color-surface-sunken); }

/* The thread itself (app/web/chat-thread.ts). */
.direct-page chat-thread { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
/* Reversed around its one child, so it scrolls from the bottom: what
   loads above moves nothing on screen. chat-thread.ts corrects the rest,
   so the browser must not as well. */
.direct-page .chat-log {
  display: flex;
  flex-direction: column-reverse;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
}
/* At least as tall as the log: a short thread starts at the top. */
.direct-page .chat-log-inner {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-4);
}
.direct-page .chat-log:focus-visible { outline-offset: -3px; }
.direct-page .chat-start { margin: auto; color: var(--color-text-muted); text-align: center; }
.direct-page .chat-day {
  align-self: center;
  margin-block: var(--space-4) var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.direct-page .chat-system {
  align-self: center;
  max-width: 85%;
  margin-block: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-align: center;
  overflow-wrap: anywhere;
}
.direct-page .chat-msg { display: grid; justify-items: start; max-width: min(75%, 32rem); }
.direct-page .chat-msg.mine { align-self: end; justify-items: end; }
.direct-page .chat-msg.theirs { align-self: start; }
.direct-page .chat-msg.first { margin-block-start: var(--space-2); }
.direct-page .chat-bubble {
  padding: var(--space-2) var(--space-3);
  border-radius: 18px;
  background: var(--color-bubble-theirs-bg);
  color: var(--color-bubble-theirs-fg);
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.direct-page .chat-msg.mine .chat-bubble { background: var(--color-bubble-mine-bg); color: var(--color-bubble-mine-fg); }
.direct-page .chat-msg.pending .chat-bubble { opacity: 0.6; }
.direct-page .chat-msg.failed .chat-bubble { outline: 2px solid var(--color-danger); outline-offset: 1px; }
.direct-page .chat-note { display: flex; align-items: center; gap: var(--space-2); margin-block-start: 2px; color: var(--color-text-muted); font-size: var(--text-xs); }
.direct-page .chat-msg.failed .chat-note { color: var(--color-danger); }
.direct-page .chat-retry {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  cursor: pointer;
}
/* Reactions (chat-thread.ts, reaction-picker.ts). The smiley beside a
   bubble shows on hover where there's a fine pointer; touch uses a long
   press and a double tap instead, so bubbles there can't be selected
   (iOS would start a text selection) and the page doesn't zoom. */
.direct-page .chat-log { touch-action: manipulation; }
.direct-page .chat-line { position: relative; display: flex; max-width: 100%; }
.direct-page .chat-react-btn {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 100%;
  display: grid;
  place-items: center;
  inline-size: 32px;
  block-size: 32px;
  margin-block: auto;
  margin-inline-start: 2px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.direct-page .chat-msg.mine .chat-react-btn { inset-inline: auto 100%; margin-inline: 0 2px; }
.direct-page .chat-react-btn:hover { background: var(--color-surface-sunken); color: var(--color-text); }
.direct-page .chat-msg:hover .chat-react-btn,
.direct-page .chat-react-btn:focus-visible { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .direct-page .chat-react-btn { display: none; }
  .direct-page .chat-bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
.direct-page .chat-reactions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-block-start: -6px;
  margin-inline: var(--space-2);
  padding: 2px 7px;
  border: 0;
  border-radius: var(--radius-full);
  /* Theirs' bubble color, ringed in the page's, so it reads as a badge
     on the bubble in both modes. */
  background: var(--color-bubble-theirs-bg);
  color: var(--color-bubble-theirs-fg);
  box-shadow: 0 0 0 2px var(--color-surface);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1.4;
}
.direct-page button.chat-reactions { cursor: pointer; }
.direct-page .chat-reactions-count { margin-inline-start: 2px; font-size: var(--text-xs); font-weight: var(--weight-medium); }
.direct-page .chat-reactions.pop { animation: chat-pop 0.4s var(--ease-out); }
@keyframes chat-pop {
  0% { transform: scale(0.4); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.direct-page .reaction-picker {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}
.direct-page .reaction-picker:popover-open { display: flex; gap: 2px; animation: chat-picker-in 0.15s var(--ease-out); }
.direct-page .reaction-picker-item {
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
}
.direct-page .reaction-picker-item:hover { background: var(--color-surface-sunken); transform: scale(1.15); }
.direct-page .reaction-picker-item[aria-checked="true"] { background: var(--color-selected-bg); }
.direct-page .reaction-picker-item:focus-visible { outline-offset: -2px; }
@keyframes chat-picker-in {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .direct-page .chat-reactions.pop,
  .direct-page .reaction-picker:popover-open { animation: none; }
  .direct-page .reaction-picker-item:hover { transform: none; }
}

.direct-page .chat-seen { align-self: end; margin-block-start: 2px; color: var(--color-text-muted); font-size: var(--text-xs); }

/* The other person is typing: three dots in a bubble of theirs. */
.direct-page .chat-typing .chat-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(1.4em + 2 * var(--space-2));
}
.direct-page .chat-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: currentColor;
  opacity: 0.4;
  animation: chat-dot 1.2s ease-in-out infinite;
}
.direct-page .chat-dot:nth-child(2) { animation-delay: 0.15s; }
.direct-page .chat-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .direct-page .chat-dot { animation: none; opacity: 0.7; }
}

.direct-page .chat-composer {
  display: flex;
  align-items: end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-block-start: 1px solid var(--color-border);
}
.direct-page .chat-composer textarea {
  flex: 1;
  min-height: var(--control-height);
  max-height: 9rem;
  padding-block: var(--space-2);
  overflow-y: hidden;  /* chat-thread.ts turns it on past max-height */
  border-radius: 20px;
  line-height: 1.4;
  resize: none;
}
.direct-page .chat-composer .btn { flex: none; border-radius: var(--radius-full); }
.direct-page .chat-error { padding: 0 var(--space-3) var(--space-3); color: var(--color-danger); font-size: var(--text-sm); }

/* New message (app/web/chat-compose.ts): the people, a group's name,
   then the composer at the bottom, as in a thread. */
.direct-page chat-compose { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.direct-page .compose-fields {
  display: grid;
  align-content: start;
  gap: var(--space-4);
  padding: var(--space-4);
  overflow-y: auto;
}
.direct-page people-field { display: block; }
.direct-page group-add { display: block; overflow-y: auto; }
.direct-page .group-add { display: grid; gap: var(--space-4); padding: var(--space-6) var(--space-4); }
.direct-page .group-add .btn { justify-self: start; }
.direct-page .compose-to,
.direct-page .compose-title { display: grid; gap: var(--space-2); }
.direct-page .compose-to label,
.direct-page .compose-title label { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.direct-page .compose-to .token-field { position: relative; }
.direct-page .compose-to .token-menu { max-height: min(22rem, 50vh); }
.direct-page .token-chip.unknown { border-color: var(--color-danger); }
.direct-page .token-option .avatar { width: 28px; height: 28px; font-size: var(--text-xs); }
.direct-page .token-option .avatar.initial { display: inline-grid; }
.direct-page .search-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); min-width: 0; }
.direct-page .search-name { font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.direct-page .search-handle { color: var(--color-text-muted); font-size: var(--text-sm); }

/* Groups: who wrote a run of bubbles. */
.direct-page .chat-sender {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-block-end: 2px;
  margin-inline-start: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.direct-page .chat-sender .avatar { width: 20px; height: 20px; font-size: 10px; }

/* A group's row in the inbox: two faces, the second over the first. */
.direct-page .chat-row-faces { position: relative; flex: none; width: 48px; height: 48px; }
.direct-page .chat-row-faces .avatar { position: absolute; width: 32px; height: 32px; font-size: var(--text-sm); box-shadow: 0 0 0 2px var(--color-surface); }
.direct-page .chat-row-faces .avatar:first-child { inset-block-start: 0; inset-inline-start: 0; }
.direct-page .chat-row-faces .avatar:nth-child(2) { inset-block-end: 0; inset-inline-end: 0; }
.direct-page .chat-row-faces .avatar:only-child { inset: 0; width: 48px; height: 48px; font-size: var(--text-lg); }
.direct-page .chat-request {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border-block-start: 1px solid var(--color-border);
  text-align: center;
}
.direct-page .chat-request p:first-child { font-weight: var(--weight-semibold); }
.direct-page .chat-request .hint { color: var(--color-text-muted); font-size: var(--text-sm); }
.direct-page .chat-request .actions { display: flex; justify-content: center; gap: var(--space-3); margin-block-start: var(--space-2); }
.direct-page .chat-request .actions .btn { min-width: 8rem; }
.direct-page .chat-declined { padding: var(--space-4); border-block-start: 1px solid var(--color-border); color: var(--color-text-muted); text-align: center; }

/* Wide screens with a conversation open: the inbox beside it, both
   scrolling inside the window's height. */
.direct-page.with-thread { height: calc(100dvh - var(--header-offset) - 2 * var(--space-6)); min-height: 28rem; }
@media (min-width: 901px) {
  .direct-page.with-thread { grid-template-columns: 22rem minmax(0, 1fr); }
  .direct-page.with-thread .direct-inbox { overflow-y: auto; }
  .direct-page.with-thread .thread-head .back { display: none; }
  .direct-page.with-thread .thread-head .back.to-thread { display: grid; }
  .direct-page.with-thread .thread-head { padding-inline-start: var(--space-4); }
}
/* Narrow: the conversation alone and full screen, as in native chat
   apps: the site header and the tab bar step aside (Layout's
   full_screen puts body.full-screen on the page; the back arrow returns
   to the inbox), and the thread is pinned edge to edge, clear of the
   safe areas. The page itself never scrolls (iOS Safari scrolls the
   page to show a focused input, and 100dvh ignores the keyboard). While
   the keyboard is open,
   chat-thread.ts sets html.chat-keyboard and the visual viewport's top
   and height: the thread then fills exactly the visible part of the
   screen. */
@media (max-width: 900px) {
  body.full-screen .site-header,
  body.full-screen .tab-bar { display: none; }
  body.full-screen { padding-block-start: 0; }
  body.full-screen .site-main,
  body.full-screen.has-tab-bar .site-main { padding: 0; }
  .direct-page.with-thread .direct-inbox { display: none; }
  .direct-page.with-thread {
    position: fixed;
    z-index: 20;
    inset: 0;
    height: auto;
    min-height: 0;
  }
  .direct-page.with-thread .direct-thread { border: 0; border-radius: 0; }
  .direct-page.with-thread .thread-head {
    padding-block-start: calc(var(--space-2) + env(safe-area-inset-top));
    padding-inline: max(var(--space-3), env(safe-area-inset-left)) max(var(--space-3), env(safe-area-inset-right));
  }
  .direct-page.with-thread .chat-footer {
    padding-block-end: env(safe-area-inset-bottom);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }
  html.chat-keyboard .direct-page.with-thread {
    inset-block: var(--chat-vv-top, 0px) auto;
    height: var(--chat-vv-height, 100dvh);
  }
  /* The keyboard covers the home indicator. */
  html.chat-keyboard .direct-page.with-thread .chat-footer { padding-block-end: 0; }
}
/* EditPostPage (app/components/edit_post_page.chad:42) */
.edit-form textarea { min-height: 8rem; }
.edit-form .link { display: grid; gap: var(--space-1); }
.edit-form .link-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.edit-form .current-image .post-image { border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.edit-form .buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* EmptyState (app/components/empty_state.chad:7) */
.empty-state {
  padding: var(--space-10) var(--space-6);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  text-align: center;
}
/* ErrorPage (app/components/error_page.chad:31) */
.error-page { display: grid; justify-items: center; gap: var(--space-3); padding-block: var(--space-12); text-align: center; }
.error-page .status { color: var(--color-tag-fg); font-size: var(--text-3xl); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.error-page p { color: var(--color-text-muted); max-width: 28rem; }
.error-page .btn { margin-block-start: var(--space-3); }
/* FeedMore (app/components/feed_more.chad:16) */
.feed-more {
  display: grid;
  gap: var(--space-3);
  place-items: center;
  min-block-size: var(--control-height);
  /* Appended posts must never hold the view on the spinner. */
  overflow-anchor: none;
}
.feed-more[data-state="done"] { display: none; }
.feed-more[data-state="idle"] .older, .feed-more[data-state="loading"] .older { display: none; }
/* The message comes above the link that retries. */
.feed-more feed-scroll { display: grid; place-items: center; order: -1; }
.feed-more feed-scroll:empty { display: none; }
.feed-more .feed-error { color: var(--color-text-muted); font-size: var(--text-sm); text-align: center; }
/* Field (app/components/field.chad:10) */
.field { display: grid; gap: var(--space-1); }
.field .field-label { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.field .field-hint { color: var(--color-text-muted); font-size: var(--text-xs); }
/* FollowAction (app/components/follow_action.chad:16) */
.follow-action { display: inline-grid; flex: none; min-width: 7.5rem; min-height: var(--control-height-sm); }
.follow-action follow-button { display: grid; }
.follow-action .follow { width: 100%; }
.follow-action .follow.following:hover { border-color: var(--color-danger); color: var(--color-danger); }
/* FollowListPage (app/components/follow_list_page.chad:16) */
.follow-list-page { display: grid; gap: var(--space-6); }
.follow-list-page .page-head { display: grid; gap: var(--space-4); }
.follow-list-page .owner { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.follow-list-page .owner h1 a { color: var(--color-text); }
.follow-list-page .owner h1 { font-size: var(--text-xl); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.follow-list-page .owner .handle { color: var(--color-text-muted); font-size: var(--text-sm); }
.follow-list-page .people {
  display: grid;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.follow-list-page .person { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.follow-list-page .person + .person { border-block-start: 1px solid var(--color-border); }
.follow-list-page .person-link { display: flex; flex: 1; align-items: center; gap: var(--space-3); min-width: 0; color: var(--color-text); }
.follow-list-page .person-link:hover { text-decoration: none; }
.follow-list-page .person-link:hover .name { text-decoration: underline; }
.follow-list-page .names { display: grid; min-width: 0; }
.follow-list-page .name { font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-list-page .person .handle { color: var(--color-text-muted); font-size: var(--text-sm); }
.follow-list-page .you { flex: none; color: var(--color-text-muted); font-size: var(--text-sm); }
/* ForgotPage (app/components/forgot_page.chad:23) */
.forgot-address { overflow-wrap: anywhere; font-weight: var(--weight-semibold); }
/* GroupDetails (app/components/group_details.chad:32) */
.group-details { display: grid; align-content: start; gap: var(--space-6); padding: var(--space-6) var(--space-4); overflow-y: auto; }
.group-details .group-id { display: grid; justify-items: center; gap: var(--space-2); text-align: center; }
.group-details .group-id h2 { font-size: var(--text-xl); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.group-details .group-id .count { color: var(--color-text-muted); font-size: var(--text-sm); }
.group-details .members { display: grid; gap: var(--space-3); }
.group-details h3 { font-size: var(--text-base); }
.group-details .people {
  display: grid;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.group-details .person { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.group-details .person + .person { border-block-start: 1px solid var(--color-border); }
.group-details .person-link { display: flex; flex: 1; align-items: center; gap: var(--space-3); min-width: 0; color: var(--color-text); }
.group-details .person-link:hover { text-decoration: none; }
.group-details .person-link:hover .name { text-decoration: underline; }
.group-details .names { display: grid; min-width: 0; }
.group-details .name { font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-details .person .handle { color: var(--color-text-muted); font-size: var(--text-sm); }
.group-details .you { flex: none; color: var(--color-text-muted); font-size: var(--text-sm); }
.group-details .owner {
  flex: none;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.group-details .add-people .name { color: var(--color-text); }
.group-details .add-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-surface-sunken);
}
.group-details group-member-menu { display: block; flex: none; }
.group-details .member-menu-button {
  display: inline-grid;
  place-items: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.group-details .member-menu-button:hover,
.group-details .member-menu-button[aria-expanded="true"] { background: var(--color-surface-sunken); color: var(--color-text); }
.group-details .member-dialog {
  width: min(24rem, 100vw - 2 * var(--space-4));
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}
.group-details .member-dialog::backdrop { background: var(--color-scrim); }
.group-details .member-dialog-body { display: grid; gap: var(--space-3); padding: var(--space-5); }
.group-details .member-dialog-body h2 { font-size: var(--text-lg); overflow-wrap: anywhere; }
.group-details .member-dialog-body .hint { color: var(--color-text-muted); font-size: var(--text-sm); }
.group-details .member-dialog-error { color: var(--color-danger); font-size: var(--text-sm); }
.group-details .member-dialog-actions { display: flex; justify-content: end; gap: var(--space-2); margin-block-start: var(--space-2); }
/* HomePage (app/components/home_page.chad:32) */
.home-page { display: grid; gap: var(--space-6); }
.home-page .page-head { display: grid; gap: var(--space-4); }
.home-page .feed-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.home-page .posts { display: grid; gap: var(--space-4); }
.home-page .empty-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-block-start: var(--space-4); }
/* ImageField (app/components/image_field.chad:14) */
.image-field { display: grid; gap: var(--space-2); }
image-picker { display: grid; gap: var(--space-2); }
image-picker:empty { display: none; }
.image-picker-preview {
  display: block;
  max-inline-size: 100%;
  max-block-size: 320px;
  inline-size: auto;
  block-size: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
}
.image-picker-error {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: var(--text-sm);
}
.image-picker-error[hidden] { display: none; }
/* ItemPreview (app/components/item_preview.chad:14) */
.item-preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  color: var(--color-text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.item-preview:hover { border-color: var(--color-border-strong); text-decoration: none; }
.item-preview .text { display: grid; gap: 2px; min-width: 0; }
.item-preview .title { font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.item-preview .domain { color: var(--color-text-muted); font-size: var(--text-sm); }
.item-preview .icon { flex: none; margin-inline-start: auto; color: var(--color-text-muted); }
[dir="rtl"] .item-preview .icon { transform: scaleX(-1); }
.item-preview .image { display: block; background: var(--color-border); object-fit: cover; }
/* Wide: the image spans the card, edge to edge, above the text row. */
.item-preview.wide { flex-wrap: wrap; padding: 0 0 var(--space-3); }
.item-preview.wide .image {
  flex: 1 0 100%;
  inline-size: 100%;
  block-size: auto;
  max-block-size: 340px;
  border-block-end: 1px solid var(--color-border);
}
.item-preview.wide .text { flex: 1; padding-inline-start: var(--space-4); }
.item-preview.wide .icon { margin-inline-end: var(--space-4); }
/* Square or portrait: a thumbnail beside the text. */
.item-preview.thumb { padding-block: var(--space-3); padding-inline-start: var(--space-3); }
.item-preview.thumb .image {
  flex: none;
  inline-size: 72px;
  block-size: 72px;
  border-radius: var(--radius-sm);
}
/* Layout (app/components/layout.chad:137) */
/* The header's height with its border and the status bar's safe area
   (the home-screen app draws under it: viewport-fit=cover). */
:root { --header-offset: calc(var(--header-height) + 1px + env(safe-area-inset-top)); }
html { scroll-padding-block-start: var(--header-offset); }
body { padding-block-start: var(--header-offset); }
.site-header {
  position: fixed;
  z-index: 10;
  inset-block-start: 0;
  inset-inline: 0;
  padding-block-start: env(safe-area-inset-top);
  border-block-end: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
}
.site-header .inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: var(--content-width);
  height: var(--header-height);
  margin: 0 auto;
  padding: var(--space-2) max(var(--space-4), env(safe-area-inset-right)) var(--space-2) max(var(--space-4), env(safe-area-inset-left));
}
.site-header .wordmark {
  display: inline-grid;
  place-items: center;
  margin-inline-start: calc(-1 * var(--space-1));
  padding: var(--space-1);
  border-radius: var(--radius-md);
  text-decoration: none;
}
.site-header .wordmark:hover { text-decoration: none; }
.site-header .wordmark:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.site-header .logo { display: block; }
.site-header .logo-bubble { fill: var(--color-logo-bubble); }
.site-header .logo-figures { fill: var(--color-logo-figures); }
/* The front figure's outline separates it from the two behind it. */
.site-header .logo-front { stroke: var(--color-logo-bubble); }
.site-header .logo-rays { fill: var(--color-logo-rays); stroke: var(--color-logo-rays); }
.site-header .search-link {
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  margin-inline-start: calc(-1 * var(--space-2));
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
}
.site-header .search-link:hover { background: var(--color-surface-sunken); color: var(--color-text); }
.site-header .search-link[aria-current="page"] { color: var(--color-text); }
.site-header .site-nav { display: flex; align-items: center; gap: var(--space-2); margin-inline-start: auto; }
.site-header .viewer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-inline-end: var(--space-1);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}
.site-header .viewer:hover { color: var(--color-text); }
.site-header .viewer:hover .viewer-handle { text-decoration: underline; }
.site-header .viewer:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.site-header .viewer .avatar { display: grid; width: 32px; height: 32px; font-size: var(--text-sm); }
.site-header .messages-link {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
}
.site-header .messages-link:hover { background: var(--color-surface-sunken); color: var(--color-text); }
.site-header .messages-link[aria-current="page"] { color: var(--color-text); }
/* The unread count: a pill over the icon's inline-end corner. */
.chat-count {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-end: 0;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid var(--color-surface);
  border-radius: var(--radius-full);
  background: var(--color-badge-bg);
  color: var(--color-badge-fg);
  font-size: 11px;
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-sizing: content-box;
}
.chat-count[hidden] { display: none; }
.site-main { display: grid; gap: var(--space-6); max-width: var(--content-width); margin: 0 auto; padding: var(--space-8) var(--space-4) calc(var(--space-12) + var(--push-prompt-space, 0px)); }
.site-main.wide { max-width: 64rem; padding-block: var(--space-6); }

/* Pull to refresh (PullRefresh, app/web/pull-refresh.ts). The spinner
   waits under the header and follows the pull (--pull) down from its
   bottom edge, its ring filling with --pull-progress. Pages that have it
   keep Chrome's own pull-to-refresh, a full reload, from firing too. */
html.pull-refresh { overscroll-behavior-y: contain; }
.pull-refresh-indicator {
  position: fixed;
  z-index: 9;
  inset-block-start: var(--header-offset);
  inset-inline: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-inline: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  opacity: min(1, calc(var(--pull-progress, 0) * 3));
  transform: translateY(calc(var(--pull, 0px) - 100% - 2px));
  transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out);
  pointer-events: none;
}
.pull-refresh-indicator.dragging { transition: none; }
.pull-refresh-indicator svg { transform: rotate(calc(var(--pull-progress, 0) * 270deg - 90deg)); }
.pull-refresh-indicator .ring {
  stroke-dashoffset: var(--pull-dash, 57);
  transition: stroke-dashoffset 200ms var(--ease-out);
}
.pull-refresh-indicator.dragging .ring { transition: none; }
.pull-refresh-indicator.armed { transform: translateY(calc(var(--pull, 0px) - 100% - 2px)) scale(1.1); }
/* Refreshing: a quarter-open ring that spins (pulses with reduced motion). */
.pull-refresh-indicator.refreshing .ring { stroke-dashoffset: 14; }
.pull-refresh-indicator.refreshing svg { animation: pull-refresh-spin 800ms linear infinite; }
@keyframes pull-refresh-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pull-refresh-pulse { 50% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) {
  .pull-refresh-indicator.refreshing svg { animation: pull-refresh-pulse 1.2s ease-in-out infinite; }
}
.pull-refresh-toast {
  position: fixed;
  z-index: 30;
  inset-block-end: calc(var(--space-6) + var(--tab-bar-offset, 0px));
  inset-inline: var(--space-4);
  max-width: 28rem;
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  text-align: center;
}
.pull-refresh-toast[hidden] { display: none; }

/* The notifications banner (PushPrompt, app/web/push-prompt.ts): a card
   above the tab bar, or in the bottom corner. Pages end with room for
   it, and it makes way for typing. */
.push-card {
  position: fixed;
  z-index: 9;
  inset-block-end: calc(var(--space-4) + var(--tab-bar-offset, env(safe-area-inset-bottom)));
  inset-inline-end: max(var(--space-4), env(safe-area-inset-right), env(safe-area-inset-left));
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: var(--space-3);
  inline-size: 24rem;
  max-inline-size: calc(100% - 2 * var(--space-4));
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  animation: push-card-in 200ms var(--ease-out);
}
@keyframes push-card-in { from { opacity: 0; transform: translateY(var(--space-4)); } }
.push-card .push-bell { color: var(--color-text-muted); }
.push-card .push-text { display: grid; gap: var(--space-1); min-width: 0; }
.push-card .push-title { font-weight: var(--weight-semibold); line-height: var(--leading-tight); }
.push-card .push-settings { display: inline-flex; align-items: center; justify-self: start; min-height: 44px; color: var(--color-link); font-size: var(--text-sm); text-decoration: underline; }
.push-card .push-body { color: var(--color-text-muted); font-size: var(--text-sm); }
.push-card .push-steps { display: grid; gap: var(--space-1); padding-inline-start: var(--space-5); font-size: var(--text-sm); list-style: decimal; }
.push-card .push-steps:focus { outline: none; }
.push-card .push-error { color: var(--color-danger); font-size: var(--text-sm); }
.push-card .push-actions { grid-column: 1 / -1; display: flex; gap: var(--space-2); }
.push-card .push-actions .btn { flex: 1; min-height: 44px; }
body:has(.push-card) { --push-prompt-space: 12rem; }
body:has(input:focus, textarea:focus, select:focus) .push-card { display: none; }
@media (prefers-reduced-motion: reduce) { .push-card { animation: none; } }

.tab-bar { display: none; }
.tab-bar .tab {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: var(--tab-bar-height);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.tab-bar .tab:hover { color: var(--color-text); text-decoration: none; }
.tab-bar .tab:focus-visible { outline-offset: -4px; }
.tab-bar .tab[aria-current="page"] { color: var(--color-text); font-weight: var(--weight-semibold); }
.tab-bar .icon { width: 24px; height: 24px; }
.tab-bar .tab-icon { position: relative; display: grid; }
.tab-bar .chat-count { inset-block-start: -4px; inset-inline-end: -10px; }
.tab-bar .avatar { display: grid; width: 24px; height: 24px; font-size: var(--text-xs); }
.tab-bar .tab[aria-current="page"] .avatar { box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-text); }

@media (max-width: 640px) {
  .site-main { padding-block-start: var(--space-6); }
  /* The tab bar replaces the header's navigation; the logo is centered. */
  .site-header .site-nav.signed-in { display: none; }
  body.has-tab-bar .site-header .inner { justify-content: center; }
  body.has-tab-bar .site-header .search-link { display: none; }
  .tab-bar {
    position: fixed;
    z-index: 10;
    inset-inline: 0;
    inset-block-end: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-block-end: env(safe-area-inset-bottom);
    border-block-start: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
  }
  /* Fixed things near the bottom (toasts) and the end of the page clear it. */
  body.has-tab-bar { --tab-bar-offset: calc(var(--tab-bar-height) + env(safe-area-inset-bottom)); }
  body.has-tab-bar .site-main { padding-block-end: calc(var(--space-12) + var(--push-prompt-space, 0px) + var(--tab-bar-offset)); }
}

/* Tooltips (app/web/hover-tip.ts, which sets top and left). */
.hover-tip {
  position: fixed;
  inset: auto;
  max-inline-size: min(20rem, 100vw - 2 * var(--space-2));
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  line-height: 1.4;
}
.hover-tip:popover-open { animation: hover-tip-in var(--duration-fast) var(--ease-out); }
@keyframes hover-tip-in { from { opacity: 0; } }
/* LegalLinks (app/components/legal_links.chad:15) */
.legal-links { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); }
.legal-links a { color: var(--color-text-muted); }
/* LegalText (app/components/legal_text.chad:12) */
.legal-text { display: grid; gap: var(--space-4); }
.legal-text h2 { margin-block-start: var(--space-4); font-size: var(--text-lg); }
.legal-text ul { display: grid; gap: var(--space-2); padding-inline-start: var(--space-5); }
.legal-text .legal-updated { color: var(--color-text-muted); font-size: var(--text-sm); }
/* ListFields (app/components/list_fields.chad:29) */
.list-fields { display: grid; gap: var(--space-4); }
.list-fields fieldset { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.list-fields .group-legend { padding: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.list-fields .group-hint { margin: 0; color: var(--color-text-muted); font-size: var(--text-xs); }
.list-fields .order { display: grid; gap: var(--space-2); }
.list-fields .order-options { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.list-fields .order-option { display: inline-flex; align-items: center; gap: var(--space-2); }
.list-fields .order-option input { accent-color: var(--color-accent); inline-size: 1.1rem; block-size: 1.1rem; margin: 0; }
.list-fields .entries { display: grid; gap: var(--space-3); }
.list-fields .entries > .group-legend { margin-block-end: var(--space-1); }
.list-fields .group-hint { margin-block-start: calc(-1 * var(--space-2)); }
.list-fields .list-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
}
.list-fields .list-entry.invalid { border-color: var(--color-danger); }
.list-fields .list-entry-head { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-2); min-block-size: var(--control-height-sm); }
.list-fields .list-entry-legend { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
/* ListEditor's row controls, at the head's inline end (app/web/list-editor.ts). */
.list-fields .list-entry-tools { display: flex; gap: var(--space-1); margin-inline-start: auto; }
.list-fields .list-entry-tools .btn { padding-inline: var(--space-2); }
.list-fields .list-entry-field { display: grid; gap: var(--space-1); font-size: var(--text-sm); }
.list-fields .list-entry-field.note { grid-column: 1 / -1; }
.list-fields .list-entry textarea { min-height: 0; }
/* Island (light DOM, see app/web/list-editor.ts): Add entry and the
   counter, under the rows. Empty until the module loads. */
.list-fields list-editor { display: block; }
.list-fields .list-editor-bar { display: flex; align-items: center; gap: var(--space-3); }
.list-fields .list-editor-counter { margin-inline-start: auto; color: var(--color-text-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .list-fields .list-entry { grid-template-columns: minmax(0, 1fr); }
}
/* ListPreview (app/components/list_preview.chad:70) */
.list-preview { display: grid; gap: var(--space-3); }
.list-preview .list-head { display: grid; gap: var(--space-1); }
.list-preview .list-title { margin: 0; font-size: var(--text-xl); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.list-preview .list-title a { color: inherit; text-decoration: none; }
.list-preview .list-title a:hover { text-decoration: underline; }
.list-preview .list-meta { color: var(--color-text-muted); font-size: var(--text-sm); }
.list-preview .list-intro { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
/* Cards: the intro is a teaser, the permalink has all of it. */
.list-preview .list-intro.clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.list-preview .list-items {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.list-preview .list-row {
  display: grid;
  grid-template-columns: 2ch 40px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  color: var(--color-text);
}
/* A linked entry: the whole row is the link, as with ItemPreview. */
.list-preview a.list-row { text-decoration: none; transition: border-color var(--duration-fast) var(--ease-out); }
.list-preview a.list-row:hover { border-color: var(--color-border-strong); text-decoration: none; }
.list-preview a.list-row:hover .list-name { text-decoration: underline; }
.list-preview .list-marker {
  color: var(--color-text-muted);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  text-align: end;
}
.list-preview .list-thumb {
  display: block;
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-border);
  object-fit: cover;
}
.list-preview .list-text { display: grid; gap: 2px; min-width: 0; }
.list-preview .list-name { color: var(--color-text); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.list-preview .list-domain { color: var(--color-text-muted); font-size: var(--text-sm); }
.list-preview .list-note { display: block; color: var(--color-text); font-size: var(--text-sm); white-space: pre-line; overflow-wrap: anywhere; }
.list-preview .list-more { justify-self: start; color: var(--color-text-muted); font-size: var(--text-sm); }
.list-preview .list-more:hover { color: var(--color-text); }
/* NewPostPage (app/components/new_post_page.chad:102) */
.compose-form textarea { min-height: 8rem; }
.compose .kinds { margin-block: var(--space-3) var(--space-4); }
.compose-form .send { display: grid; }
.compose-form .send .notice { margin-block: 0 var(--space-3); }
.compose-form .send .btn:disabled { opacity: 0.6; cursor: default; }
/* Notice (app/components/notice.chad:16) */
.notice {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-inline-start-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
  font-size: var(--text-sm);
}
.notice.info { border-inline-start-color: var(--color-accent); }
.notice.success { border-color: var(--color-success); color: var(--color-success); background: var(--color-surface); }
.notice.success a { color: inherit; font-weight: var(--weight-semibold); }
.notice.error { border-color: var(--color-danger); background: var(--color-danger-soft); color: var(--color-danger); }
/* Panel (app/components/panel.chad:8) */
.panel {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.panel h1 { font-size: var(--text-xl); }
.panel form { display: grid; gap: var(--space-4); }
.panel form .btn { justify-self: start; }
.panel .panel-footer { color: var(--color-text-muted); font-size: var(--text-sm); }
@media (max-width: 480px) { .panel { padding: var(--space-4); } }
/* PostCard (app/components/post_card.chad:30) */
.post-card {
  --post-card-pad: var(--space-5);
  display: grid;
  gap: var(--space-4);
  padding: var(--post-card-pad);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.post-card .author { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
/* The whole author block (avatar, name, handle) is one link to the profile. */
.post-card .author-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.post-card .author-link:hover { text-decoration: none; }
.post-card .author-link:hover .name { text-decoration: underline; }
/* The follow button next to the author: compact, so the date still fits
   on a phone. */
.post-card .author .follow-action { min-width: 5.5rem; }
.post-card .who { display: grid; min-width: 0; line-height: var(--leading-tight); }
.post-card .name { color: var(--color-text); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.post-card .handle { color: var(--color-text-muted); font-size: var(--text-sm); }
.post-card .meta { display: grid; justify-items: end; gap: var(--space-1); margin-inline-start: auto; text-align: end; }
.post-card .permalink, .post-card .more-tag { color: var(--color-text-muted); font-size: var(--text-sm); white-space: nowrap; }
/* Date plus expand icon: one link, one tap target, to the post page. */
.post-card .permalink { display: inline-flex; align-items: center; gap: var(--space-1); }
.post-card .permalink .icon { flex: none; }
.post-card a.permalink:hover, .post-card .more-tag:hover { color: var(--color-text); }
/* The title of a post without a link, as on a list (ListPreview). */
.post-card .post-title { margin: 0; font-size: var(--text-xl); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.post-card .post-title a { color: inherit; text-decoration: none; }
.post-card .post-title a:hover { text-decoration: underline; }
.post-card .body { white-space: pre-line; overflow-wrap: anywhere; }
/* The category kicker sits close to what it labels. */
.post-card .category-kicker + * { margin-block-start: calc(-1 * var(--space-2)); }
/* The footer is only the actions, reactions at the start, comments and
   share at the end, so it stays one line however many tags the post has: the
   tags sit with the text, above the link or picture. */
.post-card .foot { display: flex; align-items: center; gap: var(--space-3); }
/* Island (light DOM, see app/web/reaction-bar.ts). The min size keeps
   the card from jumping when the module loads. */
.post-card reaction-bar { display: block; min-block-size: var(--control-height-sm); margin-inline-end: auto; }
.post-card .reactions { display: flex; gap: var(--space-2); }
.post-card .reaction {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-block-size: var(--control-height-sm);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.post-card .reaction:hover { border-color: var(--color-border-strong); color: var(--color-text); text-decoration: none; }
.post-card .reaction[aria-pressed="true"] { border-color: var(--color-selected-border); background: var(--color-selected-bg); color: var(--color-selected-fg); }
.post-card .reaction svg { flex: none; }
/* The comments: a link to them on the post page, where the count is kept
   current by CommentThread (data-comment-count). */
.post-card .comment-count {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-block-size: var(--control-height-sm);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.post-card .comment-count:hover { border-color: var(--color-border-strong); color: var(--color-text); text-decoration: none; }
.post-card .comment-count svg { flex: none; }
/* Island (light DOM, see app/web/share-menu.ts): a round button at the
   footer's inline end, as tall as the reactions. Its menu is the
   .action-menu primitive (theme.css). The min size keeps the footer
   from jumping when the module loads. */
.post-card share-menu { display: block; min-inline-size: var(--control-height-sm); min-block-size: var(--control-height-sm); }
.post-card .share-button {
  display: inline-grid;
  place-items: center;
  inline-size: var(--control-height-sm);
  block-size: var(--control-height-sm);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
.post-card .share-button:hover,
.post-card .share-button[aria-expanded="true"] { border-color: var(--color-border-strong); background: var(--color-surface-sunken); color: var(--color-text); }
/* The arrow points forward: mirror it in RTL. */
.post-card .share-button:dir(rtl) svg { transform: scaleX(-1); }
/* The item preview bleeds to the card's inline edges: no side margin,
   side borders or rounded corners, only the top and bottom rules. */
.post-card .item-preview {
  margin-inline: calc(-1 * var(--post-card-pad));
  border-inline: 0;
  border-radius: 0;
}
/* An image post's picture bleeds the same way. */
.post-card .post-image { margin-inline: calc(-1 * var(--post-card-pad)); }
@media (max-width: 480px) { .post-card { --post-card-pad: var(--space-4); } }
/* PostComments (app/components/post_comments.chad:52) */
.comments { --comment-face: 40px; --comment-field: 44px; display: grid; gap: var(--space-4); min-width: 0; }
/* On a card it is part of the card. */
.comments.in-card { padding-block-start: var(--space-4); border-block-start: 1px solid var(--color-border); }
.comments.on-page {
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.comments .comments-title { display: flex; align-items: baseline; gap: var(--space-2); font-size: var(--text-lg); }
.comments .comments-title:focus { outline: none; }
.comments .comments-total {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
/* Island (light DOM, see app/web/comment-thread.ts). The min size is the
   composer's, so the comments don't move when the module loads. */
.comments comment-thread { display: grid; gap: var(--space-4); min-block-size: var(--comment-field); }
.comments .comment-list { display: grid; gap: var(--space-5); }
.comments .comment { display: grid; gap: var(--space-4); min-width: 0; }
/* Scrolled to: clear of the header's edge and the fixed tab bar. */
.comments .comment, .comments .comment-field {
  scroll-margin-block: var(--space-4) calc(var(--space-4) + var(--tab-bar-offset, 0px));
}
.comments .comment-row { display: flex; align-items: flex-start; gap: var(--space-3); min-width: 0; }
/* The one the URL links to. The margin keeps its text in line with the
   others'. */
.comments .comment-row.linked {
  margin-inline: calc(-1 * var(--space-3));
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  scroll-margin-block: var(--space-4) calc(var(--space-4) + var(--tab-bar-offset, 0px));
}
/* An initial's circle is the same color as the highlight. */
.comments .comment-row.linked .avatar.initial { background: var(--color-surface); }
.comments .comment-row.linked:focus { outline: none; }
.comments .comment-linked { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.comments .comment-face { flex: none; border-radius: var(--radius-full); text-decoration: none; }
.comments .comment-face .avatar { width: var(--comment-face); height: var(--comment-face); }
.comments .comment-main { display: grid; flex: 1; gap: var(--space-1); min-width: 0; }
.comments .comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--space-2);
  position: relative;
  min-width: 0;
  line-height: var(--leading-tight);
}
/* Room for the options button, which sits out of the flow so that a
   comment with one is as tall as a comment without. */
.comments .comment-head.has-menu { padding-inline-end: calc(var(--control-height-sm) + var(--space-1)); }
.comments .comment-name { color: var(--color-text); font-size: var(--text-sm); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.comments .comment-time { color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }
.comments .comment-badge {
  padding: 0 var(--space-2);
  border: 1px solid var(--color-selected-border);
  border-radius: var(--radius-full);
  background: var(--color-selected-bg);
  color: var(--color-selected-fg);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.comments .comment-body { white-space: pre-line; overflow-wrap: anywhere; }
.comments .comment-body.clamped {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  line-clamp: 6;
}
.comments .comment-actions { display: flex; flex-wrap: wrap; gap: var(--space-4); min-block-size: var(--control-height-sm); }
/* Reply, Read more, more replies: text, in a 32px tall target. */
.comments .comment-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  justify-self: start;
  min-block-size: var(--control-height-sm);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
}
.comments .comment-link:hover { color: var(--color-text); text-decoration: underline; }
.comments .comment-link[aria-busy="true"] { cursor: progress; }
.comments .comment-more { justify-self: center; }
.comments [data-comments-static] { display: grid; gap: var(--space-4); min-width: 0; }
/* One layer of replies, indented to the text above it. */
.comments .comment-replies {
  --comment-face: 32px;
  display: grid;
  gap: var(--space-4);
  min-width: 0;
  margin-inline-start: calc(40px + var(--space-3));
}
.comments .comment-replies .comment-list { gap: var(--space-4); }
.comments action-menu { display: block; }
.comments .comment-menu { position: absolute; inset-block-start: 50%; inset-inline-end: 0; translate: 0 -50%; }
.comments .comment-menu-button {
  display: inline-grid;
  place-items: center;
  inline-size: var(--control-height-sm);
  block-size: var(--control-height-sm);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.comments .comment-menu-button:hover,
.comments .comment-menu-button[aria-expanded="true"] { background: var(--color-surface-sunken); color: var(--color-text); }
/* The composer: one line until it's used. */
.comments .comment-field { display: block; flex: 1; min-width: 0; }
.comments .comment-composer { display: grid; gap: var(--space-2); min-width: 0; }
.comments .comment-composer textarea { min-block-size: var(--control-height); max-block-size: 16rem; resize: none; overflow: hidden; }
.comments .comment-composer textarea[aria-invalid="true"] { border-color: var(--color-danger); }
.comments .composer-foot { display: flex; align-items: center; gap: var(--space-2); }
.comments .composer-count { margin-inline-end: auto; color: var(--color-text-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.comments .composer-count.over { color: var(--color-danger); font-weight: var(--weight-semibold); }
.comments .composer-foot .btn:disabled, .comments .composer-foot .btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }
/* Empty, they are only there to be announced: no gap for them. */
.comments [role="alert"]:empty { position: absolute; }
.comments .comment-error { color: var(--color-danger); font-size: var(--text-sm); }
.comments .comment-empty { color: var(--color-text-muted); font-size: var(--text-sm); }
.comments .comment-sign-in { justify-self: start; min-block-size: var(--comment-field); }
.comments .comment-dialog {
  width: min(24rem, 100vw - 2 * var(--space-4));
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}
.comments .comment-dialog::backdrop { background: var(--color-scrim); }
.comments .comment-dialog-body { display: grid; gap: var(--space-3); padding: var(--space-5); }
.comments .comment-dialog-body h3 { font-size: var(--text-lg); }
.comments .comment-dialog-body .hint { color: var(--color-text-muted); font-size: var(--text-sm); }
.comments .comment-dialog-actions { display: flex; justify-content: end; gap: var(--space-2); margin-block-start: var(--space-2); }
@media (max-width: 480px) {
  .comments.on-page { padding: var(--space-4); }
  .comments .comment-replies { margin-inline-start: var(--space-8); }
}
/* PostImage (app/components/post_image.chad:16) */
.post-image {
  display: grid;
  overflow: hidden;
  border-block: 1px solid var(--color-border);
  background: var(--color-surface-sunken);
}
.post-image > * { grid-area: 1 / 1; }
.post-image .post-image-img {
  display: block;
  inline-size: 100%;
  block-size: auto;
  max-block-size: 520px;
  object-fit: cover;
}
/* The island (app/web/photo-viewer.ts, light DOM): a transparent button
   over the whole picture. */
.post-image photo-viewer { display: block; min-block-size: 0; }
.post-image .photo-button {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.post-image .photo-button:focus-visible { outline: 3px solid var(--color-focus); outline-offset: -3px; }
/* PostPage (app/components/post_page.chad:16) */
.post-page { display: grid; gap: var(--space-4); }
.post-page .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.post-page .actions .icon { flex: none; }
/* ProfilePage (app/components/profile_page.chad:43) */
.profile-page { display: grid; gap: var(--space-6); }
.profile-page .page-head { display: grid; gap: var(--space-5); }
.profile-page .identity { display: flex; align-items: center; gap: var(--space-5); min-width: 0; }
.profile-page .who { display: grid; gap: var(--space-1); min-width: 0; }
.profile-page h1 { font-size: var(--text-2xl); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.profile-page .handle { color: var(--color-text-muted); }
.profile-page .stats { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); color: var(--color-text); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.profile-page .stats a { color: inherit; }
.profile-page .follow-slot { display: flex; flex: none; flex-wrap: wrap; justify-content: end; gap: var(--space-2); align-self: flex-start; margin-inline-start: auto; }
.profile-page .message-link { min-width: 6rem; }
@media (max-width: 480px) { .profile-page .follow-slot { flex-direction: column; } }
.profile-page .posts { display: grid; gap: var(--space-4); }

/* The avatar editor and viewer (avatar-editor.ts, avatar-viewer.ts)
   are styled in avatar.chad: group details pages use them too. */

/* Own profile: the gear opens /settings. */
.profile-page .settings-link {
  flex: none;
  align-self: flex-start;
  width: 44px;
  min-height: 44px;
  margin-inline-start: auto;
  padding: 0;
  border-radius: var(--radius-full);
}
@media (max-width: 480px) {
  .profile-page .identity { gap: var(--space-4); }
  .profile-page h1 { font-size: var(--text-xl); }
}
/* RegisterFinishPage (app/components/register_finish_page.chad:18) */
.handle-field { display: grid; gap: var(--space-1); }
.handle-field handle-check { display: block; min-block-size: 1lh; font-size: var(--text-xs); }
.handle-field .handle-note { color: var(--color-text-muted); }
.handle-field .handle-note.available { color: var(--color-success); }
.handle-field .handle-note.taken, .handle-field .handle-note.invalid { color: var(--color-danger); }
/* ScopeSwitch (app/components/scope_switch.chad:14) */
.scope-switch .scope-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
}
.scope-switch .scope-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height-sm);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  white-space: nowrap;
}
.scope-switch .scope-link:hover { background: var(--color-surface-sunken); color: var(--color-text); text-decoration: none; }
.scope-switch .scope-link.current {
  border-color: var(--color-selected-border);
  background: var(--color-selected-bg);
  color: var(--color-selected-fg);
}
/* SearchBox (app/components/search_box.chad:12) */
.search-box { position: relative; min-height: var(--control-height); }
.search-box search-bar { display: block; }
.search-box .search-bar { position: relative; display: flex; align-items: flex-start; gap: var(--space-2); }

/* The token field (theme.css) as a pill on one line; a rounded box (not
   a stadium) once chips wrap. The magnifier stays beside the chips,
   centered. */
.search-box .token-field {
  padding: var(--space-1) var(--space-4);
  border-radius: calc(var(--control-height) / 2);
}
.search-box .search-icon { flex: none; color: var(--color-text-muted); }

/* People in the suggestions. */
.search-box .token-option .avatar { width: 28px; height: 28px; font-size: var(--text-xs); }
.search-box .token-option .avatar.initial { display: inline-grid; }
.search-box .search-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); min-width: 0; }
.search-box .search-name { font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.search-box .search-handle { color: var(--color-text-muted); font-size: var(--text-sm); }

/* Narrow screens: the full screen view, a native <dialog>. */
.search-box .search-sheet {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-bg);
  color: var(--color-text);
}
.search-box .search-sheet[open] { display: block; }
.search-box .search-sheet::backdrop { background: var(--color-bg); }
.search-box .search-sheet-form { display: grid; grid-template-rows: auto 1fr; gap: 0; height: 100%; }
.search-box .search-sheet-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: calc(var(--space-2) + env(safe-area-inset-top)) var(--space-3) var(--space-2);
  border-block-end: 1px solid var(--color-border);
  background: var(--color-surface);
}
.search-box .search-back {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text);
  cursor: pointer;
}
.search-box .search-back:hover { background: var(--color-surface-sunken); }
.search-box .search-back-icon:dir(rtl) { transform: scaleX(-1); }
.search-box .search-sheet .token-menu {
  padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
}
.search-box .search-sheet .token-option { min-height: 48px; }
.search-box .search-hint { padding: var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); }
/* SearchPage (app/components/search_page.chad:45) */
.search-page { display: grid; gap: var(--space-6); }
.search-page .page-head { display: grid; gap: var(--space-4); }
.search-page .posts { display: grid; gap: var(--space-4); }
/* SettingsPage (app/components/settings_page.chad:15) */
.settings-page .head { display: flex; align-items: center; gap: var(--space-2); }
.settings-page .back { display: grid; place-items: center; width: 44px; height: 44px; margin-inline-start: calc(-1 * var(--space-3)); border-radius: var(--radius-full); color: var(--color-text); }
.settings-page .back:hover { background: var(--color-surface-sunken); }
.settings-page .back svg:dir(rtl) { transform: scaleX(-1); }
.settings-page h1 { font-size: var(--text-2xl); }
.settings-page h2 { font-size: var(--text-lg); }
.settings-page { display: grid; gap: var(--space-6); }
.settings-page .setting { display: grid; gap: var(--space-3); }
.settings-page .hint { color: var(--color-text-muted); font-size: var(--text-sm); }
.settings-page push-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.settings-page push-toggle:empty { display: none; }
.settings-page .push-note { color: var(--color-text-muted); font-size: var(--text-sm); }
.settings-page .rows { display: grid; }
.settings-page .row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 48px; border-block-end: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; }
.settings-page .row:hover { text-decoration: underline; }
.settings-page .row svg { flex: none; color: var(--color-text-muted); }
.settings-page .row svg:dir(rtl) { transform: scaleX(-1); }
.settings-page .panel form .btn { justify-self: stretch; min-height: 48px; }
.settings-page .push-error { color: var(--color-danger); font-size: var(--text-sm); }
/* TagField (app/components/tag_field.chad:16) */
tag-input { position: relative; display: block; }
tag-input:empty { display: none; }
/* TagInput hides the plain input; theme.css's input rule would show it. */
.tag-field input[hidden] { display: none; }
/* --token-room: the room tag-input.ts measured on that side. */
.tag-field .token-dropdown { max-height: min(16rem, var(--token-room, 40vh)); }
.tag-field .token-dropdown.token-up { inset-block: auto calc(100% + var(--space-1)); }
/* TagList (app/components/tag_list.chad:10) */
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* TagPage (app/components/tag_page.chad:65) */
.tag-page { display: grid; gap: var(--space-6); }
.tag-page .page-head { display: grid; gap: var(--space-4); }
.tag-page .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.tag-page h1 { font-size: var(--text-3xl); color: var(--color-tag-fg); }
.tag-page h1 .hash { opacity: 0.55; }
.tag-page .tag-followers { color: var(--color-text-muted); font-size: var(--text-sm); }
.tag-page .title-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-inline-start: auto; }
/* The follow button's space is reserved, so nothing moves when the module loads. */
.tag-page .tag-follow { display: inline-grid; min-width: 7.5rem; min-height: var(--control-height-sm); }
.tag-page .tag-follow tag-follow-button { display: grid; }
.tag-page .tag-follow .follow { width: 100%; }
.tag-page .tag-follow .follow.following:hover { border-color: var(--color-danger); color: var(--color-danger); }
.tag-page .scope { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); }
.tag-page .people { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag-page .person {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
}
.tag-page .person .handle { color: var(--color-text-muted); }
.tag-page .filter { display: flex; align-items: center; gap: var(--space-2); }
.tag-page .filter-label { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.tag-page .filter input { flex: 1; min-width: 0; }
.tag-page .posts { display: grid; gap: var(--space-4); }
/* TagPill (app/components/tag_pill.chad:15) */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 28px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-tag-border);
  border-radius: var(--radius-tag);
  background: var(--color-tag-bg);
  color: var(--color-tag-fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.tag-pill:hover { background: var(--color-tag-hover-bg); text-decoration: none; }
.tag-pill .hash { opacity: 0.6; }
.tag-pill .count {
  margin-inline-start: var(--space-1);
  padding-inline-start: var(--space-2);
  border-inline-start: 1px solid var(--color-tag-border);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.tag-pill.current { background: var(--color-tag-current-bg); border-color: var(--color-tag-current-bg); color: var(--color-tag-current-fg); }
.tag-pill.current .hash { opacity: 0.75; }
.tag-pill.current .count { border-color: currentColor; }
