/* Layout: a search bar over two panels (filters left, gear list right), dressed like the
   DPS meter: ink panels in brass frames, parchment text, cyan for what you picked. */
@font-face { font-family: "DB Averia"; src: url("fonts/averia-serif-libre-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DB Averia"; src: url("fonts/averia-serif-libre-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ground: #15130a;
  --ink: rgba(28, 26, 13, 0.96);
  --ink-solid: #1c1a0d;
  --well: #2a2612;
  --well-hi: #353018;
  --parch: #eee2bc;
  --parch-dim: #b5a983;
  --parch-faint: #8a8063;
  --brass: #b8973f;
  --brass-dim: rgba(184, 151, 63, 0.38);
  --cyan: #00ccff;
  --cyan-well: #0b4357;
  --citrine: #e3b341;
  --sapphire: #4f8fe6;
  --def: #a7b98c;
  --alarm: #d6453d;
  --alarm-well: #4a1712;
  --legendary: #f8dd45;
  --rare: #0099ff;
  --magic: #eee2bc;
  --font: "DB Averia", Georgia, "Times New Roman", serif;
  --fs: 15px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground) radial-gradient(120% 70% at 50% 0%, #221f10 0%, var(--ground) 70%) no-repeat;
  color: var(--parch); font-family: var(--font); font-size: var(--fs); line-height: 1.4;
  -webkit-font-smoothing: antialiased; min-height: 100%;
}
[hidden] { display: none !important; }
a { color: var(--parch); text-decoration-color: var(--brass-dim); text-underline-offset: 0.15em; }
a:hover { text-decoration-color: var(--brass); }
code, kbd { font-family: var(--font); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }

.page { max-width: 1480px; margin: 0 auto; padding-inline: 16px; padding-block: 18px 28px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- panels, as on the meter ---------- */
.panel {
  background: var(--ink); border: 1px solid var(--brass); border-radius: 5px;
  box-shadow: inset 0 0 0 3px var(--ink-solid), inset 0 0 0 4px var(--brass-dim), 0 6px 18px rgba(0, 0, 0, 0.35);
  padding: 0.9em 1em 0.85em; min-width: 0;
}
.head { display: flex; align-items: center; gap: 0.55em; min-height: 1.6em; }
.head h2 { margin: 0; font-size: 1.08em; font-weight: 700; letter-spacing: 0.01em; }
.sub { color: var(--parch-dim); font-size: 0.86em; margin: 0; }
.dot { width: 0.62em; height: 0.62em; border-radius: 50%; background: var(--brass); border: 1px solid var(--brass); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0.42em 0.9em; border-radius: 3px;
  border: 1px solid var(--brass); background: transparent; color: var(--parch); font-weight: 700; font-size: 0.92em; white-space: nowrap;
}
.btn:hover { background: var(--well); }
.btn.primary { background: linear-gradient(#ecc85b, #c99a2e); color: #20180a; border-color: #6b5418; }
.btn.primary:hover { background: linear-gradient(#f5d670, #d6a737); }
.iconbtn { all: unset; cursor: pointer; color: var(--parch-dim); min-width: 1.6em; height: 1.6em; display: inline-grid; place-items: center; border-radius: 3px; font-size: 1em; flex: none; }
.iconbtn:hover { color: var(--parch); background: var(--well); }
.iconbtn:focus-visible { outline: 2px solid var(--cyan); }
.linkbtn { all: unset; cursor: pointer; color: var(--parch-dim); font-size: 0.84em; text-decoration: underline; text-decoration-color: var(--brass-dim); text-underline-offset: 0.15em; }
.linkbtn:hover { color: var(--parch); }
.linkbtn:focus-visible { outline: 2px solid var(--cyan); }

/* ---------- top bar: tools, then library sections ---------- */
.top { display: flex; align-items: flex-end; gap: 0.4em 1.2em; flex-wrap: wrap; border-bottom: 1px solid var(--brass); padding: 0 0.2em; }
.tabs { display: flex; align-items: stretch; gap: 0; }
.tab {
  display: inline-flex; align-items: center; gap: 0.45em; padding: 0.3em 0.9em 0.4em; margin-bottom: -1px;
  font-size: 1.32em; font-weight: 700; letter-spacing: 0.01em; color: var(--parch-faint); text-decoration: none;
  border: 1px solid transparent; border-bottom: 0; border-radius: 5px 5px 0 0; text-shadow: 0 1px 0 #000;
}
.tab::before { content: ""; width: 0.46em; height: 0.46em; border-radius: 50%; border: 1px solid currentColor; flex: none; }
.tab:hover { color: var(--parch); }
.tab.on { color: var(--parch); background: var(--ink); border-color: var(--brass); }
.tab.on::before { background: var(--brass); border-color: var(--brass); }
.tabsep { width: 1px; margin: 0.55em 0.35em 0.5em; background: var(--brass-dim); }
.top .sub { flex: 1; text-align: right; padding-bottom: 0.5em; min-width: 12em; }

/* ---------- name search ---------- */
.searchrow { padding-bottom: 0.6em; }
#q {
  width: 100%; min-width: 0; background: var(--well); border: 1px solid var(--brass-dim); border-radius: 3px;
  padding: 0.5em 0.75em; font-size: 1em; color: var(--parch); letter-spacing: 0.01em;
}
#q::placeholder { color: var(--parch-faint); }
#q:hover { border-color: var(--brass); }
#q:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
#q.on { border-color: var(--cyan); }

/* ---------- dropdown filters ---------- */
.filterbar { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5em), 1fr)); gap: 0.5em 0.7em; padding-bottom: 0.75em; border-bottom: 1px solid var(--brass-dim); }
.fsel { display: flex; flex-direction: column; gap: 0.2em; min-width: 0; }
.fsel span { font-size: 0.74em; color: var(--parch-faint); letter-spacing: 0.06em; text-transform: uppercase; }
.fsel.on span { color: var(--cyan); }
.fsel select {
  width: 100%; min-width: 0; background: var(--well); border: 1px solid var(--brass-dim); border-radius: 3px; padding: 0.35em 0.45em;
  font-size: 0.92em; color: var(--parch); cursor: pointer;
}
.fsel select:hover { border-color: var(--brass); }
.fsel select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.fsel.on select { border-color: var(--cyan); background: var(--cyan-well); color: #dff8ff; }
.fsel select option, .fsel select optgroup { background: var(--ink-solid); color: var(--parch); }
.spacer { flex: 1; }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: 0.5em; }
.reshead { flex-wrap: wrap; gap: 0.5em 0.9em; }
.reshead .btn { font-size: 0.82em; padding: 0.3em 0.7em; font-weight: 400; }

/* The gear table: one line per item, like a spreadsheet. */
.tablewrap { overflow: auto; max-height: calc(100vh - 120px); min-height: 12em; border: 1px solid var(--brass-dim); border-radius: 3px;
  scrollbar-width: thin; scrollbar-color: var(--brass-dim) transparent; }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.86em; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 0.28em 0.6em; white-space: nowrap; text-align: left; border-bottom: 1px solid rgba(184, 151, 63, 0.14); vertical-align: middle; }
.grid td + td, .grid th + th { border-left: 1px solid rgba(184, 151, 63, 0.09); }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--well); border-bottom: 1px solid var(--brass); padding: 0; }
.grid thead th button { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; padding: 0.4em 0.6em; font-weight: 700;
  font-size: 0.86em; color: var(--parch-dim); letter-spacing: 0.04em; text-transform: uppercase; }
