/* Xpidemix FSD Army Builder. Dark tactical panel, scoped to .xfsd-app so theme styles stay out. */
.xfsd-app {
  --xf-bg: #0f1418;
  --xf-panel: #161d23;
  --xf-raise: #1b252c;
  --xf-line: #26313a;
  --xf-line2: #3a4752;
  --xf-fg: #e6ecef;
  --xf-soft: #c9d4da;
  --xf-muted: #93a3ad;
  --xf-accent: #4fd1ff;
  --xf-ok: #9ccc4a;
  --xf-warn: #ffb547;
  --xf-err: #ff6b6b;
  --xf-display: 'Chakra Petch', 'Arial Narrow', sans-serif;
  --xf-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --xf-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  background: var(--xf-bg);
  color: var(--xf-fg);
  font-family: var(--xf-body);
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
  border-radius: 8px;
  overflow: clip; /* clip, not hidden, so the sticky list panel still sticks */
  -webkit-font-smoothing: antialiased;
}
.xfsd-wrap { margin: 0 0 32px; }
.xfsd-wrap.xfsd-full {
  width: 100vw; max-width: 100vw; position: relative; left: 50%; margin-left: -50vw;
}
.xfsd-wrap.xfsd-full .xfsd-app { max-width: 1480px; margin: 0 auto; border-radius: 0; }
@media (min-width: 1500px) { .xfsd-wrap.xfsd-full .xfsd-app { border-radius: 8px; } }

