/* 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-*), 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;

  /* ---- 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-focus: var(--blue-600);           /* 5.2:1 on surface */
  /* 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;
  --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-focus: var(--gray-300);         /* 12.1:1 on surface */

    --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;
  }

  /* ---- buttons --------------------------------------------------------- */
  .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%); } }

  /* ---- 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);
  }
  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); } }

/* 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);
}
/* EditPostPage (app/components/edit_post_page.chad:33) */
.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:30) */
.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); }
/* 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); }
.follow-list-page .older { justify-self: center; }
/* HomePage (app/components/home_page.chad:25) */
.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 .older { justify-self: center; }
.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:57) */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  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);
  min-height: 60px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-4);
}
.site-header .wordmark {
  color: var(--color-text);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.site-header .wordmark:hover { text-decoration: none; }
.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-main { display: grid; gap: var(--space-6); max-width: var(--content-width); margin: 0 auto; padding: var(--space-8) var(--space-4) var(--space-12); }

.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 .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(4, 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(--tab-bar-offset)); }
}
/* NewPostPage (app/components/new_post_page.chad:67) */
.compose-form textarea { min-height: 8rem; }
.compose .kinds { margin-block: var(--space-3) var(--space-4); }
/* Notice (app/components/notice.chad:15) */
.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.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:24) */
.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); }
.post-card .body { white-space: pre-line; overflow-wrap: anywhere; }
.post-card .foot { display: flex; flex-wrap: wrap; 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-start: 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; }
/* 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); }
.post-card .share-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;
}
.post-card .share-toast[hidden] { display: none; }
/* 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); } }
/* 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:10) */
.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:19) */
.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 { flex: none; align-self: flex-start; margin-inline-start: auto; }
.profile-page .posts { display: grid; gap: var(--space-4); }
.profile-page .older { justify-self: center; }

/* Own profile: 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. */
.profile-page .avatar-stack { display: grid; flex: none; }
.profile-page .avatar-stack > * { grid-area: 1 / 1; }
.profile-page avatar-editor { display: block; position: relative; border-radius: var(--radius-full); }
/* Someone else's picture (app/web/avatar-viewer.ts): view it large. */
.profile-page avatar-viewer { display: block; border-radius: var(--radius-full); }
.profile-page .avatar-button.avatar-view { cursor: zoom-in; }
.profile-page .avatar-button {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  cursor: pointer;
}
.profile-page .avatar-button:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
.profile-page .avatar-button .avatar { display: grid; }
.profile-page .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);
}
.profile-page .avatar-button:hover .avatar-scrim,
.profile-page .avatar-button:focus-visible .avatar-scrim { opacity: 1; }
/* Touch screens have no hover: a small pencil badge is always shown. */
.profile-page .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) {
  .profile-page .avatar-badge { display: grid; }
  .profile-page .avatar-button .avatar-scrim { opacity: 0; }
}
/* The modal (app/web/avatar-dialog.ts) is styled in avatar.chad: image
   posts open it too, from any page with post cards. */

.profile-page .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);
}
.profile-page .avatar-toast[hidden] { display: none; }

/* Own profile: "⋯" opens the account menu, a native popover (no JS;
   Escape or a tap outside closes it). A sheet from the bottom on
   narrow screens, a small centered card on wide ones. */
.profile-page .account-menu-button {
  flex: none;
  align-self: flex-start;
  width: 44px;
  min-height: 44px;
  margin-inline-start: auto;
  padding: 0;
  border-radius: var(--radius-full);
}
.profile-page .account-menu {
  width: min(20rem, 100vw - 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);
}
.profile-page .account-menu:popover-open { display: grid; gap: var(--space-2); }
.profile-page .account-menu::backdrop { background: var(--color-scrim); }
.profile-page .account-menu form { display: grid; }
.profile-page .account-menu .btn { width: 100%; min-height: 48px; }
@media (max-width: 640px) {
  .profile-page .account-menu {
    /* Bottom edge only, like .action-menu (theme.css): iOS Safari
       stretched the inset: 0 + margin-top: auto version. */
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 85dvh;
    overflow-y: auto;
    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;
  }
  .profile-page .account-menu:popover-open { animation: account-menu-in var(--duration-fast) var(--ease-out); }
}
@keyframes account-menu-in { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .profile-page .account-menu:popover-open { animation: none; } }

