:root {
  --night: #0d0b10;
  --night-2: #17141b;
  --night-3: #221d27;
  --star: #f2ede3;
  --mute: #aaa39b;
  --dim: #7b746f;
  --line: rgba(242, 237, 227, 0.12);
  --line-2: rgba(242, 237, 227, 0.24);
  --brass: #e5b451;
  --magic: #7fd0c8;
  --ok: #8fd18b;
  --bad: #f06579;
  --twitch: #9146ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--night);
  background-image: radial-gradient(ellipse 60% 45% at 80% 0%, #2a2128 0%, transparent 70%);
  background-attachment: fixed;
  color: var(--star);
  font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--brass); }
h1, h2 { margin: 0 0 0.6rem; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
small, .mute { color: var(--mute); }
.mark { color: var(--brass); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.78rem; margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; background: var(--night-2); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 0.5rem 0.65rem; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brass); }
textarea { resize: vertical; }
select[multiple] { padding: 0.25rem; }
.btn, .ghost, .danger {
  border-radius: 8px; padding: 0.5rem 0.95rem; cursor: pointer; font-weight: 650; border: 1px solid transparent;
  text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
}
.btn { background: var(--brass); color: #1b1408; }
.btn:hover { filter: brightness(1.08); }
.btn.twitch { background: var(--twitch); color: #fff; }
.ghost { background: transparent; border-color: var(--line-2); color: var(--star); }
.ghost:hover { border-color: var(--star); }
.danger { background: transparent; border-color: rgba(240, 101, 121, 0.5); color: var(--bad); }
.danger:hover { background: rgba(240, 101, 121, 0.1); }
.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { width: min(24rem, 100%); background: rgba(23, 20, 27, 0.85); border: 1px solid var(--line); border-radius: 16px; padding: 2rem; }
.card .btn { margin-top: 1rem; width: 100%; justify-content: center; padding: 0.75rem; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr; }
.top { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.top p { margin: 0; }
.brand { font-weight: 800; font-size: 1.05rem; }
.brand .mark { font-size: inherit; letter-spacing: 0.02em; text-transform: none; }
.status { flex: 1; color: var(--mute); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { display: flex; gap: 0.6rem; align-items: center; color: var(--mute); }
.dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--dim); margin-right: 0.35rem; vertical-align: 0.05em; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.live { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

.tabs { display: flex; gap: 0.25rem; padding: 0.5rem 1rem 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { color: var(--mute); text-decoration: none; padding: 0.55rem 0.8rem; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a:hover { color: var(--star); }
.tabs a.on { color: var(--star); border-color: var(--brass); }

main { padding: 1rem; min-height: 0; }
.view { display: none; max-width: 78rem; margin: 0 auto; }
.view.on { display: block; }
.panel { background: rgba(23, 20, 27, 0.78); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; }
.panel.narrow { max-width: 34rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.grid .wide { grid-column: 1 / -1; }
.big { font-size: 1.6rem; font-weight: 800; margin: 0.2rem 0; letter-spacing: -0.02em; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0 0 1rem; }
.row input { flex: 1 1 12rem; width: auto; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0 0; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
.item { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(23, 20, 27, 0.6); }
.item.click { cursor: pointer; }
.item.click:hover, .item.sel { border-color: var(--line-2); background: var(--night-3); }
.item .grow { flex: 1; min-width: 0; }
.item .grow p { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.item .sub { color: var(--mute); font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item img { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--night-3); flex: none; }
.item .off { opacity: 0.5; }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--night-3); flex: none; display: grid; place-items: center; font-weight: 800; color: var(--brass); }
.tag { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--line-2); color: var(--mute); margin-left: 0.3rem; vertical-align: 0.1em; }
.tag.live { border-color: var(--bad); color: var(--bad); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.toggle { display: inline-flex; gap: 0.35rem; align-items: center; color: var(--mute); font-size: 0.86rem; cursor: pointer; white-space: nowrap; }
.toggle input, .check input { width: auto; accent-color: var(--brass); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1rem; align-items: start; }
.editor { position: sticky; top: 1rem; display: grid; gap: 0.75rem; }
.editor label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
.editor label small { font-weight: 400; }
.editor .check, .check { display: flex; gap: 0.5rem; align-items: center; font-weight: 500; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-items: start; }
.prefix { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 8px; background: var(--night-2); }
.prefix span { padding: 0 0 0 0.65rem; color: var(--brass); font-weight: 800; }
.prefix input { border: 0; background: transparent; }
.preview { margin: 0; padding: 0.6rem 0.75rem; border-radius: 8px; background: var(--night); border: 1px dashed var(--line-2); color: var(--mute); font-size: 0.9rem; min-height: 2.6rem; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.8rem; margin: 0.6rem 0 0; font-size: 0.88rem; }
.help dt { color: var(--brass); font-family: ui-monospace, monospace; }
.help dd { margin: 0; color: var(--mute); }

.chatview.on { display: grid; grid-template-rows: auto 1fr auto; height: calc(100vh - 8.5rem); gap: 0.6rem; }
.chatbar { display: flex; gap: 0.75rem; align-items: center; }
.chatbar select { width: auto; min-width: 12rem; }
.feed { list-style: none; margin: 0; padding: 0.5rem 0.75rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: rgba(13, 11, 16, 0.75); font-size: 0.93rem; }
.feed li { padding: 0.15rem 0; overflow-wrap: anywhere; }
.feed .ch { display: inline-block; min-width: 6.5rem; color: var(--dim); font-size: 0.78rem; margin-right: 0.4rem; cursor: pointer; }
.feed .t { color: var(--dim); font-size: 0.75rem; margin-right: 0.35rem; font-variant-numeric: tabular-nums; }
.feed .u { font-weight: 700; margin-right: 0.3rem; }
.feed .self { background: rgba(229, 180, 81, 0.07); border-radius: 4px; }
.feed .notice, .feed .event { color: var(--magic); font-style: italic; }
.feed .action .x { font-style: italic; }
.feed .badge { font-size: 0.7rem; color: var(--brass); margin-right: 0.25rem; }
.say { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr auto; gap: 0.5rem; }

.live-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; margin-top: 0.5rem; }
.stream { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--night-2); text-decoration: none; color: inherit; }
.stream img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--night-3); }
.stream p { margin: 0; padding: 0.5rem 0.7rem 0; }
.stream p:last-child { padding-bottom: 0.6rem; color: var(--mute); font-size: 0.85rem; }
.log { list-style: none; margin: 0; padding: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; color: var(--mute); }
.log li { padding: 0.2rem 0; border-bottom: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--night-3); border: 1px solid var(--line-2); padding: 0.6rem 1rem; border-radius: 10px; max-width: calc(100% - 2rem); }
.toast.err { border-color: var(--bad); color: var(--bad); }

@media (max-width: 820px) {
  .split { grid-template-columns: 1fr; }
  .editor { position: static; }
  .cols { grid-template-columns: 1fr; }
  .say { grid-template-columns: 1fr; }
  .status { display: none; }
  #channel-list .item { flex-wrap: wrap; }
  #channel-list .item .grow { flex-basis: calc(100% - 3.5rem); }
  .feed .ch { min-width: 0; }
  .chatview.on { height: calc(100vh - 9.5rem); }
}
