:root {
  --bg-main: #121522;
  --bg-main-2: #161a28;
  --sidebar: #171b29;
  --sidebar-2: #1a2030;
  --panel: #1b2130;
  --panel-2: #1e2433;
  --line: #2b3347;
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #d6ddef;
  --text-strong: #eef3ff;
  --muted: #96a3bf;
  --blue-1: #3f67bc;
  --blue-2: #2f4f93;
  --blue-soft: #263655;
  --green-soft: #28483f;
  --green-text: #98dfbf;
  --red-soft: #583641;
  --red-text: #efbac6;
  --amber-soft: #5a4a2c;
  --amber-text: #f3d696;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-main), var(--bg-main-2));
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

a { color: #9dbbff; text-decoration: none; }
a:hover { color: #c9dbff; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid #9ec2ff;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(36, 54, 90, 0.9);
}

.skip-link {
  position: fixed;
  top: -48px;
  left: 14px;
  z-index: 1200;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(157, 192, 255, 0.72);
  background: rgba(24, 40, 68, 0.96);
  color: #edf4ff;
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.01em;
  transition: top 0.16s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 10px;
}

#app {
  height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-width: 0;
}

#sidebar {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  min-width: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-strong);
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.06);
}

.side-nav,
.side-footer-links {
  display: grid;
  gap: 4px;
}

.side-nav a,
.side-footer-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  border: 1px solid transparent;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}

.nav-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 3px;
  background: #95a4c4;
  opacity: 0.95;
  flex: 0 0 14px;
}

.nav-icon-dashboard {
  clip-path: polygon(50% 0%, 100% 38%, 100% 100%, 0% 100%, 0% 38%);
}

.nav-icon-commands {
  clip-path: polygon(0 16%, 84% 16%, 84% 0, 100% 0, 100% 100%, 0 100%);
}

.nav-icon-socials {
  clip-path: polygon(12% 0, 88% 0, 100% 24%, 100% 76%, 88% 100%, 12% 100%, 0 76%, 0 24%);
}

.nav-label {
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.side-nav a:hover,
.side-footer-links a:hover {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--line-soft);
}

.side-nav a.active {
  background: linear-gradient(180deg, rgba(58, 94, 170, 0.74), rgba(45, 72, 128, 0.76));
  border-color: rgba(121, 153, 224, 0.52);
  color: #f0f5ff;
}

.side-nav a.active .nav-icon {
  background: #eaf1ff;
}

.side-spacer { flex: 1; }

.account-dock {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 36, 0.9);
}

.account-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 8px;
  cursor: pointer;
}

.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #243651;
}

.account-meta { min-width: 0; flex: 1; }

.account-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-subline {
  color: var(--muted);
  font-size: 0.76rem;
}

.account-caret {
  color: var(--muted);
  font-size: 0.82rem;
}

.account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #161d2b;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.44);
  z-index: 35;
}

.account-list {
  display: grid;
  gap: 5px;
  max-height: min(36vh, 228px);
  overflow: auto;
  padding: 8px;
}

.account-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font-weight: 600;
  text-align: left;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.account-item:hover { border-color: var(--line); }

.account-item.active {
  border-color: rgba(118, 150, 220, 0.5);
  background: linear-gradient(180deg, rgba(56, 86, 146, 0.74), rgba(45, 66, 112, 0.68));
}

.account-item.state-reauth { border-color: rgba(231, 132, 132, 0.35); }
.account-item.state-enable { border-color: rgba(220, 185, 110, 0.35); }
.account-item.state-detached { border-color: rgba(229, 149, 149, 0.3); }
.account-item.state-healthy { border-color: rgba(110, 198, 153, 0.28); }

.account-item-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  object-fit: cover;
  background: #243651;
  flex: 0 0 auto;
}

.account-item-fallback {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: #243651;
  color: #dce6fb;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.account-item-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-item-text {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 2px;
}

