/* ========================================================================
   Gigglegrid Next — Main Stylesheet
   ========================================================================
   Section order:
   1. Fonts         — @font-face declarations
   2. Design tokens — :root custom properties
   3. Reset         — Box-sizing, margin/padding normalization
   4. Base elements — html, body, a, hr, img, headings, view transitions
   5. Layout        — Site structure, hero, footer
   6. Components    — Board, Thread, Post, Files, Catalog, Form,
                      Pagination, Badge, Manage, Tooltip
   7. Pages         — Auth (cp-*), error pages
   8. Utilities     — sr-only, text-muted, small helpers
   9. Media queries — Responsive overrides, reduced motion
   ======================================================================== */


/* ========================================================================
   1. FONTS
   ========================================================================
   Inter variable font, self-hosted with unicode-range subsetting.
   The browser only downloads the woff2 slice(s) needed for page content.
   Shared axes: weight 400–700, normal style, swap display.
   ======================================================================== */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-greek-ext.woff2") format("woff2");
  unicode-range: U+1F00-1FFF;
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/inter-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0,
    U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* Metrics-matched fallback — prevents CLS by matching Inter's metrics to a local system font */
@font-face {
  font-family: "Inter-fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* Nexa Heavy — display/heading font */
@font-face {
  font-family: "Nexa Heavy";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/assets/fonts/nexaheavy.ttf") format("truetype");
}


/* ========================================================================
   2. DESIGN TOKENS
   ======================================================================== */

:root {
  /* Surface colors */
  --background-top: #171717;
  --background-rest: #171717;
  --navbar-color: #171717;
  --post-color: #1e1e1e;
  --post-outline-color: #212121;
  --highlighted-post-color: #303030;
  --highlighted-post-outline-color: #333333;
  --floating-menu-color: #242424;
  --floating-menu-outline-color: #323232;
  --alt-label-color: #252525;
  --label-color: #252525;
  --hr: #252525;

  /* Text colors */
  --font-color: #d1d1d1;
  --alt-font-color: #a1a1a1;
  --name-color: #c5c8c6;
  --subject-color: #f1f1f1;
  --board-title: #e8e8e8;
  --title-color: #e8e8e8;
  --logo-image: url("/assets/icons/home-logo.png");
  --header-logo-height: 44px;
  --header-logo-width: min(60vw, 200px);
  --header-logo-height-mobile: 36px;
  --header-logo-width-mobile: min(62vw, 170px);

  /* Links */
  --link-color: #e8e8e8;
  --link-hover-color: #a4a4a4;
  --post-link-color: #e8e8e8;
  --link-hover: underline;

  /* Accent & interactive */
  --accent-color: #ebebeb;
  --input-borders: #232323;
  --input-color: #d1d1d1;
  --input-background: #141414;
  --drop-color: rgba(125, 125, 125, 0.4);
  --drop-text: rgba(125, 125, 125, 0.6);

  /* Semantic status */
  --color-warning: #f5a623;
  --color-error: #ff6f6f;
  --color-info: #00c8ff;
  --color-success: #00d68f;

  /* Focus ring */
  --focus-ring: 0 0 0 1px var(--accent-color);

  /* Line-level markup */
  --greentext-color: #789922;
  --orangetext-color: orange;
  --pinktext-color: #FF69B4;
  --redtext-color: #AF0A0F;

  /* Typography */
  --font-family: arial, helvetica, sans-serif;
  --font-family-display: sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.85rem;
  --text-base: 0.9rem;
  --text-lg: 1.15rem;
  --text-xl: 1.2rem;
  --text-3xl: 1.85rem;
  --text-4xl: 2.2rem;

  /* Shadows */
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
}


/* ========================================================================
   3. RESET
   ======================================================================== */

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


/* ========================================================================
   4. BASE ELEMENTS
   ======================================================================== */

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  line-height: 1.1;
  background: var(--background-rest);
  color: var(--font-color);
  font-family: var(--font-family);
}

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

a:hover {
  color: var(--link-hover-color);
  text-decoration: var(--link-hover);
}

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

img {
  max-width: 100%;
}

/* View transitions — cross-document navigation morphs (Chrome 126+, progressive) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

::view-transition-image-pair(root) {
  isolation: auto;
  mix-blend-mode: normal;
}

::view-transition-group(root) {
  background: var(--background-rest);
}

/* Focus styles — visible ring on keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.form-input:focus-visible,
.form-textarea:focus-visible,
.cp-input:focus-visible,
.cp-field-input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}


/* ========================================================================
   5. LAYOUT
   ======================================================================== */

main {
  padding: 0.75rem 0.75rem 0 0.75rem;
}

#app-content {
  transition: opacity 0.14s ease, transform 0.14s ease;
}

body.instant-nav-loading #app-content {
  opacity: 0.97;
  transform: translateY(1px);
}

.instant-nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  width: 100%;
  height: 2px;
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
  background: var(--accent-color);
  transition: transform 0.25s ease, opacity 0.2s ease;
  pointer-events: none;
}

.instant-nav-progress.is-active {
  opacity: 1;
  transform: scaleX(0.72);
}

.site-header {
  background: var(--navbar-color);
  border-bottom: 1px solid var(--post-outline-color);
}

.site-header-inner {
  width: 100%;
  margin: 0;
  padding: 0.3rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
}

.site-header-logo-link {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  text-decoration: none;
}

.site-header-logo {
  display: block;
  height: var(--header-logo-height);
  width: var(--header-logo-width);
  background-image: var(--logo-image);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: left center;
}

.site-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.site-header-staff-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.65rem;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--post-outline-color);
  background: var(--post-color);
  color: var(--alt-font-color);
  font-size: 0.68rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.site-header-staff-btn .bxf {
  font-size: 0.78rem;
}

.site-header-staff-btn:hover {
  color: var(--font-color);
  border-color: var(--font-color);
  background: var(--alt-label-color);
}

main h1:not([class]),
main h2:not([class]),
main h3:not([class]),
main h4:not([class]),
main h5:not([class]),
main h6:not([class]) {
  margin-bottom: 0.5rem;
}

main p:not([class]) {
  margin-bottom: 0.75rem;
}

main section:not([class]) + section:not([class]) {
  margin-top: 1rem;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16rem;
}

.hero-content {
  text-align: center;
}

.site-title {
  font-family: var(--font-family-display);
  font-size: var(--text-4xl);
  font-weight: 300;
  color: var(--title-color);
}

.site-subtitle {
  padding: 1rem 0;
  color: var(--alt-font-color);
}

.home-page {
  max-width: 72rem;
  margin: 0 auto;
  padding-bottom: 1rem;
}

.home-hero {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 0 0.75rem;
}

.home-hero.has-featured {
  justify-content: space-between;
}

