/* =========================================================
   BBS Damage Calculator — dark UI
   ========================================================= */
:root {
  --bg: #09090b;
  --bg-2: #0d0d10;
  --panel: #17171b;
  --panel-2: #141417;
  --panel-3: #1d1d22;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #ededf1;
  --text-dim: #a5a5b0;
  --muted: #7c7c88;
  --gold: #e9b95c;
  --gold-soft: rgba(233, 185, 92, 0.13);
  --purple: #a855f7;
  --green: #4ade80;
  --red: #f05252;
  --blue: #3b82f6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(168, 85, 247, 0.10), transparent 60%),
    radial-gradient(700px 380px at 88% -8%, rgba(233, 185, 92, 0.07), transparent 60%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1640px;
  margin: 0 auto;
  padding: 20px 22px 40px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px 18px;
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--gold);
  background: linear-gradient(145deg, rgba(233, 185, 92, 0.16), rgba(233, 185, 92, 0.03));
  border: 1px solid rgba(233, 185, 92, 0.28);
  box-shadow: 0 0 22px -6px rgba(233, 185, 92, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.15px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1b1b20, #151518);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.1s;
}
.btn svg { width: 15px; height: 15px; opacity: 0.85; }
.btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }
.btn:active { transform: translateY(1px); }
.btn.danger:hover { color: #ff9a9a; border-color: rgba(240, 82, 82, 0.45); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  gap: 16px;
  align-items: start;
}

.main-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 18px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 42%),
    linear-gradient(180deg, #17171b, #121215);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2,
.card h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
  color: #dedee5;
}

.hint { font-size: 11.5px; color: var(--muted); }
.tag-soft {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 9px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Character card ---------- */
.character-card { padding: 16px 18px; }

.char-top { display: flex; align-items: center; gap: 14px; }

.portrait {
  --ac: #a855f7;
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 32% 22%, color-mix(in srgb, var(--ac) 62%, #2a2a30), transparent 68%),
    linear-gradient(150deg, color-mix(in srgb, var(--ac) 34%, #17171b), #0e0e11 74%);
  border: 1px solid color-mix(in srgb, var(--ac) 48%, transparent);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(255, 255, 255, 0.02);
  isolation: isolate;
}
.portrait::before {
  content: "";
  position: absolute;
  inset: -40% -40% 55% -40%;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.24), transparent 70%);
  transform: rotate(-12deg);
  z-index: -1;
}
.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, transparent 0 9px, rgba(255, 255, 255, 0.035) 9px 10px);
  z-index: -1;
}
.portrait-initial {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
.portrait-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.portrait-lg { width: 66px; height: 66px; }
.portrait-lg .portrait-initial { font-size: 23px; }
.portrait-sm { width: 42px; height: 42px; }
.portrait-sm .portrait-initial { font-size: 15px; }

.char-identity { min-width: 0; flex: 1; }
.char-name-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.char-name { font-size: 17px; font-weight: 650; letter-spacing: -0.2px; }
.char-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.attr-tag {
  --ac: #999;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  padding: 2px 8px 2px 4px;
  border-radius: 99px;
  color: color-mix(in srgb, var(--ac) 78%, white);
  background: color-mix(in srgb, var(--ac) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--ac) 38%, transparent);
}
.attr-tag .attr-ico { width: 15px; height: 15px; object-fit: contain; }

.rarity-tag {
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(233, 185, 92, 0.35);
}

.char-vitals {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--muted);
}
.char-vitals span { display: inline-flex; align-items: center; gap: 4px; }
.char-vitals img { width: 13px; height: 13px; object-fit: contain; opacity: 0.9; }
.killer-pill {
  color: #d7b06a;
  background: rgba(233, 185, 92, 0.08);
  border: 1px solid rgba(233, 185, 92, 0.22);
  border-radius: 99px;
  padding: 2px 8px;
}

