/* =========================================================
   Static Noir Mint Dark — Index
   Last updated: 2025-08-12
   ---------------------------------------------------------
   • Desktop: fixed sidebar width
   • Mobile: single breakpoint (1024px) → off-canvas drawers + mobile layout
   • Height fits content in both positions
   ========================================================= */

:root {
  --bg: #0b0f14;
  --surface: #10151d;
  --surface-2: #0e131a;
  --text: #95f1d6;
  --muted: #9fb2c3;
  --border: rgba(230,238,245,.12);
  --grad-primary: linear-gradient(135deg,#0f1a1f 0%, #0b272a 45%, #0a3a33 100%);
  --alpha-80: .8;
  --surface-rgb: 16,21,29;
  --glass: rgba(var(--surface-rgb), var(--alpha-80));
  --radius: 16px;
  --glow-strong: 0 0 0 2px rgba(56,189,148,.10);

  /* Title sizing tokens */
  --header-h: 84px;

  /* NEW: fixed desktop sidebar width */
  --sidebar-w: 240px;

  /* Titles */
  --title-color: #95f1d6;

  /* Glows used by many buttons/cards */
  --glow: 0 0 0 2px rgba(56,189,148,.10);
  --glow-red: 0 0 0 2px rgba(255,107,107,.12);

  /* Form/layout sizing used across pages */
  --pad: 16px;
  --field-h: 44px;
  --wrap-max: 720px;

  /* Posts grid tokens */
  --post-min: 300px;
  --card-max: 899px;

  /* Unified flash colors */
  --success-text-color: #b4ffec;
  --error-text-color: #ffb4b4;

  /* Legacy */
  --content-max: 960px;
  --form-max: 880px;
  --gutter: 16px;

  --link-color: #95f1d6;
  --link-hover-color: #b4ffec;
  --radius-sm: 12px;

  /* =========================================================
     Standard control + surface tokens (NEW)
     Ensure dark backgrounds for mint/light text on all pages
     ========================================================= */

  /* Controls (inputs/selects/textareas) */
  --control-bg: rgba(2, 6, 23, 0.35);
  --control-bg-strong: rgba(2, 6, 23, 0.55);
  --control-border: rgba(230,238,245,.14);
  --control-border-focus: rgba(56,189,148,.55);

  /* Text containers/surfaces */
  --surface-bg: rgba(2, 6, 23, 0.28);
  --surface-bg-strong: rgba(2, 6, 23, 0.42);
  --surface-border: rgba(148,163,184,.16);
  --surface-border-dashed: rgba(148,163,184,.20);

  /* Stage 1: standardized spacing scale */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 6px;
  --space-3: 8px;
  --space-4: 10px;
  --space-5: 12px;
  --space-6: 14px;
  --space-7: 16px;
  --space-8: 18px;
  --space-9: 20px;
  --space-10: 24px;

  /* Stage 1: radius scale */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Stage 1: control shell tokens */
  --control-text: var(--text);
  --control-placeholder: rgba(159,178,195,.85);
  --control-radius: var(--radius-md);
  --control-pad-x: 12px;
  --control-pad-y: 10px;
  --control-h-sm: 30px;
  --control-h-md: 36px;
  --control-h-lg: 44px;

  /* Stage 1: shared layout + motion tokens */
  --stack-gap-sm: var(--space-3);
  --stack-gap: var(--space-5);
  --stack-gap-lg: var(--space-7);
  --card-pad: var(--space-6);
  --card-pad-lg: var(--space-7);
  --btn-radius: var(--radius-md);
  --btn-pad-y: 10px;
  --btn-pad-x: 14px;
  --btn-pad-y-compact: 8px;
  --btn-pad-x-compact: 12px;
  --btn-pad-y-tiny: 6px;
  --btn-pad-x-tiny: 10px;
  --transition-fast: .12s ease;
  --transition-base: .25s ease;

  /* Stage 1: mobile shell overlay prep */
  --z-overlay-backdrop: 220;
  --z-overlay-panel: 230;
  --mobile-panel-w: min(70.4vw, 288px);
  --mobile-panel-shadow: 0 18px 40px rgba(0,0,0,.42);
  --mobile-backdrop: rgba(2, 6, 23, .56);
}

/* Global: allow scrolling but hide scrollbars */
html, body {
  height: 100%;
  overflow-y: auto;
  -ms-overflow-style: none;  /* IE/Edge legacy */
  scrollbar-width: none;     /* Firefox */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

#app, .app, .layout, main {
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#app::-webkit-scrollbar,
.app::-webkit-scrollbar,
.layout::-webkit-scrollbar,
main::-webkit-scrollbar {
  width: 0;
  height: 0;
}

@media (hover: none) and (pointer: coarse) {
  html, body {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  html::-webkit-scrollbar,
  body::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}


/* Stage 1 scroll/layout primitives (opt-in + safe defaults) */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.scroll-y.hide-scrollbar {
  overscroll-behavior: contain;
}

.ui-stack { display: flex; flex-direction: column; gap: var(--stack-gap); }
.ui-stack--sm { gap: var(--stack-gap-sm); }
.ui-stack--lg { gap: var(--stack-gap-lg); }
.ui-row { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.ui-row--between { justify-content: space-between; }
.ui-wrap { flex-wrap: wrap; }
.ui-card-pad { padding: var(--card-pad); }
.ui-control {
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--control-text);
  border-radius: var(--control-radius);
}

@font-face {
  font-family: 'Allura';
  src: url('/fonts/Allura.woff2') format('woff2'),
       url('/fonts/Allura.woff')  format('woff'),
       url('/fonts/Allura.ttf')   format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  font-synthesis: none;
  font-display: fallback;
  font-size-adjust: 0.5;
}

/* Title bar */
.titlebar {
  border-radius: calc(var(--radius) + 8px);
  background: var(--grad-primary);
  color: var(--control-text);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}

.titlebar__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  min-height: var(--header-h);
}

.site-logo {
  margin: 0;
  line-height: 1;
}

/* Final brand rule (single source of truth) */
.titlebar .site-logo .brand {
  display: inline-block;
  padding: 0;
  border-radius: 0;
  background: none;
  text-decoration: none;

  font-family: 'Allura', cursive;
  font-weight: 400;
  font-size: 48px;
  letter-spacing: 1px;
  line-height: 1.2;

  color: var(--title-color);
  transition: transform .25s ease, text-shadow .25s ease;
}

.titlebar .site-logo .brand:hover {
  transform: scale(1.05);
}

/* Home container title */
.home-title,
.home-container > h1,
.main-content .home-title,
.main-content .section-title {
  color: var(--title-color) !important;
}

/* Post card titles on the all-posts page */
.posts-grid .post-card .post-title,
.posts-grid .post-card .post-title a,
.posts-list .post-card .post-title,
.posts-list .post-card .post-title a,
.posts-grid .post-card h1,
.posts-grid .post-card h2 {
  color: var(--title-color) !important;
}

/* Single post page title */
.single-post .post-title,
.single-post .post-header .post-title,
.post-page h1.post-title,
.post-page .post-header h1.post-title,
.single-post .post-title a {
  color: var(--title-color) !important;
}

/* Ensure link states don’t change the title color */
a.post-title:link,
a.post-title:visited,
a.post-title:hover,
a.post-title:active {
  color: var(--title-color) !important;
}

/* Base & video */
* { box-sizing: border-box; }

/* Responsive width safety for nested flex/grid children */
:where(.frame, .layout, .main-content, .sidebar, .card, .panel, .box, .form-card, .table) {
  min-width: 0;
}

:where(.main-content, .sidebar, .card, .panel, .box, .form-card) {
  width: min(100%, 100%);
}

html,
body { height: 100%; }

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  color: var(--text);
  font: 400 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: hidden; /* page itself should not scroll; main-content scrolls */
}

.video-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(800px 400px at 20% 10%, rgba(56,189,148,.08), transparent 60%);
}

