/* ============================================================
   KANAPURO — Character Library shared styles
   ============================================================ */

.character-category-section {
  margin-bottom: 2.25rem;
}

.character-category-heading {
  display: inline-block;
  font-family: var(--font-subhead);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  margin: 0 0 0.9rem;
}

.character-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* Plain, neutral card, same panel color as the rest of the site, NOT
   category-tied, that job now belongs to the name pill below. */
.character-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 10px;
  padding: 8px;
  gap: 8px;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.character-tile:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.character-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
}

/* The colored piece, a real pill with breathing room around the text,
   not text sitting flush against an edge. Falls back to a muted accent
   if a character's category is somehow missing entirely, so it never
   renders invisible. */
.character-tile .tile-name {
  display: inline-block;
  font-family: var(--font-subhead);
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  background: var(--moss);
  border-radius: 6px;
  padding: 0.38rem 0.85rem;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-grid-error {
  color: var(--muted);
  font-style: italic;
}

/* ============================================================
   Step 3 — character page layout (info card, description, gallery)
   ============================================================ */

.character-card-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2.5rem;
  margin: 1.5rem 0 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.character-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex: 1 1 300px;
  min-width: 0;
  max-width: 480px;
}
.character-header-text {
  min-width: 0;
  overflow: hidden;
}


.character-icon {
  width: 150px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: 10px;
  flex-shrink: 0;
}

.character-icon-crop-frame {
  display: block;
  width: 150px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.character-icon-crop-frame .character-icon {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
}

.character-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 0 1 auto;
}

.info-row {
  display: flex;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.info-label {
  min-width: 95px;
  flex-shrink: 0;
  color: var(--muted);
  font-family: var(--font-subhead);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding-top: 0.15rem;
}

.info-value {
  color: var(--ink);
}

/* Open space, this is genuinely just a normal content area, write
   whatever you want in it, plain paragraphs or your own HTML. */
.character-description {
  margin-bottom: 2.25rem;
  line-height: 1.6;
}

/* "Gallery" label lives inside the controls bar now */
.char-controls-gallery-heading {
  font-family: var(--font-subhead);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin-right: auto;
}

/* "Also appears in" — sits below the gallery, hidden entirely (via the
   [hidden] attribute set in HTML/JS) when there's nothing to show. */
.character-also-appears-section {
  margin-top: 2.25rem;
}

.character-also-appears-section h2 {
  display: none;
}

.also-appears-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.also-appears-controls {
  margin-bottom: 0;
}

.also-appears-list {
  flex-wrap: wrap;
  min-width: 0;
}

.also-appears-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
}

.also-appears-name {
  min-width: 0;
}

.also-appears-count {
  display: inline-grid;
  place-items: center;
  min-width: 2.25rem;
  min-height: 1.3rem;
  padding: 0.08rem 0.35rem;
  border: 1px solid currentColor;
  border-radius: 0;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.18);
}

/* ============================================================
   Gallery grid — just images, no metadata visible
   ============================================================ */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
}

.gallery-thumb {
  display: block;
  padding: 0;
  border: none;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  transition: transform 0.12s ease, filter 0.12s ease;
  position: relative;
}

.gallery-thumb:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.gallery-thumb img,
.gallery-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb img,
.gallery-thumb canvas {
  clip-path: inset(0 round 8px);
}

.gallery-thumb--embed::before,
.gallery-thumb--embed::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
}

.gallery-thumb--embed::before {
  width: 3.4rem;
  height: 3.4rem;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.54);
}

.gallery-thumb--embed::after {
  transform: translate(-35%, -50%);
  border-top: 0.8rem solid transparent;
  border-bottom: 0.8rem solid transparent;
  border-left: 1.2rem solid rgba(255, 255, 255, 0.9);
}


.gallery-watermark-canvas {
  display: block;
}
.gallery-empty,
.gallery-error {
  color: var(--muted);
  font-style: italic;
}

/* ============================================================
   Lightbox overlay — near-fullscreen, arrows outside the panel
   ============================================================ */

.gallery-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.92);
  overflow-y: auto;
  padding: 2rem 0;
}

.gallery-lightbox.is-open {
  display: block;
}


/* Arrows outside the panel, in the black side margins */
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 2.4rem;
  line-height: 1;
  width: 3rem;
  padding: 1.4rem 0;
  text-align: center;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.12s ease;
  z-index: 2;
}

.lightbox-prev { left: 0.75rem; }
.lightbox-next { right: 0.75rem; }

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Inner panel — centered in the scrollable overlay, no height cap */
.lightbox-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  width: calc(100vw - 8rem); /* 4rem arrow zone each side */
  max-width: 1400px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

/* Image area — no independent scroll; the whole overlay scrolls instead */
.lightbox-image-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #080808;
  position: relative;
  overflow: hidden;
}

.lightbox-img,
.lightbox-watermark-canvas,
.lightbox-embed {
  display: block;
  /* Width-constrained to the panel so you never scroll horizontally,
     but height is completely uncapped — full native resolution. */
  max-width: 100%;
  height: auto;
}

