/* ==========================================================================
   Chipd design system
   --------------------------------------------------------------------------
   Hand-rolled CSS, deliberately not Tailwind. The Play CDN compiled styles at
   runtime, which is why the CSP needed 'unsafe-eval'; owning the stylesheet
   lets that exception go away and removes a render-blocking round trip.

   Two token layers:
     1. Raw palette  — never changes, never referenced by components.
     2. Semantic     — flips per theme. Components only ever use these.
   ========================================================================== */

/* -------------------------------------------------------------- 1. tokens */

:root {
  /* Raw palette ---------------------------------------------------------- */
  --mulberry-50: #f6f1ff;
  --mulberry-100: #ebe0ff;
  --mulberry-200: #d8c4ff;
  --mulberry-300: #bf9dff;
  --mulberry-400: #a576f7;
  --mulberry-500: #8b55e8;
  --mulberry-600: #7340cb;
  --mulberry-700: #5c31a3;
  --mulberry-800: #46257c;
  --mulberry-900: #2f1954;

  --sunpaw-400: #ffb454;
  --sunpaw-500: #f59324;
  --sunpaw-600: #d4760f;

  --pinemint-400: #4fd1a8;
  --pinemint-500: #22b58c;
  --pinemint-600: #12906f;

  --rose-400: #e08aa0;
  --rose-600: #a83f5c;

  --cinnabar-400: #f26d70;
  --cinnabar-600: #d93036;

  /* Shape ----------------------------------------------------------------
     Rounder than a typical product UI on purpose. Tight corners read as
     "enterprise dashboard"; these read as stickers and badges. */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Motion --------------------------------------------------------------- */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 240ms;

  /* Type ----------------------------------------------------------------- */
  --font-display: "Bricolage Grotesque", "Outfit", system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 0.9375rem; /* 15px — beats 16 for a dense feed */
  --text-lg: 1.0625rem;
  --text-xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);

  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-body: 1.6;

  /* Layout --------------------------------------------------------------- */
  --topbar-h: 56px;
  --bottombar-h: 56px;
  --nav-w: 240px;
  --rail-w: 320px;
  --feed-w: 640px;
}

/* Dark is the default. Warm-plum neutrals, luminance capped at both ends so
   nothing glares at 2am. Never #000, never #fff. */
:root,
[data-theme="dark"] {
  /* Warmed from the original blue-plum greys: a touch of red in the neutral
     is the difference between "server rack at night" and "lamp-lit room". */
  --canvas: #171122;
  --surface: #211a2f;
  --surface-raised: #2c233c;
  --surface-sunken: #110c1a;
  --border: #3a2f4d;
  --border-strong: #52436b;

  --text: #f2ecf8;
  --text-muted: #b0a4c6;
  /* Small text: carries 12px timestamps and handles, so it gets no
     large-text exemption. Verified by test/contrast.test.js. */
  --text-subtle: #8c80a8;

  --brand: var(--mulberry-400);
  --brand-hover: var(--mulberry-300);
  --brand-fill: var(--mulberry-500);
  --brand-on-fill: #fff;
  --brand-ghost: rgb(165 118 247 / 0.12);

  --accent: var(--sunpaw-400);
  --accent-ghost: rgb(255 180 84 / 0.12);
  --success: var(--pinemint-400);
  --danger: var(--cinnabar-400);
  --danger-ghost: rgb(242 109 112 / 0.12);
  --danger-fill: var(--cinnabar-600);
  --cw: #ffc978;
  --mature: var(--rose-400);

  --focus-ring: var(--mulberry-300);
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 4px 16px -4px rgb(0 0 0 / 0.5);
  --shadow-3: 0 16px 48px -12px rgb(0 0 0 / 0.65);
  /* 4% white on the top edge only: makes a dark card read as lit from above.
     Does the job the old backdrop-blur glassmorphism was trying to do, for
     none of the GPU cost. */
  --hairline: inset 0 1px 0 rgb(255 255 255 / 0.04);
  color-scheme: dark;
}

[data-theme="light"] {
  --canvas: #fdf6ef; /* warm cream, like paper under a desk lamp */
  --surface: #ffffff;
  --surface-raised: #fffdfb;
  --surface-sunken: #f7eee4;
  --border: #ecdfd2;
  --border-strong: #d8c5b2;

  --text: #23182b;
  --text-muted: #5f5170;
  --text-subtle: #6f6780;

  --brand: var(--mulberry-600);
  --brand-hover: var(--mulberry-700);
  --brand-fill: var(--mulberry-500);
  --brand-on-fill: #fff;
  --brand-ghost: rgb(115 64 203 / 0.08);

  --accent: var(--sunpaw-600);
  --accent-ghost: rgb(212 118 15 / 0.1);
  --success: var(--pinemint-600);
  --danger: var(--cinnabar-600);
  --danger-ghost: rgb(217 48 54 / 0.08);
  --danger-fill: var(--cinnabar-600);
  --cw: #8a5200;
  --mature: var(--rose-600);

  --focus-ring: var(--mulberry-600);
  --shadow-1: 0 1px 2px rgb(30 26 38 / 0.06);
  --shadow-2: 0 4px 16px -4px rgb(30 26 38 / 0.1);
  --shadow-3: 0 16px 48px -12px rgb(30 26 38 / 0.18);
  --hairline: none;
  color-scheme: light;
}

