@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
/* ============================================================ tokens */
:root {
  --bg: #0e0e10; --surface: #18181b; --surface-2: #1f1f23; --surface-3: #27272e; --surface-hover: #232329;
  --border: rgba(255,255,255,0.08); --border-strong: rgba(255,255,255,0.16);
  --text: #efeff1; --text-2: #adadb8; --text-3: #7f7f8a;
  --accent: #9147ff; --accent-2: #a970ff; --accent-soft: rgba(145,71,255,0.16); --accent-ink: #fff;
  --live: #eb0400; --live-soft: rgba(235,4,0,0.14);
  --good: #0ca30c; --good-soft: rgba(12,163,12,0.16); --warn: #fab219; --warn-soft: rgba(250,178,25,0.16);
  --serious: #ec835a; --crit: #d03b3b; --crit-soft: rgba(208,59,59,0.16);
  --series-1: #9147ff; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-7: #9085e9;
  --role-bc: #e91916; --role-mod: #00ad03; --role-vip: #e005b9; --role-sub: #3987e5; --role-follow: #5f5f6d; --role-new: #e0a100; --role-bot: #6b6b78;
  --lurk: #4fb3bf; --lurk-soft: rgba(79,179,191,0.16); --active: #0ca30c; --idle: #7f7f8a;
  --grid: #2c2c2a; --axis: #383835;
  --radius: 10px; --radius-sm: 6px; --shadow: 0 12px 32px rgba(0,0,0,0.45);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --accent-grad: linear-gradient(135deg, #9d5cff 0%, #6f2ccf 100%);
  --glow: 0 0 0 1px rgba(145,71,255,.22), 0 12px 40px rgba(145,71,255,.16);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f3f5; --surface: #ffffff; --surface-2: #f6f6f8; --surface-3: #ececf0; --surface-hover: #f2f2f5;
  --border: rgba(11,11,11,0.09); --border-strong: rgba(11,11,11,0.18);
  --text: #0e0e10; --text-2: #4f4f5a; --text-3: #7a7a86;
  --accent: #772ce8; --accent-2: #5c16c5; --accent-soft: rgba(119,44,232,0.12);
  --live: #e91916; --live-soft: rgba(233,25,22,0.12);
  --good: #0a8a0a; --good-soft: rgba(10,138,10,0.12); --warn: #c98500; --warn-soft: rgba(201,133,0,0.14);
  --serious: #d9652f; --crit: #c73434; --crit-soft: rgba(199,52,52,0.12);
  --series-1: #772ce8; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-7: #4a3aa7;
  --role-mod: #008a00; --role-vip: #c800a3; --role-sub: #2a78d6; --role-follow: #6f6f7c; --role-new: #b37a00; --role-bot: #7c7c88;
  --lurk: #1f8f9c; --lurk-soft: rgba(31,143,156,0.12); --active: #0a8a0a; --idle: #8a8a96;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --shadow: 0 12px 32px rgba(20,20,40,0.16);
  color-scheme: light;
}

/* ============================================================ base */
* { box-sizing: border-box; }
html, body { height: 100%; }
svg[aria-hidden="true"] { width: 16px; height: 16px; flex: none; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; } h4 { font-size: 13px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.flex { display: flex; align-items: center; gap: 8px; } .flex-1 { flex: 1; min-width: 0; } .wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--accent-2); cursor: pointer; } .link:hover { text-decoration: underline; }
.clickable { cursor: pointer; }
kbd { font: 11px var(--mono); background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--bg); } ::-webkit-scrollbar-track { background: transparent; }

/* ============================================================ layout */
#app { display: grid; grid-template-columns: 228px minmax(0, 1fr); height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #5c16c5); display: grid; place-items: center; color: #fff; flex: none; }
.brand .name { font-weight: 700; font-size: 15px; line-height: 1.1; } .brand .sub { font-size: 11px; color: var(--text-3); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; cursor: pointer; }
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent-2); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .live-dot { margin-left: auto; }
.sidebar .foot { margin-top: auto; padding: 12px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); line-height: 1.4; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar .title { font-weight: 650; font-size: 15px; }
.topbar .crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; min-width: 0; }
.topbar .crumbs .sep { color: var(--text-3); }
.content { flex: 1; overflow: auto; padding: 20px 24px 48px; scroll-behavior: smooth; }
.page { max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .lead { color: var(--text-2); margin-top: 4px; font-size: 13px; }
.menu-btn { display: none; }

/* ============================================================ buttons / inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 500; font-size: 13px; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; } .btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--crit-soft); border-color: transparent; color: var(--crit); } .btn.danger:hover { background: var(--crit); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); } .btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.icon { padding: 6px; } .btn.icon svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.live-btn { background: var(--live); border-color: transparent; color: #fff; }
.input, .select, textarea.input { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; outline: none; min-width: 0; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm, .select.sm { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.input[type=number] { width: 84px; }
.input[type=date], .input[type=time] { color-scheme: inherit; }
.select { appearance: none; -webkit-appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; cursor: pointer; }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.45; }
.search { position: relative; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 30px; width: 100%; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 500; }
label.field > .input, label.field > .select { color: var(--text); font-weight: 400; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.switch { position: relative; display: inline-flex; align-items: center; width: 36px; height: 20px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text-2); }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ============================================================ cards / stats */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card.tight .card-head { padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; }
.grid { display: grid; gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.stat .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .label svg { width: 14px; height: 14px; color: var(--text-3); }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 4px; line-height: 1.15; letter-spacing: -0.02em; }
.stat .sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.stat.accent .value { color: var(--accent-2); }
.stat.good .value { color: var(--good); }
.stat.lurk .value { color: var(--lurk); }
.stat.new .value { color: var(--role-new); }
.hero { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: linear-gradient(120deg, var(--surface) 0%, var(--surface-2) 100%); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; flex-wrap: wrap; }
.hero .live-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--live); color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .06em; padding: 4px 10px; border-radius: 6px; }
.hero .offline-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-3); color: var(--text-2); font-weight: 700; font-size: 12px; letter-spacing: .06em; padding: 4px 10px; border-radius: 6px; }
.hero .title { font-size: 18px; font-weight: 650; }
.hero .meta { display: flex; gap: 14px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; }
.hero .meta b { color: var(--text); font-weight: 600; }
.hero .meta svg { width: 14px; height: 14px; vertical-align: -2px; color: var(--text-3); }
.drawer .d-head > svg { width: 20px; height: 20px; color: var(--accent-2); }
.hero .dur { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-left: auto; }
.hero .dur small { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; letter-spacing: 0; text-align: right; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); display: inline-block; box-shadow: 0 0 0 0 rgba(235,4,0,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(235,4,0,.55); } 70% { box-shadow: 0 0 0 7px rgba(235,4,0,0); } 100% { box-shadow: 0 0 0 0 rgba(235,4,0,0); } }
.two-col { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.notice { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--text-2); }
.notice svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; color: var(--text-3); }