.lightbox-embed {
  width: min(100%, 960px);
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

.lightbox-embed--portrait {
  width: min(100%, 430px);
  aspect-ratio: 9 / 16;
}

.lightbox-img[hidden],
.lightbox-watermark-canvas[hidden],
.lightbox-embed[hidden] {
  display: none;
}

/* Metadata panel — compact single row of three columns */
.lightbox-panel {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  min-height: 0;
}

.lightbox-col {
  flex: 1;
  padding: 0.7rem 1.1rem;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.lightbox-col:last-child {
  border-right: none;
}

.lightbox-col h3 {
  font-family: var(--font-subhead);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.lightbox-detail-row,
.lightbox-credit-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.25rem;
}

.lightbox-label {
  font-family: var(--font-subhead);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.lightbox-value {
  font-size: 0.85rem;
  color: var(--ink);
}

/* Artist credit */
.lightbox-artist-link,
.lightbox-artist-name {
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
}

.lightbox-artist-link {
  color: var(--moss);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lightbox-artist-link:hover {
  filter: brightness(1.2);
}

.lightbox-role {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Character tag pills — colored by category via JS */
.lightbox-character-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-content: flex-start;
}

.lightbox-char-pill {
  display: inline-block;
  font-family: var(--font-subhead);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: var(--moss);
  color: #fff;
  text-decoration: none;
  border: none;
  transition: filter 0.1s ease;
}

.lightbox-char-pill:hover {
  filter: brightness(1.15);
}

/* Close button and open-in-new-tab button — top-right corner */
.lightbox-close,
.lightbox-open-tab,
.lightbox-download-raw {
  position: absolute;
  top: 0.6rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.lightbox-close { right: 0.6rem; }
.lightbox-open-tab { right: 2.8rem; }
.lightbox-download-raw { right: 5rem; }

.lightbox-close:hover,
.lightbox-open-tab:hover,
.lightbox-download-raw:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}


.lightbox-open-tab[hidden],
.lightbox-download-raw[hidden] {
  display: none;
}
/* Lightbox footer — gallery link + image counter */
.lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1.1rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  font-size: 0.78rem;
}

.lightbox-gallery-link {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-subhead);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  transition: color 0.1s ease;
}

.lightbox-gallery-link:hover {
  color: var(--moss);
}

.lightbox-counter {
  color: var(--muted);
  font-family: var(--font-subhead);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

/* Central gallery lede text */
.gallery-lede {
  color: var(--muted);
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}


/* ============================================================
   Controls bar — shared between character grid and gallery
   ============================================================ */

.char-controls-bar {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 1.5rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.gallery-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1.5rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* Row 1: search / sort / random all on one line */
.char-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.3rem 0;
}

.char-controls-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.char-controls-label {
  font-family: var(--font-subhead);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

/* View-mode toggle buttons */
.char-ctrl-btn {
  font-family: var(--font-subhead);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.char-ctrl-btn:hover {
  background: var(--line);
  color: var(--ink);
}

.char-ctrl-btn.is-active {
  background: var(--moss);
  color: #fff;
  border-color: transparent;
}

/* Sort / filter selects */
.char-sort-select {
  font-family: var(--font-subhead);
  font-size: 0.8rem;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

/* Search box */
.char-search-group {
  flex: 0 1 220px;
}

.char-search-input {
  font-family: var(--font-subhead);
  font-size: 0.8rem;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  min-width: 120px;
}

.char-search-input::placeholder {
  color: var(--muted);
}

.character-grid-empty {
  color: var(--muted);
  font-style: italic;
}

/* Unsorted characters — loose tiles with no folder/heading, sitting
   directly on the page. A little breathing room before whatever
   comes after them (folder sections, or the folder-tile row). */
.char-unsorted-grid {
  margin-bottom: 2.25rem;
}


/* ============================================================
   Show more / show less toggle
   ============================================================ */

.char-show-more-btn {
  display: inline-block;
  margin-top: 0.6rem;
  font-family: var(--font-subhead);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.3rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.char-show-more-btn:hover,
.char-show-more-btn.is-expanded {
  background: var(--panel);
  color: var(--ink);
}


/* ============================================================
   Flat folder tile view
   ============================================================ */

/* Row of clickable folder tiles */
.char-folder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.char-folder-tile {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-subhead);
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  background: var(--moss); /* overridden by JS per-category */
  transition: filter 0.12s ease, transform 0.1s ease;
  user-select: none;
}

.char-folder-tile:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.char-folder-tile.is-open {
  outline: 3px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

.char-folder-name {
  line-height: 1;
}

/* Expanded character grid below the folder row */
.char-folder-panel {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.char-folder-panel[hidden] {
  display: none;
}

/* Random character button — sits right-aligned in the controls bar */
.char-random-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

.char-random-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ============================================================
   ADDITIONS — trade status, tags, subfolders, filter pills
   Append this block to the end of characters.css
   ============================================================ */

/* ------------------------------------------------------------
   Character tile image wrapper
   characters.js now wraps each tile image in a div (to allow the
   trade-status badge to sit on top of it). The old rule
   targeted ".character-tile img" directly — this keeps that
   sizing but moves it onto the wrapper, and re-points the
   image rule at a descendant selector.
   ------------------------------------------------------------ */

.character-tile-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.character-tile-img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
}

/* Small trade-status badge overlaid on a tile's image, bottom-left */
.char-tile-trade-badge {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  font-family: var(--font-subhead);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  line-height: 1.2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}


/* ------------------------------------------------------------
   Trade status badges on the character page — large, prominent,
   sit right next to the name.
   ------------------------------------------------------------ */

/* h1 sits on its own line; category badge + trade badges share the line below */
.character-header-text h1 {
  margin: 0 0 0.35rem;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

/* Trade status sits above the character name */
.character-header-text .character-category-heading {
  display: inline-flex;
  align-items: center;
  margin-right: 0.4rem;
  margin-bottom: 0;
  vertical-align: middle;
}

.character-trade-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.character-trade-status[hidden] {
  display: none;
}

.char-trade-badge {
  display: inline-block;
  font-family: var(--font-subhead);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  padding: 0.4rem 0.95rem;
  border-radius: 7px;
  line-height: 1.2;
}


/* ------------------------------------------------------------
   Tags on the character page — quiet, small, sit in the info list.
   ------------------------------------------------------------ */

.character-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.character-tags[hidden] {
  display: none;
}

.char-info-tag-pill {
  display: inline-block;
  font-family: var(--font-subhead);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.18rem 0.55rem;
  line-height: 1.3;
}


/* Show more/less toggle for character page tags */
.char-tags-toggle-btn {
  font-family: var(--font-subhead);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.18rem 0.55rem;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.char-tags-toggle-btn:hover {
  background: var(--line);
  color: var(--ink);
}



   (Row 2 / Row 3 — separate from the view/sort/search row)
   ------------------------------------------------------------ */

.char-filter-row {
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
  padding-bottom: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

/* Label group: the text label + optional OR button, fixed width so pills align */
.char-filter-label-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.char-tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.char-tag-pill {
  font-family: var(--font-subhead);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.char-tag-pill:hover {
  background: var(--line);
  color: var(--ink);
}

.char-tag-pill.is-active {
  background: var(--moss);
  color: #fff;
  border-color: transparent;
}

/* Trade-status pills get their color set inline via JS when active,
   so this just handles the resting state — same shape as tag pills. */
.char-trade-pill {
  /* inherits .char-tag-pill styling; nothing extra needed at rest */
}

/* AND/OR toggle button — same family as the view-mode toggle, but
   a fixed small width so it doesn't jump around when the label changes. */
.char-logic-btn {
  font-family: var(--font-subhead);
  font-size: 0.76rem;
  font-weight: 700;
  min-width: 2.6rem;
  text-align: center;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.char-logic-btn:hover {
  background: var(--line);
  color: var(--ink);
}

.char-logic-btn.is-active {
  background: var(--moss);
  color: #fff;
  border-color: transparent;
}


/* ------------------------------------------------------------
   Nested view — subfolders (child categories) and collapsed
   sections.
   ------------------------------------------------------------ */

/* Indent + slightly smaller heading for nested (child) categories,
   so the hierarchy reads visually without needing extra labels. */
.character-category-section--child {
  margin-left: 0;
  padding-left: 0;
  padding-top: 0.75rem;
  border-top: 1px dashed color-mix(in srgb, var(--wine) 28%, var(--line));
}

.character-category-section--child.character-category-section--collapsed-folder {
  margin-left: 0;
  padding-left: 0;
  border-top: 0;
}

.character-category-section--child > .character-category-heading {
  font-size: 0.78rem;
}

/* Folder description text under a category heading */
.character-category-description {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0 0 0.9rem;
  max-width: 640px;
}

.character-category-description--panel {
  margin-bottom: 1rem;
}

/* Collapsible heading — same pill look as a normal heading, but with
   a pointer cursor and a little disclosure arrow that flips on open. */
.character-category-heading.is-collapsible {
  position: relative;
  padding-right: 1.8rem;
}

.character-category-heading.is-collapsible::after {
  content: "▸";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

.character-category-heading.is-collapsible.is-open::after {
  transform: translateY(-50%) rotate(90deg);
}

.char-collapsed-content[hidden] {
  display: none;
}

/* Nested folder-tile rows inside an expanded flat-view panel
   (subfolders shown inside their parent's panel) */
.char-folder-row--nested {
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
/* ------------------------------------------------------------
   Breadcrumb
   ------------------------------------------------------------ */

.char-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  font-family: var(--font-subhead);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.char-breadcrumb-sep {
  color: var(--line);
  user-select: none;
}

.char-breadcrumb-crumb {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.char-breadcrumb-crumb:hover {
  color: var(--text);
}

.char-breadcrumb-current {
  color: var(--text);
}

/* Linked folder heading on the main index */
.character-category-heading--linked {
  text-decoration: none;
  transition: opacity 0.15s, transform 0.12s ease, filter 0.12s ease;
}

.character-category-heading--linked:not(.has-icon) {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.character-category-heading--linked:hover {
  opacity: 0.75;
  transform: translateY(-2px);
}

.character-category-heading--linked:not(.has-icon):hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.character-category-heading--linked.has-icon:hover {
  opacity: 1;
  filter: brightness(1.08);
}

/* When the folder has an icon, the whole heading becomes a single
   uniformly-colored box — no separate neutral card and pill, both the
   image frame and the label share the exact same category color — sized
   roughly like two character tiles side by side, with a wide image. */
.character-category-heading--linked.has-icon {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 376px;
  max-width: 100%;
  padding: 0.5rem;
  gap: 0.4rem;
  border-radius: 10px;
}

.char-folder-icon-wrap {
  width: 100%;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border-radius: 6px;
}

.character-category-heading--linked.has-icon .char-folder-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.character-category-heading--linked.has-icon .character-category-heading-label {
  display: block;
  padding: 0;
  text-align: center;
}

/* Folder page heading */
.char-folder-page-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: color 0.15s;
}

/* Collapsed root folders flow side-by-side like character tiles */
.char-collapsed-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2.25rem;
}
.char-collapsed-row--child {
  margin: 0 0 1rem;
}
.char-collapsed-row .character-category-section {
  margin-bottom: 0;
}

/* ---- Restore original character-site geometry ---- */
body.character-shell main.character-page {
  max-width: var(--max-width);
  padding: 3rem 1.5rem 5rem;
}

body.character-shell main.character-page::before {
  content: none;
  display: none;
}

body.character-shell main.character-page > h1:first-child {
  color: var(--ink);
  font-family: var(--font-subhead);
  font-size: 2.6rem;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 0.75rem;
  text-shadow: none;
}

body.character-shell .character-category-section {
  margin-bottom: 2.25rem;
}

body.character-shell .character-category-heading {
  display: inline-block;
  font-family: var(--font-subhead);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  margin: 0 0 0.9rem;
  box-shadow: none;
}

body.character-shell .character-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

body.character-shell .character-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 10px;
  padding: 8px;
  gap: 8px;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}

body.character-shell .character-tile:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

body.character-shell .character-tile img,
body.character-shell .character-tile-img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
}

body.character-shell .character-tile .tile-name {
  display: inline-block;
  width: auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-subhead);
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  background: var(--moss);
  border-radius: 6px;
  padding: 0.38rem 0.85rem;
  text-align: center;
  line-height: 1.25;
  box-shadow: none;
}

body.character-shell .character-card-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 2.5rem;
  margin: 1.5rem 0;
  padding: 0 0 1.5rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
}

body.character-shell .character-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
  flex: 1 1 300px;
  min-width: 0;
  max-width: 480px;
  text-align: left;
}

body.character-shell .character-header-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-align: left;
}

body.character-shell .character-header-text h1 {
  margin: 0 0 0.35rem;
  color: var(--ink);
  font-family: var(--font-subhead);
  font-size: 2.6rem;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  text-shadow: none;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

body.character-shell .character-header-text .character-category-heading {
  display: inline-flex;
  align-items: center;
  align-self: auto;
  margin-right: 0.4rem;
  margin-bottom: 0;
  vertical-align: middle;
  text-align: left;
}

body.character-shell .character-trade-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
  text-align: left;
}

body.character-shell .character-trade-status[hidden] {
  display: none;
}

body.character-shell .character-icon,
body.character-shell .character-icon-crop-frame {
  width: 150px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  flex-shrink: 0;
}

body.character-shell .character-icon-crop-frame {
  display: block;
  overflow: hidden;
}

body.character-shell .character-icon {
  object-fit: cover;
  object-position: center;
}

body.character-shell .character-icon-crop-frame .character-icon {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
}

body.character-shell .character-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 0 1 auto;
  align-self: center;
  justify-content: flex-start;
  min-width: 0;
  padding: 0;
  border: 0;
  text-align: left;
}

body.character-shell .info-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.6rem;
  padding: 0;
  border: 0;
  font-size: 0.9rem;
  text-align: left;
}

body.character-shell .info-label {
  min-width: 95px;
  flex-shrink: 0;
  padding-top: 0.15rem;
  color: var(--muted);
  font-family: var(--font-subhead);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-align: left;
  text-transform: uppercase;
}

body.character-shell .character-tags {
  margin-top: 0;
  padding-top: 0;
  border: 0;
}

body.character-shell .char-controls-bar {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 1.5rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
  text-align: left;
}

body.character-shell .gallery-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1.5rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
  text-align: left;
}

body.character-shell .char-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem 1rem;
  padding: 0.3rem 0;
}

body.character-shell .char-controls-group,
body.character-shell .char-filter-label-group,
body.character-shell .char-tag-pills {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
}

body.character-shell .char-tag-pills {
  flex-wrap: wrap;
  gap: 0.4rem;
}

body.character-shell .char-controls-label,
body.character-shell .char-controls-gallery-heading {
  font-family: var(--font-subhead);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

body.character-shell .char-controls-label {
  font-size: 0.72rem;
  text-transform: uppercase;
}

body.character-shell .char-controls-gallery-heading {
  width: auto;
  margin-right: auto;
  font-size: 0.9rem;
  color: var(--ink);
  text-align: left;
}

body.character-shell .char-ctrl-btn,
body.character-shell .char-show-more-btn,
body.character-shell .char-tag-pill,
body.character-shell .char-logic-btn,
body.character-shell .char-info-tag-pill,
body.character-shell .char-tags-toggle-btn,
body.character-shell .also-appears-pill,
body.character-shell .lightbox-char-pill {
  border-radius: 6px;
  letter-spacing: 0.03em;
  text-align: center;
  box-shadow: none;
}

body.character-shell .char-ctrl-btn,
body.character-shell .char-tag-pill,
body.character-shell .char-logic-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

body.character-shell .char-ctrl-btn.is-active,
body.character-shell .char-tag-pill.is-active,
body.character-shell .char-logic-btn.is-active {
  background: var(--moss);
  color: #fff;
  border-color: transparent;
}

body.character-shell .char-sort-select,
body.character-shell .char-search-input {
  font-family: var(--font-subhead);
  font-size: 0.8rem;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  box-shadow: none;
}

body.character-shell .char-search-group {
  flex: 0 1 220px;
}

body.character-shell .char-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
  padding-bottom: 0.2rem;
}

body.character-shell .char-folder-row,
body.character-shell .char-folder-row--nested {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.75rem;
}

body.character-shell .char-folder-tile {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-subhead);
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  background: var(--moss);
  box-shadow: none;
  transition: filter 0.12s ease, transform 0.1s ease;
}

body.character-shell .char-folder-panel {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: none;
}

body.character-shell .gallery-thumb {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

body.character-shell .gallery-lightbox {
  background: rgba(0, 0, 0, 0.92);
  padding: 2rem 0;
}

body.character-shell .lightbox-inner {
  width: calc(100vw - 8rem);
  max-width: 1400px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
}

body.character-shell .lightbox-prev,
body.character-shell .lightbox-next,
body.character-shell .lightbox-close,
body.character-shell .lightbox-open-tab,
body.character-shell .lightbox-download-raw {
  border-radius: 8px;
}

body.character-shell .lightbox-prev:hover,
body.character-shell .lightbox-next:hover,
body.character-shell .lightbox-close:hover,
body.character-shell .lightbox-open-tab:hover,
body.character-shell .lightbox-download-raw:hover {
  transform: none;
}

@media (max-width: 700px) {
  body.character-shell .character-header {
    flex-direction: row;
  }

  body.character-shell .character-info-list {
    flex-basis: auto;
  }
}

@media (max-width: 520px) {
  body.character-shell .character-header {
    flex-direction: column;
    text-align: center;
  }

  body.character-shell .character-header-text,
  body.character-shell .character-header-text h1,
  body.character-shell .character-header-text .character-category-heading,
  body.character-shell .character-trade-status {
    text-align: center;
  }
}

@media (min-width: 760px) {
  body.character-shell .character-card-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem);
    column-gap: clamp(1.5rem, 4vw, 3rem);
    align-items: center;
  }

  body.character-shell .character-header {
    width: 100%;
    max-width: none;
  }

  body.character-shell .character-header-text {
    flex: 1 1 auto;
    overflow: visible;
  }

  body.character-shell .character-header-text h1 {
    max-width: 100%;
    overflow-wrap: break-word;
  }

  body.character-shell .character-info-list {
    justify-self: end;
    width: 100%;
  }
}
/* ---- Restore original character library folders ---- */

body.character-shell .character-category-section--child {
  margin-left: 1.5rem;
  border-left: 2px solid var(--line);
  padding-left: 1.25rem;
  padding-top: 0;
}

body.character-shell .character-category-section--child.character-category-section--collapsed-folder {
  margin-left: 0;
  border-left: 0;
  padding-left: 0;
}

body.character-shell .character-category-section--child > .character-category-heading {
  margin-left: 0;
  font-size: 0.78rem;
}

body.character-shell .character-category-description {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0 0 0.9rem;
  max-width: 640px;
}

body.character-shell .character-category-heading.is-collapsible {
  position: relative;
  padding-right: 1.8rem;
}

body.character-shell .character-category-heading.is-collapsible::after {
  content: "▸";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

body.character-shell .character-category-heading.is-collapsible.is-open::after {
  transform: translateY(-50%) rotate(90deg);
}

body.character-shell .char-folder-row--nested {
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

body.character-shell .char-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  font-family: var(--font-subhead);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

body.character-shell .character-category-heading--linked {
  text-decoration: none;
  transition: opacity 0.15s, transform 0.12s ease, filter 0.12s ease;
}

body.character-shell .character-category-heading--linked:not(.has-icon) {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

body.character-shell .character-category-heading--linked:hover {
  opacity: 0.75;
  transform: translateY(-2px);
}

body.character-shell .character-category-heading--linked:not(.has-icon):hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

body.character-shell .character-category-heading--linked.has-icon {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 376px;
  max-width: 100%;
  padding: 0.5rem;
  gap: 0.4rem;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
}

body.character-shell .character-category-heading--linked.has-icon:hover {
  opacity: 1;
  filter: brightness(1.08);
}

body.character-shell .char-folder-icon-wrap {
  width: 100%;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border-radius: 6px;
}

body.character-shell .character-category-heading--linked.has-icon .char-folder-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body.character-shell .character-category-heading--linked.has-icon .character-category-heading-label {
  display: block;
  padding: 0;
  text-align: center;
}

body.character-shell .char-folder-page-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 0 !important;
  border-left: 0 !important;
  transition: color 0.15s;
}

body.character-shell .char-folder-page-heading::before {
  content: none;
  display: none;
}

body.character-shell .char-collapsed-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2.25rem;
}

body.character-shell .char-collapsed-row--child {
  margin: 0 0 1rem;
}
/* ---- Character home-inspired skin pass ---- */

body.character-shell {
  --character-page-width: var(--max-width);
  --character-page-padding: 3rem 1.5rem 5rem;
  --kp-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--moss-deep) 28%, transparent), transparent 18rem),
    linear-gradient(90deg, color-mix(in srgb, var(--wine) 18%, transparent) 0 11.4rem, transparent 11.4rem),
    radial-gradient(circle at 84% 7%, color-mix(in srgb, var(--moss) 8%, transparent), transparent 18rem),
    radial-gradient(circle at 12% 62%, color-mix(in srgb, var(--wine) 10%, transparent), transparent 17rem),
    var(--paper);
}