/* standalone page (layout="canvas"): slim site bar, builder edge to edge, short footer */
body.xfsd-canvas { margin: 0; padding: 0; background: #0f1418; overflow-x: clip; }
.xfsd-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 28px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  padding-left: max(clamp(16px, 3vw, 40px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 3vw, 40px), env(safe-area-inset-right, 0px));
  background: #0b1014; border-bottom: 3px solid #4fd1ff;
  font-family: 'Chakra Petch', 'Arial Narrow', sans-serif;
}
.xfsd-bar a.xfsd-bar-home, .xfsd-bar a.xfsd-bar-home:hover {
  color: #e6ecef; font-weight: 700; font-size: 22px; letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
}
.xfsd-bar .xfsd-bar-menu { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; padding: 0; list-style: none; }
.xfsd-bar .xfsd-bar-menu li { margin: 0; padding: 0; list-style: none; }
.xfsd-bar .xfsd-bar-menu a {
  color: #9fdcf5; font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; text-decoration: none;
}
.xfsd-bar .xfsd-bar-menu a:hover, .xfsd-bar .xfsd-bar-menu .current-menu-item > a { color: #fff; }
.xfsd-canvas-main { margin: 0; padding: 0; background: #0f1418; }
.xfsd-canvas-main > p:empty { display: none; }
.xfsd-wrap.xfsd-canvas-wrap { margin: 0; }
.xfsd-canvas-wrap .xfsd-app { max-width: none; border-radius: 0; min-height: calc(100vh - 110px); }
.xfsd-canvas-wrap .xfsd-head, .xfsd-canvas-wrap .xfsd-main, .xfsd-canvas-wrap .xfsd-foot { padding-left: clamp(16px, 3vw, 40px); padding-right: clamp(16px, 3vw, 40px); }
.xfsd-canvas-wrap .xfsd-factions { padding-left: clamp(8px, 3vw, 40px); padding-right: clamp(8px, 3vw, 40px); }
.xfsd-canvas-wrap .xfsd-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.xfsd-canvas-wrap .xfsd-roster { flex-basis: 400px; }
.xfsd-canvas-foot {
  padding: 16px; background: #0b1014; color: #93a3ad; text-align: center;
  font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 13px;
}
.xfsd-canvas-foot a { color: #9fdcf5; }

/* resets against theme styles */
.xfsd-app *, .xfsd-app *::before, .xfsd-app *::after { box-sizing: border-box; }
.xfsd-app h2, .xfsd-app h3, .xfsd-app p, .xfsd-app ul { margin: 0; padding: 0; }
.xfsd-app ul { list-style: none; }
.xfsd-app img { max-width: 100%; height: auto; display: block; border: 0; box-shadow: none; }
.xfsd-app a { color: #9fdcf5; text-decoration: underline; text-underline-offset: 2px; }
.xfsd-app a:hover { color: #d4f1fc; }
.xfsd-app button, .xfsd-app input, .xfsd-app select {
  font-family: inherit; font-size: inherit; line-height: 1.2; letter-spacing: normal; text-transform: none;
  margin: 0; box-shadow: none; text-shadow: none;
}
.xfsd-app button { cursor: pointer; }
.xfsd-app button:disabled { cursor: default; opacity: .55; }
.xfsd-app :focus-visible { outline: 2px solid var(--xf-warn); outline-offset: 2px; }
.xfsd-app svg { flex: none; }
.xfsd-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.xfsd-loading { padding: 40px 24px; color: #93a3ad; }
.xfsd-muted { color: var(--xf-muted); font-size: 13px; }
.xfsd-hint { color: var(--xf-muted); font-size: 12px; margin-top: -2px !important; }

/* buttons & inputs */
.xfsd-app .xfsd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 14px; border-radius: 4px;
  background: transparent; color: var(--xf-fg); border: 1px solid var(--xf-line2); font-weight: 500;
}
.xfsd-app .xfsd-btn:hover:not(:disabled) { border-color: var(--xf-accent); background: transparent; color: var(--xf-fg); }
.xfsd-app .xfsd-btn-primary { background: var(--xf-accent); border-color: var(--xf-accent); color: #0b1216; font-weight: 600; }
.xfsd-app .xfsd-btn-primary:hover:not(:disabled) { background: var(--xf-accent); color: #0b1216; filter: brightness(1.08); }
.xfsd-app .xfsd-btn-sm { min-height: 36px; padding: 0 10px; font-size: 13px; }
.xfsd-app .xfsd-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--xf-muted);
}
.xfsd-app .xfsd-icon-btn:hover { color: var(--xf-fg); background: var(--xf-raise); }
.xfsd-app .xfsd-input, .xfsd-app .xfsd-select {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: 4px;
  background: var(--xf-bg); color: var(--xf-fg); border: 1px solid var(--xf-line2); color-scheme: dark;
}
.xfsd-app .xfsd-select { padding-right: 8px; }
.xfsd-app .xfsd-select-sm { min-height: 34px; font-size: 13px; width: auto; max-width: 52%; }
.xfsd-app .xfsd-input:focus, .xfsd-app .xfsd-select:focus { border-color: var(--xf-accent); outline: none; }

/* header */
.xfsd-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 24px; background: #121a1f; border-bottom: 1px solid var(--xf-line);
}
.xfsd-brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.xfsd-title { font-family: var(--xf-display); font-weight: 700; font-size: 26px; letter-spacing: .04em; text-transform: uppercase; line-height: 1.1; }
.xfsd-accent { color: var(--xf-accent); }
.xfsd-sub { font-size: 13px; color: var(--xf-muted); }
.xfsd-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* notice */
.xfsd-notice-wrap:empty { display: none; }
.xfsd-notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 14px 24px 0; padding: 10px 10px 10px 14px; border-radius: 4px; border: 1px solid var(--xf-line2); background: var(--xf-raise);
}
.xfsd-notice.xfsd-tone-warn { border-color: var(--xf-warn); }
.xfsd-notice-actions { display: flex; align-items: center; gap: 6px; }

/* factions */
.xfsd-factions { display: flex; gap: 2px; padding: 0 24px; overflow-x: auto; border-bottom: 1px solid var(--xf-line); scrollbar-width: thin; }
.xfsd-app .xfsd-faction {
  display: inline-flex; align-items: center; gap: 9px; min-height: 54px; padding: 0 16px; white-space: nowrap;
  background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--xf-muted);
  font-family: var(--xf-display); font-weight: 600; font-size: 16px; letter-spacing: .04em; text-transform: uppercase;
}
.xfsd-app .xfsd-faction:hover { color: var(--xf-fg); background: transparent; }
.xfsd-app .xfsd-faction.is-on { color: var(--xf-fg); border-bottom-color: var(--xf-fc); }
.xfsd-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--xf-fc); }
.xfsd-badge { font-family: var(--xf-mono); font-size: 10px; letter-spacing: .05em; padding: 2px 5px; border: 1px solid var(--xf-warn); color: var(--xf-warn); border-radius: 3px; }
.xfsd-count { font-family: var(--xf-mono); font-size: 11px; min-width: 20px; padding: 1px 5px; border-radius: 10px; background: var(--xf-raise); color: var(--xf-soft); text-align: center; }

