: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(420px, 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; }