body.character-shell::before {
  opacity: 0.1;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--wine) 18%, transparent), transparent) 0 8.4rem / 100% 1px no-repeat,
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--moss) 14%, transparent), transparent) 0 18.8rem / 100% 1px no-repeat,
    linear-gradient(115deg, transparent 0 46%, color-mix(in srgb, var(--wine) 14%, transparent) 46% 47%, transparent 47% 100%) 0 0 / 17rem 12rem no-repeat;
}

body.character-shell main {
  max-width: var(--character-page-width, var(--max-width));
  padding: var(--character-page-padding, 3rem 1.5rem 5rem);
}

body.character-shell main::before {
  content: none;
  display: none;
}

body.character-shell main > h1:first-child {
  color: var(--moss);
  font-family: var(--font-display);
  font-size: 2.8rem;
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0.045em 0.045em 0 color-mix(in srgb, var(--wine) 72%, transparent);
}

body.character-shell .lede,
body.character-shell .gallery-lede,
body.character-shell .character-category-description {
  color: color-mix(in srgb, var(--muted) 88%, var(--ink));
}

body.character-shell .char-controls-bar,
body.character-shell .gallery-controls-bar,
body.character-shell .char-folder-panel {
  border-color: color-mix(in srgb, var(--wine) 42%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--wine) 8%, transparent), transparent 58%),
    color-mix(in srgb, var(--panel) 82%, transparent);
  box-shadow: 0.18rem 0.18rem 0 color-mix(in srgb, var(--moss) 10%, transparent);
}