.account-item-title {
  min-width: 0;
  font-weight: 700;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-item-subline {
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-item-status-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-top: 3px;
  min-height: 20px;
}

.account-item-state {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Legacy safety: if any route still appends a status chip into subline content,
   force it onto a centered third-row presentation instead of overlapping text. */
.account-item-subline .account-item-state {
  display: flex;
  width: max-content;
  max-width: 100%;
  margin-top: 4px;
  margin-left: 0;
  margin-right: 0;
}

.account-item-state.state-healthy {
  color: #d8ffe8;
  background: rgba(66, 164, 119, 0.24);
  border-color: rgba(95, 197, 149, 0.42);
}

.account-item-state.state-detached {
  color: #ffdede;
  background: rgba(171, 89, 89, 0.24);
  border-color: rgba(214, 130, 130, 0.42);
}

.account-item-state.state-enable {
  color: #ffe9be;
  background: rgba(198, 157, 74, 0.24);
  border-color: rgba(226, 186, 106, 0.42);
}

.account-item-state.state-reauth {
  color: #ffd6d6;
  background: rgba(173, 80, 80, 0.26);
  border-color: rgba(229, 134, 134, 0.46);
}

.account-actions {
  border-top: 1px solid var(--line);
  padding: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.account-action-link {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(145, 173, 236, 0.45);
  background: rgba(49, 74, 126, 0.34);
  color: #deebff;
  padding: 8px 10px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  white-space: nowrap;
}

.account-action-link:hover {
  border-color: rgba(145, 173, 236, 0.62);
  filter: brightness(1.05);
}

.help-recommended-cta {
  cursor: pointer;
  justify-content: center;
  font-size: 1.04rem;
  padding: 11px 12px;
  box-shadow: 0 0 0 1px rgba(157, 191, 255, 0.12) inset;
}

.help-state-banner {
  border: 1px solid rgba(120, 166, 236, 0.45);
  background: linear-gradient(180deg, rgba(27, 48, 82, 0.52), rgba(18, 33, 58, 0.64));
  border-radius: 10px;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 24px rgba(7, 15, 31, 0.32);
}

.help-state-banner.ok {
  border-color: rgba(86, 194, 143, 0.5);
  background: linear-gradient(180deg, rgba(19, 63, 49, 0.52), rgba(16, 45, 36, 0.64));
}

.help-state-banner.warn {
  border-color: rgba(220, 185, 110, 0.56);
  background: linear-gradient(180deg, rgba(79, 60, 28, 0.52), rgba(54, 41, 21, 0.66));
}

.help-state-banner.critical {
  border-color: rgba(231, 132, 132, 0.6);
  background: linear-gradient(180deg, rgba(95, 42, 42, 0.56), rgba(63, 30, 30, 0.68));
  box-shadow: 0 0 0 1px rgba(231, 132, 132, 0.18) inset, 0 14px 28px rgba(58, 20, 20, 0.34);
}

.help-state-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(109, 160, 242, 0.22);
  color: #d6e8ff;
  border: 1px solid rgba(128, 174, 240, 0.42);
}

.help-state-banner.ok .help-state-badge {
  background: rgba(76, 177, 130, 0.24);
  color: #d8ffe8;
  border-color: rgba(95, 197, 149, 0.42);
}

.help-state-banner.warn .help-state-badge {
  background: rgba(198, 157, 74, 0.26);
  color: #ffe9be;
  border-color: rgba(226, 186, 106, 0.46);
}

.help-state-banner.critical .help-state-badge {
  background: rgba(176, 82, 82, 0.28);
  color: #ffdada;
  border-color: rgba(230, 135, 135, 0.52);
}

.help-state-tone {
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  justify-self: end;
}

.help-state-summary {
  font-size: 1.03rem;
  line-height: 1.36;
  font-weight: 700;
  color: #dce9ff;
  min-width: 0;
}

.help-state-banner.critical .help-state-summary {
  color: #ffe1e1;
}

.help-state-banner.warn .help-state-summary {
  color: #f6e7c8;
}

.help-recommended-cta.warm {
  box-shadow: 0 0 0 1px rgba(243, 214, 150, 0.22) inset, 0 0 0 2px rgba(112, 88, 45, 0.28);
}

.help-recommended-cta.attention {
  box-shadow: 0 0 0 1px rgba(243, 214, 150, 0.26) inset, 0 0 0 2px rgba(112, 88, 45, 0.34), 0 8px 22px rgba(39, 28, 12, 0.3);
}

.help-recommended-cta:disabled {
  cursor: default;
  opacity: 0.72;
  filter: none;
}

.account-action-link.warm {
  border-color: rgba(241, 197, 100, 0.46);
  background: rgba(89, 70, 34, 0.42);
  color: var(--amber-text);
}

.danger-button {
  width: 100%;
  border-radius: 7px;
  border: 1px solid rgba(230, 146, 167, 0.42);
  background: rgba(143, 71, 88, 0.34);
  color: #ffdfe6;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.danger-button:hover { filter: brightness(1.06); }
.danger-button:disabled { opacity: 0.55; cursor: not-allowed; }

.side-footer {
  color: var(--muted);
  font-size: 0.8rem;
  display: grid;
  gap: 4px;
  padding: 0 4px;
}

#shell {
  min-width: 0;
}

#main {
  height: 100vh;
  min-width: 0;
  padding: 18px 20px;
  display: grid;
  gap: 14px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#topbar h1 {
  margin: 0;
  font-size: 2rem;
  color: var(--text-strong);
}

#topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.bot-status-dock {
  position: relative;
  min-width: 0;
  --status-dock-width: 228px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.admin-status-dock {
  width: var(--status-dock-width);
  max-width: 100%;
}

.bot-status-control {
  position: relative;
  width: var(--status-dock-width);
  max-width: 100%;
}

#adminView {
  min-height: 100%;
  display: block;
  min-width: 0;
}

.admin-subnav-row {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 2px 2px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(120, 144, 189, 0.2);
  background: linear-gradient(180deg, rgba(8, 14, 27, 0.94) 0%, rgba(8, 14, 27, 0.78) 75%, rgba(8, 14, 27, 0) 100%);
}

.admin-subnav {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-subnav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(30, 43, 69, 0.5);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
}

.admin-subnav-link:hover {
  color: #dce8ff;
}

.admin-subnav-link.active {
  border-color: rgba(106, 150, 228, 0.62);
  background: rgba(58, 91, 147, 0.62);
  color: #eff4ff;
}

