:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-lg: 24px; --r-md: 18px; --r-sm: 12px; --r-pill: 999px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --twitch: #a970ff; --youtube: #ff3b4e; --vk: #2f8bff;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f12;
  --glow-a: rgba(200, 245, 96, .07);
  --glow-b: rgba(60, 140, 170, .10);
  --rail: rgba(22, 25, 30, .72);
  --card: rgba(26, 29, 35, .62);
  --card-solid: #171a1f;
  --inset: rgba(255, 255, 255, .045);
  --inset-hover: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .075);
  --text: #eef0f3;
  --muted: #b3b9c2;
  --faint: #979ea8;
  --accent: #c8f560;
  --accent-ink: #15200a;
  --accent-text: #c8f560;
  --pill: #f4f5f7; --pill-ink: #0d0f12;
  --danger: #ff5a5f; --danger-soft: rgba(255, 90, 95, .12);
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .25);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #e9ecf0;
  --glow-a: rgba(160, 210, 40, .16);
  --glow-b: rgba(70, 150, 190, .14);
  --rail: rgba(255, 255, 255, .7);
  --card: rgba(255, 255, 255, .72);
  --card-solid: #ffffff;
  --inset: rgba(16, 20, 28, .045);
  --inset-hover: rgba(16, 20, 28, .08);
  --line: rgba(16, 20, 28, .09);
  --text: #12151a;
  --muted: #4b525c;
  --faint: #5f6671;
  --accent: #c8f560;
  --accent-ink: #15200a;
  --accent-text: #4a6a00;
  --pill: #12151a; --pill-ink: #ffffff;
  --danger: #d92d3a; --danger-soft: rgba(217, 45, 58, .1);
  --shadow: 0 18px 40px -20px rgba(30, 40, 60, .35), 0 2px 6px rgba(30, 40, 60, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font);
  color: var(--text);
  background:
    radial-gradient(60vw 50vh at 85% -10%, var(--glow-b), transparent 70%),
    radial-gradient(50vw 50vh at 10% 110%, var(--glow-a), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled, button[aria-disabled="true"] { cursor: not-allowed; }
[hidden] { display: none !important; }
a { color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app { display: grid; grid-template-columns: 72px 1fr; height: 100dvh; gap: 14px; padding: 14px; }

/* rail */
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0;
  background: var(--rail); border: 1px solid var(--line); border-radius: var(--r-lg);
  backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
}
.logo { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); margin-bottom: 10px; }
.logo svg { width: 22px; height: 22px; stroke-width: 2.2; }
.rail a {
  position: relative; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--muted);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.rail a:hover { background: var(--inset-hover); color: var(--text); }
.rail a[aria-current="page"] { background: var(--pill); color: var(--pill-ink); }
.rail .tip {
  position: absolute; left: 54px; white-space: nowrap; padding: 6px 10px; border-radius: 10px; font-size: 12px;
  background: var(--card-solid); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; transform: translateX(-4px); pointer-events: none; transition: opacity .15s, transform .15s var(--ease); z-index: 5;
}
.rail a:hover .tip, .rail a:focus-visible .tip { opacity: 1; transform: none; }
.rail .sep { width: 24px; height: 1px; background: var(--line); margin: 6px 0; }
.rail .me { margin-top: auto; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: linear-gradient(135deg, #3a4a2a, #23304a); color: #e8f5cf; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* main */
.main { display: grid; grid-template-rows: auto 1fr; gap: 14px; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.channel { display: flex; align-items: center; gap: 12px; min-width: 0; }
.channel h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statuses { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--inset); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.chip .pf { width: 14px; height: 14px; border-radius: 4px; }
.chip .pf svg { width: 9px; height: 9px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dot.bad { background: var(--danger); }
.dot.wait { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.spacer { flex: 1; }
.iconbtn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); color: var(--muted); transition: color .15s, background .15s; flex: none; }
.iconbtn:hover { color: var(--text); background: var(--inset-hover); }
.theme-dark-only, [data-theme="light"] .theme-light-hide { display: none; }
[data-theme="light"] .theme-dark-only { display: block; }

.work { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 420px); gap: 14px; min-height: 0; }
.col { display: flex; flex-direction: column; gap: 14px; min-height: 0; min-width: 0; overflow: auto; }
.page { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; max-width: 980px; width: 100%; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.15); -webkit-backdrop-filter: blur(22px) saturate(1.15);
}
.section { padding: 18px; display: grid; gap: 14px; }
.section h2 { margin: 0; font-size: 15px; font-weight: 650; }
.section .lead { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* segmented */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--inset); border: 1px solid var(--line); }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--r-pill); font-size: 12.5px; color: var(--muted); transition: background .18s var(--ease), color .18s var(--ease); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--pill); color: var(--pill-ink); font-weight: 600; }

