:root {
  --keke-accent: #f0b429;
  --keke-accent-strong: #d08a00;
  --keke-ink: #18251f;
  --keke-muted: #687d75;
  --keke-bg: #f6faf8;
  --keke-panel: #ffffff;
  --keke-line: #e0ebe5;
  --keke-soft: #eef7f2;
  --keke-dark: #121a18;
  --keke-radius: 8px;
}

html[data-portal-theme="dark"] {
  --keke-ink: #eef8f2;
  --keke-muted: #a7bab2;
  --keke-bg: #0f1715;
  --keke-panel: #151f1c;
  --keke-line: #26372f;
  --keke-soft: #1c2a25;
}

body.tpl-keke {
  margin: 0;
  min-width: 0;
  background: var(--keke-bg);
  color: var(--keke-ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body.tpl-keke a {
  color: inherit;
}

.keke-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--keke-panel) 94%, transparent);
  border-bottom: 1px solid var(--keke-line);
  backdrop-filter: blur(12px);
}

.keke-brand {
  width: 210px;
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.keke-brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
}

.keke-brand strong,
.keke-brand small {
  display: block;
  line-height: 1.15;
}

.keke-brand strong {
  font-size: 20px;
  font-weight: 800;
}

.keke-brand small {
  margin-top: 3px;
  color: var(--keke-muted);
  font-size: 12px;
}

.keke-search {
  flex: 1;
  max-width: 620px;
  display: flex;
  min-width: 180px;
}

.keke-search input {
  min-width: 0;
  flex: 1;
  height: 44px;
  border: 0;
  border-radius: 8px 0 0 8px;
  padding: 0 16px;
  background: var(--keke-soft);
  color: var(--keke-ink);
  font-size: 15px;
}

.keke-search button,
.keke-pill {
  height: 44px;
  border: 0;
  border-radius: 0 8px 8px 0;
  padding: 0 18px;
  background: var(--keke-accent);
  color: #211907;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.keke-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.keke-pill {
  border-radius: 22px;
  background: #dff6e8;
  color: #15452d;
}

html[data-portal-theme="dark"] .keke-pill {
  background: #213a2d;
  color: #dff6e8;
}

.keke-pill em {
  font-style: normal;
}

.keke-menu {
  display: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--keke-soft);
  color: var(--keke-ink);
  place-items: center;
}

.keke-menu span {
  width: 18px;
  height: 2px;
  background: currentColor;
  display: block;
  margin: 3px auto;
}

.keke-sidebar {
  position: fixed;
  top: 72px;
  left: 0;
  bottom: 0;
  z-index: 30;
  width: 210px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 16px;
  background: var(--keke-panel);
  border-right: 1px solid var(--keke-line);
}

.keke-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--keke-muted);
  text-decoration: none;
  font-weight: 700;
}

.keke-sidebar a.current,
.keke-sidebar a:hover {
  background: var(--keke-accent);
  color: #211907;
}

.keke-main {
  margin-left: 210px;
  padding: 28px;
  max-width: 1640px;
}

.keke-main.narrow {
  max-width: 1280px;
}

.keke-breadcrumb {
  margin-bottom: 18px;
  color: var(--keke-muted);
  font-size: 14px;
}

.keke-breadcrumb ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.keke-breadcrumb li + li::before {
  content: "›";
  margin-right: 9px;
  color: color-mix(in srgb, var(--keke-muted) 60%, transparent);
}

.keke-hero {
  min-height: 360px;
  border-radius: var(--keke-radius);
  overflow: hidden;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  padding: 44px;
  background: linear-gradient(120deg, #1e3c39 0%, #36584a 48%, #d19a38 100%);
  color: #fff;
}

.keke-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgb(0 0 0 / .28), rgb(0 0 0 / .05));
  pointer-events: none;
}

.keke-hero > * {
  position: relative;
  z-index: 1;
}

.keke-eyebrow {
  margin: 0 0 10px;
  color: var(--keke-accent);
  font-weight: 800;
}

.keke-hero h1,
.keke-page-title h1,
.keke-detail-title,
.keke-player-title {
  margin: 0;
  font-size: 40px;
  line-height: 1.18;
  letter-spacing: 0;
}

.keke-hero p {
  max-width: 680px;
  color: rgb(255 255 255 / .82);
  font-size: 17px;
  line-height: 1.75;
}

.keke-hero-card {
  align-self: end;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-radius: var(--keke-radius);
  background: rgb(8 20 18 / .62);
  border: 1px solid rgb(255 255 255 / .16);
}

.keke-hero-card img,
.keke-poster img,
.keke-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.keke-hero-card img {
  aspect-ratio: 2 / 3;
  border-radius: 6px;
}

.keke-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.keke-btn,
.keke-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 22px;
  padding: 0 20px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.keke-btn {
  background: var(--keke-accent);
  color: #211907;
}

