:root {
  --paper: #f7f5f0;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #78756f;
  --line: #dfdcd5;
  --red: #e7463a;
  --red-dark: #c83229;
  --soft-red: #fff0ed;
  --green: #299764;
  --radius: 18px;
  --shadow: 0 18px 60px rgba(30, 25, 18, .1);
  --content: min(1280px, calc(100vw - 48px));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow-x: hidden; color: var(--ink); background: var(--paper); font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
img { display: block; max-width: 100%; }

.site-header { position: sticky; top: 0; z-index: 40; border-bottom: 1px solid rgba(223, 220, 213, .85); background: rgba(247, 245, 240, .92); backdrop-filter: blur(18px); }
.header-inner { width: var(--content); min-height: 76px; margin: auto; display: grid; grid-template-columns: auto minmax(260px, 1fr) minmax(240px, 340px) auto; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--red); font: 900 19px/1 Georgia, serif; transform: rotate(-8deg); }
.brand strong { display: block; font: 800 20px/1.05 Georgia, "Songti SC", serif; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; letter-spacing: .26em; }
.nav-tabs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab { flex: 0 0 auto; padding: 10px 13px; border: 0; border-radius: 999px; color: #5f5c57; background: transparent; cursor: pointer; }
.nav-tab.active { color: var(--red); background: var(--soft-red); font-weight: 700; }
.search-form { height: 42px; display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.search-form input { width: 100%; min-width: 0; padding: 0 0 0 17px; border: 0; outline: 0; background: transparent; }
.search-form button { width: 46px; border: 0; color: white; background: var(--red); font-size: 22px; cursor: pointer; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.history-button, .source-button { display: flex; align-items: center; gap: 8px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; white-space: nowrap; font-size: 13px; }
.history-button { color: var(--red); font-weight: 700; }
.history-icon { font-size: 17px; line-height: 1; }
.source-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(41, 151, 100, .12); }

.view { display: none; }
.view.active { display: block; }
.content-shell { width: var(--content); margin: auto; }
.hero { width: var(--content); min-height: 430px; margin: 26px auto 38px; border-radius: 26px; overflow: hidden; position: relative; background: #27231f; box-shadow: var(--shadow); }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .72; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(14, 11, 9, .92) 4%, rgba(14, 11, 9, .62) 42%, rgba(14, 11, 9, .08) 75%), linear-gradient(0deg, rgba(14, 11, 9, .42), transparent 60%); }
.hero-content { position: relative; z-index: 2; width: min(620px, 65%); padding: 72px 66px; color: white; }
.hero-kicker, .eyebrow { margin: 0 0 10px; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .2em; }
.hero h1 { margin: 0 0 16px; font: 800 clamp(38px, 5vw, 68px)/1.02 Georgia, "Songti SC", serif; }
.hero p { max-width: 560px; color: rgba(255,255,255,.78); font-size: 15px; line-height: 1.8; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 9px; margin: 23px 0; }
.hero-meta span { padding: 6px 10px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(255,255,255,.08); font-size: 12px; }
.primary-button { padding: 12px 22px; border: 0; border-radius: 999px; color: white; background: var(--red); font-weight: 700; cursor: pointer; box-shadow: 0 9px 28px rgba(231,70,58,.35); }

.home-sections { display: flex; flex-direction: column; gap: 42px; padding-bottom: 70px; }
.retry-button { margin-top: 18px; padding: 9px 16px; border: 0; border-radius: 999px; color: white; background: var(--red); cursor: pointer; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 18px; }
.section-head h2, .page-heading h1 { margin: 0; font: 800 31px/1.1 Georgia, "Songti SC", serif; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.drama-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 24px 16px; }
.drama-card { border: 0; padding: 0; background: transparent; text-align: left; cursor: pointer; }
.poster { position: relative; display: block; aspect-ratio: 3 / 4.2; overflow: hidden; border-radius: 14px; background: linear-gradient(145deg, #eeeae2, #ddd7cc); }
.poster::before { content: attr(data-title); position: absolute; inset: auto 13px 18px; z-index: 0; color: #9c968c; font-size: 13px; font-weight: 700; line-height: 1.5; }
.poster::after { content: "微光短剧"; position: absolute; top: 16px; left: 13px; z-index: 0; color: #b3aca1; font: 800 10px/1 Georgia, serif; letter-spacing: .12em; }
.poster img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.poster img.image-missing { display: none; }
.drama-card:hover .poster img { transform: scale(1.045); }
.poster-badge { position: absolute; z-index: 2; left: 9px; bottom: 9px; max-width: calc(100% - 18px); padding: 5px 8px; border-radius: 7px; color: white; background: rgba(22,22,22,.74); backdrop-filter: blur(8px); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { margin: 11px 0 5px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { grid-column: 1 / -1; padding: 80px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

#searchView, #historyView, #detailView { padding: 46px 0 76px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 26px; }
.clear-history { padding: 9px 15px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); cursor: pointer; }
.clear-history:hover { border-color: var(--red); color: var(--red); }
.history-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.history-item { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.history-main { width: 100%; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; align-items: center; padding: 12px 44px 12px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.history-poster { width: 92px; aspect-ratio: 3 / 4.2; border-radius: 10px; }
.history-copy { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.history-copy strong { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.history-copy small, .history-copy time { color: var(--muted); font-size: 12px; }
.history-resume { margin-top: 5px; color: var(--red); font-size: 13px; font-weight: 700; }
.history-remove { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: var(--paper); cursor: pointer; font-size: 18px; }
.history-remove:hover { color: white; background: var(--red); }
.result-count { color: var(--muted); }
.back-link { padding: 0; margin-bottom: 26px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.back-link.light { margin: 0; color: rgba(255,255,255,.72); }
.detail-hero { display: grid; grid-template-columns: 310px 1fr; gap: 58px; align-items: start; }
.detail-poster { aspect-ratio: 3 / 4.2; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); background: #e7e3db; }
.detail-poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-poster.poster::before { font-size: 18px; }
.detail-poster.poster::after { font-size: 12px; }
.detail-copy { padding-top: 20px; }
.detail-copy h1 { margin: 0; font: 800 clamp(38px, 5vw, 64px)/1.08 Georgia, "Songti SC", serif; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 9px; margin: 20px 0; }
.detail-meta span { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: #5d5953; font-size: 12px; background: var(--surface); }
.detail-intro { max-width: 800px; color: #64615b; line-height: 1.9; }
.episode-panel { margin-top: 34px; }
.episode-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.episode-head h2 { margin: 0; font: 800 24px/1 Georgia, "Songti SC", serif; }
.episode-list { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 9px; }
.episode-button { min-height: 43px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.episode-button:hover, .episode-button.active { border-color: var(--red); color: var(--red); background: var(--soft-red); font-weight: 700; }

.player-view { min-height: calc(100vh - 76px); color: white; background: #11100f; }
.player-shell { width: min(1120px, calc(100vw - 32px)); margin: auto; padding: 26px 0 70px; }
.player-topbar { min-height: 38px; display: flex; align-items: center; justify-content: space-between; }
.player-source { color: rgba(255,255,255,.55); font-size: 12px; }
.video-frame { margin-top: 18px; overflow: hidden; border-radius: 18px; background: black; box-shadow: 0 24px 80px rgba(0,0,0,.4); }
#videoPlayer { width: 100%; aspect-ratio: 16 / 9; display: block; background: black; }
.player-content { padding-top: 28px; }
.player-title-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.player-title-row h1 { margin: 0; font: 800 34px/1.15 Georgia, "Songti SC", serif; }
.next-button { padding: 11px 18px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: white; background: rgba(255,255,255,.08); cursor: pointer; }
.player-view .episode-button { color: rgba(255,255,255,.78); border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.06); }
.player-view .episode-button.active { color: white; border-color: var(--red); background: var(--red); }
.player-view .episode-head h2 { color: white; }

.source-drawer { position: fixed; inset: 0; z-index: 70; visibility: hidden; }
.source-drawer.open { visibility: visible; }
.drawer-mask { position: absolute; inset: 0; width: 100%; border: 0; opacity: 0; background: rgba(20,18,15,.38); transition: opacity .25s; }
.source-drawer.open .drawer-mask { opacity: 1; }
.drawer-panel { position: absolute; top: 0; right: 0; width: min(390px, 92vw); height: 100%; padding: 34px; background: var(--surface); transform: translateX(100%); transition: transform .25s ease; box-shadow: -20px 0 70px rgba(20,18,15,.16); }
.source-drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: start; }
.drawer-head h2 { margin: 0; font: 800 30px/1 Georgia, "Songti SC", serif; }
.drawer-head button { border: 0; background: none; font-size: 30px; cursor: pointer; }
.drawer-tip { margin: 22px 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.source-list { display: flex; flex-direction: column; gap: 10px; }
.source-item { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); cursor: pointer; text-align: left; }
.source-item.active { border-color: var(--red); background: var(--soft-red); }
.source-health { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.source-health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.source-health.bad::before { background: var(--red); }

.toast { position: fixed; left: 50%; bottom: 30px; z-index: 90; padding: 11px 16px; border-radius: 999px; color: white; background: rgba(22,22,22,.9); transform: translate(-50%, 24px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.skeleton { animation: pulse 1.3s infinite alternate; }
@keyframes pulse { from { opacity: .64; } to { opacity: 1; } }

@media (min-width: 1440px) {
  :root { --content: min(1440px, calc(100vw - 80px)); }
  .drama-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 28px 18px; }
  .hero { min-height: 470px; }
}

@media (max-width: 1180px) {
  :root { --content: calc(100vw - 40px); }
  .header-inner { grid-template-columns: auto minmax(220px, 1fr) minmax(230px, 320px) auto; gap: 16px; }
  .brand small { display: none; }
  .drama-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .episode-list { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .detail-hero { grid-template-columns: 270px 1fr; gap: 40px; }
}

@media (max-width: 900px) {
  :root { --content: calc(100vw - 36px); }
  .site-header .header-inner { min-height: 122px; }
  .header-inner { grid-template-columns: auto minmax(220px, 1fr) auto; grid-template-rows: 62px 48px; gap: 0 14px; }
  .search-form { grid-column: 2; }
  .source-button { grid-column: 3; }
  .nav-tabs { grid-row: 2; grid-column: 1 / -1; width: 100%; padding-bottom: 8px; }
  .hero { min-height: 390px; }
  .hero-content { padding: 58px 48px; }
  .history-button span:last-child { display: none; }
  .drama-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 14px; }
  .detail-hero { grid-template-columns: 220px 1fr; gap: 32px; }
  .episode-list { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  :root { --content: calc(100vw - 28px); }
  .site-header { position: relative; }
  .header-inner { min-height: 154px !important; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 52px 44px 46px; gap: 4px 9px; }
  .brand { grid-row: 1; grid-column: 1; }
  .brand strong { font-size: 17px; }
  .brand small { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .header-actions { grid-row: 1; grid-column: 2; }
  .history-button, .source-button { padding: 9px; }
  #sourceLabel { display: none; }
  .search-form { grid-row: 2; grid-column: 1 / -1; width: 100%; height: 40px; }
  .nav-tabs { grid-row: 3; grid-column: 1 / -1; width: 100%; }
  .nav-tab { padding: 8px 11px; font-size: 14px; }
  .hero { min-height: 490px; margin-top: 14px; margin-bottom: 28px; border-radius: 18px; }
  .hero::after { background: linear-gradient(0deg, rgba(14,11,9,.94) 0%, rgba(14,11,9,.58) 65%, rgba(14,11,9,.14)); }
  .hero-content { width: 100%; padding: 235px 24px 28px; }
  .hero h1 { font-size: 40px; }
  .hero p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .section-head { align-items: start; }
  .section-head h2, .page-heading h1 { font-size: 27px; }
  .drama-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 10px; }
  .card-title { font-size: 14px; }
  #searchView, #detailView { padding-top: 28px; }
  .page-heading { align-items: start; gap: 10px; }
  .detail-hero { grid-template-columns: 112px minmax(0, 1fr); gap: 18px; }
  .detail-copy { display: contents; padding-top: 0; }
  .detail-copy > .eyebrow, .detail-copy > h1, .detail-copy > .detail-meta, .detail-copy > .primary-button { grid-column: 2; }
  .detail-copy h1 { align-self: end; font-size: 29px; overflow-wrap: anywhere; }
  .detail-intro { grid-column: 1 / -1; margin: 0; }
  .detail-meta { align-self: start; margin: 8px 0; }
  .episode-panel { grid-column: 1 / -1; width: 100%; }
  .episode-list { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
  .episode-button { font-size: 12px; }
  .player-shell { width: 100%; padding-top: 12px; }
  .player-topbar, .player-content { padding-left: 14px; padding-right: 14px; }
  .video-frame { border-radius: 0; }
  .player-title-row h1 { font-size: 25px; }
  .next-button { padding: 9px 12px; font-size: 13px; }
}

@media (max-width: 460px) {
  :root { --content: calc(100vw - 24px); }
  .hero { min-height: 430px; }
  .hero-content { padding: 215px 20px 24px; }
  .hero h1 { font-size: 34px; }
  .history-list { grid-template-columns: 1fr; }
  .drama-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .section-head h2, .page-heading h1 { font-size: 24px; }
  .result-count { font-size: 12px; white-space: nowrap; }
  .detail-hero { grid-template-columns: 102px minmax(0, 1fr); gap: 15px; }
  .detail-copy h1 { font-size: 25px; }
  .detail-meta span { padding: 5px 8px; font-size: 11px; }
  .episode-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .player-title-row { align-items: start; }
  .player-title-row h1 { font-size: 22px; }
}

@media (max-width: 350px) {
  .brand-mark { display: none; }
  .feature-strip { grid-template-columns: 1fr; }
  .episode-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