.admin-view-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
  min-width: 0;
}

.admin-view-grid > .admin-section {
  display: none;
}

.admin-view-grid > .admin-section.active {
  display: block;
}

.admin-span-12 { grid-column: span 12; }
.admin-span-8 { grid-column: span 8; }
.admin-span-6 { grid-column: span 6; }
.admin-span-4 { grid-column: span 4; }

.topbar-version-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, var(--status-dock-width));
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(123, 159, 227, 0.45);
  background: rgba(34, 53, 92, 0.58);
  color: #d7e7ff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bot-status-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  width: var(--status-dock-width);
  max-width: 100%;
  min-width: 0;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: #dce6fb;
  overflow: hidden;
}
.bot-status-button[disabled],
.bot-status-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.62;
}
.bot-status-button[disabled] .caret,
.bot-status-button.is-disabled .caret {
  opacity: 0.5;
}

#botStatusLabel {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.bot-status-button .caret {
  flex: 0 0 auto;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.bot-status-button.online {
  color: #b8f5d9;
  border-color: rgba(116, 218, 174, 0.58);
  background: linear-gradient(180deg, rgba(20, 65, 50, 0.95), rgba(16, 46, 38, 0.95));
}

.dot.online {
  background-color: #47d89a;
  box-shadow: 0 0 0 3px rgba(71, 216, 154, 0.16);
}

.bot-status-button.syncing {
  color: var(--amber-text);
  border-color: rgba(241, 197, 100, 0.42);
  background: linear-gradient(180deg, rgba(85, 68, 35, 0.9), rgba(65, 53, 27, 0.9));
}

.dot.syncing {
  background-color: #e0b868;
}

.bot-status-button.offline {
  color: #bdcbe0;
  border-color: rgba(178, 194, 221, 0.38);
  background: linear-gradient(180deg, rgba(66, 76, 95, 0.9), rgba(53, 61, 77, 0.9));
}

.dot.offline {
  background-color: #93a0b9;
}

.bot-status-button.detached {
  color: var(--red-text);
  border-color: rgba(240, 155, 178, 0.45);
  background: linear-gradient(180deg, rgba(102, 52, 67, 0.92), rgba(83, 42, 55, 0.92));
}

.dot.detached {
  background-color: #e58fa7;
}

.bot-status-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #161d2b;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  padding: 8px;
  display: grid;
  gap: 6px;
  z-index: 30;
}

.bot-status-menu button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.bot-status-menu button.warm {
  border-color: rgba(241, 197, 100, 0.46);
  background: rgba(89, 70, 34, 0.42);
  color: var(--amber-text);
}

.bot-status-menu button.danger {
  border: 1px solid rgba(230, 146, 167, 0.42);
  background: rgba(143, 71, 88, 0.34);
  color: #ffdfe6;
}

.bot-status-menu button.info {
  border-color: rgba(145, 173, 236, 0.48);
  background: rgba(49, 74, 126, 0.4);
  color: #deebff;
}

.menu-action-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  background: #9fb0cf;
  box-shadow: 0 0 0 3px rgba(159, 176, 207, 0.14);
}

.menu-action-icon.warm {
  background: #e0b868;
  box-shadow: 0 0 0 3px rgba(224, 184, 104, 0.2);
}

.menu-action-icon.danger {
  background: #e58fa7;
  box-shadow: 0 0 0 3px rgba(229, 143, 167, 0.2);
}

.menu-action-icon.info {
  background: #8db1f0;
  box-shadow: 0 0 0 3px rgba(141, 177, 240, 0.2);
}

.auth-reauth-modal {
  position: absolute;
  inset: 0;
  z-index: 24;
  background: rgba(7, 11, 22, 0.74);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(86px, 12vh, 132px) 24px 24px;
  border-radius: 10px;
}

#contentFrame.route-blocked .view.active {
  display: none !important;
}

.auth-reauth-modal.route-blocked-shell {
  position: absolute;
  inset: 0;
  z-index: 24;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(86px, 12vh, 132px) 24px 24px;
  border-radius: 0;
}

.auth-reauth-modal.route-blocked-shell .auth-reauth-card {
  width: min(560px, 100%);
  margin: 0;
}

.auth-reauth-card {
  width: min(560px, 100%);
  border: 1px solid rgba(240, 173, 127, 0.58);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(37, 51, 82, 0.95), rgba(22, 31, 54, 0.97));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  padding: 18px 18px 16px;
  display: grid;
  gap: 10px;
}

.auth-reauth-badge {
  justify-self: start;
  border-radius: 999px;
  border: 1px solid rgba(242, 191, 150, 0.62);
  background: rgba(130, 81, 44, 0.42);
  color: #ffe6d0;
  padding: 4px 10px;
  font-size: 0.73rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 800;
}

.auth-reauth-card h2 {
  margin: 0;
  font-size: 1.22rem;
}

.auth-reauth-card p {
  margin: 0;
  color: #c6d4ec;
  line-height: 1.45;
}

.auth-reauth-button {
  border: 1px solid rgba(245, 196, 146, 0.6);
  background: rgba(233, 169, 108, 0.22);
  color: #fff1e3;
  border-radius: 8px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  cursor: pointer;
}

