:root {
  --bg: #f8f9fd;
  --surface: #ffffff;
  --surface-subtle: #f3f4f8;
  --border: #e8eaf0;
  --border-strong: #dfe1e9;
  --primary: #7966f2;
  --primary-hover: #6955e5;
  --primary-soft: #f0edff;
  --text: #171a24;
  --text-secondary: #73798a;
  --text-muted: #9a9faf;
  --success: #16c784;
  --success-soft: #e9fbf4;
  --live: #ff5b5f;
  --danger-soft: #fff0f1;
  --shadow-sm: 0 1px 2px rgba(18, 23, 38, 0.025), 0 5px 16px rgba(18, 23, 38, 0.035);
  --shadow-md: 0 14px 34px rgba(32, 28, 63, 0.09), 0 3px 10px rgba(18, 23, 38, 0.04);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --sidebar-width: 232px;
  --header-height: 74px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(121, 102, 242, 0.22);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  transform: translateY(-140%);
  border-radius: 8px;
  background: var(--text);
  color: white;
  padding: 10px 14px;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

[hidden] {
  display: none !important;
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 15px 14px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 4px;
}

.brand-mark {
  display: inline-flex;
  width: 38px;
  height: 38px;
  color: var(--primary);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  margin-top: 33px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #686f80;
  padding: 0 17px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 170ms ease, color 170ms ease, transform 170ms ease;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.9;
}

.nav-item:hover {
  background: #f7f7fa;
  color: var(--text);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.sidebar-profile {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 19px 4px 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #ded9ff;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 700;
}

.profile-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.profile-copy strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy span {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 170ms ease, background-color 170ms ease, color 170ms ease, transform 170ms ease;
}

.icon-button:hover {
  border-color: #dadce5;
  background: #f8f8fb;
  color: var(--primary);
}

.icon-button:active {
  transform: scale(0.97);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}

.profile-more {
  width: 34px;
  height: 34px;
  border-color: transparent;
}

.app-body {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(252, 253, 255, 0.96);
  padding: 0 22px 0 28px;
  backdrop-filter: blur(8px);
}

.search-field {
  display: flex;
  align-items: center;
  width: min(535px, 50vw);
  height: 48px;
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f4f6fb;
  padding: 0 13px;
  color: var(--text-secondary);
  transition: border-color 170ms ease, box-shadow 170ms ease, background-color 170ms ease;
}

.search-field:focus-within {
  border-color: rgba(121, 102, 242, 0.66);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(121, 102, 242, 0.1);
}

.search-field svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  stroke-width: 2;
}

.search-field input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-field input::placeholder {
  color: #959aaa;
}

.search-field input::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-field kbd {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: #9297a7;
  padding: 0 7px;
  font-family: inherit;
  font-size: 10px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.notification-button {
  position: relative;
  width: 44px;
  height: 44px;
}

.notification-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--live);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 170ms ease, border-color 170ms ease, box-shadow 170ms ease, transform 170ms ease, opacity 170ms ease;
}

.button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 6px 14px rgba(121, 102, 242, 0.2);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 8px 18px rgba(105, 85, 229, 0.24);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: #4e5464;
}

.button-secondary:hover:not(:disabled) {
  border-color: #d1d4de;
  background: #fafafd;
}

.connect-new {
  min-height: 44px;
  padding: 0 18px;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 0;
  overflow: hidden;
  transition: grid-template-columns 220ms ease;
}

.app.has-detail .workspace {
  grid-template-columns: minmax(0, 1fr) 520px;
}

.content {
  min-width: 0;
  overflow: auto;
  padding: 28px 28px 40px;
  scrollbar-color: #d9dce6 transparent;
  scrollbar-width: thin;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 17px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(27px, 2.2vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.page-heading p {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.stream-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.filter-tabs,
.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.filter-tab {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #f1f3f8;
  color: #465068;
  padding: 0 17px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 170ms ease, color 170ms ease, box-shadow 170ms ease;
}

.filter-tab span {
  margin-left: 4px;
  opacity: 0.72;
}

.filter-tab:hover:not(.active) {
  background: var(--surface-subtle);
  color: var(--text);
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 3px 9px rgba(121, 102, 242, 0.21);
}

.view-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  gap: 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #858a99;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 170ms ease, color 170ms ease;
}

.view-toggle {
  flex: 0 0 auto;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f1f3f8;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(24, 28, 42, 0.035);
}

.view-toggle button {
  width: 40px;
  height: 38px;
  border-radius: 9px;
}

.view-toggle button:hover {
  color: var(--text);
}

.view-toggle button.active {
  background: var(--surface);
  color: var(--primary-hover);
  box-shadow: 0 2px 7px rgba(45, 39, 85, 0.09);
}

.view-toggle span {
  display: none;
}

.view-toggle svg {
  width: 16px;
  height: 16px;
}

.streams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  justify-content: start;
  gap: 20px 18px;
}

.stream-card {
  display: block;
  width: 100%;
  max-width: 420px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0;
  text-align: left;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.stream-card:hover {
  border-color: #dbdce6;
  box-shadow: 0 12px 28px rgba(29, 32, 46, 0.085);
  transform: translateY(-3px);
}

.stream-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 0 4px rgba(121, 102, 242, 0.08), 0 12px 28px rgba(66, 53, 145, 0.08);
}

.card-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: #ccd3da;
  background-position: center;
  background-size: cover;
}

