:root {
  --bg: #05060a;
  --bg-soft: #0c0f18;
  --panel: rgba(18, 22, 34, 0.72);
  --panel-solid: #11151f;
  --line: rgba(255, 255, 255, 0.10);
  --text: #e8ecf4;
  --muted: #9aa3b5;
  --accent: #ffd76a;
  --accent2: #5aa9ff;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, #0d1326 0%, var(--bg) 60%) fixed;
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- Starfield ---------- */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: repeat;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 140px 80px, #cfe3ff, transparent),
    radial-gradient(1px 1px at 90px 160px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 220px 50px, #fff, transparent),
    radial-gradient(1px 1px at 300px 200px, #bcd2ff, transparent);
  background-size: 350px 250px;
  opacity: 0.5;
  animation: drift 120s linear infinite;
}
.stars2 { background-size: 250px 200px; opacity: 0.35; animation-duration: 200s; }
.stars3 { background-size: 500px 400px; opacity: 0.25; animation-duration: 300s; }
@keyframes drift { from { background-position: 0 0; } to { background-position: 350px 250px; } }

main, .hero, .site-footer { position: relative; z-index: 1; }

/* ---------- Hero ---------- */
.hero {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px 40px;
  position: relative;
}
.hero::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 0;
  width: min(900px, 90%);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(255, 215, 106, 0.6), transparent);
}
.kicker {
  letter-spacing: 4px;
  font-size: 13px;
  color: var(--accent);
  margin: 0 0 14px;
  text-transform: uppercase;
  opacity: 0.9;
}
.hero h1 {
  font-size: clamp(34px, 7vw, 72px);
  margin: 0;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 0%, #c9d6ff 55%, #7fa8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(90, 169, 255, 0.25);
}
.subtitle {
  color: var(--muted);
  font-size: clamp(14px, 2.4vw, 19px);
  margin: 16px 0 30px;
  max-width: 640px;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 22px;
  min-width: 120px;
  backdrop-filter: blur(8px);
}
.stat b {
  display: block;
  font-size: 26px;
  color: var(--accent);
  font-weight: 800;
}
.stat span { font-size: 13px; color: var(--muted); }
.scroll-cue {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  animation: bob 1.8s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 8px); } }

/* ---------- Controls ---------- */
.controls {
  max-width: 1180px;
  margin: 30px auto 8px;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
}
.search-wrap { flex: 1 1 280px; max-width: 460px; }
#search {
  width: 100%;
  padding: 13px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#search:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(90,169,255,.18); }