/* Midnight: an overlay on dark for reading in bed, not a separate palette. */
[data-dim="true"] {
  --canvas: #0b0a0f;
  --surface: #131119;
  --surface-sunken: #08070c;
}
[data-dim="true"] img,
[data-dim="true"] video {
  filter: brightness(0.88);
}

/* A real high-contrast mode: heavier borders, brighter text, amber focus. */
[data-contrast="high"] {
  --text: #ffffff;
  --text-muted: #dcd7e8;
  --text-subtle: #bdb6cc;
  --border: #6b6383;
  --border-strong: #9a90b8;
  --brand: #c9a8ff;
  --focus-ring: #ffe58a;
}
[data-contrast="high"] .card,
[data-contrast="high"] .btn,
[data-contrast="high"] .input {
  border-width: 2px;
}

/* Body-font swap for low vision. Atkinson Hyperlegible disambiguates the
   letterforms that trip people up (I/l/1, O/0) and is genuinely warm, so it
   reads as a choice rather than a compromise. */
[data-font="hyperlegible"] {
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-display: "Atkinson Hyperlegible", system-ui, sans-serif;
}

/* ---------------------------------------------------------------- 2. base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  font-variant-numeric: tabular-nums; /* counters must not jitter as they tick */
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em; /* display sizes only; body stays at 0 */
  margin: 0;
}

p {
  margin: 0;
}

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

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

::selection {
  background: var(--brand-ghost);
  color: var(--text);
}

/* :focus-visible, not :focus — mouse users never see the ring, keyboard users
   always do. Never remove this without providing a replacement. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: -100px;
  z-index: 200;
  padding: var(--space-3) var(--space-4);
  background: var(--brand-fill);
  color: var(--brand-on-fill);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus {
  top: var(--space-3);
}

/* Reduced motion must also kill the like animation and any autoplay. */
@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;
  }
}

/* --------------------------------------------------------- 3. app shell */

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--space-4);
  padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom) + var(--space-6));
}

@media (min-width: 1024px) {
  .app-shell {
    /* minmax(0, …) not a bare width: without the 0 minimum a wide media grid
       blows the column out and the whole page scrolls sideways. */
    grid-template-columns: var(--nav-w) minmax(0, var(--feed-w));
    padding-bottom: var(--space-7);
  }
}

@media (min-width: 1280px) {
  .app-shell {
    grid-template-columns: var(--nav-w) minmax(0, var(--feed-w)) var(--rail-w);
  }
}

/* Topbar ----------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-4);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .bottom-bar {
    background: var(--canvas);
    backdrop-filter: none;
  }
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  color: var(--text);
  text-decoration: none;
  flex: none;
}
.brand:hover {
  text-decoration: none;
}

/* Logo mark is a CSS shape, not an image asset. */
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--mulberry-400), var(--sunpaw-400));
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
}
.brand-mark::before {
  content: "";
  width: 11px;
  height: 9px;
  border-radius: 50% 50% 46% 46%;
  background: var(--canvas);
  opacity: 0.92;
  margin-top: 3px;
}
.brand-mark::after {
  content: "";
  position: absolute;
  top: 6px;
  width: 15px;
  height: 4px;
  background:
    radial-gradient(circle, var(--canvas) 55%, transparent 56%) 0 0 / 5px 4px no-repeat,
    radial-gradient(circle, var(--canvas) 55%, transparent 56%) 5px 0 / 5px 4px no-repeat,
    radial-gradient(circle, var(--canvas) 55%, transparent 56%) 10px 0 / 5px 4px no-repeat;
  opacity: 0.92;
}

.brand-tld {
  color: var(--brand);
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  /* Without this the row is sized by its contents and pushes the page wider
     than the viewport on a phone. It was already 8px over before the
     notification bell was added; the bell made it 55px. */
  min-width: 0;
}

/* On a phone the bar carries theme, settings, notifications, avatar and sign
   out. The word "Log out" is the one part that can go: the same action is a
   tap away on the profile, and losing it here is what keeps the page from
   scrolling sideways. */