.card-preview::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.23) 0%, transparent 40%, rgba(7, 11, 18, 0.18) 100%);
  content: "";
}

.card-preview::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  content: "";
  pointer-events: none;
}

.signal-preview {
  --signal-rgb: 121, 102, 242;
  background-color: #dce2ed;
  background-image:
    radial-gradient(ellipse 76% 64% at 50% 118%, transparent 40%, rgba(var(--signal-rgb), 0.12) 40.5%, transparent 41.2%, transparent 57%, rgba(var(--signal-rgb), 0.08) 57.5%, transparent 58.2%),
    radial-gradient(ellipse 52% 45% at 50% 118%, transparent 42%, rgba(var(--signal-rgb), 0.14) 42.6%, transparent 43.4%),
    radial-gradient(circle at 50% 38%, rgba(var(--signal-rgb), 0.2), transparent 42%),
    linear-gradient(145deg, #1b2130 0%, #10141e 56%, #0b0e16 100%);
  background-position: center;
  background-size: cover;
}

.signal-preview::before,
.video-player.signal-preview::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(18, 23, 34, 0.08) 0%, transparent 42%, rgba(9, 13, 21, 0.5) 100%),
    radial-gradient(circle at center, transparent 0%, transparent 54%, rgba(30, 38, 53, 0.12) 78%, rgba(22, 28, 40, 0.2) 100%);
  content: "";
  animation: none;
}

.signal-monitor {
  position: absolute;
  z-index: 2;
  top: 58%;
  left: 50%;
  display: flex;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 28px);
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  background: rgba(250, 251, 254, 0.92);
  color: #171b28;
  padding: 7px 12px 7px 7px;
  box-shadow: 0 10px 28px rgba(17, 23, 38, 0.2);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(14px) saturate(1.15);
  pointer-events: none;
}

.signal-monitor-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(var(--signal-rgb), 0.28);
  border-radius: 50%;
  background: rgba(var(--signal-rgb), 0.1);
  color: rgb(var(--signal-rgb));
  box-shadow: 0 8px 24px rgba(42, 49, 67, 0.1);
  backdrop-filter: blur(5px);
}

.signal-monitor-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.9;
}

.signal-monitor-copy {
  display: grid;
  gap: 2px;
  min-width: 100px;
  overflow: hidden;
}

.signal-monitor-copy strong {
  overflow: hidden;
  color: #151927;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-monitor-copy small {
  overflow: hidden;
  color: #5f6678;
  font-size: 10px;
  font-weight: 550;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-offline {
  --signal-rgb: 125, 130, 143;
  background-image:
    radial-gradient(ellipse 76% 64% at 50% 118%, transparent 40%, rgba(125, 130, 143, 0.08) 40.5%, transparent 41.2%, transparent 57%, rgba(125, 130, 143, 0.05) 57.5%, transparent 58.2%),
    radial-gradient(ellipse 52% 45% at 50% 118%, transparent 42%, rgba(125, 130, 143, 0.08) 42.6%, transparent 43.4%),
    radial-gradient(circle at 50% 38%, rgba(125, 130, 143, 0.12), transparent 42%),
    linear-gradient(145deg, #242832 0%, #161922 58%, #11131a 100%);
}

.signal-offline::before,
.video-player.signal-offline::before {
  animation: none;
  opacity: 0.45;
}

.preview-topline {
  position: absolute;
  z-index: 2;
  top: 13px;
  right: 13px;
  left: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-badge,
.live-badge {
  display: inline-flex;
  align-items: center;
  height: 32px;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(18, 22, 28, 0.64);
  color: white;
  padding: 0 11px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  backdrop-filter: blur(8px);
}

.status-badge > span,
.live-badge > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 199, 132, 0.16);
}

.status-badge.offline > span {
  background: #a9adba;
  box-shadow: none;
}

.status-badge.unknown > span {
  background: #f1b24a;
  box-shadow: 0 0 0 3px rgba(241, 178, 74, 0.18);
}

.live-badge {
  border-color: rgba(255, 91, 95, 0.24);
  background: rgba(225, 46, 52, 0.88);
  letter-spacing: 0.03em;
}

.live-badge > span {
  display: none;
}

@keyframes liveBlink {
  50% { opacity: 0.45; }
}

.preview-signal {
  position: absolute;
  z-index: 2;
  right: auto;
  left: 13px;
  bottom: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 9px;
  background: rgba(10, 14, 20, 0.72);
  color: white;
  padding: 7px 9px;
  font-size: 10px;
  font-weight: 550;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.32);
}

.offline-indicator {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 15px;
  background: rgba(53, 57, 65, 0.28);
  color: white;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(3px);
}

.offline-indicator svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.8;
}

.preview-signal svg {
  width: 13px;
  height: 13px;
}

.stream-card.offline .card-preview {
  filter: none;
}

.card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
}

.card-body h2 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.card-copy small {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-body > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--text-muted);
}

.stream-card-skeleton {
  cursor: default;
  pointer-events: none;
}

