
  :root {
    --bg: #0d0c11;
    --panel: #17151f;
    --panel-2: #1f1c2b;
    --border: #332c44;
    --gold: #d8ac5c;
    --gold-bright: #ecc578;
    --gold-dim: #967131;
    --text: #ece4d6;
    --muted: #9e96a9;
    --danger: #e46f78;
    --ok: #4db380;
    --accent: #6ea8fe;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Georgia, serif;
    line-height: 1.45;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, .serif { font-family: Georgia, "Times New Roman", serif; }
  .num { font-variant-numeric: tabular-nums; }
  button, input, select, textarea {
    font-family: inherit;
    color: var(--text);
  }
  button {
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--panel-2);
    border-radius: 9px;
    padding: 7px 11px;
    font-size: 13px;
    min-height: 34px;
    transition: background .16s ease, border-color .16s ease, transform .1s ease, box-shadow .16s ease;
  }
  button:hover:not(:disabled) {
    border-color: var(--gold);
    background: #252133;
  }
  button:active:not(:disabled) { transform: scale(0.985); }
  button:disabled { opacity: .42; cursor: not-allowed; }
  .btn-gold {
    background: linear-gradient(135deg, #ddb262, #9b7028);
    color: #110f16;
    font-weight: 700;
    border-color: #e7c278;
  }
  .btn-gold:hover:not(:disabled) {
    background: linear-gradient(135deg, #e6be70, #a87b2e);
    border-color: #f3d28e;
  }
  .btn-danger { background: #3b171b; border-color: #7a2a33; color: #f6b8be; }
  .btn-danger:hover:not(:disabled) { background: #4a1c21; border-color: #b83d4a; }
  .btn-ok { background: #163628; border-color: #2c6d4f; color: #a7f0cb; }
  .btn-ok:hover:not(:disabled) { background: #1c4433; border-color: #3d946c; }
  .btn-sm { padding: 5px 9px; font-size: 12px; min-height: 30px; }
  .btn-xs { padding: 3px 8px; font-size: 11px; min-height: 25px; border-radius: 7px; }
  input, select, textarea {
    background: #100e16;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    width: 100%;
    max-width: 100%;
    transition: border-color .15s ease;
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
  }
  .wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  .card {
    background: linear-gradient(180deg, #191623 0%, #13111b 100%);
    border: 1px solid var(--border);
    border-top-color: rgba(216, 172, 92, 0.24);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.48);
    transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
  }
  .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .between { justify-content: space-between; }
  .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
  .grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
  @media (max-width: 680px) {
    .grid-6 { grid-template-columns: repeat(3, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
  }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #1d1929;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
  }
  .badge-archived { color: #b7b0c2; border-color: #4f485e; background: #221f2b; }
  .badge-ok { color: #b2f5d3; border-color: #2f7354; background: #142c22; }
  .badge-spell { color: #a6cbff; border-color: #2e5287; background: #13233b; }
  .badge-cantrip { color: #8be9fd; border-color: #24687a; background: #112a33; }
  .badge-ability { color: #ffd488; border-color: #825a22; background: #2b1f10; }
  .badge-passive { color: #c792ff; border-color: #8228d4; background: #2a183d; }
  .badge-equipment { color: #b8e0c8; border-color: #2f6b4a; background: #12261c; }
  .badge-unique { color: #f0c4a0; border-color: #8a5a2b; background: #2a1c10; }
  .badge-uses {
    color: var(--text);
    border-color: var(--border);
    background: #15121e;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
  }
  .badge-uses.exhausted {
    color: #ffb8bf;
    border-color: #8f2d38;
    background: #2e1216;
  }
  .badge-uses.at-will {
    color: #b2f5d3;
    border-color: #2f7354;
    background: #13291f;
  }
  .badge-dm-ctrl { color: #dfd6c7; border-color: #493f60; background: #1c1829; }
  .badge-gp { color: #ffd974; border-color: #bd8d2a; background: #2a210f; font-weight: 700; }
  .badge-combat {
    color: #ffd8dc;
    border-color: #ff4d5e;
    background: #5e131c;
    font-weight: 700;
    letter-spacing: .04em;
    box-shadow: 0 0 12px rgba(255, 77, 94, .42);
  }
  .muted { color: var(--muted); font-size: 12px; }

  /* 1. Collapsible Top Utility Drawer */
  .top-drawer-body {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(216, 172, 92, 0.2);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .drawer-subbox {
    background: #110f18;
    border: 1px solid #2b2538;
    border-radius: 9px;
    padding: 9px 11px;
  }

  /* 2. Two-Row Character Header Bubble */
  .hero-top-grid {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .avatar-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 10px;
  }
  .avatar {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid var(--gold-dim);
    background: #0d0c11;
    display: block;
    transition: border-color .16s ease, transform .16s ease;
  }
  .avatar-wrap:hover .avatar {
    border-color: var(--gold-bright);
    transform: scale(1.03);
  }
  .avatar-edit-pill {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #1d1928;
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 999px;
    padding: 1px 6px;
    font-size: 9px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,.85);
    pointer-events: none;
  }
  .hero-identity-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .hero-name-line {
    font-size: 19px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1.2;
    letter-spacing: 0.01em;
  }
  .hero-class-line {
    font-size: 13px;
    color: var(--text);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  .hero-status-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
  }
  .hero-vitals-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(216, 172, 92, 0.22);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .vital-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 240px;
  }
  .vital-meter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
    max-width: 240px;
  }
  .vital-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }
  .bar-track {
    width: 100%;
    height: 10px;
    background: #0d0c11;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
  }
  .hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #c94646, #4db380);
    transition: width .24s ease;
  }
  .xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6ea8fe, #d8ac5c);
    transition: width .24s ease;
  }

  /* 3. Unified Location, Time & Weather Bubble */
  .unified-world-bubble {
    background: linear-gradient(180deg, #181522 0%, #121019 100%);
    border: 1px solid var(--gold-dim);
    border-radius: 12px;
    padding: 8px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,.42);
  }
  .bubble-segment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
  }
  .bubble-segment svg {
    width: 15px;
    height: 15px;
    color: var(--gold);
    flex-shrink: 0;
  }
  .bubble-divider {
    width: 1px;
    height: 18px;
    background: rgba(216, 172, 92, 0.25);
  }
  @media (max-width: 680px) {
    .bubble-divider { display: none; }
  }

  /* Shared Floating Tooltip Pill */
  .tip-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #13111a;
    border: 1px solid #2b2538;
    color: var(--muted);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: all .16s ease;
  }
  .tip-icon-btn svg { pointer-events: none; }
  .tip-icon-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #1d1928;
    color: var(--gold);
    border: 1px solid var(--gold-dim);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 45;
    box-shadow: 0 6px 16px rgba(0,0,0,.72);
  }
  .tip-icon-btn:hover::after,
  .tip-icon-btn:focus-visible::after,
  .tip-icon-btn.show-tip::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  /* 4. Coherent Perception Panel (6 Senses) — single self-contained channel */
  .perception-panel {
    background: #110f18;
    border: 1px solid #2b2538;
    border-radius: 10px;
    padding: 8px 10px 10px;
    margin-bottom: 10px;
  }
  .perception-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 0;
  }
  .perception-panel.is-open .perception-header {
    margin-bottom: 8px;
  }
  .perception-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gold);
  }
  .perception-toggle {
    padding: 3px 8px;
    min-height: 26px;
    font-size: 11px;
    border-radius: 7px;
    color: var(--muted);
  }
  .perception-toggle:hover {
    color: var(--gold);
    border-color: var(--gold-dim);
  }
  .perception-summary {
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
    margin-right: 6px;
  }
  .perception-body {
    display: none;
  }
  .perception-panel.is-open .perception-body {
    display: block;
  }
  .senses-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
    margin-bottom: 0;
    padding: 0;
  }
  .sense-icon-btn {
    width: 40px;
    height: 38px;
    border-radius: 999px;
    flex-shrink: 0;
  }
  .sense-icon-btn svg { width: 18px; height: 18px; }
  .sense-icon-btn.active {
    border-color: var(--gold);
    color: var(--gold);
    background: #241e16;
    box-shadow: 0 0 12px rgba(216,172,92,.3);
  }
  .sense-icon-btn.selected {
    outline: 1px solid rgba(216,172,92,.75);
    color: var(--text);
  }
  .sense-detail {
    background: #0d0b12;
    border-left: 3px solid var(--gold-dim);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    margin-top: 8px;
  }
  .sense-detail.sense-detail-new {
    border-left-color: var(--gold);
    background: #1a1620;
  }
  .sense-new-pill {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    color: #110f16;
    background: var(--gold);
    border-radius: 999px;
    padding: 0 5px;
    margin-left: 4px;
    vertical-align: middle;
  }

  /* 5. Tall DM Dialogue Feed, Combat Mode Crimson Styling & Live Audit Strip */
  .dm-feed {
    min-height: 0;          /* shrinks to fit the current message(s) */
    max-height: 780px;      /* maximum size: scrolls only once content exceeds this */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #0f0d15;
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
  }
  .card.combat-active {
    background: linear-gradient(180deg, #2b1116 0%, #1a0b0e 100%);
    border-color: #d93848;
    box-shadow: 0 0 28px rgba(217, 56, 72, .34);
  }
  .dm-feed > .msg { flex: 0 0 auto; }
  .dm-older-link {
    flex: 0 0 auto;
    display: block;
    width: 100%;
    text-align: center;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px dashed var(--gold-dim);
    background: #14111c;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }
  .dm-older-link:hover { background: #1d1829; border-color: var(--gold); }
  .dm-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    background: #0f0d15;
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .dm-log-list .msg { margin-left: 0; }
  .dm-log-list .msg-ic, .dm-log-list .msg-ooc { margin-left: 18px; }
  /* DM-controlled "here and now" boxes: never scroll, never keep history */
  .sense-detail, .roll-callout { overflow: visible; max-height: none; }
  .card.combat-active .dm-feed {
    background: #17090c;
    border-color: #9e2633;
  }
  .card.combat-active .msg-dm {
    background: #240e13;
    border-color: #8c232e;
  }
  .combat-banner-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(140, 24, 36, .34);
    border: 1px solid #d93848;
    font-size: 12px;
    color: #ffd6da;
  }
  .combat-summary-card {
    margin-top: 8px;
    padding: 9px 11px;
    border-radius: 8px;
    background: #14111c;
    border: 1px solid var(--gold-dim);
    border-left: 3px solid var(--gold);
    font-size: 12.5px;
  }
  .dm-audit-strip {
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px dashed rgba(216, 172, 92, .28);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
  }
  .audit-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #13111c;
    color: var(--text);
    font-variant-numeric: tabular-nums;
  }
  .audit-pill.pos {
    color: #b2f5d3;
    border-color: #2f7354;
    background: #13291f;
  }
  .audit-pill.neg {
    color: #ffb8bf;
    border-color: #8f2d38;
    background: #2e1216;
  }
  .audit-pill.info {
    color: #ffd974;
    border-color: #8c6a24;
    background: #241c0d;
  }

  .dice-ic-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
    margin-top: 8px;
  }
  .dice-ic-row .dice-btn {
    flex: 1 1 38px;
    text-align: center;
    padding: 5px 4px;
    font-variant-numeric: tabular-nums;
  }
  .dice-ic-row .mode-pill-btn {
    flex: 1.4 1 64px;
    text-align: center;
    padding: 5px 8px;
  }
  .player-compose-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
  }
  .player-textarea {
    width: 100%;
    min-height: 112px;
    max-height: 360px;
    resize: vertical;
    line-height: 1.45;
    padding: 10px 12px;
    font-size: 13.5px;
    overflow-y: auto;
  }
  .msg {
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
  }
  .msg-dm { background: #181523; border: 1px solid #302940; }
  .msg-ic { background: #221d30; border: 1px solid #493f63; margin-left: 18px; }
  .msg-ooc { background: #14222c; border: 1px dashed #3d6d8f; margin-left: 18px; color: #cbe6fa; }
  .msg-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(216,172,92,.16);
  }
  .msg-head {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gold);
  }
  .dm-inline-tools {
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }
  .btn-speaking {
    background: #3b171b;
    border-color: var(--danger);
    color: #ffd4d8;
    font-weight: 700;
  }
  .roll-callout {
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #14121d;
    border: 1px solid #2c263b;
    font-size: 12px;
    color: #d6cebe;
  }

  /* 6. Evenly Spread 5 Icon-Only Gameplay Tabs */
  .tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
    border-bottom: 1px solid rgba(216, 172, 92, 0.2);
    padding: 4px 4px 10px;
  }
  .tab-btn {
    width: 48px;
    min-width: 0;
    height: 44px;
    border-radius: 10px;
    flex: 1 1 0;
    max-width: 48px;
  }
  .tab-btn svg { width: 20px; height: 20px; }
  .tab-btn.active {
    background: #221d2f;
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 14px rgba(216,172,92,.24);
  }

  /* 7. Read-Only Character Sheet Saves, Skills, Traits & Abilities */
  .sheet-section {
    background: #100e16;
    border: 1px solid #2b2538;
    border-radius: 9px;
    padding: 10px 12px;
  }
  .save-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #15121e;
    border: 1px solid #2b2538;
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 12px;
    cursor: default;
    font-variant-numeric: tabular-nums;
  }
  .save-pill.prof {
    border-color: var(--gold-dim);
    background: #1a1626;
  }
  .prof-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
    margin-right: 6px;
    border: 1px solid var(--gold);
    flex-shrink: 0;
  }
  .prof-dot.on {
    background: var(--gold);
  }
  .skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 6px;
  }
  .skill-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #15121e;
    border: 1px solid #2b2538;
    border-radius: 7px;
    padding: 5px 9px;
    font-size: 12px;
    cursor: default;
    font-variant-numeric: tabular-nums;
  }
  .skill-pill.prof {
    border-color: var(--gold-dim);
    background: #1a1626;
  }

  /* Interactive Proficiency Buttons in Character Generator */
  .gen-prof-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    background: #13111c;
    border: 1px solid #2b2538;
    border-radius: 7px;
    padding: 5px 8px;
    font-size: 12px;
    min-height: 30px;
  }
  .gen-prof-btn.selected {
    border-color: var(--gold);
    background: #241e16;
    color: var(--gold);
  }

  /* 8. Non-Tactical Illustrated Regional World Map & Proximity Directory */
  .map-stage {
    position: relative;
    width: 100%;
    height: 350px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--gold-dim);
    background: #15181c;
    box-shadow: 0 10px 26px rgba(0,0,0,.55);
  }
  .map-regional-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
  }
  .map-pin {
    position: absolute;
    transform: translate(-50%, -50%);
    background: rgba(18, 15, 26, 0.92);
    border: 1.5px solid var(--gold);
    color: var(--gold);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    min-height: 26px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,.78);
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }
  .map-pin:hover {
    background: #272136;
    border-color: #f0ca7c;
  }
  .map-pin.unvisited {
    background: rgba(18, 16, 24, 0.78);
    border-color: #797288;
    color: #c2bccf;
    border-style: dashed;
  }
  .map-pin-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--gold);
    display: inline-block;
  }
  .map-pin.unvisited .map-pin-dot { background: #797288; }
  .loc-group-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gold);
    margin: 12px 0 6px;
  }
  .loc-list-card {
    background: #100e16;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px 11px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .loc-list-card.visited { border-color: rgba(216,172,92,.42); }
  .fav-btn {
    padding: 3px 7px;
    min-height: 25px;
    font-size: 13px;
    border-radius: 7px;
    color: var(--muted);
  }
  .fav-btn.pinned {
    color: var(--gold);
    border-color: var(--gold);
    background: #241e16;
  }

  /* 9. Bullet-Point Equipment Summary (Green / Red), 12-Slot Paper-Doll & Treasure Vault */
  .equip-summary-box {
    background: linear-gradient(90deg, #1b1726 0%, #14121d 100%);
    border: 1px solid var(--gold-dim);
    border-radius: 10px;
    padding: 10px 13px;
    margin-bottom: 12px;
  }
  .equip-bullet-list {
    margin: 6px 0 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12.5px;
  }
  .equip-bullet-pos { color: var(--ok); }
  .equip-bullet-neg { color: var(--danger); }
  .equip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }
  /* Stacked body-layout equipment rack (12 slots) */
  .equip-rack-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
    overflow-x: auto;
    padding: 6px 0 10px;
  }
  .equip-rack {
    display: grid;
    grid-template-columns: 88px 96px 88px;
    grid-template-rows: 76px 76px 84px 76px 76px 76px;
    gap: 7px;
    justify-content: center;
    padding: 10px;
    background: linear-gradient(180deg, #14111c 0%, #0e0c14 100%);
    border: 1px solid var(--gold-dim);
    border-radius: 14px;
    box-shadow: inset 0 0 24px rgba(0,0,0,.35);
  }
  .rack-slot {
    position: relative;
    background:
      linear-gradient(145deg, rgba(40,34,52,.55) 0%, rgba(18,15,26,.9) 100%);
    border: 1.5px solid #3a334b;
    border-radius: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 4px;
    cursor: default;
    transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
    min-width: 0;
  }
  .rack-slot.filled {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(216,172,92,.28), inset 0 0 10px rgba(216,172,92,.06);
    background: linear-gradient(160deg, #2a2336 0%, #18141f 100%);
    cursor: pointer;
  }
  .rack-slot.filled:hover {
    transform: translateY(-1px);
    border-color: var(--gold-bright);
  }
  .rack-slot.locked {
    opacity: .4;
    border-style: dashed;
    background: #0d0b12;
  }
  .rack-slot-label {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #7a738a;
    line-height: 1.15;
    text-align: center;
  }
  .rack-slot.filled .rack-slot-label { color: var(--gold); }
  .rack-slot-img {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    object-fit: cover;
    border: 1px solid var(--gold-dim);
    background: #0d0c11;
  }
  .rack-slot-empty-ico {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px dashed #3a334b;
    color: #5c546e;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.25);
  }
  .rack-slot-name {
    font-size: 9px;
    color: var(--text);
    text-align: center;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
  }
  .rack-unequip {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    border-radius: 999px;
    font-size: 10px;
    line-height: 1;
    background: #3b171b;
    border-color: #7a2a33;
    color: #f6b8be;
    z-index: 2;
  }
  .rack-unequip:hover {
    background: #5a1f26;
    border-color: #b83d4a;
  }
  /* Anatomical stack — 3 columns, no outer empty gutters */
  .rack-slot[data-slot="head"]      { grid-column: 2; grid-row: 1; }
  .rack-slot[data-slot="amulet"]    { grid-column: 1; grid-row: 2; }
  .rack-slot[data-slot="body"]      { grid-column: 2; grid-row: 2; }
  .rack-slot[data-slot="cloak"]     { grid-column: 3; grid-row: 2; }
  .rack-slot[data-slot="leftHand"]  { grid-column: 1; grid-row: 3; }
  .rack-slot[data-slot="twoHanded"] { grid-column: 2; grid-row: 3; }
  .rack-slot[data-slot="rightHand"] { grid-column: 3; grid-row: 3; }
  .rack-slot[data-slot="gloves"]    { grid-column: 1; grid-row: 4; }
  .rack-slot[data-slot="greaves"]   { grid-column: 2; grid-row: 4; }
  .rack-slot[data-slot="belt"]      { grid-column: 3; grid-row: 4; }
  .rack-slot[data-slot="ring1"]     { grid-column: 1; grid-row: 5; }
  .rack-slot[data-slot="utility"]   { grid-column: 2; grid-row: 5; }
  .rack-slot[data-slot="ring2"]     { grid-column: 3; grid-row: 5; }
  .rack-slot[data-slot="boots"]     { grid-column: 2; grid-row: 6; }
  @media (max-width: 420px) {
    .equip-rack {
      grid-template-columns: 74px 82px 74px;
      grid-template-rows: 68px 68px 74px 68px 68px 68px;
      gap: 5px;
      padding: 8px;
    }
    .rack-slot-img { width: 32px; height: 32px; }
    .rack-slot-name { max-width: 70px; font-size: 8px; }
  }
  .slot-mini-img {
    width: 42px;
    height: 42px;
    max-width: 150px;
    max-height: 150px;
    border-radius: 7px;
    border: 1px solid var(--gold-dim);
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
  }
  .slot-empty-box {
    width: 42px;
    height: 42px;
    border-radius: 7px;
    border: 1px dashed #3a334b;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5c546e;
    font-size: 10px;
    flex-shrink: 0;
  }
  .item-link-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(216,172,92,.55);
    text-underline-offset: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }
  .item-link-title:hover {
    color: var(--gold);
    text-decoration-color: var(--gold);
  }
  .treasure-vault-box {
    background: linear-gradient(180deg, #1b1621 0%, #120f17 100%);
    border: 1px solid var(--gold-dim);
    border-radius: 10px;
    padding: 10px 13px;
    margin-top: 14px;
  }
  .coin-purse-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 8px 0;
  }
  .coin-cell {
    background: #0f0d15;
    border: 1px solid #302840;
    border-radius: 8px;
    padding: 6px 8px;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  /* <=150x150 Cohesive Thumbnail Sprites */
  .sprite-box {
    position: relative;
    width: 64px;
    height: 64px;
    max-width: 150px;
    max-height: 150px;
    flex-shrink: 0;
  }
  .sprite-thumb {
    width: 64px;
    height: 64px;
    max-width: 150px;
    max-height: 150px;
    border-radius: 9px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--gold-dim);
    background: #14111c;
    box-shadow: inset 0 0 8px rgba(0,0,0,.65);
    display: block;
    transition: transform .15s ease, border-color .15s ease;
  }
  .sprite-thumb:hover {
    border-color: var(--gold);
    transform: scale(1.04);
  }
  .sprite-gen-mini {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 21px;
    height: 21px;
    min-height: 21px;
    padding: 0;
    border-radius: 999px;
    background: #221c2e;
    border: 1px solid var(--gold);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.8);
  }
  .sprite-gen-mini svg { width: 11px; height: 11px; }
  .sprite-preview-img {
    width: 150px;
    height: 150px;
    max-width: 150px;
    max-height: 150px;
    border-radius: 10px;
    border: 2px solid var(--gold);
    background: #14111c;
    object-fit: cover;
  }

  .rare-add-footer {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .inline-entry-box {
    margin-top: 10px;
    padding: 10px;
    border-radius: 9px;
    background: #12101a;
    border: 1px solid var(--gold-dim);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* Modals, Toasts & Error Banner */
  .modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.82);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
  }
  .modal {
    background: #16141f;
    border: 1px solid var(--gold-dim);
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .portrait-studio-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
  }
  .portrait-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 124px;
    flex-shrink: 0;
  }
  .appearance-select-grid {
    flex: 1 1 240px;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  @media (max-width: 540px) {
    .appearance-select-grid {
      grid-template-columns: minmax(0, 1fr);
    }
    .portrait-preview-col {
      width: 100%;
    }
  }
  .appearance-select-grid select {
    width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
  }
  .toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 80;
    background: #1d1928;
    border: 1px solid var(--gold);
    color: var(--text);
    padding: 9px 14px;
    border-radius: 9px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0,0,0,.65);
    max-width: calc(100vw - 32px);
  }
  .err-banner {
    background: #471419;
    border: 1px solid #d9534f;
    color: #ffd4d8;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    display: none;
  }
  .portrait-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .portrait-thumb {
    width: 58px;
    height: 58px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid var(--border);
    flex-shrink: 0;
    transition: border-color .15s ease, transform .15s ease;
  }
  .portrait-thumb:hover { transform: scale(1.04); }
  .portrait-thumb.selected {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(216,172,92,.35);
  }
  .spin {
    display: inline-block;
    animation: spin360 1s linear infinite;
  }
  @keyframes spin360 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
  .atlas-scroll { overflow:auto; border-radius:9px; background:#21160e; }
  .atlas-scroll svg { display:block; width:100%; min-width:560px; height:auto; }
  .atlas-label { font-family:Georgia,serif; font-size:13px; font-weight:bold; fill:#392516; paint-order:stroke; stroke:#e8cf99; stroke-width:3px; stroke-linejoin:round; }
  .atlas-mark { cursor:pointer; }
  .atlas-mark:hover .atlas-label { fill:#8c311b; }
.undone-msg { text-decoration: line-through; opacity: .65; }

/* v0.5.7i gameplay focus */
.gameplay-focus{scroll-margin-top:40px;gap:6px}
.gameplay-focus .perception-panel{padding:6px 8px;margin-bottom:0}
.gameplay-focus .perception-header{margin-bottom:4px}
.gameplay-focus .sense-detail{max-height:64px;overflow:auto;font-size:12px;padding:6px 8px}
.gameplay-focus .sense-icon-btn{height:32px;width:34px}
.dialogue-toolbar{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
.dialogue-toolbar button{font-size:12px;padding:6px 3px;white-space:nowrap}
.gameplay-focus .dm-feed{height:clamp(160px,calc(100dvh - 390px),560px);max-height:none;min-height:150px;overscroll-behavior:contain;padding:6px}
.gameplay-focus .msg{padding:8px 10px}
.gameplay-focus .player-textarea{min-height:64px;max-height:120px;font-size:16px}
.gameplay-focus .roll-callout{width:100%;text-align:left;color:var(--gold);padding:6px 8px;font-size:12px}
.compact-log-row{display:flex;justify-content:space-between;gap:6px}
.compose-modes{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.purse-compact{color:#ffd974;font-size:13px;white-space:nowrap}
.msg-dice{background:#292319;border:1px solid var(--gold-dim);color:var(--gold)}
.msg-dice p{margin:4px 0}
.gameplay-categories{scroll-margin-top:40px}
.gameplay-categories .tabs{position:sticky;top:35px;background:#17141f;z-index:5}
@media(max-width:480px){.gameplay-focus{padding:8px}.gameplay-focus .dm-feed{height:clamp(145px,calc(100dvh - 365px),440px)}.gameplay-focus .player-compose-form{gap:5px}.gameplay-categories .tabs{margin-bottom:4px}}

/* Dialogue visual hierarchy */
.gameplay-focus.card{border-color:transparent;box-shadow:none;background:transparent}
.gameplay-focus .dm-feed{border:2px solid #b18a4d;border-radius:12px}
.gameplay-focus .player-textarea{border:2px solid #b18a4d;border-radius:10px}
.gameplay-focus .player-textarea:focus{border-color:#e4c17a;outline:1px solid #e4c17a}
.gameplay-focus .msg{border:0;border-radius:7px}
.gameplay-focus .msg-dice{border-left:3px solid #b18a4d}
.gameplay-focus .perception-panel{border:0;box-shadow:none}
.dialogue-toolbar button,.compact-log-row button{background:transparent;border:0;box-shadow:none;color:var(--gold);min-height:36px}
.dialogue-toolbar button:disabled,.compact-log-row button:disabled{opacity:.38}
.dialogue-toolbar button:focus-visible,.compact-log-row button:focus-visible{outline:2px solid var(--gold)}

/* Class tab: match sheet typography */
.class-section,.class-overview{font-size:12.5px;line-height:1.45;color:var(--text)}
.class-section-title{color:var(--gold);font-size:13px;font-weight:700;cursor:pointer}
.class-section p,.class-overview p{margin:5px 0}
.class-section li{margin:4px 0}
.class-overview{display:flex;align-items:center;justify-content:space-between;gap:12px}
.class-emblem{width:42px;height:42px;flex-shrink:0;color:var(--gold)}
