:root {
  --bg: #14161c; --panel: #1c2029; --line: #2c3240; --ink: #e6e8ee;
  --muted: #9aa3b5; --gold: #d9b45b; --ok: #6fbf73; --bad: #e0645f; --hover: #262c38;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 16px/1.5 "Segoe UI", system-ui, sans-serif; }
a { color: var(--gold); }

/* --- header ------------------------------------------------------------------------------ */
header { background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 20px;
         position: relative; z-index: 10; }
nav { display: flex; gap: 18px; align-items: center; max-width: 1000px; margin: 0 auto;
      min-height: 56px; }
nav .brand { font-weight: 700; color: var(--gold); letter-spacing: .04em; text-decoration: none;
             margin-right: 4px; white-space: nowrap; }
nav .sections { display: flex; gap: 18px; align-items: center; margin-right: auto; }
nav .sections a, nav .account a:not(.btn) { text-decoration: none; color: var(--muted);
                                            padding: 6px 0; }
nav .sections a:hover, nav .sections a.active,
nav .account a:not(.btn):hover, nav .account a.active { color: var(--ink); }
nav .account { margin-left: auto; display: flex; gap: 16px; align-items: center; }

details.menu { position: relative; margin-left: auto; }
details.menu summary { list-style: none; cursor: pointer; display: flex; align-items: center;
                       gap: 8px; padding: 5px 8px 5px 5px; border-radius: 8px; color: var(--ink);
                       user-select: none; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary:hover, details.menu[open] summary { background: var(--hover); }
details.menu .caret { color: var(--muted); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #1a1408;
          font-weight: 700; font-size: 14px; display: inline-flex; align-items: center;
          justify-content: center; flex: none; }
.avatar.big { width: 40px; height: 40px; font-size: 18px; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px;
              background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
              padding: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45); display: flex;
              flex-direction: column; }
.menu-panel a { padding: 9px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.menu-panel a:hover, .menu-panel a.active { background: var(--hover); }
.menu-head { padding: 8px 12px 6px; color: var(--muted); font-size: 12px; letter-spacing: .04em;
             text-transform: uppercase; white-space: nowrap; }
.menu-sep { display: none; height: 1px; background: var(--line); margin: 6px 4px; }
.menu-panel .phone-only { display: none; }

@media (max-width: 760px) {
  nav { gap: 12px; }
  nav .sections { display: none; }
  details.menu .menu-name { display: none; }
  .menu-panel { position: fixed; left: 12px; right: 12px; top: 62px; min-width: 0; }
  .menu-panel .phone-only, .menu-sep.phone-only { display: block; }
}

/* --- page ---------------------------------------------------------------------------------- */
main { max-width: 1000px; margin: 24px auto; padding: 0 20px; }

.subnav { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
          flex-wrap: wrap; }
.subnav a { padding: 8px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px;
            text-decoration: none; color: var(--muted); }
.subnav a:hover { color: var(--ink); }
.subnav a.active { border-bottom-color: var(--gold); color: var(--ink); }
.crumb { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
         padding: 18px 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
              flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h1, .panel-head h2 { margin: 0; }
.panel-head a { text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 12px; color: var(--gold); }
h3 { font-size: 16px; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: 3fr 2fr; gap: 18px; }
.grid.even { grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid.two, .grid.even { grid-template-columns: 1fr; } }
.grid > * { min-width: 0; }
.grid > .panel { margin-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- forms ------------------------------------------------------------------------------ */
label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 14px; }
input, select, button, textarea { font: inherit; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 9px 11px; background: #12141a; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; }
input:disabled { opacity: .5; }
textarea { min-height: 120px; resize: vertical; }
button, .btn { background: var(--gold); color: #1a1408; border: 0; border-radius: 6px;
               padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none;
               display: inline-block; line-height: 1.5; }
button.quiet, .btn.quiet { background: #2c3240; color: var(--ink); }
button.danger { background: var(--bad); color: #fff; }
button.small, .btn.small { padding: 5px 11px; font-size: 13px; }
button:not(:disabled):hover, .btn:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }

/* --- tables ----------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 13px; font-weight: 600; }
table a { text-decoration: none; }
table a:hover { text-decoration: underline; }
table tr:has(td):hover td { background: rgba(255, 255, 255, .025); }
table.kv th { width: 160px; }
tr:last-child td { border-bottom: 0; }
@media (max-width: 760px) {
  /* Fact tables stack label over value. Stat tables stay two columns: short labels, numbers. */
  table.kv:not(.stats) th { width: auto; padding-bottom: 0; border-bottom: 0; }
  table.kv:not(.stats) tr { display: grid; }
}

/* --- bits -------------------------------------------------------------------------------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: #1e3324; border: 1px solid var(--ok); }
.flash.error { background: #341f1e; border: 1px solid var(--bad); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px;
        background: #2c3240; color: var(--muted); white-space: nowrap; }
.pill.up { background: #1e3324; color: var(--ok); }
.pill.down { background: #341f1e; color: var(--bad); }
.pill.tag { background: #2c2a1e; color: var(--gold); }
pre { background: #0e1015; border: 1px solid var(--line); border-radius: 8px;
      padding: 12px; overflow-x: auto; font-size: 13px; }
details.log summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-top: 12px; }
details.log summary:hover { color: var(--ink); }
details.log pre { max-height: 260px; overflow: auto; margin: 8px 0 0; white-space: pre-wrap;
                  overflow-wrap: anywhere; }

/* --- front page --------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px;
         margin: 16px 0 6px; }
.stat { background: #12141a; border: 1px solid var(--line); border-radius: 8px;
        padding: 12px 14px; }
.stat-value { display: block; font-size: 26px; font-weight: 700; color: var(--ink);
              line-height: 1.2; }
.stat-value .pill { font-size: 14px; vertical-align: middle; }
.stat-label { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat.realm { grid-column: 1 / -1; }
}
.you { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.you-text { display: flex; flex-direction: column; flex: 1; min-width: 200px; }
.you-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.announce { padding: 12px 0; border-bottom: 1px solid var(--line); }
.announce:first-of-type { padding-top: 0; }
.announce:last-of-type { border-bottom: 0; padding-bottom: 0; }
.announce-body { white-space: pre-line; margin-top: 6px; }

/* --- companion story ------------------------------------------------------------------------ */
.story-name { font-size: 24px; color: var(--ink); margin: 0 0 8px; }
.story { max-width: 72ch; margin-bottom: 10px; }
.story p { margin: 0 0 10px; line-height: 1.6; }
.fragments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .fragments { grid-template-columns: 1fr; } }
.fragment { background: #12141a; border: 1px solid var(--line); border-radius: 8px;
            padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.fragment strong { font-size: 16px; }
.fragment p { margin: 6px 0 0; line-height: 1.5; }
.frag-kind { color: var(--gold); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
/* Choosing the path: three cards a row, radios hidden, the picked card lit. */
.path-heading { margin-top: 18px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }
.card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
        background: #12141a; border: 2px solid var(--line); border-radius: 8px; cursor: pointer;
        font-size: 14px; }
.card input { position: absolute; opacity: 0; width: 0; height: 0; }
.card:hover { border-color: #4a566c; }
.card:has(input:checked) { border-color: var(--gold); background: #2c2a1e; }
.card:has(input:focus-visible) { box-shadow: 0 0 0 2px #ffffff33; }
.card strong { font-size: 16px; }
.card.pair { cursor: default; }
.card.pair .side { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px;
                   border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.card.pair .side:hover { border-color: #4a566c; }
.card.pair .side:has(input:checked) { border-color: var(--gold); background: #3a3524; }
.card.pair:has(input:checked) { border-color: var(--gold); }

dl.compass { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0;
             font-size: 15px; }
dl.compass dt { color: var(--muted); }
dl.compass dd { margin: 0; }
@media (max-width: 760px) { dl.compass { grid-template-columns: 1fr; } dl.compass dd { margin-bottom: 6px; } }

/* --- companion dossier ---------------------------------------------------------------------- */
/* One document: the header spans both columns, the figure and gear sit left, the story right. */
.dossier .kicker { color: var(--muted); font-size: 12px; letter-spacing: .08em;
                   text-transform: uppercase; margin-bottom: 2px; }
.dossier .char-name .pill { vertical-align: middle; margin-left: 10px; }
/* The figure floats left and the biography wraps around it, magazine style. Underneath, two
   ruled sections: what drives the companion (the compass), then the story path, three cards
   across. */
.dossier-body { display: flow-root; }
.dossier-figure { float: left; width: 50%; margin: 0 24px 10px 0; }
.dossier-figure .figure-note { margin: 8px 0 0; }
.dossier-text .story { max-width: none; }
.dossier-text .story p:first-child { margin-top: 0; }
.dossier-heading { color: var(--gold); font-size: 12px; letter-spacing: .08em;
                   text-transform: uppercase; margin: 18px 0 8px; }
.dossier-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.dossier-section .dossier-heading { margin-top: 0; }
.dossier-foot { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px;
                padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .dossier-figure { float: none; width: auto; margin: 0 0 14px; }
}

/* --- armory (character page) --------------------------------------------------------------- */
.armory-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.armory-bar .picker { display: flex; align-items: center; gap: 8px; }
.armory-bar .picker select { width: auto; min-width: 220px; }
.armory-bar .subnav { margin: 0 0 0 auto; border-bottom: 0; }
.armory-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
               flex-wrap: wrap; margin-bottom: 14px; }
.char-name { font-size: 32px; margin: 0; line-height: 1.1; }
.char-title { color: var(--gold); font-size: 15px; }
.char-line { margin-top: 4px; }
.ilvl { text-align: right; }
.ilvl-value { display: block; font-size: 38px; font-weight: 700; color: var(--gold);
              line-height: 1; }
.coin { display: inline-block; padding-right: 13px; position: relative; margin-left: 4px; }
.coin::after { content: ""; position: absolute; right: 0; top: 50%; width: 9px; height: 9px;
               margin-top: -5px; border-radius: 50%; }
.coin.g::after { background: #e5c34a; }
.coin.s::after { background: #c0c0c0; }
.coin.c::after { background: #b87333; }

.armory-body { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 10px;
               align-items: start; }
.viewer iframe { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 10px;
                 background: #1a1a22; display: block; }
.gear { display: flex; flex-direction: column; gap: 6px; }
.gear-bottom { grid-column: 1 / -1; flex-direction: row; justify-content: center; }
.slot { position: relative; width: 56px; height: 56px; border: 2px solid #2c3240; border-radius: 7px;
        background: #12141a; cursor: default; }
.slot img { width: 100%; height: 100%; display: block; border-radius: 5px; object-fit: cover; }
.slot.empty span { position: absolute; inset: 0; display: flex; align-items: center;
                   justify-content: center; text-align: center; font-size: 10px; line-height: 1.1;
                   color: #4a5468; padding: 4px; }
.slot.q0 { border-color: #9d9d9d; } .slot.q1 { border-color: #d8d8d8; }
.slot.q2 { border-color: #1eff00; } .slot.q3 { border-color: #0070dd; }
.slot.q4 { border-color: #a335ee; } .slot.q5 { border-color: #ff8000; }
.slot.q6, .slot.q7 { border-color: #e6cc80; }
.slot:hover, .slot:focus { outline: 0; box-shadow: 0 0 0 2px #ffffff33; }
.tip { display: none; position: absolute; top: -4px; z-index: 40; width: 290px; padding: 10px 12px;
       background: #0b0d12f2; border: 1px solid #3a4050; border-radius: 8px; font-size: 13px;
       line-height: 1.35; text-align: left; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.gear-left .tip { left: 62px; }
.gear-right .tip { right: 62px; }
.gear-bottom .tip { top: auto; bottom: 62px; left: 50%; transform: translateX(-50%); }
.slot:hover .tip, .slot:focus .tip, .slot.open .tip { display: block; }
.tip-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.tip-set { color: var(--gold); }
.tip-line { color: var(--ink); }
.tip-split { display: flex; justify-content: space-between; gap: 10px; }
.tip .green { color: #1eff00; }
.tip .flavor { color: var(--gold); font-style: italic; margin-top: 4px; }
.tip .socket { display: flex; align-items: center; gap: 6px; }
.gem { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #555; flex: none;
       background: #2c3240; }
.gem.red { background: #c0392b; } .gem.yellow { background: #d4ac0d; }
.gem.blue { background: #2e86c1; } .gem.meta { background: #6c6c6c; }
.gem.prismatic { background: linear-gradient(135deg, #c0392b, #d4ac0d, #2e86c1); }
table.kv.stats th { width: 60%; }
@media (max-width: 760px) {
  .armory-body { grid-template-columns: 1fr; }
  .gear, .gear-bottom { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .tip, .gear-left .tip, .gear-right .tip, .gear-bottom .tip {
    position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; transform: none; }
  .slot:hover .tip { display: none; }
  .slot.open .tip { display: block; }
  .armory-bar .subnav { margin-left: 0; }
}

/* --- appearance steppers (character edit and the companion builder) ----------------------- */
.appear-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; max-width: 380px; }
.appear-label { flex: 1; color: #9aa3b5; font-size: 14px; }
.appear-value { min-width: 62px; text-align: center; font-variant-numeric: tabular-nums;
                color: #ffeab5; font-size: 14px; }
.arrow { background: #232936; border: 1px solid #39415244; color: #d5d9e2; border-radius: 6px;
         width: 30px; height: 30px; line-height: 1; font-size: 17px; cursor: pointer; padding: 0; }
.arrow:hover { background: #2e3646; }
.arrow:disabled { opacity: .3; cursor: default; }

/* --- addons catalog (addons/index.html) --- */
.addon-search { margin-bottom: 16px; }
.addon-search input {
  width: 100%; padding: 11px 14px; border-radius: 8px; font-size: 15px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.addon-search input:focus { outline: none; border-color: var(--gold); }

.addon-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .addon-layout { grid-template-columns: 1fr; } }

.addon-facets { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px 14px; }
.facet { border-bottom: 1px solid var(--line); padding: 10px 0; }
.facet:last-of-type { border-bottom: 0; }
.facet-head {
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  margin: 0 0 8px; font-size: 14px; color: var(--ink);
}
.facet-head .chev { border: solid var(--muted); border-width: 0 1.5px 1.5px 0; padding: 3px; transform: rotate(-135deg); }
.facet.collapsed .chev { transform: rotate(45deg); }
.facet.collapsed .facet-body, .facet.collapsed .facet-note, .facet.collapsed .facet-more { display: none; }
.facet-item { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; cursor: pointer; font-size: 13px; }
.facet-item input { margin: 0; }
.facet-label { flex: 1; color: var(--muted); }
.facet-item:hover .facet-label { color: var(--ink); }
.facet-count { color: #6f7789; font-size: 12px; }
.facet-body .extra { display: none; }
.facet-body.show-extra .extra { display: flex; }
.facet-more, .facet-clear {
  background: none; color: var(--muted); padding: 4px 0; font-size: 13px;
  text-decoration: underline; border: 0; cursor: pointer;
}
.facet-more:hover, .facet-clear:hover { color: var(--ink); }
.facet-clear { margin-top: 10px; }
.facet-note { color: #6f7789; font-size: 12px; margin: 6px 0 0; }

.addon-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.addon-toolbar .spacer { flex: 1; }
.addon-toolbar select { width: auto; padding: 6px 9px; font-size: 13px; margin: 0; }
.pager { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pager-btn { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; cursor: pointer; }
.pager-btn:disabled { opacity: .35; cursor: default; }
.view-toggle { display: flex; gap: 2px; }
.view-btn { background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.view-btn.active { color: var(--gold); border-color: var(--gold); }

.addon-results.list { display: flex; flex-direction: column; gap: 10px; }
.addon-results.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

.addon-row { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; gap: 14px; align-items: flex-start; }
.addon-row:hover { border-color: #4a566c; }
.addon-results.grid .addon-row { flex-direction: column; gap: 10px; }

.addon-thumb {
  flex: 0 0 auto; width: 64px; height: 64px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: #14161c; background: var(--muted);
}
.addon-body { flex: 1; min-width: 0; }
.addon-body h3 { margin: 0; font-size: 16px; color: var(--ink); }
.addon-author { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.addon-summary { margin: 0 0 8px; font-size: 14px; }
.addon-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.addon-tags .pill { background: #262c38; color: var(--muted); font-size: 11px; }
.addon-tags .pill.tag { background: #2c2a1e; color: var(--gold); }
.addon-tags .pill.warn { background: #33291e; color: #e0a45f; }
.addon-meta { color: #6f7789; font-size: 12px; }
.addon-get { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex: 0 0 auto; }
.addon-results.grid .addon-get { flex-direction: row; align-items: center; }

/* the thumbnail takes its colour from the category, so the list reads at a glance */
.cat-combat    { background: #b4635f; }
.cat-maps      { background: #5f8fb4; }
.cat-bags      { background: #b49a5f; }
.cat-tools     { background: #7f8aa0; }
.cat-interface { background: #8a6fb4; }
.cat-chat      { background: #5fb48a; }
.cat-quests    { background: #b48a5f; }
.cat-social    { background: #b45f9a; }
.cat-other     { background: #6f7789; }