.video-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.1) contrast(1.05) brightness(.9);
}

.frame {
  position: relative;
  z-index: 1;
  padding: 20px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent;
}

/* Layout: sidebar + main */
.layout {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex: 1 1 auto;
  min-height: calc(100dvh - 40px - 12px - var(--header-h));
}

/* Desktop: FIXED sidebar width; height fits content */
.layout > .sidebar {
  align-self: flex-start;
  flex: 0 0 auto;
  width: var(--sidebar-w);
  min-width: 220px;
  max-width: var(--sidebar-w);

  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  backdrop-filter: saturate(1.1) blur(2px);
}

.main-content {
  -ms-overflow-style: none;
  scrollbar-width: none;
  flex: 1 1 0%;
  min-width: 0;
  background: transparent;
  border: transparent;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  overflow: auto;
  backdrop-filter: saturate(1.1) blur(2px);
  min-height: 100%;
}

.main-content::-webkit-scrollbar,
.layout > .sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Generic containers */
.card,
.panel,
.box,
.message,
.table,
.form-card,
.alert {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: saturate(1.1) blur(2px);
}

/* Message variants */
.message.info {
  background: rgba(56,189,148,.08);
  border-color: rgba(56,189,148,.22);
  color: var(--success-text-color);
}

.message.success {
  background: rgba(56,189,148,.10);
  border-color: rgba(56,189,148,.28);
  color: var(--success-text-color);
}