.char-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.stat-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #141417;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
}
.stat-box span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.stat-box .stat-name { display: inline-flex; align-items: center; gap: 6px; }
.stat-ico { width: 17px; height: 17px; object-fit: contain; }
.stat-box input {
  width: 74px;
  background: transparent;
  border: 0;
  outline: 0;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-box input:focus { color: var(--gold); }
/* masquer les flèches */
.stat-box input::-webkit-outer-spin-button,
.stat-box input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stat-box input[type="number"],
.num-input { -moz-appearance: textfield; appearance: textfield; }

.char-actions { display: flex; gap: 7px; }

.btn-small {
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #18181d;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-small:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.24); }
.btn-small svg { width: 14px; height: 14px; }

.moves {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.moves summary {
  cursor: pointer;
  list-style: none;
  font-size: 11.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.moves summary::-webkit-details-marker { display: none; }
.moves summary::before {
  content: "▸";
  font-size: 10px;
  transition: transform 0.15s;
}
.moves[open] summary::before { transform: rotate(90deg); }
.moves-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.move-box {
  background: #141417;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
}
.move-box span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 2px;
}
.move-box input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Slots (abilities) ---------- */
.slot-row { display: flex; gap: 12px; align-items: center; }

.slot {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 17px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.075), transparent 58%),
    linear-gradient(160deg, #212127, #121215);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}
.slot:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 8px 20px -12px rgba(0, 0, 0, 0.9);
}
.slot.filled { border-color: color-mix(in srgb, var(--tone, #8b8b96) 32%, transparent); cursor: pointer; }

.slot.empty {
  background: linear-gradient(160deg, #17171b, #121215);
  border-style: dashed;
  color: #5d5d69;
}
.slot.empty:hover { color: var(--text-dim); border-color: rgba(255, 255, 255, 0.24); }
.slot-empty-plus { font-size: 24px; font-weight: 300; line-height: 1; }

.slot-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--tone, #cfcfd8);
  background:
    radial-gradient(circle at 34% 26%, color-mix(in srgb, var(--tone, #9a9aa6) 26%, transparent), transparent 64%),
    linear-gradient(160deg, #24242b, #121215);
  border: 1px solid color-mix(in srgb, var(--tone, #9a9aa6) 26%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 14px -8px rgba(0, 0, 0, 0.9);
}
.slot-icon svg { width: 25px; height: 25px; }

.slot-badge {
  position: absolute;
  right: -5px;
  top: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #26262d;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.slot.filled:hover .slot-badge { opacity: 1; }
.slot-badge:hover { color: #ff9a9a; border-color: rgba(240, 82, 82, 0.4); }

/* ---------- Bonus Abilities / Proficiencies ---------- */
.card-note {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
}

.bonus-grid { display: grid; gap: 9px; }

.bonus-slot {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 62px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1a1f, #141417);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.bonus-slot:hover { border-color: rgba(233, 185, 92, 0.34); background: #1b1b20; }
.bonus-slot:active { transform: translateY(1px); }
.bonus-slot.filled { cursor: pointer; }
.bonus-slot.empty { border-style: dashed; }
.bonus-slot.empty .bonus-name { color: var(--text-dim); }

.bonus-rank {
  width: 38px;
  height: 29px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.6));
}

.bonus-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bonus-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bonus-desc {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bonus-icon { width: 36px; height: 36px; flex: 0 0 auto; object-fit: contain; }
.bonus-plus { font-size: 22px; font-weight: 300; color: #6f6f7b; padding: 0 6px; }

.prof-grid { display: grid; gap: 9px; }

.prof-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1a1f, #141417);
}
.prof-card.empty {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  min-height: 66px;
  border-style: dashed;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.prof-card.empty:hover { color: var(--text-dim); border-color: rgba(255, 255, 255, 0.22); }
.prof-plus { font-size: 20px; font-weight: 300; color: #6f6f7b; margin-left: auto; }

.prof-top { display: flex; align-items: center; gap: 9px; }
.prof-icon { width: 32px; height: 32px; flex: 0 0 auto; object-fit: contain; }
.prof-meta { flex: 1; min-width: 0; }
.prof-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prof-cat { font-size: 10px; color: var(--muted); }

.prof-effect {
  font-size: 10.5px;
  color: var(--text-dim);
  background: #111114;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prof-level { display: flex; align-items: center; gap: 7px; }
.prof-level button {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #131316;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.prof-level button:hover { border-color: var(--line-strong); color: var(--text); }
.prof-level input[type="range"] { flex: 1; }
.prof-lv { font-size: 10px; color: var(--muted); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.prof-change {
  height: 25px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131316;
  color: #8e8e99;
  font-size: 10.5px;
  font-weight: 500;
  transition: color 0.14s, border-color 0.14s;
}
.prof-change:hover { color: var(--text-dim); border-color: var(--line-strong); }

.pick.used { opacity: 0.4; cursor: not-allowed; }
.pick.used:hover { border-color: var(--line); background: #141417; }
.pick-icon .pick-rank-img { width: 26px; height: 20px; object-fit: contain; }
.pick-icon .pick-prof-img { width: 24px; height: 24px; object-fit: contain; }
.pick-cat {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--tone, #8b8b97);
  background: color-mix(in srgb, var(--tone, #8b8b97) 12%, #141417);
  border-color: color-mix(in srgb, var(--tone, #8b8b97) 32%, transparent);
}

/* ---------- Accessories ---------- */
.acc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.acc-slot {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, #1a1a1f, #141417);
  padding: 12px;
}
.acc-slot.empty { border-style: dashed; }

.acc-top { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }

.acc-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #d8d8e2;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.1), transparent 60%),
    linear-gradient(160deg, #26262d, #141417);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 6px 16px -10px #000;
  transition: border-color 0.15s;
  padding: 0;
}
.acc-icon:hover { border-color: rgba(233, 185, 92, 0.4); }
.acc-icon svg { width: 27px; height: 27px; }
.item-img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }

.acc-meta { min-width: 0; flex: 1; }
.acc-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc-sub { font-size: 11px; color: var(--muted); }
.acc-empty-label { font-size: 12.5px; color: #6f6f7b; }

.mini-x {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #66666f;
  font-size: 15px;
  line-height: 1;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.mini-x:hover { color: #ff9a9a; border-color: rgba(240, 82, 82, 0.35); background: rgba(240, 82, 82, 0.07); }
.acc-slot.empty .acc-icon { border-style: dashed; color: #6f6f7b; }
.acc-slot.empty .roll-btn { opacity: 0.35; cursor: default; }

.roll-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.roll-btn {
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #131316;
  color: #8e8e99;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.14s;
}
.roll-btn:hover { color: var(--text-dim); border-color: var(--line-strong); }
.roll-btn.active {
  color: var(--gold);
  border-color: rgba(233, 185, 92, 0.62);
  background: linear-gradient(180deg, rgba(233, 185, 92, 0.13), rgba(233, 185, 92, 0.05));
  box-shadow: inset 0 0 14px rgba(233, 185, 92, 0.08), 0 0 0 1px rgba(233, 185, 92, 0.08);
}

/* ---------- Links ---------- */
.links-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.link-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, #1a1a1f, #141417);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.link-card.empty {
  border-style: dashed;
  justify-content: center;
  align-items: center;
  min-height: 290px;
  color: #6f6f7b;
  gap: 8px;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.link-card.empty:hover { color: var(--text-dim); border-color: rgba(255, 255, 255, 0.22); }
.link-empty-plus { font-size: 26px; font-weight: 300; line-height: 1; }

.link-head { display: flex; align-items: center; gap: 10px; }
.link-id { min-width: 0; flex: 1; cursor: pointer; }
.link-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.spe-input {
  width: 44px;
  height: 30px;
  text-align: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131316;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.spe-input:focus { border-color: rgba(233, 185, 92, 0.5); }
.link-spe-label { font-size: 10px; color: var(--muted); text-align: center; margin-bottom: 3px; letter-spacing: 0.3px; }

.slider-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 9px;
}
.slider-row .slabel { font-size: 11px; color: #8b8b97; white-space: nowrap; }
.slider-row .sval {
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.slider-row .sicon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--c, #8b8b97);
}
.slider-row .sicon svg { width: 17px; height: 17px; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 55%, transparent)); }

input[type="range"] {
  --thumb: var(--blue);
  --p: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--thumb) 0 var(--p), #2e2e36 var(--p) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--thumb);
  border: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--thumb) 18%, transparent), 0 1px 4px rgba(0, 0, 0, 0.6);
  transition: box-shadow 0.15s;
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px color-mix(in srgb, var(--thumb) 22%, transparent); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: #2e2e36; }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 99px; background: var(--thumb); }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--thumb) 18%, transparent);
}

.quick-row { display: grid; grid-template-columns: 34px 46px 1fr 1fr 1fr; gap: 5px; }
.qbtn {
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131316;
  color: #8e8e99;
  font-size: 10.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.14s;
  padding: 0 4px;
}
.qbtn:hover { color: var(--text-dim); border-color: var(--line-strong); }
.qbtn.active {
  color: var(--purple);
  border-color: rgba(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.09);
}
.qbtn.subtle { color: #6d6d79; }

.link-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lbtn {
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131316;
  color: #8e8e99;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.14s;
}
.lbtn svg { width: 13px; height: 13px; opacity: 0.8; }
.lbtn:hover { color: var(--text-dim); border-color: var(--line-strong); }
.lbtn.remove:hover { color: #ff9a9a; border-color: rgba(240, 82, 82, 0.4); }

/* ---------- Résumé / sidebar ---------- */
.summary-card { padding: 20px 18px 16px; }

.summary-title {
  text-align: center;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.1px;
  margin-bottom: 14px !important;
}

.summary-team {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}
.team-member { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 54px; }
.team-member .portrait { width: 52px; height: 52px; }
.team-names { font-size: 10px; color: var(--muted); max-width: 62px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-spe { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.team-add {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px dashed var(--line-strong);
  background: #131316;
  color: #62626e;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 300;
}
.team-add:hover { color: var(--text-dim); border-color: rgba(255,255,255,0.25); }

.damage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.dmg-tile {
  position: relative;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: #101013;
  padding: 11px 6px 9px;
  text-align: center;
  overflow: hidden;
  transition: border-color 0.2s;
}
.dmg-tile:hover { border-color: rgba(255, 255, 255, 0.22); }
.dmg-value {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dmg-label {
  margin-top: 2px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.7px;
  color: #84848f;
}
.dmg-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.05);
}
.dmg-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--bar-color, var(--gold));
  box-shadow: 0 0 10px var(--bar-color, var(--gold));
  transition: width 0.35s ease;
}
#bar-nad { --bar-color: #22c55e; }
#bar-sax { --bar-color: #a855f7; }
#bar-spe { --bar-color: #e9b95c; }
#bar-sa1 { --bar-color: #3b82f6; }
#bar-sa2 { --bar-color: #06b6d4; }
#bar-sa3 { --bar-color: #f05252; }

.summary-note {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.summary-note b { color: var(--text-dim); font-weight: 600; }

/* ---------- Champs ---------- */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field > label b {
  color: var(--text-dim);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #101013;
}
.segmented button {
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #86868f;
  font-size: 11px;
  font-weight: 550;
  transition: all 0.14s;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text-dim); }
.segmented button.active {
  color: var(--gold);
  background: linear-gradient(180deg, rgba(233, 185, 92, 0.14), rgba(233, 185, 92, 0.06));
  border-color: rgba(233, 185, 92, 0.42);
}

.num-input {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #101013;
  padding: 0 10px;
  outline: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
.num-input:focus { border-color: rgba(233, 185, 92, 0.5); }

/* Contexte du combat */
.combat-card .card-head { margin-bottom: 14px; }
.combat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 12px;
  align-items: start;
}
.combat-grid .field { margin-bottom: 0; }
.combat-grid .field > label { min-height: 16px; }
.combat-grid .field > label b { font-size: 11px; }

/* ---------- Breakdown ---------- */
.stat-lines { display: flex; flex-direction: column; gap: 8px; }
.stat-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.stat-line span { color: var(--muted); }
.stat-line b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.stat-line b.gold { color: var(--gold); }
.stat-line b.green { color: var(--green); }
.stat-line b.purple { color: var(--purple); }

.bd-bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.bd-bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--c, var(--gold)); transition: width 0.35s ease; }

.mini-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 10.5px; color: #6f6f7b; line-height: 1.5; }

.ico-inline { width: 14px; height: 14px; object-fit: contain; vertical-align: -2px; margin-right: 5px; opacity: 0.92; }

/* ---------- Disclaimer / footer ---------- */
.disclaimer { margin: 2px 2px 0; font-size: 11px; color: #5f5f6b; }
.foot {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 28px;
  font-size: 11px;
  color: #55555f;
}
.foot .dot { opacity: 0.6; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 4, 6, 0.72);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  animation: fadeIn 0.14s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  width: min(780px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1a1a1f, #111114);
  box-shadow: 0 40px 90px -30px #000, inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: popIn 0.16s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-sub { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #17171b;
  color: var(--muted);
  font-size: 13px;
  display: grid;
  place-items: center;
}
.modal-close:hover { color: var(--text); border-color: var(--line-strong); }

.modal-search-wrap {
  position: relative;
  margin: 0 20px 14px;
}
.modal-search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #66666f;
}
.modal-search-wrap input {
  width: 100%;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0f0f12;
  padding: 0 12px 0 34px;
  outline: none;
  font-size: 13px;
}
.modal-search-wrap input:focus { border-color: rgba(233, 185, 92, 0.42); }

.picker-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
}
.picker-filters[hidden] { display: none; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chip {
  height: 27px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131316;
  color: #8e8e99;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s;
}
.filter-chip img { width: 14px; height: 14px; object-fit: contain; }
.filter-chip:hover { color: var(--text-dim); border-color: var(--line-strong); }
.filter-chip.active {
  color: var(--gold);
  border-color: rgba(233, 185, 92, 0.5);
  background: rgba(233, 185, 92, 0.09);
}
.filter-select {
  height: 27px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131316;
  color: var(--text-dim);
  font-size: 11px;
  padding: 0 7px;
  outline: none;
}
.filter-select:focus { border-color: rgba(233, 185, 92, 0.42); }
.pick-count { margin-left: auto; font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 0 20px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #33333b transparent;
}
.modal-grid::-webkit-scrollbar { width: 8px; }
.modal-grid::-webkit-scrollbar-thumb { background: #2e2e36; border-radius: 99px; }

.pick {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #141417;
  text-align: left;
  transition: all 0.14s;
  min-width: 0;
}
.pick:hover { border-color: rgba(233, 185, 92, 0.4); background: #18181d; }
.pick.selected { border-color: rgba(233, 185, 92, 0.55); background: rgba(233, 185, 92, 0.06); }
.pick .portrait { width: 38px; height: 38px; }
.pick .portrait-initial { font-size: 13px; }
.pick .pick-icon {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #26262d, #141417);
  border: 1px solid var(--line-strong);
  color: var(--tone, #d8d8e2);
}
.pick .pick-icon svg { width: 22px; height: 22px; }
.pick-icon-img { padding: 0; overflow: hidden; background: #141417; }
.pick-icon-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 9px; }
.pick-attr-ico { width: 22px; height: 22px; object-fit: contain; margin-left: auto; flex: 0 0 auto; }
.pick-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.pick-name { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-desc { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-attr { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--tone, var(--muted)); }

.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 12px; grid-column: 1 / -1; }

/* ---------- Help ---------- */
.help-panel { width: min(680px, 100%); }
.help-body { padding: 0 22px 22px; overflow-y: auto; }
.formula-block {
  border: 1px solid var(--line);
  background: #101013;
  border-radius: 11px;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
}
.formula-block .indent { padding-left: 18px; color: var(--muted); }
.formula-block .fx { color: var(--gold); font-weight: 600; }
.formula-block em { color: var(--purple); font-style: normal; }
.help-list { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 12.5px; line-height: 1.75; }
.help-list li { margin-bottom: 6px; }
.help-list b { color: var(--text); font-weight: 600; }
.help-foot { font-size: 11.5px; color: var(--muted); line-height: 1.6; margin: 16px 0 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  background: #1e1e24;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: 99px;
  box-shadow: 0 18px 40px -16px #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 350px; }
  .links-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-row { grid-template-columns: 30px 40px 1fr 1fr 1fr; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; display: contents; }
  .main-col { order: 0; }
  .summary-card { order: -1; }
  .sidebar > .card:not(.summary-card) { order: 1; }
  .links-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app { padding: 14px 12px 32px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .links-grid { grid-template-columns: 1fr; }
  .acc-grid { grid-template-columns: 1fr; }
  .char-stats { grid-template-columns: 1fr; }
  .char-top { flex-wrap: wrap; }
  .char-actions { width: 100%; }
  .char-actions .btn-small { flex: 1; justify-content: center; }
  .moves-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot { width: 68px; height: 68px; }
  .modal-grid { grid-template-columns: 1fr; }
  .damage-grid { gap: 6px; }
  .dmg-value { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
