/* Inline Images & GIFs */
.post-inline-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
  display: block;
}

.post-inline-img[data-size="small"] { width: 150px; }
.post-inline-img[data-size="medium"] { width: 300px; }
.post-inline-img[data-size="full"] { width: 100%; }

.post-inline-img[data-align="left"] { float: left; margin: 8px 16px 8px 0; clear: left; }
.post-inline-img[data-align="right"] { float: right; margin: 8px 0 8px 16px; clear: right; }
.post-inline-img[data-align="center"] { display: block; margin: 8px auto; float: none; clear: both; }

/* Spoiler text blur / click-to-reveal */
.spoiler-text {
  background-color: var(--ink, #1f2937);
  color: transparent !important;
  border-radius: 4px;
  padding: 1px 4px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.spoiler-text.is-revealed {
  background-color: rgba(128, 128, 128, 0.2);
  color: inherit !important;
  user-select: text;
}

/* ==========================================================================
   Theme tokens.  Five themes (dark, light, woods, beach, desert), chosen per member
   (profile > Site theme) and set on <html data-theme="...">.  Dark is the default.
   Pages use var(--token, fallback); add new colours here, in EVERY theme, never in a template.

   --paper-*  are the tokens for pages that were designed light: they take the theme's own
   surfaces (dark in dark and woods, light in light, beach and desert).
   The menu (--nav-*) and body text are checked for contrast in test_theme_tokens.
   ========================================================================== */
:root {
  color-scheme: dark;
  --font-hud-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Surfaces (dark pages) */
  --surface-page: #09090b;
  --surface-card: #181d2a;
  --surface-card-hover: #1e2436;
  --surface-inset: #131722;
  --surface-panel: #18181b;
  --surface-raised: #27272a;
  --surface-slate: #1e293b;
  --surface-slate-strong: #334155;
  --surface-slate-stronger: #475569;

  /* Text (dark pages) */
  --text-primary: #f8fafc;
  --text-heading: #f4f4f5;
  --text-body: #e4e4e7;
  --text-soft: #d4d4d8;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #a1a1aa;
  --text-faint: #64748b;
  --text-on-accent: #ffffff;

  /* Borders (dark pages) */
  --border-default: #3f3f46;
  --border-faint: #27272a;
  --card-border: rgba(255, 255, 255, 0.08);

  /* Accents and status (backgrounds, borders, icons) */
  --accent: #3b82f6;
  --accent-soft: #60a5fa;
  --accent-strong: #2563eb;
  --accent-strong-hover: #1d4ed8;
  --info: #0ea5e9;
  --info-soft: #38bdf8;
  --success: #10b981;
  --success-soft: #34d399;
  --warning: #f59e0b;
  --warning-soft: #fbbf24;
  --warning-strong: #f97316;
  --danger: #ef4444;
  --danger-strong: #dc2626;
  --highlight: #f4c542;

  /* Identity colours for users, circles and feeds */
  --asset-user: #10b981;
  --asset-circle: #3b82f6;
  --asset-feed: #f59e0b;
  --asset-user-glow: rgba(16, 185, 129, 0.25);
  --asset-circle-glow: rgba(59, 130, 246, 0.25);
  --asset-feed-glow: rgba(245, 158, 11, 0.25);

  /* Panels that stay dark in both themes (with their light text) */
  --fixed-dark: #18181b;
  --fixed-dark-2: #27272a;
  --fixed-dark-3: #181d2a;
  --fixed-dark-4: #1e293b;
  --fixed-dark-5: #1e2436;
  --fixed-dark-border: #3f3f46;
  --on-dark: #f8fafc;
  --on-dark-heading: #f4f4f5;
  --on-dark-body: #e4e4e7;
  --on-dark-secondary: #cbd5e1;
  --on-dark-subtle: #a1a1aa;
  --on-dark-muted: #94a3b8;

  /* Translucent layers */
  --overlay-1: rgba(255, 255, 255, 0.05);
  --overlay-2: rgba(255, 255, 255, 0.1);
  --border-overlay: rgba(255, 255, 255, 0.12);
  --border-overlay-strong: rgba(255, 255, 255, 0.2);
  --scrim: rgba(15, 23, 42, 0.65);
  --inset-scrim: rgba(19, 23, 34, 0.6);

  /* Page defaults */
  --page-bg: #09090b;
  --page-text: #e4e4e7;

  /* Pale text colours used on tinted badges */
  --text-warning-pale: #fef3c7;
  --text-warning-light: #fde68a;
  --text-yellow-pale: #fef08a;
  --text-warning-mid: #fcd34d;
  --text-orange-pale: #fdba74;
  --text-success-pale: #6ee7b7;
  --text-danger-pale: #fca5a5;
  --text-danger-paler: #fecaca;
  --text-indigo-pale: #e0e7ff;
  --text-indigo-soft: #c7d2fe;

  /* Accent colours used as text */
  --text-accent: #3b82f6;
  --text-accent-soft: #60a5fa;
  --text-accent-strong: #7cadff;
  --text-accent-deep: #6ea8fe;
  --text-info: #0ea5e9;
  --text-info-soft: #38bdf8;
  --text-success: #10b981;
  --text-success-soft: #34d399;
  --text-warning: #f59e0b;
  --text-warning-soft: #fbbf24;
  --text-warning-strong: #f97316;
  --text-danger: #ef4444;
  --text-danger-strong: #f87171;
  --text-highlight: #f4c542;
  --text-violet: #a78bfa;

  /* Main menu */
  --nav-bg: #181d2a;
  --nav-border: #2a3142;
  --nav-text: #e4e4e7;
  --nav-text-muted: #b4bccb;
  --nav-text-faint: #98a2b3;
  --nav-active: #ffffff;
  --nav-labs: #a78bfa;
  --nav-admin: #f87171;
  --nav-link: #7aa2f7;
  --nav-cta-bg: #15803d;
  --nav-cta-text: #ffffff;
  --nav-badge-bg: #dc2626;
  --nav-avatar-bg: #15803d;
  --nav-focus: #7aa2f7;

  /* Light "paper" pages: surfaces */
  --paper-page: #09090b;
  --paper-surface: #181d2a;
  --paper-surface-subtle: #131722;
  --paper-surface-muted: #1e2436;
  --paper-surface-sunken: #2a3145;
  --paper-surface-neutral: #1b2030;
  --paper-ink: #475569;
  --paper-ink-2: #5b6b82;
  --paper-accent-tint: #1a2744;
  --paper-accent-tint-strong: #1e3a5f;
  --paper-danger-tint: #3b1a1f;
  --paper-success-tint: #12332a;
  --paper-warning-tint: #3a2412;

  /* Light "paper" pages: text */
  --paper-text: #f8fafc;
  --paper-text-2: #e2e8f0;
  --paper-text-3: #cbd5e1;
  --paper-text-muted: #b6c0d0;
  --paper-text-subtle: #94a3b8;
  --paper-text-faint: #8190a5;
  --paper-danger-text: #fca5a5;
  --paper-success-text: #6ee7b7;

  /* Light "paper" pages: borders */
  --paper-border: #2f3647;
  --paper-border-strong: #3f485c;
  --paper-border-alt: #2f3647;
  --paper-divider: #232a3a;
  --paper-divider-neutral: #232a3a;
  --paper-border-neutral: #2f3647;
  --paper-accent-border: #2c4a7c;
  --paper-danger-border: #6b2a33;
  --paper-success-border: #1f6b55;

  /* Gravity Well medallions */
  --medallion-base: #131722;
  --medallion-base-hover: #181d2a;
  --medallion-border: rgba(255, 255, 255, 0.08);
}

:root[data-theme="light"] {
  color-scheme: light;

  /* Surfaces (dark pages) */
  --surface-page: #f0f2f5;
  --surface-card: #ffffff;
  --surface-card-hover: #f1f5f9;
  --surface-inset: #f8fafc;
  --surface-panel: #ffffff;
  --surface-raised: #f1f5f9;
  --surface-slate: #e2e8f0;
  --surface-slate-strong: #cbd5e1;
  --surface-slate-stronger: #b6c0d0;

  /* Text (dark pages) */
  --text-primary: #0f172a;
  --text-heading: #0f172a;
  --text-body: #1e293b;
  --text-soft: #334155;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-subtle: #566074;
  --text-faint: #566074;
  --text-on-accent: #ffffff;

  /* Borders (dark pages) */
  --border-default: #cbd5e1;
  --border-faint: #e2e8f0;
  --card-border: rgba(15, 23, 42, 0.12);

  /* Accents and status (backgrounds, borders, icons) */
  --accent: #2563eb;
  --accent-soft: #3b82f6;
  --accent-strong: #1d4ed8;
  --accent-strong-hover: #1e40af;
  --info: #0369a1;
  --info-soft: #0284c7;
  --success: #047857;
  --success-soft: #059669;
  --warning: #d97706;
  --warning-soft: #f59e0b;
  --warning-strong: #ea580c;
  --danger: #dc2626;
  --danger-strong: #b91c1c;
  --highlight: #d4a017;

  /* Identity colours for users, circles and feeds */
  --asset-user: #047857;
  --asset-circle: #1d4ed8;
  --asset-feed: #b45309;
  --asset-user-glow: rgba(4, 120, 87, 0.2);
  --asset-circle-glow: rgba(29, 78, 216, 0.2);
  --asset-feed-glow: rgba(180, 83, 9, 0.2);

  /* Panels that stay dark in both themes (with their light text) */
  --fixed-dark: #18181b;
  --fixed-dark-2: #27272a;
  --fixed-dark-3: #181d2a;
  --fixed-dark-4: #1e293b;
  --fixed-dark-5: #1e2436;
  --fixed-dark-border: #3f3f46;
  --on-dark: #f8fafc;
  --on-dark-heading: #f4f4f5;
  --on-dark-body: #e4e4e7;
  --on-dark-secondary: #cbd5e1;
  --on-dark-subtle: #a1a1aa;
  --on-dark-muted: #94a3b8;

  /* Translucent layers */
  --overlay-1: rgba(15, 23, 42, 0.04);
  --overlay-2: rgba(15, 23, 42, 0.08);
  --border-overlay: rgba(15, 23, 42, 0.16);
  --border-overlay-strong: rgba(15, 23, 42, 0.28);
  --scrim: rgba(255, 255, 255, 0.9);
  --inset-scrim: rgba(241, 245, 249, 0.85);

  /* Page defaults */
  --page-bg: #ffffff;
  --page-text: #1a202c;

  /* Pale text colours used on tinted badges */
  --text-warning-pale: #92400e;
  --text-warning-light: #92400e;
  --text-yellow-pale: #854d0e;
  --text-warning-mid: #92400e;
  --text-orange-pale: #9a3412;
  --text-success-pale: #047857;
  --text-danger-pale: #b91c1c;
  --text-danger-paler: #b91c1c;
  --text-indigo-pale: #3730a3;
  --text-indigo-soft: #4338ca;

  /* Accent colours used as text */
  --text-accent: #1d4ed8;
  --text-accent-soft: #2563eb;
  --text-accent-strong: #1d4ed8;
  --text-accent-deep: #1e40af;
  --text-info: #0369a1;
  --text-info-soft: #0369a1;
  --text-success: #047857;
  --text-success-soft: #047857;
  --text-warning: #92400e;
  --text-warning-soft: #92400e;
  --text-warning-strong: #9a3412;
  --text-danger: #b91c1c;
  --text-danger-strong: #b91c1c;
  --text-highlight: #8f5a00;
  --text-violet: #6d28d9;

  /* Main menu */
  --nav-bg: #ffffff;
  --nav-border: #dddddd;
  --nav-text: #333333;
  --nav-text-muted: #555555;
  --nav-text-faint: #6b7280;
  --nav-active: #111111;
  --nav-labs: #6d28d9;
  --nav-admin: #b91c1c;
  --nav-link: #0645ad;
  --nav-cta-bg: #15803d;
  --nav-cta-text: #ffffff;
  --nav-badge-bg: #dc2626;
  --nav-avatar-bg: #15803d;
  --nav-focus: #2563eb;

  /* Light "paper" pages: surfaces */
  --paper-page: #f0f2f5;
  --paper-surface: #ffffff;
  --paper-surface-subtle: #f8fafc;
  --paper-surface-muted: #f1f5f9;
  --paper-surface-sunken: #e2e8f0;
  --paper-surface-neutral: #f5f5f5;
  --paper-ink: #0f172a;
  --paper-ink-2: #334155;
  --paper-accent-tint: #eff6ff;
  --paper-accent-tint-strong: #dbeafe;
  --paper-danger-tint: #fef2f2;
  --paper-success-tint: #ecfdf5;
  --paper-warning-tint: #fff7ed;

  /* Light "paper" pages: text */
  --paper-text: #0f172a;
  --paper-text-2: #1e293b;
  --paper-text-3: #334155;
  --paper-text-muted: #475569;
  --paper-text-subtle: #566074;
  --paper-text-faint: #5f6b7d;
  --paper-danger-text: #b91c1c;
  --paper-success-text: #047857;

  /* Light "paper" pages: borders */
  --paper-border: #e2e8f0;
  --paper-border-strong: #cbd5e1;
  --paper-border-alt: #e2e5e9;
  --paper-divider: #f1f5f9;
  --paper-divider-neutral: #f0f0f0;
  --paper-border-neutral: #e0e0e0;
  --paper-accent-border: #bfdbfe;
  --paper-danger-border: #fecaca;
  --paper-success-border: #a7f3d0;

  /* Gravity Well medallions */
  --medallion-base: #f8fafc;
  --medallion-base-hover: #ffffff;
  --medallion-border: rgba(15, 23, 42, 0.12);
}

/* Woods: a dark palette */
:root[data-theme="woods"] {
  color-scheme: dark;

  /* Surfaces (dark pages) */
  --surface-page: #0e1612;
  --surface-card: #16231b;
  --surface-card-hover: #1d2e23;
  --surface-inset: #111c15;
  --surface-panel: #121d16;
  --surface-raised: #1f2c23;
  --surface-slate: #243329;
  --surface-slate-strong: #2e4034;
  --surface-slate-stronger: #3a5042;

  /* Text (dark pages) */
  --text-primary: #f1efe2;
  --text-heading: #f3f0e4;
  --text-body: #e3e0d0;
  --text-soft: #d3d0bf;
  --text-secondary: #c6c3b0;
  --text-muted: #a9b59c;
  --text-subtle: #9aa690;
  --text-faint: #8a9a80;
  --text-on-accent: #ffffff;

  /* Borders (dark pages) */
  --border-default: #3b4a3f;
  --border-faint: #26332a;
  --card-border: rgba(241, 239, 226, 0.10);

  /* Accents and status (backgrounds, borders, icons) */
  --accent: #3a8446;
  --accent-soft: #9ccc65;
  --accent-strong: #3f7d4a;
  --accent-strong-hover: #346840;
  --info: #25807e;
  --info-soft: #7cc7c3;
  --success: #3f7f35;
  --success-soft: #a5d98a;
  --warning: #d9a441;
  --warning-soft: #e8c170;
  --warning-strong: #c9732e;
  --danger: #c04632;
  --danger-strong: #b04030;
  --highlight: #e3c76a;

  /* Identity colours for users, circles and feeds */
  --asset-user: #7cb342;
  --asset-circle: #3a7ca5;
  --asset-feed: #d9a441;
  --asset-user-glow: rgba(124, 179, 66, 0.25);
  --asset-circle-glow: rgba(106, 168, 196, 0.25);
  --asset-feed-glow: rgba(217, 164, 65, 0.25);

  /* Panels that stay dark in both themes (with their light text) */
  --fixed-dark: #18181b;
  --fixed-dark-2: #27272a;
  --fixed-dark-3: #181d2a;
  --fixed-dark-4: #1e293b;
  --fixed-dark-5: #1e2436;
  --fixed-dark-border: #3f3f46;
  --on-dark: #f8fafc;
  --on-dark-heading: #f4f4f5;
  --on-dark-body: #e4e4e7;
  --on-dark-secondary: #cbd5e1;
  --on-dark-subtle: #a1a1aa;
  --on-dark-muted: #94a3b8;

  /* Translucent layers */
  --overlay-1: rgba(241, 239, 226, 0.05);
  --overlay-2: rgba(241, 239, 226, 0.10);
  --border-overlay: rgba(241, 239, 226, 0.14);
  --border-overlay-strong: rgba(241, 239, 226, 0.22);
  --scrim: rgba(14, 22, 18, 0.7);
  --inset-scrim: rgba(17, 28, 21, 0.6);

  /* Page defaults */
  --page-bg: #0e1612;
  --page-text: #e3e0d0;

  /* Pale text colours used on tinted badges */
  --text-warning-pale: #fef3c7;
  --text-warning-light: #fde68a;
  --text-yellow-pale: #fef08a;
  --text-warning-mid: #fcd34d;
  --text-orange-pale: #fdba74;
  --text-success-pale: #6ee7b7;
  --text-danger-pale: #fca5a5;
  --text-danger-paler: #fecaca;
  --text-indigo-pale: #e0e7ff;
  --text-indigo-soft: #c7d2fe;

  /* Accent colours used as text */
  --text-accent: #8fcb6a;
  --text-accent-soft: #a9d98a;
  --text-accent-strong: #a6d48a;
  --text-accent-deep: #9acd7c;
  --text-info: #6fc4c0;
  --text-info-soft: #8fd6d2;
  --text-success: #8bc965;
  --text-success-soft: #a5d98a;
  --text-warning: #e0b050;
  --text-warning-soft: #ecc878;
  --text-warning-strong: #e08a4a;
  --text-danger: #ee8672;
  --text-danger-strong: #f29a88;
  --text-highlight: #e8cf7c;
  --text-violet: #b9a6e8;

  /* Main menu */
  --nav-bg: #16231b;
  --nav-border: #2c3d31;
  --nav-text: #ece9da;
  --nav-text-muted: #b9c2ac;
  --nav-text-faint: #9eab93;
  --nav-active: #ffffff;
  --nav-labs: #c3b1f0;
  --nav-admin: #f08a76;
  --nav-link: #9fd27c;
  --nav-cta-bg: #2f7a43;
  --nav-cta-text: #ffffff;
  --nav-badge-bg: #c0392b;
  --nav-avatar-bg: #2f7a43;
  --nav-focus: #9fd27c;

  /* Light "paper" pages: surfaces */
  --paper-page: #0e1612;
  --paper-surface: #16231b;
  --paper-surface-subtle: #111c15;
  --paper-surface-muted: #1d2e23;
  --paper-surface-sunken: #2a3b2f;
  --paper-surface-neutral: #1a281f;
  --paper-ink: #4a6350;
  --paper-ink-2: #5d7863;
  --paper-accent-tint: #1b3326;
  --paper-accent-tint-strong: #244634;
  --paper-danger-tint: #3a1f1a;
  --paper-success-tint: #1c3a24;
  --paper-warning-tint: #3a2e14;

  /* Light "paper" pages: text */
  --paper-text: #f1efe2;
  --paper-text-2: #e3e0d0;
  --paper-text-3: #cfccba;
  --paper-text-muted: #bcc4ae;
  --paper-text-subtle: #a3b096;
  --paper-text-faint: #8c9a82;
  --paper-danger-text: #f4a496;
  --paper-success-text: #a3d98a;

  /* Light "paper" pages: borders */
  --paper-border: #2f4034;
  --paper-border-strong: #405446;
  --paper-border-alt: #2f4034;
  --paper-divider: #243329;
  --paper-divider-neutral: #243329;
  --paper-border-neutral: #2f4034;
  --paper-accent-border: #3f6b4a;
  --paper-danger-border: #6b3a30;
  --paper-success-border: #3f7a4c;

  /* Gravity Well medallions */
  --medallion-base: #111c15;
  --medallion-base-hover: #16231b;
  --medallion-border: rgba(241, 239, 226, 0.10);
}

/* Beach: a light palette */
:root[data-theme="beach"] {
  color-scheme: light;

  /* Surfaces (dark pages) */
  --surface-page: #f6efe0;
  --surface-card: #fffdf8;
  --surface-card-hover: #f3ead7;
  --surface-inset: #faf4e6;
  --surface-panel: #fffdf8;
  --surface-raised: #f1e8d4;
  --surface-slate: #e3d9c3;
  --surface-slate-strong: #d3c7ad;
  --surface-slate-stronger: #c2b596;

  /* Text (dark pages) */
  --text-primary: #10343d;
  --text-heading: #0c2d36;
  --text-body: #1d3f48;
  --text-soft: #2f535c;
  --text-secondary: #2f535c;
  --text-muted: #44656d;
  --text-subtle: #44636a;
  --text-faint: #4c686f;
  --text-on-accent: #ffffff;

  /* Borders (dark pages) */
  --border-default: #d6c9ad;
  --border-faint: #e6dcc6;
  --card-border: rgba(16, 52, 61, 0.14);

  /* Accents and status (backgrounds, borders, icons) */
  --accent: #0e7490;
  --accent-soft: #0891b2;
  --accent-strong: #0e7490;
  --accent-strong-hover: #155e75;
  --info: #0369a1;
  --info-soft: #0284c7;
  --success: #0f766e;
  --success-soft: #14998f;
  --warning: #d97706;
  --warning-soft: #f59e0b;
  --warning-strong: #ea580c;
  --danger: #c53a35;
  --danger-strong: #b91c1c;
  --highlight: #e0a63a;

  /* Identity colours for users, circles and feeds */
  --asset-user: #0f766e;
  --asset-circle: #0e7490;
  --asset-feed: #c2410c;
  --asset-user-glow: rgba(15, 118, 110, 0.2);
  --asset-circle-glow: rgba(14, 116, 144, 0.2);
  --asset-feed-glow: rgba(194, 65, 12, 0.2);

  /* Panels that stay dark in both themes (with their light text) */
  --fixed-dark: #18181b;
  --fixed-dark-2: #27272a;
  --fixed-dark-3: #181d2a;
  --fixed-dark-4: #1e293b;
  --fixed-dark-5: #1e2436;
  --fixed-dark-border: #3f3f46;
  --on-dark: #f8fafc;
  --on-dark-heading: #f4f4f5;
  --on-dark-body: #e4e4e7;
  --on-dark-secondary: #cbd5e1;
  --on-dark-subtle: #a1a1aa;
  --on-dark-muted: #94a3b8;

  /* Translucent layers */
  --overlay-1: rgba(16, 52, 61, 0.04);
  --overlay-2: rgba(16, 52, 61, 0.08);
  --border-overlay: rgba(16, 52, 61, 0.16);
  --border-overlay-strong: rgba(16, 52, 61, 0.28);
  --scrim: rgba(255, 253, 248, 0.92);
  --inset-scrim: rgba(250, 244, 230, 0.85);

  /* Page defaults */
  --page-bg: #fffdf8;
  --page-text: #10343d;

  /* Pale text colours used on tinted badges */
  --text-warning-pale: #92400e;
  --text-warning-light: #92400e;
  --text-yellow-pale: #854d0e;
  --text-warning-mid: #92400e;
  --text-orange-pale: #9a3412;
  --text-success-pale: #047857;
  --text-danger-pale: #b91c1c;
  --text-danger-paler: #b91c1c;
  --text-indigo-pale: #3730a3;
  --text-indigo-soft: #4338ca;

  /* Accent colours used as text */
  --text-accent: #0e6a84;
  --text-accent-soft: #0b6f86;
  --text-accent-strong: #0e6a84;
  --text-accent-deep: #155e75;
  --text-info: #0369a1;
  --text-info-soft: #0369a1;
  --text-success: #0d6b64;
  --text-success-soft: #0d6b64;
  --text-warning: #92400e;
  --text-warning-soft: #92400e;
  --text-warning-strong: #9a3412;
  --text-danger: #b91c1c;
  --text-danger-strong: #b91c1c;
  --text-highlight: #8a5a00;
  --text-violet: #6d28d9;

  /* Main menu */
  --nav-bg: #fffdf8;
  --nav-border: #e0d3b6;
  --nav-text: #10343d;
  --nav-text-muted: #3d5d65;
  --nav-text-faint: #587479;
  --nav-active: #062a33;
  --nav-labs: #6d28d9;
  --nav-admin: #b91c1c;
  --nav-link: #0e6a84;
  --nav-cta-bg: #0f766e;
  --nav-cta-text: #ffffff;
  --nav-badge-bg: #c2410c;
  --nav-avatar-bg: #0f766e;
  --nav-focus: #0e7490;

  /* Light "paper" pages: surfaces */
  --paper-page: #f6efe0;
  --paper-surface: #fffdf8;
  --paper-surface-subtle: #faf4e6;
  --paper-surface-muted: #f1e8d4;
  --paper-surface-sunken: #e3d9c3;
  --paper-surface-neutral: #f3ecdc;
  --paper-ink: #10343d;
  --paper-ink-2: #2f535c;
  --paper-accent-tint: #e0f2f4;
  --paper-accent-tint-strong: #bfe3e8;
  --paper-danger-tint: #fdecea;
  --paper-success-tint: #e3f4ee;
  --paper-warning-tint: #fdf0d8;

  /* Light "paper" pages: text */
  --paper-text: #10343d;
  --paper-text-2: #1d3f48;
  --paper-text-3: #2f535c;
  --paper-text-muted: #44656d;
  --paper-text-subtle: #44636a;
  --paper-text-faint: #4c686f;
  --paper-danger-text: #b91c1c;
  --paper-success-text: #0d6b64;

  /* Light "paper" pages: borders */
  --paper-border: #e6dcc6;
  --paper-border-strong: #d6c9ad;
  --paper-border-alt: #e9dfc9;
  --paper-divider: #f1e8d4;
  --paper-divider-neutral: #f1e8d4;
  --paper-border-neutral: #e0d3b6;
  --paper-accent-border: #9fd0d8;
  --paper-danger-border: #f3b8b2;
  --paper-success-border: #a6d9c9;

  /* Gravity Well medallions */
  --medallion-base: #faf4e6;
  --medallion-base-hover: #fffdf8;
  --medallion-border: rgba(16, 52, 61, 0.14);
}

/* Desert: a light palette */
:root[data-theme="desert"] {
  color-scheme: light;

  /* Surfaces (dark pages) */
  --surface-page: #f3e3c9;
  --surface-card: #fbf1df;
  --surface-card-hover: #f1ddbc;
  --surface-inset: #f7e9d0;
  --surface-panel: #fbf1df;
  --surface-raised: #efdcb9;
  --surface-slate: #e5cfa5;
  --surface-slate-strong: #d6bb88;
  --surface-slate-stronger: #c4a46c;

  /* Text (dark pages) */
  --text-primary: #3a2412;
  --text-heading: #331f0f;
  --text-body: #4a301b;
  --text-soft: #5e4128;
  --text-secondary: #5e4128;
  --text-muted: #654730;
  --text-subtle: #6e4f33;
  --text-faint: #6a4c32;
  --text-on-accent: #ffffff;

  /* Borders (dark pages) */
  --border-default: #cfae7e;
  --border-faint: #e0c79c;
  --card-border: rgba(58, 36, 18, 0.16);

  /* Accents and status (backgrounds, borders, icons) */
  --accent: #b4532a;
  --accent-soft: #c8693a;
  --accent-strong: #a8431f;
  --accent-strong-hover: #8f3716;
  --info: #2f6f8f;
  --info-soft: #3b82a6;
  --success: #4d7a3a;
  --success-soft: #5f8f48;
  --warning: #c77d12;
  --warning-soft: #d6a032;
  --warning-strong: #b4532a;
  --danger: #b3261e;
  --danger-strong: #8f1d17;
  --highlight: #d6a032;

  /* Identity colours for users, circles and feeds */
  --asset-user: #4d7a3a;
  --asset-circle: #285e7a;
  --asset-feed: #b4532a;
  --asset-user-glow: rgba(77, 122, 58, 0.22);
  --asset-circle-glow: rgba(47, 111, 143, 0.22);
  --asset-feed-glow: rgba(180, 83, 42, 0.22);

  /* Panels that stay dark in both themes (with their light text) */
  --fixed-dark: #18181b;
  --fixed-dark-2: #27272a;
  --fixed-dark-3: #181d2a;
  --fixed-dark-4: #1e293b;
  --fixed-dark-5: #1e2436;
  --fixed-dark-border: #3f3f46;
  --on-dark: #f8fafc;
  --on-dark-heading: #f4f4f5;
  --on-dark-body: #e4e4e7;
  --on-dark-secondary: #cbd5e1;
  --on-dark-subtle: #a1a1aa;
  --on-dark-muted: #94a3b8;

  /* Translucent layers */
  --overlay-1: rgba(58, 36, 18, 0.05);
  --overlay-2: rgba(58, 36, 18, 0.09);
  --border-overlay: rgba(58, 36, 18, 0.18);
  --border-overlay-strong: rgba(58, 36, 18, 0.30);
  --scrim: rgba(251, 241, 223, 0.92);
  --inset-scrim: rgba(247, 233, 208, 0.85);

  /* Page defaults */
  --page-bg: #fbf1df;
  --page-text: #3a2412;

  /* Pale text colours used on tinted badges */
  --text-warning-pale: #92400e;
  --text-warning-light: #92400e;
  --text-yellow-pale: #854d0e;
  --text-warning-mid: #92400e;
  --text-orange-pale: #9a3412;
  --text-success-pale: #065f46;
  --text-danger-pale: #b91c1c;
  --text-danger-paler: #b91c1c;
  --text-indigo-pale: #3730a3;
  --text-indigo-soft: #4338ca;

  /* Accent colours used as text */
  --text-accent: #9a3f1c;
  --text-accent-soft: #a34a22;
  --text-accent-strong: #9a3f1c;
  --text-accent-deep: #7f3216;
  --text-info: #1f5f7f;
  --text-info-soft: #1f5f7f;
  --text-success: #3f6b2f;
  --text-success-soft: #3f6b2f;
  --text-warning: #8a4b05;
  --text-warning-soft: #8a4b05;
  --text-warning-strong: #8f3a0e;
  --text-danger: #a31f18;
  --text-danger-strong: #a31f18;
  --text-highlight: #7a5500;
  --text-violet: #5b21b6;

  /* Main menu */
  --nav-bg: #fbf1df;
  --nav-border: #dcc08e;
  --nav-text: #3a2412;
  --nav-text-muted: #5a3f27;
  --nav-text-faint: #735238;
  --nav-active: #1f1208;
  --nav-labs: #5b21b6;
  --nav-admin: #a31f18;
  --nav-link: #8f3716;
  --nav-cta-bg: #a8431f;
  --nav-cta-text: #ffffff;
  --nav-badge-bg: #a31f18;
  --nav-avatar-bg: #4d7a3a;
  --nav-focus: #b4532a;

  /* Light "paper" pages: surfaces */
  --paper-page: #f3e3c9;
  --paper-surface: #fbf1df;
  --paper-surface-subtle: #f7e9d0;
  --paper-surface-muted: #efdcb9;
  --paper-surface-sunken: #e5cfa5;
  --paper-surface-neutral: #f1e2c6;
  --paper-ink: #3a2412;
  --paper-ink-2: #5e4128;
  --paper-accent-tint: #fbe3d4;
  --paper-accent-tint-strong: #f4cdb4;
  --paper-danger-tint: #fbe0dc;
  --paper-success-tint: #e4efd8;
  --paper-warning-tint: #fbebc8;

  /* Light "paper" pages: text */
  --paper-text: #3a2412;
  --paper-text-2: #4a301b;
  --paper-text-3: #5e4128;
  --paper-text-muted: #654730;
  --paper-text-subtle: #6e4f33;
  --paper-text-faint: #735238;
  --paper-danger-text: #a31f18;
  --paper-success-text: #3f6b2f;

  /* Light "paper" pages: borders */
  --paper-border: #e0c79c;
  --paper-border-strong: #cfae7e;
  --paper-border-alt: #e6cfa6;
  --paper-divider: #efdcb9;
  --paper-divider-neutral: #efdcb9;
  --paper-border-neutral: #dcc08e;
  --paper-accent-border: #e8b494;
  --paper-danger-border: #eba9a1;
  --paper-success-border: #b5d19c;

  /* Gravity Well medallions */
  --medallion-base: #f7e9d0;
  --medallion-base-hover: #fbf1df;
  --medallion-border: rgba(58, 36, 18, 0.16);
}

/* Pages that do not set their own background or text colour follow the theme. */
body {
  background: var(--page-bg, #ffffff);
  color: var(--page-text, #1a202c);
}

/* Full editor (New Post, Publish Circle) */
.tiptap.ProseMirror {
  min-height: 180px;
  padding: 14px 16px;
  outline: none;
  border: none;
  font-size: 1rem;
  line-height: 1.6;
  cursor: text;
  color: var(--text-primary, #f8fafc);
  background: transparent;
  caret-color: var(--asset-circle, #3b82f6);
}

/* Tiptap Empty State Placeholder */
.tiptap.ProseMirror p.is-editor-empty:first-child::before,
.tiptap.ProseMirror p.is-empty:first-child::before,
.tiptap.ProseMirror.is-editor-empty::before {
  content: attr(data-placeholder);
  float: left;
  color: #64748b;
  pointer-events: none;
  height: 0;
  font-style: normal;
}

/* Remove fixed, top-heavy formatting toolbars */
.ql-toolbar,
.rich-editor-toolbar {
  display: none !important;
}

/* Tiptap Floating Bubble Menu */
.rich-editor-bubble-menu {
  position: absolute;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  background: var(--surface-card, #181d2a);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.7), 0 0 12px rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}
.rich-editor-bubble-menu.is-active {
  display: flex !important;
}
.rich-editor-bubble-menu button {
  background: transparent;
  color: var(--text-muted, #94a3b8);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}
.rich-editor-bubble-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #f8fafc);
}
.rich-editor-bubble-menu button.is-active {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: var(--accent-soft, #60a5fa);
}

/* Always-visible formatting toolbar (post composer) */
.rich-editor-fixed-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--surface-inset, #131722);
  border-bottom: 1px solid var(--border-overlay, rgba(255, 255, 255, 0.12));
  border-radius: 10px 10px 0 0;
}
.rich-editor-fixed-toolbar button {
  background: transparent;
  color: var(--text-secondary, #cbd5e1);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  min-width: 32px;
}
.rich-editor-fixed-toolbar button:hover {
  background: var(--surface-raised, rgba(255, 255, 255, 0.1));
  color: var(--text-primary, #f8fafc);
}
.rich-editor-fixed-toolbar button.is-active {
  background: var(--accent-strong, #2563eb);
  border-color: var(--accent-strong, #2563eb);
  color: var(--text-on-accent, #fff);
}
.rich-editor-fixed-toolbar button:focus-visible {
  outline: 2px solid var(--accent-strong, #2563eb);
  outline-offset: 2px;
}
.rich-editor-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border-overlay, rgba(255, 255, 255, 0.2));
}

/* Compact editor (Comments) */
.rich-editor-compact .tiptap.ProseMirror {
  min-height: 80px;
  padding: 8px 12px;
}

/* Outer editor wrapper */
.rich-editor-wrapper {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--surface-card, #181d2a);
  overflow: visible;
}

/* External RSS / Galactic Feed Cards */
.post.external-feed-card,
.post-card.external-feed-card,
article.external-feed-card {
  border-left: 2px solid var(--asset-feed, #f59e0b) !important;
}

/* RSS / Podcast 3D Card Styling */
.rss-item-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  border-bottom: 4px solid #cbd5e1; /* 3D shelf effect */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}

.rss-item-card:hover {
  transform: translateY(-2px);
  border-bottom-color: #94a3b8;
  box-shadow: 0 8px 12px -2px rgba(0, 0, 0, 0.08);
}

/* Category/Type Accent Spines */
.rss-item-card.type-article {
  border-left: 5px solid #F26522; /* Classic RSS Orange */
}

.rss-item-card.type-podcast {
  border-left: 5px solid #7C3AED; /* Podcast Purple */
}

/* Top-Right RSS / Podcast Flair Badge */
.rss-flair {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.flair-article {
  background: #FFF7ED;
  color: #C2410C;
  border: 1px solid #FDBA74;
}

.flair-podcast {
  background: #FAF5FF;
  color: #6B21A8;
  border: 1px solid #D8B4FE;
}

.spoiler, .spoiler-block, [data-spoiler], .spoiler-text { cursor: pointer; }
.spoiler.revealed, .spoiler-block.revealed, [data-spoiler].revealed, .spoiler-text.revealed { background-color: transparent !important; color: inherit !important; }

/* Scrollable Asset List Constraints */
.scrollable-asset-list {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) rgba(15, 23, 42, 0.2);
}

.scrollable-asset-list::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollable-asset-list::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 4px;
}

.scrollable-asset-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

.scrollable-asset-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

/* Drag Kinematics & Ring Physics */
.is-dragging {
  transform: scale(0.95);
  opacity: 0.9;
}

.ring {
  transition: box-shadow 0.3s ease-out;
}

/* Feed Card Flip Size Constraints & CSS Grid Overlap */
.post.flipped,
.post-card.flipped,
.post-circle-flip.flipped,
.post-circle-flip.is-active,
.medallion-container.flipped,
.medallion-container.is-active {
  transform-origin: center center;
  box-sizing: border-box;
}

/* Feed card sizing: scoped to circles shown inside a post, because other pages (the RSS hub)
   reuse .post-circle-flip with their own sizing. */
.post .post-circle-flip {
  display: grid !important;
  transform-style: preserve-3d;
  align-items: stretch;
}

.post .post-circle-flip > .front,
.post .post-circle-flip > .back {
  grid-area: 1 / 1 !important;
  position: relative !important;
  width: 100% !important;
  height: auto !important;
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
}

/* Only the feed's circle card rotates its own container.  In the Gravity Well the inner
   .medallion-card / .medallion-flipper rotates, so rotating the container too would
   mirror the back face. */
.post-circle-flip.flipped {
  transform: rotateY(180deg) !important;
}

.post .post-circle-flip,
.post .post-circle-flip.flipped,
.post .post-circle-flip.is-active,
.post .medallion-container,
.post .medallion-container.flipped,
.post .medallion-container.is-active {
  width: 200px !important;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  position: relative;
}

.post.flipped,
.post-card.flipped {
  transform: none;
  position: relative;
}

.post-circle-flip > .back,
.medallion-container > .back,
.medallion-back {
  transform: rotateY(180deg) !important;
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
}

/* Gravity Well ring bands and rings must always accept pointer events so
   dragover / drop fire on the SVG elements */
.ring,
.ring-band {
  pointer-events: all !important;
}

/* ===== Photo albums (a post with several photos; see _post_images.html and js/album_viewer.js) ===== */
.album { display: grid; gap: 4px; margin: 10px 0 14px; border-radius: 12px; overflow: hidden; background: var(--surface-inset, #131722); }
.album-item { position: relative; display: block; min-width: 0; min-height: 0; overflow: hidden; background: var(--surface-inset, #131722); cursor: zoom-in; }
.album-item img { display: block; width: 100%; transition: filter 0.15s ease; }
.album-item:hover img { filter: brightness(0.93); }
.album-extra { display: none; }
.album-1 .album-item img { height: auto; max-height: 520px; object-fit: cover; }
.album-2, .album-3, .album-4 { grid-template-columns: 1fr 1fr; }
.album-2 { aspect-ratio: 2 / 1; }
.album-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.album-3 .album-item:first-child { grid-row: span 2; }
.album-4 { grid-template-rows: 1fr 1fr; aspect-ratio: 4 / 3; }
.album-2 .album-item img, .album-3 .album-item img, .album-4 .album-item img { position: absolute; inset: 0; height: 100%; object-fit: cover; }
.album-more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1.6rem; font-weight: 700; pointer-events: none; }

.album-viewer { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; background: var(--viewer-bg, rgba(0, 0, 0, 0.94)); touch-action: pan-y; }
.album-viewer[hidden] { display: none; }
.album-viewer-img { max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: transform 0.18s ease; }
.album-viewer-img.is-dragging { transition: none; }
.album-viewer button { position: absolute; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 1.6rem; line-height: 1; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.album-viewer button:hover, .album-viewer button:focus-visible { background: rgba(255, 255, 255, 0.28); outline: none; }
.album-viewer-close { top: 14px; right: 14px; }
.album-viewer-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.album-viewer-next { right: 14px; top: 50%; transform: translateY(-50%); }
.album-viewer-count { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 0.95rem; background: rgba(0, 0, 0, 0.45); padding: 3px 12px; border-radius: 999px; }
body.album-viewer-open { overflow: hidden; }
@media (max-width: 720px) {
  .album-viewer-prev, .album-viewer-next { display: none; }  /* phones swipe */
}

/* ===== Phones and small tablets ===== */
@media (max-width: 720px) {
  img, video, canvas, iframe { max-width: 100%; }
  img, video { height: auto; }
  body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  button, [role="button"], a.btn, input[type="submit"], input[type="button"], select { min-height: 40px; touch-action: manipulation; }
  /* 16px stops iPhones zooming the page when a field is focused. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px; }
  /* The floating feedback button shrinks to its icon so it covers less of the page. */
  button[onclick*="feedback-widget"] { width: 48px; height: 48px; padding: 0 !important; left: 12px !important; bottom: 12px !important; font-size: 0 !important; justify-content: center; }
  button[onclick*="feedback-widget"]::before { content: "\1F4AC"; font-size: 22px; line-height: 1; }
  table { max-width: 100%; }
}