@media (max-width: 480px) {
  .profile-page .identity { gap: var(--space-4); }
  .profile-page h1 { font-size: var(--text-xl); }
}
/* 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 field looks like an input; the real input inside it has no frame. */
.search-box .search-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-4);
  border: 1px solid var(--color-control-border);
  /* A pill on one line; a rounded box (not a stadium) once chips wrap. */
  border-radius: calc(var(--control-height) / 2);
  background: var(--color-surface);
  cursor: text;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.search-box .search-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; the magnifier stays beside them, centered. */
.search-box .search-tokens {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  min-width: 0;
}
.search-box .search-icon { flex: none; color: var(--color-text-muted); }
.search-box .search-input {
  flex: 1;
  width: auto;
  min-width: 6rem;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: none;
}
.search-box .search-input:focus-visible { outline: none; box-shadow: none; }

/* Picked tags and people: pills with a remove button. */
.search-box .search-chips { display: contents; }
.search-box .search-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;
}
.search-box .search-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;
}
.search-box .search-chip-x:hover { background: var(--color-tag-hover-bg); }

/* Wide screens: the dropdown under the field. */
.search-box .search-inline .search-menu {
  position: absolute;
  z-index: 20;
  inset-block-start: calc(100% + var(--space-1));
  inset-inline: 0;
  max-height: min(24rem, 60vh);
  overflow: auto;
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}
.search-box .search-group { display: grid; }
.search-box .search-group + .search-group { margin-block-start: var(--space-1); padding-block-start: var(--space-1); border-block-start: 1px solid var(--color-border); }
.search-box .search-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);
}
.search-box .search-group-list { display: grid; }
.search-box .search-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;
}
.search-box .search-option:hover,
.search-box .search-option[aria-selected="true"] { background: var(--color-surface-sunken); }
.search-box .search-option[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--color-focus); }
.search-box .search-option[aria-selected="true"]:dir(rtl) { box-shadow: inset -3px 0 0 var(--color-focus); }
.search-box .search-tag { color: var(--color-tag-fg); font-weight: var(--weight-medium); }
.search-box .search-tag .hash { opacity: 0.6; }
.search-box .search-count {
  margin-inline-start: auto;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.search-box .search-option .avatar { width: 28px; height: 28px; font-size: var(--text-xs); }
.search-box .search-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); }
.search-box .search-empty { padding: var(--space-3); 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 .search-menu {
  overflow: auto;
  padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
}
.search-box .search-sheet .search-option { min-height: 48px; }
.search-box .search-hint { padding: var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); }

@media (max-width: 640px) {
  .search-box .search-input { font-size: var(--text-base); }
}
/* SearchPage (app/components/search_page.chad:50) */
.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); }
.search-page .older { justify-self: center; }
/* TagFilter (app/components/tag_filter.chad:59) */
.tag-filter { display: grid; gap: var(--space-2); }
.tag-filter h2 { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.tag-filter .chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag-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-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-filter .chip:hover { background: var(--color-tag-hover-bg); text-decoration: none; }
.tag-filter .chip .hash { opacity: 0.6; }
.tag-filter .chip .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-filter .chip.selected { background: var(--color-tag-current-bg); border-color: var(--color-tag-current-bg); color: var(--color-tag-current-fg); }
.tag-filter .chip.selected .hash { opacity: 0.75; }
.tag-filter .chip.selected .count { border-color: currentColor; }
/* TagList (app/components/tag_list.chad:10) */
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* TagPage (app/components/tag_page.chad:42) */
.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 .title-row .btn { margin-inline-start: auto; }
.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); }
.tag-page .older { justify-self: center; }
/* 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; }
