:root {
  color-scheme: light;
  --bg: #f3f7fc;
  --text: #172033;
  --muted: #62738c;
  --line: #e2e9f3;
  --line-strong: #cfdbea;
  --accent: #1678d2;
  --accent-2: #4f7cff;
  --success: #0a8062;
  --danger: #d92d4b;
  --radius: 16px;
  --panel-shadow: 0 18px 48px rgba(36, 67, 112, 0.09);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1000px 560px at 8% -12%, rgba(79, 124, 255, 0.12), transparent 62%),
    radial-gradient(800px 480px at 94% -6%, rgba(53, 181, 255, 0.1), transparent 58%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

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

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid rgba(31, 137, 230, 0.65);
  outline-offset: 2px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 16px 0 24px;
  border-top: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #3fbdf7, #4169f5);
  box-shadow: 0 9px 22px rgba(52, 119, 245, 0.26);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-text strong {
  color: #15223a;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-text small {
  color: #8493aa;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.proto-switch {
  display: flex;
  gap: 2px;
  flex: none;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(244, 248, 253, 0.9);
}

.proto-link {
  min-width: 66px;
  padding: 7px 13px;
  border-radius: 999px;
  color: #63748d;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: center;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}

.proto-link:hover {
  color: #16233a;
  background: rgba(255, 255, 255, 0.9);
}

.proto-link.is-active {
  color: #fff;
  background: linear-gradient(135deg, #0b78c4, #3157d8);
  box-shadow: 0 6px 16px rgba(27, 95, 205, 0.2);
}

.layout {
  display: grid;
  flex: 1 0 auto;
  grid-template-columns: minmax(0, 1.6fr) minmax(350px, 1fr);
  align-items: start;
  gap: 22px;
  width: min(1440px, calc(100% - 48px));
  margin: 26px auto 22px;
}

.player-column {
  min-width: 0;
}

.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #cfdbeb;
  border-radius: var(--radius);
  background: #0a101a;
  box-shadow: 0 22px 52px rgba(32, 60, 105, 0.16), 0 2px 8px rgba(32, 60, 105, 0.06);
}

.player-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

#mse {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  color: #8194b2;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, rgba(35, 55, 89, 0.72), rgba(7, 12, 21, 0.98) 72%);
}

.placeholder-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 5px;
  border: 1px solid rgba(106, 178, 255, 0.26);
  border-radius: 50%;
  color: #7dcbff;
  background: rgba(52, 125, 205, 0.14);
  box-shadow: 0 0 44px rgba(60, 150, 255, 0.14);
}

.placeholder-icon svg {
  width: 27px;
  height: 27px;
}

.player-placeholder strong {
  color: #dce8f8;
  font-size: 15px;
  font-weight: 600;
}

.url-form {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.url-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(35, 63, 105, 0.04);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.url-field:focus-within {
  border-color: #84c8f7;
  box-shadow: 0 0 0 4px rgba(53, 160, 235, 0.12);
}

.field-icon {
  display: flex;
  flex: none;
  color: #8ba0ba;
}

.field-icon svg {
  width: 19px;
  height: 19px;
}

.url-field input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 13.5px;
  background: transparent;
}

input::placeholder,
textarea::placeholder {
  color: #95a3b9;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, filter 0.16s, transform 0.12s;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #0b78c4, #3157d8);
  box-shadow: 0 9px 20px rgba(27, 95, 205, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  color: #0b6fb8;
  background: #eaf5ff;
  border-color: #c8e4fb;
}

.btn-secondary:hover {
  background: #dff0ff;
}

.btn-ghost {
  color: #4c5d76;
  background: #fff;
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  color: #172033;
  background: #f4f9ff;
  border-color: #b9cee6;
}

.btn-danger-text:hover {
  color: #c72542;
  background: #fff1f3;
  border-color: #f0c0c9;
}

.url-submit {
  flex: none;
  height: 50px;
  padding: 0 22px;
  border-radius: 13px;
}

.player-notice {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #f1d08a;
  border-radius: 10px;
  color: #8a5a08;
  font-size: 12.5px;
  line-height: 1.55;
  background: #fff7e5;
}

.player-notice[data-type="error"] {
  color: #b4233c;
  border-color: #f2bdc7;
  background: #fff1f3;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 22px;
  margin-top: 12px;
  color: #64748d;
  font-size: 12.5px;
}

.live-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--success);
  animation: live-pulse 2.4s ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(13, 148, 112, 0.28);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(13, 148, 112, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(13, 148, 112, 0);
  }
}