.message.error {
  background: rgba(255,86,86,.12);
  border-color: rgba(255,86,86,.35);
  color: var(--error-text-color);
}

/* Utility classes used in templates */
.container { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.mb-4 { margin-bottom: 16px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.font-bold { font-weight: 700; }
.text-left { text-align: left; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.rounded { border-radius: var(--radius-sm); }
.w-72 { width: 18rem; }

.p-4 { padding: 16px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }

.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-gray-300 { border-color: var(--border); }
.border-green-400 { border-color: rgba(56,189,148,.35); }
.border-red-400 { border-color: rgba(255,86,86,.35); }

.bg-white { background: var(--glass); }

.min-w-full { min-width: 100%; }

.text-green-700 { color: var(--success-text-color); }
.text-red-700 { color: var(--error-text-color); }

/* Buttons default */
.btn,
.danger-btn,
button,
input[type="submit"],
input[type="button"] {
  background: var(--grad-primary);
  color: var(--text);
  border: none;
  border-radius: var(--btn-radius);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow var(--transition-base), transform var(--transition-fast);
}

.btn:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-strong);
}

.btn:focus-visible,
button:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible {
  outline: 2px solid rgba(56,189,148,.55);
  outline-offset: 2px;
}

.btn.tiny {
  padding: var(--btn-pad-y-tiny) var(--btn-pad-x-tiny);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}


/* Ghost buttons (subtle surface; used for icon actions across pages) */
.btn-ghost {
  background: rgba(255,255,255,.04);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
}

.btn-ghost:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-strong);
}

.btn-ghost:focus-visible {
  outline: 2px solid rgba(56,189,148,.55);
  outline-offset: 2px;
}

.btn-ghost[aria-pressed="true"],
.btn-ghost.active {
  background: rgba(56,189,148,.12);
  border-color: rgba(56,189,148,.35);
}

/* Ghost danger variant (delete / destructive) */
.btn-ghost.danger {
  color: var(--error-text-color);
  border-color: rgba(255,107,107,.45);
  background: rgba(255,86,86,.08);
}

.btn-ghost.danger:hover {
  box-shadow: 0 0 0 8px rgba(255,107,107,.15);
}

/* Button variants */
.btn-solid { background: var(--grad-primary); }

.btn.danger,
.danger-btn {
  background: rgba(255,86,86,.10);
  border: 1px solid rgba(255,86,86,.45);
  color: var(--error-text-color);
}

.btn.danger:hover,
.danger-btn:hover {
  box-shadow: 0 0 0 4px rgba(255,86,86,.10);
}

/* Centered, reasonable-width buttons on auth & comment forms */
.login-form .btn,
.register-form .btn,
.forgot-form .btn,
.reset-form .btn,
.comment-form .btn,
form[action="/login"] .btn,
form[action="/register"] .btn,
form[action="/forgot-password"] .btn,
form[action="/reset-password"] .btn,
form[action^="/posts/"][action$="/comments/create"] .btn {
  display: block;
  width: min(260px, 100%);
  margin: 8px auto 0;
  align-self: center;
}



