/* CharacterLoft styles. Six colour themes via [data-theme]; fonts are Bootstrap's defaults.
   Every theme's text, muted text, links and accent buttons meet WCAG AA contrast (4.5:1). */

/* ───────── Theme tokens ───────── */
:root, [data-theme="light"] {
  --bg: #f5f4f8; --surface: #ffffff; --surface-2: #efedf5; --border: #e3e0ec;
  --text: #24222e; --muted: #6b687c;
  --accent: #6a45ff; --accent-rgb: 106, 69, 255; --accent-hover: #562bff; --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 14px rgba(30, 20, 60, .06);
}
[data-theme="dark"] {
  --bg: #15151b; --surface: #1f1f28; --surface-2: #282833; --border: #32323f;
  --text: #e9e7f2; --muted: #a09db3;
  --accent: #9d86ff; --accent-rgb: 157, 134, 255; --accent-hover: #b3a1ff; --on-accent: #15151b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}
[data-theme="midnight"] {
  --bg: #0c1322; --surface: #142036; --surface-2: #1a2943; --border: #24365a;
  --text: #dfe8f8; --muted: #93a6c6;
  --accent: #4ea4ff; --accent-rgb: 78, 164, 255; --accent-hover: #74b8ff; --on-accent: #0c1322;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .3);
}
[data-theme="forest"] {
  --bg: #edf3ea; --surface: #fbfdf9; --surface-2: #e3ecdf; --border: #d3e0cd;
  --text: #1f2a1e; --muted: #5a6d57;
  --accent: #337449; --accent-rgb: 51, 116, 73; --accent-hover: #2c643f; --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(20, 50, 20, .06), 0 4px 14px rgba(20, 50, 20, .07);
}
[data-theme="sunset"] {
  --bg: #fff3ea; --surface: #fffaf6; --surface-2: #fde8da; --border: #f5d9c6;
  --text: #3a2418; --muted: #85604d;
  --accent: #b84119; --accent-rgb: 184, 65, 25; --accent-hover: #9f3816; --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(90, 40, 10, .06), 0 4px 14px rgba(90, 40, 10, .08);
}
[data-theme="berry"] {
  --bg: #1c121f; --surface: #29192e; --surface-2: #33203a; --border: #47304f;
  --text: #f6e7f3; --muted: #c09bb8;
  --accent: #ff6fae; --accent-rgb: 255, 111, 174; --accent-hover: #ff8fc1; --on-accent: #1c121f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .3);
}

/* Map tokens onto Bootstrap. */
[data-theme] {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--muted);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-link-color-rgb: var(--accent-rgb);
  --bs-link-hover-color-rgb: var(--accent-rgb);
  --bs-primary-rgb: var(--accent-rgb);
  --bs-focus-ring-color: rgba(var(--accent-rgb), .3);
}
body { background: var(--bg); color: var(--text); }
.text-secondary { color: var(--muted) !important; }
.card { --bs-card-bg: var(--surface); --bs-card-border-color: var(--border); box-shadow: var(--shadow); border-radius: 14px; }
.list-group { --bs-list-group-bg: var(--surface); --bs-list-group-border-color: var(--border); --bs-list-group-color: var(--text);
  --bs-list-group-action-hover-bg: var(--surface-2); --bs-list-group-action-hover-color: var(--text); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); }
.dropdown-menu { --bs-dropdown-bg: var(--surface); --bs-dropdown-border-color: var(--border); --bs-dropdown-link-color: var(--text);
  --bs-dropdown-link-hover-bg: var(--surface-2); --bs-dropdown-link-hover-color: var(--text); box-shadow: var(--shadow); border-radius: 12px; }
.dropdown-item .bi { width: 1.4em; color: var(--muted); }
.form-control, .form-select { background-color: var(--surface); border-color: var(--border); color: var(--text); border-radius: 10px; }
.form-control:focus, .form-select:focus { background-color: var(--surface); color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(var(--accent-rgb), .2); }
.form-control::placeholder { color: var(--muted); opacity: .7; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-range::-webkit-slider-thumb { background: var(--accent); }
.form-range::-moz-range-thumb { background: var(--accent); }
.alert { border-radius: 12px; }
.btn { border-radius: 10px; }
.btn-accent, .btn-primary {
  --bs-btn-color: var(--on-accent); --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: var(--on-accent); --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-color: var(--on-accent); --bs-btn-active-bg: var(--accent-hover); --bs-btn-active-border-color: var(--accent-hover);
  --bs-btn-disabled-color: var(--on-accent); --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-accent, .btn-outline-primary {
  --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: var(--on-accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-color: var(--on-accent); --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-disabled-color: var(--accent); --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-secondary { --bs-btn-color: var(--text); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--surface-2);
  --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border); --bs-btn-active-bg: var(--surface-2); --bs-btn-active-color: var(--text); }
.text-bg-accent { background: var(--accent) !important; color: var(--on-accent) !important; }
.nav-pills .nav-link { color: var(--muted); border-radius: 10px; }
.nav-pills .nav-link.active { background: var(--accent); color: var(--on-accent); }
.nav-underline .nav-link { color: var(--muted); }
.nav-underline .nav-link.active, .nav-underline .nav-link:hover { color: var(--text); border-bottom-color: var(--accent); }

/* ───────── Top bar ───────── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1020; }
.topbar .navbar { padding: .5rem 0; }
.topbar .nav-link { color: var(--muted); font-weight: 500; border-radius: 10px; padding: .4rem .75rem !important; }
.topbar .nav-link:hover { color: var(--text); background: var(--surface-2); }
.topbar .nav-link .bi { margin-right: .25rem; }
.brand { color: var(--text) !important; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-on { background: rgba(var(--accent-rgb), .15); color: var(--accent); }
.icon-btn .count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.nav-avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--on-accent); font-weight: 700; }
/* Footer: a thin bar fixed to the bottom of the screen on every page. */
:root { --footer-h: 2.4rem; }
.site-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1010; color: var(--muted);
  background: var(--surface); border-top: 1px solid var(--border); height: calc(var(--footer-h) + env(safe-area-inset-bottom));
  display: flex; align-items: center; }
body { padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom)); }
/* One line always (scrolls sideways on very small screens), so it never grows over the page. */
.site-footer > div { white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.site-footer > div::-webkit-scrollbar { display: none; }

/* ───────── Panels & sections ───────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel-dashed { border-style: dashed; box-shadow: none; background: transparent; }
.section { margin-bottom: 2rem; }
.section-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.section-head h1, .section-head h2 { font-size: 1.4rem; font-weight: 600; margin: 0; }
.section-head .bi { color: var(--accent); margin-right: .35rem; }

/* ───────── Character cards ───────── */
.char-card { display: block; height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s; }
.char-card:hover { border-color: rgba(var(--accent-rgb), .6); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .35), var(--shadow); color: var(--text); }
.char-thumb { position: relative; aspect-ratio: 1; background: var(--surface-2); }
.char-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), .35), rgba(var(--accent-rgb), .1)); color: var(--accent); font-size: 3rem; font-weight: 800; }
.char-chips { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: .75rem; backdrop-filter: blur(4px); }
.chip-accent { background: var(--accent); color: var(--on-accent); }
.char-body { padding: .6rem .75rem .7rem; }
.char-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-meta-line { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); }
.char-owner { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-stats { margin-left: auto; display: flex; gap: .5rem; white-space: nowrap; }

/* ───────── Character page ───────── */
.char-sidebar { overflow: hidden; }
.thumb-frame.big { aspect-ratio: 1; background: var(--surface-2); }
.thumb-frame.big img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Avatar preview on the edit form: a square like the character page, capped so it fits the wider form column. */
.avatar-edit .avatar-preview { max-width: 10rem; border-radius: 12px; overflow: hidden; }
.avatar-edit .avatar-edit-link { display: inline-block; margin-top: .6rem; }
.char-sidebar h1 { font-weight: 600; }
.char-meta { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; }
.char-meta dt { font-weight: 500; color: var(--muted); }
.char-meta dd { margin: 0; }
.char-fields .list-group-item { background: transparent; }
.tag-badge { background: rgba(var(--accent-rgb), .14); color: var(--accent); font-weight: 500; border-radius: 8px; }
.char-tabs { border-bottom-color: var(--border); gap: .25rem; }
.char-tabs .nav-link { color: var(--muted); border-radius: 10px 10px 0 0; }
.char-tabs .nav-link:hover { color: var(--text); border-color: transparent; }
.char-tabs .nav-link.active { background: var(--surface); border-color: var(--border) var(--border) var(--surface); color: var(--text); }
.char-tabs .nav-link.active .bi { color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; border-radius: 999px; font-size: .9rem; text-decoration: none;
  background: var(--surface-2); color: var(--text); }
.pill:hover { background: rgba(var(--accent-rgb), .15); color: var(--accent); }
.role-dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: .4em; }
.code-area { tab-size: 2; }
.loft-table th { color: var(--muted); font-weight: 500; }
.picker-people { border-left: 3px solid var(--border); padding-left: .75rem; }

