/* Guild Hall: faction-neutral, dark slate + muted bronze. Class colors carry identity. */
:root {
  --bg: #111317;
  --bg-2: #161920;
  --panel: #1b1f26;
  --panel-2: #212630;
  --line: #2c323c;
  --line-2: #3a414d;
  --text: #e7e2d6;
  --muted: #9b968b;
  --gold: #c9a45c;
  --gold-2: #e2c27f;
  --gold-dim: #8a7143;
  --arcane: #86b6c9;
  --ok: #82b06f;
  --warn: #d6a24c;
  --danger: #cf6a5c;
  --radius: 10px;
  --display: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

/* Class colors (slightly lifted where the official shade is too dark on slate). */
.cls-0 { --cc: #b9b3a6; }
.cls-1 { --cc: #c69b6d; }  .cls-2 { --cc: #f48cba; }  .cls-3 { --cc: #aad372; }
.cls-4 { --cc: #fff468; }  .cls-5 { --cc: #f2f2f2; }  .cls-6 { --cc: #e0485f; }
.cls-7 { --cc: #3b8fe8; }  .cls-8 { --cc: #3fc7eb; }  .cls-9 { --cc: #8788ee; }
.cls-10 { --cc: #00ff98; } .cls-11 { --cc: #ff7c0a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--body);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 12% -10%, rgba(134, 182, 201, .07), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 164, 92, .06), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 6px);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.2rem; color: var(--gold-2); margin-bottom: .75rem; }
h3 { font-size: .8rem; font-family: var(--body); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: .25rem 0 .6rem; }
code { font-size: .9em; background: var(--bg-2); padding: .1em .35em; border-radius: 4px; border: 1px solid var(--line); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.warn { color: var(--warn); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico.big { width: 40px; height: 40px; color: var(--gold-dim); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Shell ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 212px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1rem;
  padding: 1.1rem .8rem;
  background: linear-gradient(180deg, rgba(27, 31, 38, .92), rgba(17, 19, 23, .92));
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .2rem .5rem .8rem; border-bottom: 1px solid var(--line);
  font-family: var(--display); font-size: 1.25rem; color: var(--gold-2); letter-spacing: .04em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: 7px; color: var(--muted);
  border-left: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, .035); text-decoration: none; }
.nav a.active { color: var(--text); background: rgba(201, 164, 92, .09); border-left-color: var(--gold); }
.nav a.active .ico { color: var(--gold); }
.signout { margin-top: auto; padding: 0 .65rem; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
button.link:hover { color: var(--text); }

.main { padding: 1.6rem 2rem 1.2rem; max-width: 1480px; width: 100%; }
.footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }

/* ---- Controls -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 36px; padding: .45rem .95rem; border-radius: 8px; cursor: pointer;
  font: 600 .88rem var(--body); letter-spacing: .01em; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-2);
  list-style: none; user-select: none;
}
.btn:hover { border-color: var(--gold-dim); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { color: #1b160c; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: #a8864a; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: rgba(207, 106, 92, .45); background: transparent; }
.btn.busy { opacity: .7; cursor: progress; }
summary.btn::-webkit-details-marker { display: none; }
input, select {
  min-height: 36px; padding: .4rem .6rem; border-radius: 7px; font: inherit; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line-2);
}
input:focus, select:focus { border-color: var(--gold-dim); outline: none; box-shadow: 0 0 0 3px rgba(201, 164, 92, .15); }
label { font-size: .8rem; color: var(--muted); }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--line-2); background: var(--panel); }
.flash.ok { border-color: rgba(130, 176, 111, .45); }
.flash.error { border-color: rgba(207, 106, 92, .5); background: rgba(207, 106, 92, .07); }

.pill { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font-size: .74rem; line-height: 1.5;
  border: 1px solid var(--line-2); color: var(--text); background: rgba(255, 255, 255, .03); white-space: nowrap; }
.pill.dim { color: var(--muted); }
.pill.faction-alliance { color: #9fbbe0; border-color: rgba(120, 155, 205, .4); }
.pill.faction-horde { color: #e0958a; border-color: rgba(205, 110, 95, .4); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); vertical-align: 1px; }
.dot.state-ok { background: var(--ok); }
.dot.state-new { background: var(--arcane); }
.dot.state-error, .dot.state-mismatch, .dot.state-not_found { background: var(--danger); }

progress { appearance: none; -webkit-appearance: none; width: 100%; height: 4px; border: 0; border-radius: 4px;
  background: rgba(255, 255, 255, .07); overflow: hidden; display: block; }
progress::-webkit-progress-bar { background: rgba(255, 255, 255, .07); border-radius: 4px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--gold-dim), var(--gold-2)); border-radius: 4px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--gold-dim), var(--gold-2)); border-radius: 4px; }

.panel { background: linear-gradient(180deg, var(--panel), rgba(27, 31, 38, .85)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; }

/* ---- Page head / toolbar ---------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head p { margin: .2rem 0 0; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.toolbar form { margin: 0; }
.sort { display: flex; align-items: center; gap: .45rem; }
.add { position: relative; }
.add[open] > summary { box-shadow: 0 0 0 3px rgba(201, 164, 92, .18); }
.add-form {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(560px, calc(100vw - 32px));
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem;
  padding: 1rem; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line-2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
}
.add-form .field { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 150px; }
.add-form .field.narrow { flex: 0 0 80px; }
.add-form .hint { flex-basis: 100%; margin: 0; font-size: .78rem; color: var(--muted); }

/* ---- Roster rows ------------------------------------------------------------ */
.roster-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px 6px; }
.roster { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 1000px; }
.row {
  display: grid; align-items: center; gap: 14px;
  grid-template-columns: 22px 52px minmax(170px, 1.3fr) 56px minmax(120px, .75fr) minmax(280px, 2.4fr) minmax(165px, 1fr);
  padding: 10px 14px 10px 8px; border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--cc) 7%, var(--panel)) 0%, var(--panel) 40%);
  border: 1px solid var(--line); border-left: 3px solid var(--cc);
  transition: border-color .15s, background-color .15s;
}
.row:hover { border-color: var(--line-2); border-left-color: var(--cc); }
.handle { display: grid; place-items: center; width: 22px; height: 40px; padding: 0; border: 0; border-radius: 5px;
  color: var(--line-2); background: none; cursor: grab; touch-action: none; }
.handle:hover, .handle:focus-visible { color: var(--gold); }
.handle:active { cursor: grabbing; }
.sorted .handle { visibility: hidden; }
.portrait { display: block; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; flex: none;
  border: 2px solid color-mix(in srgb, var(--cc) 60%, transparent); background: var(--bg-2); }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait .initials { display: grid; place-items: center; height: 100%; font-family: var(--display); color: var(--cc); font-size: 1.1rem; }
.who { min-width: 0; }
.who .name { display: block; font-family: var(--display); font-size: 1.1rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .name:hover { color: var(--gold-2); }
.sub { font-size: .85rem; color: var(--muted); }
.cls { color: var(--cc); }
.guild { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.lvl-num { font-family: var(--display); font-size: 1.6rem; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.lvl-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.profs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 6px 12px; }
.prof { min-width: 0; }
.prof-name { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prof .prof-name { display: inline-block; max-width: calc(100% - 52px); vertical-align: bottom; }
.prof-val { float: right; font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text); }
.prof-val small { color: var(--muted); }
.prof progress { margin-top: 3px; clear: both; }
.prof.secondary .prof-name { color: var(--muted); }
.prof.secondary progress::-webkit-progress-value { background: var(--line-2); }
.prof.secondary progress::-moz-progress-bar { background: var(--line-2); }
.fresh { font-size: .8rem; line-height: 1.45; }
.save-note { min-height: 1.2em; margin: .5rem 0 0; }

/* SortableJS states */
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 10px 28px rgba(0, 0, 0, .45); }
.sortable-drag { opacity: .95; }

.empty { text-align: center; padding: 3.5rem 1rem; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty h2 { margin: .8rem 0 .3rem; }

/* ---- Character detail -------------------------------------------------------- */
.crumbs { display: flex; align-items: center; gap: .5rem; font-size: .88rem; margin-bottom: 1rem; color: var(--muted); }
.crumbs .sep { color: var(--line-2); }
.crumbs [aria-current] { color: var(--text); }
.hero { position: relative; overflow: hidden; padding: 1.4rem 1.5rem; margin-bottom: 1rem; border-radius: var(--radius);
  border: 1px solid var(--line); border-top: 3px solid var(--cc);
  background: radial-gradient(600px 300px at 85% 30%, color-mix(in srgb, var(--cc) 12%, transparent), transparent 70%), var(--panel); }
.hero .render { position: absolute; right: -40px; top: -30px; height: 150%; max-width: 55%; object-fit: cover; object-position: top;
  opacity: .5; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%); mask-image: linear-gradient(90deg, transparent, #000 45%); }
.hero-id { position: relative; display: flex; align-items: center; gap: 1.1rem; }
.portrait.lg { width: 84px; height: 84px; border-radius: 12px; }
.hero .name { font-size: 2.1rem; line-height: 1.15; color: var(--cc); }
.hero .sub { font-size: 1rem; margin: .15rem 0 .45rem; color: var(--text); }
.hero .tags { margin: 0; }
.stats { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, max-content)); gap: .4rem 2.4rem; margin: 1.3rem 0 0; }
.stats div { min-width: 0; }
.stats dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.stats dd { margin: .1rem 0 0; font-family: var(--display); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stats dd small { font-family: var(--body); font-size: .75rem; color: var(--muted); }
.stats .guild-name { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18rem; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1rem; align-items: start; }
.detail-grid.even { grid-template-columns: 1fr 1fr; }
.prof-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.prof-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.prof-line { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: 4px; }
.prof-detail .prof-name { font-size: .95rem; }
.prof-detail .prof-val { float: none; font-size: .95rem; }
.prof-detail progress { height: 6px; }
.recipes { margin-top: .35rem; font-size: .82rem; }
.recipes summary { cursor: pointer; color: var(--muted); }
.recipes summary:hover { color: var(--text); }
.recipes ul { margin: .4rem 0 0; padding-left: 1.1rem; columns: 2 200px; column-gap: 1.5rem; color: var(--text); }
.recipes li { break-inside: avoid; margin-bottom: 2px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0 0 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.danger-zone { margin-top: 1rem; background: transparent; border-style: dashed; }
.danger-zone form { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 0; }
.placeholder { text-align: center; padding: 2.5rem 1.5rem; max-width: 640px; }
.placeholder p { margin: .8rem auto 0; max-width: 46ch; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.2rem; }
.prose h2:first-child { margin-top: 0; }
.prose p { color: #cfc9bc; }

/* ---- Login ------------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: grid; place-content: center; padding: 16px; }
.login-card { width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: .55rem; text-align: center;
  padding: 2rem 1.6rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.login-card img { margin: 0 auto .2rem; }
.login-card h1 { color: var(--gold-2); }
.login-card p { margin: 0 0 .6rem; }
.login-card label { text-align: left; }
.login-card .btn { margin-top: .4rem; }
.login-foot { text-align: center; font-size: .8rem; }

/* ---- Responsive ----------------------------------------------------------------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: .4rem;
    padding: .5rem 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { border: 0; padding: 0 .4rem 0 0; font-size: 1.05rem; }
  .brand span { display: none; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; flex: 1; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: .4rem .6rem; border-left: 0; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; font-size: .88rem; }
  .nav a.active { border-bottom-color: var(--gold); }
  .signout { margin: 0; padding: 0; }
  .main { padding: 1.2rem 16px; }
  .detail-grid, .detail-grid.even { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  h1 { font-size: 1.5rem; }
  .roster { min-width: 0; }
  .roster-scroll { overflow: visible; margin: 0; padding: 0; }
  .row { grid-template-columns: 20px 48px minmax(0, 1fr) auto; gap: 8px 10px; padding: 10px 12px 12px 6px; }
  .row .portrait { width: 48px; height: 48px; }
  .row .tags { grid-column: 3 / 5; }
  .row .profs { grid-column: 2 / 5; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .row .fresh { grid-column: 2 / 5; display: flex; flex-wrap: wrap; gap: 0 1rem; }
  .page-head { align-items: stretch; }
  .toolbar { width: 100%; position: relative; }
  .add { position: static; }
  .add-form { left: 0; right: 0; width: auto; }
  .hero { padding: 1.1rem; }
  .hero .render { opacity: .28; max-width: 80%; }
  .hero .name { font-size: 1.6rem; }
  .portrait.lg { width: 64px; height: 64px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem 1rem; }
  .prof-cols { grid-template-columns: 1fr; }
}