body.character-shell .char-filter-row,
body.character-shell .char-folder-row--nested {
  border-top-color: color-mix(in srgb, var(--wine) 30%, var(--line));
}

body.character-shell .character-card-row {
  border-bottom-color: color-mix(in srgb, var(--wine) 34%, var(--line));
}

body.character-shell .character-category-heading {
  border-color: color-mix(in srgb, var(--wine) 44%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--wine) 10%, transparent), transparent 58%),
    color-mix(in srgb, var(--panel) 84%, transparent);
  color: var(--moss);
  box-shadow: 0.14rem 0.14rem 0 color-mix(in srgb, var(--moss) 9%, transparent);
}

body.character-shell .character-category-heading--linked,
body.character-shell .char-folder-tile,
body.character-shell .char-tag-pill.is-active,
body.character-shell .char-logic-btn.is-active,
body.character-shell .char-ctrl-btn.is-active,
body.character-shell .char-info-tag-pill,
body.character-shell .lightbox-char-pill,
body.character-shell .character-tile .tile-name {
  box-shadow: 0.12rem 0.12rem 0 color-mix(in srgb, var(--wine) 24%, transparent);
}

body.character-shell .character-category-heading--linked.has-icon {
  border: 1px solid color-mix(in srgb, var(--wine) 32%, transparent);
  box-shadow: 0.24rem 0.24rem 0 color-mix(in srgb, var(--moss) 12%, transparent);
}

