/*
 * shadcn/ui design tokens, hand-ported.
 *
 * The names are shadcn's own — --background, --foreground, --card, --primary,
 * --muted, --border, --input, --ring, --radius — so anyone who has read a
 * shadcn theme can read this one, and a theme generated by the shadcn theme
 * editor can be pasted in wholesale.
 *
 * What is NOT here is Tailwind or the shadcn CLI. The board renders server-side
 * with Hono's JSX and ships plain CSS, so the React components cannot be used
 * directly; what is ported is their *anatomy* and their token vocabulary. See
 * components.css, where each class mirrors a shadcn component's structure.
 *
 * Theme resolution has three states, and all three are handled:
 *   - light lives on bare :root, so a page always has a complete palette
 *   - dark is redefined under prefers-color-scheme for the default "system"
 *     setting, guarded so an explicit light choice still wins
 *   - dark is redefined again under [data-theme="dark"] so the toggle wins in
 *     both directions
 * A colour whose only definition sits inside a media query is a colour that
 * disappears when someone picks the other theme.
 */

:root {
  --radius: 0.625rem;

  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);

  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);

  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);

  --primary: oklch(0.511 0.262 276.966);
  --primary-foreground: oklch(0.985 0 0);

  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);

  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);

  --accent: oklch(0.967 0.001 286.375);
  --accent-foreground: oklch(0.21 0.006 285.885);

  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);

  --success: oklch(0.596 0.145 163.225);
  --success-foreground: oklch(0.985 0 0);

  --warning: oklch(0.681 0.162 75.834);
  --warning-foreground: oklch(0.141 0.005 285.823);

  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.511 0.262 276.966);

  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);

  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-primary: oklch(0.511 0.262 276.966);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.967 0.001 286.375);
  --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --sidebar-ring: oklch(0.511 0.262 276.966);

  /* Board-specific roles, layered on the shadcn palette rather than beside it. */
  --unread: var(--primary);
  --staff: oklch(0.577 0.245 27.325);
  --sticky: oklch(0.681 0.162 75.834);
  --online: oklch(0.596 0.145 163.225);

  --font-sans:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --shadow-xs: 0 1px 2px 0 oklch(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 oklch(0 0 0 / 0.1), 0 1px 2px -1px oklch(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px oklch(0 0 0 / 0.1), 0 2px 4px -2px oklch(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px oklch(0 0 0 / 0.1), 0 4px 6px -4px oklch(0 0 0 / 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --background: oklch(0.141 0.005 285.823);
    --foreground: oklch(0.985 0 0);

    --card: oklch(0.21 0.006 285.885);
    --card-foreground: oklch(0.985 0 0);

    --popover: oklch(0.21 0.006 285.885);
    --popover-foreground: oklch(0.985 0 0);

    --primary: oklch(0.673 0.182 276.935);
    --primary-foreground: oklch(0.141 0.005 285.823);

    --secondary: oklch(0.274 0.006 286.033);
    --secondary-foreground: oklch(0.985 0 0);

    --muted: oklch(0.274 0.006 286.033);
    --muted-foreground: oklch(0.705 0.015 286.067);

    --accent: oklch(0.274 0.006 286.033);
    --accent-foreground: oklch(0.985 0 0);

    --destructive: oklch(0.704 0.191 22.216);
    --destructive-foreground: oklch(0.141 0.005 285.823);

    --success: oklch(0.696 0.17 162.48);
    --success-foreground: oklch(0.141 0.005 285.823);

    --warning: oklch(0.769 0.188 70.08);
    --warning-foreground: oklch(0.141 0.005 285.823);

    --border: oklch(1 0 0 / 12%);
    --input: oklch(1 0 0 / 16%);
    --ring: oklch(0.673 0.182 276.935);

    --sidebar: oklch(0.21 0.006 285.885);
    --sidebar-foreground: oklch(0.985 0 0);
    --sidebar-primary: oklch(0.673 0.182 276.935);
    --sidebar-primary-foreground: oklch(0.141 0.005 285.823);
    --sidebar-accent: oklch(0.274 0.006 286.033);
    --sidebar-accent-foreground: oklch(0.985 0 0);
    --sidebar-border: oklch(1 0 0 / 12%);
    --sidebar-ring: oklch(0.673 0.182 276.935);

    --unread: var(--primary);
    --staff: oklch(0.704 0.191 22.216);
    --sticky: oklch(0.769 0.188 70.08);
    --online: oklch(0.696 0.17 162.48);
  }
}

:root[data-theme='dark'] {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);

  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);

  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);

  --primary: oklch(0.673 0.182 276.935);
  --primary-foreground: oklch(0.141 0.005 285.823);

  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);

  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);

  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);

  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.141 0.005 285.823);

  --success: oklch(0.696 0.17 162.48);
  --success-foreground: oklch(0.141 0.005 285.823);

  --warning: oklch(0.769 0.188 70.08);
  --warning-foreground: oklch(0.141 0.005 285.823);

  --border: oklch(1 0 0 / 12%);
  --input: oklch(1 0 0 / 16%);
  --ring: oklch(0.673 0.182 276.935);

  --sidebar: oklch(0.21 0.006 285.885);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.673 0.182 276.935);
  --sidebar-primary-foreground: oklch(0.141 0.005 285.823);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 12%);
  --sidebar-ring: oklch(0.673 0.182 276.935);

  --unread: var(--primary);
  --staff: oklch(0.704 0.191 22.216);
  --sticky: oklch(0.769 0.188 70.08);
  --online: oklch(0.696 0.17 162.48);
}