@media (max-width: 480px) {
  .topbar {
    gap: var(--space-2);
    padding-inline: var(--space-3);
  }
  .topbar-inner {
    gap: var(--space-2);
  }
  .topbar-actions .btn-ghost {
    display: none;
  }
}

/* Sidebar nav ------------------------------------------------------------ */

.sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    position: sticky;
    top: calc(var(--topbar-h) + var(--space-5));
    align-self: start;
    max-height: calc(100dvh - var(--topbar-h) - var(--space-6));
    overflow-y: auto;
  }
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  background: none;
  border: 0;
  width: 100%;
  text-align: start;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.nav-item:hover {
  background: var(--brand-ghost);
  color: var(--text);
  text-decoration: none;
}
.nav-item {
  font-weight: 600;
}
.nav-item[aria-current="page"] {
  color: var(--brand);
  font-weight: 700;
  background: var(--brand-ghost);
}
/* Icons wiggle once on hover. Small, cheap, and it makes the nav feel alive
   instead of inert. Killed by prefers-reduced-motion like everything else. */
.nav-item:hover .nav-icon {
  animation: wiggle 420ms var(--ease-out);
}
@keyframes wiggle {
  25% {
    rotate: -9deg;
  }
  60% {
    rotate: 7deg;
  }
  100% {
    rotate: 0deg;
  }
}
/* Leading notch on the active item, scaling in from the centre. */
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  translate: 0 -50%;
  width: 3px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  animation: notch-in var(--dur-base) var(--ease-out);
}
@keyframes notch-in {
  from {
    transform: scaleY(0.3);
    opacity: 0;
  }
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

/* The unread badge rides on the bell in the top bar. --brand-fill with
   --brand-on-fill is the one pairing contrast.test.js already covers, so the
   count does not introduce a colour pair of its own. */
.notif-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
}
.notif-dot {
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  min-width: 16px;
  height: 16px;
  padding-inline: 4px;
  border-radius: var(--radius-pill);
  background: var(--brand-fill);
  color: var(--brand-on-fill);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  /* Sits against the bar, not the button, so it reads as attached to the icon
     rather than floating over it. */
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.nav-count {
  margin-inline-start: auto;
  min-width: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: var(--radius-pill);
  background: var(--brand-fill);
  color: var(--brand-on-fill);
  font-size: var(--text-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Bottom bar (mobile) ---------------------------------------------------- */

.bottom-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 60;
  height: calc(var(--bottombar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  align-items: stretch;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .bottom-bar {
    display: none;
  }
}

.bottom-bar .nav-item {
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 48px; /* touch target floor, even though the icon is 24px */
  min-height: 48px;
  border-radius: 0;
  font-size: var(--text-xs);
  padding: 0;
}
.bottom-bar .nav-item[aria-current="page"] {
  background: none;
  color: var(--brand);
}
.bottom-bar .nav-item[aria-current="page"]::before {
  inset-inline: 30%;
  inset-inline-start: 30%;
  top: 0;
  translate: none;
  width: auto;
  height: 3px;
  border-radius: 0 0 var(--radius-pill) var(--radius-pill);
}
.bottom-bar .nav-count {
  position: absolute;
  top: 4px;
  inset-inline-end: 22%;
  margin: 0;
}

/* Compose FAB: the one action worth pulling out of the bar, in thumb reach. */
.fab {
  position: fixed;
  inset-inline-end: var(--space-4);
  bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom) + var(--space-4));
  z-index: 55;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  border: 0;
  background: var(--brand-fill);
  color: var(--brand-on-fill);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-3);
  transition: transform var(--dur-fast) var(--ease-out);
}
.fab:active {
  transform: scale(0.94);
}

@media (min-width: 1024px) {
  .fab {
    display: none;
  }
}

/* Rail ------------------------------------------------------------------- */

.rail {
  display: none;
}

@media (min-width: 1280px) {
  .rail {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    position: sticky;
    top: calc(var(--topbar-h) + var(--space-5));
    align-self: start;
  }
}

.feed-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0; /* pairs with minmax(0,…) to stop media overflowing */
  padding-top: var(--space-5);
}

/* ------------------------------------------------------------ 4. surfaces */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1), var(--hairline);
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.card-pad {
  padding: var(--space-4);
}
/* Lift on hover rather than just a border change. A card that physically
   responds feels like an object on a corkboard, not a table row. */
.card-hover {
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    translate var(--dur-base) var(--ease-spring);
}
.card-hover:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  box-shadow: var(--shadow-2), var(--hairline);
  translate: 0 -2px;
}

