:root {
  color-scheme: dark;
  --bg: #09090a;
  --panel: #151516;
  --panel-2: #1d1d1f;
  --ink: #f6f4ef;
  --muted: #969499;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ef5a43;
  --accent-ink: #fff8f5;
  --green: #52c58b;
  --phone: 440px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #050506; color: var(--ink); }
body { min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

#app {
  width: min(100%, var(--phone));
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.screen { min-height: 100dvh; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 20px 10px;
}
.wordmark { font: 800 23px/1 Georgia, "Songti SC", serif; letter-spacing: 1px; }
.wordmark i { display: inline-block; width: 8px; height: 8px; margin-left: 5px; background: var(--accent); border-radius: 50%; }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: 2px; }
.section-title { margin: 0; font: 700 28px/1.2 Georgia, "Songti SC", serif; }
.icon-button {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%;
  background: rgba(17, 17, 18, 0.82); display: grid; place-items: center; cursor: pointer;
}

.home-search[hidden] { display: none; }
.home-search { margin: 0 20px 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #141415; }
.home-search > label { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 800; }
.search-field { display: flex; align-items: center; gap: 9px; min-height: 45px; padding: 0 13px; border: 1px solid #39393c; border-radius: 10px; background: #0d0d0e; color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-results { display: grid; gap: 8px; margin-top: 10px; }
.search-empty { margin: 4px 2px 1px; color: var(--muted); font-size: 12px; }
.search-result { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: #202022; text-align: left; cursor: pointer; }
.search-result span { display: grid; gap: 4px; }
.search-result small { color: var(--muted); }
.search-result b { color: var(--accent); font-size: 22px; }
.search-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

.home-header { padding: 18px 22px 16px; }
.feature-card { position: relative; min-height: 420px; overflow: hidden; background: radial-gradient(circle at 72% 18%, #3c2924 0, #181719 38%, #0b0b0c 76%); }
.feature-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.feature-card.cover-missing::before { content: "AI"; position: absolute; top: 44px; right: 22px; color: rgba(255,255,255,.055); font: 900 150px/1 Georgia, serif; letter-spacing: -16px; }
.feature-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(4,4,5,.98) 0%, rgba(4,4,5,.28) 58%, rgba(4,4,5,.02) 100%); }
.feature-copy { position: absolute; z-index: 1; left: 22px; right: 22px; bottom: 26px; }
.feature-title { max-width: 360px; margin: 10px 0 8px; font: 800 36px/1.08 Georgia, "Songti SC", serif; }
.feature-meta { color: #d1ced0; font-size: 14px; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid rgba(255,255,255,.2); border-radius: 99px; font-size: 11px; font-weight: 800; letter-spacing: 1px; background: rgba(7,7,8,.45); }
.mode-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.mode-pill.mock::before { background: #f0bd4c; }
.watch-button { margin-top: 19px; display: inline-flex; align-items: center; gap: 8px; padding: 13px 18px; border: 0; border-radius: 99px; background: var(--ink); color: #111; font-weight: 800; cursor: pointer; }

.section { padding: 30px 20px 4px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font: 700 23px/1.2 Georgia, "Songti SC", serif; }
.section-heading span { color: var(--muted); font-size: 12px; }
.drama-list { display: grid; gap: 14px; }
.drama-row { display: grid; grid-template-columns: 90px 1fr 34px; gap: 14px; align-items: center; padding: 10px; background: #121213; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.drama-row img { width: 90px; height: 118px; object-fit: cover; border-radius: 8px; background: #222; }
.drama-row h3 { margin: 0 0 8px; font-size: 18px; }
.drama-row p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.drama-row .arrow { font-size: 25px; color: #777; }
.player-screen { background: #050506; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.player-head { position: relative; z-index: 3; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: calc(9px + env(safe-area-inset-top)) 12px 9px; }
.player-head h1 { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center; font-size: 16px; }
.video-stage { position: relative; width: 100%; aspect-ratio: 9 / 15.6; max-height: 71dvh; background: #000; overflow: hidden; }
.video-stage video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; background: #111; color: #d9d6d1; }
.video-error[hidden] { display: none; }
.video-error strong { display: block; margin-bottom: 16px; font-size: 16px; }
.video-error button { min-width: 112px; min-height: 42px; border: 1px solid rgba(255,255,255,.22); border-radius: 99px; background: #f3f0eb; color: #111; font-weight: 800; cursor: pointer; }
.player-info { padding: 18px 18px 4px; }
.player-info h2 { margin: 0; font: 700 24px/1.25 Georgia, "Songti SC", serif; }
.episode-name { margin: 9px 0 4px; color: var(--accent); font-size: 15px; font-weight: 800; }
.episode-controls { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 10px; padding: 16px 18px 0; }
.episode-controls button { min-height: 47px; border: 1px solid var(--line); border-radius: 10px; background: #141415; cursor: pointer; }
.episode-controls .primary { background: var(--ink); color: #111; border-color: var(--ink); font-weight: 800; }
.episode-controls button:disabled { opacity: .35; cursor: default; }

.drawer-scrim { position: fixed; z-index: 20; inset: 0; background: rgba(0,0,0,.65); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.episode-drawer { position: fixed; z-index: 21; left: 50%; bottom: 0; width: min(100%, var(--phone)); max-height: 72dvh; transform: translate(-50%, 105%); background: #19191b; border-radius: 22px 22px 0 0; transition: transform .22s ease; padding-bottom: calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -24px 60px rgba(0,0,0,.45); }
.episode-drawer.open { transform: translate(-50%, 0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 21px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-head button { border: 0; background: transparent; color: #aaa; font-size: 27px; cursor: pointer; }
.season-view[hidden], .season-episodes[hidden] { display: none; }
.season-view > p { margin: 15px 20px 8px; color: var(--muted); font-size: 12px; }
.season-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; max-height: 53dvh; overflow: auto; padding: 10px 20px 8px; }
.season-grid button { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 58px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: #252527; cursor: pointer; }
.season-grid button.active { border-color: var(--accent); background: rgba(239,90,67,.13); }
.season-grid small, .episode-grid small { color: var(--muted); font-size: 11px; font-weight: 500; }
.season-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 0; }
.season-toolbar button { border: 0; padding: 8px 0; background: transparent; color: var(--accent); cursor: pointer; }
.episode-ranges { display: flex; gap: 7px; overflow-x: auto; padding: 12px 20px 0; scrollbar-width: none; }
.episode-ranges::-webkit-scrollbar { display: none; }
.episode-ranges button { flex: 0 0 auto; min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 99px; background: #242426; color: var(--muted); font-size: 12px; cursor: pointer; }
.episode-ranges button.active { border-color: var(--accent); background: rgba(239,90,67,.13); color: var(--ink); }
.episode-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; max-height: 45dvh; overflow: auto; padding: 14px 20px 8px; }
.episode-grid button { display: grid; gap: 2px; aspect-ratio: 1; place-content: center; border: 1px solid var(--line); border-radius: 9px; background: #252527; font-weight: 750; cursor: pointer; }
.episode-grid button.active { background: var(--accent); border-color: var(--accent); color: white; }
.complete-note { margin: 12px 18px 0; padding: 11px; border-radius: 8px; background: #1b261f; color: #91ddb0; text-align: center; font-size: 13px; }

.admin-screen { background: #0c0c0d; }
.admin-wrap { padding: 18px 20px 40px; }
.admin-title { margin: 12px 0 8px; font: 800 34px/1.15 Georgia, "Songti SC", serif; }
.admin-subtitle { margin: 0 0 26px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.input-row { display: grid; gap: 10px; }
.input-row input, .input-row textarea { width: 100%; min-height: 52px; padding: 14px 15px; border: 1px solid #343436; border-radius: 10px; outline: 0; background: #171719; color: white; resize: vertical; line-height: 1.55; }
.input-row input:focus, .input-row textarea:focus { border-color: #777; }
.primary-button { min-height: 51px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 850; cursor: pointer; }
.primary-button:disabled { opacity: .5; cursor: wait; }
.sample-hint { margin: 10px 2px 0; color: #6f6d71; font-size: 11px; word-break: break-all; }
.status-line { display: flex; align-items: center; gap: 9px; min-height: 44px; margin-top: 13px; padding: 0 4px; color: #bbb7bc; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #606066; }
.status-line.loading .status-dot { background: var(--accent); box-shadow: 0 0 0 5px rgba(239,90,67,.14); }
.status-line.success .status-dot { background: var(--green); }
.status-line.error { color: #ff8d7c; }
.status-line.error .status-dot { background: #ff624e; }
.parsed-card { margin-top: 17px; border-top: 1px solid var(--line); padding-top: 22px; }
.parsed-hero { display: grid; grid-template-columns: 92px 1fr; gap: 16px; align-items: start; }
.parsed-hero img { width: 92px; height: 126px; object-fit: cover; border-radius: 8px; background: #242426; }
.parsed-hero h2 { margin: 4px 0 10px; font: 700 21px/1.3 Georgia, "Songti SC", serif; }
.parsed-meta { margin: 5px 0; color: var(--muted); font-size: 12px; word-break: break-all; }
.batch-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.batch-head h2 { margin: 0; font: 700 21px/1.3 Georgia, "Songti SC", serif; }
.batch-head span { color: var(--green); font-size: 12px; }
.batch-note { margin: 12px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.batch-results { display: grid; gap: 12px; }
.batch-result { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #151517; }
.batch-result img { width: 72px; height: 98px; object-fit: cover; border-radius: 7px; background: #242426; }
.batch-result h3 { margin: 3px 0 8px; font-size: 15px; line-height: 1.35; }
.batch-result p { margin: 3px 0; color: var(--muted); font-size: 11px; word-break: break-all; }
.batch-index { color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.batch-error { grid-template-columns: 1fr; border-color: rgba(255,98,78,.35); }
.work-candidate { margin: 17px 0; padding: 17px; border: 1px solid rgba(239,90,67,.45); border-radius: 12px; background: rgba(239,90,67,.07); }
.candidate-label { margin: 0 0 7px; color: var(--accent); font-size: 12px; font-weight: 800; }
.work-candidate h2 { margin: 0; font: 700 20px/1.35 Georgia, "Songti SC", serif; }
.candidate-total { margin: 7px 0 13px; color: #ddd9d4; font-size: 14px; font-weight: 750; }
.candidate-seasons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; padding: 12px; border-radius: 9px; background: rgba(0,0,0,.22); }
.candidate-seasons div { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.candidate-seasons strong { color: var(--ink); }
.candidate-note { margin: 12px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.candidate-actions { display: grid; grid-template-columns: 1.25fr 1fr; gap: 8px; }
.candidate-actions button { min-height: 45px; border: 1px solid var(--line); border-radius: 9px; background: #242426; cursor: pointer; }
.candidate-actions .primary-button { border: 0; background: var(--accent); }
.candidate-actions button:disabled { opacity: .5; cursor: wait; }
.selection-head { margin-top: 25px; display: flex; align-items: center; justify-content: space-between; }
.selection-head h3 { margin: 0; font-size: 16px; }
.selected-count { color: var(--accent); font-size: 12px; }
.quick-actions { display: flex; gap: 7px; margin: 13px 0; overflow-x: auto; }
.quick-actions button { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; background: #1b1b1d; font-size: 12px; cursor: pointer; }
.import-episodes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 300px; overflow: auto; padding: 4px 2px 13px; }
.episode-check { position: relative; }
.episode-check input { position: absolute; opacity: 0; }
.episode-check span { display: grid; place-items: center; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #18181a; color: #a5a2a7; font-size: 12px; cursor: pointer; }
.episode-check input:checked + span { border-color: var(--accent); background: rgba(239,90,67,.13); color: white; }
.import-button { width: 100%; margin-top: 9px; }
.import-success { margin-top: 16px; padding: 15px; border: 1px solid rgba(82,197,139,.25); background: rgba(82,197,139,.08); border-radius: 10px; color: #9ce1b7; font-size: 13px; line-height: 1.6; }
.import-success a { text-decoration: underline; font-weight: 750; }
.empty-state, .loading-state { padding: 80px 24px; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); width: max-content; max-width: calc(100% - 40px); padding: 11px 15px; border-radius: 8px; background: #efede8; color: #111; font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  #app { min-height: calc(100dvh - 48px); border: 1px solid #272729; border-radius: 20px; }
  .screen { min-height: calc(100dvh - 50px); }
  .episode-drawer { bottom: 24px; border-radius: 22px; }
}

@media (max-height: 720px) {
  .video-stage { aspect-ratio: 9 / 12.7; }
  .player-info { padding-top: 12px; }
}
