:root {
  color-scheme: dark;
  --bg: #090c0b;
  --panel: #131816;
  --panel-soft: #0e1210;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f6f4;
  --muted: #929d97;
  --accent: #45df91;
  --accent-ink: #062516;
  --danger: #ff807a;
  --warning: #f3c86c;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(69, 223, 145, 0.36);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.site-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(69, 223, 145, 0.4);
  border-radius: 11px;
  color: var(--accent);
  background: rgba(69, 223, 145, 0.07);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.login-view {
  display: grid;
  width: 100%;
  max-width: 420px;
  min-height: calc(100vh - 24px);
  margin: 0 auto;
  align-content: center;
  gap: 24px;
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.03em;
}

.form-description {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.field-label {
  margin-bottom: -7px;
  color: #c0c8c3;
  font-size: 13px;
  font-weight: 650;
}

.token-field {
  position: relative;
}

.token-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 72px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: #0a0e0c;
}

.token-field input:focus {
  border-color: rgba(69, 223, 145, 0.7);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(69, 223, 145, 0.08);
}

.token-field input::placeholder {
  color: #6e7872;
}

.visibility-button {
  position: absolute;
  top: 50%;
  right: 7px;
  min-width: 48px;
  min-height: 38px;
  padding: 0 8px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 9px;
  color: #b5beb9;
  background: transparent;
  font-size: 12px;
}

.field-hint,
.form-error {
  min-height: 18px;
  margin: -8px 0 0;
  font-size: 12px;
}

.field-hint {
  color: #78837d;
}

.form-error {
  color: var(--danger);
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.inline-button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  font-weight: 650;
}

.primary-button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  color: var(--accent-ink);
  background: var(--accent);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.inline-button:disabled {
  cursor: wait;
  opacity: 0.46;
}

.button-arrow {
  font-size: 20px;
  font-weight: 400;
}

.app-view {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.header-actions,
.player-actions,
.list-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.service-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #bbc4bf;
  font-size: 12px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(69, 223, 145, 0.08);
}

.text-button,
.inline-button {
  min-height: 40px;
  padding: 0 11px;
  color: #b6c0ba;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
}

.dashboard {
  display: grid;
  gap: 10px;
}

.player-panel,
.stream-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.player-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.player-heading,
.player-footer,
.panel-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-heading h2,
.panel-heading h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 670;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 10px;
}

.connection-badge > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.connection-badge strong {
  font-weight: 650;
}

.connection-badge.is-working {
  color: var(--warning);
}

.connection-badge.is-live {
  color: var(--accent);
}

.connection-badge.is-error {
  color: var(--danger);
}

.video-shell {
  position: relative;
  display: grid;
  width: min(100%, 420px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #030504;
}

.video-shell video {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.video-placeholder,
.video-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 20px;
  text-align: center;
  background: radial-gradient(circle, #18211c, #050706 72%);
}

.placeholder-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 11px;
  place-items: center;
  border: 1px solid rgba(69, 223, 145, 0.27);
  border-radius: 14px;
  color: var(--accent);
  background: rgba(69, 223, 145, 0.06);
  font-size: 12px;
  font-weight: 800;
}

.video-placeholder h3,
.video-loading strong {
  margin: 0;
  font-size: 14px;
}

.video-placeholder p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.video-loading {
  gap: 12px;
  background: rgba(3, 5, 4, 0.9);
}

.loading-ring {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(69, 223, 145, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.connection-detail {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-button,
.danger-button {
  min-width: 58px;
  min-height: 40px;
  padding: 0 11px;
  font-size: 12px;
}

.secondary-button {
  color: #d8dfdb;
  background: rgba(255, 255, 255, 0.07);
}

.danger-button {
  color: #ffc0bc;
  background: rgba(255, 128, 122, 0.09);
}

.stream-panel {
  padding: 14px;
}

.count-badge {
  display: grid;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  place-items: center;
  border-radius: 9px;
  color: var(--accent);
  background: rgba(69, 223, 145, 0.08);
  font-size: 11px;
  font-weight: 750;
}

.inline-button {
  min-height: 34px;
  padding: 0 9px;
}

.stream-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.stream-card {
  display: grid;
  width: 100%;
  min-height: 56px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
}

.stream-card.is-selected {
  border-color: rgba(69, 223, 145, 0.36);
  background: rgba(69, 223, 145, 0.08);
}

.stream-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

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

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

.stream-copy span,
.viewer-count {
  color: var(--muted);
  font-size: 10px;
}

.viewer-count {
  white-space: nowrap;
}

.empty-state {
  display: grid;
  min-height: 112px;
  place-content: center;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-symbol {
  margin-bottom: 7px;
  color: #39433d;
  font-size: 18px;
}

.empty-state h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: #1a211d;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.38);
  font-size: 12px;
}

@media (min-width: 700px) {
  .site-shell {
    padding: 20px;
  }

  .app-header {
    margin-bottom: 16px;
  }

  .player-panel {
    padding: 18px;
  }

  .player-heading h2,
  .panel-heading h2 {
    font-size: 19px;
  }

  .toast {
    right: 20px;
    left: auto;
    width: max-content;
    max-width: min(420px, calc(100vw - 40px));
  }
}

@media (min-width: 920px) {
  .site-shell {
    padding: 28px;
  }

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

  .stream-panel {
    min-height: 100%;
  }

  .stream-list {
    max-height: calc(100vh - 190px);
    overflow-y: auto;
  }

  .video-shell {
    width: min(100%, 330px);
  }
}

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