.stream-card-skeleton .card-preview,
.stream-card-skeleton .card-body > span {
  background: linear-gradient(90deg, #eef0f5 25%, #f8f9fc 48%, #eef0f5 75%);
  background-size: 240% 100%;
  animation: skeletonPulse 1.25s ease-in-out infinite;
}

.stream-card-skeleton .card-body > span {
  width: 56%;
  height: 13px;
  border-radius: 6px;
}

@keyframes skeletonPulse {
  to { background-position: -140% 0; }
}

.streams-grid.list-view {
  grid-template-columns: minmax(0, 1fr);
}

.streams-grid.list-view .stream-card {
  display: grid;
  max-width: none;
  grid-template-columns: minmax(230px, 34%) minmax(0, 1fr);
}

.streams-grid.list-view .card-preview {
  aspect-ratio: 16 / 8.5;
}

.streams-grid.list-view .card-body {
  padding: 20px 22px;
}

.streams-grid.list-view .card-body h2 {
  font-size: 16px;
}

.empty-state {
  display: grid;
  justify-items: center;
  min-height: 330px;
  place-content: center;
  border: 1px dashed #d9dce6;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state > span {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-state svg {
  width: 22px;
  height: 22px;
}

.empty-state h2 {
  margin: 17px 0 7px;
  font-size: 16px;
}

.empty-state p {
  margin: 0 0 19px;
  color: var(--text-secondary);
  font-size: 12px;
}

.detail-panel {
  position: relative;
  z-index: 10;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--border);
  background: var(--surface);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 180ms ease, transform 220ms ease;
  pointer-events: none;
}

.app.has-detail .detail-panel {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border-bottom: 0;
  padding: 7px 10px 0 24px;
}

.detail-header > div {
  visibility: hidden;
}

.detail-label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-header h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.detail-scroll {
  min-height: 0;
  overflow: auto;
  padding: 0 24px 24px;
  scrollbar-color: #d9dce6 transparent;
  scrollbar-width: thin;
}

.video-player {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background-color: #232b32;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 9px 24px rgba(17, 21, 32, 0.13);
}

.video-player video {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #090b10;
  object-fit: contain;
}

.video-player:not(.is-connected) .player-controls {
  display: none;
}

.video-player::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 7, 12, 0.22) 0%, transparent 43%, rgba(3, 6, 10, 0.64) 100%);
  content: "";
}

.detail-signal-monitor {
  display: none !important;
  gap: 13px;
}

.detail-signal-monitor .signal-monitor-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
}

.detail-signal-monitor .signal-monitor-copy strong {
  font-size: 12px;
}

.detail-signal-monitor .signal-monitor-copy small {
  font-size: 10px;
}

.player-topline {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  left: 14px;
  display: flex;
  justify-content: space-between;
}

.player-controls {
  position: absolute;
  z-index: 2;
  right: 13px;
  bottom: 12px;
  left: 13px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.player-controls button {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  background: transparent;
  color: white;
  padding: 0;
  cursor: pointer;
}

.player-controls svg {
  width: 17px;
  height: 17px;
}

.stream-summary {
  border-bottom: 1px solid var(--border);
  padding: 19px 6px 18px;
}

.stream-summary h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.025em;
}

.info-section {
  margin-bottom: 22px;
  border: 1px solid #eef0f5;
  border-radius: 12px;
  background: #f7f8fb;
  padding: 17px 18px 15px;
}

.info-section h3,
.connection-form h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.info-section h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
}

.info-section h3 svg {
  width: 18px;
  height: 18px;
  color: #31394e;
}

.info-list {
  display: grid;
  gap: 0;
  margin: 13px 0 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  min-height: 36px;
}

.info-list dt {
  color: var(--text-secondary);
  font-size: 12px;
}

.info-list dd {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #333744;
  font-size: 12px;
  font-weight: 550;
}

.info-list dd span:not(.info-status-dot) {
  color: var(--text-muted);
  font-weight: 450;
}

.info-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 199, 132, 0.11);
}

.info-status-dot.offline {
  background: #a9adba;
  box-shadow: none;
}

.info-status-dot.unknown {
  background: #f1b24a;
  box-shadow: 0 0 0 3px rgba(241, 178, 74, 0.14);
}

.connection-form {
  padding: 0 2px 5px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

.section-heading > svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.field-group {
  margin-bottom: 14px;
}

.input-shell,
.modal-input {
  display: flex;
  align-items: center;
  height: 47px;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--text-muted);
  transition: border-color 170ms ease, box-shadow 170ms ease;
}

.input-shell:focus-within,
.modal-input:focus-within {
  border-color: rgba(121, 102, 242, 0.75);
  box-shadow: 0 0 0 3px rgba(121, 102, 242, 0.1);
}

.input-shell.invalid,
.modal-input.invalid {
  border-color: rgba(255, 91, 95, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 91, 95, 0.08);
}

.input-shell > svg,
.modal-input > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.input-shell input,
.modal-input input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.input-shell input::placeholder,
.modal-input input::placeholder {
  color: #a2a6b3;
}

.input-shell button,
.modal-input button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8c91a0;
  padding: 0;
  cursor: pointer;
}

.input-shell button:hover,
.modal-input button:hover {
  background: #f4f4f8;
  color: var(--text);
}

.input-shell button svg,
.modal-input button svg {
  width: 17px;
  height: 17px;
}

.field-message {
  display: block;
  height: 0;
  overflow: hidden;
  color: var(--live);
  font-size: 10px;
  line-height: 18px;
  opacity: 0;
  transition: height 170ms ease, opacity 170ms ease;
}

.field-group.has-error .field-message {
  height: 18px;
  opacity: 1;
}