/* ───────── Profiles ───────── */
.profile-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.profile-avatar { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; }
.profile-avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--on-accent); font-size: 2.2rem; font-weight: 800; }

/* ───────── Activity ───────── */
.activity-list { display: flex; flex-direction: column; gap: .5rem; }
.activity-item { display: flex; align-items: center; gap: .9rem; padding: .7rem .9rem; margin: 0; color: var(--text); text-decoration: none; }
.activity-item:hover { border-color: rgba(var(--accent-rgb), .6); color: var(--text); }
.activity-item.is-new { border-left: 4px solid var(--accent); }
.activity-thumb { width: 52px; height: 52px; border-radius: 10px; overflow: hidden; flex: none; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.4rem; }
.activity-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ───────── Theme picker ───────── */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; }
.theme-card { cursor: pointer; display: block; }
.theme-card input { position: absolute; opacity: 0; }
.theme-preview { display: block; height: 96px; border-radius: 12px; padding: 10px; border: 2px solid var(--border); position: relative; }
.theme-card input:checked + .theme-preview { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .3); }
.theme-card input:focus-visible + .theme-preview { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-bar { display: block; height: 12px; border-radius: 4px; margin-bottom: 8px; }
.tp-card { display: inline-block; width: 44%; height: 44px; border-radius: 6px; margin-right: 4%; padding: 6px; vertical-align: top; }
.tp-accent { display: block; height: 8px; width: 70%; border-radius: 4px; }
.theme-name { display: block; margin-top: .35rem; font-weight: 500; }

/* ───────── Images ───────── */
/* The whole picture fits on screen: never wider than the column or taller than the window
   (minus the top bar and the previous/next row). */
.image-stage img { display: block; margin: 0 auto; max-width: 100%; max-height: calc(100dvh - 14rem); width: auto; height: auto; object-fit: contain; border-radius: 10px; }
.crop-wrap { height: min(70vh, 34rem); background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.crop-wrap img { display: block; max-width: 100%; max-height: 100%; }
.crop-wrap .cropper-container { cursor: grab; }
.crop-wrap .cropper-container:active { cursor: grabbing; }
.crop-preview { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.crop-preview.big { width: 160px; height: 160px; }
.crop-preview.small { width: 64px; height: 64px; border-radius: 50%; }

/* ───────── User-styled areas ─────────
   `contain: paint` makes these the containing block for position:fixed descendants
   and clips overflow, so custom CSS can't cover the site. */
.profile-custom, .bio-custom {
  contain: paint; position: relative; isolation: isolate; overflow-wrap: anywhere;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; min-height: 4rem;
}
.profile-custom img, .bio-custom img { max-width: 100%; max-height: 90dvh; height: auto; object-fit: contain; }

/* ───────── Blinkies off ───────── */
[data-blinkies="off"] *, [data-blinkies="off"] *::before, [data-blinkies="off"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
.reduced-motion-only { display: none; }
@media (prefers-reduced-motion: reduce) {
  .char-card, .world-card { transition: none; }
  .reduced-motion-only { display: block; }
  /* Members' own profile and bio CSS: no animations when the device asks for less motion. */
  .profile-custom *, .profile-custom *::before, .profile-custom *::after,
  .bio-custom *, .bio-custom *::before, .bio-custom *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto !important; }
}

/* Watermark status on the image page */
.watermark-box { border: 1px dashed var(--border); border-radius: 12px; padding: .75rem; }
.text-accent { color: var(--accent) !important; }

[data-bs-theme="dark"] { color-scheme: dark; }
[data-bs-theme="light"] { color-scheme: light; }
html, .settings-nav, textarea, .table-responsive { scrollbar-color: var(--border) transparent; }

/* ───────── Page width ───────── */
.container-wide { width: 100%; max-width: 2800px; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }
@media (min-width: 768px) { .container-wide { padding-left: 1.5rem; padding-right: 1.5rem; } }
@media (min-width: 1600px) { .container-wide { padding-left: 2.5rem; padding-right: 2.5rem; } }
.navbar > .container-wide { display: flex; flex-wrap: inherit; align-items: center; justify-content: space-between; }

/* ───────── Settings (one page, sticky sidebar) ───────── */
.settings-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.75rem; align-items: start; }
/* Forms stay readable on very wide screens; galleries elsewhere use the full width. */
.settings-shell { max-width: 1760px; margin-left: auto; margin-right: auto; }
.settings-nav { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: .6rem; box-shadow: var(--shadow); scrollbar-width: thin; }
.settings-who { display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem .75rem; color: var(--text); text-decoration: none;
  border-bottom: 1px solid var(--border); margin-bottom: .25rem; line-height: 1.2; }
.settings-group { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: .8rem .6rem .25rem; }
.settings-link { display: flex; align-items: center; gap: .55rem; padding: .34rem .6rem; border-radius: 9px; color: var(--text);
  text-decoration: none; font-size: .9rem; white-space: nowrap; }
.settings-link .bi { color: var(--muted); width: 1.1rem; text-align: center; flex-shrink: 0; }
.settings-link:hover { background: var(--surface-2); color: var(--text); }
.settings-link.active { background: rgba(var(--accent-rgb), .14); color: var(--accent); font-weight: 600; }
.settings-link.active .bi { color: var(--accent); }
.settings-main, .settings-nav { min-width: 0; }
.settings-section { scroll-margin-top: 1rem; margin-bottom: 2.25rem; }
/* Bootstrap's smooth scrolling makes every save reload at the top, then glide down. */
html:has(.settings-shell) { scroll-behavior: auto; }
.settings-h { font-size: 1.3rem; font-weight: 650; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.settings-h > .bi { color: var(--accent); }
.panel-h { font-size: .95rem; font-weight: 650; margin-bottom: .6rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1rem; align-items: stretch; margin-bottom: 1rem; }
.settings-grid > .panel { margin-bottom: 0; }
.settings-grid > .settings-section { margin-bottom: 1.25rem; }
.panel .settings-grid { margin-bottom: 0; gap: 1.25rem 2rem; }
.narrow-form { max-width: 30rem; }
.settings-phonebar, .settings-drawer-head { display: none; }
@media (max-width: 991.98px) {
  .settings-shell { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  /* Phone/tablet: a slim bar under the header shows the current section; its button slides
     the full section menu in from the left (the same list as the desktop sidebar). */
  .settings-phonebar { display: flex; align-items: center; gap: .75rem; position: sticky; top: var(--topbar-h, 0); z-index: 20;
    margin: 0 -1rem; padding: .5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
  .settings-current { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .settings-nav { position: fixed; top: 0; bottom: 0; left: 0; z-index: 1060; width: min(300px, 85vw); max-height: none;
    overflow-y: auto; border-radius: 0 16px 16px 0; margin: 0; transform: translateX(-105%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s; box-shadow: 0 0 40px rgba(0,0,0,.25); padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .settings-nav.open { transform: none; visibility: visible; transition: transform .22s ease; }
  .settings-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: .25rem .25rem .75rem; }
  .settings-backdrop { position: fixed; inset: 0; z-index: 1055; background: rgba(0,0,0,.4); }
  .settings-section { scroll-margin-top: 6rem; }
}
@media (max-width: 991.98px) and (prefers-reduced-motion: reduce) { .settings-nav, .settings-nav.open { transition: none; } }

.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem; margin-bottom: .75rem; background: var(--surface-2); border-radius: 12px; }
.bulk-bar .input-group { width: auto; flex: 1 1 19rem; max-width: 30rem; }
.bulk-bar .input-group .form-select { min-width: 9.5rem; }
.bulk-bar .input-group .input-group-text { min-width: 5.5rem; }
/* Delete sits on its own row, apart from the routine changes, with the selection count. */
.bulk-danger { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .5rem; margin-top: .1rem; border-top: 1px solid var(--border); }
.sticky-bulk { position: sticky; top: .5rem; z-index: 5; box-shadow: var(--shadow); }
@media (max-width: 991.98px) { .sticky-bulk { top: 3.4rem; } }

.folder-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.fchip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .75rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .85rem; cursor: pointer; }
.fchip:hover { border-color: var(--accent); color: var(--accent); }
.fchip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fchip.active .text-secondary { color: inherit !important; opacity: .8; }
.fchip.chip-ghost { border-style: dashed; color: var(--muted); }
.folder-list { display: flex; flex-direction: column; gap: .4rem; }
.folder-row { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 10px; }
.folder-row .input-group { max-width: 22rem; flex: 1; }

.mini-thumb { display: inline-flex; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; background: var(--surface-2);
  align-items: center; justify-content: center; font-weight: 700; color: var(--muted); cursor: pointer; margin: 0; flex-shrink: 0; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mass-table { --bs-table-bg: transparent; }
.mass-table td, .mass-table th { padding: .45rem .6rem; }
.mass-table th:first-child, .mass-table td:first-child { width: 2.6rem; }
.mass-table th:nth-child(2), .mass-table td:nth-child(2) { width: 3.6rem; }
#manage-table td:nth-child(3), #tag-table td:nth-child(3) { min-width: 9rem; }
.mass-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.mass-table tbody tr:has(input:checked) { background: rgba(var(--accent-rgb), .09); }
.sort-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.sort-list li { display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 10px; }
.sort-pos { width: 4.2rem; flex-shrink: 0; }
.session-list li, .person-row { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.session-list li:last-child, .person-row:last-child { border-bottom: 0; }
.list-row { padding: .45rem 0; border-top: 1px solid var(--border); }
.wm-preview { max-height: 340px; width: 100%; object-fit: contain; background: var(--surface-2); }

/* Image manager: grouped by upload day */
.image-day { margin-top: 1rem; }
.image-day-head { display: flex; align-items: baseline; gap: .5rem; font-weight: 650; padding-bottom: .4rem; margin-bottom: .6rem; border-bottom: 1px solid var(--border); }
.image-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; }
@media (min-width: 1400px) { .image-pick-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.image-pick { position: relative; display: block; background: var(--surface-2); border: 2px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; margin: 0; }
.image-pick img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.image-pick:hover img { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: -2px; }
.image-pick > .form-check-input { position: absolute; top: .45rem; left: .45rem; z-index: 2; width: 1.15em; height: 1.15em; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.image-pick-flags { position: absolute; top: .4rem; right: .4rem; z-index: 2; display: flex; gap: .2rem; }
.image-pick-flags .badge { font-size: .65rem; }
.image-pick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .25); }
.image-pick-meta { display: block; padding: .3rem .45rem; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--surface); }

/* ───────── NSFW ───────── */
.nsfw-badge, .chip-nsfw { background: #d6336c !important; color: #fff !important; font-weight: 700; }
.chip-nsfw { font-size: .68rem; padding: 0 7px; }
.gore-badge, .chip-gore { background: #a61e1e !important; color: #fff !important; font-weight: 700; }
.chip-gore-minor { background: #c2641a !important; }
.trauma-badge, .chip-trauma { background: #6741d9 !important; color: #fff !important; font-weight: 700; cursor: help; }
.chip-gore, .chip-trauma { font-size: .68rem; padding: 0 7px; }
.rating-picker { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .75rem; }
.warning-trauma { white-space: pre-line; }
.blur-nsfw { overflow: hidden; }
.blur-nsfw img { filter: blur(18px) saturate(.6); transform: scale(1.08); transition: filter .2s; }
/* Hover reveals only for people who chose "hover or tap"; tap/click always works. */
@media (hover: hover) { .blur-nsfw:not(.blur-tap):hover img { filter: none; } }
.blur-nsfw.revealed img { filter: none; }
/* Image manager tiles: the blur sits on the picture, so the checkbox still works directly. */
.pick-thumb { display: block; overflow: hidden; }
/* Tiny thumbnails need less blur to stay recognisable as "something's here". */
.mini-thumb.blur-nsfw img { filter: blur(5px) saturate(.6); }
.blur-nsfw:not(.revealed) { cursor: pointer; }
.cf-rows { display: flex; flex-direction: column; gap: .6rem; }
.cf-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.cf-label { min-width: 12rem; flex: 1; }
.cf-modes .btn { min-width: 4.2rem; }
.btn-check:checked + .cf-show { background: #2b8a3e; border-color: #2b8a3e; color: #fff; }
.btn-check:checked + .cf-blur, .btn-check:checked + .cf-warn { background: #e67700; border-color: #e67700; color: #fff; }
.btn-check:checked + .cf-hide { background: #c92a2a; border-color: #c92a2a; color: #fff; }
.pinglist-box .bi-megaphone { color: var(--accent); }

/* ───────── Content warnings ───────── */
.warning-gate { max-width: 34rem; margin-top: 3rem; padding: 2rem; }
.warning-icon { font-size: 2.5rem; color: #e0a100; }
.warning-text { white-space: pre-line; font-size: 1.05rem; }

/* ───────── Vault ───────── */
.vault-locked { padding: 3rem 1.5rem; }
.vault-icon { font-size: 2.8rem; color: var(--accent); }
.vault-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.vault-upload { margin-bottom: 1rem; }
.vault-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
@media (min-width: 576px) { .vault-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .85rem; } }
@media (min-width: 1600px) { .vault-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }
.vault-tile { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.vault-tile a { display: block; overflow: hidden; background: var(--surface-2); }
.vault-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.vault-tile a:hover img { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: -2px; }
.vault-tile figcaption { display: flex; align-items: center; gap: .4rem; padding: .45rem .6rem; font-size: .82rem; min-height: 2.3rem; }
.vault-actions { margin-left: auto; display: flex; gap: .5rem; flex-shrink: 0; }
.vault-actions a, .vault-actions button { color: var(--muted); background: none; border: 0; padding: 0; line-height: 1; }
.vault-actions a:hover { color: var(--accent); }
.vault-actions button:hover { color: #dc3545; }
.vault-actions form { margin: 0; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(8, 8, 12, .92); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: calc(100vw - 7rem); max-height: 100vh; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 5rem); object-fit: contain; border-radius: 6px; }
.lightbox figcaption { color: #ddd; font-size: .9rem; margin-top: .6rem; text-align: center; }
.lightbox button { position: absolute; background: rgba(255,255,255,.1); color: #fff; border: 0; width: 3rem; height: 3rem; border-radius: 50%; font-size: 1.3rem; }
.lightbox button:hover { background: rgba(255,255,255,.22); }
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
@media (max-width: 575.98px) {
  .lightbox figure { max-width: 100vw; }
  .lb-prev, .lb-next { top: auto; bottom: 1rem; transform: none; }
}
body.lb-open { overflow: hidden; }

/* ───────── Character page on phones: compact header card, swipeable tabs ───────── */
@media (max-width: 767.98px) {
  .char-sidebar { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
  .char-sidebar > .thumb-frame.big { aspect-ratio: auto; height: 100%; min-height: 112px; }
  .char-sidebar > .char-info { padding: .75rem !important; }
  .char-sidebar h1 { font-size: 1.15rem; }
  .char-sidebar .char-meta dt:nth-of-type(n+4), .char-sidebar .char-meta dd:nth-of-type(n+4) { display: none; }
  .char-sidebar > :not(.thumb-frame):not(.char-info) { grid-column: 1 / -1; }
  .char-sidebar > .thumb-frame.big { grid-row: 1; grid-column: 1; }
  /* Name and details beside the picture, whatever comes between them in the page (the owner's
     "Set an icon" button goes underneath, full width). */
  .char-sidebar > .char-info { grid-row: 1; grid-column: 2; }
  .char-sidebar > .icon-edit-link { margin: .75rem .75rem; }
  .char-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .char-tabs::-webkit-scrollbar { display: none; }
  .char-tabs .nav-link { white-space: nowrap; padding: .45rem .7rem; }
  /* Fade the right edge so it's clear more tabs scroll into view. */
  .char-tabs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); padding-right: 1.5rem; }
}

/* Card grids: 2 columns on phones, then as many ~200px cards as fit (big screens get more). */
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
@media (min-width: 576px) { .card-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; } }
@media (min-width: 1600px) { .card-grid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); } }
@media (min-width: 576px) { .card-grid-lg { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
.card-grid > .col { width: auto; max-width: none; padding: 0; }

/* ───────── Narrow form pages (report, world edit, members) ───────── */
.narrow-page { max-width: 720px; margin: 0 auto; }
.narrow-page.wide { max-width: 980px; }

/* ───────── Search ───────── */
.nav-search { position: relative; display: flex; align-items: center; margin: .5rem 0; }
.nav-search i { position: absolute; left: .7rem; color: var(--muted); font-size: .85rem; pointer-events: none; }
.nav-search input { width: 100%; padding: .35rem .75rem .35rem 2rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: .9rem; }
.nav-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .2); }
/* A fixed width: growing on focus pushed the rest of the bar sideways. */
@media (min-width: 992px) { .nav-search { margin: 0 .75rem 0 0; } .nav-search input { width: 200px; } }
@media (min-width: 1200px) { .nav-search input { width: 260px; } }
/* Top bar labels stay on one line; below 992px they're in the menu instead. */
.topbar .nav-link { white-space: nowrap; }
/* Small laptops (992-1199px): labels without their icons, tighter spacing, so everything fits on one line. */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .topbar .navbar-nav.me-auto .nav-link .bi { display: none; }
  .topbar .navbar-nav .nav-link { padding-left: .45rem; padding-right: .45rem; }
  .topbar .navbar-brand { margin-right: .5rem; }
}
.search-bar .input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.search-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }
.search-side { display: flex; flex-wrap: wrap; gap: .5rem; }
.person-chip { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .8rem .3rem .3rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: .9rem; }
.person-chip:hover { border-color: var(--accent); }
.person-chip img, .person-chip .nav-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; font-size: .8rem; }
.person-chip > .bi { width: 28px; text-align: center; color: var(--accent); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-cloud .tag-badge { font-size: .9rem; padding: .4em .7em; text-decoration: none; }
a.tag-badge { text-decoration: none; }
a.tag-badge:hover { background: rgba(var(--accent-rgb), .25); }
.tag-on { background: var(--accent); color: var(--on-accent); }
.tag-on:hover { background: var(--accent-hover) !important; color: var(--on-accent); }

/* ───────── Comments ───────── */
.comments-h { font-size: 1.1rem; font-weight: 650; margin-bottom: .75rem; }
.comment-thread { padding: .9rem 0; border-top: 1px solid var(--border); }
.comment-thread:first-of-type { border-top: 0; }
.comment { display: flex; gap: .75rem; scroll-margin-top: 80px; }
.comment:target { background: rgba(var(--accent-rgb), .08); border-radius: 12px; box-shadow: 0 0 0 6px rgba(var(--accent-rgb), .08); }
.comment-avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; text-decoration: none; }
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; font-size: .92rem; }
.comment-author { font-weight: 650; color: var(--text); text-decoration: none; }
.comment-author:hover { color: var(--accent); }
.comment-time { color: var(--muted); font-size: .8rem; text-decoration: none; }
.owner-badge { background: rgba(var(--accent-rgb), .15); color: var(--accent); font-weight: 600; font-size: .7rem; }
.comment-body { margin-top: .2rem; overflow-wrap: anywhere; }
.comment-body p { margin-bottom: .4rem; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body blockquote { border-left: 3px solid var(--border); padding-left: .75rem; color: var(--muted); margin: .4rem 0; }
.comment-body pre { background: var(--surface-2); padding: .5rem .75rem; border-radius: 8px; white-space: pre-wrap; }
.comment-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .25rem 1rem; margin-top: .35rem; font-size: .82rem; }
.comment-actions form { margin: 0; }
.comment-more { flex-basis: auto; }
.comment-more[open] { flex-basis: 100%; }
.comment-more > summary, .comment-link { color: var(--muted); cursor: pointer; list-style: none; background: none; border: 0; padding: 0; font-size: .82rem; text-decoration: none; }
.comment-more > summary::-webkit-details-marker { display: none; }
.comment-more > summary:hover, .comment-link:hover { color: var(--accent); }
.comment-replies { margin: .75rem 0 0 calc(38px + .75rem); padding-left: .9rem; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: .9rem; }
.comment-replies .comment-avatar { flex-basis: 30px; width: 30px; height: 30px; font-size: .8rem; }
@media (max-width: 575.98px) { .comment-replies { margin-left: .5rem; padding-left: .6rem; } }
.comment.is-deleted .comment-avatar { opacity: .35; }

/* ───────── Worlds ───────── */
.world-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
@media (min-width: 768px) { .world-grid { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); } }
.world-card { display: flex; gap: .9rem; align-items: center; margin: 0; color: var(--text); text-decoration: none; transition: border-color .15s; }
.world-card:hover { border-color: var(--accent); }
.world-mark { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), rgba(var(--accent-rgb), .55)); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; }
.world-card-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.world-name { font-weight: 650; font-size: 1.05rem; }
.world-header { flex-wrap: wrap; }
.world-mark-big { border-radius: 22px !important; background: linear-gradient(135deg, var(--accent), rgba(var(--accent-rgb), .55)) !important; }
.member-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; }
.member-list a { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; min-width: 0; }
.member-list .nav-avatar { width: 28px; height: 28px; font-size: .8rem; }
.member-list .badge { margin-left: auto; }

/* ───────── Wishlist & transfers ───────── */
.wish-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
@media (min-width: 576px) { .wish-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.wish-item { margin: 0; padding: .75rem; display: flex; flex-direction: column; }
.wish-card > .char-card, .wish-card > * { margin: 0; }
.wish-want { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; text-align: center; min-height: 150px; border-radius: 12px; background: var(--surface-2); padding: 1rem; }
.wish-want .bi { font-size: 2rem; color: var(--accent); }
.transfer-box > summary { cursor: pointer; }
.offer-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.offer-row:first-child { border-top: 0; padding-top: 0; }
.offer-row:last-child { padding-bottom: 0; }

/* ───────── Reports ───────── */
.report-row.is-closed { opacity: .65; }
.report-reason { white-space: pre-wrap; color: var(--muted); }
.comment-form .btn { white-space: nowrap; flex-shrink: 0; }

/* A section you jumped to from the sidebar glows briefly when the page gets there. */
.settings-section.just-arrived > .settings-h { animation: arrive-glow 1.4s ease-out; border-radius: 10px; }
@keyframes arrive-glow { 0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .0); background: rgba(var(--accent-rgb), .0); }
  15% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), .25); background: rgba(var(--accent-rgb), .14); }
  100% { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); background: rgba(var(--accent-rgb), 0); } }