/* Reset and base typography. Everything below reads from the shadcn tokens. */

*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: var(--border);
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Tells the browser which form controls and scrollbars to paint. Without it a
     dark board keeps light scrollbars and light native widgets. */
  color-scheme: light dark;
}

:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.011em;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
}

code, kbd, pre, samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 4px);
}

/* A skip link that is invisible until focused, so keyboard users can jump the
   nav without a visible control cluttering the header for everyone else. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 0.875rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/*
 * shadcn/ui components, hand-ported to plain CSS.
 *
 * Each block below mirrors one shadcn component's anatomy — the same element
 * structure, the same variant names, the same tokens. `.btn` is shadcn's
 * Button, `.card` + `.card-header` + `.card-title` is its Card, and so on. A
 * developer who knows shadcn should be able to guess the class names.
 */

/* --- Button -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  height: 2.25rem;
  padding-inline: 1rem;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  user-select: none;
}

.btn:hover { background: color-mix(in oklab, var(--primary) 90%, black); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 85%, var(--foreground) 8%); }

.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}
.btn-destructive:hover { background: color-mix(in oklab, var(--destructive) 90%, black); }

.btn-link {
  background: transparent;
  color: var(--primary);
  height: auto;
  padding: 0;
}
.btn-link:hover { background: transparent; text-decoration: underline; }

.btn-sm { height: 2rem; padding-inline: 0.75rem; font-size: 0.8125rem; border-radius: calc(var(--radius) - 4px); }
.btn-lg { height: 2.75rem; padding-inline: 1.5rem; font-size: 0.9375rem; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-icon.btn-sm { width: 2rem; }
.btn-block { display: flex; width: 100%; }

/* --- Card ---------------------------------------------------------------- */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.006em; }
.card-description { font-size: 0.8125rem; color: var(--muted-foreground); }
.card-content { padding: 1.25rem; }
.card-content.flush { padding: 0; }
.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--muted) 40%, transparent);
}

/* --- Badge --------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
  background: var(--primary);
  color: var(--primary-foreground);
  white-space: nowrap;
}

.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.badge-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.badge-success { background: var(--success); color: var(--success-foreground); }
.badge-warning { background: var(--warning); color: var(--warning-foreground); }
.badge-staff { background: color-mix(in oklab, var(--staff) 15%, transparent); color: var(--staff); border-color: color-mix(in oklab, var(--staff) 30%, transparent); }

/* --- Avatar -------------------------------------------------------------- */

.avatar {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9999px;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--muted);
  user-select: none;
}

.avatar img,
.avatar svg { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 1.5rem; height: 1.5rem; }
.avatar-lg { width: 3.5rem; height: 3.5rem; }
.avatar-xl { width: 5rem; height: 5rem; border-radius: var(--radius); }
.avatar-fallback {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

/* --- Input, Textarea, Label, Select -------------------------------------- */

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  min-height: 2.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder,
.textarea::placeholder { color: var(--muted-foreground); }

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}

.textarea { min-height: 8rem; resize: vertical; line-height: 1.6; }
.textarea.mono { font-family: var(--font-mono); font-size: 0.8125rem; }

.select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.field { margin-bottom: 1rem; }
.field-hint { font-size: 0.75rem; color: var(--muted-foreground); margin-top: 0.375rem; }
.field-error { font-size: 0.75rem; color: var(--destructive); margin-top: 0.375rem; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.375rem 0;
}
.checkbox-row input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.2rem;
  accent-color: var(--primary);
  flex: none;
}