.site-logo {
  flex: 0 0 auto;
  display: block;
  height: 140px;
  width: min(92vw, 400px);
  max-width: 100%;
  background-image: var(--logo-image);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

.home-featured-post {
  flex: 1 1 auto;
  min-width: 0;
}

.home-featured-post .post.reply {
  margin-left: 0;
  width: 100%;
}

#popular-threads {
  margin: 0 auto;
  padding: 0.5rem 0.5rem 0;
}

.home-popular-empty {
  text-align: center;
  color: var(--alt-font-color);
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  padding: 1rem;
}

.home-popular-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.home-popular-card {
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  padding: 0.45rem;
}

.home-popular-board-name {
  margin-bottom: 0.3rem;
  font-size: var(--text-sm);
  font-weight: 700;
}

.home-popular-thumb-link {
  display: block;
}

.home-popular-thumb {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-height: 9.5rem;
  object-fit: cover;
}

.home-popular-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 7.75rem;
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  background: var(--post-outline-color);
}

.home-popular-teaser {
  display: block;
  margin-top: 0.45rem;
  font-size: var(--text-xs);
  color: var(--font-color);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.home-popular-teaser b {
  font-weight: 700;
}

.site-footer {
  padding: 0.75rem;
  padding-bottom: 1.15rem;
  color: var(--alt-font-color);
  font-size: var(--text-xs);
  text-align: center;
}


/* ========================================================================
   6. COMPONENTS
   ======================================================================== */


/* 6a. Board
   ------------------------------------------------------------------------ */

.board-header {
  text-align: center;
}

.board-banner {
  margin: 0 auto;
  border: 1px solid var(--hr);
}

.board-banner-fallback {
  margin: 0 auto;
}

.board-title {
  font-family: var(--font-family-display);
  font-size: var(--text-4xl);
  font-weight: 300;
  color: var(--board-title);
}

.board-subtitle {
  color: var(--alt-font-color);
}

.board-header-divider {
  width: 90%;
}


/* 6b. Thread
   ------------------------------------------------------------------------ */

.thread-divider {
  border: none;
  border-top: 1px solid var(--hr);
  min-width: 99%;
}

.nav-divider {
  border: none;
  border-top: 1px solid var(--hr);
  min-width: 99%;
  margin: 0;
}

.thread-nav {
  margin: 8px 0;
}

.thread-nav:last-of-type {
  margin: 8px 0 0 0;
}

.catalog-nav {
  margin: 8px 0;
}

.catalog-nav:last-of-type {
  margin: 8px 0 0 0;
}

.thread-links,
.catalog-links {
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
  padding: 8px;
  margin: 5px 0;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
}

.thread-links > a + a,
.catalog-links > a + a {
  margin-left: 0.5rem;
}

.thread-stats {
  margin-left: auto;
  white-space: nowrap;
  color: var(--alt-font-color);
  font-size: var(--text-sm);
}

.thread-update {
  margin-left: auto;
  white-space: nowrap;
  font-size: var(--text-sm);
}

.thread-update .update-btn {
  cursor: pointer;
}

.thread-update .auto-label {
  cursor: pointer;
}

.thread-update .auto-label input[type="checkbox"] {
  vertical-align: middle;
}

.thread-update .update-status {
  color: var(--alt-font-color);
}

/* Live (WebSocket) mode: hide the manual controls and surface only the
   connection status ("Connecting..." / "Live (Xms)"). */
.thread-update.live-active .thread-update-controls {
  display: none;
}

.thread-update.live-active .update-status {
  color: var(--font-color);
}

.blotter {
  color: red;
  font-weight: bold;
  text-align: center;
}

/* News blotter — recent news entries below post form */
.news-blotter {
  max-width: 28rem;
  margin: 0 auto;
  font-size: var(--text-sm);
  color: var(--alt-font-color);
}

.news-blotter-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.news-blotter-date {
  color: var(--alt-font-color);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.news-blotter-sep {
  color: var(--alt-font-color);
  font-size: var(--text-xs);
}

.news-blotter-text {
  color: var(--font-color);
}

.news-blotter-empty {
  color: var(--alt-font-color);
  font-style: italic;
}

.news-blotter-footer {
  text-align: right;
  font-size: var(--text-xs);
}

.news-blotter-footer a {
  color: var(--link-color);
  text-decoration: none;
}

.news-blotter-footer a:hover {
  color: var(--link-hover-color);
  text-decoration: var(--link-hover);
}


/* 6c. Post
   ------------------------------------------------------------------------ */

.post.op {
  max-width: 100%;
}

.post.reply {
  display: inline-block;
  vertical-align: top;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  padding: 0.25rem 0.4rem;
  max-width: 100%;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.post.reply:target {
  background: var(--highlighted-post-color);
  border-color: var(--highlighted-post-outline-color);
}

/* When JS is loaded, the 2 s flash from .post-highlighted is the sole
   highlight mechanism.  Neutralize :target so it doesn't persist after
   the flash fades.  No-JS keeps :target as a permanent fallback.
   Reset to normal post colors — inherit would pick up the page/thread
   container background which is a different color. */
:root.js .post.reply:target {
  background: var(--post-color);
  border-color: var(--post-outline-color);
}

:root.js .post.reply.post-highlighted {
  background: var(--highlighted-post-color);
  border-color: var(--highlighted-post-outline-color);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Hover preview: subtle background highlight for on-page posts */
:root.js .post.reply.hover-highlighted {
  background: var(--highlighted-post-color);
  border-color: var(--highlighted-post-outline-color);
}

/* Hover preview popover — positioned container; the inner .post.reply
   already carries background, border, padding, and font-size. */
#post-hover {
  display: none;
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-height: 80vh;
  overflow: hidden;
}

/* OP posts have no background/border normally (they flow inline with the
   page), but inside the hover popover they need a visible container. */
#post-hover .post.op {
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  padding: 0.25rem 0.4rem;
}

.post-info {
  font-size: var(--text-sm);
}

/* Timestamp FOUC prevention: hide server-rendered UTC text until render.js
   processes the element and adds data-processed.  visibility:hidden preserves
   layout space so there's no shift — just a brief invisible gap. */
:root.js time[datetime] {
  visibility: hidden;
}
:root.js time[datetime][data-processed] {
  visibility: visible;
}

.post-subject {
  font-weight: 600;
  color: var(--subject-color);
}

.post-name {
  font-weight: 600;
  color: var(--name-color);
}

.post-trip {
  color: var(--alt-font-color);
}

.you-marker {
  color: var(--alt-font-color);
}

/* Country/region flag icons — 11px matches the sprite row height */
.flag {
  height: 11px;
  width: auto;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
}

.post-links a {
  color: var(--font-color);
}

.post-icon .bxf {
  vertical-align: text-bottom;
}

.post-message {
  font-size: var(--text-base);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 0.5rem 1rem 0.5rem 0;
  overflow: hidden;
}

.post:not(:has(.post-files)) .post-message,
.post:has(.post-files.multi-file) .post-message {
  padding: 0.5rem 1rem;
}

.public-ban {
  color: var(--ban-message-color, #f00);
  font-weight: bold;
  font-size: var(--text-base);
  padding: 0.25rem 1rem;
}

.dead-link {
  text-decoration: line-through;
}

.quote-link {
  color: var(--post-link-color);
  text-decoration: underline;
}

.greentext  { color: var(--greentext-color); }
.orangetext { color: var(--orangetext-color); }
.pinktext   { color: var(--pinktext-color); }
.redtext    { color: var(--redtext-color); font-size: 11pt; font-weight: bold; }

.backlinks {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--alt-font-color);
}

.backlinks a {
  text-decoration: underline;
}

.backlinks.clear {
  clear: left;
}

.omitted-notice {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  display: flex;
  align-items: center;
  gap: 0.35em;
  flex-wrap: wrap;
}

.expand-thread {
  cursor: pointer;
  vertical-align: middle;
  font-size: 1em;
  user-select: none;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
}

.expand-thread.spin {
  animation: expand-spin 0.8s linear infinite;
}

@keyframes expand-spin {
  to { transform: rotate(360deg); }
}

.body-truncated-notice {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  margin-top: 0.25rem;
}

.replies > * + * {
  margin-top: 4px;
}

.post.reply {
  min-width: 18rem;
}

.post-mod-meta {
  padding: 5px;
  font-size: var(--text-xs);
  color: var(--alt-font-color);
}

.post-mod-meta .mod-meta-line {
  display: block;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-mod-meta .mod-meta-line strong {
  font-weight: 600;
}


/* 6d-1. Post Menu (⋮ dropdown)
   ------------------------------------------------------------------------ */

/* The post article needs relative positioning so the menu can anchor to it. */
.post {
  position: relative;
}

.post-menu {
  display: inline;
  position: relative;
}

.post-menu-btn {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
  margin: 4px -5px 0px 4px !important;
  float: left;
  font-weight: bold;
  opacity: 1 !important;
  height: 0.5em !important;
  font-size: 16px;
  display: inline-block;
  width: 1em;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--alt-font-color);
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  text-align: center;
  text-decoration: none;
}

/* Dropdown list */
.post-menu-list {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  list-style: none;
  min-width: 140px;
  background: var(--floating-menu-color);
  border: 1px solid var(--floating-menu-outline-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 30;
}

.post-menu-list.post-menu-list-mirror {
  right: auto;
  left: 0;
}

.post-menu.is-open .post-menu-list {
  display: block;
}

/* Each menu item — button or anchor styled the same. */
.post-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--font-color);
  font-size: var(--text-sm);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}

.post-menu-item:hover {
  background: var(--label-color);
  text-decoration: none;
}

.post-menu-item .bxf {
  font-size: 0.9rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

/* Delete item gets a danger color on hover. */
.post-menu-delete:hover {
  color: var(--color-error);
}

/* Post visually fading out after in-place deletion. */
.post-deleted {
  opacity: 0.4;
  text-decoration: line-through;
  transition: opacity 0.5s ease;
}


/* 6d. Post Files
   ------------------------------------------------------------------------ */

/* Float is intentional — post message text wraps around thumbnails */
.post-files {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  float: left;
  margin-right: 1rem;
}

.post.op .post-files {
  margin-bottom: 7px;
}

.post.reply .post-files,
.post .post-files.multi-file {
  margin-top: 0.25rem;
}

/* Multi-file: images in a row, body flows below (no float wrapping) */
.post-files.multi-file {
  flex-direction: row;
  flex-wrap: wrap;
  float: none;
  margin-bottom: 0 !important;
}

/* OP multi-file: reorder so post-info appears above images */
.post.op:has(.post-files.multi-file) {
  display: flex;
  flex-direction: column;
}

.post.op:has(.post-files.multi-file) .post-info {
  order: -2;
}

.post.op:has(.post-files.multi-file) .post-mod-meta {
  order: -1;
}

.post-file {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* Block display on media wrappers kills inline baseline gaps so
   .post-file gap is the single source of truth for spacing. */
.post-file > a,
.post-file > .video-player {
  display: block;
  line-height: 0;
}

/* ---- Spoiler blur ---- */
/* Spoilered thumbnails/videos get a heavy blur + overflow clip so edges
   don't leak outside the bounding box. Click-to-reveal is handled in JS.
   Darkness is baked into brightness() so removing .spoilered transitions
   smoothly via the base transition rule below. */
.spoilered {
  position: relative;
  overflow: hidden;
  display: inline-block;
  cursor: pointer;
}

/* Base transition on media so it persists AFTER .spoilered is removed,
   giving a smooth unblur on reveal.  clip-path keeps corners sharp while
   blur fades — without it the blur bleeds past the element box once the
   parent's overflow:hidden disappears with the .spoilered class. */
.post-file img,
.video-player > video {
  transition: filter 0.35s ease, transform 0.35s ease;
  clip-path: inset(0);
}

.spoilered img,
.spoilered video {
  filter: blur(15px) brightness(0.45);
  transform: scale(1.1);
}

.spoilered:hover img,
.spoilered:hover video {
  filter: blur(15px) brightness(0.6);
}

/* Hide all injected overlays while the player is spoilered. */
.video-player.spoilered .video-controls,
.video-player.spoilered .video-idle-time,
.video-player.spoilered .video-big-play {
  display: none;
}

.file-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  background: var(--post-outline-color);
  color: var(--alt-font-color);
  font-size: var(--text-xs);
  font-weight: 600;
}

.file-info {
  display: flex;
  align-items: baseline;
  font-size: var(--text-xs);
  line-height: 1.1;
  white-space: nowrap;
}

.file-info a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* --- Inline video player --- */

:root.js .video-player-fallback { display: none; }

.video-player {
  position: relative;
  cursor: pointer;
}

.video-player video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Controls container — gradient overlay at bottom */
.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 6px 5px;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 2;
}

.video-player:hover .video-controls,
.video-player.video-controls-visible .video-controls { opacity: 1; pointer-events: auto; }

/* --- Scrub / progress bar --- */
.video-scrub {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height 150ms ease;
}

.video-scrub:hover { height: 6px; }

.video-scrub-fill {
  height: 100%;
  background: #fff;
  border-radius: inherit;
  pointer-events: none;
  width: 0;
}

/* --- Controls row (buttons + volume) --- */
.video-controls-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 26px;
}