.field-message.error {
  height: auto;
  min-height: 18px;
  margin-top: 4px;
  overflow: visible;
  opacity: 1;
}

.detail-connect-button {
  width: 100%;
  min-height: 48px;
}

.detail-disconnect-button {
  width: 100%;
  min-height: 48px;
}

.recording-button {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 1px solid #df4b53;
  background: var(--surface);
  color: #c63840;
}

.recording-button:hover:not(:disabled) {
  background: #fff5f5;
  border-color: #c63840;
}

.recording-button.is-recording {
  border-color: #d83f48;
  background: #d83f48;
  color: white;
}

.recording-button.is-recording:hover:not(:disabled) {
  border-color: #c4333c;
  background: #c4333c;
}

.recording-indicator {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.recording-button.is-recording .recording-indicator {
  border-radius: 2px;
}

.recording-message {
  display: block;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.recording-message[hidden],
.recording-button[hidden] {
  display: none;
}

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: white;
  border-radius: 50%;
  animation: buttonSpin 700ms linear infinite;
}

@keyframes buttonSpin {
  to { transform: rotate(360deg); }
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(22, 24, 33, 0.42);
  padding: 24px;
  backdrop-filter: blur(3px);
  animation: backdropIn 160ms ease both;
}

.modal-backdrop[hidden] {
  display: none;
}

@keyframes backdropIn {
  from { opacity: 0; }
}

.modal {
  position: relative;
  width: min(100%, 440px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  background: var(--surface);
  padding: 28px;
  box-shadow: 0 24px 70px rgba(21, 20, 32, 0.2);
  animation: modalIn 200ms ease both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
}

.modal-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.modal-icon svg {
  width: 21px;
  height: 21px;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  border-color: transparent;
}

.modal h2 {
  margin: 19px 0 7px;
  font-size: 21px;
  letter-spacing: -0.035em;
}

.modal > p {
  margin: 0 0 25px;
  color: var(--text-secondary);
  font-size: 13px;
}

.form-field {
  display: grid;
  gap: 8px;
  margin-bottom: 17px;
}

.form-field > label {
  color: #454a58;
  font-size: 12px;
  font-weight: 600;
}

.modal-error {
  min-height: 0;
  color: var(--live);
  font-size: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}

.modal-actions .button {
  min-width: 112px;
}

.toast-region {
  position: fixed;
  z-index: 200;
  right: 24px;
  bottom: 24px;
  display: grid;
  width: min(360px, calc(100vw - 48px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.97);
  padding: 12px 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 220ms ease both;
  pointer-events: auto;
}

.toast.leaving {
  animation: toastOut 200ms ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(14px); }
}

.toast-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
}

.toast.info .toast-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.toast.error .toast-icon {
  background: var(--danger-soft);
  color: var(--live);
}

.toast-icon svg {
  width: 18px;
  height: 18px;
}

.toast-copy {
  min-width: 0;
}

.toast-copy strong,
.toast-copy span {
  display: block;
}

.toast-copy strong {
  margin-bottom: 3px;
  font-size: 12px;
}

.toast-copy span {
  color: var(--text-secondary);
  font-size: 11px;
}

.toast button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.toast button:hover {
  background: var(--surface-subtle);
}

.toast button svg {
  width: 14px;
  height: 14px;
}

/* Settings */
.settings-page[hidden],
.streams-page[hidden],
.recordings-page[hidden] {
  display: none;
}

.recordings-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.recordings-heading h1 {
  margin: 0;
  font-size: clamp(27px, 2.2vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.recordings-heading p {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.recordings-refresh {
  min-height: 42px;
}

.recordings-refresh.is-loading svg {
  animation: buttonSpin 800ms linear infinite;
}

.recordings-list {
  display: grid;
  gap: 10px;
}

.recording-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}

.recording-row-icon {
  display: grid;
  width: 58px;
  height: 48px;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.recording-row-icon svg {
  width: 21px;
  height: 21px;
}

.recording-row-copy {
  min-width: 0;
}

.recording-row-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
}

.recording-row-title h2 {
  overflow: hidden;
  margin: 0;
  font-size: 14px;
  font-weight: 680;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recording-active-label {
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--danger-soft);
  color: #c63840;
  padding: 4px 7px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.recording-row-module {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 11px;
}

.recording-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 15px;
  margin-top: 8px;
  color: #686f80;
  font-size: 11px;
}

.recording-row-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.recording-row-meta svg {
  width: 13px;
  height: 13px;
}

.recording-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recording-row-actions .button {
  min-height: 38px;
  padding-inline: 13px;
}

.recording-download-button {
  width: 40px;
  min-width: 40px;
  padding: 0 !important;
}

.recording-row-skeleton {
  min-height: 76px;
  overflow: hidden;
}

.recording-row-skeleton::after {
  width: 48%;
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f1f5 25%, #fafafd 50%, #f0f1f5 75%);
  background-size: 200% 100%;
  content: "";
  animation: skeleton 1.35s linear infinite;
}

.recordings-empty {
  display: grid;
  justify-items: center;
  min-height: 330px;
  place-content: center;
  border: 1px dashed #d9dce6;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.recordings-empty > span {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
}

.recordings-empty svg {
  width: 22px;
  height: 22px;
}

.recordings-empty h2 {
  margin: 17px 0 7px;
  font-size: 16px;
}

.recordings-empty p {
  max-width: 380px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.recording-viewer-backdrop {
  padding: 28px;
}

.recording-viewer {
  width: min(980px, 100%);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(21, 20, 32, 0.22);
  animation: modalIn 200ms ease both;
}

.recording-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px;
}

.recording-viewer-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.025em;
}

.recording-viewer-header p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
}

.recording-viewer video {
  display: block;
  width: 100%;
  max-height: min(68vh, 680px);
  aspect-ratio: 16 / 9;
  background: #090b10;
  object-fit: contain;
}

.recording-viewer-actions {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px 18px;
}

.settings-heading {
  margin-bottom: 24px;
}

.settings-heading h1 {
  margin: 0;
  font-size: clamp(27px, 2.2vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.settings-heading p {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: stretch;
  gap: 18px;
  min-height: calc(100vh - var(--header-height) - 139px);
}

.settings-nav {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  align-self: stretch;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 9px;
  box-shadow: var(--shadow-sm);
}

.settings-nav button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 54px;
  gap: 13px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #303546;
  padding: 0 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 170ms ease, color 170ms ease;
}

.settings-nav button::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: -9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
  content: "";
}

.settings-nav button:hover:not(.active) {
  background: #f7f7fb;
}

.settings-nav button.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.settings-nav button.active::before {
  background: var(--primary);
}

.settings-nav svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.9;
}

