:root {
  --bg: #121214;
  --panel: #1a1a1e;
  --panel-2: #202026;
  --line: #2c2c33;
  --line-strong: #3d3d46;
  --text: #e8e6e1;
  --muted: #9a978f;
  --gold: #e3b85c;
  --class-bg: #1d3352; --class-fg: #8fbaf0;
  --camp-bg: #1d3b26; --camp-fg: #84d28f;
  --miss-bg: #3d1e1e; --miss-fg: #e88a85;
  --radius: 6px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4ef; --panel: #ffffff; --panel-2: #f1eee7; --line: #e2ded5; --line-strong: #cbc6ba;
    --text: #1f1e1b; --muted: #6b675e; --gold: #9a6b12;
    --class-bg: #dfeafa; --class-fg: #1d4f8f; --camp-bg: #e0f2e2; --camp-fg: #1f6b2c; --miss-bg: #fbe3e1; --miss-fg: #9b2a22;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; font-weight: 600; color: var(--gold); letter-spacing: 0.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
a { color: var(--gold); }
.sub, .hint, .muted { color: var(--muted); }
.sub { margin: 2px 0 0; font-size: 13px; }
.hint { font-size: 12.5px; margin: 8px 0 0; }
.error { color: var(--miss-fg); font-size: 13px; margin: 6px 0 0; }

button, select, input { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); }
button { padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--gold); }
button.small { font-size: 12.5px; padding: 2px 10px; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
select, input { padding: 3px 6px; min-width: 0; }
input[type="number"] { width: 4.2em; }
summary { cursor: pointer; }

/* ---------------------------------------------------------------- header */
.top, .layout, .foot { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px 24px; flex-wrap: wrap; padding-top: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand img { border-radius: 6px; border: 1px solid var(--line-strong); }
.share { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; position: relative; }
.import summary { list-style: none; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.import summary::-webkit-details-marker { display: none; }
.import[open] summary { border-color: var(--gold); }
.import-form, .import .error { position: absolute; right: 0; z-index: 5; }
.import-form { top: calc(100% + 6px); display: flex; gap: 6px; padding: 8px; width: min(420px, calc(100vw - 32px)); background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.import-form input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.import .error { top: calc(100% + 56px); background: var(--panel-2); padding: 4px 8px; border-radius: var(--radius); }

/* ---------------------------------------------------------------- two columns: group | plan */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 24px 32px; padding-top: 20px; padding-bottom: 24px; align-items: start; }
section { min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; min-height: 30px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label.inline { color: var(--muted); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }

.menu { position: relative; }
.menu > summary { list-style: none; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; color: var(--muted); }
.menu[open] > summary { border-color: var(--gold); }
.menu-box { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: 290px; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.menu-box > button { text-align: left; }
.menu-head { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.saved { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.saved-item { display: flex; gap: 4px; }
.saved-load { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-form { display: flex; gap: 6px; }
.save-form input { flex: 1; }

/* the group's rows */
.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.member { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto auto 26px; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.member .cls { border-radius: 4px; }
.member .name { width: 100%; }
.x { padding: 0; width: 26px; height: 26px; line-height: 1; color: var(--muted); }
.prof-pick { grid-column: 2 / -1; font-size: 13px; }
.prof-pick summary { color: var(--muted); padding: 1px 0; }
.prof-pick[open] summary { color: var(--text); }
.prof-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 2px 10px; padding: 6px 0 4px; }
.prof-head { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.prof-opt { display: flex; gap: 4px; align-items: center; cursor: pointer; }
.prof-opt.off { color: var(--muted); cursor: default; }
.prof-box .small { grid-column: 1 / -1; justify-self: start; margin-top: 4px; }
.add-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.class-picks { display: flex; gap: 4px; flex-wrap: wrap; }
.pick { padding: 2px; line-height: 0; }
.pick img { border-radius: 4px; }

.c-warrior { color: #c79c6e; } .c-rogue { color: #fff569; } .c-hunter { color: #abd473; } .c-mage { color: #69ccf0; }
.c-warlock { color: #9482c9; } .c-priest { color: #f0f0f0; } .c-druid { color: #ff7d0a; } .c-shaman { color: #3f9cf0; }
.c-paladin { color: #f58cba; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .c-rogue { color: #8a7d00; }
  :root:not([data-theme="dark"]) .c-priest { color: #555; }
  :root:not([data-theme="dark"]) .c-mage { color: #1c7fa8; }
  :root:not([data-theme="dark"]) .c-warrior { color: #8a6232; }
  :root:not([data-theme="dark"]) .c-hunter { color: #567a24; }
}

/* ---------------------------------------------------------------- the plan */
.cover { margin: 0; color: var(--muted); }
#pct { color: var(--gold); font-weight: 700; font-size: 20px; }
.controls { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line-strong); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--gold); color: #1a1408; }
.options > summary { list-style: none; padding: 4px 10px; color: var(--muted); }
.options > summary::-webkit-details-marker { display: none; }
.options > summary::before { content: "▸ "; }
.options[open] > summary::before { content: "▾ "; }
.options-box { display: flex; flex-direction: column; gap: 6px; padding: 6px 0 2px 10px; }
.opt-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
input[type="range"] { width: 100%; max-width: 280px; accent-color: var(--gold); }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.person { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); grid-template-areas: "who what" "who how"; gap: 2px 12px; align-items: center; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.person.none { background: transparent; }
.who { grid-area: who; display: flex; gap: 8px; align-items: center; min-width: 0; }
.pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what { grid-area: what; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.what .ico { border: 1px solid var(--line-strong); border-radius: 4px; }
.fname { font-weight: 600; }
.gives { color: var(--camp-fg); }
.how { grid-area: how; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.chip-b { display: inline-flex; gap: 3px; align-items: center; padding: 0 6px; border-radius: 4px; background: var(--class-bg); color: var(--class-fg); font-size: 12.5px; }
.empty { color: var(--muted); list-style: none; padding: 8px 0; }
.extras p { margin: 10px 0 0; font-size: 14px; }
.extras strong { color: var(--gold); font-weight: 600; margin-right: 4px; }
.ico { vertical-align: -3px; border-radius: 3px; }

details.more { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
details.more > summary { font-weight: 600; }
.grid-scroll { overflow-x: auto; margin-top: 8px; }
.grid, .ref { border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: center; white-space: nowrap; }
.grid thead th { vertical-align: bottom; font-weight: 600; }
.grid thead img { display: block; margin: 0 auto 2px; border-radius: 3px; }
.gname { display: block; font-size: 11.5px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.grid tbody th { text-align: left; font-weight: 400; color: var(--muted); }
.grid td { min-width: 44px; font-variant-numeric: tabular-nums; }
.ref th, .ref td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.ref thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.ref tbody th { font-weight: 600; white-space: nowrap; }
.k { padding: 0 6px; border-radius: 4px; }
.k-class { background: var(--class-bg); color: var(--class-fg); }
.k-camp { background: var(--camp-bg); color: var(--camp-fg); }
.k-missing { background: var(--miss-bg); color: var(--miss-fg); }

.tip { position: fixed; z-index: 10; max-width: 340px; padding: 8px 10px; white-space: pre-line; background: #0b0b0d; color: #f2efe6; border: 1px solid var(--gold); border-radius: var(--radius); font-size: 13px; line-height: 1.45; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
[data-tip] { cursor: help; }
button[data-tip], input[data-tip], select[data-tip], summary[data-tip], label[data-tip] { cursor: pointer; }
input.name[data-tip] { cursor: text; }

.foot { border-top: 1px solid var(--line); padding-top: 14px; padding-bottom: 30px; font-size: 12.5px; color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .member { grid-template-columns: 28px minmax(0, 1fr) auto auto; }
  .member .name { grid-column: 2 / 4; }
  .member select:first-of-type { grid-column: 2; grid-row: 2; }
  .member select:last-of-type { grid-column: 3; grid-row: 2; }
  .member input[type="number"] { grid-column: 4; grid-row: 2; width: 3.6em; }
  .member select { max-width: 100%; }
  .member .x { grid-column: 4; grid-row: 1; justify-self: end; }
  .person { grid-template-columns: 1fr; grid-template-areas: "who" "what" "how"; }
  .share { width: 100%; }
  .group .section-head { position: relative; }
  .menu { position: static; }
  .menu-box { left: 0; right: 0; width: auto; top: 100%; }
}
