/* ============================================================
   PAGE 1 — PATCH HISTORY (SIDEBAR LAYOUT)
   ============================================================ */
.history-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2rem;
  align-items: flex-start;
}

/* Sticky sidebar */
.patch-sidebar {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

/* Glossary launcher — stays in the patch-history sidebar. */
.glossary-toggle-btn {
  width: 100%;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #0e0e0e;
  color: var(--color-accent);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.glossary-toggle-btn:hover, .glossary-toggle-btn:focus-visible { border-color: var(--color-accent); background: #191010; }

/* Full-width, self-contained glossary dialog. */
.glossary-overlay {
  position: fixed;
  inset: 0;
  z-index: 6500;
  display: none;
  padding: max(20px, 4vh) 16px;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.84);
  backdrop-filter: blur(6px);
}
.glossary-overlay.open { display: flex; }
.glossary-dialog {
  display: flex;
  flex-direction: column;
  width: min(1040px, 100%);
  max-height: min(880px, 92dvh);
  min-height: 0;
  overflow: hidden;
  background: #090909;
  border: 1px solid #292020;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 80px rgba(0,0,0,.8);
}
.glossary-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 1.2rem 1.5rem 1rem;
  border-bottom: 1px solid #242424;
  flex: 0 0 auto;
}
.glossary-modal-eyebrow { color: var(--color-accent); text-transform: uppercase; letter-spacing: .17em; font-weight: 700; font-size: .66rem; }
.glossary-modal-header h2 { margin-top: .18rem; font-size: 1.65rem; }
.glossary-modal-header p { font-size: .78rem; color: var(--color-muted); line-height: 1.4; margin-top: .3rem; }
.glossary-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #313131;
  border-radius: 50%;
  background: #141414;
  color: #ddd;
  font-size: 1rem;
  cursor: pointer;
}
.glossary-close:hover, .glossary-close:focus-visible { border-color: var(--color-accent); color: #fff; }
.glossary-modal-tools { padding: .9rem 1.5rem .8rem; border-bottom: 1px solid #242424; flex: 0 0 auto; }
.glossary-search-row { display: flex; gap: .6rem; }
.glossary-search-box { position: relative; display: block; flex: 1; min-width: 0; }
.glossary-search-box svg { position: absolute; width: 19px; height: 19px; top: 50%; left: .8rem; transform: translateY(-50%); color: #777; pointer-events: none; }
#glossary-search {
  width: 100%;
  padding: .65rem .9rem .65rem 2.35rem;
  border-radius: var(--radius);
  background: #101010;
  border: 1px solid #303030;
  outline: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: .86rem;
}
#glossary-search:focus { border-color: var(--color-accent); }
#glossary-search::placeholder { color: #888; }
.glossary-clear {
  border-radius: var(--radius);
  background: #141414;
  color: #ccc;
  border: 1px solid #303030;
  padding: 0 .75rem;
  font: 600 .77rem var(--font-body);
  cursor: pointer;
}
.glossary-clear:hover { border-color: #777; color: #fff; }
.glossary-clear[hidden] { display: none; }
.glossary-filters {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: .7rem 0 .2rem;
}
.glossary-filter {
  flex: 0 0 auto;
  border: 1px solid #303030;
  border-radius: 999px;
  padding: .34rem .7rem;
  background: #141414;
  color: #a9a9a9;
  font: 600 .72rem var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.glossary-filter:hover { border-color: #666; color: #fff; }
.glossary-filter.active { background: #321414; border-color: var(--color-accent); color: #fff; }
.glossary-result-count { margin-top: .35rem; color: #888; font-size: .68rem; min-height: 1.15em; }
.glossary-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1.1rem 1.5rem 1.6rem; scrollbar-color: #4d2525 #111; }
.glossary-section { margin-bottom: 1.3rem; }
.glossary-section-title {
  display: flex;
  align-items: center;
  gap: .65rem;
  font: 700 .78rem var(--font-heading);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: .65rem;
}
.glossary-section-title::after { content: ''; flex: 1; height: 1px; background: #292020; }
.glossary-section-count { font-size: .68rem; letter-spacing: 0; color: #858585; font-weight: 400; order: 1; }
.glossary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; align-items: start; }
.glossary-entry {
  min-width: 0;
  background: #101010;
  border: 1px solid #252525;
  border-radius: var(--radius);
  padding: .9rem 1rem;
  transition: border-color .15s;
}
.glossary-entry:hover { border-color: #493030; }
.glossary-term { color: #f0f0f0; font: 700 .94rem var(--font-heading); line-height: 1.3; margin-bottom: .4rem; }
.glossary-def { font: 400 .79rem/1.55 var(--font-body); color: #c0c0c0; overflow-wrap: anywhere; white-space: pre-line; }
.glossary-details { margin-top: .6rem; }
.glossary-details summary { color: #d65a52; font: 600 .73rem var(--font-heading); cursor: pointer; width: fit-content; list-style: none; }
.glossary-details summary::-webkit-details-marker { display: none; }
.glossary-details summary::after { content: ' +'; }
.glossary-details[open] summary::after { content: ' −'; }
.glossary-details > .glossary-def { margin-top: .6rem; padding-top: .65rem; border-top: 1px solid #272727; }
.glossary-empty { padding: 2.4rem .9rem; text-align: center; color: var(--color-muted); font-size: .9rem; }
.glossary-empty[hidden], .glossary-section[hidden], .glossary-entry[hidden] { display: none; }
@media (max-width: 650px) {
  .glossary-overlay { padding: 0; align-items: stretch; }
  .glossary-dialog { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; }
  .glossary-modal-header { padding: 1rem 1rem .75rem; }
  .glossary-modal-tools { padding: .7rem 1rem; }
  .glossary-scroll { padding: 1rem; }
  .glossary-grid { grid-template-columns: 1fr; }
  .glossary-modal-header h2 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { .glossary-filter, .glossary-entry { transition: none; } }

/* Search box */
.history-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  outline: none;
  box-sizing: border-box;
}

.history-search:focus { border-color: var(--color-accent); }
.history-search::placeholder { color: var(--color-muted); }

/* Patch entry card */
.patch-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 1.5rem 0;
}

.patch-list-grid.search-active {
  display: flex;
  flex-direction: column;
}

.patch-entry {
  background: #0a0a0a;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.patch-entry.latest { border-left: 2px solid var(--color-accent); }
.patch-entry:hover { border-color: #444; }

.patch-header {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.1rem;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.patch-header:hover { background: #111; }
.patch-header-left { display: none; }
.patch-body { display: none; }

.version-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  background: var(--color-accent);
  color: #ffffff;
}

.version-badge.origin {
  background: var(--color-surface2);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.patch-title { display: none; }
.patch-date  { font-size: 0.82rem; color: #d2d2d2; }
.patch-change-count { font-size: 0.78rem; color: #bcbcbc; padding-top: 0.5rem; border-top: 1px solid #353535; }
.patch-chevron { display: none; }

.patch-chevron {
  font-size: 0.7rem;
  color: var(--color-muted);
  transition: transform 0.2s;
}

.patch-entry.open .patch-chevron { transform: rotate(180deg); }

/* Patch body — hidden when collapsed */
.patch-body { display: none; padding: 1rem 1.25rem; background: #0f0f0f; }
.patch-entry.open .patch-body { display: block; }

.patch-summary { font-size: 0.88rem; color: var(--color-muted); margin-bottom: 1rem; }

/* Sub-section — collapsible */
.sub-section { margin-bottom: 0.5rem; border-radius: var(--radius); overflow: hidden; }

.sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  transition: background 0.15s;
}

.sub-header:hover { background: var(--color-border); }
.sub-entry.open .sub-header { border-radius: var(--radius) var(--radius) 0 0; }

.sub-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-stretch: semi-condensed;
}

/* Class colors on sub-section labels */
.sub-label.cat-monster  { color: var(--cl-monster); }
.sub-label.cat-assault  { color: var(--cl-assault); }
.sub-label.cat-medic    { color: var(--cl-medic); }
.sub-label.cat-support  { color: var(--cl-support); }
.sub-label.cat-trapper  { color: var(--cl-trapper); }
.sub-label.cat-general  { color: #a0a0b0; }
.sub-label.cat-perk     { color: #8899bb; }

.sub-chevron { font-size: 0.65rem; color: var(--color-muted); transition: transform 0.2s; }
.sub-entry.open .sub-chevron { transform: rotate(180deg); }

.sub-body { display: none; padding: 0.75rem 0.75rem; background: #1e1e1e; border: 1px solid var(--color-border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
.sub-entry.open .sub-body { display: block; }

/* Sub-header portrait and icon */
.sub-header-left { display: flex; align-items: center; gap: 0.6rem; flex: 1; }

/* ── SUB-SECTION PORTRAIT ──────────────────────────────────────
   Replace .sub-portrait placeholder with an <img loading="lazy" decoding="async">:
   <img loading="lazy" decoding="async" src="https://assets.modded-evolve.com/images/full_body_portraits/parnell.png" alt="Parnell">
   ─────────────────────────────────────────────────────────────── */
.sub-portrait {
  width: 90px;
  height: 50px;
  border-radius: 4px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  color: var(--color-muted);
  overflow: hidden;
}

/* ── SUB-SECTION CLASS ICON ────────────────────────────────────
   Replace .sub-class-icon placeholder with an <img loading="lazy" decoding="async">:
   <img loading="lazy" decoding="async" src="https://assets.modded-evolve.com/icons/assault.png" alt="Assault"
        style="width:28px;height:28px;object-fit:contain;display:block;">
   ─────────────────────────────────────────────────────────────── */
.sub-class-icon {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Icon slot background matches its class color */
.sub-entry.cat-monster .sub-class-icon { background: #000000; }
.sub-entry.cat-assault .sub-class-icon { background: var(--cl-assault); }
.sub-entry.cat-medic   .sub-class-icon { background: var(--cl-medic); }
.sub-entry.cat-support .sub-class-icon { background: var(--cl-support); }
.sub-entry.cat-trapper .sub-class-icon { background: var(--cl-trapper); }
.sub-entry.cat-general .sub-class-icon { background: #867088; }
.sub-entry.cat-perk    .sub-class-icon { background: #8899bb; }

/* Same for filter button icon slots on characters page */
.filter-btn[data-cls="monster"] .class-icon { background: #000000; }
.filter-btn[data-cls="assault"] .class-icon { background: var(--cl-assault); }
.filter-btn[data-cls="medic"]   .class-icon { background: var(--cl-medic); }
.filter-btn[data-cls="support"] .class-icon { background: var(--cl-support); }
.filter-btn[data-cls="trapper"] .class-icon { background: var(--cl-trapper); }
.filter-btn[data-cls="all"]     .class-icon { background: #867088; }

/* Default bullet — matches characters page › style */
.change-list { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; }

.change-list li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
}

.change-list li::before {
  content: '›';
  position: absolute;
  left: 0;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
  color: #a0a0b0;
}

/* Class-colored › arrows */
.sub-entry.cat-monster .change-list li::before  { color: var(--cl-monster); }
.sub-entry.cat-assault .change-list li::before  { color: var(--cl-assault); }
.sub-entry.cat-medic   .change-list li::before  { color: var(--cl-medic); }
.sub-entry.cat-support .change-list li::before  { color: var(--cl-support); }
.sub-entry.cat-trapper .change-list li::before  { color: var(--cl-trapper); }
.sub-entry.cat-general .change-list li::before  { color: #867088; }
.sub-entry.cat-perk    .change-list li::before  { color: #8899bb; }

/* Indented (nested) bullets */
.change-list li.indent-1 { padding-left: 3rem; }
.change-list li.indent-2 { padding-left: 4.5rem; }
.change-list li.indent-3 { padding-left: 6rem; }
.change-list li.indent-1::before { content: '»'; left: 1.5rem; font-size: 1rem; opacity: 0.75; }
.change-list li.indent-2::before { content: '»'; left: 3rem;   font-size: 1rem; opacity: 0.6; }
.change-list li.indent-3::before { content: '»'; left: 4.5rem; font-size: 1rem; opacity: 0.5; }

/* Bullet colours matching their title colour */
.sub-entry.cat-general [data-title-type="hunter"]        .change-list li::before { color: #344968 !important; }
.sub-entry.cat-general [data-title-type="monster"]       .change-list li::before { color: var(--cl-monster) !important; }
.sub-entry.cat-general [data-title-type="general-purple"].change-list li::before { color: #867088 !important; }

/* Rank separators in patch modal — match class colour */
.sub-entry.cat-monster .rank-sep { color: var(--cl-monster); }
.sub-entry.cat-assault .rank-sep { color: var(--cl-assault); }
.sub-entry.cat-medic   .rank-sep { color: var(--cl-medic); }
.sub-entry.cat-support .rank-sep { color: var(--cl-support); }
.sub-entry.cat-trapper .rank-sep { color: var(--cl-trapper); }
.sub-entry.cat-general .rank-sep { color: #867088; }

.change-list li.hidden-by-search { display: none; }

/* ============================================================
   PATCH MODAL OVERLAY
   ============================================================ */
#patch-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 5000;
  justify-content: center;
  align-items: flex-start;
  padding: 60px 1rem 1rem;
  backdrop-filter: blur(4px);
}

#patch-modal-overlay.open {
  display: flex;
}

#patch-modal {
  background: #0a0a0a;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1100px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

#patch-modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: #050505;
  border-bottom: 1px solid var(--color-border);
}

#patch-modal-header-left { display: flex; align-items: center; gap: 0.75rem; }
#patch-modal-title { font-size: 0.95rem; font-weight: 700; color: var(--color-text); }
#patch-modal-date  { font-size: 0.78rem; color: var(--color-muted); }

#patch-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
#patch-modal-close:hover { border-color: var(--color-accent); color: var(--color-accent); }

#patch-modal-body { flex: 1; }

/* ── CHAR HISTORY MODAL ── */
#char-history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 6000;
  justify-content: center;
  align-items: flex-start;
  padding: 60px 1rem 1rem;
  backdrop-filter: blur(4px);
}
#char-history-overlay.open { display: flex; }

#char-history-modal {
  background: #0a0a0a;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

#char-history-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: #050505;
  border-bottom: 1px solid var(--color-border);
  gap: 1rem;
}
#char-history-header-left { display: flex; align-items: center; gap: 0.85rem; }
#char-history-portrait {
  width: 48px;
  height: 48px;
  object-fit: cover;
  object-position: top;
  border-radius: 6px;
  border: 1px solid #222;
}
#char-history-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  font-family: var(--font-heading);
}
#char-history-subtitle { font-size: 0.75rem; color: var(--color-muted); margin-top: 2px; }
#char-history-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
#char-history-close:hover { border-color: var(--color-accent); color: var(--color-accent); }

#char-history-body { flex: 1; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; }

.ch-patch-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ch-patch-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  background: #111;
  border-bottom: 1px solid var(--color-border);
}
.ch-patch-label .version-badge { font-size: 0.72rem; }
.ch-patch-label .ch-patch-date { font-size: 0.72rem; color: var(--color-muted); }
.ch-patch-entries { display: flex; flex-direction: column; }
.ch-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-muted);
  font-size: 0.875rem;
}

/* ── PATCH MODAL — CLASS PICKER ── */
/* Class picker removed from here — defined below */

.modal-class-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: #111;
  border: 1px solid #222;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  min-width: 90px;
}

.modal-class-btn img { width: 48px; height: 48px; object-fit: contain; }
.modal-class-btn:hover { background: #1a1a1a; border-color: #333; color: var(--color-text); }
.modal-class-btn.active { border-color: var(--cls-color, var(--color-accent)); color: var(--cls-color, var(--color-accent)); background: #151515; }

/* ── PATCH MODAL — CLASS + CHAR PICKERS ── */
#patch-modal-class-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  justify-content: center;
  position: sticky;
  top: 53px;
  background: #080808;
  border-bottom: 1px solid var(--color-border);
  z-index: 6;
}

#patch-modal-char-picker {
  display: none;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  justify-content: center;
  position: sticky;
  top: 133px;
  background: #060606;
  border-bottom: 1px solid var(--color-border);
  z-index: 5;
}

#patch-modal-char-picker.visible { display: flex; }

.modal-char-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  background: #111;
  border: 1px solid #222;
  border-radius: var(--radius);
  padding: 0.5rem;
  transition: border-color 0.15s, background 0.15s;
  width: 240px;
}

.modal-char-btn img { width: 100%; height: 110px; object-fit: cover; object-position: top center; border-radius: 3px; }
.modal-char-btn span { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); text-align: center; line-height: 1.2; }
.modal-char-btn:hover { background: #1a1a1a; border-color: #444; }
.modal-char-btn.active { border-color: var(--cls-color, var(--color-accent)); }

/* ── PATCH MODAL — CHARACTER DETAIL ── */
#patch-modal-char-detail { display: none; }
#patch-modal-char-detail.visible { display: block; }

[id^="modal-char-anchor-"] {
  scroll-margin-top: 230px;
}

/* Modal: show ability changes text (hidden by default in characters page) */
#patch-modal-char-detail .ability-block > .ability-changes {
  display: block !important;
}


/* Back button */
.modal-back-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--color-muted);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
}
.modal-back-btn:hover { color: var(--color-text); }

/* ── CHARACTER CARD LAYOUT ── */

/* Each character is a fixed-height card: portrait left, abilities right */
.sub-entry {
  display: flex;
  min-height: 580px;
  border-bottom: 1px solid #111;
}
.sub-entry:last-child { border-bottom: none; }
/* General/Technical blocks have no portrait, so size to content instead of the 580px portrait height */
.sub-entry.cat-general { min-height: 0; }

/* Portrait — wide, fills full card height, never shifts */
.sub-portrait-col {
  width: 480px;
  min-width: 480px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sub-portrait-col img.fullbody {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center center;
  margin: auto;
  display: block;
}
.sub-char-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 60px 10px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.96));
  text-align: center;
  z-index: 1;
}
.sub-char-name {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  display: block;
}
.sub-char-cls {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-top: 3px;
}
.sub-entry.cat-monster .sub-portrait-col { box-shadow: inset -3px 0 0 var(--cl-monster); }
.sub-entry.cat-assault .sub-portrait-col { box-shadow: inset -3px 0 0 var(--cl-assault); }
.sub-entry.cat-medic   .sub-portrait-col { box-shadow: inset -3px 0 0 var(--cl-medic); }
.sub-entry.cat-support .sub-portrait-col { box-shadow: inset -3px 0 0 var(--cl-support); }
.sub-entry.cat-trapper .sub-portrait-col { box-shadow: inset -3px 0 0 var(--cl-trapper); }
.sub-entry.cat-general .sub-portrait-col { box-shadow: inset -3px 0 0 #a0a0b0; }
.sub-entry.cat-perk    .sub-portrait-col { box-shadow: inset -3px 0 0 #8899bb; }

.sub-entry.cat-monster .sub-char-cls { color: var(--cl-monster); }
.sub-entry.cat-assault .sub-char-cls { color: var(--cl-assault); }
.sub-entry.cat-medic   .sub-char-cls { color: var(--cl-medic); }
.sub-entry.cat-support .sub-char-cls { color: var(--cl-support); }
.sub-entry.cat-trapper .sub-char-cls { color: var(--cl-trapper); }
.sub-entry.cat-general .sub-char-cls { color: #a0a0b0; }
.sub-entry.cat-perk    .sub-char-cls { color: #8899bb; }

/* Abilities column — scrolls internally */
.sub-abilities-col {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #0b0b0b;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a #0b0b0b;
}
.sub-abilities-col::-webkit-scrollbar { width: 4px; }
.sub-abilities-col::-webkit-scrollbar-track { background: #0b0b0b; }
.sub-abilities-col::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

/* Icon card row — horizontal */
.ability-icon-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* Each ability is an icon card in the row */
.ability-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 1rem 0.75rem;
  background: #111;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  width: 190px;
  flex-shrink: 0;
}
.ability-block:hover  { background: #161616; border-color: #333; }
.ability-block.active { background: #161616; border-bottom: 3px solid var(--cls-accent, #8b1a1a); }

.ability-icon-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ability-icon-wrap img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
  border: 1px solid #2a2a2a;
  display: block;
}
.ability-icon-wrap img[src*="thumbnails"] { object-fit: cover; object-position: center; }

#history img[src*="defaulthunter"],
#patch-modal-char-detail img[src*="defaulthunter"],
#char-history-body img[src*="defaulthunter"] {
  background: #344968 !important;
}
.ability-icon-placeholder {
  width: 150px;
  height: 150px;
  border-radius: 12px;
  background: #000;
  border: 1px solid #1a1a1a;
}
.ability-slot-label { display: none; }

/* Specific icons that are naturally large — pad them down */
img[src*="markovarcmines"],
img[src*="hydetoxicgrenade"],
img[src*="griffinsoundspike"],
img[src*="crowpetbatray"],
img[src*="crowkeniticlongrifle"] {
  object-fit: contain;
  padding: 18px;
}

img[src*="monsterarmorregenperk"] {
  object-fit: contain;
  padding: 10px;
}
.ability-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

/* Changes panel — shown below the icon row */
.ability-changes-panel {
  display: none;
  background: #111;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  padding: 1rem 1.1rem;
}
.ability-changes-panel.active { display: block; }

.ability-changes-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
}

/* hidden — original per-block changes, used as data source only */
.ability-block > .ability-changes { display: none; }

/* ── PATCH HISTORY ABILITY LAYOUT ── */
/* ── History and char-history modal: let sub-entries shrink to content ── */
#history .sub-entry {
  min-height: 0;
  height: auto;
}

/* Char history modal: minimum height so portrait is never cut off, grows with content */
#char-history-body .sub-entry {
  min-height: 380px;
  height: auto;
}

/* Separator between character entries: slightly more visible in history */
#history .sub-entry,
#char-history-body .sub-entry {
  border-bottom: 1px solid #222;
}
#history .sub-entry:last-child,
#char-history-body .sub-entry:last-child { border-bottom: none; }

#history .sub-abilities-col,
#char-history-body .sub-abilities-col {
  flex-direction: column;
  align-items: stretch;
  gap: 1.5rem;
  padding: 1.5rem;
  overflow-y: auto;
}


/* ── RANK BADGE ── */
.rank-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--color-accent);
  color: #ffffff;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.sub-entry.cat-monster .rank-badge { background: var(--cl-monster); }
.sub-entry.cat-assault .rank-badge { background: var(--cl-assault); }
.sub-entry.cat-medic   .rank-badge { background: var(--cl-medic); }
.sub-entry.cat-support .rank-badge { background: var(--cl-support); }
.sub-entry.cat-trapper .rank-badge { background: var(--cl-trapper); }

/* ============================================================
   PERK BLOCK — STRUCTURED PERK DISPLAY IN PATCH HISTORY
   ============================================================ */
.patch-preface {
  margin: 0 0 1.5rem;
  padding: 0.95rem 1.2rem 1rem;
  background: rgba(134, 112, 136, 0.08);
  border: 1px solid rgba(134, 112, 136, 0.3);
  border-left: 3px solid #867088;
  border-radius: 6px;
}
.patch-preface-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #867088;
  margin-bottom: 0.45rem;
}
.patch-preface p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
}
.patch-preface p + p {
  margin-top: 0.8rem;
}
.perk-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}
.perk-block-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}
.perk-main-icon {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  background: #000;
  flex-shrink: 0;
  object-fit: contain;
}
.perk-block-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #867088;
}

/* All ability-blocks: icon left, title+changes right */
#history .sub-entry.cat-general .ability-block,
#patch-modal-char-detail .sub-entry.cat-general .ability-block,
#char-history-body .sub-entry.cat-general .ability-block,
#history .sub-entry.cat-monster .ability-block,
#patch-modal-char-detail .sub-entry.cat-monster .ability-block,
#char-history-body .sub-entry.cat-monster .ability-block,
#history .sub-entry.cat-assault .ability-block,
#patch-modal-char-detail .sub-entry.cat-assault .ability-block,
#char-history-body .sub-entry.cat-assault .ability-block,
#history .sub-entry.cat-medic .ability-block,
#patch-modal-char-detail .sub-entry.cat-medic .ability-block,
#char-history-body .sub-entry.cat-medic .ability-block,
#history .sub-entry.cat-support .ability-block,
#patch-modal-char-detail .sub-entry.cat-support .ability-block,
#char-history-body .sub-entry.cat-support .ability-block,
#history .sub-entry.cat-trapper .ability-block,
#patch-modal-char-detail .sub-entry.cat-trapper .ability-block,
#char-history-body .sub-entry.cat-trapper .ability-block {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
}
.perk-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-left: 0.75rem;
}
.perk-block-v2 .perk-section-monster + .perk-section-hunter .perk-item:first-child {
  margin-top: 0.5rem;
}
.perk-block-v2 .perk-section-monster + .perk-section-hunter .perk-section-heading {
  margin-bottom: 2.25rem;
}
.perk-section-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.perk-section-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #2a2a2a;
  background: #000;
  object-fit: contain;
  flex-shrink: 0;
}
.perk-section-heading span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.perk-section-monster .perk-section-heading span { color: var(--cl-monster); }
.perk-section-hunter  .perk-section-heading span { color: #344968; }
.perk-section-note {
  font-size: 0.82rem;
  color: var(--color-muted);
  font-style: italic;
  padding: 0.3rem 0.5rem;
  border-left: 2px solid #333;
  margin-bottom: 0.25rem;
}
.perk-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.perk-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #2a2a2a;
  background: #000;
  object-fit: contain;
  flex-shrink: 0;
}
.perk-item-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
}
.perk-item-changes {
  padding-left: 0.75rem;
  margin-top: 0.15rem;
}
.perk-section-monster .perk-item-changes li::before { color: var(--cl-monster) !important; }
.perk-section-hunter  .perk-item-changes li::before { color: #344968 !important; }

/* ── PERK BLOCK V2 — side-by-side test (p18 only) ── */
.perk-block-v2 {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.perk-block-v2 .perk-block-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}
.perk-block-v2 .perk-section-icon {
  width: 72px;
  height: 72px;
  border-radius: 8px;
}
.perk-block-v2 .perk-section-heading span {
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.perk-block-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.perk-block-v2 .perk-item {
  display: grid;
  grid-template-columns: 74px 1fr;
  column-gap: 0.5rem;
  row-gap: 0.2rem;
  align-items: start;
  padding-left: 1rem;
}
.perk-block-v2 .perk-item-icon {
  grid-row: 1 / 3;
  grid-column: 1;
  align-self: start;
  width: 74px;
  height: 74px;
  border-radius: 8px;
}
.perk-block-v2 .perk-item-name {
  grid-row: 1;
  grid-column: 2;
  align-self: center;
  text-align: left;
  font-size: 0.85rem;
}
.perk-block-v2 .perk-item-changes {
  grid-row: 2;
  grid-column: 2;
}


#history .ability-block,
#char-history-body .ability-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  flex-shrink: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  cursor: default;
  gap: 0.35rem;
}

#history .ability-block:hover,
#char-history-body .ability-block:hover { background: transparent; }

#history .ability-icon-wrap img,
#history .ability-icon-placeholder,
#char-history-body .ability-icon-wrap img,
#char-history-body .ability-icon-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  background: #000;
}

#history .ability-block > .ability-changes,
#char-history-body .ability-block > .ability-changes {
  display: block;
  width: 100%;
}

/* Character ability names in history — compact label */
#history .ability-name,
#char-history-body .ability-name {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

/* General section titles (Global — Hunters, Wildlife, Progression etc.)
   These are section headers so they get much more prominent treatment */
#history .sub-entry.cat-general .ability-name,
#patch-modal-char-detail .sub-entry.cat-general .ability-name,
#char-history-body .sub-entry.cat-general .ability-name {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #867088 !important;
  margin-bottom: 0.6rem;
}

