:root {
  color-scheme: light;
  --ink: #17181c;
  --muted: #737782;
  --line: #e7e8ec;
  --surface: #ffffff;
  --surface-soft: #f6f7f9;
  --accent: #ef477d;
  --accent-dark: #c92d61;
  --blue: #2878d0;
  --shadow: 0 18px 50px rgba(20, 23, 31, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--surface-soft);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--surface-soft);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1440px, 100%);
  min-height: 64px;
  margin: 0 auto;
  padding: 10px 24px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(260px, 560px);
  gap: 24px;
  align-items: center;
}

.brand {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-align: left;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 7px;
  font-weight: 900;
}

.search-box input {
  width: 100%;
  height: 42px;
  padding: 0 15px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 7px;
  outline: none;
}

.search-box input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 71, 125, 0.12);
}

.account-actions {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.account-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.plain-button {
  height: 38px;
  padding: 0 17px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d9dbe1;
  border-radius: 7px;
  font-weight: 700;
}

.plain-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.category-bar {
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.category-list {
  width: min(1440px, 100%);
  min-height: 56px;
  margin: 0 auto;
  padding: 9px 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-list::-webkit-scrollbar {
  display: none;
}

.category-button {
  min-width: max-content;
  height: 36px;
  padding: 0 17px;
  color: #5f636d;
  background: #f1f2f5;
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
}

.category-button[aria-selected="true"] {
  color: #fff;
  background: var(--accent);
}

.content-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 24px calc(48px + env(safe-area-inset-bottom));
}

.section-heading {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-panel {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #d8dae0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-light {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}

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

.video-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px 16px;
}

.video-card {
  width: 100%;
  min-width: 0;
  padding: 0;
  display: block;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.video-thumb {
  position: relative;
  width: 100%;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #e1e3e8;
  border-radius: 7px;
}

.video-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent 45%);
  pointer-events: none;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms ease, transform 220ms ease;
}

.video-thumb img.loaded {
  opacity: 1;
}

.video-card:hover .video-thumb img {
  transform: scale(1.025);
}

.duration {
  position: absolute;
  z-index: 2;
  right: 7px;
  bottom: 6px;
  padding: 3px 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.68);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.2;
}

.video-title {
  width: 100%;
  min-height: 42px;
  margin: 8px 1px 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: #2b2d33;
  font-size: 14px;
  line-height: 21px;
}

.load-sentinel {
  width: 100%;
  height: 1px;
  margin-top: 24px;
}

.modal[hidden],
[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 14, 0.78);
  backdrop-filter: blur(6px);
}

.player-dialog {
  position: relative;
  z-index: 1;
  width: min(1120px, 94vw);
  max-height: 94vh;
  overflow: hidden;
  background: #090a0c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-toolbar {
  min-height: 58px;
  padding: 10px 12px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
}

.player-toolbar h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.icon-button {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  border-radius: 50%;
  font-size: 25px;
  line-height: 1;
}

.icon-button-dark {
  color: #343740;
  background: #f0f1f4;
}

.player-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: #000;
}

.player-stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.player-loading,
.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: #fff;
  background: #090a0c;
  text-align: center;
}

.player-error {
  color: #ffb4c8;
}

.login-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 26px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.login-heading p {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.login-heading h2 {
  margin: 0;
  font-size: 25px;
}

.login-dialog form {
  margin-top: 22px;
  display: grid;
  gap: 16px;
}

.login-dialog label {
  display: grid;
  gap: 7px;
  color: #4f535d;
  font-size: 13px;
  font-weight: 700;
}

.login-dialog input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d9dbe1;
  border-radius: 7px;
  outline: none;
}

.login-dialog input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 71, 125, 0.12);
}

.primary-button {
  width: 100%;
  height: 46px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.form-error {
  margin: -4px 0 0;
  color: #ce2c43;
  font-size: 13px;
  line-height: 19px;
}

.login-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  max-width: min(440px, calc(100vw - 32px));
  padding: 11px 16px;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(19, 21, 26, 0.92);
  border-radius: 7px;
  box-shadow: var(--shadow);
  font-size: 13px;
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .video-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .header-inner {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 9px 14px;
  }

  .search-box {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .account-name {
    display: none;
  }

  .category-list,
  .content-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

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

@media (max-width: 560px) {
  .header-inner {
    min-height: 58px;
  }

  .brand {
    font-size: 17px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .plain-button {
    height: 36px;
    padding: 0 14px;
  }

  .category-list {
    min-height: 52px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .category-button {
    height: 34px;
    padding: 0 15px;
  }

  .content-shell {
    padding-top: 17px;
  }

  .section-heading h1 {
    font-size: 21px;
  }

  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 17px 10px;
  }

  .video-title {
    min-height: 38px;
    font-size: 13px;
    line-height: 19px;
  }

  .modal {
    padding: 0;
  }

  .player-dialog {
    width: 100vw;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .player-toolbar {
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .player-stage {
    aspect-ratio: auto;
    height: min(62vh, 72vw);
  }

  .login-dialog {
    align-self: end;
    width: 100%;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
  }
}