body.character-shell .character-tile {
  border-color: color-mix(in srgb, var(--wine) 34%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--moss) 4%, transparent), transparent 55%),
    color-mix(in srgb, var(--panel) 84%, transparent);
  box-shadow: 0.2rem 0.2rem 0 color-mix(in srgb, var(--moss) 9%, transparent);
}

body.character-shell .character-tile-img-wrap,
body.character-shell .char-folder-icon-wrap,
body.character-shell .gallery-thumb {
  outline: 1px solid color-mix(in srgb, var(--wine) 22%, transparent);
  outline-offset: -1px;
}

body.character-shell .character-icon-crop-frame {
  outline: 2px solid color-mix(in srgb, var(--wine) 42%, transparent);
  outline-offset: 3px;
}

body.character-shell .char-controls-label,
body.character-shell .char-controls-gallery-heading,
body.character-shell .info-label,
body.character-shell .char-breadcrumb {
  color: color-mix(in srgb, var(--wine) 72%, var(--muted));
}

body.character-shell .char-ctrl-btn,
body.character-shell .char-show-more-btn,
body.character-shell .char-tag-pill,
body.character-shell .char-logic-btn,
body.character-shell .char-tags-toggle-btn,
body.character-shell .char-sort-select,
body.character-shell .char-search-input {
  border-color: color-mix(in srgb, var(--wine) 32%, var(--line));
  background-color: color-mix(in srgb, var(--paper) 82%, var(--panel));
  transition:
    color 150ms var(--kp-ease-out),
    background-color 150ms var(--kp-ease-out),
    border-color 150ms var(--kp-ease-out),
    box-shadow 150ms var(--kp-ease-out),
    transform 150ms var(--kp-ease-out),
    filter 150ms var(--kp-ease-out);
}