.grid thead th button:hover { color: var(--parch); background: var(--well-hi); }
.grid thead th button:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.grid thead th button.on { color: var(--cyan); }
.grid thead th button.atk-t:not(.on) { color: var(--citrine); }
.grid thead th button.exp-t:not(.on) { color: var(--sapphire); }
.grid thead th button.def-t:not(.on) { color: var(--def); }
.grid .n { text-align: right; }
.grid thead th.n button { text-align: right; }
.grid tbody tr.row td { background: var(--ink-solid); }
.grid tbody tr.row.alt td { background: #211e0f; }
.grid tbody tr.row:hover td { background: #2f2a15; }
.grid tbody tr.row.open td { background: var(--well); }
.grid td.c-name { position: sticky; left: 0; z-index: 1; max-width: 22em; overflow: hidden; text-overflow: ellipsis; }
.grid thead th.c-name { left: 0; z-index: 3; }
.grid td.c-name .l1 { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 700; cursor: pointer; text-align: left; color: inherit; }
.grid td.c-name .l1.r-L { color: var(--legendary); }
.grid td.c-name .l1.r-R { color: var(--rare); }
.grid td.c-name .l1.r-M { color: var(--magic); }
.grid td.c-name .l1:hover { text-decoration: underline; text-decoration-color: var(--brass); text-underline-offset: 0.15em; }
.grid td.c-name .l1:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.gear-icon { --gear-frame: #aaa; width: 40px; height: 40px; box-sizing: border-box; padding: 2px; object-fit: contain;
  vertical-align: middle; margin-right: 0.5em; background: radial-gradient(ellipse at center, #57533a, #25230f);
  border: 2px solid var(--gear-frame); border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3), 0 0 3px var(--gear-frame); }
.r-L .gear-icon { --gear-frame: var(--legendary); }
.r-R .gear-icon { --gear-frame: var(--rare); }
.grid td.c-attack { color: var(--citrine); }
.grid td.c-expertise { color: var(--sapphire); }
.grid td.c-defense { color: var(--def); }
.grid td.c-total { font-weight: 700; }
.grid td.zero, .grid .z { color: var(--parch-faint); }
.grid td.kind { opacity: 0.75; }
.grid td.c-class, .grid td.c-slot, .grid td.c-focus, .grid td.c-skill, .grid td.c-magic, .grid td.c-id, .grid td.c-level { color: var(--parch-dim); }
.grid td.c-owner { color: var(--parch); }
.grid .eq { color: var(--cyan); font-size: 0.8em; border: 1px solid var(--cyan); border-radius: 2px; padding: 0 0.2em; margin-left: 0.1em; }
.rune { white-space: nowrap; color: var(--parch); }
.rune.hit { color: var(--cyan); font-weight: 700; }
.grid tr.detailrow td { white-space: normal; background: var(--well); padding: 0; position: sticky; left: 0; }
.grid tr.detailrow .detail { max-width: 70em; }
.detail { padding: 0.45em 0.5em 0.85em; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17em), 1fr)); gap: 0.7em 1.5em; font-size: 0.88em; }
.detail h4 { margin: 0 0 0.25em; font-size: 0.85em; color: var(--parch-faint); letter-spacing: 0.05em; text-transform: uppercase; font-weight: 400; }
.detail dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.15em 0.8em; }
.detail dt { color: var(--parch-dim); }
.detail dd { margin: 0; }
.detail p { margin: 0 0 0.3em; }
.detail .desc { color: var(--parch-dim); }
.detail .src { color: var(--parch-faint); font-size: 0.92em; }
.more { align-self: center; margin-top: 0.4em; font-weight: 400; }
.grid td.empty { padding: 1.4em 0.5em; color: var(--parch-dim); text-align: center; white-space: normal; background: none; }
.empty .ex { margin-top: 0.4em; }