/* Shared button base */
.video-btn {
  background: none;
  border: none;
  padding: 2px;
  margin: 0;
  cursor: pointer;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  opacity: 0.85;
  transition: opacity 150ms ease;
  flex-shrink: 0;
}

.video-btn:hover { opacity: 1; }

/* Volume group: icon + vertical popup slider (pushed right by flex auto-margin) */
.video-volume-group {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}

/* Vertical popup appears above mute button on hover */
.video-volume-popup {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  padding: 8px 0;
  background: rgba(0,0,0,0.75);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.video-volume-group:hover .video-volume-popup { opacity: 1; pointer-events: auto; }

.video-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  writing-mode: vertical-lr;
  direction: rtl;            /* high values at top */
  width: 4px;
  height: 52px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.video-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.video-volume-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}

/* Fullscreen button pushed to right when no volume group */
.video-btn-fullscreen {
  margin-left: auto;
}

.video-volume-group ~ .video-btn-fullscreen {
  margin-left: 0;
}

/* --- Idle time badge (when controls hidden) --- */
.video-idle-time {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.55);
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 1;
  line-height: 1;
}

.video-player:hover .video-idle-time,
.video-player.video-controls-visible .video-idle-time { opacity: 0; }

/* --- Big center play overlay (paused state) --- */
.video-big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 1;
}