@media (prefers-reduced-motion: reduce) { .settings-section.just-arrived > .settings-h { animation: none; } }
.partial-badge, .chip-partial { background: #e8862c !important; color: #fff !important; font-weight: 700; }
.chip-partial { font-size: .68rem; padding: 0 7px; }
.cf-confirm { margin: -.2rem 0 .4rem; padding-left: 2.2rem; }
.rating-defs dt { font-weight: 600; margin-top: .3rem; }
.rating-defs dd { margin: 0; color: var(--muted); }
/* Personal info on profiles */
.about-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem 1.25rem; margin: 0; }
.about-list dt { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.about-list dd { margin: 0; overflow-wrap: anywhere; }

/* ───────── Stats ───────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.stat-tile { margin: 0; display: flex; flex-direction: column; gap: .1rem; position: relative; color: var(--text); text-decoration: none; }
a.stat-tile:hover { border-color: var(--accent); }
.stat-n { font-size: 1.9rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: .85rem; }
.stat-d { color: var(--muted); font-size: .75rem; }
.stat-icon { position: absolute; top: .9rem; right: 1rem; color: var(--muted); opacity: .6; }
.chart { margin: 0; }
.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-top: 1.2rem; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; min-width: 0; cursor: default; }
.bar-col:hover { background: rgba(var(--accent-rgb), .06); border-radius: 6px 6px 0 0; }
.bar { width: min(70%, 36px); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-val { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.bar-label { position: absolute; bottom: -1.3rem; font-size: .7rem; color: var(--muted); white-space: nowrap; }
.chart .bar-chart { margin-bottom: 1.4rem; }
.hbar-list { display: flex; flex-direction: column; gap: .45rem; }
.hbar { display: grid; grid-template-columns: minmax(0, 8rem) 1fr 2.5rem; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-size: .9rem; }
.hbar:hover .hbar-label { color: var(--accent); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-list { padding-left: 1.2rem; }
.rank-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .25rem 0; }
@media (min-width: 576px) { .card-grid-sm { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.vault-locked form .btn { white-space: nowrap; }

/* Two-factor */
.otp-input { font-family: ui-monospace, monospace; letter-spacing: .2em; }
.tf-steps li { margin-bottom: 1rem; }
.tf-qr { display: inline-block; padding: 8px; background: #fff; border-radius: 10px; line-height: 0; }
.tf-qr svg { width: 220px; height: 220px; }
.tf-secret { font-size: 1rem; letter-spacing: .08em; word-break: break-all; }
.tf-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem 1rem; list-style: none; padding: 1rem;
  border: 1px dashed var(--muted); border-radius: 10px; margin-bottom: 1rem; }
.tf-codes code { font-size: 1rem; color: var(--text); }
@media print { .topbar, .site-footer, .tf-codes ~ div { display: none !important; } }

/* Recent images: one row, as many as fit; the grid's extra rows collapse to nothing. */
.recent-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); grid-template-rows: auto;
  grid-auto-rows: 0; column-gap: .5rem; row-gap: 0; overflow: hidden; }