.type-filter, .sort-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.sort-wrap { display: flex; align-items: center; gap: 10px; }
.sort-label { color: var(--muted); font-size: 13px; letter-spacing: 3px; white-space: nowrap; }
.sort-hint {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
[hidden] { display: none !important; }
.type-filter button, .sort-toggle button {
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
}
.type-filter button:hover, .sort-toggle button:hover { color: var(--text); border-color: var(--accent2); }
.type-filter button.active, .sort-toggle button.active {
  background: linear-gradient(180deg, #1b2746, #131b30);
  color: #fff;
  border-color: var(--accent2);
  box-shadow: 0 0 18px rgba(90,169,255,.25);
}

/* ---------- Era nav ---------- */
.era-nav {
  max-width: 1180px;
  margin: 18px auto 6px;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.era-nav button {
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.era-nav button:hover { color: #fff; }
.era-nav button .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- Timeline ---------- */
.timeline {
  max-width: 1180px;
  margin: 18px auto 40px;
  padding: 0 20px 40px;
}
.era-group { margin-bottom: 26px; }
.era-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0 16px;
  padding-left: 6px;
}
.era-head .bar { width: 5px; height: 30px; border-radius: 3px; }
.era-head h2 { margin: 0; font-size: 22px; letter-spacing: 1px; }
.era-head .range { color: var(--muted); font-size: 13px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--card-accent, var(--accent2));
  box-shadow: 0 16px 40px rgba(0,0,0,.5), 0 0 0 1px var(--card-accent, var(--accent2)) inset;
}
.card .poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: #0a0d16;
  border-bottom: 1px solid var(--line);
}
.card .body { padding: 14px 16px 16px; }
.card .meta-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .zh { font-size: 18px; font-weight: 800; margin: 0; }
.card .en { font-size: 12px; color: var(--muted); margin: 2px 0 8px; letter-spacing: .3px; }
.card .badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.accent { color: #07101f; font-weight: 700; }
.card .iu { color: var(--card-accent, var(--accent2)); font-weight: 700; font-size: 13px; }
.card .card-desc {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Era description ---------- */
.era-desc {
  margin: -2px 0 18px;
  padding: 12px 16px;
  max-width: 760px;
  font-size: 14px;
  line-height: 1.7;
  color: #c4cde0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--card-accent, var(--accent2));
  border-radius: 0 12px 12px 0;
}

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,4,9,.8); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  z-index: 1;
  width: min(880px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(0,0,0,.4);
  color: #fff; font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { background: rgba(255,80,80,.25); }
.modal-body { display: grid; grid-template-columns: 280px 1fr; gap: 0; }
.modal-body .m-poster { width: 100%; }
.modal-body .m-poster img { width: 100%; display: block; aspect-ratio: 2/3; object-fit: cover; }
.modal-body .m-info { padding: 26px 28px; }
.modal-body .m-info h2 { margin: 0 0 2px; font-size: 26px; }
.modal-body .m-info .m-en { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.modal-body .m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 8px 0 18px; }
.modal-body .m-grid div { font-size: 14px; }
.modal-body .m-grid span { color: var(--muted); display: block; font-size: 12px; }
.modal-body .m-desc { color: #d4dae8; font-size: 15px; line-height: 1.75; }
.modal-body .m-section { margin-top: 18px; }
.modal-body .m-section h4 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--accent);
  text-transform: uppercase;
}
.modal-body .m-section p { margin: 0; font-size: 14.5px; color: #d4dae8; line-height: 1.7; }
.modal-body .m-cast { color: #e8ecf4 !important; }
.modal-body .m-trivia {
  background: rgba(255, 215, 106, 0.07);
  border: 1px solid rgba(255, 215, 106, 0.22);
  border-radius: 10px;
  padding: 10px 14px !important;
  font-size: 13.5px;
  color: #e7d9b0 !important;
}

/* ---------- Footer ---------- */
.site-footer { padding: 40px 20px 70px; }
.footer-card {
  max-width: 880px; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px 30px;
}
.footer-card h3 { margin: 18px 0 8px; color: var(--accent); font-size: 16px; }
.footer-card h3:first-child { margin-top: 0; }
.footer-card p { color: var(--muted); font-size: 14px; margin: 0; }
.footer-card code { background: rgba(255,255,255,.08); padding: 2px 7px; border-radius: 6px; color: #ffe2a6; font-size: 13px; }
.footer-card .credit { margin-top: 16px; font-size: 12.5px; opacity: .7; }

/* ---------- Era description ---------- */
.era-desc {
  margin: 6px 2px 16px;
  color: var(--muted); font-size: 14px; line-height: 1.7;
  border-left: 3px solid var(--card-accent, var(--accent2));
  padding: 2px 0 2px 14px; max-width: 760px;
}

/* ---------- Modal sections ---------- */
.modal-body .m-desc { color: #d4dae8; font-size: 15px; line-height: 1.85; }
.modal-body .m-section { margin-top: 18px; }
.modal-body .m-section h4 {
  margin: 0 0 6px; font-size: 13px; letter-spacing: 1px;
  color: var(--accent); text-transform: uppercase;
}
.modal-body .m-cast { color: #e7ecf6; font-size: 14.5px; line-height: 1.7; margin: 0; }
.modal-body .m-trivia {
  color: #ffe2a6; font-size: 14px; line-height: 1.7; margin: 0;
  background: rgba(255,210,120,.07); border: 1px solid rgba(255,210,120,.18);
  border-radius: 10px; padding: 10px 12px;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-body .m-poster { max-width: 220px; margin: 20px auto 0; }
  .stat { min-width: 92px; padding: 11px 16px; }
  .stat b { font-size: 21px; }
}