.video-player.video-paused .video-big-play { opacity: 0.8; }
.video-player.video-paused:hover .video-big-play { opacity: 1; }


/* 6e. Catalog
   ------------------------------------------------------------------------ */

.catalog-threads {
  text-align: center;
}

.catalog-cell {
  vertical-align: top;
  display: inline-block;
  word-wrap: break-word;
  overflow: hidden;
  margin-top: 0.25rem;
  margin-bottom: 1.25rem;
  padding: 0.25rem 0 0.125rem 0;
  position: relative;
  width: 11.25rem;
  max-height: 20rem;
}

.catalog-no-file {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: 6.25rem;
  height: 6.25rem;
  background: var(--post-outline-color);
  color: var(--alt-font-color);
  font-size: var(--text-xs);
  font-weight: 600;
}

.catalog-meta {
  font-size: var(--text-xs);
  line-height: 1.1;
  color: var(--alt-font-color);
}

.catalog-meta b {
  color: var(--font-color);
}

.catalog-icons {
  margin-top: 0.125rem;
  font-size: var(--text-xs);
}

.catalog-teaser {
  padding: 0 0.9375rem;
  font-size: var(--text-xs);
  color: var(--font-color);
  overflow: hidden;
  word-wrap: break-word;
}

.catalog-teaser b {
  font-weight: 700;
}

.catalog-teaser s {
  background-color: #000;
  color: #000;
  text-decoration: none;
}

.catalog-teaser s:focus,
.catalog-teaser s:hover {
  color: #fff;
}

.catalog-cell a {
  border: none;
  text-decoration: none;
  color: inherit;
}

.catalog-cell a:hover {
  text-decoration: none;
}


/* 6f. Form
   ------------------------------------------------------------------------ */

.post-form {
  margin: 0 auto;
  width: 100%;
  max-width: 28rem;
  transition: opacity 180ms ease;
}

.post-form.is-quick-hidden {
  opacity: 0;
  pointer-events: none;
}

.form-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.form-row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  align-items: center;
  gap: 2px;
}

.form-row-top {
  align-items: start;
}

.form-row-inline {
  display: flex;
  align-items: center;
  gap: 2px;
}

.form-row-inline-wide {
  gap: 0.75rem;
}

.form-label {
  display: flex;
  align-self: stretch;
  align-items: center;
  padding: 0.25rem 0.5rem;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--post-outline-color);
  border: 1px solid var(--input-borders);
}

.form-label-top {
  padding-top: 0.5rem;
  align-items: start;
}

.form-input {
  width: 100%;
  padding: 0.25rem 0.5rem;
  font-size: var(--text-sm);
  border: 1px solid var(--input-borders);
  border-radius: 0;
  background: var(--input-background);
  color: var(--input-color);
}

.form-textarea {
  min-height: 7rem;
  resize: vertical;
}

.form-textarea-short {
  min-height: 6rem;
}

.form-input::placeholder {
  color: transparent;
}

.form-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--accent-color);
  color: var(--background-rest);
  border: none;
  border-radius: 0;
  cursor: pointer;
}

.form-submit:hover {
  opacity: 0.9;
}

.form-submit[disabled],
.form-submit[aria-disabled="true"] {
  opacity: 0.65;
  cursor: not-allowed;
}

.form-submit-full {
  display: inline-flex;
  width: 100%;
}

.form-submit-mobile {
  display: none;
}

.form-checkbox-label {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: var(--text-xs);
}

.form-checkbox {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0;
  accent-color: var(--accent-color);
}

.form-inline-error {
  margin-left: 8rem;
  margin-top: 0.125rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--color-error) 45%, var(--post-outline-color));
  background: color-mix(in srgb, var(--color-error) 14%, var(--post-color));
  color: var(--color-error);
  font-size: var(--text-xs);
  line-height: 1.3;
}

.form-inline-error[hidden] {
  display: none;
}

.form-inline-error-quick {
  margin: 0;
}


/* 6f-ii. File zone — multi-file dropzone with per-file spoiler
   ------------------------------------------------------------------------ */

/* Container. Inline <script> in <head> adds .js to <html>.  CSS uses
   :root.js to hide the native file input and show the dropzone from the
   first paint with zero delay — no class toggle needed. */
.file-zone {
  display: flex;
  flex-direction: column;
  margin: 2px;
}

/* With JS: native input is visually hidden by CSS (not display:none — that
   breaks required validation).  Without JS: native input stays visible. */
:root.js .file-zone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  padding: 0;
}

:root:not(.js) .file-zone-drop,
:root:not(.js) .file-zone-list { display: none; }

/* Dropzone target — click or drag-and-drop. */
.file-zone-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem;
  border: 3px dashed var(--drop-color);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-zone-drop.is-dragover {
  border-color: var(--accent-color);
  background: color-mix(in srgb, var(--accent-color) 8%, transparent);
}

.file-zone-prompt {
  font-size: var(--text-sm);
  color: var(--drop-text);
  pointer-events: none;
  user-select: none;
}

/* File list grid — one card per selected file. */
.file-zone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* Individual file card. */
.file-zone-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 5.5rem;
  padding: 0.25rem;
  border: 1px solid var(--post-outline-color);
  background: var(--post-color);
  overflow: hidden;
}

/* Thumbnail / icon area. */
.file-zone-thumb {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  background: var(--background-rest);
}

.file-zone-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  font-size: var(--text-xs);
  color: var(--muted-text-color);
  text-transform: uppercase;
  word-break: break-all;
  text-align: center;
}