/* --- Alert --------------------------------------------------------------- */

.alert {
  display: flex;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  background: var(--card);
  font-size: 0.875rem;
}
.alert-title { font-weight: 600; margin-bottom: 0.125rem; }
.alert-description { color: var(--muted-foreground); }
.alert-destructive {
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
  background: color-mix(in oklab, var(--destructive) 8%, var(--card));
}
.alert-destructive .alert-title { color: var(--destructive); }
.alert-success {
  border-color: color-mix(in oklab, var(--success) 35%, transparent);
  background: color-mix(in oklab, var(--success) 8%, var(--card));
}
.alert-warning {
  border-color: color-mix(in oklab, var(--warning) 40%, transparent);
  background: color-mix(in oklab, var(--warning) 10%, var(--card));
}

/* --- Separator ----------------------------------------------------------- */

.separator { height: 1px; background: var(--border); border: none; margin: 1rem 0; }
.separator-vertical { width: 1px; height: auto; align-self: stretch; margin: 0 0.5rem; }

/* --- Tabs ---------------------------------------------------------------- */

.tabs-list {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--muted);
  border-radius: calc(var(--radius) - 2px);
  overflow-x: auto;
  max-width: 100%;
}

.tabs-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.tabs-trigger:hover { color: var(--foreground); text-decoration: none; }
.tabs-trigger[aria-selected='true'],
.tabs-trigger.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

/* --- Table --------------------------------------------------------------- */

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: color-mix(in oklab, var(--muted) 45%, transparent); }

/* --- Dropdown menu ------------------------------------------------------ */
/* Built on <details> so it works with JavaScript disabled. shadcn's menu is a
   Radix popover; the anatomy and class names are kept, the mechanism is not. */

.dropdown { position: relative; }
.dropdown > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.dropdown > summary::-webkit-details-marker { display: none; }

.dropdown-content {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  z-index: 50;
  min-width: 12rem;
  padding: 0.25rem;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.dropdown-content.align-left { right: auto; left: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  color: var(--popover-foreground);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.dropdown-item:hover { background: var(--accent); color: var(--accent-foreground); text-decoration: none; }
.dropdown-item.destructive { color: var(--destructive); }
.dropdown-label {
  padding: 0.375rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dropdown-separator { height: 1px; background: var(--border); margin: 0.25rem 0; }

/* --- Skeleton ------------------------------------------------------------ */

.skeleton {
  background: var(--muted);
  border-radius: calc(var(--radius) - 2px);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  50% { opacity: 0.5; }
}

/* --- Breadcrumb ---------------------------------------------------------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--muted-foreground); }
.breadcrumb a:hover { color: var(--foreground); }
.breadcrumb-separator { opacity: 0.5; }
.breadcrumb-page { color: var(--foreground); font-weight: 500; }

/* --- Pagination ---------------------------------------------------------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin: 1.25rem 0;
}
.pagination-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding-inline: 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  color: var(--foreground);
  border: 1px solid transparent;
  text-decoration: none;
}
.pagination-item:hover { background: var(--accent); text-decoration: none; }
.pagination-item[aria-current='page'] {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
}
.pagination-ellipsis { color: var(--muted-foreground); padding-inline: 0.25rem; }

/* --- Tooltip (CSS only) -------------------------------------------------- */

.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.375rem);
  left: 50%;
  translate: -50% 0;
  padding: 0.25rem 0.5rem;
  background: var(--foreground);
  color: var(--background);
  font-size: 0.6875rem;
  border-radius: calc(var(--radius) - 4px);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 60;
}
.tooltip:hover::after,
.tooltip:focus-visible::after { opacity: 1; }

/* --- Empty state --------------------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted-foreground);
}
.empty-title { font-weight: 600; color: var(--foreground); }

/* Board layout, composed from the shadcn primitives in components.css. */

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.container {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

.main { flex: 1; padding-block: 1.5rem 3rem; }

/* --- Site header --------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--background) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 3.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  font-size: 0.9375rem;
  color: var(--foreground);
  letter-spacing: -0.014em;
  flex: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: calc(var(--radius) - 3px);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.75rem;
  font-weight: 700;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 0.375rem 0.625rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.nav-link:hover { color: var(--foreground); background: var(--accent); text-decoration: none; }
.nav-link.active { color: var(--foreground); background: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 0.5rem; flex: none; }

.search-form { position: relative; display: none; }
@media (min-width: 48rem) { .search-form { display: block; } }
.search-form .input { height: 2rem; min-height: 2rem; width: 13rem; font-size: 0.8125rem; }

/* The unread count sits on the bell rather than beside it, so the header keeps
   its height whether or not there is anything to report. */
.notif-button { position: relative; }
.notif-dot {
  position: absolute;
  top: -0.125rem;
  right: -0.125rem;
  min-width: 1rem;
  height: 1rem;
  padding-inline: 0.1875rem;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  background: var(--destructive);
  color: var(--destructive-foreground);
  font-size: 0.625rem;
  font-weight: 700;
  border: 2px solid var(--background);
}

/* --- Board index --------------------------------------------------------- */

.category { margin-bottom: 1.5rem; }
.category-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.625rem;
  padding-inline: 0.125rem;
}
.category-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

.forum-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.875rem;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.forum-row:last-child { border-bottom: none; }
.forum-row:hover { background: color-mix(in oklab, var(--muted) 45%, transparent); }

.forum-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: 1rem;
}
.forum-row.unread .forum-icon {
  background: var(--primary);
  color: var(--primary-foreground);
}