/* Per-block title colours based on data-title-type */
#history .sub-entry.cat-general [data-title-type="hunter"] .ability-name,
#patch-modal-char-detail .sub-entry.cat-general [data-title-type="hunter"] .ability-name,
#char-history-body .sub-entry.cat-general [data-title-type="hunter"] .ability-name          { color: #867088 !important; }

#history .sub-entry.cat-general [data-title-type="monster"] .ability-name,
#patch-modal-char-detail .sub-entry.cat-general [data-title-type="monster"] .ability-name,
#char-history-body .sub-entry.cat-general [data-title-type="monster"] .ability-name         { color: #867088 !important; }

#history .sub-entry.cat-general [data-title-type="general-purple"] .ability-name,
#patch-modal-char-detail .sub-entry.cat-general [data-title-type="general-purple"] .ability-name,
#char-history-body .sub-entry.cat-general [data-title-type="general-purple"] .ability-name  { color: #867088 !important; }
.sub-entry.cat-general .ability-name .ttl-hunter  { color: #344968 !important; }
.sub-entry.cat-general .ability-name .ttl-monster { color: var(--cl-monster) !important; }

/* ── MODAL CHAR DETAIL ABILITY LAYOUT ── */
#patch-modal-char-detail .sub-abilities-col {
  flex-direction: column;
  align-items: stretch;
  gap: 1.5rem;
  padding: 1.5rem;
  overflow-y: visible;
  height: auto;
}