/* File name — single truncated line. */
.file-zone-name {
  width: 100%;
  margin-top: 0.125rem;
  font-size: 0.625rem;
  line-height: 1.2;
  color: var(--text-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.file-zone-meta {
  display: flex;
  width: 100%;
  margin-top: 0.125rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.125rem;
}

.file-zone-size {
  font-size: 0.625rem;
  color: var(--muted-text-color);
}

.file-zone-status {
  font-size: 0.5625rem;
  line-height: 1.2;
  padding: 0 0.1875rem;
  border: 1px solid var(--post-outline-color);
  text-transform: uppercase;
}

.file-zone-status.is-ready {
  color: var(--alt-font-color);
}

.file-zone-status.is-staging {
  color: var(--accent-color);
}

.file-zone-status.is-failed {
  color: var(--danger-color, #d33);
}

.file-zone-error {
  width: 100%;
  margin-top: 0.125rem;
  font-size: 0.5625rem;
  line-height: 1.2;
  color: var(--danger-color, #d33);
}

.file-zone-card.file-zone-card-is-failed {
  border-color: var(--danger-color, #d33);
}

/* Controls row: spoiler checkbox + remove button. */
.file-zone-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.125rem;
  gap: 0.125rem;
}

.file-zone-spoiler-label {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  font-size: 0.625rem;
  color: var(--muted-text-color);
  cursor: pointer;
  user-select: none;
}

.file-zone-spoiler-cb {
  width: 0.625rem;
  height: 0.625rem;
  accent-color: var(--accent-color);
}

.file-zone-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--muted-text-color);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}

.file-zone-remove:hover {
  color: var(--danger-color, #d33);
}

/* Live-draft attachment lock: once a file is attached while live-draft
   posting is active the file cannot be removed from the current form. */
.file-zone.gg-draft-locked .file-zone-remove {
  display: none !important;
}

/* Live-draft placeholder post — a reply being written in real time. */
.post-draft {
  opacity: 0.85;
  border-left: 2px solid var(--accent-color, #789);
}

.post-draft-badge {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--muted-text-color);
}

.post-draft-image {
  margin-left: 0.35rem;
}

.file-zone-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  border: 1px solid var(--input-borders);
  background: var(--label-color);
  color: var(--font-color);
  font-size: 0.5625rem;
  line-height: 1.1;
  cursor: pointer;
}

.file-zone-retry:hover {
  background: var(--highlighted-post-color);
}

/* 6f-iii. Quick reply
   ------------------------------------------------------------------------ */

.quick-reply {
  position: fixed;
  right: 1rem;
  top: 1rem;
  width: min(26rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 34rem);
  display: none;
  flex-direction: column;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  box-shadow: var(--shadow-xl);
  z-index: 1200;
}

.quick-reply.is-open {
  display: flex;
}

.quick-reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  background: var(--floating-menu-color);
  border-bottom: 1px solid var(--post-outline-color);
}

.quick-reply-title {
  font-size: var(--text-xs);
  font-weight: 700;
}

.quick-reply-close {
  border: 1px solid var(--input-borders);
  background: var(--label-color);
  color: var(--font-color);
  padding: 0.125rem 0.5rem;
  font-size: var(--text-xs);
  line-height: 1;
  cursor: pointer;
}

.quick-reply-close:hover {
  background: var(--highlighted-post-color);
}

.quick-reply-body {
  padding: 0.5rem;
  overflow: auto;
}

.post-form-quick {
  max-width: none;
}

.quick-reply-fields {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.quick-reply .form-input {
  border-color: var(--input-borders);
  background: var(--input-background);
  color: var(--input-color);
}

.quick-reply .form-input::placeholder {
  color: var(--alt-font-color);
}

.quick-reply-textarea {
  min-height: 8.75rem;
  resize: vertical;
}

.quick-reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.375rem;
}

.quick-reply-submit {
  padding: 0.25rem 0.625rem;
}

/* 6f-iv. Fixed notices */
.gg-notice-stack {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  width: min(24rem, calc(100vw - 1.2rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1400;
  pointer-events: none;
}

.gg-notice {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--post-outline-color);
  border-left-width: 3px;
  background: color-mix(in srgb, var(--post-color) 96%, #000);
  color: var(--font-color);
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
  opacity: 0;
  animation: gg-notice-in 140ms ease forwards;
}

.gg-notice:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-xl);
}

.gg-notice-content {
  min-width: 0;
  width: 100%;
}

.gg-notice-message {
  margin: 0;
  font-size: var(--text-xs);
  line-height: 1.3;
  font-weight: 600;
}

.gg-notice-progress {
  margin-top: 0.35rem;
  width: 100%;
  height: 0.2rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--post-outline-color) 60%, transparent);
  overflow: hidden;
}

.gg-notice-progress-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  opacity: 0.4;
  transition: none;
  will-change: width;
}

.gg-notice-dismiss {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  width: 1.2rem;
  height: 1.2rem;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.gg-notice-dismiss:hover {
  border-color: var(--post-outline-color);
  background: color-mix(in srgb, var(--post-outline-color) 40%, transparent);
}

.gg-notice-success { border-left-color: var(--color-success); }
.gg-notice-info { border-left-color: var(--color-info); }
.gg-notice-warning { border-left-color: var(--color-warning); }
.gg-notice-error { border-left-color: var(--color-error); }

@keyframes gg-notice-in {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}


/* 6g. Pagination
   ------------------------------------------------------------------------ */

.page-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-sm);
}

.page-nav-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--post-outline-color);
  background: var(--post-color);
  color: var(--link-color);
  text-decoration: none;
  white-space: nowrap;
}

.page-nav-jump:hover {
  background: var(--highlighted-post-color);
  border-color: var(--highlighted-post-outline-color);
  color: var(--link-color);
  text-decoration: none;
}

.page-nav-pages {
  display: inline-flex;
  list-style: none;
}

.page-nav-item {
  border: 1px solid var(--post-outline-color);
  border-right: none;
  background: var(--post-color);
}

.page-nav-item:last-child {
  border-right: 1px solid var(--post-outline-color);
}

.page-nav-item > a,
.page-nav-item > span {
  display: block;
  padding: 0.375rem 0.625rem;
  color: var(--link-color);
  text-decoration: none;
}

.page-nav-item > a:hover {
  background: var(--highlighted-post-color);
  color: var(--link-color);
  text-decoration: none;
}

.page-nav-item:has(> a:hover) {
  border-color: var(--highlighted-post-outline-color);
}

.page-nav-current {
  background: var(--accent-color);
}

.page-nav-current > span {
  color: var(--background-rest);
  font-weight: 700;
}

.page-nav-ellipsis > span {
  color: var(--alt-font-color);
  cursor: default;
}

.page-nav-empty > span {
  color: var(--alt-font-color);
  cursor: default;
}


/* 6h. Badge
   ------------------------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 0.375rem;
  font-size: 0.625rem;
  line-height: 1rem;
  border-radius: 0.25rem;
  font-weight: 600;
}

.badge-outline {
  border: 1px solid currentColor;
  background: transparent;
}

.badge-warning {
  background: color-mix(in srgb, var(--color-warning) 20%, transparent);
  color: var(--color-warning);
}

.badge-error {
  background: color-mix(in srgb, var(--color-error) 20%, transparent);
  color: var(--color-error);
}

.badge-success {
  background: color-mix(in srgb, var(--color-success) 20%, transparent);
  color: var(--color-success);
}

.badge-info {
  background: color-mix(in srgb, var(--color-info) 20%, transparent);
  color: var(--color-info);
}


/* 6i. Manage
   ------------------------------------------------------------------------ */

.manage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.manage-table th,
.manage-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.manage-table thead th {
  font-weight: 600;
  border-bottom: 1px solid var(--hr);
}

.manage-table tbody tr:nth-child(even) {
  background: var(--background-rest);
}