/* ---------- mounts: a compact table, one line per mount ---------- */
.mgrid td { padding-block: 0.12em; }
.mgrid td.c-pic { width: 4.9em; padding: 0.1em 0.35em; }
.mgrid .pic { display: block; width: 72px; height: 48px; border-radius: 3px; background: var(--well); }
.mgrid tbody tr.row:hover .pic, .mgrid tbody tr.row.open .pic { background: var(--well-hi); }
.mgrid .picbtn { all: unset; display: block; cursor: pointer; border-radius: 3px; }
.mgrid .picbtn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.mgrid td.c-key { color: var(--parch-faint); font-size: 0.92em; }
.mgrid td.c-rig, .mgrid td.c-level { color: var(--parch-dim); }
.mgrid td.c-idols { color: var(--citrine); }
.mgrid td.c-name { left: 0; }
.mgrid td.c-desc { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--parch-faint); }
.mgrid td.c-rarity.r-L { color: var(--legendary); }
.mgrid td.c-rarity.r-R { color: var(--rare); }
.mdetail { max-width: calc(100vw - 72px); display: flex; gap: 0.6em 1.2em; padding: 0.5em 0.6em 0.8em; align-items: flex-start; flex-wrap: wrap; font-size: 0.88em; }
.mdetail img { width: 240px; max-width: 100%; height: auto; aspect-ratio: 3 / 2; flex: none; border-radius: 4px; background: var(--ink-solid); border: 1px solid var(--brass-dim); }
.mdetail .txt { flex: 1; min-width: min(100%, 16em); max-width: 46em; display: flex; flex-direction: column; gap: 0.35em; }
.mdetail .desc { color: var(--parch); margin: 0; }
.mdetail .desc.none { color: var(--parch-faint); }
.mdetail dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.1em 0.9em; }
.mdetail dt { color: var(--parch-faint); }
.mdetail dd { margin: 0; color: var(--parch-dim); }

