:root {
  --bg: #16171b; --panel: #1f2026; --panel2: #282a32; --line: #383b46;
  --text: #e9e7e1; --dim: #9c9a92; --accent: #a3762f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}
button:hover { border-color: #5d6274; }
button.primary { background: var(--accent); border-color: var(--accent); color: #17140d; font-weight: 700; }
button.danger { color: #ff8d85; }
button.small { padding: 2px 8px; font-size: 12px; }
button.icon { padding: 2px 6px; font-size: 12px; line-height: 1; }
input[type=text], input[type=number], select, textarea {
  width: 100%; background: #121319; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
textarea { resize: vertical; min-height: 54px; }
input[type=color] { width: 40px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); margin: 10px 0 3px; }
label.check { display: flex; align-items: center; gap: 8px; text-transform: none; font-size: 13px; color: var(--text); letter-spacing: 0; }

#app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
header h1 { font-size: 16px; margin: 0 12px 0 0; }
header .spacer { flex: 1; }
header .hlink { color: var(--dim); font-size: 13px; text-decoration: none; }
header .hlink:hover { color: var(--text); }
header select { width: auto; }
header label { margin: 0; }

main { display: grid; grid-template-columns: 300px 1fr 520px; min-height: 0; }
main > section { min-height: 0; overflow: auto; padding: 14px; }
#start, #editor { background: var(--panel); }
#start { border-right: 1px solid var(--line); }
#start p { color: var(--dim); font-size: 13px; }
#editor { border-left: 1px solid var(--line); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 0 0 8px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 18px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
h3 .small { margin-left: auto; }

.warn { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: #3a2f14; color: #f1cf7a; font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; border-radius: 6px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #17140d; font-weight: 700; }
.pos {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  padding: 8px; margin-top: 6px; background: var(--panel2); border-radius: 8px;
}
.pos .n { font-weight: 600; }
.pos .n small { font-weight: 600; color: #f1cf7a; margin-left: 6px; font-size: 10px; letter-spacing: .06em; }
.pos .d { grid-column: 1 / -1; font-size: 12px; color: var(--dim); }
/* the colour dot in front of an ability in the library is its ability type */
.pos .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.grp { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin: 14px 0 2px; }
.grp:first-child { margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row.tight > * { flex: none; }
.hint { font-size: 12px; color: var(--dim); margin: 6px 0 0; }

.lib-tools { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.lib-count { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
.blank { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

#cards { display: flex; flex-wrap: wrap; gap: 14px; align-content: flex-start; }
.thumb { position: relative; cursor: pointer; border-radius: 8px; outline: 3px solid transparent; outline-offset: 3px; }
.thumb.sel { outline-color: var(--accent); }
.thumb .ws { zoom: .42; }
.thumb .ac { zoom: .72; }
.thumb .copies {
  position: absolute; right: -6px; top: -6px; background: var(--accent); color: #17140d;
  border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px;
}
.empty { color: var(--dim); padding: 40px; text-align: center; width: 100%; }

#preview { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 0 12px; background: var(--panel); }
#preview .ws { zoom: .66; }
#preview .ac { zoom: 1.1; }
@media (min-height: 980px) { #preview { position: sticky; top: -14px; z-index: 2; } }

/* list editors (weapons, abilities) */
table.ed { width: 100%; border-collapse: collapse; margin-top: 4px; }
table.ed th { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); font-weight: 600; text-align: left; padding: 0 3px 2px; }
table.ed td { padding: 2px 2px; vertical-align: top; }
table.ed input[type=text], table.ed textarea, table.ed select { padding: 4px 6px; }
table.ed td.x { width: 28px; }
table.ed textarea { min-height: 36px; }
table.ed .w-name { min-width: 110px; }
table.ed .w-s { width: 44px; }
table.ed .w-m { width: 62px; }

/* ---------- sheets (screen preview + print) ---------- */
#sheets { display: none; background: #3a3b42; padding: 20px; overflow: auto; height: 100%; }
body.view-sheets main { display: none; }
body.view-sheets #sheets { display: block; }
.sheet {
  background: #fff; margin: 0 auto 20px; box-shadow: 0 4px 20px #0008;
  display: grid; justify-content: center; align-content: start; overflow: hidden;
}
.sheet.backs { direction: rtl; }
.sheet.backs .ws { direction: ltr; }
.sheet.guides .ws, .sheet.guides .ac { outline: .15mm dashed #777; }

@media print {
  html, body { height: auto; background: #fff; }
  #app { display: block; height: auto; }
  header, main { display: none !important; }
  #sheets { display: block !important; padding: 0; background: none; overflow: visible; height: auto; }
  .sheet { margin: 0; box-shadow: none; break-after: page; }
  .sheet:last-child { break-after: auto; }
}