/* layout */
.xfsd-main { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; padding: 24px; }
.xfsd-catalogue { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.xfsd-roster {
  flex: 1 1 360px; min-width: 0; background: var(--xf-panel); border: 1px solid var(--xf-line); border-radius: 6px;
  position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
}
.admin-bar .xfsd-roster { top: 48px; max-height: calc(100vh - 64px); }

/* catalogue */
.xfsd-cat-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.xfsd-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.xfsd-app .xfsd-tab {
  min-height: 40px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--xf-line2);
  background: transparent; color: var(--xf-fg); font-weight: 600;
}
.xfsd-app .xfsd-tab:hover { border-color: var(--xf-accent); background: transparent; color: var(--xf-fg); }
.xfsd-app .xfsd-tab.is-on { background: var(--xf-accent); border-color: var(--xf-accent); color: #0b1216; }
.xfsd-search { display: flex; align-items: center; gap: 8px; flex: 0 1 260px; padding-left: 12px; border: 1px solid var(--xf-line2); border-radius: 4px; color: var(--xf-muted); }
.xfsd-search:focus-within { border-color: var(--xf-accent); }
.xfsd-app .xfsd-search .xfsd-input { border: 0; padding-left: 0; background: transparent; }
.xfsd-allypick:empty { display: none; }
.xfsd-allypick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.xfsd-allypick label { font-size: 13px; color: var(--xf-muted); }
.xfsd-app .xfsd-allypick .xfsd-select { width: auto; }

.xfsd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.xfsd-card { display: flex; flex-direction: column; background: var(--xf-panel); border: 1px solid var(--xf-line); border-radius: 6px; overflow: hidden; }
.xfsd-pic { position: relative; aspect-ratio: 4 / 3; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--xf-raise); border-bottom: 1px solid var(--xf-line); }
.xfsd-app .xfsd-pic img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); max-width: none; object-fit: contain; }
.xfsd-pic-ph {
  background: repeating-linear-gradient(135deg, #1b242b 0 10px, #182027 10px 20px);
  font-family: var(--xf-display); font-weight: 700; font-size: 30px; letter-spacing: .06em; color: var(--xf-fc);
}
.xfsd-pic-ph span { opacity: .75; }
.xfsd-card-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; flex: 1; }
.xfsd-card.is-compact { border-top: 3px solid var(--xf-fc); }
.xfsd-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.xfsd-app .xfsd-card-name { font-family: var(--xf-display); font-weight: 600; font-size: 17px; line-height: 1.2; color: var(--xf-fg); text-wrap: balance; margin: 0; }
.xfsd-pts { font-family: var(--xf-mono); font-weight: 600; font-size: 14px; color: var(--xf-accent); white-space: nowrap; }
.xfsd-card-type { font-size: 13px; color: var(--xf-muted); }
.xfsd-card-note { font-size: 13px; color: var(--xf-soft); }
.xfsd-app .xfsd-add { margin-top: auto; width: 100%; border-color: var(--xf-accent); font-weight: 600; }
.xfsd-card-body > .xfsd-add { margin-top: auto; }
.xfsd-card-body .xfsd-card-type + .xfsd-add, .xfsd-card-body .xfsd-card-note + .xfsd-add { margin-top: auto; }
.xfsd-empty { grid-column: 1 / -1; padding: 40px 20px; text-align: center; color: var(--xf-muted); border: 1px dashed var(--xf-line2); border-radius: 6px; }