.keke-btn-secondary {
  background: color-mix(in srgb, var(--keke-panel) 82%, transparent);
  border-color: var(--keke-line);
  color: var(--keke-ink);
}

.keke-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
}

.keke-section,
.keke-panel {
  margin-top: 28px;
}

.keke-section-head,
.keke-page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.keke-section-head h2,
.keke-panel h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.keke-section-head a {
  color: var(--keke-muted);
  text-decoration: none;
  font-weight: 700;
}

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

.keke-grid.wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.keke-card {
  min-width: 0;
}

.keke-poster {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--keke-radius);
  aspect-ratio: 2 / 3;
  background: var(--keke-soft);
  text-decoration: none;
}

.keke-poster .badge {
  position: absolute;
  left: 8px;
  top: 8px;
  max-width: calc(100% - 16px);
  border-radius: 6px;
  padding: 4px 7px;
  background: #35b66f;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.keke-poster .status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 8px 8px;
  background: linear-gradient(180deg, transparent, rgb(0 0 0 / .72));
  color: #fff;
  font-size: 13px;
  text-align: center;
}

.keke-card h3,
.keke-card h2 {
  margin: 9px 0 4px;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
}

.keke-card h3 a,
.keke-card h2 a {
  text-decoration: none;
}

.keke-card p {
  margin: 0;
  color: var(--keke-muted);
  font-size: 13px;
  line-height: 1.45;
}

.keke-rank {
  position: sticky;
  top: 92px;
  align-self: start;
  padding: 18px;
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  border: 1px solid var(--keke-line);
}

.keke-rank ol {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.keke-rank li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.keke-rank i {
  font-style: normal;
  color: var(--keke-accent-strong);
  font-weight: 900;
}

.keke-rank a {
  display: block;
  text-decoration: none;
  font-weight: 800;
  line-height: 1.35;
}

.keke-rank small {
  display: block;
  margin-top: 4px;
  color: var(--keke-muted);
}

.keke-filter {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 16px;
  border-radius: var(--keke-radius);
  border: 1px solid var(--keke-line);
  background: var(--keke-panel);
}

.keke-filter-line {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.keke-filter-line strong {
  line-height: 34px;
  color: var(--keke-muted);
}

.keke-filter-line div,
.keke-sortline,
.keke-chip-row,
.keke-lines,
.keke-episodes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keke-filter a,
.keke-sortline a,
.keke-chip,
.keke-lines a,
.keke-episodes a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--keke-soft);
  color: var(--keke-ink);
  text-decoration: none;
  white-space: nowrap;
}

.keke-filter a.active,
.keke-sortline a.active,
.keke-lines a.current,
.keke-episodes a.active {
  background: var(--keke-accent);
  color: #211907;
  font-weight: 800;
}

.keke-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}

.keke-meta span,
.keke-meta a,
.keke-inline-action {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--keke-soft);
  color: var(--keke-muted);
  text-decoration: none;
  font-weight: 700;
}

.keke-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.keke-list {
  display: grid;
  gap: 14px;
}

.keke-list article {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  border: 1px solid var(--keke-line);
}

.keke-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 8px;
  background: var(--keke-soft);
}

.keke-article {
  padding: 24px;
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  border: 1px solid var(--keke-line);
}

.keke-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.keke-form-card {
  padding: 18px;
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  border: 1px solid var(--keke-line);
}

.keke-form-card label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--keke-muted);
}

.keke-form-card input,
.keke-form-card textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 42px;
  border: 1px solid var(--keke-line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--keke-soft);
  color: var(--keke-ink);
}

.keke-form-card textarea {
  min-height: 90px;
  padding-top: 10px;
}

.keke-player-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
}

.keke-player-tools button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  color: #fff;
  background: rgb(255 255 255 / .18);
}

.keke-detail {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
  border-radius: var(--keke-radius);
  background: linear-gradient(120deg, var(--keke-soft), var(--keke-panel));
  border: 1px solid var(--keke-line);
}

.keke-detail .keke-poster {
  align-self: start;
}

.keke-summary {
  color: var(--keke-muted);
  font-size: 16px;
  line-height: 1.8;
}

.keke-info-card {
  padding: 20px;
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  border: 1px solid var(--keke-line);
}

.keke-info-card + .keke-info-card {
  margin-top: 18px;
}

.keke-video-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 360px;
  gap: 20px;
}

.keke-video {
  min-height: 520px;
  border-radius: var(--keke-radius);
  overflow: hidden;
  background: #0a0a0a;
  display: grid;
  place-items: center;
}

.keke-video video,
.keke-video iframe {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
}

.keke-play-side {
  padding: 22px;
  border-radius: var(--keke-radius);
  background: #202220;
  color: #fff;
}