/* ============================================================ badges / status */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; line-height: 16px; white-space: nowrap; color: #fff; background: var(--role-follow); vertical-align: middle; }
.badge svg { width: 10px; height: 10px; }
.badge.bc { background: var(--role-bc); } .badge.mod { background: var(--role-mod); } .badge.vip { background: var(--role-vip); } .badge.sub { background: var(--role-sub); }
.badge.follow { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.badge.new { background: var(--role-new); color: #1a1200; } .badge.bot { background: var(--role-bot); } .badge.custom { background: var(--accent); }
.badge.first { background: var(--warn); color: #1a1200; }
.badge.founder { background: #7c3aed; }
.help { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--text-3); font-size: 10px; font-weight: 700; line-height: 1; cursor: help; margin-left: 6px; position: relative; vertical-align: 1px; text-transform: none; letter-spacing: 0; font-family: var(--font); }
.help:hover, .help:focus, .help.show { color: var(--text); border-color: var(--accent); outline: none; }
.help::after { content: attr(data-tip); position: absolute; left: -6px; top: calc(100% + 8px); width: max-content; max-width: 300px; background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 400; line-height: 1.45; white-space: normal; text-align: left; box-shadow: var(--shadow); opacity: 0; visibility: hidden; transition: opacity .12s; z-index: 70; text-transform: none; letter-spacing: 0; }
.help.right::after { left: auto; right: -6px; }
.help:hover::after, .help:focus::after, .help.show::after { opacity: 1; visibility: visible; }
.tbl th .help { vertical-align: -1px; }
.setting-row .info b .help, .card-head h3 .help, .stat .label .help, .page-head h1 .help { margin-left: 6px; }
label.field > span .help { margin-left: 2px; }
.roles-table td { vertical-align: top; }
.role-pick { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.role-pick:hover { background: var(--surface-hover); }
.role-pick input { accent-color: var(--accent); margin: 0; }
.role-pick .cap { margin-left: auto; font-size: 11px; color: var(--text-3); }
.badge.outline { background: transparent; border: 1px solid currentColor; }
.badges { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.active { color: var(--active); } .status.lurking { color: var(--lurk); } .status.idle { color: var(--idle); } .status.absent { color: var(--text-3); } .status.absent::before { background: transparent; border: 1.5px solid currentColor; }
.status.present { color: var(--active); } .status.left { color: var(--text-3); }
.status.attended { color: var(--text-2); } .status.chatted { color: var(--active); } .status.lurked { color: var(--lurk); } .status.quiet { color: var(--idle); }
.card.stale { border-style: dashed; }
.card.stale .ring .fill { stroke: var(--text-3); }
.status svg { width: 12px; height: 12px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill.lurk { background: var(--lurk-soft); color: var(--lurk); } .pill.good { background: var(--good-soft); color: var(--good); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.crit { background: var(--crit-soft); color: var(--crit); } .pill.accent { background: var(--accent-soft); color: var(--accent-2); } .pill.new { background: rgba(224,161,0,.16); color: var(--role-new); }
.pill svg { width: 11px; height: 11px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; border-radius: 14px; }
.user { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.user .uname { font-weight: 600; } .user:hover .uname { color: var(--accent-2); text-decoration: underline; }
.user .login { font-size: 11px; color: var(--text-3); }
tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--role-new); }
tr.is-new { background: rgba(224,161,0,.05); }
tr.is-mod td:first-child { box-shadow: inset 3px 0 0 var(--role-mod); }
tr.is-live { background: var(--live-soft); }

/* ============================================================ tables */
.table-wrap { overflow-x: auto; }
.table-wrap.scroll { max-height: 520px; overflow: auto; border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; z-index: 2; background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text); }
.tbl th .arrow { display: inline-block; width: 10px; margin-left: 3px; color: var(--accent-2); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-hover); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl th.right, .tbl td.right { text-align: right; white-space: nowrap; }
.tbl td.wrap { white-space: normal; }
.drawer .tbl.compact td, .drawer .tbl.compact th { padding: 5px 6px; font-size: 12px; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl.compact td { padding: 5px 8px; } .tbl.compact th { padding: 7px 8px; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; font-size: 12px; color: var(--text-2); border-top: 1px solid var(--border); }
.card.tight .table-wrap.scroll { border-radius: 0; }
.bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--series-1); vertical-align: middle; }
.bar-track { display: inline-block; width: 56px; height: 6px; border-radius: 3px; background: var(--surface-3); vertical-align: middle; margin-right: 6px; position: relative; overflow: hidden; }
.bar-track .bar { position: absolute; left: 0; top: 0; height: 100%; }

/* ============================================================ filter bar / chips */
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filterbar .search { width: 240px; }
.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--text); background: var(--surface-hover); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip svg { width: 12px; height: 12px; }
.chip .x { margin-left: 2px; opacity: .6; } .chip .x:hover { opacity: 1; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; color: var(--text-2); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 13px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .count { margin-left: 6px; font-size: 11px; color: var(--text-3); background: var(--surface-3); padding: 1px 6px; border-radius: 999px; }
.multisel { position: relative; }
.multisel .box { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 34px; padding: 3px 6px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; cursor: text; min-width: 200px; }
.multisel .box input { border: 0; background: transparent; outline: none; color: var(--text); font: inherit; font-size: 13px; flex: 1; min-width: 80px; padding: 3px 4px; }
.multisel .list { position: absolute; z-index: 30; top: 100%; left: 0; margin-top: 4px; min-width: 240px; max-height: 260px; overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; }
.multisel .list div { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.multisel .list div:hover, .multisel .list div.hl { background: var(--surface-hover); }
.dropdown { position: relative; display: inline-block; }
.dropdown .menu { position: absolute; z-index: 60; top: 100%; left: 0; margin-top: 4px; min-width: 320px; max-height: 440px; overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; }
.dropdown .menu.right { left: auto; right: 0; }
.dropdown .menu button { display: flex; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; gap: 8px; align-items: center; }
.dropdown .menu button:hover { background: var(--surface-hover); }
.dropdown .menu button code { font-family: var(--mono); font-size: 12px; color: var(--accent-2); }
.dropdown .menu .hint { font-size: 11px; color: var(--text-3); margin-left: auto; white-space: nowrap; padding-left: 12px; }

/* ============================================================ drawer / modal / toast */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90; opacity: 0; transition: opacity .15s; }
.backdrop.show { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100vw; background: var(--surface); border-left: 1px solid var(--border); z-index: 100; transform: translateX(100%); transition: transform .18s ease-out; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.drawer.show { transform: translateX(0); }
.drawer .d-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex: none; }
.drawer .d-body { flex: 1; overflow: auto; padding: 16px; }
.drawer .d-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex: none; }
.modal-wrap { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; width: 640px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: 860px; }
.modal .m-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal .m-body { padding: 18px; overflow: auto; }
.modal .grid { align-content: start; }
.modal .m-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); animation: fadein .15s; display: flex; gap: 8px; align-items: center; }
.toast.ok { border-color: var(--good); } .toast.err { border-color: var(--crit); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; font-weight: 500; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.mini-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.mini-stat .label { font-size: 11px; color: var(--text-2); } .mini-stat .value { font-size: 17px; font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; } .mini-stat .sub { font-size: 11px; color: var(--text-3); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 8px; }
.section-title h4 { margin: 0; }

/* ============================================================ timeline / chat */
.timeline { display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 78px 26px 1fr; gap: 8px; align-items: start; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.ev:hover { background: var(--surface-hover); }
.ev .t { font-family: var(--mono); font-size: 12px; color: var(--text-3); padding-top: 2px; white-space: nowrap; }
.ev .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.ev .ic svg { width: 13px; height: 13px; }
.ev.chat .ic { background: transparent; } .ev.enter .ic { color: var(--good); } .ev.exit .ic { color: var(--text-3); } .ev.lurk .ic { color: var(--lurk); background: var(--lurk-soft); } .ev.redeem .ic { color: var(--accent-2); background: var(--accent-soft); } .ev.mod .ic { color: var(--crit); background: var(--crit-soft); } .ev.follow .ic { color: var(--series-5); } .ev.sub .ic { color: var(--role-sub); } .ev.cheer .ic { color: var(--warn); background: var(--warn-soft); } .ev.stream .ic { color: var(--live); background: var(--live-soft); }
.ev .body { min-width: 0; line-height: 1.4; }
.ev .body .msg { color: var(--text); }
.ev .body .who { font-weight: 600; cursor: pointer; } .ev .body .who:hover { color: var(--accent-2); text-decoration: underline; }
.ev .body .desc { color: var(--text-2); }
.ev .body .stream-ref { font-size: 11px; color: var(--text-3); margin-left: 8px; cursor: pointer; } .ev .body .stream-ref:hover { color: var(--accent-2); }
.ev.chat .body .who.mod { color: var(--role-mod); } .ev.chat .body .who.vip { color: var(--role-vip); } .ev.chat .body .who.bc { color: var(--role-bc); } .ev.chat .body .who.bot { color: var(--text-3); }
.ev.cmd .msg { font-family: var(--mono); font-size: 12.5px; color: var(--accent-2); }
.ev.chat.is-bot .msg { color: var(--text-2); }
.ev .chat-badge { margin-right: 4px; }
.day-sep { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }

/* ============================================================ moderator coverage */
.mod-list { display: flex; flex-direction: column; }
.mod-row { display: grid; grid-template-columns: 1fr auto auto auto auto auto; gap: 10px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mod-row:last-child { border-bottom: 0; }
.mod-row .metric { text-align: right; font-variant-numeric: tabular-nums; min-width: 60px; } .mod-row .metric small { display: block; font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.mod-row.absent { opacity: .62; }
.coverage-ring { display: inline-flex; align-items: baseline; gap: 4px; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; } .coverage-ring small { font-size: 13px; color: var(--text-2); font-weight: 500; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin-top: 12px; }
.summary-strip div { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; text-align: center; }
.summary-strip b { display: block; font-size: 16px; } .summary-strip span { font-size: 10.5px; color: var(--text-2); }

/* ============================================================ settings */
.settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.subnav button { text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--text-2); cursor: pointer; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.subnav button svg { width: 15px; height: 15px; }
.subnav button:hover { background: var(--surface-hover); color: var(--text); } .subnav button.on { background: var(--accent-soft); color: var(--text); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .info { min-width: 0; } .setting-row .info b { display: block; font-weight: 600; } .setting-row .info span { font-size: 12px; color: var(--text-2); }
.setting-row .ctl { flex: none; display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.save-state.saving { color: var(--warn); } .save-state.saved { color: var(--good); }
.tpl-editor { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); }
.tpl-editor .tb { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: 10px 10px 0 0; }
.tpl-editor textarea { width: 100%; border: 0; background: transparent; color: var(--text); font: 13px/1.5 var(--mono); padding: 10px 12px; min-height: 64px; resize: vertical; outline: none; display: block; }
.tpl-editor .preview { border-top: 1px solid var(--border); padding: 8px 12px; font-size: 12.5px; background: var(--surface); border-radius: 0 0 10px 10px; }
.tpl-editor .preview .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; margin-bottom: 4px; }
.tpl-editor .preview .bubble { display: inline-block; background: var(--surface-3); border-radius: 8px; padding: 6px 10px; }
.tpl-editor .preview .bubble .bot { color: var(--text-3); font-weight: 600; margin-right: 6px; }
.rule-grid { display: grid; grid-template-columns: 1fr repeat(4, 96px) 40px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rule-grid.head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 700; padding: 4px 0; }
.rule-grid .input { width: 100%; }
.cmd-row { border-bottom: 1px solid var(--border); padding: 10px 0; }
.cmd-row .top { display: grid; grid-template-columns: 40px 130px 1fr auto; gap: 12px; align-items: center; }
.cmd-row code { font-family: var(--mono); font-weight: 700; color: var(--accent-2); }
.cmd-row .body { margin-top: 10px; display: grid; gap: 10px; }
.cmd-row .body .field-row { gap: 10px; }
.role-row { display: grid; grid-template-columns: 30px 180px 1fr 44px 36px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border-strong); }
input[type=color] { width: 32px; height: 26px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); padding: 1px 2px; cursor: pointer; }

/* ============================================================ simulator */
.sim-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sim-grid .btn { justify-content: flex-start; }
.sim-log { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 3px; }
.sim-log .ok { color: var(--good); } .sim-log .err { color: var(--crit); }

/* ============================================================ charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 10.5px; font-family: var(--font); }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .area { fill: var(--series-1); opacity: .12; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { fill: var(--series-1); } .chart .bar.dim { fill: var(--surface-3); } .chart .bar.hl { fill: var(--accent-2); }
.chart .lbl { fill: var(--text-2); font-size: 11px; font-family: var(--font); }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: none; opacity: 0; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; opacity: 0; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 6px; padding: 5px 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); display: none; z-index: 5; box-shadow: var(--shadow); }
.chart-tip b { display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar-row { display: grid; grid-template-columns: 140px 1fr 58px; gap: 10px; align-items: center; padding: 4px 0; font-size: 12.5px; }
.hbar-row .track { height: 14px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar-row .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }

/* ============================================================ empty / loading */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty svg { width: 34px; height: 34px; color: var(--text-3); margin-bottom: 8px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }
.loading-screen { height: 100vh; display: grid; place-items: center; text-align: center; color: var(--text-2); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy { opacity: .55; pointer-events: none; transition: opacity .15s; }
.content.refreshing { opacity: .7; }

/* ============================================================ polish pass */
body { font-feature-settings: "cv02", "cv03", "cv04", "cv11"; background: radial-gradient(1100px 520px at 12% -12%, rgba(145,71,255,.16), transparent 62%), radial-gradient(900px 480px at 100% 0%, rgba(58,130,246,.08), transparent 60%), var(--bg); background-attachment: fixed; }
:root[data-theme="light"] body { background: radial-gradient(1100px 520px at 12% -12%, rgba(119,44,232,.10), transparent 62%), radial-gradient(900px 480px at 100% 0%, rgba(42,120,214,.08), transparent 60%), var(--bg); }
h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 700; }
.sidebar { background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%); }
.brand .logo { background: var(--accent-grad); box-shadow: 0 6px 18px rgba(145,71,255,.35); border-radius: 10px; }
.nav a { position: relative; transition: background .12s, color .12s; }
.nav a.active { background: linear-gradient(90deg, var(--accent-soft), transparent); }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent-grad); }
.topbar { background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(10px); }
.card { border-radius: 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 10px 30px rgba(0,0,0,.22); }
:root[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(20,20,40,.06), 0 10px 30px rgba(20,20,40,.06); }
.stat { border-radius: 14px; padding: 14px 16px; box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 10px 30px rgba(0,0,0,.18); transition: transform .15s, box-shadow .15s, border-color .15s; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: 0; background: radial-gradient(240px 120px at 100% 0%, rgba(255,255,255,.04), transparent 60%); pointer-events: none; }
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat .label { font-weight: 500; }
.stat .label svg { width: 26px; height: 26px; padding: 6px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.stat.good .label svg { background: var(--good-soft); color: var(--good); }
.stat.lurk .label svg { background: var(--lurk-soft); color: var(--lurk); }
.stat.new .label svg { background: rgba(224,161,0,.16); color: var(--role-new); }
.stat.accent .label svg { background: var(--accent-soft); color: var(--accent-2); }
.stat .value { font-size: 27px; font-weight: 750; margin-top: 6px; }
.stat .delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; margin-left: 8px; padding: 1px 6px; border-radius: 999px; vertical-align: middle; letter-spacing: 0; }
.stat .delta.up { color: var(--good); background: var(--good-soft); } .stat .delta.down { color: var(--crit); background: var(--crit-soft); } .stat .delta.flat { color: var(--text-2); background: var(--surface-3); }
.stat .delta svg { width: 10px; height: 10px; padding: 0; background: transparent; }
.hero { border-radius: 16px; background: radial-gradient(700px 240px at 0% 0%, rgba(145,71,255,.22), transparent 60%), linear-gradient(120deg, var(--surface) 0%, var(--surface-2) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 14px 40px rgba(0,0,0,.28); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: 0; border-radius: 16px; padding: 1px; background: linear-gradient(120deg, rgba(145,71,255,.5), transparent 40%, transparent 70%, rgba(58,130,246,.35)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
:root[data-theme="light"] .hero { background: radial-gradient(700px 240px at 0% 0%, rgba(119,44,232,.12), transparent 60%), linear-gradient(120deg, #fff 0%, var(--surface-2) 100%); }
.hero .live-pill { background: linear-gradient(135deg, #ff3b30, #c80000); box-shadow: 0 6px 18px rgba(235,4,0,.35); border-radius: 8px; padding: 6px 12px; }
.hero .offline-pill { border-radius: 8px; padding: 6px 12px; }
.hero .title { font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.hero .dur { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; }
.btn { border-radius: 9px; transition: background .12s, border-color .12s, transform .12s, box-shadow .12s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-grad); box-shadow: 0 6px 18px rgba(145,71,255,.30); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(145,71,255,.38); }
.btn.danger:hover { box-shadow: 0 6px 18px rgba(208,59,59,.3); }
.tbl th { background: var(--surface-2); border-bottom: 1px solid var(--border-strong); }
.tbl th:first-child { border-top-left-radius: 8px; } .tbl th:last-child { border-top-right-radius: 8px; }
.tbl tbody tr:nth-child(even) { background: rgba(255,255,255,.015); }
:root[data-theme="light"] .tbl tbody tr:nth-child(even) { background: rgba(20,20,40,.02); }
.tbl tbody tr:hover { background: var(--accent-soft); }
.tbl tbody tr.is-live { background: var(--live-soft); }
.badge { border-radius: 6px; padding: 2px 7px; box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); }
.badge.follow { box-shadow: none; }
.tabs button.on { border-bottom-width: 3px; border-image: var(--accent-grad) 1; }
.chip.on { background: linear-gradient(135deg, rgba(157,92,255,.28), rgba(111,44,207,.18)); border-color: var(--accent); }
.summary-strip div { background: linear-gradient(180deg, var(--surface-3), var(--surface-2)); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.summary-strip b { font-size: 18px; font-weight: 750; }
.mini-stat { border-radius: 10px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.mini-stat .value { font-weight: 750; }
.backdrop { backdrop-filter: blur(4px); background: rgba(0,0,0,.5); }
.drawer { box-shadow: -20px 0 60px rgba(0,0,0,.5); }
.modal { box-shadow: 0 30px 80px rgba(0,0,0,.6); border-radius: 16px; }
.ev { transition: background .1s; }
.ev .ic { border-radius: 7px; }
.avatar { box-shadow: inset 0 -2px 0 rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.3); }
.avatar.lg { border-radius: 16px; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: url(#ringGrad); transition: stroke-dashoffset .4s ease; }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 750; line-height: 1; text-align: center; }
.ring .num small { display: block; font-size: 9px; color: var(--text-3); font-weight: 600; text-align: center; margin-top: 2px; }
.card-head .ring-wrap { display: flex; align-items: center; gap: 10px; }
.card-head .ring-wrap .lbl { font-size: 12px; color: var(--text-2); text-align: right; line-height: 1.3; }
.card-head .ring-wrap .lbl b { display: block; color: var(--text); font-size: 15px; }
.chart .line { stroke-width: 2.25; }
.chart .dot { r: 4.5; }
.page-head .lead { font-size: 13.5px; }
.sidebar .foot { background: linear-gradient(180deg, transparent, rgba(145,71,255,.06)); }
.notice { border-radius: 10px; }
.filterbar .search .input { border-radius: 9px; }
.empty svg { color: var(--accent-2); opacity: .6; }

/* ============================================================ responsive */
@media (max-width: 1180px) {
  #app { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar .brand .name, .sidebar .brand .sub, .sidebar .nav a span, .sidebar .foot { display: none; }
  .sidebar .nav a { justify-content: center; padding: 10px; } .sidebar .nav .live-dot { display: none; }
  .table-wrap { overflow-x: auto; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; } .subnav { flex-direction: row; flex-wrap: wrap; position: static; margin-bottom: 8px; }
  .rule-grid { grid-template-columns: 1fr repeat(4, 80px) 36px; }
}
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 80; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .18s; }
  .sidebar.open { transform: none; }
  .sidebar .brand .name, .sidebar .brand .sub, .sidebar .nav a span, .sidebar .foot { display: block; }
  .sidebar .nav a { justify-content: flex-start; }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px 14px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100vw; }
  .hero .dur { margin-left: 0; width: 100%; }
  .mod-row { grid-template-columns: 1fr auto; }
  .cmd-row .top { grid-template-columns: 40px 1fr; }
  .rule-grid, .rule-grid.head { grid-template-columns: 1fr 1fr 1fr; }
}
@media print { .sidebar, .topbar, .drawer, .backdrop { display: none !important; } #app { grid-template-columns: 1fr; } .content { overflow: visible; } }

/* Moderators have view-only access: settings controls are shown but inert. */
.readonly-mode .settings-layout input, .readonly-mode .settings-layout select, .readonly-mode .settings-layout textarea,
.readonly-mode .settings-layout .switch, .readonly-mode .settings-layout [data-act="clear-data"], .readonly-mode .role-pick input { pointer-events: none; opacity: .55; }

/* The top bar holds the account menu; keep it (and its dropdown) above page content. */
.topbar { position: relative; z-index: 40; }

/* Logo = HavensSquire portrait (sidebar + sign-in screen). */
.brand .logo.img { background: none; padding: 0; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.45); }
.brand .logo.img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; display: block; }
.loading-screen .brand .logo.img { width: 56px; height: 56px; border-radius: 14px; }

/* Role / status filter chips tinted with their Twitch colour (set per chip as --c). */
.chip[style*="--c"] svg { color: var(--c); }
.chip[style*="--c"] { border-color: color-mix(in srgb, var(--c) 40%, var(--border-strong)); }
.chip[style*="--c"]:hover { background: color-mix(in srgb, var(--c) 12%, var(--surface-2)); }
.chip.on[style*="--c"] { background: color-mix(in srgb, var(--c) 26%, transparent); border-color: var(--c); color: var(--text); }
.chip.on[style*="--c"] svg { color: var(--text); }

/* Help tooltips are drawn by lists.js as one floating box (never clipped by cards or the screen edge). */
.help::after { display: none !important; }
#tipfloat { position: fixed; z-index: 1000; display: none; pointer-events: none; width: max-content; background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 400; line-height: 1.45; text-align: left; box-shadow: var(--shadow); }

/* Clickable stat cards on the Live Dashboard. */
.stat[data-act="stat-list"] { cursor: pointer; }
.stat[data-act="stat-list"]:hover { border-color: var(--accent); }
.stat[data-act="stat-list"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* New help request pop-ups (admin), bottom-right. */
#help-popups { position: fixed; right: 16px; bottom: 16px; z-index: 120; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px)); }
.help-popup { background: var(--surface); border: 1px solid var(--warn); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; animation: popin .18s ease-out; }
.help-popup svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--warn); }
@keyframes popin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Viewers' Twitch profile pictures cover the coloured initial. */
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ☰ collapses the sidebar to an icon strip on larger screens (phones keep the slide-in menu). */
.menu-btn { display: inline-flex; }
#app.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
#app.collapsed .nav a span, #app.collapsed .sidebar .foot, #app.collapsed .brand > div:not(.logo) { display: none; }
#app.collapsed .nav a { justify-content: center; padding: 10px; }
#app.collapsed .nav a.active::before { left: -8px; }
#app.collapsed .brand { justify-content: center; padding: 16px 8px 12px; }
@media (max-width: 760px) {
  #app.collapsed { grid-template-columns: 1fr; }
  #app.collapsed .nav a span, #app.collapsed .sidebar .foot { display: block; }
  #app.collapsed .brand > div:not(.logo) { display: block; }
  #app.collapsed .nav a { justify-content: flex-start; }
}
#app.collapsed .nav a .live-dot { display: block; position: absolute; top: 7px; right: 10px; }
#app.collapsed .nav a .pill { display: block; position: absolute; top: 3px; right: 3px; padding: 0 5px !important; font-size: 9px !important; line-height: 15px; }
@media (max-width: 760px) { #app.collapsed .nav a .live-dot, #app.collapsed .nav a .pill { position: static; } }

/* Ctrl+K search results */
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-item:hover, .search-item.sel { background: var(--surface-hover); }
.search-item.sel { box-shadow: inset 0 0 0 1px var(--accent); }
.search-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.search-ic svg { width: 15px; height: 15px; color: var(--text-2); }
#search-results { max-height: 50vh; overflow: auto; }

.badge.regular { background: #0f8a7e; }

/* Live Dashboard: 10 cards → 5 per row on wide screens. */
@media (min-width: 1500px) { .stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Lead Moderator marker in moderator tables: a small green star instead of the full pill. */
.lead-star { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: #0e9f6e; }
.lead-star svg { width: 15px; height: 15px; fill: currentColor; }

/* ============================================================ phones */
/* Pieces that only exist for phones stay hidden on bigger screens. */
.tabbar, .sb-backdrop, .sb-tools, .top-search { display: none; }
@supports (height: 100dvh) { #app, .main { height: 100dvh; } }

@media (max-width: 760px) {
  html, body { overflow: hidden; }
  body { font-size: 14.5px; -webkit-tap-highlight-color: transparent; }
  ::-webkit-scrollbar { width: 0; height: 0; }

  /* Top bar: menu, back link, search, channel. Reload and theme move into the menu. */
  .topbar { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0; gap: 6px; }
  .topbar .top-tool { display: none; }
  .topbar .top-search { display: inline-flex; }
  .topbar .btn.icon { padding: 9px; border-radius: 10px; }
  .topbar .crumbs .title, .topbar .crumbs .sep { display: none; }
  .topbar .crumbs .title:only-child { display: block; font-size: 16px; font-weight: 750; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 2px; }
  .main:has(.page-head h1) .topbar .crumbs .title { display: none; }
  .topbar .crumbs .link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); padding: 6px 12px 6px 9px; border-radius: 999px; }
  .topbar .crumbs .link::before { content: ""; width: 7px; height: 7px; border-left: 2px solid var(--accent-2); border-bottom: 2px solid var(--accent-2); transform: rotate(45deg); margin-right: 2px; }
  .topbar .dropdown > .btn { max-width: 190px !important; padding: 7px 10px; border-radius: 999px; }
  .topbar .dropdown > .btn .pill { display: none; }
  .topbar .save-state { position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); background: var(--surface-3); padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow); }
  .topbar .save-state:empty { display: none; }
  .dropdown .menu.right { position: fixed; left: 10px; right: 10px; top: calc(60px + env(safe-area-inset-top)); min-width: 0 !important; max-height: calc(100dvh - 160px); border-radius: 14px; padding: 6px; }
  .dropdown .menu button { padding: 11px 10px; font-size: 14px; }

  /* Slide-in menu with a dimmed page behind it. */
  .sidebar { width: min(300px, 84vw); padding-top: env(safe-area-inset-top); box-shadow: none; background: var(--surface); }
  .sidebar.open { box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .sidebar .nav a { padding: 12px 12px; font-size: 15px; }
  .sb-tools { display: flex; gap: 8px; padding: 10px 14px; margin-top: auto; }
  .sb-tools .btn { flex: 1; justify-content: center; padding: 10px; }
  .sidebar .foot { margin-top: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); font-size: 12px; }
  .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 79; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .18s; }
  .sidebar.open + .sb-backdrop { opacity: 1; pointer-events: auto; }

  /* Bottom tab bar. */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-top: 1px solid var(--border); }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; border-radius: 12px; color: var(--text-3); font-size: 10.5px; font-weight: 600; letter-spacing: .01em; cursor: pointer; transition: color .15s; }
  .tabbar a svg { width: 22px; height: 22px; transition: transform .15s; }
  .tabbar a.active { color: var(--text); }
  .tabbar a.active svg { color: var(--accent-2); transform: translateY(-1px); }
  .tabbar a.active::before { content: ""; position: absolute; top: -7px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent-grad); }
  .tabbar a:active svg { transform: scale(.9); }
  .tb-live { position: absolute; top: 4px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 2px var(--surface); display: none; }
  .tb-live.on { display: block; }
  .tb-badge { position: absolute; top: 1px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--crit); color: #fff; font: 700 10px/16px var(--font); font-style: normal; text-align: center; box-shadow: 0 0 0 2px var(--surface); }

  /* Page body. */
  .content { padding: 14px 12px calc(92px + env(safe-area-inset-bottom)); scroll-behavior: auto; }
  h1 { font-size: 22px; }
  .page-head { margin-bottom: 12px; }
  .page-head .lead { font-size: 13px; }
  .card { padding: 14px; border-radius: 16px; }
  .card.tight .card-head { padding: 12px 14px; }
  .card-head { flex-wrap: wrap; }

  /* Demo bar: one short line. */
  .demo-bar { padding: 8px 12px; gap: 8px !important; flex-wrap: nowrap !important; }
  .demo-bar .hide-sm { display: none; }
  .demo-bar > .flex-1 { display: none; }
  .demo-bar .demo-text { margin-right: auto; white-space: nowrap; }
  .demo-bar .pill { display: none; }
  .demo-bar .btn { padding: 6px 10px; font-size: 12.5px; }
  .demo-bar svg { display: none; }
  .demo-bar { overflow: hidden; }

  /* Live hero: status and clock on top, then title and details. */
  .hero { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 16px; margin-bottom: 12px; }
  .hero > .flex-1 { grid-column: 1 / -1; order: 3; }
  .hero > .btn { grid-column: 1 / -1; order: 4; justify-content: center; }
  .hero .title { font-size: 18px; line-height: 1.25; }
  .hero .meta { gap: 6px 12px; font-size: 12.5px; }
  .hero .dur { width: auto !important; margin-left: auto !important; font-size: 26px; text-align: right; line-height: 1; }
  .hero .dur small { margin-top: 4px; }

  /* Stat cards: two across, tighter. */
  .stats { gap: 10px; }
  .stat { padding: 12px; border-radius: 14px; }
  .stat .label { font-size: 12px; gap: 7px; line-height: 1.25; }
  .stat .label svg { width: 24px; height: 24px; padding: 5px; }
  .stat .value { font-size: 24px; margin-top: 8px; }
  .stat .delta { margin-left: 4px; }
  .stat:hover { transform: none; }
  .stat .label .help { display: none; }

  /* Filter rows scroll sideways instead of stacking into a tall block. */
  .filterbar { flex-wrap: wrap; gap: 6px 8px; }
  .filterbar > .small.muted:first-child { width: 100% !important; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
  .filterbar .search, .flex:has(> [data-tsearch]) .search, .flex > .search:has([data-tsearch]) { width: 100% !important; }
  .flex:has(> .search [data-tsearch]) { flex-wrap: wrap; }
  .filterbar label.field[style*="row"] { width: 100%; }
  .filterbar label.field[style*="row"] > .input { flex: 1 1 0; min-width: 0; width: auto !important; }
  .filterbar > .grow { display: none; }
  .filterbar > .select, .filterbar > .multisel { width: 100%; }
  .filterbar > .multisel .box { width: 100%; }
  .tbl tbody tr:hover td:first-child { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
  .chips { flex-wrap: nowrap; overflow-x: auto; max-width: calc(100% + 28px); margin: 0 -14px; padding: 2px 14px; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent); scrollbar-width: none; }
  .chip { padding: 7px 13px; font-size: 13px; flex: none; }
  .filterbar label.field { font-size: 12.5px; }

  /* Tables scroll sideways with the first column pinned. */
  .tbl { font-size: 13px; }
  .tbl td, .tbl th { padding: 9px 8px; }
  .tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 6px 0 8px -6px rgba(0,0,0,.5); }
  .tbl th:first-child { z-index: 3; background: var(--surface-2); }
  :root[data-theme="light"] .tbl th:first-child, :root[data-theme="light"] .tbl td:first-child { box-shadow: 6px 0 8px -6px rgba(20,20,40,.18); }
  .tbl tbody tr.is-live td:first-child { background: color-mix(in srgb, var(--live) 14%, var(--surface)); }
  .tbl td:first-child { max-width: 52vw; }
  .tbl td:first-child .badge { font-size: 9.5px; padding: 1px 5px; }
  .tbl-foot { flex-wrap: wrap; }

  /* Settings: sub-pages become a sideways strip of pills. */
  .settings-layout { gap: 12px; }
  .subnav { flex-wrap: nowrap !important; overflow-x: auto; margin: 0 -12px 4px !important; padding: 2px 12px; scrollbar-width: none; gap: 6px; }
  .subnav button { flex: none; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; }
  .subnav button.on { border-color: var(--accent); }
  .setting-row { flex-wrap: wrap; gap: 10px; }
  .setting-row .info { flex: 1 1 200px; }
  .tabs button { padding: 10px 12px; }

  /* Text boxes at 16px so phones do not zoom in when you tap them; bigger tap targets. */
  .input, .select, textarea.input, .input.sm, .select.sm, .multisel .box input { font-size: 16px; }
  .btn { padding: 9px 13px; }
  .btn.sm { padding: 7px 11px; font-size: 13px; }
  .switch { width: 42px; height: 24px; }
  .switch span::after { width: 18px; height: 18px; }
  .switch input:checked + span::after { transform: translateX(18px); }

  /* Pop-ups slide up from the bottom as sheets. */
  .modal-wrap { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 90dvh; border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheetup .22s cubic-bezier(.2,.8,.2,1); padding-bottom: env(safe-area-inset-bottom); }
  .modal::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto -4px; flex: none; }
  .modal .m-head { padding: 12px 16px; }
  .modal .m-body { padding: 16px; }
  .modal .m-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal .m-foot .btn { flex: 1; justify-content: center; }
  .drawer { width: 100vw; border-left: 0; padding-top: env(safe-area-inset-top); }
  .drawer .d-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); width: calc(100vw - 24px); }
  #help-popups { right: 12px; left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
  #tipfloat { max-width: calc(100vw - 24px) !important; }

  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
  .hbar-row { grid-template-columns: 96px 1fr 50px; }
  .ev { grid-template-columns: 58px 24px 1fr; padding: 8px 10px; }
}
@keyframes sheetup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* Live Dashboard: what the percentages compare against. */
.compare-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.compare-bar .seg button { padding: 5px 12px; }
.compare-bar .seg button.on { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

/* Settings ▸ Import watch time */
.import-steps { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 6px; line-height: 1.5; }
.import-steps code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; color: var(--text); }
.import-staged { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--good-soft); border: 1px solid color-mix(in srgb, var(--good) 40%, transparent); }
.import-staged > svg { color: var(--good); }
.import-bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; max-width: 320px; margin-left: auto; margin-right: auto; }
.import-bar i { display: block; height: 100%; background: var(--accent-grad); transition: width .2s; }
#modal-body .center > svg { width: 34px; height: 34px; color: var(--good); }