.now-label {
  flex: none;
}

.now-playing strong {
  max-width: 52%;
  overflow: hidden;
  color: #172033;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-group {
  flex: none;
  padding: 2px 8px;
  border: 1px solid #cfe4f8;
  border-radius: 999px;
  color: #1774b6;
  font-size: 10.5px;
  background: #eef7ff;
}

.media-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.media-state {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: #fff;
}

.media-state.is-loading {
  color: #8a5a08;
  border-color: #f1d08a;
  background: #fff7e5;
}

.media-state.is-live {
  color: #0a8062;
  border-color: #bde8d8;
  background: #e9f8f2;
}

.media-state.is-vod {
  color: #0b6fb8;
  border-color: #c8e4fb;
  background: #eaf5ff;
}

.media-state.is-paused,
.media-state.is-ended {
  color: #64748d;
  border-color: #dde7f2;
  background: #f4f8fd;
}

.media-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  line-height: 22px;
  background: #fff;
}

.media-label {
  flex: none;
  color: #7a8ba2;
  font-size: 10.5px;
}

.media-item strong {
  color: #243449;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.list-column {
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--panel-shadow);
}

.import-panel {
  flex: none;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h1 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.panel-heading p {
  margin-top: 3px;
  color: #6e7f96;
  font-size: 11.5px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #788ba4;
  background: #f8fbff;
  cursor: pointer;
}

.icon-btn:hover {
  color: #172033;
  border-color: var(--line-strong);
  background: #f1f7fe;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.2s;
}

.import-panel.is-collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.import-panel.is-collapsed .import-body {
  display: none;
}

.import-body {
  margin-top: 12px;
}

#playlistInput {
  display: block;
  width: 100%;
  height: 132px;
  min-height: 96px;
  max-height: 260px;
  padding: 11px 13px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: #263650;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  background: #f8fbff;
  transition: border-color 0.18s, box-shadow 0.18s;
}

#playlistInput:focus {
  border-color: #8ecdf8;
  box-shadow: 0 0 0 4px rgba(53, 160, 235, 0.1);
}

.format-hints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  color: #6e7f96;
  font-size: 10.5px;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.import-actions .btn {
  height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 12.5px;
}

.actions-sep {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: var(--line);
}

.import-status {
  min-height: 17px;
  margin-top: 8px;
  color: #64748d;
  font-size: 11.5px;
  line-height: 1.5;
}

.import-status.is-success {
  color: var(--success);
}

.import-status.is-error {
  color: var(--danger);
}

.import-status.is-info {
  color: #0f74c5;
}

.list-panel {
  display: flex;
  flex-direction: column;
  min-height: 300px;
  margin-top: 16px;
  overflow: hidden;
}

.list-column .list-panel:first-child {
  margin-top: 0;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}

.list-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-title h2 {
  font-size: 13.5px;
  font-weight: 650;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  color: #0b78c4;
  font-size: 10.5px;
  font-weight: 650;
  background: #e7f5ff;
}

.text-btn {
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  color: #64748d;
  font-size: 11.5px;
  background: none;
  cursor: pointer;
}

.text-btn:hover {
  color: #c72542;
}

.list-search {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  margin: 0 16px 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.list-search:focus-within {
  border-color: #9fd4f8;
  box-shadow: 0 0 0 3px rgba(53, 160, 235, 0.09);
}

.search-icon {
  display: flex;
  flex: none;
  margin-right: 8px;
  color: #8ba0ba;
}

.search-icon svg {
  width: 16px;
  height: 16px;
}

#searchInput {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 12.5px;
  background: none;
}

#searchInput::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #8496ad;
  background: none;
  cursor: pointer;
}

.search-clear:hover {
  color: #172033;
  background: #eaf2fb;
}

.search-clear svg {
  width: 14px;
  height: 14px;
}

.playlist {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 130, 170, 0.28) transparent;
}

.playlist::-webkit-scrollbar {
  width: 8px;
}

.playlist::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(100, 130, 170, 0.26);
  background-clip: padding-box;
}

.playlist::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 130, 170, 0.42);
  background-clip: padding-box;
}

.group + .group {
  margin-top: 2px;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-radius: 8px;
  list-style: none;
  color: #6f8097;
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
}

.group-head::-webkit-details-marker {
  display: none;
}

.group-head:hover {
  background: #f4f9ff;
}

.group-head > svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: #8fa0b5;
  transition: transform 0.18s;
}

.group[open] > .group-head > svg {
  transform: rotate(90deg);
}

