:root {
  --st-primary: #ff4b4b;
  --st-primary-hover: #ff2b2b;
  --st-bg: #ffffff;
  --st-sidebar-bg: #f0f2f6;
  --st-border: #d5dae5;
  --st-text: #262730;
  --st-muted: #555867;
  --st-card-shadow: 0 1px 2px rgba(38, 39, 48, 0.06), 0 10px 20px rgba(38, 39, 48, 0.04);
  --st-radius: 0.5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", sans-serif;
  color: var(--st-text);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: var(--st-primary);
  text-decoration: none;
}

a:hover {
  color: var(--st-primary-hover);
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 18rem;
  border-right: 1px solid var(--st-border);
  background: var(--st-sidebar-bg);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 1035;
  transition: transform 0.24s ease;
}

.sidebar-inner {
  padding: 1.1rem 0.9rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.5rem 0.85rem;
  border-bottom: 1px solid var(--st-border);
}

.brand-icon {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.65rem;
  background: #ffffff;
  border: 1px solid var(--st-border);
  display: grid;
  place-items: center;
  color: var(--st-primary);
  font-size: 1rem;
}

.brand-eyebrow {
  margin: 0;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--st-muted);
}

.brand-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
}

.nav-section {
  margin: 0 0 0.55rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--st-muted);
  padding-left: 0.45rem;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar .nav-link {
  width: 100%;
  border-radius: 0.55rem;
  border: 1px solid transparent;
  color: var(--st-text);
  padding: 0.55rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.sidebar .nav-link i {
  font-size: 0.95rem;
}

.sidebar .nav-link:hover {
  background: #ffffff;
  border-color: var(--st-border);
  color: var(--st-text);
}

.sidebar .nav-link.active {
  background: #ffffff;
  border-color: var(--st-border);
  box-shadow: 0 1px 1px rgba(38, 39, 48, 0.05);
}

.nav-link-button {
  text-align: left;
  background: transparent;
  color: var(--st-text);
  font: inherit;
  cursor: pointer;
}

.sidebar-note {
  margin-top: auto;
  background: #ffffff;
  border: 1px solid var(--st-border);
  border-radius: 0.7rem;
  padding: 0.75rem;
}

.sidebar-note-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: 0.93rem;
}

.sidebar-note-body {
  margin: 0;
  color: var(--st-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.sidebar-note-session {
  border-left-width: 4px;
}

.sidebar-note-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.sidebar-note-session .sidebar-note-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 9rem;
  min-width: 0;
  margin: 0;
}

.sidebar-note-title-icon {
  width: 1.15rem;
  height: 1.15rem;
  display: inline-grid;
  place-items: center;
  font-size: 0.85rem;
}

.sidebar-note-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--st-border);
  color: #445062;
  background: #f6f8fc;
}

.sidebar-note-browser {
  border-left-color: #5f7fa8;
}

.sidebar-note-browser .sidebar-note-badge {
  background: #eaf2ff;
  border-color: #c8daf6;
  color: #2e5e98;
}

.sidebar-note-day {
  border-left-color: #2e8a57;
}

.sidebar-note-day .sidebar-note-badge {
  background: #e8f7ef;
  border-color: #bde7cd;
  color: #1f7446;
}

.sidebar-note-week {
  border-left-color: #2f8a86;
}

.sidebar-note-week .sidebar-note-badge {
  background: #e6f7f5;
  border-color: #b7e3de;
  color: #1f726e;
}

.sidebar-note-month {
  border-left-color: #6d62c1;
}

.sidebar-note-month .sidebar-note-badge {
  background: #f1edff;
  border-color: #d8cff8;
  color: #5144ab;
}

.sidebar-note-extended {
  border-left-color: #a9752d;
}

.sidebar-note-extended .sidebar-note-badge {
  background: #fff4e6;
  border-color: #f1d6af;
  color: #8b5f20;
}

.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 3.75rem;
  border-bottom: 1px solid var(--st-border);
  padding: 0.55rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.sidebar-toggle {
  border-radius: 0.55rem;
  border-color: var(--st-border);
  color: var(--st-text);
  padding: 0.2rem 0.6rem;
}

.topbar-meta {
  min-width: 0;
}

.topbar-kicker {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--st-muted);
}

.topbar-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.topbar-user-menu {
  margin-left: auto;
  position: relative;
}