/* Global baseline for native form controls
   (ensures consistent selects/textboxes across all pages, even when utility classes are used) */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="hidden"])),
:where(textarea),
:where(select) {
  appearance: none;
  color-scheme: dark;
  min-height: var(--field-h);
  padding: var(--control-pad-y) var(--control-pad-x);
  border-radius: var(--control-radius);
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

:where(textarea) {
  min-height: 140px;
  padding: 12px;
  background: var(--control-bg-strong);
  resize: vertical;
  line-height: 1.55;
}

:where(select) {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding-right: 44px;
  background: var(--control-bg-strong);
}

:where(select option) {
  background: #0b0f14;
  color: var(--text);
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):focus),
:where(textarea:focus),
:where(select:focus) {
  border-color: var(--control-border-focus);
  box-shadow: var(--glow-strong);
}

:where(input::placeholder),
:where(textarea::placeholder) {
  color: var(--control-placeholder);
}

/* Make utility-styled controls match the theme too */
:where(input.border, textarea.border, select.border) {
  border-color: var(--control-border);
  background: var(--control-bg);
  color: var(--text);
}

:where(select.border) {
  background: var(--control-bg-strong);
}
/* =========================================================
   Standard form controls (ROOT, standardized)
   ========================================================= */

.account-input {
  width: 100%;
  height: var(--field-h);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  outline: none;
}

.account-input::placeholder {
  color: rgba(159,178,195,.85);
}

.account-input:focus {
  border-color: var(--control-border-focus);
  box-shadow: var(--glow-strong);
}

/* Textareas: standard textbox */
textarea.account-input {
  height: auto;
  min-height: 160px;
  padding: 12px;
  background: var(--control-bg-strong);
  resize: vertical;
  line-height: 1.55;
}

/* Standard select styling */
.field { position: relative; }

select.account-input {
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
  padding-right: 44px;
  cursor: pointer;
  background: var(--control-bg-strong);
}

/* Ensure dropdown menu stays dark in all browsers */
select.account-input option {
  background: #0b0f14;
  color: var(--text);
}

.select-arrow {
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  opacity: .85;
}

/* Safety net: posts grid defers to --post-min */
:where(.main-content .posts-grid) {
  display: grid;
  gap: 12px;
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(var(--post-min, 320px), 1fr));
}

:where(.main-content .posts-grid) > * {
  min-width: 0;
  max-width: 100%;
}

/* Final width guarantees */
.frame {
  width: 100% !important;
  max-width: none !important;
}

.frame > .layout {
  display: flex !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
  max-width: none !important;
  flex: 1 1 auto !important;
}

.frame > .layout > .sidebar {
  align-self: flex-start !important;
  flex: 0 0 auto !important;
  width: auto !important;
}