.settings-panels {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}

.settings-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.settings-card-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-card-heading h2 {
  margin: 0 0 5px;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.settings-card-heading p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.settings-card-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.settings-card-icon svg {
  width: 21px;
  height: 21px;
}

.settings-card-icon.danger {
  background: var(--danger-soft);
  color: var(--live);
}

.settings-form {
  margin-top: 18px;
}

.settings-form-fields,
.create-user-form {
  display: grid;
  align-items: start;
  gap: 14px;
}

.password-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.settings-field > label {
  color: #4c5263;
  font-size: 11px;
  font-weight: 600;
}

.settings-input {
  display: flex;
  align-items: center;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  padding: 0 12px;
  transition: border-color 170ms ease, box-shadow 170ms ease;
}

.settings-input:focus-within {
  border-color: rgba(121, 102, 242, 0.72);
  box-shadow: 0 0 0 3px rgba(121, 102, 242, 0.09);
}

.settings-input.invalid {
  border-color: rgba(255, 91, 95, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 91, 95, 0.07);
}

.settings-input input {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.settings-input input::placeholder {
  color: #a0a6b7;
}

.settings-input button {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #70778a;
  padding: 0;
  cursor: pointer;
}

.settings-input button:hover {
  background: #f3f4f8;
  color: var(--primary);
}

.settings-input button svg {
  width: 16px;
  height: 16px;
}

.settings-error {
  display: block;
  min-height: 11px;
  color: var(--live);
  font-size: 10px;
}

.settings-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

.settings-form-actions .button,
.create-account-button {
  min-width: 188px;
}

.create-user-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 188px;
}

.create-account-button {
  align-self: center;
  margin-top: 18px;
}

.users-table {
  margin-top: 12px;
}

.users-table-head,
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(140px, 0.8fr) 58px;
  align-items: center;
}

.users-table-head {
  min-height: 28px;
  padding: 0 12px;
  color: #596073;
  font-size: 11px;
  font-weight: 600;
}

.users-table-body {
  display: grid;
  gap: 3px;
}

.user-row {
  min-height: 36px;
  border: 1px solid #eceef3;
  border-radius: 9px;
  background: #fbfbfd;
  padding: 3px 8px 3px 12px;
  font-size: 12px;
}

.user-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.user-avatar {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #e7e2ff;
  color: #5f4de6;
  font-size: 10px;
  font-weight: 700;
}

.user-avatar.blue {
  background: #ddebff;
  color: #356ed1;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge {
  justify-self: start;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  padding: 5px 10px;
  font-size: 9px;
  font-weight: 600;
}

.delete-user-button {
  display: grid;
  width: 30px;
  height: 28px;
  justify-self: end;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: #ffe8e9;
  color: var(--live);
  cursor: pointer;
  transition: background-color 170ms ease, transform 170ms ease;
}

.delete-user-button:hover {
  background: #ffdadd;
  transform: translateY(-1px);
}

.delete-user-button svg {
  width: 15px;
  height: 15px;
}

.logout-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logout-button {
  min-width: 188px;
  border-color: var(--live);
  background: white;
  color: var(--live);
}

.logout-button:hover {
  background: var(--danger-soft);
}

.settings-page[data-active-tab="users"] [data-account-only] {
  display: none;
}

.settings-page[data-active-tab="account"] .users-card {
  display: none;
}

.user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.account-action {
  display: grid;
  width: 30px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  cursor: pointer;
}

.account-action:hover {
  background: #e3ddff;
}

.account-action svg {
  width: 15px;
  height: 15px;
}

.user-row-loading {
  display: flex;
  color: var(--text-secondary);
}

/* Authorization */
.auth-gate {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  overflow: auto;
  background:
    radial-gradient(circle at 18% 12%, rgba(121, 102, 242, 0.12), transparent 32%),
    radial-gradient(circle at 86% 88%, rgba(80, 194, 164, 0.1), transparent 30%),
    #f6f7fb;
  padding: 32px 20px;
}