.topbar-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--st-border);
  background: #ffffff;
  border-radius: 999px;
  padding: 0.25rem 0.42rem 0.25rem 0.3rem;
  color: var(--st-text);
  line-height: 1.15;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.topbar-user-trigger:hover,
.topbar-user-menu.open .topbar-user-trigger,
.topbar-user-menu:focus-within .topbar-user-trigger {
  border-color: #b8bfce;
  background: #fcfdff;
  box-shadow: 0 6px 16px rgba(38, 39, 48, 0.08);
}

.topbar-avatar {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid var(--st-border);
}

.topbar-user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.topbar-user-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--st-muted);
  font-size: 0.63rem;
  font-weight: 600;
}

.topbar-user-name {
  color: var(--st-text);
  font-size: 0.86rem;
  font-weight: 700;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-chevron {
  font-size: 0.74rem;
  color: var(--st-muted);
  transition: transform 0.2s ease;
}

.topbar-user-menu:hover .topbar-user-chevron,
.topbar-user-menu:focus-within .topbar-user-chevron,
.topbar-user-menu.open .topbar-user-chevron {
  transform: rotate(180deg);
}

.topbar-user-dropdown {
  position: absolute;
  top: calc(100% - 0.12rem);
  right: 0;
  min-width: 14rem;
  background: #ffffff;
  border: 1px solid var(--st-border);
  border-radius: 0.75rem;
  box-shadow: 0 18px 34px rgba(38, 39, 48, 0.14);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 1036;
}

.topbar-user-menu:hover .topbar-user-dropdown,
.topbar-user-menu:focus-within .topbar-user-dropdown,
.topbar-user-menu.open .topbar-user-dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.topbar-user-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--st-text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.6rem;
}

.topbar-user-item:hover,
.topbar-user-item:focus-visible {
  background: #f7f9fd;
  border-color: var(--st-border);
  color: var(--st-text);
}

.topbar-user-item.active {
  background: #f7f9fd;
  border-color: var(--st-border);
}

.topbar-user-item-button {
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.account-modal-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(30, 34, 45, 0.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 1040;
}

.account-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.account-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 1050;
}

.account-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.account-modal-panel {
  width: min(560px, 100%);
  max-height: min(92vh, 680px);
  overflow-y: auto;
}

.account-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.account-modal-close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  border: 1px solid var(--st-border);
  background: #ffffff;
  color: var(--st-muted);
  display: grid;
  place-items: center;
  line-height: 1;
}

.account-modal-close:hover {
  background: #f8f9fc;
}

.account-modal-profile {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0.35rem;
}

.account-modal-name {
  margin: 0 0 0.1rem;
  font-weight: 700;
  font-size: 1.02rem;
}

.account-modal-tabs {
  display: inline-flex;
  gap: 0.3rem;
  margin-top: 0.55rem;
  margin-bottom: 0.25rem;
  padding: 0.3rem;
  border: 1px solid var(--st-border);
  border-radius: 0.7rem;
  background: #f8f9fc;
}

.account-modal-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--st-muted);
  font-weight: 700;
  font-size: 0.88rem;
  border-radius: 0.55rem;
  padding: 0.38rem 0.72rem;
  line-height: 1.2;
}

.account-modal-tab.active {
  color: var(--st-text);
  background: #ffffff;
  border-color: var(--st-border);
  box-shadow: 0 1px 2px rgba(38, 39, 48, 0.06);
}

.account-modal-tab-panel {
  display: none;
  margin-top: 0.35rem;
}

.account-modal-tab-panel.active {
  display: block;
}

.account-avatar-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.account-avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.avatar-choice {
  border: 1px solid var(--st-border);
  border-radius: 0.6rem;
  min-height: 2.4rem;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #ffffff;
  color: var(--st-text);
  font-size: 0.87rem;
  font-weight: 600;
}

.avatar-choice input[type='radio'] {
  margin: 0;
}

.avatar-choice:has(input[type='radio']:checked) {
  border-color: #aeb7c9;
  box-shadow: 0 3px 8px rgba(38, 39, 48, 0.08);
}

.avatar-tone-rose {
  background: #fff3f3;
  color: #cf2f2f;
  border-color: #ffc8c8;
}