.recent-item { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; }
.recent-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (min-width: 768px) { .recent-strip { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); } }
@media (min-width: 1400px) { .recent-strip { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); } }

/* Tag manager */
.tag-merge-bar { position: sticky; bottom: .75rem; z-index: 5; box-shadow: 0 6px 24px rgba(0,0,0,.12); }

/* Live updates */
.icon-btn .count[hidden] { display: none; }
.live-bar { display: block; margin: 0 auto .75rem; border-radius: 999px; grid-column: 1 / -1; }

/* @mentions */
a.mention { font-weight: 600; text-decoration: none; background: rgba(var(--accent-rgb), .12); border-radius: 4px; padding: 0 .2em; }

.rank-cols { columns: 16rem; column-gap: 3rem; }
.rank-cols li { max-width: 22rem; }
.rank-cols li { break-inside: avoid; }

/* Terms / privacy */
.legal-doc h1 { font-size: 1.6rem; margin-bottom: 1rem; }
.legal-doc h2 { font-size: 1.15rem; margin-top: 1.6rem; }
.legal-doc li { margin-bottom: .3rem; }

/* Share links */
.share-img { max-width: 100%; max-height: 80vh; border-radius: 10px; }
.site-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem 2rem; }
.site-setting .input-group { max-width: 16rem; }
.upload-note { margin-top: .35rem; font-size: .85rem; color: #b8860b; }
[data-bs-theme="dark"] .upload-note { color: #f0c36d; }

/* ───────── Icon editor ───────── */
.icon-previews { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.crop-preview.icon-pv-sidebar { width: 180px; height: 180px; }
.crop-preview.icon-pv-card { width: 120px; height: 120px; border-radius: 10px; }
.crop-preview.icon-pv-list { width: 40px; height: 40px; border-radius: 8px; }
.icon-current { width: 100%; max-width: 260px; border-radius: 14px; border: 1px solid var(--border); }
.icon-saved-small { width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--border); }
.icon-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: .6rem; }
.icon-choice { position: relative; margin: 0; padding: 0; cursor: pointer; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: none; }
.icon-choice img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.icon-choice:hover, .icon-choice:focus-visible { border-color: var(--accent); }
.icon-choice-busy { position: absolute; inset: 0; display: none; place-items: center; background: rgba(0, 0, 0, .5); color: #fff; }
.icon-choice.busy { border-color: var(--accent); }
.icon-choice.busy .icon-choice-busy { display: grid; }
form.is-busy .icon-choice:not(.busy) { opacity: .5; cursor: progress; }
.upload-panel { transition: outline-color .15s; outline: 2px dashed transparent; outline-offset: -2px; }
.upload-panel.drop-over { outline-color: var(--accent); background: rgba(var(--accent-rgb), .06); }
.upload-chosen { display: grid; gap: .4rem; margin: .5rem 0 0; max-height: 22rem; overflow-y: auto; }
.upload-chosen-item { display: flex; align-items: center; gap: .6rem; padding: .3rem; border-radius: .5rem; background: rgba(var(--accent-rgb), .04); }
.upload-chosen-item img { width: 48px; height: 48px; object-fit: cover; border-radius: .35rem; flex: none; }
.upload-chosen-ph { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: .35rem; background: var(--surface-2); color: var(--muted); font-size: 1.3rem; }
.upload-chosen-info { flex: 1; min-width: 0; }
.upload-chosen-info .upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-dup { color: var(--bs-warning-text-emphasis); }
.upload-chosen-item.is-dup { outline: 1px solid var(--bs-warning-border-subtle); }
.checklist-steps { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.checklist-steps li { display: flex; gap: .5rem; align-items: flex-start; }
.checklist-steps .bi { color: var(--accent); margin-top: .1rem; }
.checklist-steps .is-done .checklist-title { color: var(--bs-secondary-color); text-decoration: line-through; }
.checklist-title { font-weight: 600; }
.image-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; text-align: center; }
.icon-edit-link { display: block; margin: .75rem 1rem 0; }

/* ───────── Folder cards on profiles ───────── */
.grid-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .9rem; }
.grid-path { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.folder-card .char-thumb { background: linear-gradient(135deg, rgba(var(--accent-rgb), .22), rgba(var(--accent-rgb), .06)); }
.folder-card .thumb-empty .bi { font-size: 3rem; color: var(--accent); }
.folder-count { background: rgba(0, 0, 0, .6) !important; color: #fff !important; }
.folder-edit .form-select { max-width: 14rem; }

/* Icon buttons in the top bar get a text label inside the folded phone/tablet menu. */
.menu-label { display: none; }
@media (max-width: 991.98px) {
  .topbar .icon-btn { width: auto; justify-content: flex-start; gap: .6rem; padding: 0 .5rem; color: var(--muted); }
  .topbar .icon-btn .menu-label { display: inline; font-size: 1rem; }
  .topbar .icon-btn .count { position: static; margin-left: .25rem; }
}

/* Radio lists for choices whose labels are sentences (they wrap, unlike a dropdown). */
.choice-list { margin: 0; padding: 0; border: 0; }
.choice-list legend { float: none; width: auto; margin-bottom: .35rem; font-size: inherit; }
.choice-list .form-check { margin-bottom: .3rem; }
/* "Only people I choose": its lists/people box only while that choice is ticked. */
.access-choice:not(:has(input[value="custom"]:checked)) + .picker-people { display: none; }

/* Admin tables on phones: each row becomes a small card with labelled fields (no sideways scrolling). */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
  .table-stack td { border: 0; padding: .15rem 0; text-align: left !important; }
  .table-stack td[data-label]:not([data-label=""])::before { content: attr(data-label); display: inline-block; min-width: 7.5rem; color: var(--muted); font-size: .8rem; }
  .table-stack td:first-child { font-weight: 600; }
  .table-stack td:first-child::before { display: none !important; }
  /* Admin section links: compact so they take two rows, not four. */
  .nav-pills .nav-link { padding: .3rem .6rem; font-size: .9rem; }
}

/* Settings → Storage: recently deleted list */
.trash-item { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--bs-border-color); }
.trash-item:first-child { border-top: 0; }
.trash-thumb { width: 56px; height: 56px; border-radius: .4rem; object-fit: cover; flex: none; background: var(--bs-tertiary-bg); }
.trash-thumb-empty { display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--bs-secondary-color); }
.trash-body { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.trash-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Gallery upload with per-file progress */
.upload-steps { padding-left: 1.2rem; margin-bottom: .75rem; }
.upload-list { margin: .5rem 0 0; }
.upload-item { padding: .4rem 0; border-top: 1px solid var(--bs-border-color); }
.upload-line { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.upload-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.upload-state { margin-left: auto; }
.upload-item[data-state="failed"] .upload-state { color: var(--bs-danger-text-emphasis); }
.upload-item[data-state="done"] .progress-bar { background: var(--bs-success); }
.upload-item[data-state="failed"] .progress { display: none; }
.upload-progress { height: .35rem; margin-top: .3rem; }
.upload-progress .progress-bar { transition: width .2s linear; }
/* Server-side processing has no measurable progress: a slow pulse says "still working". */
.upload-processing .progress-bar { animation: upload-pulse 1.4s ease-in-out infinite; }
@keyframes upload-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .upload-progress .progress-bar { transition: none; }
  .upload-processing .progress-bar { animation: none; opacity: .7; }
}

/* Gallery sections */
.gallery-sections { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.gallery-group + .gallery-group { margin-top: 1.5rem; }
.gallery-group-title { margin-bottom: .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--bs-border-color); }
.gallery-group { scroll-margin-top: 5rem; }
.gallery-caption { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* Organise images */
.organise-row { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: .6rem; }
.organise-side { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding-top: .25rem; flex: none; }
.organise-sel { width: 1.25rem; height: 1.25rem; margin: 0; }
.organise-handle { cursor: grab; touch-action: none; color: var(--bs-secondary-color); padding: .25rem .35rem; }
.organise-handle:hover, .organise-handle:focus-visible { color: var(--bs-body-color); }
.organise-row.dragging { outline: 2px dashed var(--accent); opacity: .85; }
.organise-row.dragging .organise-handle { cursor: grabbing; }
.organise-row.selected { outline: 2px solid var(--accent); }
.organise-thumb-wrap { flex: none; margin: 0; cursor: pointer; }
.bulk-panel { margin-bottom: .75rem; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.bulk-actions details { min-width: 0; }
.bulk-actions details[open] { flex-basis: 100%; }
.bulk-actions summary { font-size: .875rem; cursor: pointer; }
.organise-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: .4rem; flex: none; }
.organise-fields { flex: 1; min-width: 0; }
.organise-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.organise-pos { width: 4.5rem; }
.organise-save { position: sticky; bottom: 0; padding: .6rem 0; background: var(--bs-body-bg); }
@media (max-width: 575.98px) {
  .organise-row { flex-direction: column; }
  .organise-side { flex-direction: row; }
  .organise-thumb { width: 72px; height: 72px; }
}

/* Who can see this */
.access-summary { display: grid; grid-template-columns: minmax(10rem, 14rem) 1fr; gap: .5rem 1rem; }
.access-summary dt { font-weight: 600; }
.access-summary dd { margin: 0; }
@media (max-width: 575.98px) { .access-summary { grid-template-columns: 1fr; } .access-summary dd { margin-bottom: .4rem; } }
.access-checks li, .access-images li { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .4rem; }
.access-checks .ok > i, .access-images .ok strong { color: var(--bs-success-text-emphasis); }
.access-checks .no > i, .access-images .no strong { color: var(--bs-danger-text-emphasis); }
.access-images img { width: 48px; height: 48px; object-fit: cover; border-radius: .3rem; flex: none; }
.access-images .no img { opacity: .45; }

/* Keyboard focus: always visible, on everything that can be focused. */
.skip-link { position: absolute; left: .75rem; top: -3rem; z-index: 2000; padding: .5rem .9rem; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: .5rem; }
main:focus { outline: none; }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:not([tabindex="-1"]):focus-visible,
.char-card:focus-visible, .settings-link:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.form-check-input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.topbar .nav-link[aria-current="page"] { color: var(--accent); font-weight: 600; }
.form-check-input[type=checkbox]:indeterminate { background-color: var(--accent); border-color: var(--accent); }
/* (Radio buttons with none chosen also count as :indeterminate, so the rule above is checkboxes only.) */
.feedback-message { white-space: pre-wrap; }

/* ───────── Helpdesk ───────── */
.wide-ish { max-width: 52rem; }
.ticket-list { display: grid; gap: .5rem; }
.ticket-row { display: flex; align-items: center; gap: .75rem; margin: 0; color: inherit; text-decoration: none; }
.ticket-row:hover, .ticket-row:focus-visible { border-color: var(--accent); }
.ticket-row.is-closed { opacity: .7; }
.ticket-kind-icon { font-size: 1.3rem; color: var(--accent); flex: none; }
.ticket-main { flex: 1; min-width: 0; }
.ticket-subject { font-weight: 600; overflow-wrap: anywhere; }
.ticket-title { overflow-wrap: anywhere; }
.ticket-kinds { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.ticket-kind-choice { display: flex; gap: .6rem; align-items: center; padding: .6rem .75rem; border: 1px solid var(--bs-border-color); border-radius: .6rem; cursor: pointer; margin: 0; }
.ticket-kind-choice:has(input:checked) { border-color: var(--accent); background: rgba(var(--accent-rgb), .06); }
.ticket-kind-choice .form-check-input { margin-top: 0; flex: none; }
.ticket-kind-choice .bi { color: var(--accent); }
.ticket-thread { display: grid; gap: .6rem; margin-bottom: 1rem; }
.ticket-msg { border: 1px solid var(--bs-border-color); border-radius: .75rem; padding: .7rem .9rem; background: var(--bs-body-bg); }
.ticket-msg.from-staff { border-left: 3px solid var(--accent); }
.ticket-msg.from-member { border-left: 3px solid var(--bs-secondary-color); }
.ticket-msg.is-note { background: var(--bs-warning-bg-subtle); border-color: var(--bs-warning-border-subtle); }
.ticket-msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.ticket-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-event { padding: 0 .9rem; }
.ticket-reply:has(#mode-note:checked) { background: var(--bs-warning-bg-subtle); }
.ticket-tabs { display: flex; flex-wrap: wrap; gap: .35rem; }
.ticket-table td, .ticket-table th { padding: .55rem .75rem; }
.ticket-table tr.needs-staff td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.tc-num { display: none; }
@media (max-width: 767.98px) {
  .ticket-table thead, .ticket-table .tc-id { display: none; }
  .ticket-table, .ticket-table tbody, .ticket-table tr { display: block; }
  .ticket-table tr { padding: .65rem .85rem; border-bottom: 1px solid var(--bs-border-color); }
  .ticket-table td { display: block; padding: .1rem 0 !important; border: 0; }
  .ticket-table td.tc-inline { display: inline-block; margin: .3rem .5rem .1rem 0; }
  .ticket-table td.tc-labelled { display: inline-block; margin-right: .9rem; }
  .ticket-table td.tc-labelled::before { content: attr(data-label) ": "; color: var(--bs-secondary-color); }
  .ticket-table .tc-num { display: inline; }
  .ticket-table tr.needs-staff { box-shadow: inset 3px 0 0 var(--bs-danger); }
  .ticket-table tr.needs-staff td:first-child { box-shadow: none; }
}

/* Phones and tablets: the opened menu (with the account menu inside it) never runs past the bottom
   of the screen. It scrolls on its own, without moving the page behind it. */
@media (max-width: 991.98px) {
  .topbar .navbar-collapse { max-height: calc(100dvh - 4.25rem); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
}

/* Browse header: title and filter link on one line, sort buttons underneath on phones. */
.browse-head { flex-wrap: wrap; row-gap: .6rem; }
.browse-sort { margin-left: auto; }
@media (max-width: 575.98px) {
  .browse-sort { margin-left: 0; width: 100%; display: flex; }
  .browse-sort .btn { flex: 1 1 auto; white-space: nowrap; padding-left: .4rem; padding-right: .4rem; }
}
.welcome { background: linear-gradient(135deg, rgba(var(--accent-rgb), .12), rgba(var(--accent-rgb), .03)); }
.welcome p { max-width: 46rem; }

/* Image page: phones show the image, then its credits, then comments; wider screens put the
   credits and then the comments in a column beside the image. */
.image-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.image-layout > * { min-width: 0; }
@media (min-width: 992px) {
  .image-layout { grid-template-columns: minmax(0, 3fr) minmax(20rem, 1fr); grid-template-areas: "main side" "main comments"; grid-template-rows: auto 1fr; align-items: start; }
  .image-main { grid-area: main; }
  .image-side { grid-area: side; }
  .image-comments { grid-area: comments; }
}
/* Phones: table checkboxes and small text buttons get a thumb-sized target. */
@media (max-width: 767.98px) {
  td > .form-check-input, th > .form-check-input, td .form-check-input:only-child, th .form-check-input:only-child { width: 1.6rem; height: 1.6rem; margin: 0; }
  [data-select-group] { padding: .45rem .3rem !important; }
}
.auto-ping-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .35rem .75rem; align-items: center; margin-bottom: .4rem; }
@media (max-width: 575.98px) { .auto-ping-row { grid-template-columns: 1fr; } }
.list-row:target { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: .5rem; }
.checklist-next { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: .6rem; background: rgba(var(--accent-rgb), .07); }
.checklist-later li { margin-top: .2rem; }
.checklist-later .bi, .text-accent { color: var(--accent); }
.confirm-dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); max-width: 26rem; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.confirm-dialog p { margin-bottom: 1rem; }
/* Getting started: a plain checklist. */
.checklist-head { display: flex; align-items: center; gap: .6rem; }
.checklist-head h2 { white-space: nowrap; }
.checklist-progress { flex: 0 1 6rem; min-width: 3rem; height: .4rem; background: var(--surface-2); }
.checklist-progress .progress-bar { background: var(--accent); }
.checklist-items { display: grid; gap: .35rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.checklist-item { display: inline-flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.checklist-item .bi { color: var(--accent); font-size: 1.05rem; }
a.checklist-item { color: var(--text); text-decoration: none; }
a.checklist-item:hover, a.checklist-item:focus-visible { color: var(--accent); text-decoration: underline; }
.checklist-items .is-done .checklist-item { color: var(--muted); text-decoration: line-through; }
/* Form-wide actions that stay in view just above the site footer while a long form scrolls. */
.form-actions { position: sticky; bottom: calc(var(--footer-h) + env(safe-area-inset-bottom)); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin: 0 -.5rem; padding: .65rem .5rem; background: var(--bg); border-top: 1px solid var(--border); }
.danger-zone { border-color: rgba(220, 53, 69, .35); }
.profile-css > summary { cursor: pointer; }
.gallery-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.checklist-hide { padding: .3rem .4rem; margin: -.3rem -.4rem; }
/* Avatar dialog (character page and edit form) */
.avatar-dialog { width: min(52rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; box-shadow: var(--shadow); }
.avatar-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.avatar-dialog[open] { display: flex; flex-direction: column; }
.ae-head, .ae-foot { display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; }
.ae-head { border-bottom: 1px solid var(--border); justify-content: space-between; }
.ae-foot { border-top: 1px solid var(--border); justify-content: flex-end; }
.ae-error { margin: .75rem 1rem 0; }
.ae-body { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1rem; padding: 1rem; overflow-y: auto; }
.ae-stage { min-height: 16rem; max-height: 26rem; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.ae-stage img { display: block; max-width: 100%; max-height: 26rem; }
.ae-previews { display: flex; align-items: flex-end; gap: .6rem; margin-bottom: .75rem; }
.ae-pv-big { width: 6rem; height: 6rem; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.ae-pv-small { width: 2.5rem; height: 2.5rem; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.ae-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; max-height: 16rem; overflow-y: auto; }
.ae-thumb { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; }
.ae-thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.ae-thumb[aria-pressed="true"], .ae-thumb:hover, .ae-thumb:focus-visible { border-color: var(--accent); }
@media (max-width: 575.98px) { .ae-body { grid-template-columns: 1fr; } .ae-stage { height: min(80vw, 22rem); min-height: 0; max-height: none; } .ae-stage img { max-height: 100%; } .ae-gallery { max-height: none; overflow-y: visible; } }
/* New character form: avatar crop under the file field */
.inline-crop { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem; margin-top: .5rem; }
.crop-thumb { position: relative; padding: 0; border: 0; background: none; border-radius: 12px; flex: none; }
.inline-crop-preview { display: block; width: 6rem; height: 6rem; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.crop-thumb-edit { position: absolute; right: -.4rem; bottom: -.4rem; width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: .8rem; border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.crop-thumb:hover .crop-thumb-edit, .crop-thumb:focus-visible .crop-thumb-edit { filter: brightness(1.15); }
.crop-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Phones: the cropper under the field, full width and tall enough to work with a finger. */
.inline-crop-stage { order: -1; width: 100%; height: min(85vw, 24rem); background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.inline-crop-stage img { display: block; max-width: 100%; max-height: 100%; }
/* Wide screens: a floating cropper window, dragged by its title bar. */
.crop-pop { position: fixed; z-index: 1080; width: min(44rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 1rem 3rem rgba(0,0,0,.35); }
.crop-pop[hidden] { display: none; }
.crop-pop-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border);
  cursor: move; user-select: none; touch-action: none; }
.crop-pop-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding: 1rem; min-height: 0; }
.crop-pop-stage { height: min(30rem, calc(100dvh - 10rem)); background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.crop-pop-stage img { display: block; max-width: 100%; max-height: 100%; }
.crop-pop-side { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.crop-pop-side .cp-big { display: block; width: 8rem; height: 8rem; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.crop-pop-side .cp-small { display: block; width: 3rem; height: 3rem; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.crop-pop-foot { display: flex; justify-content: flex-end; padding: .6rem .9rem; border-top: 1px solid var(--border); }

/* The rating picker on its own: legends otherwise take Bootstrap's 1.5rem heading size. */
.rating-picker > legend { font-size: inherit; float: none; width: auto; }
/* Inside a section that already says "Content rating": no second box or title. */
.rating-plain .rating-picker { border: 0; padding: 0; }
.rating-plain .rating-picker > legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rating-plain .rating-picker > .form-text { display: none; }
.choice-list legend.small { font-size: .875em; }

/* ───────── Favourite lists (the star menu on a character) ───────── */
.fav-menu { position: relative; }
.fav-menu > summary { list-style: none; }
.fav-menu > summary::-webkit-details-marker { display: none; }
.fav-caret { font-size: .65em; opacity: .75; }
.fav-pop { position: absolute; z-index: 1050; top: calc(100% + .35rem); left: 0; width: 15rem; max-width: calc(100vw - 2rem);
  padding: .75rem; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .5rem;
  box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.18); }
.fav-pop fieldset { margin: 0; }
.fav-lists { max-height: 14rem; overflow-y: auto; }
.fav-lists .form-check { margin-bottom: .2rem; }
.fav-lists .form-check-label { overflow-wrap: anywhere; }
.fav-manage { position: relative; }
.fav-manage > summary { list-style: none; }
.fav-manage > summary::-webkit-details-marker { display: none; }
.fav-pop-end { left: auto; right: 0; }
/* Phones: zoom slider under the pan-and-zoom cropper. */
.crop-zoom { display: flex; align-items: center; gap: .6rem; width: 100%; order: -1; padding: .25rem .25rem 0; color: var(--text-muted, var(--bs-secondary-color)); }
.crop-zoom[hidden] { display: none; }
.crop-zoom .form-range { flex: 1; }
.crop-zoom input[type=range] { height: 1.75rem; }
.ae-stage-wrap { min-width: 0; }
.crop-pop-foot { gap: 1rem; align-items: center; }
.crop-pop-foot .crop-zoom { flex: 1; width: auto; max-width: 24rem; margin-right: auto; padding: 0; }
.crop-pop-stage .cropper-container, .ae-stage .cropper-container { cursor: grab; }
.crop-pop-stage .cropper-container:active, .ae-stage .cropper-container:active { cursor: grabbing; }
/* Organise: the bulk action titles as a row of buttons; the open one's options show below it. */
.bulk-actions.tabbed { display: block; }
.bulk-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.bulk-tabs .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.bulk-tabs .btn-outline-danger.active { background: var(--bs-danger); border-color: var(--bs-danger); }
.bulk-actions.tabbed > details > summary { display: none; }
.bulk-actions.tabbed > details:not([open]) { display: none; }
.bulk-actions.tabbed > details[open] { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }

/* Art tab popup viewer. */
.art-viewer { width: min(72rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 0; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.art-viewer::backdrop { background: rgba(0, 0, 0, .75); }
.art-viewer[open] { display: flex; flex-direction: column; }
.av-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
.av-head .pill { margin: 0; }
.av-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 12rem; padding: .75rem 3.25rem; background: var(--surface-2); }
.av-blur { display: flex; align-items: center; justify-content: center; }
.av-edit { display: block; width: 100%; margin: .75rem 0 0; padding: .8rem 1rem; font-size: 1.15rem; }
.av-img { display: block; max-width: 100%; max-height: calc(100dvh - 9rem); object-fit: contain; border-radius: 8px; }
.av-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: grid; place-items: center; font-size: 1.1rem; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.av-nav:disabled { opacity: .35; }
.av-prev { left: .5rem; } .av-next { right: .5rem; }
.av-caption { padding: .6rem .9rem; }
@media (max-width: 575.98px) { .av-stage { padding: .5rem; } .av-nav { top: auto; bottom: .75rem; transform: none; } }
.art-viewer { overflow-y: auto; }
.art-viewer .av-img { max-height: min(70dvh, calc(100dvh - 12rem)); }
.av-info { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1.25rem; padding: 1rem; border-top: 1px solid var(--border); }
.av-details .credits { margin-bottom: 0; }
.av-comments .comments-h { font-size: 1.05rem; margin-top: 0; }
@media (max-width: 767.98px) { .av-info { grid-template-columns: 1fr; } }
.art-viewer > * { flex-shrink: 0; }
.comment-body img { max-width: 100%; max-height: 60dvh; height: auto; object-fit: contain; }

/* Notifications page: a picture for each, unread ones marked with a dot. */
.notif-item { display: flex; align-items: center; gap: .75rem; }
.notif-pic { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--text-muted, var(--bs-secondary-color)); }
.notif-pic.round { border-radius: 50%; }
.notif-pic img { width: 100%; height: 100%; object-fit: cover; }
.notif-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notif-time { flex: none; white-space: nowrap; }
.notif-item.unread .notif-text { font-weight: 600; }
.notif-item.unread .notif-text::before { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-right: .45rem; border-radius: 50%; background: var(--accent); vertical-align: middle; }
@media (max-width: 575.98px) { .notif-item { flex-wrap: wrap; } .notif-time { width: 100%; padding-left: 3.25rem; } }

/* Admin → Site settings → Emails: editor and live preview side by side. */
.email-tpl { padding: 1rem; margin-top: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.email-tpl-head { margin-bottom: .35rem; }
.email-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 992px) { .email-edit-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.email-code { font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 10rem; resize: vertical; tab-size: 2; }
.email-preview { display: block; width: 100%; height: 30rem; border: 1px solid var(--border); border-radius: 10px; background: #f3f0fa; }
.email-logo-thumb { height: 1.8rem; width: auto; border-radius: 4px; background: #fff; padding: 2px; }

/* Announcements */
.announce-banner { display: flex; align-items: center; gap: .85rem; border-left: 4px solid var(--accent); padding-top: .65rem; padding-bottom: .65rem; }
.announce-banner-link { text-decoration: none; color: inherit; }
.announce-banner-link:hover strong { text-decoration: underline; }
.announce-banner.is-hidden { display: none; }
.announce-close { flex: none; }
.announce-banner-icon { font-size: 1.4rem; color: var(--accent); flex: none; }
.announce-banner-text { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.announce-body { overflow-wrap: anywhere; }
.announce-body img { max-width: 100%; height: auto; border-radius: .5rem; }
.announce-body > :last-child { margin-bottom: 0; }
.announce-admin-list li { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.announce-admin-list li:last-child { border-bottom: 0; }

/* Admin */
.backup-details { display: inline; }
.backup-details summary { display: inline; cursor: pointer; color: var(--accent); }
.backup-details[open] { display: block; margin-top: .25rem; }
@media (max-width: 767.98px) {
  .admin-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; padding-bottom: .25rem; }
  .admin-tabs .nav-link { white-space: nowrap; }
}
.audit-entry { display: grid; grid-template-columns: 11rem 1fr; gap: .25rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.audit-entry:last-child { border-bottom: 0; }
.audit-what { min-width: 0; overflow-wrap: anywhere; }
.audit-raw summary { display: inline; cursor: pointer; margin-left: .35rem; }
.audit-raw[open] summary { display: block; margin: .25rem 0 0; }
.audit-raw pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; background: var(--surface-2); padding: .5rem; border-radius: .375rem; }
@media (max-width: 575.98px) { .audit-entry { grid-template-columns: 1fr; } }

/* Font Awesome in profile HTML: respect "reduce motion" (fa-spin, fa-beat and friends). */
@media (prefers-reduced-motion: reduce) {
  [class*="fa-spin"], [class*="fa-beat"], [class*="fa-bounce"], [class*="fa-fade"], [class*="fa-flip"], [class*="fa-shake"] { animation: none !important; }
}