.group-name {
  min-width: 0;
  overflow: hidden;
  color: #3d4f68;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  flex: none;
  padding: 0 6px;
  border: 1px solid #e4ecf6;
  border-radius: 999px;
  color: #6b7d95;
  font-size: 10px;
  background: #f3f7fc;
}

.group-body {
  padding: 1px 0 5px;
}

.channel {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text);
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.channel:hover {
  background: #f4f9ff;
}

.channel.is-active {
  border-color: #bde2fb;
  background: linear-gradient(90deg, #e7f5ff, #f4f9ff);
}

.ch-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  overflow: hidden;
  border: 1px solid #e4ecf6;
  border-radius: 7px;
  color: #1479c9;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #f1f6fc;
}

.ch-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ch-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ch-name {
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel.is-active .ch-name {
  color: #0b5f9e;
  font-weight: 600;
}

.ch-host {
  overflow: hidden;
  color: #6e7f96;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-action {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  color: #1787d6;
  opacity: 0;
  transform: translateX(2px);
  transition: opacity 0.14s, transform 0.14s;
}

.ch-action svg {
  width: 16px;
  height: 16px;
}

.channel:hover .ch-action,
.channel.is-active .ch-action {
  opacity: 1;
  transform: translateX(0);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 210px;
  padding: 24px;
  color: #6e7f96;
  font-size: 12px;
  text-align: center;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  color: #b5c5d9;
}

.empty-state strong {
  color: #53657e;
  font-size: 13px;
  font-weight: 600;
}

@media (hover: none) {
  .ch-action {
    opacity: 0.35;
  }
}

@media (min-width: 981px) {
  .layout {
    height: calc(100vh - 127px);
    min-height: 580px;
  }

  .player-column {
    position: sticky;
    top: 26px;
  }

  .list-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    min-height: 0;
  }

  .list-panel {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 0;
  }
}

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

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    width: min(760px, calc(100% - 28px));
    margin: 18px auto 22px;
    gap: 18px;
  }

  .site-footer {
    width: min(760px, calc(100% - 28px));
  }

  .list-panel {
    max-height: 68vh;
  }

  .now-playing strong {
    max-width: 70%;
  }
}

@media (max-width: 620px) {
  .site-footer {
    gap: 10px;
    width: calc(100% - 24px);
    padding: 14px 0 20px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .brand-mark svg {
    width: 20px;
    height: 20px;
  }

  .brand-text strong {
    font-size: 14px;
  }

  .proto-switch {
    padding: 2px;
  }

  .proto-link {
    min-width: 56px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .layout {
    width: calc(100% - 24px);
    margin: 14px auto 18px;
    gap: 14px;
  }

  .player-frame {
    border-radius: 13px;
  }

  .player-placeholder {
    gap: 5px;
    font-size: 11px;
  }

  .placeholder-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 3px;
  }

  .placeholder-icon svg {
    width: 23px;
    height: 23px;
  }

  .player-placeholder strong {
    font-size: 14px;
  }

  .url-form {
    gap: 8px;
    margin-top: 10px;
  }

  .url-field {
    height: 46px;
    padding: 0 12px;
  }

  .url-field input {
    font-size: 12.5px;
  }

  .url-submit {
    height: 46px;
    padding: 0 16px;
  }

  .now-playing {
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 9px;
  }

  .now-playing strong {
    max-width: calc(100% - 90px);
  }

  .media-info {
    gap: 6px;
    margin-top: 8px;
  }

  .media-state,
  .media-item {
    height: 23px;
    line-height: 21px;
  }

  .media-state {
    padding: 0 9px;
  }

  .media-item {
    padding: 0 8px;
  }

  .import-panel {
    padding: 14px;
    border-radius: 14px;
  }

  #playlistInput {
    height: 118px;
    font-size: 11.5px;
  }

  .import-actions {
    gap: 6px;
  }

  .import-actions .btn {
    height: 34px;
    flex: 1 1 auto;
    padding: 0 10px;
    font-size: 12px;
  }

  .actions-sep {
    display: none;
  }

  .format-hints {
    font-size: 10px;
  }

  .list-panel {
    max-height: 66vh;
    margin-top: 0;
    border-radius: 14px;
  }

  .list-toolbar {
    padding: 12px 13px 9px;
  }

  .list-search {
    margin: 0 13px 8px;
  }

  .playlist {
    padding: 2px 7px 10px;
  }

  .group-head {
    padding: 8px 7px;
  }

  .channel {
    padding: 7px 7px;
  }
}

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