.table-scroll {
  overflow-x: auto;
}

.error-alert,
.manage-flash-error {
  padding: 0.75rem 1rem;
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--color-error) 15%, var(--post-color));
  color: var(--color-error);
  font-size: var(--text-sm);
}

.manage-flash-success {
  padding: 0.75rem 1rem;
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--color-success) 15%, var(--post-color));
  color: var(--color-success);
  font-size: var(--text-sm);
}

/* Manage page container */
.manage-page {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 0;
}

.manage-page h1 {
  font-size: var(--text-xl);
  margin-bottom: 0.5rem;
}

.manage-page h2 {
  font-size: var(--text-lg);
  margin-bottom: 0.75rem;
}

.manage-back {
  display: inline-block;
  font-size: var(--text-sm);
  margin-bottom: 1rem;
}

.manage-section {
  margin-top: 1.5rem;
}

/* Manage post form — reuses .post-form layout */
.manage-form {
  margin: 0 auto;
  width: 100%;
  max-width: 28rem;
}

/* Entries list */
.manage-entry {
  padding: 1rem 0;
  border-bottom: 1px solid var(--hr);
}

.manage-entry:last-child {
  border-bottom: none;
}

.manage-entry-subject {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--subject-color);
  margin-bottom: 0.25rem;
}

.manage-entry-meta {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  margin-bottom: 0.5rem;
}

.manage-entry-body {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--font-color);
  margin-bottom: 0.5rem;
}

.manage-entry-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--text-sm);
}

.manage-entry-actions form {
  display: inline;
}

.manage-entry-actions button {
  background: none;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 0;
}

.manage-entry-actions button:hover {
  text-decoration: underline;
}

/* Pagination */
.manage-pagination {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: var(--text-sm);
}

/* Public news */
.news-page {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 0;
}

.news-page h1 {
  font-size: var(--text-xl);
  margin-bottom: 1rem;
}

.news-article {
  padding: 1rem 0;
  border-bottom: 1px solid var(--hr);
}

.news-article:last-of-type {
  border-bottom: none;
}

.news-article-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.news-article-meta {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  margin-bottom: 0.5rem;
}

.news-article-body {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--font-color);
}


/* 6j. Tooltip
   ------------------------------------------------------------------------ */

#tooltip {
  position: fixed;
  max-width: 300px;
  padding: 4px 8px;
  background: var(--floating-menu-color);
  border: 1px solid var(--floating-menu-outline-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  color: var(--font-color);
  font-size: var(--text-xs);
  line-height: 1.4;
  z-index: 50;
  pointer-events: none;
  white-space: pre-line;
  opacity: 0;
  transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1);
}

#tooltip.is-visible {
  opacity: 1;
}

/* Arrow via ::after pseudo-element (4px border triangle). */
#tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  margin-left: -4px;
  border: 4px solid transparent;
}

/* Arrow points down (tooltip above target). */
#tooltip.tip-top::after {
  top: 100%;
  border-top-color: var(--floating-menu-outline-color);
}

/* Arrow points up (tooltip below target). */
#tooltip.tip-bottom::after {
  bottom: 100%;
  border-bottom-color: var(--floating-menu-outline-color);
}

/* Shift arrow when tooltip is near left/right viewport edge. */
#tooltip.tip-left::after {
  left: 12px;
  margin-left: 0;
}

#tooltip.tip-right::after {
  left: auto;
  right: 12px;
  margin-left: 0;
}


/* ========================================================================
   7. PAGES
   ======================================================================== */

/* Centered page system (auth, error) */
.cp-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--background-rest);
  padding: 0.5rem;
}

.cp-card {
  width: 100%;
  max-width: 420px;
  background: transparent;
  border-radius: 0;
  border: 1px solid var(--post-outline-color);
}

.cp-card-body {
  padding: 1rem;
}

.cp-title {
  margin: 0 0 0.625rem;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--title-color);
}

.cp-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cp-input-stack {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  border: 1px solid var(--input-borders);
}

.cp-input {
  width: 100%;
  height: 44px;
  padding: 0.625rem 0.75rem;
  font-size: var(--text-base);
  border: none;
  outline: none;
  background: #fff;
  color: #000;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}

.cp-input::placeholder,
.cp-field-input::placeholder {
  color: #999;
}

.cp-input:first-child {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.cp-input:last-child {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.cp-input + .cp-input {
  border-top: 1px solid var(--input-borders);
}

.cp-field {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cp-field + .cp-field {
  margin-top: 0.5rem;
}

.cp-field-label {
  display: none;
}

.cp-field-input {
  width: 100%;
  height: 44px;
  padding: 0.625rem 0.75rem;
  font-size: var(--text-base);
  border: 1px solid var(--input-borders);
  outline: none;
  background: #fff;
  color: #000;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}

.cp-field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.cp-field-checkbox .cp-field-label {
  display: inline;
  margin: 0;
}

.cp-field-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-color);
}

.cp-btn {
  width: 100%;
  max-width: 320px;
  height: 44px;
  margin-top: 0.75rem;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-color);
  color: #fff;
  font-size: var(--text-base);
  font-weight: 700;
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
}

.cp-btn:hover {
  opacity: 0.85;
  text-decoration: none;
}

.cp-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cp-links {
  margin-top: 0.75rem;
  font-size: var(--text-sm);
  color: var(--font-color);
}

.cp-links a {
  color: #fff;
  font-weight: 700;
}

.cp-links a:hover {
  color: var(--accent-color);
  text-decoration: none;
}

.cp-alert-error {
  width: 100%;
  max-width: 320px;
  margin: 0 0 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0;
  border: 1px solid color-mix(in srgb, var(--color-error) 45%, var(--post-outline-color));
  background: color-mix(in srgb, var(--color-error) 15%, var(--post-color));
  color: var(--color-error);
  font-size: var(--text-sm);
}

/* Fieldset & Legend (card-based groupings) */
.cp-fieldset {
  border: 1px solid var(--border-color);
  border-radius: 0;
  padding: 1rem;
  margin-bottom: 1rem;
}

.cp-legend {
  font-weight: bold;
  padding: 0 0.5rem;
}

/* ========================================================================
   Manage Action Pages (ban form, warn form, ban list)
   ======================================================================== */

.manage-action.page {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0.75rem 0.5rem 1.5rem;
}

/* Form — clean card sections with post styling */
.action-form {
  max-width: 36rem;
}

.action-form .form-fields {
  border: 1px solid var(--post-outline-color);
  background: var(--post-color);
  padding: 0.75rem;
  margin: 0 0 0.5rem;
}

.action-form .form-fields:first-of-type {
  margin-top: 0;
}

.action-form .form-legend {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--title-color);
  padding: 0;
  margin-bottom: 0.4rem;
}

.action-form .field {
  margin-bottom: 0.5rem;
}

.action-form .field:last-child {
  margin-bottom: 0;
}

.action-form .field-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  margin-bottom: 0.15rem;
  font-weight: 600;
}