.auth-card {
  width: min(100%, 430px);
  border: 1px solid rgba(226, 228, 237, 0.92);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  padding: 32px;
  box-shadow: 0 24px 70px rgba(39, 35, 75, 0.12);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.035em;
}

.auth-heading {
  margin: 34px 0 25px;
}

.auth-heading > span {
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-heading h1 {
  margin: 9px 0 8px;
  font-size: 30px;
  letter-spacing: -0.045em;
}

.auth-heading p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.55;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-error {
  margin: -3px 0 15px;
  color: #c83f48;
  font-size: 12px;
  line-height: 1.45;
}

.auth-security {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 10px;
}

.auth-security svg {
  width: 14px;
  height: 14px;
}

.modal-open {
  overflow: hidden;
}

.modal-actions > :only-child {
  min-width: 100%;
}

@media (max-width: 1180px) {
  .settings-layout {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .password-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .create-user-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .create-account-button {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-nav {
    min-height: auto;
    flex-direction: row;
  }

  .settings-nav button {
    width: auto;
    min-width: 170px;
  }

  .settings-nav button::before {
    display: none;
  }
}

@media (max-width: 1320px) {
  :root {
    --sidebar-width: 220px;
  }

  .app.has-detail .workspace {
    grid-template-columns: minmax(0, 1fr) 420px;
  }

  .content {
    padding-inline: 26px;
  }

  .topbar {
    padding-inline: 26px;
  }

}

@media (max-width: 1000px) {
  :root {
    --sidebar-width: 84px;
  }

  .sidebar {
    align-items: center;
    padding-inline: 14px;
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand-name,
  .nav-item span,
  .profile-copy,
  .profile-more {
    display: none;
  }

  .sidebar-nav {
    width: 100%;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .sidebar-profile {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-inline: 0;
  }

  .app.has-detail .workspace {
    grid-template-columns: minmax(0, 1fr) 390px;
  }

  .search-field {
    width: min(440px, 48vw);
  }

  .search-field kbd {
    display: none;
  }

  .connect-new span {
    display: none;
  }

  .connect-new {
    width: 46px;
    padding: 0;
  }

  .page-heading .availability {
    display: none;
  }

  .streams-grid,
  .app.has-detail .streams-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 800px) {
  .app.has-detail .workspace {
    grid-template-columns: minmax(0, 1fr) 0;
  }

  .app.has-detail .detail-panel {
    position: fixed;
    z-index: 60;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(470px, calc(100vw - var(--sidebar-width)));
    box-shadow: -18px 0 42px rgba(22, 24, 36, 0.13);
  }

  .content {
    padding: 30px 22px 40px;
  }

  .topbar {
    padding-inline: 22px;
  }

  .streams-grid,
  .app.has-detail .streams-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stream-toolbar {
    align-items: flex-start;
  }

  .view-toggle span {
    display: none;
  }
}

@media (max-width: 700px) {
  :root {
    --sidebar-width: 0px;
    --header-height: 64px;
  }

  html,
  body {
    width: 100%;
    min-width: 320px;
    height: 100%;
  }

  body {
    overflow: hidden;
  }

  .app {
    display: block;
    width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  .app-body {
    width: 100%;
    height: 100%;
    grid-template-rows: var(--header-height) minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    z-index: 70;
    inset: auto 0 0;
    display: block;
    width: 100%;
    height: calc(76px + env(safe-area-inset-bottom));
    min-height: 0;
    border-top: 1px solid var(--border);
    border-right: 0;
    background: rgba(255, 255, 255, 0.97);
    padding: 7px 10px calc(9px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(25, 28, 42, 0.06);
    backdrop-filter: blur(14px);
  }

  .brand,
  .sidebar-profile {
    display: none;
  }

  .sidebar-nav {
    display: grid;
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
  }

  .nav-item {
    display: flex;
    width: 100%;
    height: 59px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    border-radius: 12px;
    padding: 0;
    font-size: 10px;
  }

  .nav-item span {
    display: block;
  }

  .nav-item svg {
    width: 19px;
    height: 19px;
  }

  .topbar {
    gap: 8px;
    min-width: 0;
    padding: 0 12px;
  }

  .search-field {
    width: auto;
    min-width: 0;
    height: 42px;
    flex: 1 1 auto;
    gap: 8px;
    border-radius: 11px;
    padding: 0 11px;
  }

  .search-field input {
    min-width: 0;
    font-size: 12px;
  }

  .search-field svg {
    width: 17px;
    height: 17px;
  }

  .topbar-actions {
    flex: 0 0 auto;
    gap: 7px;
  }

  .notification-button,
  .connect-new {
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 11px;
  }

  .notification-dot {
    top: 8px;
    right: 8px;
  }

  .workspace,
  .app.has-detail .workspace {
    grid-template-columns: minmax(0, 1fr) 0;
  }

  .content {
    padding: 21px 16px calc(102px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }

  .page-heading,
  .settings-heading {
    margin-bottom: 20px;
  }

  .page-heading h1,
  .settings-heading h1 {
    font-size: 26px;
  }

  .page-heading p,
  .settings-heading p {
    max-width: 320px;
    font-size: 12px;
    line-height: 1.5;
  }

  .stream-toolbar {
    display: block;
    margin-bottom: 16px;
  }

  .filter-tabs {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .filter-tab {
    width: 100%;
    height: 40px;
    padding: 0 6px;
    font-size: 11px;
  }

  .view-toggle {
    display: none;
  }

  .streams-grid,
  .app.has-detail .streams-grid,
  .streams-grid.list-view {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .stream-card,
  .streams-grid.list-view .stream-card {
    display: block;
    width: 100%;
    max-width: none;
  }

  .streams-grid.list-view .card-preview {
    aspect-ratio: 16 / 9;
  }

  .stream-card:hover {
    transform: none;
  }

  .card-body {
    min-height: 68px;
    padding: 13px 15px 14px;
  }

  .card-body h2 {
    font-size: 14px;
  }

  .status-badge,
  .live-badge {
    height: 29px;
    font-size: 10px;
  }

  .preview-topline {
    top: 11px;
    right: 11px;
    left: 11px;
  }

  .preview-signal {
    bottom: 10px;
    left: 11px;
    padding: 6px 8px;
  }

  .app.has-detail .detail-panel {
    position: fixed;
    z-index: 80;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-left: 0;
    box-shadow: none;
  }

  .detail-header {
    position: relative;
    z-index: 3;
    min-height: 58px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    padding: 7px 10px 7px 16px;
    backdrop-filter: blur(12px);
  }

  .detail-header > div {
    visibility: visible;
  }

  .detail-label {
    display: none;
  }

  .detail-header h2 {
    display: block;
    font-size: 16px;
  }

  .detail-scroll {
    padding: 14px 14px 30px;
  }

  .video-player {
    border-radius: 12px;
  }

  .stream-summary {
    padding: 17px 4px;
  }

  .stream-summary h3 {
    font-size: 17px;
  }

  .info-section {
    margin-bottom: 19px;
    padding: 16px;
  }

  .info-list div {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .connection-form {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .detail-connect-button {
    min-height: 50px;
  }

  .settings-layout {
    display: block;
    min-height: 0;
  }

  .settings-nav {
    display: grid;
    min-height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 14px;
    padding: 4px;
  }

  .settings-nav button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    justify-content: center;
    gap: 8px;
    padding: 0 8px;
    font-size: 11px;
  }

  .settings-nav button svg {
    width: 17px;
    height: 17px;
  }

  .settings-card {
    border-radius: 13px;
    padding: 16px;
  }

  .settings-card-heading {
    align-items: flex-start;
    gap: 11px;
  }

  .settings-card-icon {
    width: 40px;
    height: 40px;
  }

  .settings-card-heading h2 {
    font-size: 14px;
  }

  .settings-card-heading p {
    font-size: 11px;
    line-height: 1.45;
  }

  .password-fields,
  .create-user-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-form-actions .button,
  .create-account-button {
    width: 100%;
    min-width: 0;
  }

  .create-account-button {
    grid-column: auto;
    justify-self: stretch;
    margin-top: 2px;
  }

  .users-table {
    margin-top: 16px;
  }

  .users-table-head,
  .user-row {
    grid-template-columns: minmax(0, 1fr) auto 34px;
  }

  .users-table-head {
    padding: 0 7px;
  }

  .users-table-head span:nth-child(2) {
    display: none;
  }

  .user-row {
    padding-left: 8px;
  }

  .role-badge {
    padding: 4px 6px;
    font-size: 8px;
  }

  .logout-card {
    align-items: stretch;
    flex-direction: column;
  }

  .logout-button {
    width: 100%;
    min-width: 0;
  }

  .modal-backdrop {
    align-items: end;
    padding: 12px;
  }

  .modal {
    width: 100%;
    border-radius: 20px 20px 14px 14px;
    padding: 22px 18px 18px;
  }

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

  .modal-actions .button {
    min-width: 0;
    padding-inline: 10px;
  }

  .toast-region {
    right: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
  }

  .empty-state {
    min-height: 280px;
  }
}

@media (max-width: 390px) {
  .topbar {
    padding-inline: 10px;
  }

  .notification-button {
    display: none;
  }

  .content {
    padding-inline: 13px;
  }

  .info-list div {
    grid-template-columns: 94px minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .auth-gate {
    place-items: start center;
    padding: 20px 14px;
  }

  .auth-card {
    margin-top: max(18px, env(safe-area-inset-top));
    border-radius: 16px;
    padding: 24px 20px;
  }

  .auth-heading {
    margin: 28px 0 22px;
  }

  .auth-heading h1 {
    font-size: 27px;
  }
}

@media (max-width: 700px) and (orientation: landscape) {
  .sidebar {
    height: 64px;
    padding-block: 4px;
  }

  .nav-item {
    height: 54px;
  }

  .content {
    padding-bottom: 80px;
  }
}

/* Wide viewing mode: the stream is the primary workspace, while module
   information remains available in a compact side column. */
@media (min-width: 1001px) {
  .app.has-detail.is-watching .workspace {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .app.is-watching .content {
    overflow: hidden;
    padding-inline: 0;
    opacity: 0;
    pointer-events: none;
  }

  .app.is-watching .detail-panel {
    border-left: 0;
  }

  .app.is-watching .detail-header {
    min-height: 58px;
    border-bottom: 1px solid var(--border);
    padding: 8px 14px 8px 24px;
  }

  .app.is-watching .detail-header > div {
    visibility: visible;
  }

  .app.is-watching .detail-label {
    display: none;
  }

  .app.is-watching .detail-scroll {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 360px);
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: start;
    gap: 18px 24px;
    overflow: auto;
    padding: 20px 24px 24px;
  }

  .app.is-watching .video-player {
    grid-row: 1 / 4;
    grid-column: 1;
    align-self: center;
    width: 100%;
    max-height: calc(100dvh - var(--header-height) - 118px);
    border-radius: 14px;
  }

  .app.is-watching .stream-summary,
  .app.is-watching .info-section,
  .app.is-watching .connection-form {
    grid-column: 2;
    min-width: 0;
  }

  .app.is-watching .stream-summary {
    padding: 6px 4px 2px;
  }

  .app.is-watching .info-section {
    margin-bottom: 0;
  }

  .app.is-watching .connection-form {
    align-self: start;
  }
}

.video-player:fullscreen,
.video-player:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  background: #090b10;
}

@media (max-width: 700px) {
  .recordings-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .recording-row {
    grid-template-columns: 50px minmax(0, 1fr);
    align-items: start;
  }

  .recording-row-icon {
    width: 50px;
    height: 44px;
  }

  .recording-row-actions {
    grid-column: 1 / -1;
  }

  .recording-row-actions .recording-play-button {
    flex: 1;
  }

  .recording-viewer-backdrop {
    align-items: end;
    padding: 0;
  }

  .recording-viewer {
    width: 100%;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* iPhone / installed web app ------------------------------------------------ */
html {
  -webkit-text-size-adjust: 100%;
}

.mobile-brand,
.mobile-stream-search {
  display: none;
}

button,
input,
select,
textarea {
  touch-action: manipulation;
}

.ios-install-banner {
  position: fixed;
  z-index: 140;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  width: min(430px, calc(100vw - 28px));
  margin-inline: auto;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(121, 102, 242, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  padding: 12px;
  box-shadow: 0 18px 48px rgba(31, 28, 64, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.ios-install-banner.in-app {
  bottom: calc(88px + env(safe-area-inset-bottom));
}

.ios-install-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.ios-install-icon svg {
  width: 21px;
  height: 21px;
}

.ios-install-banner > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ios-install-banner strong {
  font-size: 13px;
}

.ios-install-banner > div > span {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
}

.ios-install-banner button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.ios-install-banner button svg {
  width: 17px;
  height: 17px;
}

.pwa-standalone .ios-install-banner {
  display: none !important;
}

@media (max-width: 700px) {
  :root {
    --header-height: calc(58px + env(safe-area-inset-top));
  }

  body {
    overscroll-behavior: none;
  }

  .topbar {
    min-height: var(--header-height);
    align-items: flex-end;
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  }

  .mobile-brand {
    display: flex;
    min-width: 0;
    height: 42px;
    align-items: center;
    gap: 9px;
  }

  .mobile-brand-mark {
    display: inline-flex;
    width: 31px;
    height: 31px;
    flex: 0 0 auto;
    color: var(--primary);
  }

  .mobile-brand-mark svg {
    width: 100%;
    height: 100%;
  }

  .mobile-brand strong {
    overflow: hidden;
    font-size: 17px;
    letter-spacing: -0.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .search-field {
    display: none !important;
  }

  .notification-button {
    display: none;
  }

  .mobile-stream-search {
    display: flex;
    width: 100%;
    height: 46px;
    align-items: center;
    gap: 9px;
    margin: -4px 0 15px;
    border: 1px solid var(--border-strong);
    border-radius: 13px;
    background: var(--surface);
    padding: 0 13px;
    color: var(--text-muted);
    box-shadow: 0 1px 2px rgba(18, 23, 38, 0.02);
  }

  .mobile-stream-search:focus-within {
    border-color: rgba(121, 102, 242, 0.58);
    box-shadow: 0 0 0 3px rgba(121, 102, 242, 0.1);
  }

  .mobile-stream-search svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
  }

  .mobile-stream-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 16px;
  }

  .mobile-stream-search input::placeholder {
    color: var(--text-muted);
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .content {
    padding: 18px max(14px, env(safe-area-inset-right)) calc(90px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }

  .page-heading,
  .settings-heading {
    margin-bottom: 18px;
  }

  .page-heading h1,
  .settings-heading h1 {
    font-size: 25px;
    letter-spacing: -0.035em;
  }

  .sidebar {
    height: calc(70px + env(safe-area-inset-bottom));
    padding: 5px max(8px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .nav-item {
    height: 58px;
    border-radius: 13px;
  }

  .connect-new {
    width: 42px;
    min-width: 42px;
  }

  .detail-header {
    min-height: calc(58px + env(safe-area-inset-top));
    padding: calc(7px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 7px max(16px, env(safe-area-inset-left));
  }

  .detail-scroll {
    padding: 14px max(14px, env(safe-area-inset-right)) calc(30px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }

  .modal-backdrop {
    padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .auth-gate {
    padding: max(20px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-card {
    margin-top: 0;
  }

  .recording-viewer {
    max-height: calc(100dvh - env(safe-area-inset-top) - 10px);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .toast-region {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 370px) {
  .mobile-brand strong {
    display: none;
  }
}

/* Device access keys stay visually protected without exposing a password
   input to browser credential managers. */
input[data-device-secret] {
  -webkit-text-security: disc;
}

input[data-device-secret].is-revealed {
  -webkit-text-security: none;
}

@media (max-width: 700px) {
  html,
  body,
  .app,
  .auth-gate {
    touch-action: pan-x pan-y;
  }
}
