:root {
  --bg: #15171c; --panel: #1e2128; --panel2: #262a33; --line: #343a46;
  --text: #e8eaee; --dim: #98a1b0; --accent: #e0483d;
}
* { 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: #56607a; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: #ff8d85; }
button.small { padding: 2px 8px; font-size: 12px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; background: #12141a; 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; }
input[type=range] { width: 100%; }
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: 290px 1fr 400px; min-height: 0; }
main > section { min-height: 0; overflow: auto; padding: 14px; }
#roster, #editor { background: var(--panel); }
#roster { border-right: 1px solid var(--line); }
#editor { border-left: 1px solid var(--line); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 0 0 8px; }

.warn { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: #3a2f14; color: #f1cf7a; font-size: 12px; }
.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 .d { grid-column: 1 / -1; font-size: 12px; color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row.tight > * { flex: none; }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.grid5 input { text-align: center; }

#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 .card { zoom: 0.55; }
.thumb .copies {
  position: absolute; right: -6px; top: -6px; background: var(--accent); color: #fff;
  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; justify-content: center; padding: 4px 0 12px; }
#preview .card { zoom: 1.25; }
#preview .c-art { cursor: grab; touch-action: none; }
#preview .c-art.drag { cursor: grabbing; }
#preview.over .card { outline: 3px dashed var(--accent); }

/* ---------- sheets (screen preview + print) ---------- */
#sheets { display: none; background: #3b3f48; 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; grid-template-columns: repeat(2, 76mm); grid-auto-rows: 111mm;
  justify-content: center; align-content: start;
  overflow: hidden;
}
.sheet.backs { direction: rtl; }
.sheet.backs .card { direction: ltr; }
.sheet.guides .card { outline: 0.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; }
}