/* roster */
.xfsd-roster-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--xf-line); display: flex; flex-direction: column; gap: 12px; }
.xfsd-roster-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.xfsd-namebox { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.xfsd-app .xfsd-name { font-family: var(--xf-display); font-weight: 600; font-size: 19px; min-height: 40px; padding: 0 8px; margin-left: -8px; background: transparent; border-color: transparent; }
.xfsd-app .xfsd-name:hover { border-color: var(--xf-line2); }
.xfsd-totals { text-align: right; }
.xfsd-total { font-family: var(--xf-mono); font-weight: 600; font-size: 28px; line-height: 1; color: var(--xf-accent); font-variant-numeric: tabular-nums; }
.xfsd-total span { font-size: 15px; color: var(--xf-muted); }
.xfsd-total.is-over { color: var(--xf-err); }
.xfsd-meter { height: 8px; background: var(--xf-bg); border-radius: 4px; overflow: hidden; }
.xfsd-meter-bar { height: 100%; width: 0; background: var(--xf-accent); transition: width .2s; }
.xfsd-meter.is-over .xfsd-meter-bar { background: var(--xf-err); }
.xfsd-sizes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.xfsd-sizes .xfsd-muted { margin-right: 4px; }
.xfsd-app .xfsd-size {
  min-height: 40px; min-width: 50px; padding: 0 10px; border-radius: 4px; border: 1px solid var(--xf-line2);
  background: transparent; color: var(--xf-fg); font-family: var(--xf-mono); font-weight: 600;
}
.xfsd-app .xfsd-size:hover { border-color: var(--xf-accent); background: transparent; color: var(--xf-fg); }
.xfsd-app .xfsd-size.is-on { border-color: var(--xf-accent); color: var(--xf-accent); background: var(--xf-raise); }
.xfsd-share-wrap:empty { display: none; }
.xfsd-share { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: center; }
.xfsd-share label { grid-column: 1 / -1; font-size: 12px; color: var(--xf-muted); }
.xfsd-app .xfsd-share .xfsd-input { min-height: 36px; font-family: var(--xf-mono); font-size: 13px; }

.xfsd-roster-body { padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.xfsd-app .xfsd-eyebrow { font-family: var(--xf-body); font-size: 12px; font-weight: 600; color: var(--xf-muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 10px; }
.xfsd-roster-head .xfsd-eyebrow { margin-top: 0; }
.xfsd-row { display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 6px 12px; border: 1px solid var(--xf-line); border-radius: 4px; }
.xfsd-row.is-sel { border-color: var(--xf-accent); background: var(--xf-raise); }
.xfsd-row-flat { flex-direction: row; align-items: center; gap: 8px; padding: 2px 4px 2px 12px; }
.xfsd-row-main { display: flex; align-items: center; gap: 6px; }
.xfsd-app .xfsd-row-pick {
  flex: 1; min-width: 0; min-height: 40px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 0; border: 0; background: transparent; color: var(--xf-fg); text-align: left;
}
.xfsd-app .xfsd-row-pick:hover { background: transparent; color: var(--xf-fg); }
.xfsd-row-name { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.xfsd-row-pts { font-family: var(--xf-mono); color: var(--xf-muted); font-variant-numeric: tabular-nums; }
.xfsd-row-tools { display: inline-flex; }
.xfsd-row-tools .xfsd-icon-btn { width: 30px; }
.xfsd-chip { display: inline-block; margin-left: 8px; padding: 1px 6px; font-size: 11px; font-weight: 600; border-radius: 3px; border: 1px solid var(--xf-line2); color: var(--xf-soft); vertical-align: 1px; }
.xfsd-sub-rows { display: flex; flex-direction: column; gap: 4px; padding-right: 6px; }
.xfsd-sub-row { display: flex; align-items: center; gap: 8px; }
.xfsd-sub-row label { flex: 0 0 auto; min-width: 72px; font-size: 12px; color: var(--xf-muted); }
.xfsd-app .xfsd-sub-row .xfsd-select { min-height: 34px; font-size: 13px; }
.xfsd-systems { font-size: 12px; color: var(--xf-muted); padding-right: 6px; }
.xfsd-char { display: flex; align-items: center; gap: 8px; padding-left: 12px; margin: 2px 0 0 2px; border-left: 2px solid var(--xf-accent); font-size: 14px; }
.xfsd-char.is-loose { border-left-color: var(--xf-warn); padding: 4px 4px 4px 12px; border-top: 1px solid var(--xf-line); border-right: 1px solid var(--xf-line); border-bottom: 1px solid var(--xf-line); border-radius: 0 4px 4px 0; margin: 0; }
.xfsd-char .xfsd-row-name { color: var(--xf-soft); flex: 1 1 96px; }
.xfsd-mini { display: none; }
.xfsd-checks { display: flex; flex-direction: column; gap: 8px; }
.xfsd-checks li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--xf-soft); }
.xfsd-tag { flex: none; min-width: 48px; text-align: center; font-family: var(--xf-mono); font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 3px; border: 1px solid currentColor; }
.xfsd-tag.xfsd-tone-ok { color: var(--xf-ok); }
.xfsd-tag.xfsd-tone-warn { color: var(--xf-warn); }
.xfsd-tag.xfsd-tone-error { color: var(--xf-err); }
.xfsd-tag.xfsd-tone-info { color: var(--xf-muted); }

/* footer & toast */
.xfsd-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 18px 24px 24px; border-top: 1px solid var(--xf-line); font-size: 13px; color: var(--xf-muted); }
.xfsd-foot p { max-width: 70ch; }
.xfsd-foot nav { display: flex; flex-wrap: wrap; gap: 18px; }
.xfsd-toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 99999;
  padding: 10px 16px; border-radius: 4px; background: #e6ecef; color: #0f1418; font-weight: 600; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35); max-width: calc(100vw - 32px);
}
.xfsd-print { display: none; }

