/* 样式以原型为准（https://live-home-nov06.vercel.app/），去掉了底部导航
   最低兼容 iOS 12：不用 aspect-ratio / inset / flex gap / clamp / :has */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #191919;
  color: #fff;
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; color: inherit; }

.app {
  max-width: 580px;
  margin: auto;
  padding: 0 10px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* 搜索 */
header {
  height: 58px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #343434;
}
.top-search {
  flex: 1;
  min-width: 0;
  height: 36px;
  background: #282828;
  border: 1px solid #3b3b3b;
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 0 5px 0 12px;
  margin: 0;
}
.top-search:focus-within { border-color: #9bb86e; }
.top-search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #9398a0;
  stroke-width: 1.7;
  flex-shrink: 0;
  margin-right: 8px;
}
.top-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: none;
  background: none;
  font-size: 14px;
  color: #fff;
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
  margin-right: 8px;
}
.top-search input::-webkit-search-cancel-button { display: none; }
.top-search button {
  background: #444;
  color: #fff;
  border-radius: 16px;
  padding: 5px 13px;
  font-size: 12px;
}

/* 标签 */
.tabs {
  margin-top: 10px;
  height: 40px;
  background: #262626;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 15px;
}
.tabs button {
  position: relative;
  background: none;
  padding: 0;
  margin: 0 24px;
  color: #b9b9c2;
  font-size: 14px;
  white-space: nowrap;
}
.tabs button.active { color: #fff; font-weight: bold; }
.tabs button.active:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 9px;
  right: 9px;
  height: 3px;
  background: #fff;
}

/* 卡片 */
.grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-gap: 10px 8px;
  gap: 10px 8px;
}
.card {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border-radius: 7px;
  overflow: hidden;
  background: #242424;
  text-align: left;
  color: #fff;
  transition: transform .15s;
}
.card:hover { transform: translateY(-2px); }
.cover {
  position: relative;
  height: 0;
  padding-top: 100%;
  overflow: hidden;
  background: #333;
}
.cover-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 封面是竖屏截图，脸一般在上半部分 */
  object-position: center 25%;
  display: block;
}
.cover-img:not([src]) { visibility: hidden; }
.cover:after {
  content: "";
  position: absolute;
  top: 55%;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
  pointer-events: none;
}
.live-badge, .room-type {
  position: absolute;
  z-index: 1;
  top: 0;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
  color: #fff;
}
.live-badge {
  right: 0;
  padding: 3px 7px;
  border-radius: 0 0 4px 4px;
  background: rgba(65, 65, 65, .93);
}
.live-badge.performing { background: #8d3ec7; }
.room-type {
  left: 0;
  height: 21px;
  min-width: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 5px;
  background: rgba(68, 68, 68, .8);
  border-radius: 0 0 5px 0;
}
.room-type.newcomer-badge { font-size: 11px; line-height: 17px; }
.room-type.toy-badge { width: 25px; padding: 1px 3px; }
.toy-badge svg { display: block; width: 21px; height: 18px; }
.cover-meta {
  position: absolute;
  z-index: 2;
  bottom: 4px;
  left: 5px;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 12px;
  font-weight: bold;
}
.rating {
  display: flex;
  align-items: center;
  background: rgba(37, 37, 37, .79);
  padding: 2px 3px;
  border-radius: 2px;
  white-space: nowrap;
}
.rating > * { margin-right: 3px; }
.rating > :last-child { margin-right: 0; }
.rating strong { font-size: 12px; color: #ffd900; }
.rating small { font-size: 9px; color: #a9bed1; font-weight: normal; }
.flag-icon {
  display: block;
  width: 16px;
  height: 11px;
  object-fit: contain;
  flex: 0 0 16px;
  border-radius: 1px;
}
.room-info { padding: 7px 7px 6px; min-height: 44px; }
.room-name, .room-description {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 17px;
}
.room-name { font-weight: bold; }
.room-description { color: #d1d1d1; font-size: 11px; }

#empty { display: none; text-align: center; color: #aaa; padding: 35px 0; font-size: 14px; }

/* 底部：加载中 / 加载更多 / 重试 / 没有更多 */
.more { min-height: 56px; display: flex; align-items: center; justify-content: center; color: #888; font-size: 13px; }
.more span { display: flex; align-items: center; }
.more i {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .2);
  border-top-color: #ccc;
  animation: spin .8s linear infinite;
}
.more button { background: #262626; color: #ccc; font-size: 13px; padding: 8px 18px; border-radius: 16px; }
.more-error button { color: #f0a0a0; }

@media (max-width: 400px) {
  .tabs button { margin: 0 18px; }
  .live-badge { font-size: 10px; padding: 3px 4px; }
  .room-type { font-size: 10px; }
  .rating { padding: 2px; }
  .rating > * { margin-right: 1px; }
  .rating strong { font-size: 10px; }
  .rating small { font-size: 8px; }
  .cover-meta { left: 3px; right: 2px; font-size: 10px; }
  .flag-icon { width: 14px; height: 10px; flex-basis: 14px; }
}

/* PC：原型只有手机版，这里放宽内容区、增加列数 */
@media (min-width: 761px) {
  .app { max-width: 1200px; padding: 0 24px 40px; }
  header { height: 68px; }
  .top-search { flex: 0 1 480px; margin: 0 auto; }
  .tabs { margin-top: 14px; height: 46px; }
  .tabs button { font-size: 15px; margin: 0 32px; }
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-gap: 16px 14px; gap: 16px 14px; margin-top: 16px; }
  .room-info { padding: 9px 10px 8px; }
  .room-name { font-size: 14px; line-height: 20px; }
  .room-description { font-size: 12px; line-height: 18px; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* 提示与加载 */
.toast {
  position: fixed;
  left: 50%;
  top: 45%;
  z-index: 20;
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .82);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  transition: opacity .2s, visibility .2s;
}
.toast.show { opacity: 1; visibility: visible; }
.loading {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(0, 0, 0, .55);
  color: #ddd;
  font-size: 13px;
}
.loading.show { display: flex; }
.loading i {
  width: 30px;
  height: 30px;
  margin-bottom: 12px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