.avatar-tone-blue {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.avatar-tone-green {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.avatar-tone-amber {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.avatar-tone-violet {
  background: #f5f3ff;
  color: #5b21b6;
  border-color: #ddd6fe;
}

.account-password-form {
  margin-top: 0.35rem;
}

.account-modal-message {
  margin: 0;
  border-radius: var(--st-radius);
  border: 1px solid transparent;
  padding: 0.55rem 0.68rem;
  font-size: 0.9rem;
}

.account-modal-message.is-error {
  color: #7f1d1d;
  background: #fff5f5;
  border-color: #ffc7c7;
}

.account-modal-message.is-success {
  color: #14532d;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.account-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.content {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.4rem 1.2rem 2rem;
}

.page-head {
  margin-bottom: 1rem;
}

.page-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.section-eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--st-muted);
  font-size: 0.76rem;
}

.section-subtitle {
  margin: 0.35rem 0 0;
  color: var(--st-muted);
  line-height: 1.45;
}

.st-card {
  background: #ffffff;
  border: 1px solid var(--st-border);
  border-radius: 0.8rem;
  box-shadow: var(--st-card-shadow);
  padding: 1rem;
}

.card-title {
  margin: 0 0 0.8rem;
  font-size: 1.12rem;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.metric-label {
  margin: 0;
  color: var(--st-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.74rem;
}

.metric-value {
  margin: 0.25rem 0 0.1rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--st-text);
}

.metric-help {
  margin: 0;
  color: var(--st-muted);
  font-size: 0.92rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.widget-table {
  overflow-x: auto;
}

.widget-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.widget-table th,
.widget-table td {
  text-align: left;
  padding: 0.62rem;
  border-bottom: 1px solid var(--st-border);
}

.widget-table th {
  font-weight: 700;
  color: var(--st-muted);
  background: #fafafa;
}

.quick-list {
  margin: 0;
  padding-left: 1.15rem;
}

.quick-list li {
  margin-bottom: 0.45rem;
}

.channel-grid,
.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.profile-avatar {
  width: 3.3rem;
  height: 3.3rem;
  border-radius: 999px;
  border: 1px solid var(--st-border);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.channel-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.04rem;
}

.channel-card p {
  margin: 0;
  color: var(--st-muted);
}

.channel-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.65rem;
  border: 1px solid var(--st-border);
  background: #ffffff;
  color: var(--st-primary);
  display: grid;
  place-items: center;
  margin-bottom: 0.7rem;
}

.channel-actions-card,
.channel-list-card {
  margin-bottom: 0.9rem;
}

.stream-card {
  margin-bottom: 0;
}

.channel-actions-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;
}

.channel-actions-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.channel-actions-buttons .btn {
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.channel-actions-endpoint {
  margin-top: 0.72rem;
  display: grid;
  grid-template-columns: auto minmax(16rem, 24rem);
  align-items: center;
  gap: 0.55rem 0.8rem;
}

.channel-actions-endpoint .form-label {
  margin: 0;
  font-weight: 600;
}

.channel-actions-endpoint .st-input {
  max-width: 24rem;
}

.channel-actions-endpoint-hint {
  grid-column: 2;
  font-size: 0.82rem;
}

.channel-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.channel-create-actions {
  grid-column: 1 / -1;
}

.channel-create-actions .btn {
  min-width: 14rem;
}

.channel-create-message,
.channel-page-message {
  margin: 0.75rem 0 0;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
}

.channel-create-message.is-error,
.channel-page-message.is-error {
  color: #7f1d1d;
  background: #fff5f5;
  border-color: #ffc7c7;
}

.channel-create-message.is-success,
.channel-page-message.is-success {
  color: #14532d;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.channel-page-modal-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 1050;
}

.channel-page-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.channel-page-modal {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.channel-page-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.channel-page-modal-panel {
  width: min(720px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  transition: width 0.2s ease;
}

.channel-page-modal-panel.channel-page-modal-panel-wide {
  width: min(1120px, 100%);
}

.channel-page-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.8rem;
}

.channel-page-modal-close {
  border: 1px solid var(--st-border);
  background: #ffffff;
  color: var(--st-text);
  border-radius: 0.55rem;
  width: 2.3rem;
  height: 2.3rem;
  display: inline-grid;
  place-items: center;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.channel-page-modal-close:hover {
  background: #f8f9fc;
  border-color: #bac3d3;
}

.history-controls {
  display: grid;
  grid-template-columns: 10rem 15rem auto;
  gap: 0.65rem;
  align-items: end;
  margin-bottom: 0.7rem;
}

.history-controls.history-controls-messages {
  grid-template-columns: 15rem auto;
}

.history-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.42rem;
}

.history-panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.history-controls-toggle {
  display: none;
  width: 1.95rem;
  height: 1.95rem;
  border: 1px solid var(--st-border);
  background: #ffffff;
  color: var(--st-muted);
  border-radius: 999px;
  line-height: 1;
  place-items: center;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.history-controls-toggle:hover {
  border-color: #b7c3d8;
  background: #f8fbff;
  color: var(--st-text);
}

.history-controls-toggle.is-open {
  border-color: #b7c3d8;
  background: #f8fbff;
  color: var(--st-text);
}

.history-summary-tip {
  border: 1px solid var(--st-border);
  background: #ffffff;
  color: var(--st-muted);
  border-radius: 999px;
  width: 1.95rem;
  height: 1.95rem;
  display: inline-grid;
  place-items: center;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.history-summary-tip:hover {
  border-color: #b7c3d8;
  background: #f8fbff;
  color: var(--st-text);
}

.history-summary-tip:focus-visible {
  outline: 2px solid #9fb3dc;
  outline-offset: 2px;
}

.history-summary-tooltip {
  position: fixed;
  z-index: 1200;
  max-width: min(24rem, calc(100vw - 1rem));
  padding: 0.52rem 0.62rem;
  border-radius: 0.6rem;
  border: 1px solid #0f172a;
  background: #111827;
  color: #f9fafb;
  font-size: 0.79rem;
  line-height: 1.35;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.history-summary-tooltip.is-open {
  opacity: 1;
  transform: translateY(0);
}

.history-control-button .btn {
  min-height: 2.5rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 22rem;
  overflow-y: auto;
}

.history-item {
  border: 1px solid var(--st-border);
  border-radius: 0.6rem;
  background: #ffffff;
  padding: 0.55rem 0.6rem;
}

.history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-socket-type {
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--st-muted);
  letter-spacing: 0.05em;
}

.history-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.6rem;
  padding: 0.12rem 0.46rem;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.history-status-chip.is-open {
  background: #ecfdf3;
  color: #065f46;
  border-color: #a7f3d0;
}

.history-status-chip.is-closed {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.history-item-meta {
  margin: 0.28rem 0 0;
  color: var(--st-muted);
  font-size: 0.84rem;
  word-break: break-word;
}

.history-empty {
  color: var(--st-muted);
  border: 1px dashed var(--st-border);
  border-radius: 0.6rem;
  padding: 0.7rem;
  text-align: center;
}

.history-tabs {
  margin: 0 0 0.65rem;
  border-bottom: 1px solid var(--st-border);
  display: inline-flex;
  gap: 0.35rem;
}

.history-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--st-muted);
  font-weight: 700;
  font-size: 0.89rem;
  padding: 0.36rem 0.5rem;
}

.history-tab.active {
  color: var(--st-text);
  border-bottom-color: var(--st-primary);
}

.history-tab-panel {
  display: none;
  margin-top: 0.4rem;
}

.history-tab-panel.active {
  display: block;
}

.history-tab-panel h4 {
  margin: 0;
}

.history-messages-list {
  max-height: 18rem;
}

.history-mobile-list {
  display: none;
}

.history-desktop-table-wrap {
  display: block;
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--st-border);
  border-radius: 0.6rem;
  background: #ffffff;
}

.history-messages-table-wrap {
  max-height: 18rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.history-table th,
.history-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--st-border);
  text-align: left;
  vertical-align: top;
}

.history-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbff;
  color: #4b5870;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-table code {
  font-size: 0.78rem;
}

.history-empty-cell {
  color: var(--st-muted);
  text-align: center;
  padding: 0.8rem 0.6rem;
}

.history-message-cell pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.79rem;
  line-height: 1.34;
  color: #1f2937;
}

