/* Inter (SIL Open Font License), latin subset, all weights in one file */
@font-face {
  font-family: "Inter";
  src: url("inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --surface: #0d1117;
  --panel: #161b22;
  --raised: #1c232c;
  --line: #2b323b;
  --ink: #e6edf3;
  --muted: #9198a1;
  --gold: #f0c04a;
  --bar: #338ced;
  --good: #3fb950;
  --bad: #f47067;
  --warn: #d9a218;
  --easy: #c5b5c5;
  --medium: #fefba3;
  --hard: #fefefe;
  --elite: #fefe58;
  --master: #69d6fe;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "cv11", "ss01";
}

.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Header and tabs */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px 0;
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
h1 { font: 700 22px/1.2 var(--sans); margin: 0; color: var(--gold); letter-spacing: -.02em; }
#tabs { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; }
#tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent;
  color: var(--muted); font: 500 14.5px var(--sans); padding: 6px 14px 10px; cursor: pointer; white-space: nowrap;
}
#tabs button:hover { color: var(--ink); }
#tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }
#tabs .count {
  font: 600 11px var(--sans); background: var(--warn); color: #14110a;
  border-radius: 9px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px;
}

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }

/* Panels */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); align-items: start; }
.panel {
  grid-column: span 6; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; min-width: 0;
}
.panel.wide { grid-column: span 12; }
.panel.third { grid-column: span 4; }
.panel.two-thirds { grid-column: span 8; }
.panel h2 { font: 600 16px/1.3 var(--sans); margin: 0 0 2px; letter-spacing: -.01em; }
.panel .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
@media (max-width: 980px) { .panel, .panel.third, .panel.two-thirds { grid-column: span 12; } }

/* Stat tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile .value { font: 700 28px/1.25 var(--sans); letter-spacing: -.02em; }
.tile .note { color: var(--muted); font-size: 12px; }
.tile.link { cursor: pointer; }
.tile.link:hover { border-color: var(--gold); }
.up { color: var(--good); } .down { color: var(--bad); }

/* Horizontal bars */
.bars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 7px 10px; align-items: center; }
.bars .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.bars .name.first { color: var(--gold); }
.bars .track { display: flex; gap: 2px; height: 14px; }
.bars .seg { height: 100%; background: var(--bar); min-width: 2px; }
.bars .seg:last-child { border-radius: 0 4px 4px 0; }
.bars .value { text-align: right; font-variant-numeric: tabular-nums; }
.seg.t0 { background: var(--easy); } .seg.t1 { background: var(--medium); } .seg.t2 { background: var(--hard); }
.seg.t3 { background: var(--elite); } .seg.t4 { background: var(--master); }
.clickable { cursor: pointer; } .clickable:hover { text-decoration: underline; }

/* Columns over time */
.columns { display: flex; align-items: flex-end; gap: 2px; height: 130px; border-bottom: 1px solid var(--line); }
.columns .col { flex: 1; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 1px; }
.columns .col.empty { background: var(--line); }
.columns .col:hover, .bars .seg:hover { filter: brightness(1.25); }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend img, .tier-head img { width: 18px; height: 18px; object-fit: contain; }

.tiers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; }
@media (max-width: 1100px) { .tiers { grid-template-columns: repeat(2, 1fr); } }
.tier-head { display: flex; align-items: center; gap: 8px; font: 600 14.5px var(--sans); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 8px; }

/* Feeds */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--muted); font-size: 12px; padding-top: 1px; white-space: nowrap; }
.feed .detail { color: var(--muted); font-size: 12.5px; }
.day-head { font: 600 13.5px var(--sans); color: var(--gold); margin: 14px 0 2px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 9px; padding: 0 7px;
  border: 1px solid var(--line); color: var(--muted); vertical-align: 1px; white-space: nowrap;
}
.badge.join { color: var(--good); border-color: #23532c; }
.badge.leave { color: var(--bad); border-color: #6b2b27; }
.badge.due { color: var(--warn); border-color: #5f4a12; }
.badge.pet { color: var(--gold); border-color: #5f4a12; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
input[type="search"], select {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font: inherit; min-width: 220px;
}
select { min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--bar); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 16px;
  padding: 5px 12px; font: inherit; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--raised); color: var(--ink); border-color: var(--gold); }
.more { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 7px 14px; font: inherit; cursor: pointer; margin-top: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.row:hover { background: var(--raised); cursor: pointer; }
td .was { color: var(--muted); font-size: 12px; }
td.notes { max-width: 320px; color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); padding: 14px 0; }

/* Member dialog */
dialog {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 60px); padding: 22px 24px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { font: 700 24px/1.2 var(--sans); letter-spacing: -.02em; margin: 0 0 4px; color: var(--gold); }
dialog h3 { font: 600 15px var(--sans); margin: 18px 0 6px; }
dialog .close { float: right; background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin-top: 12px; }
.facts div span { display: block; color: var(--muted); font-size: 12px; }
.clue-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.clue-row span { display: inline-flex; align-items: center; gap: 6px; }
.clue-row img { width: 20px; height: 20px; object-fit: contain; }

#tip {
  position: fixed; z-index: 20; pointer-events: none; background: #010409; border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 10px; font-size: 12.5px; white-space: pre-line; max-width: 280px;
}

/* Login and refusal */
.gate { max-width: 460px; margin: 12vh auto 0; text-align: center; }
.gate h2 { font: 700 22px/1.3 var(--sans); margin: 0 0 8px; }
.button {
  display: inline-block; margin-top: 14px; background: #5865f2; color: #fff; font-weight: 600;
  border-radius: 8px; padding: 10px 20px; text-decoration: none;
}
.button:hover { background: #4752c4; }
#stamp a { color: var(--muted); }