@media (max-width: 479px) {
  /* Full-bleed cards on small phones: side gutters waste scarce width.
     Top-level cards only — :not(.card .card) spares anything nested inside
     another card, which would otherwise hang off the screen edge. */
  #view .card:not(.card .card) {
    border-radius: 0;
    border-inline: 0;
    margin-inline: calc(var(--space-4) * -1);
  }
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* ------------------------------------------------------------- 5. buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding-inline: var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: scale(0.97); /* tactile press, reads as responsive on touch */
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand-fill);
  color: var(--brand-on-fill);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow-2);
}

/* Mixed from --text rather than pinned to a surface token. On dark that lifts
   the button above the card; on light it recedes below it. Using
   --surface-raised made it invisible on light (both are white) and
   --surface-sunken made it a black hole on dark. */
.btn-secondary {
  background: color-mix(in srgb, var(--text) 9%, var(--surface));
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 15%, var(--surface));
}

.btn-ghost {
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--brand-ghost);
  color: var(--text);
}

.btn-danger {
  color: var(--danger);
  border-color: currentColor;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-ghost);
}

.btn-sm {
  height: 32px;
  padding-inline: var(--space-3);
  font-size: var(--text-xs);
}
.btn-lg {
  height: 48px;
  padding-inline: var(--space-5);
  font-size: var(--text-base);
}
.btn-block {
  width: 100%;
}

/* Controls that are visually smaller than 44px get a centred, invisible hit
   rectangle that is at least 44×44. The control looks compact; the tap target
   is not. Applied to every sub-44px control in the shell. */
.btn-sm,
.icon-btn,
.brand,
.avatar-link {
  position: relative;
}
.btn-sm::after,
.icon-btn::after,
.brand::after,
.avatar-link::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline-start: 50%;
  translate: -50% -50%;
  width: 100%;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
}

/* Square icon button, still 44px of hit area at the smaller visual size. */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 0;
  background: none;
  color: var(--text-muted);
  position: relative;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover {
  background: var(--brand-ghost);
  color: var(--text);
}

/* --------------------------------------------------------------- 6. forms */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-subtle);
}
.input:hover,
.textarea:hover {
  border-color: var(--border-strong);
}
.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: var(--leading-body);
}

.input-prefix {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding-inline-start: var(--space-3);
}
.input-prefix span {
  color: var(--text-subtle);
  font-weight: 700;
}
.input-prefix .input {
  border: 0;
  background: none;
  padding-inline-start: 0;
}
.input-prefix:focus-within {
  border-color: var(--focus-ring);
}

.hint {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}
.error-text {
  font-size: var(--text-sm);
  color: var(--danger);
}

/* Switch ----------------------------------------------------------------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 44px;
  padding-block: var(--space-2);
}

.switch {
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface-sunken);
  position: relative;
  transition: background var(--dur-base) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    translate var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out);
}
.switch[aria-checked="true"] {
  background: var(--brand-fill);
  border-color: var(--brand-fill);
}
.switch[aria-checked="true"]::after {
  translate: 18px 0;
  background: #fff;
}

/* -------------------------------------------------------------- 7. avatar */

.avatar {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* No stock photo, no generated art: an empty avatar is a tinted disc with the
   first glyph of the handle set in the display face. It is coloured from the
   handle's own hue — see .avatar-initial in section 16. */
.avatar-lg {
  width: 96px;
  height: 96px;
  font-size: 96px;
}
.avatar-md {
  width: 56px;
  height: 56px;
  font-size: 56px;
}
.avatar {
  font-size: 40px;
}

/* Status collar: a ring with a gap, warmer than the usual corner dot.
   Always paired with a visible or sr-only label — never colour alone. */
.avatar-collar {
  box-shadow:
    0 0 0 3px var(--canvas),
    0 0 0 5px var(--status, var(--success));
}
.avatar-collar-online {
  --status: var(--success);
}
.avatar-collar-con {
  --status: var(--accent);
}

/* -------------------------------------------------------------- 8. badges */

/* Three shapes so the tiers are distinguishable without reading colour. */
.badge-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
}
.badge-earned {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
}
.badge-mod {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 26%, transparent);
  color: var(--danger);
}

/* Owner: the only badge that gets the gradient treatment, so platform
   ownership is unmistakable and not confusable with a self-chosen role pill. */
.badge-owner {
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--accent) 26%, transparent),
    color-mix(in srgb, var(--brand) 26%, transparent));
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
  color: var(--accent);
}

/* Content badges are rectangular on purpose: shape alone separates a safety
   label from a decorative role pill, which matters for colourblind users. */
.badge-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--cw) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--cw) 32%, transparent);
  color: var(--cw);
  font-size: var(--text-xs);
  font-weight: 700;
}
.badge-mature {
  background: color-mix(in srgb, var(--mature) 14%, transparent);
  border-color: color-mix(in srgb, var(--mature) 32%, transparent);
  color: var(--mature);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.badge-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status, var(--text-subtle));
  flex: none;
}