body.character-shell .char-ctrl-btn:hover,
body.character-shell .char-show-more-btn:hover,
body.character-shell .char-tag-pill:hover,
body.character-shell .char-logic-btn:hover,
body.character-shell .char-tags-toggle-btn:hover {
  background: color-mix(in srgb, var(--wine) 12%, var(--panel));
  color: var(--ink);
  border-color: color-mix(in srgb, var(--wine) 48%, var(--line));
}

body.character-shell .character-tile,
body.character-shell .gallery-thumb,
body.character-shell .character-category-heading--linked,
body.character-shell .char-folder-tile {
  transition:
    color 150ms var(--kp-ease-out),
    background-color 150ms var(--kp-ease-out),
    border-color 150ms var(--kp-ease-out),
    box-shadow 150ms var(--kp-ease-out),
    transform 150ms var(--kp-ease-out),
    filter 150ms var(--kp-ease-out),
    opacity 150ms var(--kp-ease-out);
}

@media (hover: hover) and (pointer: fine) {
  body.character-shell .character-tile:hover,
  body.character-shell .gallery-thumb:hover,
  body.character-shell .character-category-heading--linked:hover,
  body.character-shell .char-folder-tile:hover {
    filter: brightness(1.05);
    box-shadow: 0.26rem 0.26rem 0 color-mix(in srgb, var(--wine) 16%, transparent);
  }
}