#imp-se-name[readonly] { background: var(--surface-3); color: var(--text-2); cursor: default; }
#imp-se-name[readonly]:focus { border-color: var(--border-strong); box-shadow: none; }

/* Settings ▸ Export data */
.xp-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.xp-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; }
.xp-item:hover { border-color: var(--border-strong); }
.xp-item.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.xp-item input { accent-color: var(--accent); width: 16px; height: 16px; margin: 3px 0 0; flex: none; }
.xp-item .xp-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.xp-item.on .xp-ic { background: var(--accent-soft); color: var(--accent-2); }
.xp-item b { font-weight: 600; font-size: 13.5px; }
.xp-item small { display: block; color: var(--text-3); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.xp-count { margin-left: 8px; font-size: 11px; color: var(--text-3); font-weight: 600; }
.xp-go { display: flex; align-items: center; gap: 12px; position: sticky; bottom: 0; z-index: 5; }
@media (max-width: 900px) { .xp-list { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .xp-go { bottom: 0; } .xp-go .btn { padding: 10px 18px; } }

/* Clear tracked data: warning, scheduled state, and the red bar while it is pending. */
.clear-warn { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--crit-soft); border: 1px solid color-mix(in srgb, var(--crit) 45%, transparent); }
.clear-warn > svg { width: 22px; height: 22px; color: var(--crit); flex: none; }
.clear-list { margin: 14px 0 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-2); line-height: 1.5; }
.clear-pending { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--crit-soft); border: 1px solid var(--crit); }
.clear-pending > svg { width: 20px; height: 20px; color: var(--crit); flex: none; }
.clear-banner { margin: 0; border-radius: 0; border-left: 0; border-right: 0; border-style: solid; border-color: var(--crit); background: var(--crit-soft); color: var(--text); display: flex; align-items: center; gap: 10px; }
.clear-banner > svg { color: var(--crit); }

/* Viewers ▸ Last seen filter */
.seen-now { color: var(--good); font-weight: 600; }
@media (min-width: 761px) { .filterbar > .small.muted:first-child { white-space: nowrap; width: auto !important; min-width: 78px; } }
@media (min-width: 761px) { .filterbar > .chips { flex: 1 1 0; min-width: 0; } }
.seen-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); flex: none; margin-left: 2px; }
.seen-custom .input { width: 64px; }

/* Use the whole screen: no fixed-width column in the middle. Role badges get room to sit side by side. */
.page { max-width: none; }
@media (min-width: 1100px) { .tbl td .badges { min-width: 230px; } }