.frame > .layout > .main-content {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Create Post — category pills styled like sidebar chips */
.create-categories {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
}

.create-categories legend.create-label {
  font-weight: 700;
  margin-bottom: 8px;
}

.create-categories .hint {
  font-weight: 400;
  opacity: .85;
}

.create-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.create-categories label.category-option {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.create-categories label.category-option > input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.create-categories label.category-option > span {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
  font-weight: 700;
  font-size: .90rem;
  user-select: none;
  transition: box-shadow .2s ease, border-color .2s ease, background .2s ease, transform .08s ease;
}

.create-categories label.category-option:hover > span {
  transform: translateY(-1px);
  box-shadow: var(--glow-strong);
}

.create-categories label.category-option > input[type="checkbox"]:checked + span {
  background: rgba(56,189,148,.12);
  border-color: rgba(56,189,148,.35);
  box-shadow: var(--glow);
}

.create-categories label.category-option > input[type="checkbox"]:focus-visible + span {
  outline: 2px solid rgba(56,189,148,.55);
  outline-offset: 2px;
}

/* Desktop: fix header & sidebar; scroll only main-content */
@media (min-width: 1025px) {
  
  
  .frame { min-height: 100dvh; overflow: hidden; }
  
  .titlebar { position: sticky; top: 0; z-index: 100; }
  
  .layout { height: calc(100dvh - var(--header-h) - 40px); }
  
  body:not(.mobile-shell-ready) .layout > .sidebar {
    align-self: flex-start;
    height: auto;
    max-height: calc(100dvh - var(--header-h) - 40px);
    overflow: auto;
  }
  
  .main-content { height: 100%; overflow-y: auto; }
  
  .sidebar .checkbox-list.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
  }
  
  .sidebar .checkbox-list.categories .btn {
    flex: 1 1 100%;
    order: 99;
    width: 100%;
    margin-top: 8px;
    justify-content: center;
  }
}

/* Stage 1 mobile shell overlay prep (CSS only; JS toggles come later) */
.shell-backdrop {
  position: fixed;
  inset: 0;
  background: var(--mobile-backdrop);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-base), visibility var(--transition-base);
  z-index: var(--z-overlay-backdrop);

  /* Prevent tap/active/focus flash on mobile browsers (backdrop is a <button>) */
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.shell-backdrop:focus,
.shell-backdrop:focus-visible,
.shell-backdrop:active {
  outline: none;
}

@media (max-width: 1024px) {
  /* Mobile drawers: narrower panels */
  body { --mobile-panel-w: min(56vw, 256px); }
  body.mobile-nav-open .shell-backdrop,
  body.mobile-aside-open .shell-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.mobile-shell-ready .layout {
    display: block;
    min-height: auto;
  }

  body.mobile-shell-ready .layout > .sidebar {
    position: fixed;
    top: calc(var(--header-h) + var(--space-7));
    left: var(--space-3);
    bottom: var(--space-3);
    width: var(--mobile-panel-w);
    max-width: calc(100vw - (var(--space-3) * 2));
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
    box-shadow: var(--mobile-panel-shadow);
    z-index: var(--z-overlay-panel);
    transform: translateX(calc(-100% - var(--space-4)));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--transition-base), opacity var(--transition-base), visibility var(--transition-base);
  }

  body.mobile-shell-ready .layout > .sidebar::-webkit-scrollbar {
    width: 0; height: 0;
  }

  body.mobile-shell-ready.mobile-nav-open .layout > .sidebar {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Optional right panel hook (used by realtime SPA columns when wired) */
  body.mobile-shell-ready .is-offcanvas-right {
    position: fixed !important;
    top: calc(var(--header-h) + var(--space-7));
    right: var(--space-3);
    bottom: var(--space-3);
    width: var(--mobile-panel-w);
    max-width: calc(100vw - (var(--space-3) * 2));
    overflow-y: auto;
    overflow-x: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
    box-shadow: var(--mobile-panel-shadow);
    z-index: var(--z-overlay-panel);
    transform: translateX(calc(100% + var(--space-4)));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--transition-base), opacity var(--transition-base), visibility var(--transition-base);
  }

  body.mobile-shell-ready .is-offcanvas-right::-webkit-scrollbar {
    width: 0; height: 0;
  }

  body.mobile-shell-ready.mobile-aside-open .is-offcanvas-right {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

/* Mobile */
@media (max-width: 1024px) {
  body { overflow-y: auto; }

  body:not(.mobile-shell-ready) .layout { flex-direction: column; min-height: auto; }

  body:not(.mobile-shell-ready) .layout > .sidebar {
    order: -1;
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
  }

  body:not(.mobile-shell-ready) .main-content { min-height: auto; overflow-y: auto; }

  body:not(.mobile-shell-ready) .frame > .layout > .sidebar {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    align-self: stretch !important;
  }

  body:not(.mobile-shell-ready) .sidebar > .sidebar-user,
  body:not(.mobile-shell-ready) .sidebar > .sidebar-nav,
  body:not(.mobile-shell-ready) .sidebar > .admin-nav,
  body:not(.mobile-shell-ready) .sidebar > .sidebar-logout,
  body:not(.mobile-shell-ready) .sidebar > details,
  body:not(.mobile-shell-ready) .sidebar > .sidebar-section {
    width: 100%;
  }

  body:not(.mobile-shell-ready) .frame > .layout > .sidebar > * {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body:not(.mobile-shell-ready) .frame > .layout > .sidebar details > summary.sidebar-heading {
    display: block;
    width: 100%;
  }

  body:not(.mobile-shell-ready) .frame { overflow: visible; }
  body:not(.mobile-shell-ready) .layout { height: auto; }
  body:not(.mobile-shell-ready) .layout > .sidebar { height: auto; max-height: none; overflow: visible; }
  body:not(.mobile-shell-ready) .main-content { height: auto; overflow: visible; }
}

/* =========================================================
   Root reusable controls (repeatable across pages)
   ========================================================= */

/* Settings wrapper + title */
.settings-wrapper {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 18px;
}

.settings-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0 0 10px;
}

/* Standard surfaces for text containers */
.surface {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 14px;
}

.surface-strong {
  background: var(--surface-bg-strong);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 14px;
}

.surface-muted {
  background: rgba(2, 6, 23, 0.22);
  border: 1px dashed var(--surface-border-dashed);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
}



/* Labeled framed box (label top-left) */
.lbox{
  position: relative;
  margin-top: 12px;
}

.lbox__label{
  position: absolute;
  top: -10px;
  left: 14px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  background: #0b0f14;
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .2px;
}

.textbox{
  border-radius: var(--radius-sm);
  border: 1px solid var(--control-border);
  background: var(--control-bg-strong);
  color: var(--text);
  padding: 12px;
  min-height: var(--field-h);
}

.textbox.prewrap{
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.flagline{
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(148,163,184,.20);
}

.flagline:last-child{ border-bottom: none; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Pills / chip rows */
.pillrow,
.rep-meta,
.resp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pill,
.rep-k,
.modqueue-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(2,6,23,.25);
  font-size: 12px;
  color: var(--text);
  opacity: .94;
}

/* Thread + responses */
.thread {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148,163,184,.20);
}

.thread-title {
  margin: 0 0 10px;
  font-weight: 800;
  font-size: 14px;
}

.thread-empty {
  margin: 0;
  border-radius: 16px;
  background: rgba(2,6,23,.22);
  border: 1px dashed var(--surface-border-dashed);
  padding: 12px;
  color: var(--muted);
}

.resp {
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: var(--surface-bg-strong);
  padding: 12px;
  margin: 10px 0;
}

.resp-meta {
  font-size: 13px;
  opacity: 0.9;
}

.resp-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-size: 14px;
  margin-top: 6px;
}

/* Moderation queue layout */
.modqueue-wrapper {
  width: 100%;
  margin: 18px 0;
  padding: 0 18px 18px;
}

.modqueue-grid {
  display: grid;
  gap: 12px;
  width: 100%;
  grid-template-columns: 1fr;
}

.modqueue-empty {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  backdrop-filter: saturate(1.1) blur(2px);
  padding: 14px;
  color: var(--muted);
}

.modqueue-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  backdrop-filter: saturate(1.1) blur(2px);
  overflow: hidden;
}