.forum-name { font-weight: 600; font-size: 0.9375rem; color: var(--foreground); }
.forum-name:hover { color: var(--primary); }
.forum-desc {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-top: 0.125rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.forum-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-align: right;
}
.forum-stat { display: none; }
@media (min-width: 40rem) { .forum-stat { display: block; min-width: 3.5rem; } }
.forum-stat strong { display: block; color: var(--foreground); font-size: 0.8125rem; font-weight: 600; }
.forum-last { display: none; max-width: 14rem; }
@media (min-width: 60rem) { .forum-last { display: block; } }
.forum-last-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--foreground);
  font-weight: 500;
}

/* --- Topic list ---------------------------------------------------------- */

.topic-row {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto;
  gap: 0.875rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.topic-row:last-child { border-bottom: none; }
.topic-row:hover { background: color-mix(in oklab, var(--muted) 45%, transparent); }

/* An unread topic gets a rail rather than a bold row: it marks the row without
   changing its height, so the list does not reflow as things are read. */
.topic-row.unread { box-shadow: inset 2px 0 0 var(--unread); }
.topic-row.unread .topic-title { font-weight: 650; }

.topic-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--foreground);
  display: inline;
}
.topic-title:hover { color: var(--primary); }

.topic-tags { display: inline-flex; gap: 0.25rem; margin-right: 0.375rem; vertical-align: 1px; }
.topic-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.1875rem;
}
.topic-sub a { color: var(--muted-foreground); font-weight: 500; }
.topic-sub a:hover { color: var(--foreground); }
.dot::before { content: '·'; margin-inline: 0.125rem; }

.topic-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-align: right;
}
.topic-count { display: none; }
@media (min-width: 40rem) { .topic-count { display: block; min-width: 3rem; } }
.topic-count strong { display: block; color: var(--foreground); font-size: 0.8125rem; }

/* --- Topic view ---------------------------------------------------------- */

.topic-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.topic-heading { font-size: 1.375rem; letter-spacing: -0.018em; }
.topic-head-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-top: 0.375rem;
}

.post {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 0.875rem;
  overflow: hidden;
  scroll-margin-top: 4.5rem;
}
@media (min-width: 48rem) {
  .post { grid-template-columns: 11rem minmax(0, 1fr); }
}

/* The author column is a sidebar on desktop and a byline on mobile — the same
   markup, reordered, so the post body is never squeezed into a narrow column. */