.foot { display: flex; flex-wrap: wrap; gap: 0.3em 1.5em; justify-content: space-between; font-size: 0.8em; color: var(--parch-faint); padding: 0 0.2em; }

/* ---------- drop + toast ---------- */
.drop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(10, 9, 4, 0.72); pointer-events: none; }
.drop > div { border: 2px dashed var(--brass); border-radius: 8px; padding: 2em 3em; background: var(--ink); display: flex; flex-direction: column; gap: 0.3em; align-items: center; text-align: center; }
.drop b { font-size: 1.2em; }
.drop span { color: var(--parch-dim); font-size: 0.9em; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); transform: translateX(-50%); z-index: 60; max-width: min(92vw, 34em);
  background: var(--ink-solid); border: 1px solid var(--brass); border-radius: 4px; padding: 0.55em 0.9em; font-size: 0.9em; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.toast.bad { border-color: var(--alarm); color: #f6c9c3; }

/* ---------- narrow ---------- */
@media (max-width: 1100px) {
  .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .tabs .tabsep { display: none; }
  .tabs .tab { justify-content: center; min-width: 0; gap: 0.3em; font-size: 1em; padding-inline: 0.3em; text-align: center; }
}
@media (max-width: 820px) {
  :root { --fs: 14px; }
}
@media (max-width: 600px) {
  .tablewrap { max-height: 75vh; }
  .grid td.c-name { max-width: 12em; }
  .top .sub { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================= Spells: icon grids + level card ================= */
.sgpanel { display: flex; flex-direction: column; gap: 0.7em; }

/* Enemies reuse the spell tiles and detail card. */
.enemy-filters, .enemy-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.65em 1em; }
.enemy-filters label, .enemy-controls label { display: flex; align-items: center; gap: 0.5em; color: var(--parch-dim); font-size: 0.88em; }
.enemy-filters select, .enemy-controls select { max-width: 100%; min-width: 0; background: var(--well); color: var(--parch); border: 1px solid var(--brass-dim); border-radius: 3px; padding: 0.4em; font: inherit; }
.enemy-controls label { flex: 1; min-width: 12em; }
.enemy-controls select { flex: 1; }
.enemy-controls { margin: 0.7em 0; }
.enemy-filters #count { margin-left: auto; }
.enemy-panel .enemy-tiles { grid-template-columns: repeat(auto-fill, minmax(8em, 1fr)); }
.enemy-panel .enemy-tile .ic { width: 96px; height: 96px; object-fit: contain; }
.enemy-meta, .enemy-rank { font-size: 0.68em; color: var(--parch-dim); }
.enemy-rank { color: var(--parch-faint); }
.enemy-portrait { display: block; width: min(240px, 100%); height: auto; margin: auto; }
.enemy-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5em; margin: 0.8em 0; }
.enemy-stats > div { border: 1px solid var(--brass-dim); border-radius: 4px; background: var(--well); padding: 0.6em 0.25em; text-align: center; }
.enemy-stats dt { font-size: 0.72em; color: var(--parch-dim); }
.enemy-stats dd { margin: 0.2em 0 0; color: var(--cyan); font-size: 1.1em; font-weight: 700; overflow-wrap: anywhere; }
.enemy-card .cfacts { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }
.enemy-card dd { overflow-wrap: anywhere; }
.enemy-card .enemy-source { margin-top: 1em; line-height: 1.5; }
.enemy-dialog-open { overflow: hidden; }
.party-comparison-wrap { max-width: 100%; overflow-x: auto; margin-block: 1em; }
.party-comparison { width: 100%; border-collapse: collapse; font-size: 0.8em; font-variant-numeric: tabular-nums; }
.party-comparison caption { color: var(--parch-dim); font-weight: 700; text-align: left; padding-bottom: 0.5em; }
.party-comparison th, .party-comparison td { padding: 0.45em 0.35em; border-bottom: 1px solid var(--brass-dim); text-align: right; white-space: nowrap; }
.party-comparison th:first-child { text-align: left; }
.party-comparison thead { color: var(--parch-dim); }
.party-comparison .selected { background: var(--cyan-well); color: #dff8ff; }
.party-comparison-wrap .stats { margin-top: 0.5em; }
@media (max-width: 420px) {
  .tabs .tab { font-size: 1em; padding-inline: 0.45em; }
  .tabs .tabsep { margin-inline: 0.15em; }
  .enemy-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .enemy-filters label { width: 100%; justify-content: space-between; }
  .enemy-filters select { width: 70%; }
}

/* class picker */
.classbar { display: flex; gap: 0.5em; flex-wrap: wrap; }
.clstab { display: inline-flex; align-items: baseline; gap: 0.4em; cursor: pointer; padding: 0.4em 0.95em; border-radius: 4px;
  border: 1px solid var(--brass-dim); background: var(--well); color: var(--parch-dim); font-weight: 700; font-size: 1.02em; }
.clstab .cc { font-size: 0.78em; color: var(--parch-faint); font-weight: 400; }
.clstab:hover { border-color: var(--brass); color: var(--parch); }
.clstab.on { border-color: var(--cyan); background: var(--cyan-well); color: #dff8ff; }
.clstab.on .cc { color: #a7e6f6; }

.sgsearch { padding-bottom: 0.2em; }

/* grouped icon grids */
.gsec { margin-top: 0.3em; }
.gh { margin: 0 0 0.5em; font-size: 0.82em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--parch-dim);
  border-bottom: 1px solid var(--brass-dim); padding-bottom: 0.3em; }
.gh .gc { color: var(--parch-faint); font-weight: 400; margin-left: 0.3em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2em, 1fr)); gap: 0.5em; margin-bottom: 1em; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.3em; cursor: pointer;
  background: var(--ink-solid); border: 1px solid var(--brass-dim); border-radius: 5px; padding: 0.55em 0.3em 0.45em; color: var(--parch);
  font: inherit; text-align: center; }
.tile:hover { border-color: var(--brass); background: var(--well); }
.tile:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.tile .ic { width: 56px; height: 56px; image-rendering: auto; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }
.tile .tn { font-size: 0.8em; line-height: 1.15; font-weight: 700; }
.tile .tt { position: absolute; top: 0.3em; right: 0.35em; font-size: 0.66em; color: var(--parch-faint); letter-spacing: 0.03em; }
.tile .tv { position: absolute; top: 0.3em; left: 0.35em; font-size: 0.66em; color: var(--brass); font-weight: 700; letter-spacing: 0.02em; }
.cfacts .vnote { display: block; margin-top: 0.3em; font-size: 0.85em; color: var(--parch-faint); }
.empty { padding: 1.6em 0.5em; color: var(--parch-dim); text-align: center; }

/* the card overlay */
.cardback { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 7, 3, 0.74); overflow: auto; }
.card { width: min(34em, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--ink); color: var(--parch);
  border: 1px solid var(--brass); border-radius: 6px; box-shadow: inset 0 0 0 3px var(--ink-solid), inset 0 0 0 4px var(--brass-dim), 0 12px 40px rgba(0,0,0,0.6); }