.keke-search-empty,
.keke-empty,
.keke-error {
  padding: 36px;
  border: 1px dashed var(--keke-line);
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  text-align: center;
}

.keke-profile {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 20px;
  padding: 24px;
  border-radius: var(--keke-radius);
  border: 1px solid var(--keke-line);
  background: var(--keke-panel);
}

.keke-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--keke-accent);
  color: #211907;
  font-size: 30px;
  font-weight: 900;
}

.keke-comment-list,
.keke-link-grid,
.keke-actor-grid {
  display: grid;
  gap: 12px;
}

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

.keke-link-grid a,
.keke-comment-list article,
.keke-actor-grid a {
  padding: 14px;
  border-radius: var(--keke-radius);
  background: var(--keke-panel);
  border: 1px solid var(--keke-line);
  text-decoration: none;
}

.keke-link-grid strong,
.keke-actor-grid strong {
  display: block;
  margin-bottom: 5px;
}

.keke-link-grid span,
.keke-actor-grid span {
  color: var(--keke-muted);
  font-size: 13px;
}

.keke-dock {
  display: none;
}

@media (max-width: 1180px) {
  .keke-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .keke-layout,
  .keke-video-layout {
    grid-template-columns: 1fr;
  }
  .keke-rank {
    position: static;
  }
}

@media (max-width: 900px) {
  .keke-topbar {
    height: 60px;
    gap: 10px;
    padding: 0 14px;
  }
  .keke-menu {
    display: grid;
    flex: 0 0 40px;
  }
  .keke-brand {
    width: auto;
    min-width: 0;
    flex: 0 1 auto;
  }
  .keke-brand-logo {
    width: 36px;
    height: 36px;
  }
  .keke-brand strong {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
  }
  .keke-brand small,
  .keke-search button,
  .keke-actions a {
    display: none;
  }
  .keke-search {
    max-width: none;
    min-width: 72px;
    flex: 1;
  }
  .keke-search input {
    height: 38px;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 14px;
  }
  .keke-pill {
    width: 42px;
    height: 38px;
    padding: 0;
  }
  .keke-pill em {
    display: none;
  }
  .keke-sidebar {
    top: 60px;
    width: min(82vw, 300px);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 14px 0 30px rgb(0 0 0 / .2);
  }
  .keke-sidebar.nav-open {
    transform: translateX(0);
  }
  .keke-main {
    margin-left: 0;
    padding: 16px 14px calc(92px + env(safe-area-inset-bottom));
  }
  .keke-hero {
    min-height: 300px;
    display: block;
    padding: 28px 20px;
  }
  .keke-hero h1,
  .keke-page-title h1,
  .keke-detail-title,
  .keke-player-title {
    font-size: 28px;
    line-height: 1.25;
  }
  .keke-hero-card {
    grid-template-columns: 86px minmax(0, 1fr);
    margin-top: 22px;
  }
  .keke-section-head,
  .keke-page-title {
    align-items: start;
    display: block;
  }
  .keke-grid,
  .keke-grid.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .keke-filter {
    padding: 12px;
  }
  .keke-filter-line {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .keke-filter-line div,
  .keke-sortline {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .keke-filter-line div::-webkit-scrollbar,
  .keke-sortline::-webkit-scrollbar {
    display: none;
  }
  .keke-detail {
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
  }
  .keke-summary {
    font-size: 14px;
    line-height: 1.65;
  }
  .keke-video,
  .keke-video video,
  .keke-video iframe {
    min-height: 220px;
  }
  .keke-play-side {
    padding: 16px;
  }
  .keke-link-grid {
    grid-template-columns: 1fr;
  }
  .keke-list article {
    grid-template-columns: 96px minmax(0, 1fr);
    padding: 10px;
  }
  .keke-form-grid {
    grid-template-columns: 1fr;
  }
  .keke-profile {
    grid-template-columns: 64px minmax(0, 1fr);
    padding: 16px;
  }
  .keke-avatar {
    width: 64px;
    height: 64px;
    font-size: 22px;
  }
  .keke-dock {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 50;
    display: flex;
    gap: 4px;
    padding: 6px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--keke-panel) 96%, transparent);
    border: 1px solid var(--keke-line);
    box-shadow: 0 10px 28px rgb(0 0 0 / .18);
    overflow-x: auto;
    white-space: nowrap;
  }
  .keke-dock a {
    flex: 1 0 66px;
    min-width: 66px;
    display: grid;
    gap: 2px;
    justify-items: center;
    border-radius: 10px;
    padding: 7px 5px;
    color: var(--keke-muted);
    text-decoration: none;
    font-size: 12px;
  }
  .keke-dock a.current {
    background: #dff6e8;
    color: #15452d;
  }
  html[data-portal-theme="dark"] .keke-dock a.current {
    background: #213a2d;
    color: #dff6e8;
  }
}