.action-form .label-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-form .label-inline .field-label {
  display: inline;
  margin-bottom: 0;
  white-space: nowrap;
}

.action-form .label-inline .field-control {
  flex: 1;
}

.action-form .field-control {
  display: block;
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  background: var(--input-background);
  color: var(--font-color);
  font-size: var(--text-sm);
  font-family: inherit;
  box-sizing: border-box;
}

.action-form .field-control:focus {
  outline: none;
  border-color: var(--accent-color);
}

.action-form textarea.field-control {
  resize: vertical;
  min-height: 3rem;
}

.action-form .field-desc {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  margin: 0.2rem 0 0;
}

/* Checkbox / toggle buttons — Infinity-Next .field-button pattern */
.action-form .field-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.action-form .field-button {
  display: block;
  font-size: var(--text-sm);
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--post-outline-color);
  margin-right: -1px;
  margin-bottom: -1px;
  background: var(--background-rest);
  color: var(--font-color);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.action-form .field-button:hover {
  background: var(--alt-label-color);
}

.action-form .field-button input[type="checkbox"] {
  margin-right: 0.3rem;
  vertical-align: text-bottom;
}

.action-form .field-button small {
  color: var(--alt-font-color);
}

/* Submit button — staff-page act-btn style */
.act-btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 1.2rem;
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  background: transparent;
  color: var(--font-color);
  cursor: pointer;
}

.act-btn-submit:hover {
  background: var(--alt-label-color);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.row-submit {
  padding-top: 0;
  margin-bottom: 0;
}

/* ========================================================================
   Ban List — staff-grid pattern
   ======================================================================== */

.ban-list {
  display: flex;
  flex-direction: column;
}

.ban-row {
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  align-items: start;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  margin-top: -1px;
}

.ban-kind {
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid currentColor;
  border-radius: 0;
  padding: 0.1rem 0.3rem;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.ban-kind-warning { color: var(--color-warning); background: rgba(245, 166, 35, 0.08); }
.ban-kind-ban { color: var(--color-error); background: rgba(255, 111, 111, 0.08); }
.ban-kind-range { color: var(--color-info); background: rgba(0, 200, 255, 0.08); }
.ban-kind-geo { color: var(--color-success); background: rgba(0, 214, 143, 0.08); }

.ban-main {
  min-width: 0;
}

.ban-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.ban-target {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--title-color);
}

.ban-board {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
}

.ban-reason {
  font-size: var(--text-xs);
  color: var(--font-color);
  margin-top: 0.1rem;
  display: block;
}

.ban-meta {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  margin-top: 0.1rem;
  display: block;
}

.ban-appeal {
  font-size: var(--text-xs);
  margin-top: 0.2rem;
  padding: 0.2rem 0.4rem;
  background: rgba(245, 166, 35, 0.06);
  border: 1px solid var(--post-outline-color);
}

.ban-actions {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  align-self: center;
}

.ban-actions form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}


/* ========================================================================
   MODAL OVERLAY
   ======================================================================== */

/* ========================================================================
   Modal Overlay — gallery-matched style
   ======================================================================== */

/* Scroll lock when modal is open */
body.modal-open {
  overflow: hidden;
}

/* Full-screen backdrop — opacity-driven like gallery */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* The card that holds modal content */
.modal-shell {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  transform: scale(0.88);
  opacity: 0;
  transition: transform 300ms cubic-bezier(0.2, 0.9, 0.3, 1.0),
              opacity 280ms cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

.modal-overlay.is-open .modal-shell {
  transform: scale(1);
  opacity: 1;
}

/* Scrollable content area */
#modal-content {
  padding: 0.75rem;
  overflow-y: auto;
  flex: 1 1 auto;
  max-height: calc(90vh - 1rem);
}

/* Modal footer — Cancel / Submit button pair */
.modal-actions {
  display: flex;
  margin: 0 -0.75rem -0.75rem;
}

.modal-actions button {
  flex: 1;
  padding: 0.9rem 0;
  background: var(--post-color);
  border: none;
  border-top: 2px solid var(--post-outline-color);
  border-radius: 0;
  color: var(--font-color);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}

.modal-actions button:first-child {
  border-right: 2px solid var(--post-outline-color);
}

.modal-actions button:hover {
  background: var(--alt-label-color);
}

/* Allow the action-form styles to work inside modals unchanged */
.modal-shell .action-form {
  max-width: none;
}

/* Forms inside modals inherit cp-form spacing */
.modal-shell .cp-form {
  max-width: none;
}

/* Closing animation — backdrop, shell, and close button all fade together */
.modal-overlay.is-closing {
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.is-closing .modal-shell {
  transform: scale(0.92);
  opacity: 0;
}

/* Mobile: modal goes full-width */
@media (max-width: 480px) {
  .modal-shell {
    max-width: 100%;
    max-height: 100vh;
  }
}

/* ========================================================================
   8. UTILITIES
   ======================================================================== */

/* Screen-reader only — visually hidden but accessible to assistive tech */
.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;
}

.text-muted {
  color: var(--alt-font-color);
}

.reply-link {
  font-weight: 500;
}




/* ========================================================================
   9. MEDIA QUERIES
   ========================================================================
   Breakpoint: 480px — mobile
   ======================================================================== */

@media (max-width: 480px) {
  /* Form: collapse grid, hide labels, show mobile submit */
  .form-row {
    grid-template-columns: 1fr;
  }

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

  .form-input::placeholder {
    color: var(--alt-font-color);
  }

  .form-inline-error {
    margin-left: 0;
  }

  .form-submit {
    display: none;
  }

  .form-submit-mobile {
    display: block;
  }

  .form-submit-mobile .form-submit,
  .quick-reply .form-submit {
    display: inline-flex;
  }

  .gg-notice-stack {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    top: 0.6rem;
    width: min(95vw, 24rem);
  }

  /* Catalog */
  .catalog-cell {
    width: 155px;
  }

  .home-popular-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .site-header-inner {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .site-header-logo-link {
    min-height: 2.25rem;
  }

  .site-header-logo {
    height: var(--header-logo-height-mobile);
    width: var(--header-logo-width-mobile);
  }

  .home-hero.has-featured {
    flex-direction: column;
    align-items: center;
  }

  .home-featured-post {
    width: 100%;
  }

  .home-popular-card:nth-child(n + 5) {
    display: none;
  }

  /* Auth pages */
  .cp-card {
    max-width: 100%;
  }

  .cp-card-body {
    padding: 0.75rem;
  }

  .cp-input-stack,
  .cp-input,
  .cp-field,
  .cp-field-input,
  .cp-btn {
    width: 100%;
  }
}

/* ========================================================================
   Staff Management Page (.manage-staff)
   ======================================================================== */

.manage-staff.page {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0.75rem 0.5rem 1.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.page-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--title-color);
}

.page-title span {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--alt-font-color);
  margin-left: 0.4rem;
}

