:root {
  --bg: #121013;
  --bg-glow: #2a1610;
  --surface: #1b181c;
  --surface-2: #242025;
  --surface-3: #2e2930;
  --border: #3a343c;
  --border-strong: #534a55;
  --text: #efe8e1;
  --muted: #a89d95;
  --faint: #7a706a;
  --accent: #e8743b;
  --accent-strong: #ff8a4c;
  --accent-ink: #1a0d06;
  --gold: #f2b25c;
  --avail: #3f8a68;
  --avail-ink: #e9fff4;
  --pref: #e8743b;
  --pref-ink: #1a0d06;
  --danger: #ef6a5f;
  --ok: #78c995;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Cinzel", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -200px, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
}
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 96px; }
.wrap.wide { max-width: 1180px; }

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 0; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--text); }
.brand h1 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.08em;
  font-size: 28px; margin: 0; color: var(--text);
  text-shadow: 0 0 24px rgba(232, 116, 59, 0.35);
}
.brand span { color: var(--muted); font-size: 14px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.who img { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); }
.who .name { font-weight: 600; }
.who form { margin: 0; }

.hero { padding: 24px 0 8px; }
.hero h2 { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; letter-spacing: 0.02em; }
.hero p { color: var(--muted); margin: 0; max-width: 60ch; }

/* Cards and sections */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-top: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 18px; }
.card .hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.field + .field { margin-top: 16px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.optional { color: var(--faint); font-weight: 400; }
.req { color: var(--accent); }

input[type="text"], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
select:disabled { opacity: 0.5; }
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(232, 116, 59, 0.2); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.counter { font-size: 12px; color: var(--faint); text-align: right; margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); cursor: pointer;
  text-decoration: none; color: var(--text); font-weight: 600;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn.discord:hover { background: #6a75f5; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(239, 106, 95, 0.4); background: transparent; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Segmented choices (radio / checkbox pills) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  font-size: 15px; user-select: none;
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.choices.nums .choice span { min-width: 44px; justify-content: center; padding: 8px 0; }

/* Spec picker */
.spec-row { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 8px; align-items: center; }
.spec-row + .spec-row { margin-top: 10px; }
.rank-badge {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}
.spec-row.filled .rank-badge { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.role-tag { font-size: 12px; color: var(--muted); grid-column: 2 / -1; margin-top: -4px; }
.class-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }

/* Availability grid */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; border: 1px solid var(--border); }
.legend .l-off { background: var(--surface-2); }
.legend .l-av { background: var(--avail); border-color: var(--avail); }
.legend .l-pref { background: var(--pref); border-color: var(--pref); }

.avail-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.avail {
  display: grid; grid-template-columns: minmax(64px, auto) repeat(7, minmax(40px, 1fr)); gap: 4px;
  min-width: 340px; user-select: none;
}
.avail .colhead {
  background: none; border: 0; padding: 6px 0; font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer; border-radius: 6px; min-height: 36px;
}
.avail .colhead:hover { background: var(--surface-2); }
.avail .rowhead { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; justify-content: center; line-height: 1.2; padding-right: 4px; }
.avail .rowhead b { color: var(--text); font-weight: 600; font-size: 13px; }
.avail .cell {
  min-height: 40px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2);
  cursor: pointer; padding: 0; font-size: 12px; font-weight: 700; color: transparent;
  transition: background 0.08s ease;
}
.avail .cell:hover { border-color: var(--border-strong); }
.avail .cell[data-v="1"] { background: var(--avail); border-color: var(--avail); color: var(--avail-ink); }
.avail .cell[data-v="2"] { background: var(--pref); border-color: var(--pref); color: var(--pref-ink); }
.avail .corner { font-size: 11px; color: var(--faint); align-self: end; padding-bottom: 8px; }
.grid-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.grid-tools .tzline { color: var(--muted); font-size: 13px; margin-right: auto; }