/* platform marks */
.pf { width: 16px; height: 16px; border-radius: 5px; display: inline-grid; place-items: center; flex: none; color: #fff; }
.pf svg { width: 11px; height: 11px; fill: currentColor; stroke: none; }
.pf.twitch { background: var(--twitch); } .pf.youtube { background: var(--youtube); } .pf.vk { background: var(--vk); }

/* player */
.player { padding: 12px; }
.screen { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: #07080a; }
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.screen .placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; color: #c9ced6; }
.screen .placeholder p { margin: 0; max-width: 36ch; }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 12px 4px 2px; flex-wrap: wrap; }
.player-bar .note { flex: 1 1 200px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: transform .12s var(--ease), background .15s, opacity .15s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.solid { background: var(--pill); color: var(--pill-ink); }
.btn.ghost { background: var(--inset); border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--inset-hover); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn svg.i { width: 16px; height: 16px; }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-head { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.chat-head .row { display: flex; align-items: center; gap: 8px; }
.chat-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.modes { display: flex; gap: 6px; flex-wrap: wrap; }
.mode { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; color: var(--muted); background: var(--inset); border: 1px solid var(--line); transition: background .15s, color .15s; }
.mode[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 600; }
.mode[aria-disabled="true"] { opacity: .45; }
.feed { flex: 1; overflow: auto; padding: 8px 8px 4px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.msg { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 8px 10px; border-radius: 14px; transition: background .15s; }
.msg:hover, .msg:focus-within { background: var(--inset); }
.msg .pf { margin-top: 2px; }
.msg .who { font-weight: 650; font-size: 13px; overflow-wrap: anywhere; }
.msg .who .role { white-space: nowrap; font-weight: 500; font-size: 11px; color: var(--faint); margin-left: 6px; }
.msg .time { font-size: 11px; color: var(--faint); margin-left: 6px; font-weight: 400; }
.msg p { margin: 1px 0 0; overflow-wrap: anywhere; }
.msg.gone p { color: var(--faint); font-style: italic; }
.acts { position: absolute; top: 6px; right: 8px; display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--card-solid); border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; transform: translateY(2px); transition: opacity .15s, transform .15s var(--ease); pointer-events: none; }
.msg:hover .acts, .msg:focus-within .acts { opacity: 1; transform: none; pointer-events: auto; }
.acts button { width: 30px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.acts button:hover { background: var(--inset-hover); color: var(--text); }
.acts button.ban:hover { background: var(--danger-soft); color: var(--danger); }
.acts button[aria-disabled="true"] { opacity: .35; }
.acts svg.i { width: 16px; height: 16px; }
.composer { padding: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.composer .field { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 18px; background: var(--inset); border: 1px solid var(--line); }
.composer .field:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.composer .iconbtn { width: 36px; height: 36px; }
.composer input[type="text"] { flex: 1; border: 0; outline: 0; background: none; min-width: 0; height: 32px; }
.composer input::placeholder { color: var(--faint); }
.composer .opts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.note { font-size: 11.5px; color: var(--faint); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.newer { position: sticky; bottom: 4px; align-self: center; margin-top: auto; }

/* lists: team, audit, settings */
.rows { display: grid; gap: 2px; }
.rowi { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--inset); flex-wrap: wrap; }
.rowi + .rowi { margin-top: 4px; }
.rowi .grow { flex: 1 1 220px; min-width: 0; }
.rowi .title { font-weight: 600; overflow-wrap: anywhere; }
.rowi .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rowi.off { opacity: .55; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 4px; border-radius: var(--r-pill); font-size: 11.5px; background: var(--card-solid); border: 1px solid var(--line); color: var(--muted); }
.tag .pf { width: 14px; height: 14px; border-radius: 4px; }
.tag .pf svg { width: 9px; height: 9px; }
.tag.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); padding-left: 8px; }
.tag.ok { color: var(--accent-text); padding-left: 8px; }
select, .input {
  height: 34px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card-solid); color: var(--text); min-width: 0;
}
.input { flex: 1 1 260px; }
.input[readonly] { color: var(--muted); }
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; padding: 4px 2px; font-size: 13px; }
.role-card { display: grid; gap: 10px; padding: 14px; border-radius: var(--r-md); background: var(--inset); }
.role-card .head .input { flex: 0 1 260px; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.audit-time { font-size: 12px; color: var(--faint); min-width: 92px; }
.err { color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--r-pill); background: var(--pill); color: var(--pill-ink); font-weight: 600; font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s var(--ease); z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.bad { background: var(--danger); color: #fff; }
.toast button { text-decoration: underline; font-weight: 700; }

button.channel { text-align: left; color: inherit; padding: 4px 10px 4px 4px; margin-left: -4px; border-radius: var(--r-sm); transition: background .15s; }
button.channel:hover { background: var(--inset); }

/* popovers: profile and timeout menu */
.pop {
  margin: 0; inset: auto; width: min(300px, calc(100vw - 24px)); padding: 14px; display: none; gap: 10px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card-solid); color: var(--text); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s var(--ease), display .15s allow-discrete, overlay .15s allow-discrete;
}
.pop:popover-open { display: grid; opacity: 1; transform: none; }
@starting-style { .pop:popover-open { opacity: 0; transform: translateY(-4px); } }
.pop-title { font-weight: 650; font-size: 13.5px; overflow-wrap: anywhere; }
.pop .note { margin: -4px 0 0; }
.pop .rowi { padding: 8px 10px; }
.pop .rowi .grow { flex-basis: 0; }
.pop.profile { top: 64px; left: 78px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.presets .btn { padding: 0; }
.custom { display: flex; gap: 6px; }
.custom .input { flex: 1 1 auto; width: 0; }

/* stream title and category */
.stream-form { display: grid; gap: 14px; }
.stream-form > div { display: grid; gap: 8px; justify-items: start; }
.stream-form .input, .stream-form select { width: 100%; }
.field-label { color: var(--muted); font-size: 13px; }
.stream .meta.error { color: var(--danger); }
.targets { display: flex; gap: 8px 14px; flex-wrap: wrap; }
.chip.picked { padding: 4px 4px 4px 12px; height: auto; min-height: 30px; white-space: normal; max-width: 100%; color: var(--text); }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; width: 22px; height: 22px; border-radius: 50%; }
.chip-x:hover { background: var(--inset-hover); color: var(--text); }
.found { display: grid; gap: 6px; }
.found-head { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.found-list { display: flex; gap: 6px; flex-wrap: wrap; max-height: 148px; overflow: auto; }
.found-list .btn { height: auto; min-height: 30px; padding: 5px 12px; white-space: normal; text-align: left; max-width: 100%; }

.tabbar { display: none; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(420px, 100%); padding: 28px; display: grid; gap: 18px; }
.login h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.login p { margin: 0; color: var(--muted); }
.login .brand { display: flex; align-items: center; gap: 12px; }
.login .providers { display: grid; gap: 8px; }
.login .providers .btn { height: 44px; justify-content: flex-start; }
.login .msg-box { padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; background: var(--inset); color: var(--muted); }
.login .msg-box.bad { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1100px) {
  .work { grid-template-columns: 1fr; }
  .col { overflow: visible; min-height: auto; }
  .main { overflow: auto; }
  .chat { height: 70vh; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding: 10px 10px calc(86px + env(safe-area-inset-bottom)); gap: 10px; height: auto; min-height: 100dvh; }
  .rail { display: none; }
  .main { overflow: visible; }
  .top { flex-wrap: wrap; }
  .top .statuses { order: 9; width: 100%; }
  .channel .sub { display: none; }
  .channel h1 { font-size: 16px; }
  .chat { height: calc(100dvh - 140px); }
  .page { overflow: visible; }
  .composer input[type="text"], .custom .input { font-size: 16px; }
  .pop.profile { top: 56px; left: 10px; }
  .acts { opacity: 1; transform: none; position: static; margin-top: 6px; width: max-content; grid-column: 2; box-shadow: none; pointer-events: auto; }
  .msg:not(:focus-within) .acts { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 10;
    justify-content: space-around; padding: 6px; border-radius: 22px; background: var(--rail); border: 1px solid var(--line); box-shadow: var(--shadow);
    backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
  }
  .tabbar a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 16px; font-size: 11px; color: var(--muted); text-decoration: none; }
  .tabbar a[aria-current="page"] { background: var(--pill); color: var(--pill-ink); font-weight: 600; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (hover: none) {
  .msg:hover { background: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}