body.character-shell .character-tile:active,
body.character-shell .gallery-thumb:active,
body.character-shell .character-category-heading--linked:active,
body.character-shell .char-folder-tile:active,
body.character-shell .char-ctrl-btn:active,
body.character-shell .char-show-more-btn:active,
body.character-shell .char-tag-pill:active,
body.character-shell .char-logic-btn:active,
body.character-shell .char-tags-toggle-btn:active {
  transform: translateY(1px) scale(0.985);
}

body.character-shell .character-tile:focus-visible,
body.character-shell .gallery-thumb:focus-visible,
body.character-shell .character-category-heading--linked:focus-visible,
body.character-shell .char-folder-tile:focus-visible,
body.character-shell .char-ctrl-btn:focus-visible,
body.character-shell .char-show-more-btn:focus-visible,
body.character-shell .char-tag-pill:focus-visible,
body.character-shell .char-logic-btn:focus-visible,
body.character-shell .char-tags-toggle-btn:focus-visible,
body.character-shell .char-sort-select:focus-visible,
body.character-shell .char-search-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--moss) 70%, var(--paper));
  outline-offset: 3px;
}

body.character-shell .gallery-lightbox {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--moss-deep) 20%, rgba(0, 0, 0, 0.92)), rgba(0, 0, 0, 0.92)),
    radial-gradient(circle at 82% 12%, color-mix(in srgb, var(--wine) 16%, transparent), transparent 22rem);
}