.chead { display: flex; align-items: center; gap: 0.7em; padding: 0.8em 0.9em; border-bottom: 1px solid var(--brass-dim);
  position: sticky; top: 0; background: var(--ink); z-index: 1; border-radius: 6px 6px 0 0; }
.cic { width: 72px; height: 72px; flex: none; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7)); }
.ctitle { flex: 1; min-width: 0; }
.ctitle h3 { margin: 0; font-size: 1.22em; }
.csub { margin: 0.15em 0 0; font-size: 0.82em; color: var(--parch-dim); }
.clevel { display: flex; flex-direction: column; gap: 0.2em; flex: none; }
.clevel span { font-size: 0.68em; color: var(--parch-faint); letter-spacing: 0.06em; text-transform: uppercase; }
.clevel select { background: var(--cyan-well); border: 1px solid var(--cyan); border-radius: 3px; color: #dff8ff; padding: 0.35em 0.5em; font: inherit; font-size: 0.92em; cursor: pointer; }
.clevel select option { background: var(--ink-solid); color: var(--parch); }
.cclose { all: unset; cursor: pointer; align-self: flex-start; color: var(--parch-faint); font-size: 1.1em; padding: 0.1em 0.3em; border-radius: 3px; }
.cclose:hover { color: var(--parch); background: var(--well); }
.cclose:focus-visible { outline: 2px solid var(--cyan); }

.cbody { padding: 0.8em 1em 1em; }
.cmana { font-size: 1.05em; color: var(--sapphire); margin-bottom: 0.5em; }
.cmana b { color: #cfe3ff; font-size: 1.1em; }
.cbody .base { margin: 0 0 0.4em; font-size: 1.02em; }
.cbody .stats { margin: 0 0 0.5em; color: var(--parch-faint); font-size: 0.9em; }
.uh { margin: 0.6em 0 0.35em; font-size: 0.78em; letter-spacing: 0.05em; text-transform: uppercase; color: var(--cyan); font-weight: 700; }
.ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.2em; }
.ul li { padding-left: 0.9em; text-indent: -0.9em; }
.ul li::before { content: "·"; display: inline-block; width: 0.9em; text-indent: 0; color: var(--brass); }
.ul li.new { color: #fff; }
.ul li.new::before { content: "▸"; color: var(--cyan); font-size: 0.8em; }
.ul .x { color: var(--cyan); font-weight: 700; }
.ul .was { color: var(--parch-faint); font-size: 0.9em; }
.g { text-decoration: underline dotted var(--parch-faint); text-underline-offset: 0.22em; }
.cfacts { margin: 0.9em 0 0; padding-top: 0.6em; border-top: 1px solid var(--brass-dim); display: grid; grid-template-columns: max-content 1fr; gap: 0.2em 0.9em; font-size: 0.9em; }
.cfacts dt { color: var(--parch-faint); white-space: nowrap; }
.cfacts dd { margin: 0; color: var(--parch-dim); }
.cnav { display: flex; justify-content: space-between; gap: 0.5em; margin-top: 0.9em; }
.cstep { cursor: pointer; background: var(--well); border: 1px solid var(--brass-dim); color: var(--parch); border-radius: 3px; padding: 0.4em 0.8em; font: inherit; font-size: 0.9em; }
.cstep:hover:not([disabled]) { border-color: var(--brass); background: var(--well-hi); }
.cstep[disabled] { opacity: 0.35; cursor: default; }
.cstep:focus-visible { outline: 2px solid var(--cyan); }

@media (max-width: 600px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(4.6em, 1fr)); }
  .chead { flex-wrap: wrap; }
  .clevel { order: 3; width: 100%; flex-direction: row; align-items: center; gap: 0.5em; }
  .clevel select { flex: 1; }
}

