:root {
  color-scheme: dark;
  --display: Cinzel, Forum, 'Times New Roman', serif; /* Forum covers Cyrillic, which Cinzel lacks */
  --bg: #0a0705;
  --panel: #17110b;
  --panel2: #0f0b07;
  --tile: #0d0906;
  --line: #4a3820;
  --line-strong: #7a6238;
  --gold: #ffd100;
  --gold-dim: #c9a14a;
  --text: #eadfc6;
  --muted: #a8987a;
  --warn: #f0b429;
  --danger: #ff8a80;
  --alliance: #2f6fd6;
  --horde: #c0262b;
  --tank: #5b9bf0;
  --heal: #4fc16a;
  --dps: #e0574f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 17px/1.45 'Crimson Pro', Georgia, serif;
  background: radial-gradient(ellipse at top, #2a1c10 0%, var(--bg) 60%) fixed, var(--bg);
}

#app { max-width: 1120px; margin: 0 auto; padding: 0 16px 16px; }

h1, h2, h3, .brand, .btn, .tabs button, .badge, .field > span, .field > legend, .pickset legend, .seg, .slot, .steplabel, .code, .switcher, .sheet-title { font-family: var(--display); }
h2 { margin: 0 0 12px; color: var(--gold); font-size: 22px; }
h3 { margin: 0; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }
.wide { grid-column: 1 / -1; width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }

/* ---------- focus ---------- */
:is(button, summary, a, .linkish):focus-visible,
.pick:has(input:focus-visible),
.seg label:has(input:focus-visible),
.check:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title tools" "sub tools";
  align-items: center; gap: 4px 12px;
  padding: 16px 0 12px; border-bottom: 1px solid var(--line);
}
.top h1, .top .brand { grid-area: title; }
.top .sub { grid-area: sub; margin: 0; color: var(--gold-dim); }
.top-tools { grid-area: tools; display: flex; align-items: center; gap: 8px; }
h1, .brand, .sheet-title {
  margin: 0;
  font-size: clamp(26px, 6vw, 44px); font-weight: 700; letter-spacing: .04em;
  background: linear-gradient(#fff6c4, var(--gold) 50%, #a8740a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 1px #000);
}
.brand { font-size: 22px; }
.pill { display: inline-block; padding: 1px 10px; color: #1a1000; font-weight: 600; white-space: nowrap; background: var(--gold-dim); border-radius: 999px; }

.langbtn { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; color: var(--gold); font-weight: 600; background: var(--tile); border: 1px solid var(--line); border-radius: 4px; }
.langbtn:hover { border-color: var(--gold-dim); }
.flag { width: 24px; height: 16px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px #000a; }

.account { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px 0 4px; color: var(--gold); border: 1px solid var(--line); border-radius: 22px; }
img.avatar { object-fit: cover; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; color: #1a1000; font: 700 16px var(--display); background: linear-gradient(#ffe169, #c99400); border-radius: 50%; }

/* ---------- menus (details/summary) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0;
  display: grid; min-width: 240px; padding: 6px;
  background: linear-gradient(var(--panel), var(--panel2)); border: 1px solid var(--gold-dim); border-radius: 6px;
  box-shadow: 0 10px 30px #000c;
}
.menu.right .menu-pop { left: auto; right: 0; }
.menu-pop p { padding: 6px 12px; font-size: 15px; }
.menu-pop button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; color: var(--text); font: inherit; text-align: left; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.menu-pop button:hover, .menu-pop button:focus-visible { color: var(--gold); background: #2a1f0d; }
.menu-pop button[aria-current="true"] { color: var(--gold); font-weight: 600; }
.menu-pop .danger { color: var(--danger); }
.menu-pop .ok { margin-left: auto; color: var(--heal); }
.menu-pop hr { margin: 4px 0; border: 0; border-top: 1px solid var(--line); }

/* ---------- tabs ---------- */
.tabs {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 4px; margin: 0 0 20px; padding: 8px 0 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
  box-shadow: -16px 0 var(--bg), 16px 0 var(--bg); /* cover the gutters while stuck */
}
.tabs button {
  min-height: 44px; padding: 0 22px; margin-bottom: -1px;
  color: var(--muted); font-size: 16px; background: none; cursor: pointer;
  border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
}
.tabs button[aria-current="page"] { color: var(--gold); background: var(--panel); border-color: var(--line); }

/* ---------- panels & buttons ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: inset 0 0 0 1px #000, inset 0 1px 0 #ffffff0d, 0 6px 18px #000a;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  color: var(--gold); font-size: 15px; letter-spacing: .04em; text-shadow: 0 1px 1px #000;
  background: linear-gradient(#b8160d, #6a0a05);
  border: 1px solid #2a0402; border-radius: 4px;
  box-shadow: inset 0 1px 0 #ff8a7055, inset 0 -2px 0 #0006, 0 0 0 1px #8a6a2e, 0 3px 6px #000;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled { filter: grayscale(1) brightness(.7); cursor: not-allowed; }
.btn.ghost { color: var(--gold-dim); background: var(--tile); border-color: var(--line); box-shadow: 0 0 0 1px #000; text-shadow: none; }
.btn.ghost:hover { color: var(--gold); border-color: var(--gold-dim); filter: none; }
.btn.wide { width: 100%; margin: 8px 0 16px; }
.btn.discord { color: #fff; background: linear-gradient(#6c78ff, #4752c4); box-shadow: inset 0 1px 0 #fff4, 0 0 0 1px #8a6a2e, 0 3px 6px #000; }

.iconbtn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--gold-dim); font-size: 20px; background: var(--tile); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.iconbtn:hover { color: var(--gold); border-color: var(--gold-dim); }
.linkish { min-height: 44px; padding: 0; color: var(--gold); font: 600 17px 'Crimson Pro', Georgia, serif; text-align: left; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; background: none; border: 0; cursor: pointer; }
.linkish:hover { text-decoration-color: currentColor; }
.danger-link { min-height: 44px; margin-top: 16px; padding: 0; color: var(--danger); font: inherit; text-decoration: underline; background: none; border: 0; cursor: pointer; }

/* ---------- inputs ---------- */
input:not([type="radio"], [type="checkbox"]) {
  width: 100%; min-height: 44px; padding: 8px 10px;
  color: var(--text); font: inherit;
  background: #070504; border: 1px solid var(--line-strong); border-radius: 4px;
}
input:focus { outline: 2px solid transparent; border-color: var(--gold-dim); box-shadow: 0 0 0 2px #ffd10044; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--gold); }
.field { display: block; margin: 14px 0 0; padding: 0; border: 0; }
.field > span, .field > legend { display: block; margin-bottom: 4px; padding: 0; color: var(--gold); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button, .seg label { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--muted); font: 600 14px var(--display); background: var(--tile); border: 0; cursor: pointer; }
.seg button[aria-pressed="true"], .seg label:has(input:checked) { color: #1a1000; background: var(--gold-dim); }

/* ---------- icons, badges, chips, roles ---------- */
.ico { width: 36px; height: 36px; flex: none; vertical-align: middle; border: 1px solid #000; border-radius: 4px; box-shadow: 0 0 0 1px #6b5530; }
.ico.sm { width: 24px; height: 24px; }
.ico.xs { width: 18px; height: 18px; margin-right: 4px; }
.badge { display: inline-block; white-space: nowrap; padding: 1px 7px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 3px; }
.badge.main { color: #1a1000; background: linear-gradient(#ffe169, #c99400); border-color: #000; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 3px 10px 3px 3px; background: var(--tile); border: 1px solid var(--line); border-radius: 4px; }
.chip b { color: var(--pc, var(--gold)); }
.chip.zero { border: 1px dashed #8a3a2a; }
.chip.zero b { color: #ff8a70; }
.chip.warn { padding: 3px 10px; color: var(--warn); border: 1px dashed #8a6400; }
.role { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.role svg { width: 14px; height: 14px; fill: currentColor; }
.role-tank { color: var(--tank); }
.role-heal { color: var(--heal); }
.role-dps { color: var(--dps); }

/* ---------- characters page ---------- */
.chars-layout { display: grid; gap: 20px; }
@media (min-width: 900px) {
  .chars-layout { grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
  .plan { position: sticky; top: 76px; }
}
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.title-row h2 { margin: 0; }
.hint { color: var(--muted); }
.plan { padding: 16px; }
.plan h3 { margin: 8px 0 4px; color: var(--muted); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.plan .big { margin: 0; color: var(--gold); font: 700 20px var(--display); }
.glist { margin: 0; padding: 0; list-style: none; }

.plates { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.plate {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "icon head edit" "icon specs specs" "note note note";
  align-items: center; gap: 4px 12px;
  min-height: 96px; padding: 10px 12px;
  background: linear-gradient(90deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-left: 4px solid var(--cc); border-radius: 6px;
  box-shadow: inset 0 0 0 1px #000, 0 6px 18px #000a;
}
.plate.has-rail { grid-template-columns: 44px auto minmax(0, 1fr) auto; grid-template-areas: "rail icon head edit" "rail icon specs specs"; padding-left: 4px; }
.plate.main { background: linear-gradient(90deg, #2a1f0d, var(--panel2)); box-shadow: inset 0 0 0 1px #000, 0 0 0 1px #8a6a2e, 0 6px 18px #000a; }
.plate.incomplete { border-style: dashed; border-color: #c98a00; border-left-style: solid; }
.rail { grid-area: rail; display: grid; gap: 4px; }
.rail button { width: 44px; height: 44px; color: var(--gold-dim); background: var(--tile); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.rail button:hover:not(:disabled) { color: var(--gold); border-color: var(--gold-dim); }
.rail button:disabled { opacity: .3; cursor: default; }
.pico { grid-area: icon; width: 56px; height: 56px; align-self: start; box-shadow: 0 0 0 2px var(--cc); }
.phead { grid-area: head; min-width: 0; }
.ptitle { display: inline; margin-left: 6px; color: var(--cc); font-size: 19px; overflow-wrap: break-word; }
.psub { margin: 2px 0 0; color: var(--muted); }
.noteflag { color: var(--gold-dim); }
.pspecs { grid-area: specs; display: flex; flex-wrap: wrap; gap: 6px; }
.pspecs:empty { display: none; }
.pspecs .break { flex-basis: 100%; height: 0; }
.prof { display: inline-flex; align-items: center; color: var(--muted); font-size: 15px; margin-right: 6px; }
.hero-profs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 14px; }
.spec { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 2px; font-size: 15px; background: var(--tile); border: 1px solid var(--line); border-radius: 4px; }
.spec small { margin-right: 2px; color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.plate .note { grid-area: note; margin: 4px 0 0; color: var(--muted); font-style: italic; }
.pedit { grid-area: edit; align-self: start; }
.pen { display: none; font-size: 18px; }

.slot {
  display: grid; place-items: center; gap: 4px; width: 100%; min-height: 72px; margin-top: 10px; padding: 14px;
  color: var(--gold-dim); font-size: 16px; font-weight: 700;
  background: none; border: 2px dashed var(--line); border-radius: 6px; cursor: pointer;
}
.slot:hover { color: var(--gold); border-color: var(--gold-dim); }
.slot.big { min-height: 180px; font-size: 22px; }
.slot small { color: var(--muted); font: 16px 'Crimson Pro', Georgia, serif; }

/* ---------- dialog ---------- */
dialog {
  width: min(720px, calc(100vw - 32px)); max-height: 90dvh; padding: 0;
  color: var(--text); overflow: auto; overscroll-behavior: contain;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--gold-dim); border-top: 2px solid var(--gold); border-radius: 8px;
  box-shadow: 0 20px 60px #000;
}
dialog::backdrop { background: #000b; }
.dlg-top, dialog > .dlg-head { position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--line); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; }
.dlg-head h2 { flex: 1; margin: 0; font-size: 20px; }
.dlg-head span { flex: 1; }
.dlg-preview { padding: 0 12px 12px; }
.dlg-preview .plate { min-height: 80px; }
.dlg-body { padding: 8px 16px 16px; }
.dlg-foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel2); border-top: 1px solid var(--line);
}
.dlg-foot .muted { margin-right: auto; }

.step { border-bottom: 1px solid var(--line); scroll-margin-top: 190px; }
.step > summary { display: flex; align-items: center; gap: 12px; min-height: 56px; cursor: pointer; list-style: none; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary::after { content: '▸'; color: var(--gold-dim); }
.step[open] > summary::after { content: '▾'; }
.stepnum { display: grid; place-items: center; flex: none; width: 28px; height: 28px; color: var(--gold); font: 700 14px var(--display); border: 1px solid var(--gold-dim); border-radius: 50%; }
.steplabel { flex: 1; color: var(--gold); font-size: 16px; }
.stepval { color: var(--muted); text-align: right; }
.ok { color: var(--heal); }
.stepbody { padding: 0 0 16px; }

/* ---------- pickers (radio tiles) ---------- */
.pickset { margin: 0 0 14px; padding: 0; border: 0; }
.pickset legend { display: flex; align-items: center; margin-bottom: 6px; padding: 0; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.pickset.alliance legend { color: #8ab4ff; }
.pickset.horde legend { color: #ff8a8a; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pick {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px; padding: 8px 4px;
  color: var(--pc, var(--text)); font-size: 14px; line-height: 1.15; text-align: center;
  background: var(--tile); border: 1px solid #33271a; border-radius: 5px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.pick span { overflow-wrap: break-word; hyphens: auto; }
.pick:hover { border-color: var(--gold-dim); box-shadow: 0 0 8px #ffd10033; }
.pick:has(input:checked) { background: #1f170c; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 14px #ffd10066; }
.pick.dim { opacity: .4; filter: grayscale(1); }
.pick.dim:hover { opacity: .75; }
.pick:has(input:disabled) { opacity: .3; filter: grayscale(1); cursor: not-allowed; }
.pick .tag { position: absolute; top: -9px; right: -4px; padding: 0 6px; color: #0b0805; font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--heal); border-radius: 8px; }
.pick.pair { border-color: #3f8f4f; }
.sublabel { margin: 10px 0 6px; color: var(--muted); font-size: 14px; font-style: italic; }
.hint-box { margin: 0 0 8px; padding: 8px 12px; background: #1f170c; border-left: 3px solid var(--gold-dim); border-radius: 0 4px 4px 0; }
.hint-box.good { border-left-color: var(--heal); }
.specs { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.specs .pick { flex-direction: row; justify-content: flex-start; gap: 8px; padding: 6px 8px; text-align: left; }
.specs .pick .ico { width: 28px; height: 28px; }
.specs .pick .role { margin-left: auto; }

/* ---------- guild ---------- */
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.cards2 .panel { padding: 20px; }
.cards2 h3 { margin-bottom: 6px; color: var(--gold); }
.guild-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.switcher { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 14px; color: var(--gold); font-size: 20px; font-weight: 700; background: var(--tile); border: 1px solid var(--gold-dim); border-radius: 4px; }
.gmeta { display: inline-flex; align-items: center; }
.gactions { display: flex; gap: 8px; margin-left: auto; }
.quiet { padding: 24px; text-align: center; }
.quiet h3 { color: var(--gold); }

.ready { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; padding: 16px; margin-bottom: 8px; }
.ready h2 { margin: 0; font-size: 18px; }
.ready h3 { margin: 0 0 6px; color: var(--muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.ready .big { margin: 0 0 6px; color: var(--gold); font: 700 28px var(--display); }
progress { width: 100%; height: 10px; appearance: none; background: #070504; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
progress::-webkit-progress-bar { background: #070504; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #a8740a, var(--gold)); }
progress::-moz-progress-bar { background: linear-gradient(90deg, #a8740a, var(--gold)); }
.rolebar { display: flex; gap: 2px; margin-bottom: 6px; border-radius: 4px; overflow: hidden; }
.rolebar span { display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex-grow: var(--n); min-width: max-content; padding: 4px 8px; color: #0b0805; font-weight: 600; }
.rolebar svg { width: 13px; height: 13px; fill: currentColor; }
.rolebar .tank { background: var(--tank); }
.rolebar .heal { background: var(--heal); }
.rolebar .dps { background: var(--dps); }
.rolebar .zero { color: var(--muted); background: none; border: 1px dashed var(--line); }
.facrow { display: flex; align-items: center; gap: 4px; margin: 0 0 4px; }
.facrow b { margin-left: auto; color: var(--gold); }
.gaps { margin: 10px 0 0; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0; }
.controls input[type="search"] { flex: 1 1 180px; width: auto; }

.member { margin-bottom: 8px; border-left: 4px solid var(--cc); }
.member.me { border-color: var(--gold-dim); border-left-color: var(--cc); box-shadow: inset 0 0 0 1px #000, 0 0 0 1px #8a6a2e, 0 6px 18px #000a; }
.member > summary {
  display: grid; grid-template-columns: 180px minmax(0, 1fr) 110px 150px; grid-template-areas: "name main role alts";
  align-items: center; gap: 4px 12px; min-height: 56px; padding: 4px 12px;
  list-style: none; cursor: pointer;
}
.member > summary::-webkit-details-marker { display: none; }
.mname { grid-area: name; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mmain { grid-area: main; display: flex; align-items: center; gap: 8px; min-width: 0; }
.mmain b { color: var(--cc); }
.mrole { grid-area: role; }
.malts { grid-area: alts; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; justify-content: flex-end; }
.mbody { display: grid; gap: 10px; justify-items: start; padding: 4px 12px 12px; }
.mbody .plates { width: 100%; }
.missing { margin-top: 16px; padding: 16px; border-style: dashed; }
.missing h3 { margin-bottom: 6px; color: var(--gold-dim); font-size: 16px; }

/* join requests: badge, the leader's request list, my own waiting requests */
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 4px; padding: 0 6px; color: #1a1000; font: 700 13px/1 'Crimson Pro', Georgia, serif; background: var(--gold); border-radius: 999px; vertical-align: middle; }
.requests { margin-bottom: 16px; padding: 14px 16px 6px; border-color: var(--gold-dim); }
.requests h3 { margin: 0 0 8px; color: var(--gold); }
.req { display: grid; grid-template-columns: 180px minmax(0, 1fr) auto; grid-template-areas: "name main actions"; align-items: center; gap: 6px 12px; padding: 8px 0 8px 12px; border-top: 1px solid var(--line); border-left: 4px solid var(--cc); }
.req .mmain { flex-wrap: wrap; }
.ractions { grid-area: actions; display: flex; gap: 8px; }
.waiting { margin-bottom: 16px; padding: 14px 16px; }
.waiting h3 { margin: 0 0 4px; color: var(--gold-dim); font-size: 16px; }
.waiting li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }

.classgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.classcard { overflow: hidden; }
.classcard h3 { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--cc); font-size: 16px; background: linear-gradient(90deg, color-mix(in srgb, var(--cc) 22%, transparent), transparent); border-bottom: 2px solid var(--cc); }
.classcard h3 b { margin-left: auto; }
.classcard ul { display: grid; gap: 6px; margin: 0; padding: 10px 12px; list-style: none; }
.classcard li { display: flex; align-items: center; gap: 8px; }
.classcard li small { margin-left: auto; }
.classcard > p { margin: 0; padding: 10px 12px; }

/* dialogs: invite / join / share */
.code { margin: 12px 0; padding: 12px; color: var(--gold); font-size: 28px; font-weight: 700; letter-spacing: .12em; text-align: center; border: 1px dashed var(--gold-dim); border-radius: 6px; user-select: all; }
.okline { color: var(--heal); font-weight: 600; }
.joinform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.joinform .field { flex: 1 1 240px; }
.gcard { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0; padding: 14px; }
.gcard > div { flex: 1 1 200px; }
.gcard p { flex-basis: 100%; margin: 0; }
.alert { margin: 16px 0; padding: 10px 12px; color: var(--danger); border: 1px solid #7a2a24; border-radius: 4px; background: #2a0d0b; }
.label { margin: 14px 0 6px; color: var(--gold); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.discord-preview { margin: 0; padding: 12px; color: #dbdee1; font: 14px/1.45 system-ui, sans-serif; white-space: pre-wrap; word-break: break-all; background: #1e1f22; border-left: 4px solid #5865F2; border-radius: 4px; }
.linkbox { font-size: 14px !important; }

/* ---------- toast ---------- */
.toast-box {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 16px;
  background: linear-gradient(var(--panel), var(--panel2)); border: 1px solid var(--gold-dim); border-radius: 6px;
  box-shadow: 0 10px 30px #000c;
}
.toast-box button { min-height: 44px; padding: 0 14px; color: var(--gold); font: 600 14px var(--display); background: none; border: 1px solid var(--gold-dim); border-radius: 4px; cursor: pointer; }

/* ---------- shared sheet ---------- */
.sheet { max-width: 860px; margin: 20px auto 0; }
.banner { position: relative; margin-bottom: 20px; padding: 28px 24px; overflow: hidden; background: linear-gradient(135deg, #2a1f0d, var(--panel2)); border: 1px solid var(--line); border-radius: 8px; }
.fac-horde .banner { background: linear-gradient(135deg, #4a0e0e, #160807); border-color: #7a1f1f; }
.fac-alliance .banner { background: linear-gradient(135deg, #0f2550, #070b16); border-color: #23458a; }
.banner .crest { position: absolute; top: 50%; right: -20px; width: 220px; height: 220px; opacity: .1; transform: translateY(-50%); border: 0; border-radius: 50%; box-shadow: none; }
.banner .sub { position: relative; margin: 6px 0 0; color: var(--gold-dim); }
.sheet-title { position: relative; font-size: clamp(24px, 5vw, 38px); }
.hero { position: relative; padding: 20px; border-left: 4px solid var(--cc); }
.hero-top { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.hico { width: 96px; height: 96px; box-shadow: 0 0 0 2px var(--cc); }
.hero .ptitle { display: block; margin: 4px 0 0; font-size: 28px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { display: grid; justify-items: center; gap: 4px; padding: 12px 8px; text-align: center; background: var(--tile); border: 1px solid var(--line); border-radius: 6px; }
.tile small { color: var(--muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.tile .ico { width: 40px; height: 40px; }
.tile b { hyphens: auto; overflow-wrap: break-word; }
.tile.empty b { color: var(--muted); }
.hero .note { margin: 14px 0 0; color: var(--muted); font-style: italic; }
.num, .alts > .plate::before {
  position: absolute; top: -12px; left: -12px; z-index: 1;
  display: grid; place-items: center; width: 30px; height: 30px;
  color: #1a1000; font: 700 15px var(--display); background: linear-gradient(#ffe169, #c99400); border: 1px solid #000; border-radius: 50%;
}
.then { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--gold-dim); font-family: var(--display); }
.then::before, .then::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-dim), transparent); }
.alts { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); counter-reset: n 1; }
.alts > .plate { position: relative; }
.alts > .plate::before { counter-increment: n; content: counter(n); }
.sheet-cta { margin: 24px 0; }
.sheet .muted.center { padding: 24px; }

.ruleset { display: inline-flex; align-items: center; }
.loading { padding: 32px 0; text-align: center; }
.seg label small { margin-left: 4px; font-size: 11px; font-weight: 400; }

/* ---------- login ---------- */
.login { max-width: 460px; margin: 8vh auto; padding: 28px; text-align: center; }
.login h1 { font-size: 24px; margin-bottom: 16px; }
.login .btn { width: 100%; margin: 20px 0 12px; text-decoration: none; }
.invite-ctx { margin-bottom: 16px; padding: 10px 12px; color: var(--gold); background: #2a1f0d; border: 1px solid var(--gold-dim); border-radius: 4px; }

footer { margin: 32px 0 8px; color: #9a8c72; font-size: 14px; text-align: center; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .plate.flash { animation: flash .6s ease-out; }
  @keyframes flash { from { box-shadow: 0 0 0 2px var(--gold), 0 0 24px #ffd10088; } }
  dialog[open] { animation: rise .18s ease-out; }
  @keyframes rise { from { opacity: 0; translate: 0 8px; } }
}

@media (forced-colors: active) {
  h1, .brand, .sheet-title { background: none; color: CanvasText; }
}

/* ---------- mobile ---------- */
@media (max-width: 600px) {
  .top { grid-template-areas: "title title" "sub tools"; }
  .top .date, .uname, .lname { display: none; }
  .account { padding-right: 4px; }
  .tabs button { flex: 1; padding: 0 8px; }

  .plate.has-rail { grid-template-areas: "rail icon head edit" "rail specs specs specs"; }
  .pico { width: 48px; height: 48px; }
  .ptitle { display: block; margin: 2px 0 0; }
  .pedit .lbl { display: none; }
  .pedit .pen { display: inline; }
  .pedit:has(.pen) { width: 44px; padding: 0; }
  .plate.has-rail.incomplete { grid-template-areas: "rail icon head head" "rail specs specs specs" "rail edit edit edit"; }
  .plate.incomplete .pedit { justify-self: start; }
  .dlg-preview .pspecs { display: none; }

  dialog { inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .dlg-foot .btn { flex: 1; min-height: 48px; }
  .specs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .specs .pick { flex-direction: column; justify-content: center; text-align: center; }
  .specs .pick .role { margin: 0; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .guild-head .sw { flex: 1 1 100%; }
  .gactions { margin-left: 0; }
  .member > summary { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name role" "main alts"; padding: 8px 12px; }
  .req { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "main" "actions"; }
  .ractions .btn { flex: 1; }
  .tiles { gap: 6px; }
  .hero-top { align-items: flex-start; }
  .hico { width: 64px; height: 64px; }
}