.auth-reauth-button:hover {
  filter: brightness(1.09);
}

.auth-reauth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-reauth-disconnect {
  border-color: rgba(230, 146, 167, 0.45);
  background: rgba(143, 71, 88, 0.34);
  color: #ffdfe6;
}

.auth-reauth-footnote {
  font-size: 0.78rem;
  color: #9bb1d4;
}

.auth-reauth-retry {
  border: 1px solid rgba(128, 166, 232, 0.45);
  border-radius: 8px;
  background: rgba(36, 58, 95, 0.36);
  color: #cbdcf8;
  font-size: 0.8rem;
  padding: 7px 9px;
}

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.panel-head {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-head h3 { margin: 0; }

.panel-status {
  color: var(--muted);
  font-size: 0.8rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(58%, 420px);
}

.panel-status.info {
  color: #d4e4ff;
  border-color: rgba(136, 171, 239, 0.5);
  background: rgba(48, 74, 128, 0.35);
}

.panel-status.success {
  color: #c5f8df;
  border-color: rgba(123, 223, 181, 0.55);
  background: rgba(29, 87, 65, 0.35);
}

.panel-status.error {
  color: #ffdce5;
  border-color: rgba(244, 157, 182, 0.55);
  background: rgba(129, 47, 68, 0.36);
}

.panel-status.loading {
  color: var(--amber-text);
  border-color: rgba(241, 197, 100, 0.42);
  background: rgba(90, 74, 44, 0.35);
}

.panel-body {
  padding: 14px;
  min-height: 0;
  min-width: 0;
}

#contentFrame {
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  position: relative;
}

#contentFrame.content-frame--admin {
  padding-right: 4px;
}

#contentFrame.content-frame--logs {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.view {
  display: none;
  height: 100%;
  min-height: 0;
}

.view.active { display: block; }

.logs-view.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.logs-view > .logs-panel {
  flex: 1 1 auto;
}

.logs-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.logs-panel .panel-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 1080px) {
  #contentFrame.content-frame--logs {
    display: block;
  }

  .logs-view.active {
    display: block;
    min-height: 0;
    height: auto;
  }

  .logs-panel,
  .logs-panel .panel-body {
    height: auto;
    min-height: 0;
    display: block;
  }
}

@media (max-width: 900px) {
  #app.app--logs {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  #main.main--logs {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  #contentFrame.content-frame--logs {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  .logs-view.active,
  .logs-panel,
  .logs-panel .panel-body {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }
}

.socials-panel {
  height: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.chat-view-panel {
  height: 100%;
  max-width: 100%;
  width: 100%;
  margin: 0;
}

.chat-view-panel .panel-body {
  display: grid;
  gap: 12px;
  align-content: start;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
}

.view-grid {
  height: auto;
  min-height: 0;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas:
    "channel channel"
    "chat chat"
    "streams controls";
  align-content: start;
  min-width: 0;
}

.quota-restriction-banner {
  border: 1px solid rgba(230, 171, 117, 0.58);
  background: linear-gradient(180deg, rgba(79, 57, 31, 0.46), rgba(49, 36, 24, 0.62));
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: grid;
  gap: 6px;
}

.quota-restriction-banner.warn {
  border-color: rgba(231, 188, 122, 0.62);
}

.quota-restriction-banner.info {
  border-color: rgba(117, 170, 236, 0.62);
  background: linear-gradient(180deg, rgba(33, 54, 88, 0.5), rgba(23, 40, 70, 0.64));
}

.quota-restriction-banner.error {
  border-color: rgba(231, 132, 132, 0.62);
  background: linear-gradient(180deg, rgba(98, 46, 46, 0.45), rgba(61, 31, 31, 0.62));
}

.quota-restriction-title {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #ffe6bc;
}

.quota-restriction-banner.error .quota-restriction-title {
  color: #ffd4d4;
}

.quota-restriction-banner.info .quota-restriction-title {
  color: #d3e7ff;
}

.quota-restriction-summary {
  color: #d8e4ff;
  font-size: 0.92rem;
}

.quota-restriction-list {
  margin: 0;
  padding-left: 18px;
  color: #c9d9f8;
  font-size: 0.86rem;
  line-height: 1.35;
}

.channel-panel { grid-area: channel; }
#chatControlsPanel { grid-area: chat; }
#streamsPanel { grid-area: streams; }
#controlsColumn {
  grid-area: controls;
  min-height: 0;
  min-width: 0;
  overflow: visible;
}

#controlsPanel {
  min-height: 0;
  min-width: 0;
}

#streamsPanel .panel-body {
  flex: 1 1 auto;
  min-height: 0;
}

#controlsPanel .panel-body {
  overflow: visible;
  min-width: 0;
}

#chatControlsPanel .panel-body {
  overflow: visible;
  min-width: 0;
}

.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
}

.channel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.channel-header img {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #243651;
}

.channel-header h2 { margin: 0; }

.metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 10px;
}

.metric {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  padding: 7px;
  min-width: 0;
}

.metric .label { color: var(--muted); font-size: 0.76rem; }
.metric .value {
  margin-top: 3px;
  font-weight: 700;
  min-width: 0;
}