/* Loot ranking */
.rank-list { display: grid; gap: 8px; }
.rank-item {
  display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; min-height: 52px; width: 100%;
}
.rank-item:hover { border-color: var(--border-strong); }
.rank-item.ranked { border-color: rgba(232, 116, 59, 0.6); background: rgba(232, 116, 59, 0.08); }
.rank-item.ranked .rank-badge { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rank-item .t { font-weight: 600; }
.rank-item .d { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }

/* Checkbox row */
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check + .field { margin-top: 14px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

/* Save bar */
.savebar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 20px;
  background: rgba(18, 16, 19, 0.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding: 12px 0;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.status { font-size: 14px; color: var(--muted); flex: 1; min-width: 180px; }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }

.notice {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; margin-top: 16px;
}
.notice.err { border-color: rgba(239, 106, 95, 0.5); color: var(--danger); }
.notice.info { border-color: rgba(242, 178, 92, 0.4); }

.login-card { text-align: center; padding: 32px 20px; }
.login-card .btn { display: flex; width: fit-content; margin: 0 auto; }
.login-card ul { text-align: left; display: inline-block; color: var(--muted); font-size: 14px; margin: 16px 0 20px; padding-left: 20px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

@media (max-width: 560px) {
  .brand h1 { font-size: 24px; }
  .card { padding: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .spec-row { grid-template-columns: 30px 1fr; }
  .spec-row select:last-of-type { grid-column: 2; }
  .avail { grid-template-columns: 52px repeat(7, minmax(30px, 1fr)); gap: 3px; min-width: 0; }
  .avail .rowhead b { font-size: 12px; white-space: nowrap; }
  .avail .rowhead span { font-size: 10px; white-space: nowrap; }
  .avail .colhead { font-size: 12px; }
  .choices.nums { gap: 6px; }
  .choices.nums .choice span { min-width: 38px; }
}

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

/* ================= Officer dashboard ================= */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 0 4px; }
.dash-head h2 { font-family: var(--font-display); font-size: 24px; margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.filters label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.filters select { width: auto; min-height: 36px; padding: 6px 30px 6px 10px; font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .k { color: var(--muted); font-size: 13px; margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-grid > .card { margin-top: 16px; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

/* Heatmap */
.heat { display: grid; grid-template-columns: 70px repeat(7, minmax(44px, 1fr)); gap: 3px; min-width: 420px; }
.heat .hh { font-size: 13px; font-weight: 600; text-align: center; padding: 4px 0; }
.heat .hr { font-size: 12px; color: var(--muted); display: flex; align-items: center; }
.heat .hc {
  min-height: 42px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; padding: 0;
  background: color-mix(in oklab, var(--accent) calc(var(--t) * 100%), var(--surface-2));
  color: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.heat .hc.dark-ink { color: var(--accent-ink); }
.heat .hc:hover, .heat .hc.sel { border-color: var(--gold); }
.heat-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.heat-scale .bar { flex: 0 0 140px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--surface-2), var(--accent)); }
.who-list { margin-top: 12px; font-size: 14px; }
.who-list .grp { margin-top: 6px; }
.who-list .grp b { color: var(--muted); font-weight: 600; margin-right: 6px; }

/* Horizontal bars */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 48px; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { display: block; height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.subhead { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 16px 0 8px; }
.subhead:first-child { margin-top: 0; }

/* Window finder */
.windows { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.windows li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; flex-wrap: wrap; }
.windows li b { font-weight: 600; }
.windows .cnt { font-variant-numeric: tabular-nums; color: var(--muted); }
.windows .cnt strong { color: var(--text); font-size: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; }
table.data td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr.resp-row { cursor: pointer; }
table.data tr.resp-row:hover td { background: var(--surface-2); }
table.data td.num { font-variant-numeric: tabular-nums; text-align: right; }
.person { display: flex; align-items: center; gap: 8px; }
.person img { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); }
.person .u { color: var(--faint); font-size: 12px; }
.detail td { background: var(--surface-2); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 4px 0; }
.detail-grid h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-grid p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.mini { display: grid; grid-template-columns: 34px repeat(7, 18px); gap: 2px; font-size: 10px; color: var(--muted); }
.mini i { width: 18px; height: 14px; border-radius: 3px; background: var(--surface-3); display: block; }
.mini i[data-v="1"] { background: var(--avail); }
.mini i[data-v="2"] { background: var(--pref); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); margin: 0 4px 4px 0; }
.search { max-width: 280px; min-height: 38px !important; padding: 6px 10px !important; }

.officer-list { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.officer-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px; }
.add-officer { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
@media (max-width: 560px) { .add-officer { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .heat { grid-template-columns: 44px repeat(7, minmax(28px, 1fr)); min-width: 0; gap: 2px; }
  .heat .hc { min-height: 36px; font-size: 12px; }
  .heat .hh { font-size: 12px; }
  .heat .hr { font-size: 11px; }
}

/* ================= Icon pickers ================= */
.gicon { width: 22px; height: 22px; border-radius: 4px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); background: var(--surface-3); }
.gicon.lg { width: 36px; height: 36px; border-radius: 6px; }
.choice span .gicon { margin-right: 8px; }
.choices.factions .choice span { min-height: 48px; padding: 8px 16px 8px 10px; font-size: 16px; }
.choices.factions .gicon { width: 30px; height: 30px; }

.picked { display: grid; gap: 8px; margin-bottom: 16px; }
.pick {
  display: grid; grid-template-columns: 30px auto 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); min-height: 56px;
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--cls, var(--border));
}
.pick.empty { grid-template-columns: 30px 1fr; border-style: dashed; border-left-width: 1px; background: transparent; }
.pick .rank-badge { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pick.empty .rank-badge { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.pick-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pick-actions { display: flex; gap: 4px; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }

.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; }
.class-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
}
.class-tile:hover { border-color: var(--cls); }
.class-tile.active { border-color: var(--cls); box-shadow: 0 0 0 1px var(--cls) inset; background: color-mix(in oklab, var(--cls) 12%, var(--surface-2)); }
.tile-count {
  position: absolute; top: 4px; right: 4px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center;
}

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.spec-tile {
  display: flex; align-items: center; gap: 10px; text-align: left; min-height: 52px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); border: 1px solid var(--border);
}
.spec-tile:hover:not(:disabled) { border-color: var(--cls); }
.spec-tile.on { border-color: var(--accent); background: rgba(232, 116, 59, 0.1); }
.spec-tile:disabled { opacity: 0.45; cursor: not-allowed; }
.spec-text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.rank-badge.sm { width: 24px; height: 24px; font-size: 12px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

@media (max-width: 560px) {
  .class-grid { grid-template-columns: repeat(3, 1fr); }
  .spec-grid { grid-template-columns: 1fr; }
}
.spec-cell { display: inline-flex; align-items: center; gap: 8px; }
.bar-row .lbl { display: flex; align-items: center; gap: 8px; }
.bar-row .lbl .gicon { width: 20px; height: 20px; }

/* Guild logo */
.brand { align-items: center; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 18px rgba(232, 116, 59, 0.25); }
.hero-out { text-align: center; }
.hero-out p { margin: 0 auto; }
.hero-logo { width: 112px; height: 112px; border-radius: 24px; margin-bottom: 16px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 40px rgba(232, 116, 59, 0.3); }
@media (max-width: 560px) { .brand-logo { width: 34px; height: 34px; } .brand span { display: none; } }