body.character-shell .lightbox-inner {
  border-color: color-mix(in srgb, var(--wine) 42%, var(--line));
  box-shadow: 0.34rem 0.34rem 0 color-mix(in srgb, var(--wine) 22%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  body.character-shell .character-tile:hover,
  body.character-shell .gallery-thumb:hover,
  body.character-shell .character-category-heading--linked:hover,
  body.character-shell .char-folder-tile:hover,
  body.character-shell .character-tile:active,
  body.character-shell .gallery-thumb:active,
  body.character-shell .character-category-heading--linked:active,
  body.character-shell .char-folder-tile:active,
  body.character-shell .char-ctrl-btn:active,
  body.character-shell .char-show-more-btn:active,
  body.character-shell .char-tag-pill:active,
  body.character-shell .char-logic-btn:active,
  body.character-shell .char-tags-toggle-btn:active {
    transform: none;
  }
}

/* ---- Character square-edge skin pass ---- */

body.character-shell .char-controls-bar,
body.character-shell .gallery-controls-bar,
body.character-shell .char-folder-panel,
body.character-shell .character-category-heading,
body.character-shell .character-category-heading--linked.has-icon,
body.character-shell .character-card-row,
body.character-shell .character-tile,
body.character-shell .char-folder-tile,
body.character-shell .char-ctrl-btn,
body.character-shell .char-show-more-btn,
body.character-shell .char-tag-pill,
body.character-shell .char-logic-btn,
body.character-shell .char-info-tag-pill,
body.character-shell .char-tags-toggle-btn,
body.character-shell .also-appears-pill,
body.character-shell .lightbox-char-pill,
body.character-shell .char-sort-select,
body.character-shell .char-search-input,
body.character-shell .gallery-thumb,
body.character-shell .lightbox-inner,
body.character-shell .lightbox-prev,
body.character-shell .lightbox-next,
body.character-shell .lightbox-close,
body.character-shell .lightbox-open-tab,
body.character-shell .lightbox-download-raw {
  border-radius: 0;
}

body.character-shell .character-icon,
body.character-shell .character-icon-crop-frame,
body.character-shell .character-tile img,
body.character-shell .character-tile-img-wrap,
body.character-shell .character-tile-img-wrap img,
body.character-shell .char-folder-icon-wrap,
body.character-shell .character-category-heading--linked.has-icon .char-folder-icon {
  border-radius: 0;
}

body.character-shell .character-tile .tile-name,
body.character-shell .character-category-heading-label {
  border-radius: 0;
}

body.character-shell .character-tile,
body.character-shell .char-controls-bar,
body.character-shell .gallery-controls-bar,
body.character-shell .char-folder-panel,
body.character-shell .character-category-heading--linked.has-icon {
  box-shadow: 0.22rem 0.22rem 0 color-mix(in srgb, var(--moss) 12%, transparent);
}

body.character-shell .character-category-heading,
body.character-shell .character-tile .tile-name,
body.character-shell .char-folder-tile,
body.character-shell .char-tag-pill.is-active,
body.character-shell .char-logic-btn.is-active,
body.character-shell .char-ctrl-btn.is-active {
  box-shadow: 0.12rem 0.12rem 0 color-mix(in srgb, var(--wine) 22%, transparent);
}

/* ---- Character visual bugfix pass ---- */

body.character-shell {
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  body.character-shell {
    overflow-x: hidden;
  }
}

body.character-shell main,
body.character-shell .char-controls-bar,
body.character-shell .gallery-controls-bar,
body.character-shell .char-folder-panel,
body.character-shell .character-card-row,
body.character-shell .character-tile,
body.character-shell .character-tile-img-wrap,
body.character-shell .character-category-section,
body.character-shell .character-category-heading--linked.has-icon,
body.character-shell .char-folder-icon-wrap,
body.character-shell .gallery-thumb,
body.character-shell .lightbox-inner,
body.character-shell .char-sort-select,
body.character-shell .char-search-input {
  box-sizing: border-box;
}

body.character-shell main {
  width: min(100%, var(--character-page-width, var(--max-width)));
}

body.character-shell .character-card-row,
body.character-shell .character-gallery-section,
body.character-shell .character-also-appears-section {
  scroll-margin-top: 6rem;
}

body.character-shell .character-category-section--child {
  margin-left: 0;
  padding-left: 0;
  padding-top: 0.75rem;
  border-left: 0;
  border-top: 1px dashed color-mix(in srgb, var(--wine) 30%, var(--line));
}

body.character-shell .character-category-section--child.character-category-section--collapsed-folder {
  padding-top: 0;
  border-top: 0;
}

body.character-shell .info-value {
  min-width: 0;
  overflow-wrap: normal;
}

body.character-shell .info-value a {
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  body.character-shell main {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  body.character-shell .char-collapsed-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
  }

  body.character-shell .char-collapsed-row .character-category-section,
  body.character-shell .character-category-heading--linked.has-icon {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body.character-shell .character-category-heading--linked.has-icon {
    padding: 0.45rem;
  }

  body.character-shell .char-folder-icon-wrap,
  body.character-shell .character-category-heading-label {
    min-width: 0;
  }

  body.character-shell .character-card-row,
  body.character-shell .character-header,
  body.character-shell .character-info-list,
  body.character-shell .gallery-controls-bar {
    width: 100%;
    max-width: 100%;
  }

  body.character-shell .character-header-text h1 {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  body.character-shell .info-row {
    display: grid;
    grid-template-columns: minmax(4.9rem, auto) minmax(0, 1fr);
    align-items: baseline;
  }

  body.character-shell .info-label {
    min-width: 0;
  }

  body.character-shell .gallery-controls-bar {
    align-items: flex-start;
  }

  body.character-shell .char-controls-gallery-heading {
    width: 100%;
    margin-right: 0;
  }
}

@media (max-width: 420px) {
  body.character-shell .char-controls-row,
  body.character-shell .char-filter-row,
  body.character-shell .gallery-controls-bar,
  body.character-shell .char-controls-group,
  body.character-shell .char-tag-pills {
    gap: 0.45rem 0.55rem;
  }

  body.character-shell .char-search-group {
    flex: 1 1 100%;
  }

  body.character-shell .char-search-input {
    width: 100%;
  }
}

/* ---- Local owner character editor mount ---- */

body.character-shell .character-breadcrumb-mount {
  min-width: 0;
  margin-bottom: 1.25rem;
}

body.character-shell .character-breadcrumb-mount.character-editor-mounted {
  margin-bottom: 0;
}

body.character-shell .character-breadcrumb-mount > .char-breadcrumb {
  margin-bottom: 0;
}

.lightbox-char-pill--offsite,
body.character-shell .lightbox-char-pill--offsite {
  border-color: color-mix(in srgb, #777 48%, var(--line));
  background: color-mix(in srgb, #777 14%, var(--panel));
  color: color-mix(in srgb, var(--ink) 74%, #777);
}

.lightbox-char-pill--offsite:hover,
.lightbox-char-pill--offsite:focus-visible,
body.character-shell .lightbox-char-pill--offsite:hover,
body.character-shell .lightbox-char-pill--offsite:focus-visible {
  border-color: color-mix(in srgb, #777 64%, var(--line));
  background: color-mix(in srgb, #777 22%, var(--panel));
}
.character-owner-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, #15110f 58%, transparent);
}

.character-owner-confirm {
  box-sizing: border-box;
  width: min(100%, 24rem);
  border: 2px solid color-mix(in srgb, var(--wine) 55%, var(--line));
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0.75rem 1.5rem color-mix(in srgb, #15110f 32%, transparent);
  padding: 1rem;
}

.character-owner-confirm--danger {
  border-color: color-mix(in srgb, #8f2f3d 68%, var(--line));
}

.character-owner-confirm h2 {
  margin: 0 0 0.5rem;
  color: var(--wine);
  font-family: var(--font-subhead);
  font-size: 0.86rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.character-owner-confirm p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.character-owner-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 1rem;
}

.character-owner-confirm-primary,
.character-owner-confirm-secondary {
  min-height: 2rem;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.35rem 0.7rem;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-subhead);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
}

.character-owner-confirm-primary {
  border-color: color-mix(in srgb, #8f2f3d 62%, var(--line));
  background: color-mix(in srgb, #8f2f3d 18%, var(--panel));
}

.character-owner-confirm-primary:hover,
.character-owner-confirm-secondary:hover,
.character-owner-confirm-primary:focus-visible,
.character-owner-confirm-secondary:focus-visible {
  border-color: var(--moss);
  outline: 2px solid color-mix(in srgb, var(--moss) 42%, transparent);
  outline-offset: 2px;
}