/* small screens */
@media (max-width: 760px) {
  .xfsd-head, .xfsd-main, .xfsd-foot { padding-left: 16px; padding-right: 16px; }
  .xfsd-factions { padding: 0 8px; }
  .xfsd-notice { margin-left: 16px; margin-right: 16px; }
  .xfsd-roster { position: static; max-height: none; }
  .xfsd-search { flex: 1 1 100%; }
  .xfsd-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .xfsd-app .xfsd-card-name { font-size: 15px; }
  .xfsd-actions .xfsd-btn { flex: 1 1 auto; }
  .xfsd-mini {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; bottom: 0; z-index: 50;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: #121a1f; border-top: 1px solid var(--xf-line2);
  }
  .xfsd-mini-text { font-family: var(--xf-mono); font-weight: 600; color: var(--xf-accent); }
  .xfsd-mini.is-over .xfsd-mini-text { color: var(--xf-err); }
  .xfsd-toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .xfsd-app * { transition: none !important; } }

/* print: only the roster sheet */
@media print {
  body * { visibility: hidden !important; }
  .xfsd-print, .xfsd-print * { visibility: visible !important; }
  .xfsd-print { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 12mm; color: #000; background: #fff; font-family: 'IBM Plex Sans', Arial, sans-serif; }
  .xfsd-print h2 { font-size: 20pt; margin: 0 0 4pt; }
  .xfsd-print p { margin: 0 0 10pt; font-size: 11pt; }
  .xfsd-print pre { white-space: pre-wrap; font-family: 'IBM Plex Mono', 'Courier New', monospace; font-size: 11pt; line-height: 1.5; }
}
