:root {
  --bg: #16161a; --panel: #1f1f25; --card: #24242b; --line: #34343e; --text: #dcdce4; --dim: #8b8b98;
  --accent: #e0a030; --accent-bg: #3a3120; --note: #6fb6ff; --note-bg: #1d2a3a; --mod: #9fd28a;
  --str: #e57b6b; --agi: #7bd17b; --int: #7aa8ef; --danger: #e06060;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.45 system-ui, sans-serif; }
body { display: flex; overflow: hidden; }
button, input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 7px; font: inherit; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
.dim { color: var(--dim); }
.grow { flex: 1; }
code, pre, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
a { color: var(--note); }

/* sidebar */
#side { width: 230px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.sidehead { padding: 8px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--accent); }
#weapons { flex: 1; overflow: auto; }
.grp { color: var(--dim); font-size: 11px; padding: 8px 10px 2px; text-transform: uppercase; letter-spacing: .05em; }
.wpn { display: flex; align-items: center; gap: 8px; padding: 3px 10px; cursor: pointer; }
.wpn:hover { background: #2a2a32; }
.wpn.sel { background: var(--accent-bg); color: var(--accent); }
.wpn img { width: 24px; height: 24px; border-radius: 3px; background: var(--bg); }
.badge { margin-left: auto; background: var(--note-bg); color: var(--note); border-radius: 9px; padding: 0 6px; font-size: 11px; }
.sidefoot { padding: 6px 10px; font-size: 11px; color: var(--dim); border-top: 1px solid var(--line); }

/* main */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 64px; }
#head img { width: 44px; height: 44px; border-radius: 4px; }
#head h1 { margin: 0; font-size: 18px; }
#head .meta { color: var(--dim); font-size: 12px; }
.prim { font-weight: 600; }
.prim.STR { color: var(--str); } .prim.AGI { color: var(--agi); } .prim.INT { color: var(--int); }
#tabs { display: flex; gap: 4px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
#tabs button { border-color: transparent; background: none; }
#tabs button.on { border-color: var(--accent); color: var(--accent); }
#tabs label { display: flex; gap: 4px; align-items: center; }
#view { flex: 1; overflow: auto; padding: 14px; }
.empty { color: var(--dim); padding: 40px; text-align: center; }
h2 { font-size: 14px; margin: 18px 0 8px; color: var(--accent); font-weight: 600; }
h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px; position: relative; }
.card.has-note { border-color: var(--note); }
.card .top { display: flex; gap: 10px; align-items: flex-start; }
.card .top img { width: 40px; height: 40px; border-radius: 4px; flex: none; background: var(--bg); }
.card .title { font-weight: 600; font-size: 14px; }
.card .sub { color: var(--dim); font-size: 11px; }
.card .act { margin-left: auto; flex: none; }
.tip { margin: 8px 0; padding: 8px; background: var(--bg); border-radius: 4px; white-space: normal; }
.tip .lv { color: var(--dim); font-size: 11px; }
details > summary { cursor: pointer; color: var(--dim); font-size: 12px; margin-top: 4px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 2px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: normal; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.fields td.v { cursor: pointer; font-variant-numeric: tabular-nums; }
table.fields td.v:hover { background: var(--accent-bg); }
td.mod { color: var(--mod); }
td.want, span.want { color: var(--note); }
td.want::after { content: " ✎"; }
tr.me td { background: var(--accent-bg); }
.uses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { display: inline-block; background: #2c2c35; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; font-size: 11px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.setup { color: var(--dim); }
.stat { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: 12px; }
.stat b { font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; }
.bar > div { height: 100%; background: var(--accent); border-radius: 2px; }
.cardnotes { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.cardnote { background: var(--note-bg); border-left: 3px solid var(--note); padding: 4px 8px; border-radius: 3px; cursor: pointer; font-size: 12px; }
.cardnote.closed { opacity: .55; border-left-color: var(--dim); }
.herogrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slider { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.slider input[type=range] { flex: 1; }
.warn { color: var(--accent); font-size: 12px; }

/* code and wiki */
.codewrap { display: flex; gap: 10px; height: 100%; }
.trlist { width: 260px; flex: none; overflow: auto; }
.trlist div { padding: 2px 6px; cursor: pointer; border-radius: 3px; }
.trlist div:hover { background: #2a2a32; }
.trlist div.sel { background: var(--accent-bg); color: var(--accent); }
pre.code { flex: 1; margin: 0; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px; white-space: pre; }
pre.code mark { background: #5a4410; color: inherit; }
.wiki { max-width: 980px; }
.wiki table { margin: 6px 0 12px; }
.wiki h1 { font-size: 20px; } .wiki h2 { font-size: 16px; } .wiki h3 { font-size: 14px; color: var(--text); }
.wiki code { background: #2a2a32; padding: 0 3px; border-radius: 3px; }

/* notes panel */
#notes { width: 300px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
.noteshead { display: flex; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); }
#noteList { flex: 1; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.note { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--note); border-radius: 4px; padding: 6px 8px; cursor: pointer; }
.note:hover { border-color: var(--note); }
.note.done { border-left-color: var(--mod); opacity: .7; }
.note.dropped { border-left-color: var(--dim); opacity: .55; }
.note .what { font-weight: 600; font-size: 12px; }
.note .chg { font-size: 12px; }
.note .txt { white-space: pre-wrap; font-size: 12px; margin-top: 2px; }
.note .reply { font-size: 11px; color: var(--mod); margin-top: 2px; }
.note .when { font-size: 10px; color: var(--dim); }

/* dialog */
#dlg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 10; }
#dlg[hidden] { display: none; }
#noteForm { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; width: 520px; display: flex; flex-direction: column; gap: 8px; }
#noteForm label { display: flex; flex-direction: column; gap: 2px; color: var(--dim); font-size: 12px; }
#noteForm input, #noteForm select, #noteForm textarea { color: var(--text); font-size: 13px; }
.row2 { display: flex; gap: 8px; align-items: flex-end; } .row2 > * { flex: 1; }
.dlghead, .dlgfoot { display: flex; align-items: center; gap: 6px; }
.dlghead button { border: none; background: none; }

/* shop and wave pages */
.shopn { width: 24px; text-align: center; font-size: 11px; color: var(--dim); flex: none; }
.filters { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.filters button.on { border-color: var(--accent); color: var(--accent); }
.cat { display: inline-block; font-size: 10px; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--dim); }
.cat.click { cursor: pointer; font-size: 11px; }
.cat.click:hover, .cat.on { border-color: var(--accent); color: var(--accent); }
.gold { color: #f0c850; font-weight: 600; }
.unitline { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.unitline img { width: 28px; height: 28px; border-radius: 3px; flex: none; background: var(--bg); }
.nested { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.nested .card { background: var(--panel); }
table.wavetable td, table.wavetable th { white-space: nowrap; }
table.wavetable td:nth-child(2) { white-space: normal; min-width: 260px; }
.noicon { width: 28px; height: 28px; flex: none; border-radius: 3px; background: var(--bg); }

/* public mode (tools/kit_export.py): read-only, Kit tab, shops and waves only */
.public #notes, .public #extraction, .public #tabs label, .public .act[data-act=note], .public #dlg { display: none; }
.public table.fields td.v { cursor: default; }
.public table.fields td.v:hover { background: none; }
.public .chip { cursor: default; }
.public .chip:hover { border-color: var(--line); }
.mana { color: #6fa8ff; font-weight: 600; }

/* guide builder (guide.js, public page) */
.guide { max-width: 1100px; }
.gform { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; }
.gform input { width: 260px; }
.gsec { margin: 14px 0; }
.gsec h2 .dim { font-weight: normal; font-size: 12px; }
.gpicked { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; min-height: 50px; }
.gempty { margin-left: 4px; }
.gslot { width: 48px; height: 48px; box-sizing: border-box; border: 1px dashed var(--line); border-radius: 4px; flex: none; }
.gpick { position: relative; width: 48px; height: 48px; }
.gpick img { width: 48px; height: 48px; border: 1px solid var(--accent); border-radius: 4px; }
.gpick > b { position: absolute; right: 0; bottom: 0; background: rgba(0,0,0,.8); color: #fff; font-size: 11px; padding: 0 4px; border-radius: 3px; }
.gpick .gtools { display: none; position: absolute; left: -6px; top: -18px; white-space: nowrap; z-index: 2; }
.gpick:hover .gtools { display: flex; }
.gtools button { padding: 0 4px; font-size: 11px; line-height: 16px; }
.gpool { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; margin-top: 4px; }
.gtile { display: flex; align-items: center; gap: 6px; text-align: left; padding: 3px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; color: inherit; cursor: pointer; }
.gtile:hover { border-color: var(--accent); }
.gtile.taken { opacity: .35; cursor: default; }
.gtile img { width: 28px; height: 28px; flex: none; }
.gtile span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groles { display: flex; gap: 6px; flex-wrap: wrap; }
.groles button.on { border-color: var(--accent); background: var(--accent-bg); }
.gabils { display: grid; gap: 8px; }
.gabil { display: grid; grid-template-columns: 220px 1fr; gap: 8px; align-items: start; }
.gabilname { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.gabilname img { width: 32px; height: 32px; }
.guide textarea { width: 100%; box-sizing: border-box; }
.gactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 18px 0 30px; position: sticky; bottom: 0; background: var(--bg, #17171d); padding: 8px 0; }
.gnote { max-width: 900px; margin: 2px 0 6px; }
.gbudget { margin: 4px 0; }
.gbudget.warn { color: #ff8a65; }
.gpick.over img { border-color: #ff8a65; opacity: .6; }
.gzenith { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 8px; padding: 8px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent-bg); max-width: 900px; }
.gzenith img { width: 48px; height: 48px; }
.gzenith { min-height: 84px; box-sizing: border-box; }
.gzenith.gzempty { border-style: dashed; border-color: var(--line); background: none; }
/* read-only guide page (renderGuideView in guide.js, on the guide site) */
.gview .gvhead { display: flex; gap: 14px; align-items: center; margin: 4px 0 10px; }
.gview .gvhead img { width: 64px; height: 64px; border-radius: 6px; }
.gview .gvhead h1 { margin: 0 0 4px; font-size: 22px; }
.gview .gvnote { margin: 8px 0 12px; max-width: 900px; }
.gview .gvnote > div, .gview .gvtext { margin-top: 4px; line-height: 1.5; overflow-wrap: anywhere; max-width: 900px; }
.gview .gpick { cursor: default; }
.gtile.gchoice { border-style: dashed; border-color: var(--accent); }
.gpick.zen img { box-shadow: 0 0 0 2px #f0c850, 0 0 8px #f0c850; }
#gtip { position: fixed; z-index: 50; max-width: min(380px, 92vw); background: #0d0d11; border: 1px solid var(--accent); border-radius: 4px; padding: 8px 10px; font-size: 12px; line-height: 1.4; pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,.6); }
#gtip .gtt { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
#gtip .gts { color: var(--accent); font-weight: 600; margin-top: 6px; }
#gtip .gtn { margin-top: 4px; }
.brand { cursor: pointer; }
.home { max-width: 1100px; padding: 6px 4px 30px; }
.home h2 { font-size: 15px; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.hintro { font-size: 14px; line-height: 1.55; max-width: 820px; margin: 4px 0 6px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.hcard { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: inherit; cursor: pointer; }
.hcard:hover, .hlink:hover { border-color: var(--accent); }
.hcard img { width: 56px; height: 56px; border-radius: 4px; }
.hcard span { font-size: 13px; text-align: center; }
.hlinks { display: flex; flex-wrap: wrap; gap: 6px; }
.hlink { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: inherit; cursor: pointer; }
.hlink img { width: 24px; height: 24px; }
.hlink .dim { font-size: 11px; }
#tabs[hidden] { display: none; }

/* ---- narrow screens (phones): the sidebar becomes a slide-out menu, the page scrolls as a whole ---- */
#menuBtn, #scrim { display: none; }
@media (max-width: 760px) {
  body { display: block; overflow: auto; height: auto; }
  #main { min-height: 100vh; }
  #view { overflow: visible; padding: 10px; }
  #menuBtn { display: block; position: fixed; top: 10px; left: 8px; z-index: 31; font-size: 20px; line-height: 1; padding: 8px 11px; background: var(--panel); }
  #head { padding-left: 60px; min-height: 60px; position: sticky; top: 0; z-index: 20; }
  #tabs { position: sticky; top: 60px; z-index: 20; overflow-x: auto; }
  #side { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 85vw); z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.menu #side { transform: none; }
  body.menu #scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .55); }
  .wpn { padding: 7px 12px; }  /* bigger touch targets */
  table.wavetable { display: block; overflow-x: auto; }
  table.wavetable td:nth-child(2) { min-width: 200px; }
  .gform input { width: 100%; }
  .gform label { display: block; margin-bottom: 6px; }
  .gabil { grid-template-columns: 1fr; gap: 4px; }
  .gpool { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .hgrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .hintro { font-size: 13px; }
  .gtile, .hlink { min-height: 38px; }
  .gtile span { white-space: normal; }  /* "Sell a talent point (+3 stat points)" wraps instead of being cut */
  .gactions { position: static; flex-wrap: wrap; }  /* pinned, its wrapped buttons would cover a third of the screen */
}