.chip-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-ghost);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* ---------------------------------------------------------------- 9. tabs */

.tablist {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
.tablist::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  flex: none;
  scroll-snap-align: start;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-sm);
  transition: color var(--dur-fast) var(--ease-out);
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
}
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline: var(--space-3);
  bottom: -1px;
  height: 3px;
  border-radius: var(--radius-pill) var(--radius-pill) 0 0;
  background: var(--brand);
  animation: tab-in var(--dur-base) var(--ease-out);
}
@keyframes tab-in {
  from {
    transform: scaleX(0.4);
    opacity: 0;
  }
}

/* --------------------------------------------------------------- 10. post */

.post {
  display: flex;
  flex-direction: column;
  content-visibility: auto;
  contain-intrinsic-size: auto 320px; /* keeps the scrollbar honest off-screen */
}

.post-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
}

.post-ident {
  min-width: 0;
  flex: 1;
}

.post-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-weight: 700;
  font-size: var(--text-sm);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-subtle);
  font-size: var(--text-xs);
  margin-top: 2px;
}
.post-handle {
  font-family: var(--font-mono);
}

.post-body {
  padding: 0 var(--space-4) var(--space-3);
  max-width: 68ch; /* measure cap — never justify */
  font-size: var(--text-base);
  line-height: var(--leading-body);
  overflow-wrap: anywhere; /* a pasted URL must not blow the column out */
  white-space: pre-wrap;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2) var(--space-2);
  border-top: 1px solid var(--border);
  margin-top: var(--space-1);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding-inline: var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.action-btn:hover {
  background: var(--brand-ghost);
  color: var(--text);
}
.action-btn[data-danger]:hover {
  background: var(--danger-ghost);
  color: var(--danger);
}
/* Scoped to the like button. Any pressed toggle used to get the filled-heart
   treatment, which made "Following" render as a solid pink bell — reading as a
   second like rather than a notification setting. */
.action-btn.is-like[aria-pressed="true"] {
  color: var(--mature);
}
.action-btn.is-like[aria-pressed="true"] svg {
  fill: currentColor;
  animation: pop var(--dur-slow) var(--ease-spring);
}

/* Following is a state, not an achievement: it reads in the brand colour
   without the fill, and drops back to muted text once you have opted out. */
.action-btn.is-follow[aria-pressed="true"] {
  color: var(--brand);
}
/* The one celebratory spring in the system. Anywhere else and the UI feels
   bouncy and cheap. */
@keyframes pop {
  0% {
    transform: scale(0.8);
  }
  60% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

/* -------------------------------------------------------------- 11. media */

.media-grid {
  display: grid;
  gap: 4px;
  padding-inline: var(--space-4);
  padding-bottom: var(--space-3);
}
.media-grid[data-count="1"] {
  grid-template-columns: 1fr;
}
.media-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}
.media-grid[data-count="3"] {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.media-grid[data-count="3"] > :first-child {
  grid-row: span 2;
}
.media-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
}

.media-slot {
  position: relative;
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-sunken);
  aspect-ratio: 1;
}
.media-grid[data-count="1"] .media-slot {
  aspect-ratio: 4 / 3;
  max-height: 70vh;
}
/* Traditional art posted as a tall photo must not be centre-cropped —
   the composition is the work. Letterbox it into the well instead. */
.media-slot[data-fit="contain"] img {
  object-fit: contain;
}
.media-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The ALT badge is a real button: showing the author's description on tap is
   what makes people write it. Platforms that hide alt text get single-digit
   coverage. */
.alt-badge {
  position: absolute;
  inset-inline-start: var(--space-2);
  bottom: var(--space-2);
  padding: 3px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 0.7);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.alt-badge:hover {
  background: rgb(0 0 0 / 0.85);
}

/* Content veil ----------------------------------------------------------- */

/* Opaque element ABOVE the media, not filter:blur() on the <img>. A CSS blur
   samples the real pixels — it can be undone in devtools or caught in a
   screenshot mid-transition. This never paints the content until revealed. */
.media-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  text-align: center;
  background: var(--surface-sunken);
  background-image: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--mature) 7%, transparent) 0 10px,
    transparent 10px 20px
  );
  transition: opacity var(--dur-slow) var(--ease-out);
}
.media-slot[data-revealed="true"] .media-veil {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.media-veil p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 34ch;
}

/* The warning itself lives outside the veil and is always readable — the
   point of a warning is to be read before you decide. */
.cw-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: 0 var(--space-4) var(--space-3);
}

/* ------------------------------------------------------- 12. feed states */