#patch-modal-char-detail .ability-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  flex-shrink: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  cursor: default;
  gap: 0.35rem;
}

#patch-modal-char-detail .ability-block:hover { background: transparent; }

#patch-modal-char-detail .ability-icon-wrap img,
#patch-modal-char-detail .ability-icon-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  background: #000;
}

#patch-modal-char-detail .ability-block > .ability-changes {
  display: block;
  width: 100%;
}

#patch-modal-char-detail .ability-name {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
  text-align: left;
}

#patch-modal-char-detail .sub-entry {
  min-height: 580px;
  height: auto;
}
/* Portrait-less general blocks size to content in the modal too */
#patch-modal-char-detail .sub-entry.cat-general { min-height: 0; }

.sub-entry.cat-monster .ability-block.active { --cls-accent: var(--cl-monster); border-bottom-color: var(--cl-monster); }
.sub-entry.cat-assault .ability-block.active { --cls-accent: var(--cl-assault); border-bottom-color: var(--cl-assault); }
.sub-entry.cat-medic   .ability-block.active { --cls-accent: var(--cl-medic);   border-bottom-color: var(--cl-medic); }
.sub-entry.cat-support .ability-block.active { --cls-accent: var(--cl-support); border-bottom-color: var(--cl-support); }
.sub-entry.cat-trapper .ability-block.active { --cls-accent: var(--cl-trapper); border-bottom-color: var(--cl-trapper); }
.sub-entry.cat-general .ability-block.active { border-bottom-color: #a0a0b0; }
.sub-entry.cat-perk    .ability-block.active { border-bottom-color: #8899bb; }

.sub-entry.cat-monster .ability-changes-title { color: var(--cl-monster); }
.sub-entry.cat-assault .ability-changes-title { color: var(--cl-assault); }
.sub-entry.cat-medic   .ability-changes-title { color: var(--cl-medic); }
.sub-entry.cat-support .ability-changes-title { color: var(--cl-support); }
.sub-entry.cat-trapper .ability-changes-title { color: var(--cl-trapper); }
.sub-entry.cat-general .ability-changes-title { color: #a0a0b0; }
.sub-entry.cat-perk    .ability-changes-title { color: #8899bb; }

.sub-entry.cat-monster .ability-name { color: var(--cl-monster); }
.sub-entry.cat-assault .ability-name { color: var(--cl-assault); }
.sub-entry.cat-medic   .ability-name { color: var(--cl-medic); }
.sub-entry.cat-support .ability-name { color: var(--cl-support); }
.sub-entry.cat-trapper .ability-name { color: var(--cl-trapper); }
.sub-entry.cat-general .ability-name { color: #867088; }
.sub-entry.cat-perk    .ability-name { color: #8899bb; }

/* Legend panel in sidebar */
.sidebar-legend {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.sidebar-legend-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.legend-tag {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.legend-desc {
  font-size: 0.7rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.legend-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0.75rem 0;
}

.legend-class-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.legend-class-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-class-name {
  font-size: 0.7rem;
  color: var(--color-muted);
}

.stat {
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tag-reconciled { display:inline-block; font-size:0.6rem; font-weight:700; letter-spacing:0.1em; text-transform:uppercase; padding:0.12rem 0.4rem; border-radius:3px; margin-left:0.3rem; vertical-align:middle; white-space:nowrap; background:#221a22; color:#a98aa0; cursor:pointer; text-decoration:none; transition:background .15s, color .15s; }
.tag-reconciled:hover { background:#2e2330; color:#c4a9bd; }
.tag-origin { display:inline-block; font-size:0.6rem; font-weight:700; letter-spacing:0.1em; text-transform:uppercase; padding:0.12rem 0.4rem; border-radius:3px; margin-left:0.3rem; vertical-align:middle; white-space:nowrap; background:#221a22; color:#a98aa0; cursor:pointer; text-decoration:none; transition:background .15s, color .15s; }
.tag-origin:hover { background:#2e2330; color:#c4a9bd; }
.pn-num { font-weight: 700; color: #fff; }
.perk-item-icon { display: block; overflow: hidden; }
.perk-item-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pn-num .rank-sep { margin: 0 0.14em; font-weight: 400; }
.rank-token { display:inline-block; background:#8b1a1a; color:#fff; font-weight:700; font-size:0.82em; line-height:1.2; padding:0.02rem 0.34rem; border-radius:3px; white-space:nowrap; }
.tag-undocumented { display:inline-block; font-size:0.6rem; font-weight:700; letter-spacing:0.1em; text-transform:uppercase; padding:0.12rem 0.4rem; border-radius:3px; margin-left:0.3rem; vertical-align:middle; white-space:nowrap; background:#2a2a2a; color:#9a9a9a; border:1px solid #4a4a4a; cursor:default; }

/* Vanilla entry */
.vanilla-entry {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-top: 0.5rem;
}

.vanilla-entry h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.vanilla-entry p  { font-size: 0.85rem; color: var(--color-muted); }