.metric-handle {
  grid-column: span 2;
}

.metric-handle .value {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#channelId {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#streams {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.stream-row {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.stream-thumb-link {
  display: block;
  text-decoration: none;
}

.stream-thumb-link[aria-disabled="true"] {
  pointer-events: none;
}

.stream-thumb {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line-soft);
  display: block;
}

.stream-thumb-fallback {
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
}

.stream-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.stream-meta-top,
.stream-meta-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stream-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-time {
  color: var(--muted);
  font-size: 0.78rem;
}

.stream-chat {
  font-size: 0.74rem;
  font-weight: 600;
}

.stream-chat.ready { color: #93e0c2; }
.stream-chat.missing { color: #c8d4e7; }

.stream-prelive,
.stream-pin-indicator,
.stream-monitor-indicator {
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px 8px;
}

.stream-prelive.ready {
  color: #9de6c8;
  border-color: rgba(147, 224, 194, 0.44);
}

.stream-prelive.window {
  color: #f3d696;
  border-color: rgba(241, 197, 100, 0.42);
}

.stream-prelive.idle {
  color: #bdcbe0;
}

.stream-pin-indicator {
  color: #b7d1ff;
  border-color: rgba(117, 154, 231, 0.42);
}

.stream-monitor-indicator {
  color: #c9f7df;
  border-color: rgba(132, 225, 181, 0.5);
  background: rgba(32, 93, 70, 0.34);
}

.stream-monitor-indicator.prelive {
  color: #f6e1aa;
  border-color: rgba(241, 197, 100, 0.46);
  background: rgba(114, 82, 36, 0.34);
}

.stream-debug-wrap {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.stream-debug-toggle {
  justify-self: start;
  border: 1px solid rgba(122, 150, 208, 0.5);
  background: rgba(47, 66, 105, 0.45);
  color: #d4e3ff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.73rem;
  font-weight: 700;
}

.stream-debug-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.stream-debug-panel {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  padding: 8px;
}

.stream-debug-grid {
  display: grid;
  gap: 4px;
}

.stream-debug-row {
  display: grid;
  grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 0.74rem;
  line-height: 1.35;
}

.stream-debug-key {
  color: #9eb2d7;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.stream-debug-value {
  color: #d8e4fa;
  overflow-wrap: anywhere;
}

.stream-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.stream-open-link {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 10px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-open-link[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.5;
}

.stream-pin-button {
  border: 1px solid rgba(117, 154, 231, 0.45);
  background: rgba(45, 67, 116, 0.52);
  color: #dfe9ff;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-pin-button.active {
  border-color: rgba(241, 197, 100, 0.5);
  background: rgba(90, 74, 44, 0.45);
  color: #ffe9b9;
}

.stream-delete-button {
  border: 1px solid rgba(226, 124, 124, 0.48);
  background: rgba(126, 48, 48, 0.42);
  color: #ffd9d9;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-delete-button:hover {
  border-color: rgba(235, 138, 138, 0.6);
  background: rgba(138, 53, 53, 0.52);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 700;
}

.status-pill.live { color: #9de6c8; border-color: rgba(147, 224, 194, 0.44); }
.status-pill.upcoming { color: #f3d696; border-color: rgba(241, 197, 100, 0.42); }
.status-pill.offline { color: #bdcbe0; }

.inline-form {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  min-width: 0;
}

.inline-action-form {
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  min-width: 0;
}

.profile-form {
  display: grid;
  gap: 10px;
  min-width: 0;
}

#chatControlsForm {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

#chatControlsForm .profile-subpanel {
  height: 100%;
  align-content: start;
}

.profile-section {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.profile-section-heading {
  margin-bottom: 0;
}

.profile-subpanel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  padding: 10px;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.profile-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  min-width: 0;
}

.prelive-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stream-details-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.socials-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-group input,
.field-group select {
  width: 100%;
  min-width: 0;
}

.field-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a7b4cf;
  font-weight: 700;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.chat-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
}

.chat-toggle-label {
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.chat-toggle-row .toggle {
  flex: 0 0 auto;
}

.support-ack-options {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.support-ack-toggle-row {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 10px;
}

.support-ack-toggle-row .chat-toggle-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.support-ack-options.is-disabled .support-ack-toggle-row,
.support-ack-toggle-row.is-disabled {
  opacity: 0.5;
  border-color: rgba(122, 135, 161, 0.24);
  background: rgba(34, 41, 57, 0.42);
}

.support-ack-options.is-disabled .support-ack-toggle-row .chat-toggle-label,
.support-ack-toggle-row.is-disabled .chat-toggle-label {
  color: #8e99b0;
}

.support-ack-options.is-disabled .support-ack-toggle-row .toggle,
.support-ack-toggle-row.is-disabled .toggle {
  pointer-events: none;
}

.support-ack-options.is-disabled .support-ack-toggle-row .toggle span,
.support-ack-toggle-row.is-disabled .toggle span {
  background: #4a5160;
}

.support-ack-options.is-disabled .support-ack-toggle-row .toggle input:checked + span,
.support-ack-toggle-row.is-disabled .toggle input:checked + span {
  background: #5f6880;
}

.chat-test-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.chat-activity-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
}

.chat-activity-list {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-activity-empty {
  padding: 10px 12px;
  font-size: 0.84rem;
}

.chat-activity-row {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 108px;
  align-items: start;
  gap: 10px;
}

.chat-activity-row:last-child {
  border-bottom: 0;
}

.chat-activity-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.chat-activity-author {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.chat-activity-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(118, 153, 220, 0.4);
  background: rgba(20, 31, 58, 0.86);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.chat-activity-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-activity-avatar-fallback {
  font-size: 0.72rem;
  font-weight: 700;
  color: #e3ecff;
  line-height: 1;
}

.chat-activity-author-name {
  font-size: 0.82rem;
  color: #e0e9ff;
  font-weight: 700;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-activity-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.chat-activity-badge {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.chat-activity-badge.owner {
  color: #d7f0ff;
  border-color: rgba(119, 184, 230, 0.55);
  background: rgba(43, 73, 94, 0.42);
}

.chat-activity-badge.mod {
  color: #d7ffea;
  border-color: rgba(113, 209, 157, 0.55);
  background: rgba(36, 89, 68, 0.38);
}

.chat-activity-badge.member {
  color: #fff2bf;
  border-color: rgba(234, 198, 98, 0.52);
  background: rgba(98, 78, 38, 0.4);
}

.chat-activity-badge.verified {
  color: #d9e7ff;
  border-color: rgba(126, 162, 233, 0.52);
  background: rgba(50, 72, 114, 0.38);
}

.chat-activity-time {
  width: 92px;
  font-size: 0.76rem;
  color: #b0c2e2;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  align-self: center;
}

.chat-activity-type {
  width: 108px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
  justify-self: end;
  align-self: center;
  white-space: nowrap;
}

.chat-activity-type.chat {
  color: #b8cbef;
  border-color: rgba(121, 154, 214, 0.45);
  background: rgba(45, 62, 97, 0.34);
}

.chat-activity-type.reward {
  color: #ffe1a9;
  border-color: rgba(237, 189, 97, 0.5);
  background: rgba(92, 72, 35, 0.34);
}

.chat-activity-type.mod {
  color: #ffd4de;
  border-color: rgba(234, 142, 169, 0.5);
  background: rgba(117, 52, 76, 0.34);
}

.chat-activity-message {
  font-size: 0.84rem;
  line-height: 1.35;
  color: #dce8ff;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  min-width: 0;
}

.chat-test-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-test-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.chat-test-form button {
  min-width: 88px;
}

.chat-test-form button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-unified-status {
  min-height: 28px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  font-size: 0.78rem;
  line-height: 1.25;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-unified-status.connected {
  color: #9de6c8;
  border-color: rgba(147, 224, 194, 0.38);
  background: rgba(40, 92, 69, 0.22);
}

.chat-unified-status.success {
  color: #b8ecce;
  border-color: rgba(147, 224, 194, 0.5);
  background: rgba(26, 84, 59, 0.32);
}

.chat-unified-status.error {
  color: #ffd2df;
  border-color: rgba(231, 134, 165, 0.45);
  background: rgba(113, 47, 72, 0.32);
}

#main.chat-view-active #mainFooter {
  display: none;
}

.readonly-pill {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  min-height: 36px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.prelive-hint {
  font-size: 0.8rem;
  line-height: 1.35;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
}

.subsection {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  min-width: 0;
}

.subheading {
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.subtle-danger {
  border: 1px solid rgba(230, 146, 167, 0.42);
  background: rgba(143, 71, 88, 0.33);
  color: #ffdce5;
  font-size: 0.8rem;
  padding: 6px 9px;
}

.form-status {
  margin-top: 8px;
  margin-bottom: 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 9px 11px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
}

.form-status.error {
  color: #ffdce5;
  background: rgba(129, 47, 68, 0.36);
  border-color: rgba(244, 157, 182, 0.55);
}

.form-status.success {
  color: #c5f8df;
  background: rgba(29, 87, 65, 0.35);
  border-color: rgba(123, 223, 181, 0.55);
}

.form-status.info {
  color: #d4e4ff;
  background: rgba(48, 74, 128, 0.35);
  border-color: rgba(136, 171, 239, 0.5);
}

#targetsList { margin-top: 8px; }
#catchesList { margin-top: 8px; }

#catchesSummary {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
}

.target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px;
  margin-bottom: 6px;
}

.target-row button {
  border: 1px solid rgba(230, 146, 167, 0.42);
  background: rgba(143, 71, 88, 0.33);
  font-size: 0.8rem;
  padding: 5px 8px;
}

.target-row.empty,
.catch-row.empty {
  justify-content: flex-start;
  color: var(--muted);
}

.catch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px;
  margin-bottom: 6px;
}

.catch-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.catch-row button {
  border: 1px solid rgba(230, 146, 167, 0.42);
  background: rgba(143, 71, 88, 0.33);
  font-size: 0.8rem;
  padding: 5px 8px;
}

.catch-row button[data-catch-add],
.catch-row button[data-catch-remove] {
  border: 1px solid rgba(117, 154, 231, 0.45);
  background: rgba(45, 67, 116, 0.52);
}

.catch-row button[data-catch-clear] {
  border: 1px solid rgba(230, 146, 167, 0.42);
  background: rgba(143, 71, 88, 0.33);
}

.commands-panel {
  height: auto;
  padding: 0;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  min-height: 0;
  overflow: visible;
}

.commands-panel .panel-head {
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.commands-panel .panel-head h3 {
  flex: 0 0 auto;
}

.commands-prefix-guide {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.14);
  display: grid;
  gap: 8px;
}

.commands-prefix-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.commands-prefix-title {
  color: var(--text-strong);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.commands-prefix-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.commands-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.commands-toolbar-head {
  width: min(520px, 100%);
  max-width: 100%;
  flex: 0 1 520px;
  padding: 0;
  border-bottom: 0;
  grid-template-columns: minmax(240px, 520px);
  justify-content: end;
}

.commands-toolbar-head .search-input {
  width: 100%;
  display: block;
}

.search-input,
.quick-run input,
input,
select {
  border: 1px solid var(--line);
  background: #171e2d;
  color: var(--text);
  border-radius: 7px;
  padding: 8px 10px;
  font: inherit;
}

.quick-run {
  display: grid;
  grid-template-columns: minmax(130px, 180px) auto;
  gap: 8px;
}

button {
  border: 1px solid rgba(91, 123, 194, 0.55);
  background: linear-gradient(180deg, var(--blue-1), var(--blue-2));
  color: #f2f6ff;
  border-radius: 7px;
  padding: 8px 11px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.commands-table-wrap {
  width: 100%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
}

.commands-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.commands-table th,
.commands-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

.commands-table th {
  color: #d0d9ea;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.15);
}

.commands-table td {
  color: var(--text);
  font-size: 0.92rem;
}

.commands-table tr:hover td { background: rgba(255, 255, 255, 0.01); }

.cmd-name {
  font-weight: 700;
  color: #e8eefb;
}

.cmd-desc {
  color: var(--muted);
  font-size: 0.88rem;
}

.alias-manager {
  display: grid;
  gap: 7px;
}

.alias-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prefix-chip-list {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.prefix-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  border-radius: 999px;
  border: 1px solid rgba(126, 153, 214, 0.42);
  background: rgba(49, 70, 113, 0.55);
  color: #dce8ff;
  padding: 4px 8px;
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 700;
}

.alias-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid rgba(126, 153, 214, 0.42);
  background: rgba(49, 70, 113, 0.55);
  color: #dce8ff;
  padding: 4px 8px;
  font-size: 0.76rem;
  line-height: 1;
}

.alias-chip:hover {
  filter: brightness(1.1);
}

.alias-chip-x {
  color: #b2c4eb;
  font-size: 0.82rem;
}

.alias-add-row {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(110px, 1fr) auto;
  align-items: center;
}

.alias-add-row input {
  width: 100%;
  padding: 6px 7px;
  font-size: 0.84rem;
}

.alias-add-row button {
  padding: 6px 8px;
  font-size: 0.78rem;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.role-badge.everyone {
  background: var(--blue-soft);
  border-color: rgba(144, 173, 237, 0.35);
  color: #c8dcff;
}

.role-badge.moderator {
  background: var(--green-soft);
  border-color: rgba(149, 223, 194, 0.35);
  color: var(--green-text);
}

.role-badge.owner {
  background: var(--red-soft);
  border-color: rgba(240, 187, 201, 0.35);
  color: var(--red-text);
}

.cmd-actions {
  display: inline-grid;
  grid-template-columns: 72px;
  gap: 6px;
  align-items: center;
}

.cmd-actions input[type='number'] {
  width: 72px;
  padding: 6px 7px;
}

.cmd-actions button {
  padding: 6px 8px;
  font-size: 0.78rem;
}

#commandsFormStatus {
  margin-top: 10px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 19px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #5a6274;
  transition: 120ms ease;
}

.toggle span::before {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #f4f6fb;
  transition: 120ms ease;
}

.toggle input:checked + span { background: #4a72c3; }
.toggle input:checked + span::before { transform: translateX(15px); }

.command-response {
  padding: 8px 12px 12px;
  min-height: 20px;
}

#mainFooter {
  border-top: 1px solid var(--line);
  padding: 12px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  flex-wrap: nowrap;
  min-height: 60px;
}

#mainFooter > * {
  display: inline-flex;
  align-items: center;
}

.footer-copy {
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  color: #9aa8c4;
  line-height: 1.35;
}

.footer-links {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  line-height: 1.35;
  flex: 0 0 auto;
}

.footer-links span {
  color: #73819d;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  padding: 2px 0;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

@media (max-width: 1240px) {
  #chatControlsForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "channel"
      "chat"
      "streams"
      "controls";
  }

  #controlsColumn {
    grid-template-rows: auto;
  }

  #streamsPanel .panel-body {
    max-height: 280px;
  }

  #mainFooter {
    flex-wrap: wrap;
  }
}

@media (max-width: 1100px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  #app {
    height: auto;
    grid-template-columns: 1fr;
    max-width: 100vw;
    overflow-x: hidden;
  }

  #sidebar {
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    overflow: visible;
  }

  .side-nav {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(17, 23, 36, 0.9);
  }

  .side-nav a {
    min-width: 0;
    justify-content: center;
    padding: 9px 8px;
    gap: 8px;
  }

  .side-nav .nav-label {
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account-dock,
  .bot-status-dock {
    width: 100%;
  }

  .bot-status-dock {
    max-width: 100%;
    align-items: stretch;
  }

  .admin-status-dock {
    align-items: flex-start;
    width: 100%;
  }

  .topbar-version-pill {
    width: 100%;
  }

  .bot-status-control {
    width: 100%;
    max-width: 100%;
  }

  .account-menu {
    position: static;
    margin: 8px;
    max-height: min(52vh, 420px);
  }

  .bot-status-button {
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
  }

  .bot-status-menu {
    position: static;
    margin-top: 8px;
    width: 100%;
    min-width: 0;
    max-height: min(44vh, 360px);
    overflow: auto;
  }

  .side-spacer,
  .side-footer {
    display: none;
  }

  #main {
    height: auto;
    overflow: visible;
    overflow-x: hidden;
    grid-template-rows: auto auto auto;
    max-width: 100vw;
  }

  #contentFrame,
  .view,
  .view-grid,
  #controlsColumn,
  .commands-panel,
  .chat-view-panel {
    height: auto;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
  }

  #streamsPanel .panel-body {
    max-height: none;
    overflow: visible;
  }

  #topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .commands-toolbar {
    grid-template-columns: 1fr;
  }

  #chatControlsForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .commands-toolbar-head {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
    grid-template-columns: 1fr;
  }

  .commands-panel .panel-head {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .auth-reauth-modal {
    padding: clamp(68px, 10vh, 104px) 14px 14px;
  }

  .auth-reauth-actions {
    width: 100%;
    flex-direction: column;
  }

  .auth-reauth-button {
    width: 100%;
    justify-content: center;
  }

  .commands-table {
    min-width: 0;
  }

  .quick-run {
    grid-template-columns: 1fr auto;
  }

  .inline-action-form {
    grid-template-columns: 1fr auto;
  }

  .inline-action-form button:nth-of-type(2) {
    grid-column: span 2;
    justify-self: start;
  }

  .stream-row {
    grid-template-columns: 136px minmax(0, 1fr);
  }

  .stream-thumb {
    width: 136px;
    height: 76px;
  }

  .stream-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .stream-debug-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .stream-details-grid {
    grid-template-columns: 1fr;
  }

  .prelive-grid {
    grid-template-columns: 1fr;
  }

  .chat-test-form {
    grid-template-columns: 1fr;
  }

  .chat-view-panel .panel-body {
    height: auto;
    grid-template-rows: auto auto;
  }

  .chat-activity-panel {
    height: auto;
    grid-template-rows: auto auto;
  }

  .chat-activity-list {
    min-height: 260px;
    max-height: 56vh;
  }

  .metric-handle {
    grid-column: span 1;
  }

  .socials-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  #main { padding: 12px; }

  #topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  #chatControlsForm {
    grid-template-columns: 1fr;
  }

  .quick-run {
    grid-template-columns: 1fr;
  }

  .chat-test-head {
    align-items: flex-start;
  }

  .chat-activity-author-name {
    max-width: 140px;
  }

  .chat-activity-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .chat-activity-time {
    width: auto;
    text-align: left;
    align-self: start;
  }

  .chat-activity-type {
    width: fit-content;
    justify-self: start;
    align-self: start;
  }

  .socials-grid {
    grid-template-columns: 1fr;
  }

  .side-nav {
    grid-template-columns: 1fr;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .side-nav a {
    justify-content: flex-start;
    padding: 10px;
  }

  .account-actions {
    grid-template-columns: 1fr;
  }

  .stream-row {
    grid-template-columns: 1fr;
  }

  .stream-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .stream-actions {
    grid-column: auto;
    justify-content: flex-start;
  }

  .cmd-actions {
    grid-template-columns: 1fr;
  }

  .commands-table-wrap {
    overflow-x: hidden;
    overflow-y: visible;
  }

  .commands-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  .commands-table thead {
    display: none;
  }

  .commands-table tbody {
    display: block;
  }

  .commands-table tr {
    display: block;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 6px 8px;
  }

  .commands-table tr:hover td {
    background: transparent;
  }

  .commands-table td {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 2px;
    border-bottom: 0;
    align-items: start;
  }

  .commands-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-top: 4px;
  }

  .commands-table td[data-label="Enabled"] {
    align-items: center;
  }

  .commands-table td[data-label="Enabled"] .toggle {
    margin-top: 2px;
  }

  .commands-table .alias-add-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .commands-table .cmd-actions {
    grid-template-columns: 72px;
    justify-content: start;
  }

  #mainFooter {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding: 18px 12px 16px;
    font-size: 0.82rem;
  }

  .footer-copy {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-wrap: balance;
  }

  .footer-links {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .footer-links span {
    display: none;
  }
}

@media (max-width: 900px) {
  .help-state-banner {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 7px;
  }

  .help-state-tone {
    justify-self: start;
  }
}