.history-message-body {
  margin: 0.38rem 0 0;
  border: 1px solid var(--st-border);
  border-radius: 0.5rem;
  background: #f8fafc;
  padding: 0.48rem 0.55rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.79rem;
  line-height: 1.34;
  color: #1f2937;
}

.channel-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.channel-table-wrap {
  margin-top: 0.2rem;
}

.key-visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--st-muted);
  font-weight: 700;
  padding: 0.1rem 0.25rem;
  line-height: 1.1;
}

.key-visibility-toggle:hover {
  color: var(--st-text);
  border-color: var(--st-border);
  background: #ffffff;
}

.key-visibility-toggle i {
  font-size: 0.9rem;
}

.copy-chip {
  position: relative;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  padding: 0.1rem 0.2rem;
  border-radius: 0.4rem;
  max-width: 100%;
}

.copy-chip:hover {
  border-color: var(--st-border);
  background: #f7f9ff;
}

.copy-chip::after {
  content: attr(data-copy-feedback);
  position: absolute;
  left: 50%;
  top: -1.7rem;
  transform: translate(-50%, 0.3rem);
  background: #14532d;
  color: #ffffff;
  border-radius: 0.4rem;
  padding: 0.12rem 0.38rem;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.copy-chip.is-copied::after,
.copy-chip.is-copy-error::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.copy-chip.is-copy-error::after {
  background: #7f1d1d;
}

.channel-table .channel-key {
  display: inline-block;
  max-width: 18rem;
  word-break: break-all;
}

.channel-description-cell {
  max-width: 19rem;
  color: var(--st-muted);
  font-size: 0.89rem;
  line-height: 1.3;
  cursor: help;
}

.channel-description-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.channel-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.8rem;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.channel-status-chip.is-open {
  background: #ecfdf3;
  color: #065f46;
  border-color: #a7f3d0;
}

.channel-status-chip.is-closed {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.channel-open-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.44rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.14rem 0.45rem 0.14rem 0.18rem;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.channel-open-switch-track {
  display: inline-flex;
  align-items: center;
  width: 2rem;
  height: 1rem;
  border-radius: 999px;
  padding: 0.12rem;
  background: #fecaca;
  transition: background-color 0.15s ease;
}

.channel-open-switch-knob {
  width: 0.76rem;
  height: 0.76rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.28);
  transform: translateX(0);
  transition: transform 0.15s ease;
}

.channel-open-switch.is-open {
  background: #ecfdf3;
  color: #166534;
  border-color: #bbf7d0;
}

.channel-open-switch.is-open .channel-open-switch-track {
  background: #86efac;
}

.channel-open-switch.is-open .channel-open-switch-knob {
  transform: translateX(0.94rem);
}

.channel-open-switch.is-closed {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.channel-open-switch.is-closed .channel-open-switch-track {
  background: #fecaca;
}

.channel-open-switch:hover {
  border-color: #cbd5e1;
}

.channel-table tr.is-selected {
  background: #f9fbff;
}

.channel-actions-trigger {
  min-width: 8.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.channel-actions-trigger i {
  transition: transform 0.15s ease;
}

.channel-actions-trigger[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.channel-actions-portal {
  position: fixed;
  z-index: 2400;
  min-width: 11rem;
  max-width: min(14rem, calc(100vw - 1rem));
  display: grid;
  gap: 0.24rem;
  padding: 0.34rem;
  border-radius: 0.58rem;
  border: 1px solid var(--st-border);
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
}

.channel-actions-portal[hidden] {
  display: none;
}

.channel-actions-portal-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--st-text);
  text-align: left;
  font-size: 0.84rem;
  padding: 0.42rem 0.52rem;
}

.channel-actions-portal-item:hover,
.channel-actions-portal-item:focus-visible {
  background: #f8fbff;
  border-color: #dbe7fb;
  outline: none;
}

.channel-empty-cell {
  text-align: center;
  color: var(--st-muted);
}

.stream-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.stream-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.stream-connection-state {
  border: 1px solid var(--st-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  white-space: nowrap;
}

.stream-connection-state.is-idle {
  color: var(--st-muted);
  background: #f8f9fc;
}

.stream-connection-state.is-connecting {
  color: #92400e;
  background: #fffbeb;
  border-color: #fcd34d;
}

.stream-connection-state.is-open {
  color: #166534;
  background: #f0fdf4;
  border-color: #86efac;
}

.stream-connection-state.is-error {
  color: #7f1d1d;
  background: #fff5f5;
  border-color: #fecaca;
}

.stream-controls-toggle {
  display: none;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--st-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--st-muted);
  line-height: 1;
  place-items: center;
}

.stream-controls-toggle:hover {
  border-color: #b7c3d8;
  background: #f8fbff;
  color: var(--st-text);
}

.stream-controls-toggle.is-open {
  border-color: #b7c3d8;
  background: #f8fbff;
  color: var(--st-text);
}

.stream-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  align-items: end;
}

.stream-button-row {
  display: inline-flex;
  gap: 0.5rem;
}

.stream-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 0.9rem;
  align-items: stretch;
}

