    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      min-height: 100vh;
      background: #2a2218;
      color: #3e2e1e;
      font-family: 'Crimson Text', Georgia, serif;
      line-height: 1.6;
      transition: background 0.4s ease;
    }

    /* ── Parchment texture via CSS ────────────────────────── */
    .parchment-bg {
      background:
        repeating-linear-gradient(
          0deg,
          transparent,
          transparent 28px,
          rgba(139,115,75,0.03) 28px,
          rgba(139,115,75,0.03) 29px
        ),
        radial-gradient(ellipse at 15% 10%, rgba(180,140,80,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 90%, rgba(160,120,60,0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(200,170,110,0.06) 0%, transparent 70%),
        linear-gradient(180deg, #f5ecd4 0%, #efe2c4 30%, #e8d8b4 70%, #e0d0a8 100%);
      transition: background 0.4s ease, color 0.4s ease;
    }

    ::-webkit-scrollbar { width: 10px; }
    ::-webkit-scrollbar-track { background: rgba(60,45,25,0.15); }
    ::-webkit-scrollbar-thumb {
      background: linear-gradient(180deg, #b89860, #8a6e3e);
      border-radius: 5px;
      border: 2px solid rgba(245,236,212,0.5);
    }

    /* ── Leather Spine / Binding Edge ────────────────────── */
    .book-wrapper {
      display: flex;
      min-height: 100vh;
    }
    .book-spine {
      width: 36px;
      min-width: 36px;
      background:
        linear-gradient(90deg, #1e160e 0%, #3a2a18 30%, #4a3820 60%, #3a2a18 85%, #2a1e12 100%);
      box-shadow: inset -4px 0 12px rgba(0,0,0,0.4), 2px 0 8px rgba(0,0,0,0.3);
      position: relative;
    }
    .book-spine::after {
      content: '';
      position: absolute;
      top: 0; bottom: 0; right: 0;
      width: 3px;
      background: linear-gradient(180deg,
        rgba(180,140,80,0.4),
        rgba(180,140,80,0.15) 20%,
        rgba(180,140,80,0.15) 80%,
        rgba(180,140,80,0.4)
      );
    }
    .book-body {
      flex: 1;
      display: flex;
      flex-direction: column;
    }

    /* ── Header ─────────────────────────────────────────────── */
    .header {
      padding: 32px 36px 0;
      border-bottom: 2px solid #c4a46a;
      position: relative;
    }
    .header::after {
      content: '';
      position: absolute;
      bottom: -5px; left: 36px; right: 36px;
      height: 1px;
      background: rgba(160,120,60,0.3);
    }
    .header h1 {
      font-family: 'Cinzel Decorative', 'Cinzel', serif;
      font-size: 32px;
      font-weight: 700;
      color: #4a3420;
      letter-spacing: 3px;
      margin-bottom: 4px;
    }
    .header .subtitle {
      font-size: 14px;
      color: #8a7050;
      font-style: italic;
      margin-bottom: 22px;
    }

    /* ── Cat Tabs ────────────────────────────────────────── */
    .cat-tabs {
      display: flex;
      gap: 1px;
      flex-wrap: wrap;
    }
    .cat-tab {
      padding: 10px 16px;
      border: 1px solid rgba(160,120,60,0.25);
      border-bottom: none;
      border-radius: 5px 5px 0 0;
      background: rgba(220,200,160,0.3);
      color: #7a6040;
      cursor: pointer;
      font-size: 13px;
      font-family: 'Cinzel', serif;
      font-weight: 400;
      letter-spacing: 0.5px;
      transition: all 0.2s ease;
      white-space: nowrap;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .cat-tab:hover {
      background: rgba(220,200,160,0.6);
      color: #4a3420;
    }
    .cat-tab.active {
      background: linear-gradient(180deg, rgba(245,236,212,0.95), rgba(239,226,196,0.95));
      border-color: #c4a46a;
      color: #4a3420;
      font-weight: 600;
      position: relative;
      z-index: 1;
    }
    .cat-tab .tab-icon {
      width: 18px;
      height: 18px;
      object-fit: contain;
      opacity: 0.7;
    }
    .cat-tab.active .tab-icon { opacity: 1; }
    .cat-tab .tab-count {
      display: inline-block;
      margin-left: 2px;
      padding: 1px 7px;
      font-size: 10px;
      border-radius: 8px;
      background: rgba(160,120,60,0.12);
      color: #8a7050;
      font-family: 'Crimson Text', serif;
    }
    .cat-tab.active .tab-count {
      background: rgba(160,120,60,0.2);
      color: #6a5030;
    }

    /* ── Search Bar ──────────────────────────────────────────── */
    .search-bar {
      padding: 14px 36px;
      border-bottom: 1px solid rgba(160,120,60,0.2);
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
    }
    .search-bar input {
      flex: 1;
      min-width: 180px;
      max-width: 360px;
      padding: 9px 14px;
      background: rgba(255,250,235,0.6);
      border: 1px solid rgba(160,120,60,0.3);
      border-radius: 4px;
      color: #3e2e1e;
      font-family: 'Crimson Text', serif;
      font-size: 15px;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .search-bar input::placeholder { color: #a09070; }
    .search-bar input:focus {
      border-color: #b89860;
      box-shadow: 0 0 0 2px rgba(184,152,96,0.15);
    }
    .search-count {
      font-size: 13px;
      color: #8a7050;
      font-style: italic;
    }
    .filter-controls {
      display: flex;
      gap: 8px;
      margin-left: auto;
      align-items: center;
      flex-wrap: wrap;
    }
    .filter-select {
      padding: 7px 28px 7px 12px;
      border: 1px solid rgba(160,120,60,0.3);
      border-radius: 4px;
      background-color: #f5ecd4;
      color: #5a4a30;
      font-family: 'Crimson Text', serif;
      font-size: 13px;
      outline: none;
      cursor: pointer;
      transition: border-color 0.2s, background-color 0.4s, color 0.4s;
      appearance: none;
      -webkit-appearance: none;
      -moz-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a7050'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 10px center;
      background-size: 10px 6px;
    }
    .filter-select:focus { border-color: #b89860; }
    .filter-select option {
      background: #f5ecd4;
      color: #3e2e1e;
    }
    .filter-select.has-value {
      border-color: #b89860;
      background-color: #efe2c4;
      color: #4a3420;
      font-weight: 600;
    }
    .filter-toggle {
      padding: 7px 14px;
      border: 1px solid rgba(160,120,60,0.3);
      border-radius: 4px;
      background: rgba(255,250,235,0.6);
      color: #7a6040;
      cursor: pointer;
      font-family: 'Crimson Text', serif;
      font-size: 13px;
      transition: all 0.2s;
    }
    .filter-toggle:hover { background: rgba(220,200,160,0.5); }
    .filter-toggle.active {
      background: rgba(160,60,50,0.1);
      border-color: rgba(160,60,50,0.4);
      color: #8b3030;
      font-weight: 600;
    }

    /* ── Active Filter Pills ─────────────────────────────────── */
    .active-filters {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      padding: 0 36px 10px;
      border-bottom: 1px solid rgba(160,120,60,0.12);
    }
    .active-filters:empty { display: none; padding: 0; border: none; }
    .filter-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 10px;
      border-radius: 12px;
      font-size: 12px;
      font-family: 'Crimson Text', serif;
      background: rgba(184,152,96,0.15);
      border: 1px solid rgba(184,152,96,0.3);
      color: #6a5030;
    }
    .filter-pill-close {
      cursor: pointer;
      opacity: 0.5;
      transition: opacity 0.2s;
      font-size: 14px;
      line-height: 1;
    }
    .filter-pill-close:hover { opacity: 1; }
    .filter-pill.mandatory-pill {
      background: rgba(160,60,50,0.08);
      border-color: rgba(160,60,50,0.25);
      color: #8b3030;
    }
    .filter-pill.component-pill {
      background: rgba(60,100,120,0.08);
      border-color: rgba(60,100,120,0.25);
      color: #3a6070;
    }

    /* ── Main Layout ─────────────────────────────────────────── */
    .main {
      display: flex;
      flex: 1;
    }

    /* ── Feat List (Index Page) ─────────────────────────────── */
    .feat-list {
      width: 340px;
      min-width: 340px;
      border-right: 1px solid rgba(160,120,60,0.2);
      overflow-y: auto;
      max-height: calc(100vh - 170px);
    }
    .feat-level-group {
      border-bottom: 1px solid rgba(160,120,60,0.1);
    }
    .feat-level-header {
      padding: 10px 20px;
      font-family: 'Cinzel', serif;
      font-size: 11px;
      font-weight: 600;
      color: #8a7050;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      background: rgba(200,170,110,0.12);
      border-bottom: 1px solid rgba(160,120,60,0.1);
      position: sticky;
      top: 0;
      z-index: 2;
    }
    .feat-item {
      padding: 10px 20px;
      cursor: pointer;
      border-bottom: 1px solid rgba(160,120,60,0.06);
      transition: background 0.15s;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .feat-item:hover { background: rgba(200,170,110,0.12); }
    .feat-item.active {
      background: rgba(200,170,110,0.22);
      border-left: 3px solid #b89860;
    }
    .feat-item-icon {
      width: 22px;
      height: 22px;
      object-fit: contain;
      opacity: 0.65;
      flex-shrink: 0;
    }
    .feat-item.active .feat-item-icon { opacity: 1; }
    .feat-item-name {
      font-size: 15px;
      color: #4a3a28;
      flex: 1;
    }
    .feat-item.active .feat-item-name {
      color: #3a2a18;
      font-weight: 600;
    }
    .feat-item-cat {
      font-size: 11px;
      color: #a09070;
      font-style: italic;
      white-space: nowrap;
    }
    .feat-item-mandatory {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #b04040;
      box-shadow: 0 0 4px rgba(176,64,64,0.3);
      flex-shrink: 0;
    }

    /* ── Feat Detail (Right Page) ────────────────────────────── */
    .feat-detail {
      flex: 1;
      padding: 32px 40px;
      overflow-y: auto;
      max-height: calc(100vh - 170px);
      position: relative;
    }
    .feat-detail-empty {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100%;
      color: #a09070;
      font-style: italic;
      font-size: 16px;
      gap: 12px;
    }
    .feat-detail-empty .empty-icon {
      font-size: 48px;
      opacity: 0.3;
    }

    /* Cat header with icon */
    .feat-header {
      display: flex;
      align-items: flex-start;
      gap: 18px;
      margin-bottom: 18px;
      padding-bottom: 18px;
      border-bottom: 2px solid rgba(160,120,60,0.2);
    }
    .feat-cat-icon {
      width: 56px;
      height: 56px;
      object-fit: contain;
      flex-shrink: 0;
      filter: drop-shadow(0 2px 4px rgba(60,40,10,0.2));
    }
    .feat-header-text { flex: 1; min-width: 0; }
    .feat-title-row {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 8px;
    }
    .feat-action-row {
      display: flex;
      gap: 6px;
      flex-shrink: 0;
    }
    .feat-share {
      background: rgba(80,55,15,0.15);
      border: 1px solid rgba(160,120,60,0.4);
      color: #6a4a20;
      cursor: pointer;
      padding: 5px 7px;
      border-radius: 4px;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-family: 'Cinzel', serif;
      font-size: 11px;
      letter-spacing: 0.5px;
      transition: background 0.15s, color 0.15s, border-color 0.15s;
      flex-shrink: 0;
    }
    .feat-share svg { width: 12px; height: 12px; display: block; }
    .feat-share:hover { color: #3a2a18; border-color: rgba(160,120,60,0.7); background: rgba(160,120,60,0.18); }
    .feat-share.copied { color: #4a6a2a; border-color: rgba(74,106,42,0.6); background: rgba(74,106,42,0.12); }
    .share-toast {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(40,28,14,0.95);
      color: #f0d688;
      padding: 10px 18px;
      border-radius: 4px;
      border: 1px solid rgba(160,120,60,0.5);
      font-family: 'Cinzel', serif;
      font-size: 12px;
      letter-spacing: 0.5px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
      z-index: 9999;
      box-shadow: 0 4px 18px rgba(0,0,0,0.4);
    }
    .share-toast.visible { opacity: 1; }
    body.dark-mode .feat-share {
      background: rgba(80,60,30,0.25);
      border-color: rgba(160,130,80,0.35);
      color: #c0a868;
    }
    body.dark-mode .feat-share:hover {
      background: rgba(100,75,35,0.35);
      color: #e8c878;
      border-color: rgba(180,150,90,0.6);
    }
    body.dark-mode .feat-share.copied { color: #88c060; border-color: rgba(120,180,80,0.5); background: rgba(70,110,40,0.2); }
    .feat-detail-title {
      font-family: 'Cinzel Decorative', 'Cinzel', serif;
      font-size: 24px;
      font-weight: 700;
      color: #3a2a18;
      margin-bottom: 8px;
      letter-spacing: 1px;
      line-height: 1.3;
    }
    .feat-meta {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }
    .feat-meta-tag {
      padding: 3px 11px;
      border-radius: 3px;
      font-size: 12px;
      font-family: 'Cinzel', serif;
      letter-spacing: 0.5px;
    }
    .tag-cat {
      background: rgba(160,120,60,0.12);
      border: 1px solid rgba(160,120,60,0.3);
      color: #6a5030;
    }
    .tag-level {
      background: rgba(60,90,120,0.08);
      border: 1px solid rgba(60,90,120,0.2);
      color: #4a6a80;
    }
    .tag-category {
      background: rgba(60,100,50,0.08);
      border: 1px solid rgba(60,100,50,0.2);
      color: #4a6a3a;
						display:none;
    }
    .tag-mandatory-warn {
      background: rgba(160,60,50,0.08);
      border: 1px solid rgba(160,60,50,0.25);
      color: #8b3030;
    }
    .tag-class {
      background: rgba(90,70,50,0.06);
      border: 1px solid rgba(90,70,50,0.18);
      color: #6a5a40;
      font-size: 11px;
    }
    .tag-class-active {
      background: rgba(90,70,50,0.14);
      border-color: rgba(90,70,50,0.35);
      color: #4a3a20;
      font-weight: 700;
    }

    /* Description */
    .feat-description {
      margin-bottom: 28px;
      padding: 18px 22px;
      background: rgba(255,250,235,0.5);
      border: 1px solid rgba(160,120,60,0.15);
      border-left: 3px solid rgba(160,120,60,0.3);
      border-radius: 2px;
      font-size: 15px;
      line-height: 1.75;
      color: #4a3a28;
      white-space: pre-wrap;
    }
    .feat-description:empty { display: none; }

    /* Feat stat header — the "Caster Level(s) / Cat / Range / …" lines
       parsed off the top of the description, shown as clickable, explained
       rows (click a row to reveal what that stat means). */
    .feat-stats {
      margin-bottom: 28px;
      max-width: 680px;
      background: rgba(255,250,235,0.5);
      border: 1px solid rgba(160,120,60,0.15);
      border-left: 3px solid rgba(160,120,60,0.3);
      border-radius: 2px;
      overflow: hidden;
    }
    .feat-stat-row {
      display: flex; justify-content: space-between; gap: 16px;
      padding: 8px 22px; font-size: 14px; color: #4a3a28;
      border-bottom: 1px solid rgba(160,120,60,0.1);
    }
    .feat-stat-row:last-child { border-bottom: none; }
    .feat-stat-label {
      color: #6a5030; font-family: 'Cinzel', serif; font-size: 12px;
      letter-spacing: 0.5px; white-space: nowrap;
    }
    .feat-stat-value { text-align: right; color: #3e2e1e; }
    .feat-stat-row.has-info { cursor: pointer; transition: background 0.15s; }
    .feat-stat-row.has-info:hover { background: rgba(200,170,110,0.12); }
    .feat-stats .info-dot {
      display: inline-flex; align-items: center; justify-content: center;
      width: 14px; height: 14px; margin-left: 7px; border-radius: 50%;
      font-size: 9px; font-weight: 700; line-height: 1; vertical-align: 1px;
      color: #7a5a20; background: rgba(160,120,60,0.18);
      border: 1px solid rgba(160,120,60,0.45); transition: all 0.15s;
    }
    .feat-stat-row.has-info:hover .info-dot,
    .feat-stat-row.open .info-dot {
      color: #fff8ec; background: #a07a30; border-color: #a07a30;
    }
    .feat-stat-info {
      display: none; font-size: 13px; line-height: 1.6; color: #5a4a30;
      padding: 0 22px; background: rgba(245,235,215,0.6);
      border-bottom: 1px solid rgba(160,120,60,0.1);
    }
    .feat-stat-info.open { display: block; padding: 10px 22px 12px; }
    .feat-stat-info .wiki-link {
      display: block; margin-top: 8px; font-size: 12px;
      color: #7a5a20; text-decoration: none;
      border-bottom: 1px dotted rgba(122,90,32,0.5);
      text-align:right;
    }
    .feat-stat-info .wiki-link:hover { color: #5a4010; border-bottom-color: rgba(90,64,16,0.8); }

    /* ── Components Table ────────────────────────────────────── */
    .components-section h3 {
      font-family: 'Cinzel', serif;
      font-size: 14px;
      font-weight: 600;
      color: #6a5030;
      letter-spacing: 1px;
      text-transform: uppercase;
      margin-bottom: 12px;
      padding-bottom: 8px;
      border-bottom: 1px solid rgba(160,120,60,0.2);
    }
    .components-table {
      width: 100%;
      border-collapse: collapse;
    }
    .components-table thead th {
      text-align: left;
      padding: 8px 12px;
      font-family: 'Cinzel', serif;
      font-size: 11px;
      font-weight: 600;
      color: #8a7050;
      letter-spacing: 1px;
      text-transform: uppercase;
      border-bottom: 2px solid rgba(160,120,60,0.2);
    }
    .components-table tbody td {
      padding: 10px 12px;
      font-size: 14px;
      border-bottom: 1px solid rgba(160,120,60,0.08);
      color: #4a3a28;
    }
    .components-table tbody tr:hover {
      background: rgba(200,170,110,0.08);
    }
    .components-table tbody tr.mandatory-row {
      background: rgba(160,60,50,0.05);
      border-left: 3px solid rgba(160,60,50,0.5);
    }
    .components-table tbody tr.mandatory-row:hover {
      background: rgba(160,60,50,0.08);
    }
    .comp-name { color: #3e2e1e; }
    .comp-qty { color: #4a6a80; text-align: center; }
    .comp-percent { color: #5a7a4a; text-align: center; }
    .comp-mandatory { text-align: center; }
    .mandatory-badge {
      display: inline-block;
      padding: 2px 8px;
      font-size: 10px;
      font-family: 'Cinzel', serif;
      letter-spacing: 1px;
      text-transform: uppercase;
      border-radius: 3px;
      background: rgba(160,60,50,0.1);
      border: 1px solid rgba(160,60,50,0.3);
      color: #8b3030;
    }
    .no-components {
      color: #a09070;
      font-style: italic;
      padding: 16px 0;
    }
    .components-table tbody tr.filtered-comp-row {
      background: rgba(60,100,130,0.06);
      border-left: 3px solid rgba(60,100,130,0.4);
    }
    .components-table tbody tr.filtered-comp-row:hover {
      background: rgba(60,100,130,0.1);
    }
    .components-table tbody tr.filtered-comp-row.mandatory-row {
      background: linear-gradient(90deg, rgba(60,100,130,0.06), rgba(160,60,50,0.05));
      border-left: 3px solid rgba(120,70,80,0.5);
    }

    /* ── Component Info Box ──────────────────────────────────── */
    .component-info {
      margin-top: 24px;
      padding: 18px 22px;
      background: rgba(255,250,235,0.4);
      border: 1px solid rgba(160,120,60,0.15);
      border-radius: 4px;
      font-size: 14px;
      line-height: 1.7;
      color: #5a4a30;
    }
    .component-info h4 {
      font-family: 'Cinzel', serif;
      font-size: 12px;
      font-weight: 600;
      color: #6a5030;
      letter-spacing: 1px;
      text-transform: uppercase;
      margin-bottom: 10px;
    }
    .component-info p { margin-bottom: 10px; }
    .component-info p:last-child { margin-bottom: 0; }
    .info-required { color: #8b3030; font-weight: 600; }
    .info-optional { color: #3a6070; font-weight: 600; }
    .info-link {
      color: #7a5a20;
      text-decoration: none;
      border-bottom: 1px solid rgba(122,90,32,0.3);
      transition: border-color 0.2s;
    }
    .info-link:hover { border-bottom-color: rgba(122,90,32,0.7); }
    .info-divider {
      border: none;
      border-top: 1px solid rgba(160,120,60,0.15);
      margin: 12px 0;
    }
    .info-detail {
      font-size: 13px;
      color: #7a6a4a;
      font-style: italic;
    }

    /* ── Loading / Error ─────────────────────────────────────── */
    .loading {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 300px;
      color: #a09070;
      font-style: italic;
      font-size: 16px;
    }
    .loading-spinner {
      display: inline-block;
      width: 20px;
      height: 20px;
      border: 2px solid rgba(160,120,60,0.2);
      border-top-color: rgba(160,120,60,0.6);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      margin-right: 10px;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .error-msg {
      text-align: center;
      padding: 40px;
      color: #8b3030;
    }

    /* ── Cat accent colors on title ───────────────────────── */
    [data-cat="A"] .feat-detail-title { color: #2a5a8a; }
    [data-cat="C"] .feat-detail-title { color: #2a6a4a; }
    [data-cat="D"] .feat-detail-title { color: #5a5a7a; }
    [data-cat="E"] .feat-detail-title { color: #8a6a20; }
    [data-cat="I"] .feat-detail-title { color: #6a4a8a; }
    [data-cat="N"] .feat-detail-title { color: #4a6a2a; }
    [data-cat="T"] .feat-detail-title { color: #8a4a2a; }
    [data-cat="V"] .feat-detail-title { color: #8a2a2a; }

    /* ── Dark Mode Toggle ────────────────────────────────────── */
    .dark-mode-toggle {
      padding: 8px 14px;
      border: 1px solid rgba(160,120,60,0.3);
      border-radius: 6px;
      background: rgba(255,250,235,0.5);
      color: #6a5030;
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
      transition: all 0.3s;
      flex-shrink: 0;
      margin-top: 4px;
    }
    .dark-mode-toggle:hover { background: rgba(220,200,160,0.6); }

    /* ── Breadcrumb + corner nav ─────────────────────────────── */
    .breadcrumb {
      font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 1.5px;
      text-transform: uppercase; color: #8a7050; margin-bottom: 10px;
    }
    .breadcrumb a {
      color: #6a5030; text-decoration: none; transition: color 0.15s;
    }
    .breadcrumb a:hover { color: #3e2e1e; }
    .breadcrumb .sep { color: #b89860; margin: 0 8px; }
    .breadcrumb .current { color: #3e2e1e; font-weight: 600; }

    .header-actions {
      display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    }
    .corner-nav {
      display: flex; gap: 4px; margin-top: 4px;
    }
    .corner-nav a {
      padding: 8px 14px;
      border: 1px solid rgba(160,120,60,0.3);
      border-radius: 6px;
      background: rgba(255,250,235,0.5);
      color: #6a5030;
      text-decoration: none;
      font-family: 'Cinzel', serif;
      font-size: 12px;
      letter-spacing: 0.5px;
      transition: all 0.2s;
    }
    .corner-nav a:hover { background: rgba(220,200,160,0.6); color: #3e2e1e; }

    body.dark-mode .breadcrumb { color: #7a6a4a; }
    body.dark-mode .breadcrumb a { color: #a08858; }
    body.dark-mode .breadcrumb a:hover { color: #e0c888; }
    body.dark-mode .breadcrumb .sep { color: #5a4a30; }
    body.dark-mode .breadcrumb .current { color: #e0c888; }
    body.dark-mode .corner-nav a {
      background: rgba(40,30,20,0.5);
      border-color: rgba(120,90,50,0.35);
      color: #b09868;
    }
    body.dark-mode .corner-nav a:hover { background: rgba(60,45,25,0.7); color: #e0c888; }

    @media (max-width: 600px) {
      .corner-nav { display: none; }
    }

    /* ═══════════════════════════════════════════════════════════
       DARK MODE
       ═══════════════════════════════════════════════════════════ */
    body.dark-mode {
      background: #151015;
    }
    body.dark-mode .parchment-bg {
      background:
        repeating-linear-gradient(
          0deg,
          transparent,
          transparent 28px,
          rgba(80,60,40,0.04) 28px,
          rgba(80,60,40,0.04) 29px
        ),
        radial-gradient(ellipse at 15% 10%, rgba(60,40,20,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 90%, rgba(50,30,15,0.12) 0%, transparent 50%),
        linear-gradient(180deg, #1e1a14 0%, #1a1610 30%, #181410 70%, #16120e 100%);
      color: #c8b898;
    }

    /* Spine */
    body.dark-mode .book-spine {
      background: linear-gradient(90deg, #0a0806 0%, #1a1410 30%, #201a12 60%, #1a1410 85%, #0e0a06 100%);
    }

    /* Header */
    body.dark-mode .header {
      border-bottom-color: #5a4a2a;
    }
    body.dark-mode .header::after { background: rgba(80,60,30,0.3); }
    body.dark-mode .header h1 { color: #e0c888; }
    body.dark-mode .header .subtitle { color: #8a7858; }

    /* Tabs */
    body.dark-mode .cat-tab {
      background: rgba(60,48,28,0.3);
      border-color: rgba(80,60,30,0.3);
      color: #9a8868;
    }
    body.dark-mode .cat-tab:hover {
      background: rgba(80,60,30,0.5);
      color: #c8b888;
    }
    body.dark-mode .cat-tab.active {
      background: linear-gradient(180deg, rgba(30,26,20,0.95), rgba(26,22,16,0.95));
      border-color: #5a4a2a;
      color: #e0c888;
    }
    body.dark-mode .cat-tab .tab-count {
      background: rgba(80,60,30,0.2);
      color: #8a7858;
    }
    body.dark-mode .cat-tab.active .tab-count {
      background: rgba(80,60,30,0.3);
      color: #c8b888;
    }

    /* Search bar */
    body.dark-mode .search-bar { border-bottom-color: rgba(80,60,30,0.2); }
    body.dark-mode .search-bar input {
      background: rgba(40,32,20,0.5);
      border-color: rgba(80,60,30,0.3);
      color: #c8b898;
    }
    body.dark-mode .search-bar input::placeholder { color: #6a5a40; }
    body.dark-mode .search-bar input:focus {
      border-color: #8a7040;
      box-shadow: 0 0 0 2px rgba(138,112,64,0.15);
    }
    body.dark-mode .search-count { color: #7a6a4a; }

    /* Filters */
    body.dark-mode .filter-select {
      background-color: #2a2418;
      border-color: rgba(100,80,40,0.5);
      color: #c8b898;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23c8b898'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 10px center;
      background-size: 10px 6px;
    }
    body.dark-mode .filter-select:focus { border-color: #a08850; }
    body.dark-mode .filter-select option {
      background: #252018;
      color: #c8b898;
      padding: 6px;
    }
    body.dark-mode .filter-select.has-value {
      border-color: #a08850;
      background-color: #332a1c;
      color: #e0c888;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23e0c888'/%3E%3C/svg%3E");
    }
    body.dark-mode .filter-toggle {
      background: rgba(40,32,20,0.5);
      border-color: rgba(80,60,30,0.3);
      color: #9a8868;
    }
    body.dark-mode .filter-toggle:hover { background: rgba(60,48,28,0.5); }
    body.dark-mode .filter-toggle.active {
      background: rgba(140,50,40,0.15);
      border-color: rgba(140,50,40,0.4);
      color: #d08080;
    }

    /* Filter pills */
    body.dark-mode .active-filters { border-bottom-color: rgba(80,60,30,0.12); }
    body.dark-mode .filter-pill {
      background: rgba(100,80,40,0.15);
      border-color: rgba(100,80,40,0.3);
      color: #b0a070;
    }
    body.dark-mode .filter-pill.mandatory-pill {
      background: rgba(140,50,40,0.1);
      border-color: rgba(140,50,40,0.25);
      color: #d08080;
    }
    body.dark-mode .filter-pill.component-pill {
      background: rgba(50,80,100,0.1);
      border-color: rgba(50,80,100,0.25);
      color: #80a8c0;
    }

    /* Feat list */
    body.dark-mode .feat-list { border-right-color: rgba(80,60,30,0.2); }
    body.dark-mode .feat-level-group { border-bottom-color: rgba(80,60,30,0.1); }
    body.dark-mode .feat-level-header {
      color: #8a7858;
      background: rgba(60,48,28,0.15);
      border-bottom-color: rgba(80,60,30,0.1);
    }
    body.dark-mode .feat-item { border-bottom-color: rgba(80,60,30,0.06); }
    body.dark-mode .feat-item:hover { background: rgba(80,60,30,0.12); }
    body.dark-mode .feat-item.active {
      background: rgba(80,60,30,0.22);
      border-left-color: #8a7040;
    }
    body.dark-mode .feat-item-name { color: #c0b088; }
    body.dark-mode .feat-item.active .feat-item-name { color: #e0c888; }
    body.dark-mode .feat-item-cat { color: #7a6a4a; }
    body.dark-mode .feat-item-icon { filter: brightness(1.3); }

    /* Detail */
    body.dark-mode .feat-detail-empty { color: #6a5a40; }
    body.dark-mode .feat-header { border-bottom-color: rgba(80,60,30,0.2); }
    body.dark-mode .feat-cat-icon { filter: brightness(1.3) drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }
    body.dark-mode .feat-detail-title { color: #e0c888; }
    body.dark-mode .tag-cat {
      background: rgba(80,60,30,0.15);
      border-color: rgba(80,60,30,0.3);
      color: #b0a070;
    }
    body.dark-mode .tag-level {
      background: rgba(50,70,90,0.12);
      border-color: rgba(50,70,90,0.25);
      color: #80a0b8;
    }
    body.dark-mode .tag-category {
      background: rgba(50,80,40,0.12);
      border-color: rgba(50,80,40,0.25);
      color: #88b070;
    }
    body.dark-mode .tag-mandatory-warn {
      background: rgba(140,50,40,0.1);
      border-color: rgba(140,50,40,0.25);
      color: #d08080;
    }
    body.dark-mode .tag-class {
      background: rgba(100,85,60,0.1);
      border-color: rgba(100,85,60,0.25);
      color: #a09070;
    }
    body.dark-mode .tag-class-active {
      background: rgba(100,85,60,0.2);
      border-color: rgba(100,85,60,0.4);
      color: #d0c090;
    }
    body.dark-mode .feat-description {
      background: rgba(30,26,18,0.5);
      border-color: rgba(80,60,30,0.15);
      border-left-color: rgba(80,60,30,0.3);
      color: #b0a080;
    }

    /* Feat stat header (dark) */
    body.dark-mode .feat-stats {
      background: rgba(30,26,18,0.5);
      border-color: rgba(80,60,30,0.15);
      border-left-color: rgba(80,60,30,0.3);
    }
    body.dark-mode .feat-stat-row {
      color: #b0a080;
      border-bottom-color: rgba(80,60,30,0.18);
    }
    body.dark-mode .feat-stat-label { color: #a09060; }
    body.dark-mode .feat-stat-value { color: #c0b088; }
    body.dark-mode .feat-stat-row.has-info:hover { background: rgba(80,60,30,0.18); }
    body.dark-mode .feat-stats .info-dot {
      color: #c0a860; background: rgba(120,95,40,0.25);
      border-color: rgba(150,120,60,0.5);
    }
    body.dark-mode .feat-stat-row.has-info:hover .info-dot,
    body.dark-mode .feat-stat-row.open .info-dot {
      color: #1a1410; background: #c0a860; border-color: #c0a860;
    }
    body.dark-mode .feat-stat-info {
      color: #9a8a66; background: rgba(20,17,11,0.55);
      border-bottom-color: rgba(80,60,30,0.18);
    }
    body.dark-mode .feat-stat-info .wiki-link {
      color: #c0a860; border-bottom-color: rgba(192,168,96,0.5);
    }
    body.dark-mode .feat-stat-info .wiki-link:hover { color: #e0c888; border-bottom-color: rgba(224,200,136,0.8); }

    /* Components table */
    body.dark-mode .components-section h3 {
      color: #a09060;
      border-bottom-color: rgba(80,60,30,0.2);
    }
    body.dark-mode .components-table thead th {
      color: #8a7858;
      border-bottom-color: rgba(80,60,30,0.25);
    }
    body.dark-mode .components-table tbody td {
      border-bottom-color: rgba(80,60,30,0.08);
      color: #b0a080;
    }
    body.dark-mode .components-table tbody tr:hover { background: rgba(80,60,30,0.08); }
    body.dark-mode .components-table tbody tr.mandatory-row {
      background: rgba(140,50,40,0.06);
      border-left-color: rgba(140,50,40,0.5);
    }
    body.dark-mode .components-table tbody tr.mandatory-row:hover { background: rgba(140,50,40,0.1); }
    body.dark-mode .comp-name { color: #c0b088; }
    body.dark-mode .comp-qty { color: #80a0b8; }
    body.dark-mode .comp-percent { color: #88b070; }
    body.dark-mode .mandatory-badge {
      background: rgba(140,50,40,0.15);
      border-color: rgba(140,50,40,0.35);
      color: #d08080;
    }
    body.dark-mode .no-components { color: #6a5a40; }
    body.dark-mode .components-table tbody tr.filtered-comp-row {
      background: rgba(50,80,100,0.08);
      border-left-color: rgba(50,80,100,0.4);
    }
    body.dark-mode .components-table tbody tr.filtered-comp-row:hover { background: rgba(50,80,100,0.12); }
    body.dark-mode .components-table tbody tr.filtered-comp-row.mandatory-row {
      background: linear-gradient(90deg, rgba(50,80,100,0.08), rgba(140,50,40,0.06));
      border-left-color: rgba(100,60,70,0.5);
    }

    /* Component info box */
    body.dark-mode .component-info {
      background: rgba(30,26,18,0.4);
      border-color: rgba(80,60,30,0.15);
      color: #9a8a68;
    }
    body.dark-mode .component-info h4 { color: #a09060; }
    body.dark-mode .info-required { color: #d08080; }
    body.dark-mode .info-optional { color: #80a8c0; }
    body.dark-mode .info-link {
      color: #c8a860;
      border-bottom-color: rgba(200,168,96,0.3);
    }
    body.dark-mode .info-link:hover { border-bottom-color: rgba(200,168,96,0.7); }
    body.dark-mode .info-divider { border-top-color: rgba(80,60,30,0.15); }
    body.dark-mode .info-detail { color: #7a6a4a; }

    /* Loading / error */
    body.dark-mode .loading { color: #6a5a40; }
    body.dark-mode .loading-spinner {
      border-color: rgba(80,60,30,0.2);
      border-top-color: rgba(80,60,30,0.6);
    }
    body.dark-mode .error-msg { color: #d08080; }

    /* Dark mode toggle itself */
    body.dark-mode .dark-mode-toggle {
      background: rgba(40,32,20,0.5);
      border-color: rgba(80,60,30,0.3);
      color: #c8a860;
    }
    body.dark-mode .dark-mode-toggle:hover { background: rgba(60,48,28,0.5); }

    /* Scrollbar */
    body.dark-mode ::-webkit-scrollbar-track { background: rgba(20,16,10,0.3); }
    body.dark-mode ::-webkit-scrollbar-thumb {
      background: linear-gradient(180deg, #6a5430, #4a3a20);
      border-color: rgba(30,26,20,0.5);
    }

    /* Cat accent colors — dark mode */
    body.dark-mode [data-cat="A"] .feat-detail-title { color: #70b0e0; }
    body.dark-mode [data-cat="C"] .feat-detail-title { color: #70c890; }
    body.dark-mode [data-cat="D"] .feat-detail-title { color: #b0b0d0; }
    body.dark-mode [data-cat="E"] .feat-detail-title { color: #e0b870; }
    body.dark-mode [data-cat="I"] .feat-detail-title { color: #b090d8; }
    body.dark-mode [data-cat="N"] .feat-detail-title { color: #b0d070; }
    body.dark-mode [data-cat="T"] .feat-detail-title { color: #d89878; }
    body.dark-mode [data-cat="V"] .feat-detail-title { color: #e08080; }

    /* ── Fade-in animation ───────────────────────────────────── */
    .fade-in { animation: fadeIn 0.25s ease; }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(6px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* ── Responsive ──────────────────────────────────────────── */
    @media (max-width: 860px) {
      .book-spine { display: none; }
      .main { flex-direction: column; }
      .feat-list {
        width: 100%;
        min-width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid rgba(160,120,60,0.2);
      }
      .feat-detail {
        max-height: none;
        padding: 24px 20px;
      }
      .filter-controls { margin-left: 0; }
      .search-bar { flex-wrap: wrap; padding: 14px 20px; }
      .header { padding: 20px 20px 0; }
      .active-filters { padding: 0 20px 10px; }
    }

    /* ── Feat Codex additions ─────────────────────────────────────────────── */
    .cat-disclaimer {
      display: flex;
      align-items: flex-start;
      gap: 9px;
      margin: 12px 36px;
      padding: 10px 14px;
      font-size: 13px;
      line-height: 1.5;
      color: #6a5a3a;
      background: rgba(200,170,110,0.12);
      border: 1px solid rgba(160,120,60,0.25);
      border-left: 3px solid rgba(160,120,60,0.5);
      border-radius: 4px;
    }
    .cat-disclaimer strong { color: #4a3a20; font-weight: 700; }
    .cat-disclaimer-icon {
      flex-shrink: 0;
      color: #a07a30;
      font-size: 14px;
      line-height: 1.4;
    }
    body.dark-mode .cat-disclaimer {
      color: #a0906a;
      background: rgba(60,48,28,0.22);
      border-color: rgba(100,80,40,0.3);
      border-left-color: rgba(120,95,45,0.55);
    }
    body.dark-mode .cat-disclaimer strong { color: #d0c090; }
    body.dark-mode .cat-disclaimer-icon { color: #c0a860; }

    /* Prerequisite feat chips inside the detail stat rows. */
    .feat-stat-value .feat-prereq-link {
      color: #6a4a1a;
      font-weight: 600;
      text-decoration: none;
      border-bottom: 1px dotted rgba(160,120,60,0.6);
      cursor: pointer;
    }
    .feat-stat-value .feat-prereq-link:hover { color: #3a2a18; border-bottom-style: solid; }
    .feat-stat-value .feat-prereq-text { color: #6a5a3a; }
    .feat-stat-value .feat-prereq-sep { opacity: 0.5; margin: 0 2px; }
    body.dark-mode .feat-stat-value .feat-prereq-link { color: #d8b878; border-bottom-color: rgba(160,120,60,0.5); }
    body.dark-mode .feat-stat-value .feat-prereq-link:hover { color: #f0d8a0; }
    body.dark-mode .feat-stat-value .feat-prereq-text { color: #a0906a; }

    /* The category label on each list row (renamed from the spellbook's
       per-item school tag). Keep it from crowding long feat names. */
    .feat-item-cat { white-space: nowrap; }

    /* ── Golden icon frames ───────────────────────────────────────────────── */
    /* Every feat icon — list rows, the detail header, member/successor rows —
       sits in a warm golden frame that reads well on parchment and shifts to a
       brighter brass in dark mode. */
    .feat-item-icon,
    .feat-cat-icon,
    .feat-member-icon,
    .feat-chip-icon {
      border: 2px solid #b8893a;
      border-radius: 6px;
      background: #f3e8cf;
      box-shadow: 0 0 0 1px rgba(60,40,15,0.18), inset 0 0 0 1px rgba(255,248,228,0.45);
      object-fit: cover;
    }
    body.dark-mode .feat-item-icon,
    body.dark-mode .feat-cat-icon,
    body.dark-mode .feat-member-icon,
    body.dark-mode .feat-chip-icon {
      border-color: #e6bf6a;
      background: #2a2114;
      box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 0 6px rgba(214,177,90,0.25);
    }

    /* ── Master-feat "more" indicators (NWN-style trailing ellipsis) ──────── */
    .feat-group-more,
    .feat-title-more,
    .feat-chip-more {
      color: #a8761f;
      font-weight: 700;
      letter-spacing: 1px;
    }
    body.dark-mode .feat-group-more,
    body.dark-mode .feat-title-more,
    body.dark-mode .feat-chip-more { color: #e6bf6a; }
    .feat-title-more { font-size: 0.8em; vertical-align: middle; }

    .feat-group-count {
      flex-shrink: 0;
      min-width: 22px;
      text-align: center;
      font-size: 11px;
      font-weight: 700;
      color: #6a4a1a;
      background: rgba(184,137,58,0.18);
      border: 1px solid rgba(160,120,60,0.4);
      border-radius: 10px;
      padding: 1px 6px;
      margin-left: auto;
    }
    body.dark-mode .feat-group-count {
      color: #e6bf6a;
      background: rgba(214,177,90,0.14);
      border-color: rgba(214,177,90,0.4);
    }
    .feat-item-group .feat-item-name { font-weight: 600; }

    .tag-group {
      background: rgba(184,137,58,0.18);
      color: #6a4a1a;
      border: 1px solid rgba(160,120,60,0.4);
    }
    body.dark-mode .tag-group { color: #e6bf6a; background: rgba(214,177,90,0.14); border-color: rgba(214,177,90,0.4); }

    /* ── Prerequisites / Required-For two-column layout ───────────────────── */
    .feat-relations {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px;
    }
    @media (max-width: 720px) { .feat-relations { grid-template-columns: 1fr; gap: 14px; } }
    .feat-relations-col h3 { margin-top: 0; }
    .feat-rel-empty { font-size: 13px; color: #8a7858; font-style: italic; padding: 6px 0; }
    body.dark-mode .feat-rel-empty { color: #9a8a68; }
    .feat-rel-note { font-size: 12px; color: #8a7858; margin-bottom: 8px; }
    body.dark-mode .feat-rel-note { color: #9a8a68; }

    .feat-rel-list { display: flex; flex-direction: column; gap: 6px; }

    /* Clickable chips (required-for entries). */
    .feat-chip {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border: 1px solid rgba(160,120,60,0.3);
      border-radius: 5px;
      background: rgba(200,170,110,0.08);
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .feat-chip:hover { background: rgba(200,170,110,0.2); border-color: rgba(160,120,60,0.6); }
    .feat-chip-icon { width: 24px; height: 24px; }
    .feat-chip-name { font-size: 14px; color: #4a3a20; }
    .feat-chip-more { margin-left: auto; }
    body.dark-mode .feat-chip { background: rgba(60,48,28,0.3); border-color: rgba(120,95,45,0.35); }
    body.dark-mode .feat-chip:hover { background: rgba(80,64,36,0.45); }
    body.dark-mode .feat-chip-name { color: #d8c8a0; }

    /* ── Member / successor rows (drill-in lists) ─────────────────────────── */
    .feat-member-list { display: flex; flex-direction: column; gap: 4px; }
    .feat-member {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 7px 10px;
      border: 1px solid rgba(160,120,60,0.25);
      border-radius: 5px;
      background: rgba(200,170,110,0.06);
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s, transform 0.05s;
    }
    .feat-member:hover { background: rgba(200,170,110,0.18); border-color: rgba(160,120,60,0.55); }
    .feat-member:active { transform: translateY(1px); }
    .feat-member-icon { width: 28px; height: 28px; }
    .feat-member-name { flex: 1; font-size: 14px; color: #4a3a20; }
    .feat-member-flag { width: 8px; height: 8px; border-radius: 50%; background: #b8893a; flex-shrink: 0; }
    .feat-member-go { color: #a8761f; font-weight: 700; }
    body.dark-mode .feat-member { background: rgba(60,48,28,0.28); border-color: rgba(120,95,45,0.3); }
    body.dark-mode .feat-member:hover { background: rgba(80,64,36,0.42); }
    body.dark-mode .feat-member-name { color: #d8c8a0; }
    body.dark-mode .feat-member-flag { background: #e6bf6a; }
    body.dark-mode .feat-member-go { color: #e6bf6a; }

    /* ── Back-link to a parent master feat ────────────────────────────────── */
    .feat-backlink {
      display: inline-block;
      font-size: 13px;
      color: #8a5a18;
      cursor: pointer;
      margin-bottom: 10px;
      font-weight: 600;
    }
    .feat-backlink:hover { color: #5a3a10; text-decoration: underline; }
    body.dark-mode .feat-backlink { color: #e6bf6a; }

    /* ── Epic XP (EEXP) — orchid accent that reads on both themes ──────────── */
    /* Shown as an "Epic XP Cost" row inside Prerequisites. Orchid is light on
       parchment, so light mode uses a deeper orchid; dark mode the brighter
       orchid that pops on the dark ground. */
    .eexp-value { color: #a3268f; font-weight: 700; white-space: nowrap; }
    body.dark-mode .eexp-value { color: #e497e0; }
    .eexp-link { color: #a3268f; font-weight: 600; }
    body.dark-mode .eexp-link { color: #e497e0; }

    /* The "E6 Only Feats" category tab gets a faint orchid tint. */
    .cat-tab[data-cat="99"].active { box-shadow: inset 0 -2px 0 #b5379f; }