.modqueue-card__meta {
  opacity: .9;
  font-size: .95rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.modqueue-form{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Filter row should be compact (inline) */
.modqueue-filter{
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Keep the filter select from becoming full-width */
.modqueue-filter select{
  width: 240px;
  max-width: 100%;
  height: 36px;
  padding: 6px 10px;
  box-sizing: border-box;
}

.modqueue-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}


/* Moderation queue footer layout (shared for posts + comments) */
.modqueue-card__footer{
  padding: 12px 14px;
  background: var(--surface-bg);
  border-top: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mq-row{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mq-row--actions{
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.mq-flaggrid{
  display: flex;
  align-items: center;
  gap: 10px;
}

.mq-flagform--inline{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
  row-gap: 6px; /* small separation between selector row and note */
}

.mq-flag-note{
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  margin-top: 2px; /* breaks the "touching" look even if borders are tight */
}

.mq-row--unflag{
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.flagline--row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.flagtext{
  flex:1;
  min-width:0;
}

/* Title bar actions (notifications icon) */
.titlebar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.titlebar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* User menu dropdown (titlebar) */
.titlebar__actions .user-menu {
  position: relative;
}

.titlebar__actions .user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;

  /* Fit to content with a small offset; cap for small screens */
  width: max-content;
  max-width: 92vw;

  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(12, 18, 26, .95);
  box-shadow: 0 18px 40px rgba(0,0,0,.55);

  /* High z-index so the menu overlays the right sidebar + columns */
  z-index: 12000;
}

.titlebar__actions.open .user-dropdown {
  display: block;
}

/* User menu: tree/explorer (root list only) */
.user-tree__cols {
  display: flex;
}

/* Layout: content stays right-anchored by popup (right:0). Items remain left-text. */
.user-tree__col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px; /* small vertical gap between nodes */
}

.user-tree__col--root {
  width: max-content;        /* fit to content */
  padding-right: 0;
}

.user-tree__item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;

  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 800;
  color: var(--text);

  text-align: left;          /* ensure text remains left */
  background: rgba(255,255,255,.04);
  white-space: nowrap;
}

.user-tree__item.has-children {
  cursor: pointer;
  user-select: none;
}

.user-tree__item.active,
.user-tree__item.has-children:hover {
  background: rgba(255,255,255,.08);
  box-shadow: var(--glow);
}

.user-tree__chev {
  opacity: .9;
  font-weight: 900;
  width: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-tree__label {
  flex: 1;
  min-width: 0;
}

.user-tree__sep {
  height: 1px;
  margin: 4px 0; /* tighter to match small-gap layout */
  background: rgba(255,255,255,.10);
}

/* Separate flyout overlay (sub-nodes) */
.user-flyout {
  display: none;
  position: absolute;

  /* Touch the LEFT edge of the main dropdown (no gap) */
  top: 0;
  right: 100%;
  left: auto;

  width: max-content;
  max-width: 92vw;

  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(12, 18, 26, .95);
  box-shadow: 0 18px 40px rgba(0,0,0,.55);

  z-index: 12001;
}

.user-flyout.open {
  display: block;
}


.user-flyout__lvl2-wrap {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(-100%);
  pointer-events: none; /* only the nested flyout should capture mouse */
}
.user-flyout--lvl2 {
  top: 0;
  right: 100%;
  left: auto;
  pointer-events: auto;
}
.user-flyout--lvl2.open {
  display: block;
}

/* Third-level flyout (nested under a flyout item). */
.user-flyout.user-flyout--lvl2 {
  top: 0;
  right: 100%;
  margin-right: 0;
  z-index: 12002;
  width: max-content;
  max-width: 92vw;
}

.user-flyout__pane {
  display: none;
}

.user-flyout__pane.active {
  display: block;
}

.user-flyout__link {
  display: block;
  padding: 8px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  margin-top: 6px; /* small vertical gap */
  white-space: nowrap;
}

.user-flyout__pane .user-flyout__link:first-child {
  margin-top: 0;
}

.user-flyout__link:hover {
  background: rgba(255,255,255,.06);
  box-shadow: var(--glow);
}

/* Logout in tree */
.user-tree__logout {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: var(--text);

  font-weight: 800;
  cursor: pointer;
}

.user-tree__logout:hover {
  background: rgba(255,255,255,.08);
  box-shadow: var(--glow);
}

.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  text-decoration: none;
}

/* Topbar icon visibility: keep button size, enlarge SVG glyphs */
.rt-topbar .icon-button svg {
  width: 28px !important;
  height: 28px !important;
  display: block;
}

.badge--corner {
  position: absolute;
  top: -6px;
  right: -6px;
}


.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  text-decoration: none;
}

.badge--corner {
  position: absolute;
  top: -6px;
  right: -6px;
}

/* === Added: global template coverage (admin/modqueue, sr-only, id fallbacks) === */
/* Accessible “screen-reader only” label (used in moderation filters) */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Admin section wrapper/header used by moderation + other admin pages */
.admin-wrap {
  width: 100%;
  margin: 18px 0;
  padding: 0 18px 18px;
}

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px 0;
}

.admin-title {
  margin: 0;
  padding: 12px 14px;
  background: var(--grad-primary);
  color: var(--title-color);
  border-radius: 14px;
  font-weight: 800;
  line-height: 1.2;
}

/* Moderation queue fallbacks (needed for post-edits view, which may not load moderation_posts.css) */
.modqueue-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 900px) {
  .modqueue-list { grid-template-columns: 1fr; }
}