.post-author {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--muted) 35%, transparent);
}
@media (min-width: 48rem) {
  .post-author {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.375rem;
    padding: 1.25rem 1rem;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
}

.post-author-name { font-weight: 600; font-size: 0.875rem; color: var(--foreground); }
.post-author-name:hover { color: var(--primary); }
.post-author-title { font-size: 0.6875rem; color: var(--muted-foreground); }
.post-author-stats { font-size: 0.6875rem; color: var(--muted-foreground); display: none; }
@media (min-width: 48rem) { .post-author-stats { display: block; } }

.post-main { display: flex; flex-direction: column; min-width: 0; }
.post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
}
.post-permalink { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

.post-body {
  padding: 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.7;
  overflow-wrap: break-word;
  flex: 1;
}
.post-body > *:first-child { margin-top: 0; }
.post-body > *:last-child { margin-bottom: 0; }
.post-body p { margin-block: 0 0.875rem; }
.post-body h2, .post-body h3, .post-body h4 { margin-block: 1.5rem 0.625rem; }
.post-body ul, .post-body ol { margin-block: 0 0.875rem; padding-left: 1.5rem; }
.post-body li { margin-bottom: 0.25rem; }
.post-body img { border-radius: calc(var(--radius) - 2px); margin-block: 0.5rem; }
.post-body hr { margin-block: 1.25rem; }

.post-body blockquote,
.post-body .bb-quote {
  margin: 0 0 0.875rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--primary);
  border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
  background: color-mix(in oklab, var(--muted) 55%, transparent);
  color: var(--muted-foreground);
}
.post-body blockquote cite,
.post-body .bb-quote cite {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}

.post-body code {
  background: var(--muted);
  padding: 0.125rem 0.3125rem;
  border-radius: calc(var(--radius) - 5px);
  font-size: 0.85em;
}
.post-body pre {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.875rem 1rem;
  overflow-x: auto;
  margin-block: 0 0.875rem;
  line-height: 1.55;
}
.post-body pre code { background: none; padding: 0; font-size: 0.8125rem; }

.md-table-wrap { overflow-x: auto; margin-bottom: 0.875rem; }
.md-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.md-table th { background: var(--muted); font-weight: 600; }

.bb-center { text-align: center; }
.bb-right { text-align: right; }
.bb-spoiler { border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); padding: 0.5rem 0.75rem; margin-bottom: 0.875rem; }
.bb-spoiler summary { cursor: pointer; font-weight: 500; font-size: 0.8125rem; }
.bb-video { position: relative; aspect-ratio: 16 / 9; margin-bottom: 0.875rem; }
.bb-video iframe { width: 100%; height: 100%; border: 0; border-radius: calc(var(--radius) - 2px); }

.mention {
  font-weight: 550;
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  padding: 0.0625rem 0.25rem;
  border-radius: calc(var(--radius) - 5px);
}
.mention:hover { text-decoration: none; background: color-mix(in oklab, var(--primary) 20%, transparent); }

/*
 * The signature is separated by a rule and set smaller and quieter than the
 * post. It only appears once its author has earned it — see signatureGate in
 * @tsbb/core — so an empty separator never shows up under a new member's post.
 */
.post-signature {
  margin: 0 1.25rem 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}
.post-signature a { color: var(--muted-foreground); text-decoration: underline; text-underline-offset: 2px; }
.post-signature a:hover { color: var(--primary); }

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--muted) 30%, transparent);
}
.post-actions { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }

.post.is-hidden { opacity: 0.6; border-style: dashed; }
.post.is-solution { border-color: var(--success); box-shadow: 0 0 0 1px color-mix(in oklab, var(--success) 40%, transparent); }

/* --- Composer ------------------------------------------------------------ */

.composer { margin-top: 1.25rem; }
.composer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--input);
  border-bottom: none;
  border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0;
  background: var(--muted);
}
.composer .textarea {
  border-radius: 0 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px);
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* --- Profile ------------------------------------------------------------- */

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.profile-stats { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.profile-stat strong { display: block; font-size: 1.125rem; font-weight: 650; }
.profile-stat span { font-size: 0.75rem; color: var(--muted-foreground); }

/* --- Layout helpers ------------------------------------------------------ */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-title { font-size: 1.25rem; letter-spacing: -0.016em; }
.page-subtitle { font-size: 0.8125rem; color: var(--muted-foreground); margin-top: 0.125rem; }

.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.muted { color: var(--muted-foreground); }
.small { font-size: 0.8125rem; }
.tiny { font-size: 0.75rem; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

.layout-with-sidebar { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 64rem) {
  .layout-with-sidebar { grid-template-columns: minmax(0, 1fr) 18rem; }
}
.sidebar { display: flex; flex-direction: column; gap: 1rem; }

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.site-footer a { color: var(--muted-foreground); }
.site-footer a:hover { color: var(--foreground); }

/* --- Admin --------------------------------------------------------------- */

.admin-layout { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 56rem) {
  .admin-layout { grid-template-columns: 13rem minmax(0, 1fr); }
}
.admin-nav { display: flex; flex-direction: column; gap: 0.125rem; }
.admin-nav-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  padding: 0.75rem 0.625rem 0.25rem;
}
