:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --line: #d9e0e9;
  --line-strong: #c4cedb;
  --text: #182132;
  --muted: #65738a;
  --blue: #735cff;
  --blue-ink: #5f49e8;
  --blue-soft: #f0edff;
  --purple: #7a56e8;
  --purple-soft: #f0edff;
  --live: #16d8c0;
  --green: #82b366;
  --green-soft: #eef6eb;
  --red: #b85450;
  --red-soft: #f8eeee;
  --shadow: 0 12px 30px rgba(31, 42, 58, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { font: inherit; }
button { color: inherit; }

.page-shell {
  width: min(1380px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 22px 44px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 2px 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue-ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

h1 { margin: 0; font-size: clamp(27px, 4vw, 38px); line-height: 1.12; }
.intro { margin: 9px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.topbar-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.topbar-actions a, .refresh-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  padding: 8px 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}

.refresh-button { border-color: var(--text); background: var(--text); color: #fff; }
.refresh-button:disabled { cursor: wait; opacity: .72; }

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.status-copy { display: flex; align-items: center; gap: 11px; min-width: 0; }
.status-copy strong { display: block; font-size: 14px; }
.status-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.status-dot.loading { background: var(--blue); box-shadow: 0 0 0 4px rgba(108, 142, 191, .16); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(130, 179, 102, .16); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 4px rgba(184, 84, 80, .14); }
.status-time { display: grid; justify-items: end; gap: 3px; white-space: nowrap; }
.status-time span { color: var(--muted); font-size: 11px; }
.status-time strong { font-size: 13px; }

.group-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.group-tabs::-webkit-scrollbar { display: none; }
.group-tab {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--panel);
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}
.group-tab span { margin-left: 5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-tab.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-ink); }

.groups { display: grid; gap: 24px; }
.group-section { background: transparent; }
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 2px 12px;
  border-bottom: 1px solid var(--line);
}
.group-title { display: flex; align-items: center; gap: 9px; }
.group-title h2 { margin: 0; font-size: 17px; }
.group-mark { width: 5px; height: 20px; border-radius: 3px; background: var(--blue); }
.group-section[data-group="SNH"] .group-mark { background: var(--purple); }
.group-section[data-group="BEJ"] .group-mark { background: var(--green); }
.group-header span { color: var(--muted); font-size: 12px; }

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px 14px;
  padding-top: 14px;
}
.room-card {
  display: block;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.room-card:hover .room-cover, .room-card:focus-visible .room-cover { outline: 3px solid var(--blue); outline-offset: 2px; }
.room-card:focus-visible { outline: none; }
.room-card:disabled { cursor: wait; opacity: .68; }
.room-cover {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  background: #e8ebef;
  box-shadow: 0 3px 12px rgba(31, 42, 58, .09);
}
.cover-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.live-pill {
  position: absolute;
  top: 10px;
  right: 0;
  border-radius: 16px 0 0 16px;
  background: var(--live);
  color: #fff;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.room-title {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .75);
}
.type-pill {
  position: absolute;
  right: 9px;
  bottom: 9px;
  border-radius: 4px;
  background: var(--purple);
  color: #fff;
  padding: 3px 7px;
  font-size: 12px;
}
.type-pill.radio { background: #e7aa24; }
.type-pill + .room-title { right: 59px; }
.room-copy { display: flex; align-items: center; justify-content: space-between; gap: 9px; min-width: 0; padding: 9px 2px 0; }
.member-identity { display: flex; align-items: center; gap: 5px; min-width: 0; }
.room-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 650; }
.trainee-badge { flex: 0 0 auto; border-radius: 4px; background: #aab2bd; color: #fff; padding: 2px 4px; font-size: 9px; line-height: 1.2; }
.room-meta { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.play-label { display: none; }

.empty-state { border: 1px dashed var(--line-strong); border-radius: 9px; background: var(--panel); padding: 46px 20px; text-align: center; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.skeleton { height: 250px; border-radius: 10px; background: #e9edf3; animation: pulse 1.1s ease-in-out infinite alternate; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(90vw, 520px);
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 11px 15px;
  box-shadow: 0 12px 32px rgba(24, 33, 50, .22);
  font-size: 13px;
}

@keyframes pulse { to { opacity: .55; } }

@media (max-width: 760px) {
  .page-shell { padding: 16px 12px 34px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .topbar-actions { width: 100%; }
  .topbar-actions a, .refresh-button { flex: 1; }
  .status-panel { align-items: flex-start; }
  .status-time { display: none; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 17px 10px; }
  .room-name { font-size: 14px; }
  .room-title { font-size: 13px; }
  .live-pill { top: 8px; padding: 4px 10px; font-size: 12px; }
}

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