.add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  color: var(--font-color);
  background: transparent;
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
}

.add-btn:hover {
  background: var(--alt-label-color);
  color: var(--accent-color);
  border-color: var(--accent-color);
  text-decoration: none;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 0.5rem;
}

.filter-chip {
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  background: var(--post-color);
  color: var(--alt-font-color);
  cursor: pointer;
  user-select: none;
  margin-right: -1px;
  text-decoration: none;
}

.filter-chip:hover {
  background: var(--alt-label-color);
  color: var(--font-color);
  text-decoration: none;
}

.filter-chip.active {
  background: var(--alt-label-color);
  color: var(--accent-color);
  border-color: var(--accent-color);
  position: relative;
  z-index: 1;
}

/* Staff list */
.staff-list {
  display: flex;
  flex-direction: column;
}

.staff-row {
  display: grid;
  grid-template-columns: 1.75rem 1fr auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  background: var(--post-color);
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  margin-top: -1px;
}

.staff-id {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  font-variant-numeric: tabular-nums;
}

.staff-main {
  min-width: 0;
}

.staff-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.staff-username {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--title-color);
}

.staff-boards {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
}

.staff-last {
  font-size: var(--text-xs);
  color: var(--alt-font-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 38ch;
  display: block;
  margin-top: 0.1rem;
}

/* Staff role badges */
.manage-staff .badge {
  border: 1px solid currentColor;
  border-radius: 0;
}

.badge-admin {
  color: var(--color-warning);
  background: rgba(245, 166, 35, 0.1);
}

.badge-manager {
  color: var(--color-warning);
  background: rgba(245, 166, 35, 0.06);
}

.badge-mod {
  color: var(--color-info);
  background: rgba(0, 200, 255, 0.08);
}

.badge-jan {
  color: var(--color-success);
  background: rgba(0, 214, 143, 0.08);
}

.badge-appr {
  color: var(--alt-font-color);
  background: transparent;
}

/* Action buttons */
.staff-actions {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}

.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--post-outline-color);
  border-radius: 0;
  background: transparent;
  color: var(--alt-font-color);
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  margin-left: -1px;
}

.act-btn:hover {
  background: var(--alt-label-color);
  color: var(--font-color);
  border-color: #444;
  text-decoration: none;
  position: relative;
  z-index: 1;
}

.act-btn.promote:hover {
  background: rgba(0, 214, 143, 0.08);
  border-color: var(--color-success);
  color: var(--color-success);
}

.act-btn.demote:hover {
  background: rgba(255, 111, 111, 0.08);
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Promote/demote form buttons should look like act-btn */
.staff-actions form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

/* Responsive */
@media (max-width: 480px) {
  .staff-row {
    grid-template-columns: 1.25rem 1fr auto;
    padding: 0.35rem 0.4rem;
  }

  .staff-last {
    max-width: 22ch;
  }

  .act-btn {
    width: 1.35rem;
    height: 1.35rem;
    font-size: 0.7rem;
  }
}

/* ========================================================================
   Image Gallery Lightbox — Discord/Twitter-style fullscreen overlay
   ======================================================================== */

/* Scroll lock when gallery is open */
body.gallery-open {
  overflow: hidden;
}

/* Full-screen backdrop — separate from #modal-host */
.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Image — scales large images to fit, small images stay 1:1 */
.gallery-image {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  transform: scale(0.88);
  opacity: 0;
  cursor: zoom-in;
  transition: transform 300ms cubic-bezier(0.2, 0.9, 0.3, 1.0),
              opacity 280ms cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

/* Disable transition during active panning for instant movement */
.gallery-image.is-panning {
  transition: none;
}

.gallery-overlay.is-open .gallery-image {
  transform: scale(1);
  opacity: 1;
}

/* Controls — top-right translucent pill buttons, fixed to viewport */
.gallery-controls {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 9501;
}

.gallery-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  transition: transform 200ms ease, opacity 200ms ease, background 150ms ease;
}

.gallery-overlay.is-open .gallery-btn {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger: second button delayed */
.gallery-overlay.is-open .gallery-btn:nth-child(2) {
  transition-delay: 50ms;
}

.gallery-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Zoom state — image zoomed via CSS transform, no native scroll */
.gallery-overlay.is-zoomed {
  overflow: hidden;
}

.gallery-overlay.is-zoomed .gallery-image {
  cursor: grab;
}

.gallery-overlay.is-zoomed .gallery-image.is-panning {
  cursor: grabbing;
}

/* Closing animation — backdrop, image, and controls all fade together */
.gallery-overlay.is-closing {
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-overlay.is-closing .gallery-image {
  transform: scale(0.92);
  opacity: 0;
}

.gallery-overlay.is-closing .gallery-btn {
  opacity: 0;
  transform: translateY(-8px);
}

/* Prev / Next nav buttons — circular, matching .gallery-btn style */
.gallery-nav {
  position: fixed;
  top: 50%;
  z-index: 9501;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: transform 200ms ease, opacity 200ms ease, background 150ms ease;
}

.gallery-overlay.is-open .gallery-nav {
  opacity: 1;
  pointer-events: auto;
}

.gallery-prev { left: 1rem; }
.gallery-next { right: 1rem; }

.gallery-nav:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Hide nav when only one image */
.gallery-overlay.gallery-single .gallery-nav,
.gallery-overlay.gallery-single .gallery-counter {
  display: none;
}

/* Image counter — centered at bottom */
.gallery-counter {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9501;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 0.2rem 0.65rem;
  border-radius: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.gallery-overlay.is-open .gallery-counter {
  opacity: 1;
}

.gallery-overlay.is-closing .gallery-nav {
  opacity: 0;
}

.gallery-overlay.is-closing .gallery-counter {
  opacity: 0;
}

/* Mobile — edge-to-edge image, smaller controls */
@media (max-width: 480px) {
  .gallery-image {
    max-width: 100vw;
    max-height: 100vh;
  }

  .gallery-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .gallery-controls {
    top: 0.5rem;
    right: 0.5rem;
    gap: 0.35rem;
  }

  .gallery-nav {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .gallery-prev { left: 0.35rem; }
  .gallery-next { right: 0.35rem; }

  .gallery-counter {
    bottom: 0.75rem;
    font-size: 0.75rem;
  }
}

/* Mobile — hide post hover popover (hover not useful on touch) */
@media (max-width: 480px) {
  #post-hover {
    display: none !important;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0s;
  }

  #tooltip {
    transition: none;
  }

  .modal-overlay,
  .modal-shell {
    transition-duration: 0ms;
  }

  .gallery-overlay,
  .gallery-image,
  .gallery-btn,
  .gallery-nav,
  .gallery-counter {
    transition-duration: 0ms;
  }

  .video-controls,
  .video-idle-time,
  .video-big-play,
  .video-btn,
  .video-scrub,
  .gg-notice,
  #app-content,
  .instant-nav-progress {
    transition: none;
    animation: none;
    transform: none;
    opacity: 1;
  }
}