.skeleton {
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  animation: pulse 1.6s var(--ease-out) infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* Pawpad loader: four CSS discs in an arc. Reads as a paw at a glance,
   stays abstract, ships no image. */
.pawpad {
  display: inline-grid;
  grid-template-columns: repeat(3, 6px);
  gap: 3px;
  align-items: end;
  justify-items: center;
  width: 24px;
}
.pawpad i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: pad 1.1s var(--ease-out) infinite;
}
.pawpad i:nth-child(2) {
  animation-delay: 0.12s;
  margin-bottom: 3px;
}
.pawpad i:nth-child(3) {
  animation-delay: 0.24s;
}
.pawpad i:nth-child(4) {
  grid-column: 1 / -1;
  width: 13px;
  height: 10px;
  border-radius: 50% 50% 46% 46%;
  animation-delay: 0.36s;
}
@keyframes pad {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}
.empty-state h3 {
  font-size: var(--text-xl);
}
.empty-state p {
  color: var(--text-muted);
  max-width: 44ch;
  line-height: var(--leading-body);
}

.load-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* An explicit terminus. Endless scroll with no floor is hostile to the
   late-night browsing this palette is tuned for. */
.feed-end {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  color: var(--text-subtle);
  font-size: var(--text-sm);
}
.feed-end::before,
.feed-end::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ------------------------------------------------------------- 13. modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgb(0 0 0 / 0.66);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.modal[hidden] {
  display: none;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal-panel {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - var(--space-6));
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
  padding: var(--space-5);
  animation: rise var(--dur-slow) var(--ease-out);
}
@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.modal-title {
  font-size: var(--text-xl);
  font-weight: 800;
}

/* Bottom sheet on phones: a centred dialog wastes thumb reach. */
@media (max-width: 599px) {
  .modal {
    place-items: end stretch;
    padding: 0;
  }
  .modal-panel {
    max-width: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
    animation: sheet-up var(--dur-slow) var(--ease-out);
  }
  @keyframes sheet-up {
    from {
      transform: translateY(100%);
    }
  }
}

/* --------------------------------------------------------------- 14. toast */

.toast-region {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-3));
  inset-inline-end: var(--space-4);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 380px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-3);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast::before {
  content: "";
  width: 3px;
  align-self: stretch;
  border-radius: var(--radius-pill);
  background: var(--success);
  flex: none;
}
.toast[data-kind="error"]::before {
  background: var(--danger);
}
.toast[data-kind="warn"]::before {
  background: var(--accent);
}
@keyframes toast-in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}

@media (max-width: 599px) {
  .toast-region {
    inset-inline: var(--space-3);
    top: calc(var(--topbar-h) + var(--space-2));
  }
  .toast {
    max-width: none;
  }
}

/* ------------------------------------------------------------- 15. profile */

.profile-banner {
  aspect-ratio: 3 / 1;
  background: var(--surface-sunken);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
}
.profile-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Empty banner is a wash in the owner's own hue, overlaid with the paw tile —
   never a stock photograph. Someone who has not uploaded a banner still gets a
   header that belongs to them. */
.profile-banner:not(:has(img)) {
  background-image:
    radial-gradient(ellipse 12px 10px at 38px 60px, var(--paw-strong) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 26px 46px, var(--paw-strong) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 36px 42px, var(--paw-strong) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 46px 44px, var(--paw-strong) 99%, transparent 100%),
    linear-gradient(
      118deg,
      hsl(var(--user-hue, 265) 58% 46%) 0%,
      hsl(calc(var(--user-hue, 265) + 34) 56% 38%) 52%,
      hsl(calc(var(--user-hue, 265) + 68) 52% 30%) 100%
    );
  background-size: 120px 120px, 120px 120px, 120px 120px, 120px 120px, cover;
}
[data-theme="light"] .profile-banner:not(:has(img)) {
  background-image:
    radial-gradient(ellipse 12px 10px at 38px 60px, var(--paw-strong) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 26px 46px, var(--paw-strong) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 36px 42px, var(--paw-strong) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 46px 44px, var(--paw-strong) 99%, transparent 100%),
    linear-gradient(
      118deg,
      hsl(var(--user-hue, 265) 80% 76%) 0%,
      hsl(calc(var(--user-hue, 265) + 34) 78% 70%) 52%,
      hsl(calc(var(--user-hue, 265) + 68) 72% 64%) 100%
    );
  background-size: 120px 120px, 120px 120px, 120px 120px, 120px 120px, cover;
}

:root,
[data-theme="dark"] {
  --paw-strong: rgb(255 255 255 / 0.07);
}
[data-theme="light"] {
  --paw-strong: rgb(255 255 255 / 0.3);
}

.profile-head {
  padding: 0 var(--space-4) var(--space-4);
}

/* Half-overlap welds the two upload slots into one identity block. The 4px
   canvas ring is a knockout, not a shadow — it holds up over ANY banner. */