.stream-panel {
  border: 1px solid var(--st-border);
  border-radius: 0.75rem;
  background: #ffffff;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stream-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.stream-panel-head h4 {
  margin: 0;
  font-size: 0.97rem;
}

.device-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.device-item {
  border: 1px solid var(--st-border);
  border-radius: 0.6rem;
  padding: 0.5rem 0.58rem;
  background: #fafcff;
}

.device-item-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.device-socket-type {
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--st-muted);
  letter-spacing: 0.05em;
}

.device-channel-code {
  color: var(--st-primary);
  font-size: 0.78rem;
  margin-right: 0.25rem;
}

.device-item-meta {
  margin: 0.3rem 0 0;
  color: var(--st-muted);
  font-size: 0.84rem;
  word-break: break-all;
}

.device-empty {
  color: var(--st-muted);
  border: 1px dashed var(--st-border);
  border-radius: 0.6rem;
  padding: 0.6rem;
  text-align: center;
}

.stream-log {
  min-height: 16rem;
  max-height: 22rem;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  border: 1px solid var(--st-border);
  border-radius: 0.6rem;
  background: #131722;
  color: #d6deeb;
  padding: 0.55rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.81rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.stream-send-form {
  margin-top: 0.55rem;
  display: grid;
  grid-template-columns: 14rem 1fr auto;
  gap: 0.55rem;
}

.stream-note {
  margin-top: 0.8rem;
}

@media (min-width: 768px) {
  .channel-page-modal-panel.channel-page-modal-panel-wide {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .channel-page-modal-panel.channel-page-modal-panel-wide .stream-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  .channel-page-modal-panel.channel-page-modal-panel-wide .stream-grid {
    flex: 1 1 auto;
    min-height: 0;
  }

  .channel-page-modal-panel.channel-page-modal-panel-wide .stream-panel {
    min-height: 0;
    overflow: hidden;
  }

  .channel-page-modal-panel.channel-page-modal-panel-wide .device-list,
  .channel-page-modal-panel.channel-page-modal-panel-wide .stream-log {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
}

.auth-shell {
  min-height: calc(100vh - 10rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: min(460px, 100%);
}

.st-form .form-label {
  font-weight: 600;
  color: var(--st-text);
}

.st-input.form-control,
.st-input.form-select {
  min-height: 2.5rem;
  border-radius: var(--st-radius);
  border: 1px solid var(--st-border);
  color: var(--st-text);
  background: #ffffff;
}

.st-input.form-control:focus,
.st-input.form-select:focus {
  border-color: var(--st-primary);
  box-shadow: 0 0 0 0.2rem rgba(255, 75, 75, 0.18);
}

.st-btn.btn-primary {
  background: var(--st-primary);
  border-color: var(--st-primary);
  border-radius: var(--st-radius);
  min-height: 2.5rem;
  font-weight: 600;
}

.st-btn.btn-primary:hover,
.st-btn.btn-primary:focus {
  background: var(--st-primary-hover);
  border-color: var(--st-primary-hover);
}

.alert {
  border-radius: var(--st-radius);
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 992px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    inset: 0 auto auto 0;
    width: min(18rem, 84vw);
    height: 100svh;
    height: 100dvh;
    min-height: 100svh;
    max-height: 100dvh;
    transform: translateX(-100%);
    box-shadow: 0 24px 40px rgba(38, 39, 48, 0.2);
  }

  .sidebar-inner {
    min-height: auto;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .sidebar-inner > .sidebar-note {
    margin-top: 0;
    padding: 0.6rem 0.65rem;
    border-radius: 0.62rem;
  }

  .sidebar-note-head {
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.22rem;
    flex-wrap: nowrap;
  }

  .sidebar-note-session .sidebar-note-title {
    font-size: 0.77rem;
    line-height: 1.2;
  }

  .sidebar-note-title-icon {
    width: 0.95rem;
    height: 0.95rem;
    font-size: 0.72rem;
  }

  .sidebar-note-badge {
    align-self: center;
    white-space: nowrap;
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    padding: 0.08rem 0.42rem;
  }

  .sidebar-note-body {
    font-size: 0.74rem;
    line-height: 1.28;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1030;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar {
    padding-inline: 0.8rem;
  }

  .topbar-title {
    font-size: 1rem;
  }

  .topbar-kicker {
    font-size: 0.7rem;
  }

  .topbar-user-label,
  .topbar-user-chevron {
    display: none;
  }

  .topbar-user-trigger {
    padding-right: 0.35rem;
  }

  .topbar-user-name {
    max-width: 5.3rem;
  }

  .account-modal {
    padding: 0.7rem;
  }

  .account-modal-actions {
    flex-direction: column-reverse;
  }

  .account-modal-actions .btn {
    width: 100%;
  }

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

  .content {
    padding: 1rem 0.8rem 1.4rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .metric-grid,
  .channel-grid,
  .about-grid {
    grid-template-columns: 1fr;
  }

  .channel-create-grid,
  .stream-controls,
  .stream-grid,
  .stream-send-form,
  .history-controls {
    grid-template-columns: 1fr;
  }

  .stream-controls-toggle {
    display: inline-grid;
  }

  .stream-controls {
    display: none;
  }

  .stream-controls.is-open {
    display: grid;
  }

  .history-tabs {
    display: flex;
    width: 100%;
  }

  .history-tab {
    flex: 1;
    text-align: center;
  }

  .history-controls-toggle {
    display: inline-grid;
  }

  .history-controls {
    display: none;
  }

  .history-controls.is-open {
    display: grid;
  }

  .history-mobile-list {
    display: flex;
  }

  .history-desktop-table-wrap {
    display: none;
  }

  .stream-grid .stream-panel:first-child {
    order: 2;
  }

  .stream-grid .stream-panel:last-child {
    order: 1;
  }

  .channel-actions-head {
    flex-direction: column;
    align-items: stretch;
  }

  .channel-actions-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .channel-actions-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  .channel-actions-endpoint {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .channel-actions-endpoint .st-input {
    max-width: none;
  }

  .channel-actions-endpoint-hint {
    grid-column: auto;
    margin-top: -0.05rem;
  }

  .channel-table thead {
    display: none;
  }

  .channel-table,
  .channel-table tbody,
  .channel-table tr,
  .channel-table td {
    display: block;
    width: 100%;
  }

  .channel-table tr {
    border: 1px solid var(--st-border);
    border-radius: 0.7rem;
    margin-bottom: 0.75rem;
    background: #ffffff;
    padding: 0.1rem 0;
  }

  .channel-table tr.is-selected {
    border-color: #b8c8ec;
    box-shadow: inset 0 0 0 1px #d7e2fa;
  }

  .channel-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.65rem;
    border-bottom: 1px dashed #e6ebf4;
    padding: 0.52rem 0.62rem;
  }

  .channel-table td:last-child {
    border-bottom: 0;
  }

  .channel-table td::before {
    content: attr(data-label);
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--st-muted);
    font-weight: 700;
    min-width: 7.2rem;
    flex-shrink: 0;
    padding-top: 0.15rem;
  }

  .channel-table td.channel-empty-cell {
    display: block;
    text-align: center;
    border-bottom: 0;
  }

  .channel-table td.channel-empty-cell::before {
    content: none;
  }

  .channel-actions-trigger {
    min-width: 7.2rem;
    max-width: 10.8rem;
    width: 100%;
  }

  .channel-actions-portal {
    max-width: calc(100vw - 0.75rem);
  }

  .copy-chip {
    text-align: left;
  }

  .channel-page-modal {
    padding: 0.65rem;
    align-items: flex-start;
    padding-top: 0.8rem;
  }

  .channel-page-modal-panel {
    max-height: calc(100vh - 1.2rem);
  }

  .stream-log {
    min-height: 11rem;
  }

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

  .channel-list-head {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-shell {
    min-height: auto;
    padding-top: 0.8rem;
    align-items: flex-start;
  }
}