/* Shared Optimizer introduction. Native dialog keeps keyboard focus in the card. */
.launcher-dialog { width: min(34em, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 1.25em; color: var(--parch); font: inherit; }
.launcher-dialog::backdrop { background: rgba(10, 9, 4, 0.8); }
.launcher-heading { display: flex; align-items: center; justify-content: space-between; gap: 1em; }
.launcher-heading h2 { margin: 0; font-size: 1.25em; }
.launcher-dialog p { margin: 0.9em 0; }
.launcher-actions { display: flex; flex-wrap: wrap; gap: 0.65em; margin-top: 1.15em; }
.launcher-actions a { text-decoration: none; white-space: normal; text-align: center; }
.launcher-dialog .launcher-access { margin-bottom: 0; font-size: 0.8em; color: var(--parch-faint); }
.pets-empty { min-height: 9em; display: grid; place-items: center; }

/* Mounts and pets use the same section headings, spacing and icon sizes as Enemies. */
.collection-panel .tiles { grid-template-columns: repeat(auto-fill, minmax(8em, 1fr)); }
.collection-panel .tile .ic { width: 96px; height: 96px; object-fit: contain; }
.companion-card { padding: 0; }
.companion-card::backdrop { background: rgba(8, 7, 3, 0.74); }
.companion-card .cfacts { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }
.companion-card dd { overflow-wrap: anywhere; }
.companion-portrait { display: block; width: min(320px, 100%); height: auto; object-fit: contain; margin: 0 auto 1em; }
body:has(.companion-card[open]) { overflow: hidden; }