.profile-avatar {
  width: clamp(88px, 12vw, 120px);
  height: clamp(88px, 12vw, 120px);
  font-size: clamp(88px, 12vw, 120px);
  margin-top: calc(clamp(88px, 12vw, 120px) / -2);
  border: 4px solid var(--canvas);
  background: var(--canvas);
  border-radius: var(--radius-pill);
  position: relative;
  z-index: 1;
}

.profile-name {
  font-size: var(--text-2xl);
  font-weight: 800;
}

.profile-stats {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.profile-stats b {
  color: var(--text);
  font-weight: 700;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.meta-row span,
.meta-row a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------------------------------------------------- 16. personality

   The layer that separates a community space from a dashboard. Everything
   here is CSS shapes, gradients and type — no illustration, no imagery.
   ---------------------------------------------------------------------- */

/* Paw-print wallpaper -----------------------------------------------------
   A tiled paw drawn entirely from radial gradients: one pad plus four toes,
   repeated on an offset grid so the rhythm is not obviously square. Sits at
   very low opacity behind everything and never intercepts a pointer. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    /* paw A — pad */ radial-gradient(ellipse 13px 11px at 34px 44px, var(--paw) 99%, transparent 100%),
    /* toes */ radial-gradient(ellipse 5px 6px at 22px 30px, var(--paw) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 32px 26px, var(--paw) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 42px 28px, var(--paw) 99%, transparent 100%),
    radial-gradient(ellipse 5px 6px at 50px 36px, var(--paw) 99%, transparent 100%),
    /* paw B — pad */ radial-gradient(ellipse 11px 9px at 122px 116px, var(--paw) 99%, transparent 100%),
    /* toes */ radial-gradient(ellipse 4px 5px at 112px 104px, var(--paw) 99%, transparent 100%),
    radial-gradient(ellipse 4px 5px at 121px 100px, var(--paw) 99%, transparent 100%),
    radial-gradient(ellipse 4px 5px at 130px 102px, var(--paw) 99%, transparent 100%),
    radial-gradient(ellipse 4px 5px at 137px 109px, var(--paw) 99%, transparent 100%);
  background-size: 170px 170px;
}

:root,
[data-theme="dark"] {
  --paw: rgb(255 255 255 / 0.028);
}
[data-theme="light"] {
  --paw: rgb(90 50 20 / 0.045);
}
/* The wallpaper is decoration; it goes when someone asks for plain surfaces. */
[data-contrast="high"] body::before,
[data-dim="true"] body::before {
  display: none;
}

/* Per-user colour identity ------------------------------------------------
   Every handle derives a stable hue (set as --user-hue by app.js). It colours
   that person's avatar disc, initial and collar, so faces are distinguishable
   at a glance in a feed even before anyone uploads a picture. Lightness and
   chroma are fixed per theme, so contrast holds at every hue. */
.avatar-initial {
  font-family: var(--font-display);
  font-weight: 800;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 0.46em;
  text-transform: uppercase;
  user-select: none;
  color: hsl(var(--user-hue, 265) 72% 82%);
  background:
    linear-gradient(145deg,
      hsl(var(--user-hue, 265) 46% 30%),
      hsl(calc(var(--user-hue, 265) + 28) 48% 20%));
}
[data-theme="light"] .avatar-initial {
  color: hsl(var(--user-hue, 265) 62% 26%);
  background:
    linear-gradient(145deg,
      hsl(var(--user-hue, 265) 74% 88%),
      hsl(calc(var(--user-hue, 265) + 28) 72% 80%));
}

/* A soft ring in the user's own hue. */
.avatar[style*="--user-hue"] {
  box-shadow: 0 0 0 2px color-mix(in srgb, hsl(var(--user-hue) 60% 60%) 42%, transparent);
}

/* Sticker badges ----------------------------------------------------------
   Species and role pills tilt very slightly and carry a hard offset shadow,
   so they read as things stuck onto the card rather than table cells. The
   tilt alternates by position to avoid a uniform slant. */
.badge-role {
  padding: 3px 11px;
  border-width: 1.5px;
  font-weight: 800;
  box-shadow: 1.5px 1.5px 0 color-mix(in srgb, var(--brand) 22%, transparent);
  rotate: -1.4deg;
  transition: rotate var(--dur-fast) var(--ease-spring), scale var(--dur-fast) var(--ease-out);
}
.badge-role:nth-of-type(even) {
  rotate: 1.6deg;
}
.badge-role:hover {
  rotate: 0deg;
  scale: 1.06;
}
.badge-earned {
  box-shadow: 1.5px 1.5px 0 color-mix(in srgb, var(--accent) 26%, transparent);
}
.badge-mod {
  box-shadow: 1.5px 1.5px 0 color-mix(in srgb, var(--danger) 26%, transparent);
}

/* A species badge takes the wearer's hue, so the same fox is the same colour
   everywhere. Falls back to brand when no hue is set. */
.badge-species {
  color: hsl(var(--user-hue, 265) 68% 78%);
  background: hsl(var(--user-hue, 265) 44% 22%);
  border-color: hsl(var(--user-hue, 265) 44% 38%);
  box-shadow: 1.5px 1.5px 0 hsl(var(--user-hue, 265) 44% 18%);
}
[data-theme="light"] .badge-species {
  color: hsl(var(--user-hue, 265) 68% 24%);
  background: hsl(var(--user-hue, 265) 82% 91%);
  border-color: hsl(var(--user-hue, 265) 54% 76%);
  box-shadow: 1.5px 1.5px 0 hsl(var(--user-hue, 265) 60% 84%);
}

/* Expressive headings -----------------------------------------------------
   Page titles get a warm gradient and a heavier optical size. Body copy is
   untouched — personality belongs in the display face, never in paragraphs. */
.display-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-2xl);
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, var(--brand), var(--accent) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
  padding-bottom: 2px;
}
/* Gradient text loses its contrast guarantee in high-contrast mode. */
[data-contrast="high"] .display-title {
  background: none;
  color: var(--text);
}