.modqueue-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  backdrop-filter: saturate(1.1) blur(2px);
  overflow: hidden;
}

.modqueue-card__head {
  background: var(--grad-primary);
  padding: 12px 14px 10px;
}

.modqueue-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .95rem;
  opacity: .92;
}

.modqueue-time { white-space: nowrap; }

.modqueue-card__body {
  padding: 14px;
  background: var(--surface-bg);
  border-top: 1px solid var(--surface-border);
  line-height: 1.65;
  overflow-wrap: break-word;
}

.modqueue-card__footer {
  padding: 12px 14px;
  background: var(--surface-bg);
  border-top: 1px solid var(--surface-border);
}

.modqueue-card__flags {
  padding: 0 14px 14px;
  background: var(--surface-bg);
}

/* Inline flag/reject forms */
.mq-flagform--inline { margin: 0; }
.mq-flaggrid {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Dynamic ids used by moderation flag forms */
form[id^="mq-flag-post-"],
form[id^="mq-flag-comment-"] {
  scroll-margin-top: 96px;
}

/* ID fallbacks for templates that rely on id-only inputs (edit pages, some admin forms) */
#title,
#body,
#comment-body,
#response,
#details,
#reason,
#flag,
#status,
#reason_category,
#new_password,
#password_confirm,
#identifier,
#password,
#email,
#username,
#current,
#new,
#confirm,
#cat-name,
#images {
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

#title:focus,
#body:focus,
#comment-body:focus,
#response:focus,
#details:focus,
#reason:focus,
#flag:focus,
#status:focus,
#reason_category:focus,
#new_password:focus,
#password_confirm:focus,
#identifier:focus,
#password:focus,
#email:focus,
#username:focus,
#current:focus,
#new:focus,
#confirm:focus,
#cat-name:focus,
#images:focus {
  border-color: rgba(56,189,148,.45);
  box-shadow: var(--glow);
}