/* Brand wordmark gets the same treatment. */
.brand span:last-child {
  background: linear-gradient(100deg, var(--text) 40%, var(--brand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-contrast="high"] .brand span:last-child {
  background: none;
  color: var(--text);
}

/* Paw divider at the end of a feed, replacing the plain rule. */
.feed-end::before,
.feed-end::after {
  background: linear-gradient(to right, transparent, var(--border) 40%, var(--border));
}
.feed-end::after {
  background: linear-gradient(to left, transparent, var(--border) 40%, var(--border));
}

/* Composer prompt: friendlier than an empty text row. */
.composer-prompt {
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2);
  transition: background var(--dur-fast) var(--ease-out);
}
.composer-prompt:hover {
  background: var(--brand-ghost);
}

/* Empty states get a larger, friendlier paw mark. */
.empty-state .pawpad {
  scale: 1.7;
  margin-bottom: var(--space-4);
  opacity: 0.85;
}

/* ------------------------------------------------------- 17. file picker */

.picker-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 132px;
  padding: var(--space-5) var(--space-4);
  text-align: center;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    scale var(--dur-fast) var(--ease-out);
}
.picker-drop:hover,
.picker-drop:focus-visible {
  border-color: var(--brand);
  background: var(--brand-ghost);
  color: var(--text);
}
/* While a file is dragged over the target. */
.picker-drop[data-over="true"] {
  border-color: var(--brand);
  background: var(--brand-ghost);
  color: var(--text);
  scale: 1.01;
}
.picker-drop svg {
  color: var(--brand);
}

.picker-preview {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}
.picker-preview img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
}

.picker-remove {
  position: absolute;
  top: var(--space-2);
  inset-inline-end: var(--space-2);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.66);
  color: #fff;
  transition: background var(--dur-fast) var(--ease-out);
}
.picker-remove:hover {
  background: var(--danger);
}
/* Keeps the visible control compact while the tap target stays 44px. */
.picker-remove::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  width: 44px;
  height: 44px;
}

/* --------------------------------------------------------------- 18. util */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.row-between {
  justify-content: space-between;
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.muted {
  color: var(--text-muted);
}
.subtle {
  color: var(--text-subtle);
  font-size: var(--text-xs);
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mono {
  font-family: var(--font-mono);
}
[hidden] {
  display: none !important;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-3);
}
.metric {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  text-align: center;
}
.metric b {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--brand);
}
.metric span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

/* Reported content, quoted in the moderation queue so it is judged on what was
   actually said rather than on the reporter's summary of it. */
.report-quote {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-inline-start: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------ in-page dialogs */

/* Confirmations and short questions (askConfirm / askText in app.js). These
   replace the browser's own confirm() and prompt() boxes, which ignore the
   theme and cannot mark which button is the dangerous one. */
.dialog-panel {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.dialog-message {
  color: var(--text-muted);
  line-height: var(--leading-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}
@media (max-width: 599px) {
  /* Full-width, thumb-reachable buttons on phones, confirm on top. */
  .dialog-actions {
    flex-direction: column-reverse;
  }
  .dialog-actions .btn {
    width: 100%;
    height: 48px;
  }
}

/* Solid destructive action. The outline .btn-danger reads as secondary; the
   button that deletes something should not. */
.btn-danger-solid {
  background: var(--danger-fill);
  color: #fff;
  box-shadow: var(--shadow-1);
}
.btn-danger-solid:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow-2);
}