#body,
#comment-body,
#details,
#response {
  min-height: 140px;
  resize: vertical;
}

/* Comment anchor helper */
#comments {
  scroll-margin-top: 96px;
}

/* === Added: missing hooks (modqueue-author, mq-flagform, modqueue-filter-select) === */
/* Minor hooks referenced by templates */
.modqueue-author {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: baseline;
}

.mq-flagform { margin: 0; }

/* Moderation filter select is identified by id in template */
#modqueue-filter-select {
  min-width: 240px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 700;
  font-size: .85rem;
  line-height: 1;
}

.badge--corner {
  position: absolute;
  top: -6px;
  right: -6px;
}


@media (prefers-reduced-motion: reduce) {
  .shell-backdrop,
  body.mobile-shell-ready .layout > .sidebar,
  body.mobile-shell-ready .is-offcanvas-right,
  .btn, button, input[type="submit"], input[type="button"] {
    transition: none !important;
  }
}


@media (max-width: 1024px) {
  /* Keep nested user flyouts inside viewport on mobile (avoid off-screen 3rd layer) */
  .user-flyout {
    max-width: min(92vw, 360px);
  }

  .user-flyout__lvl2-wrap {
    position: static;
    transform: none;
    pointer-events: auto;
    margin-top: 6px;
  }

  .user-flyout--lvl2,
  .user-flyout.user-flyout--lvl2 {
    position: static;
    top: auto;
    right: auto;
    left: auto;
    margin: 6px 0 0;
    width: 100%;
    max-width: 100%;
    z-index: auto;
    box-shadow: 0 10px 24px rgba(0,0,0,.35);
  }

  .user-flyout__link {
    white-space: normal;
    word-break: break-word;
  }
}
