:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #657089;
  --line: #dbe2ec;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --success: #087a55;
  --danger: #b42318;
  --warning: #9a6700;
  --shadow: 0 16px 45px rgba(33, 45, 78, .10);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, rgba(79,70,229,.12), transparent 30rem),
    radial-gradient(circle at 95% 10%, rgba(8,122,85,.08), transparent 28rem),
    var(--bg);
}
body.modal-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 64px; display: flex; align-items: center; gap: 18px; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; background: url("/assets/brand-icon.webp") center/contain no-repeat; box-shadow: 0 8px 18px rgba(79,70,229,.18); }
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav a, .nav button { color: var(--ink); border: 0; background: transparent; padding: 9px 11px; border-radius: 10px; }
.nav a:hover, .nav button:hover { background: #eef1f7; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, .9fr) minmax(360px, 1.1fr); }
.auth-side { padding: clamp(30px, 7vw, 100px); display: flex; flex-direction: column; justify-content: center; background: linear-gradient(145deg, #24206e, #4f46e5 52%, #7c3aed); color: white; }
.auth-side h1 { font-size: clamp(34px, 5vw, 64px); line-height: 1.05; margin: 18px 0; }
.auth-side p { max-width: 560px; color: rgba(255,255,255,.83); line-height: 1.8; }
.auth-main { display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(620px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: clamp(22px, 4vw, 38px); box-shadow: var(--shadow); }
.auth-card h2 { margin: 0 0 8px; }
.muted { color: var(--muted); line-height: 1.65; }
.entry-guide { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; margin: 20px 0 6px; }
.entry-guide button { text-align: left; border: 1px solid var(--line); border-radius: 14px; padding: 13px; background: #fafbff; color: var(--ink); min-height: 132px; }
.entry-guide button:hover { border-color: #aeb7ff; background: #f5f6ff; transform: translateY(-1px); }
.entry-guide strong { display: block; margin-bottom: 7px; color: var(--primary-dark); }
.entry-guide span { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
.entry-guide b { display: block; color: var(--primary); font-size: 13px; margin-top: 10px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 6px; background: #eef1f7; border-radius: 14px; margin: 24px 0; }
.tab { border: 0; background: transparent; color: var(--muted); border-radius: 10px; padding: 10px 8px; font-weight: 700; }
.tab.active { background: white; color: var(--primary); box-shadow: 0 4px 12px rgba(33,45,78,.09); }
.panel { display: none; scroll-margin-top: 14px; }
.panel.active { display: block; }
.panel-arrival { animation: panelArrival .85s ease; }
@keyframes panelArrival { 0%,100% { box-shadow: none; } 35% { box-shadow: 0 0 0 4px rgba(79,70,229,.16); border-radius: 14px; } }
.field { margin: 15px 0; }
.field label { display: block; font-weight: 700; margin-bottom: 7px; }
.field input, .field select, .field textarea, .library-search input, .filter-selects select {
  width: 100%; border: 1px solid #cbd4e1; background: white; color: var(--ink); border-radius: 12px; padding: 12px 13px; outline: none; transition: .15s ease;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .library-search input:focus, .filter-selects select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.field small { display: block; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline > * { flex: 1 1 180px; }
.compact-actions > * { flex: 0 1 auto; }
.checkline { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 14px; margin: 12px 0; }
.checkline input { margin-top: 3px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 43px; border-radius: 12px; padding: 10px 15px; border: 1px solid transparent; font-weight: 750; }
.btn-primary { color: white; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { color: var(--ink); background: white; border-color: var(--line); }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { color: white; background: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.message { display: none; margin: 14px 0; padding: 11px 13px; border-radius: 12px; line-height: 1.55; }
.message.show { display: block; }
.message.error { color: #7a271a; background: #fef3f2; border: 1px solid #fecdca; }
.message.success { color: #05603a; background: #ecfdf3; border: 1px solid #abefc6; }
.message.info { color: #1849a9; background: #eff8ff; border: 1px solid #b2ddff; }
.warning-box { border-left: 4px solid #f79009; background: #fffaeb; color: #7a2e0e; padding: 13px 15px; border-radius: 8px; line-height: 1.6; }
.notice-box { border: 1px solid #b2ddff; background: #eff8ff; color: #1849a9; padding: 13px 15px; border-radius: 12px; line-height: 1.65; }
.support-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: #fafbff; }
.support-card h3 { margin-top: 0; }
.support-card p { line-height: 1.75; }
.helper-line { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 16px 0 0; }
.existing-account-hint { border: 1px solid #fec84b; background: #fffaeb; border-radius: 14px; padding: 16px; margin: 16px 0; }
.existing-account-hint p { line-height: 1.6; }
.masked-account { color: var(--primary-dark); font-weight: 800; }
.recovered-account { margin: 18px 0; border: 1px solid #abefc6; background: #ecfdf3; border-radius: 14px; padding: 16px; }
.recovered-account span, .recovered-account strong { display: block; }
.recovered-account strong { margin-top: 6px; font-size: 22px; color: #05603a; }
.page-main { padding: 34px 0 90px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.hero-row h1 { margin: 0 0 7px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 7px 24px rgba(33,45,78,.06); }
.card-pad { padding: 20px; }
.continue-card { display: grid; grid-template-columns: 70px minmax(0,1fr) auto; align-items: center; gap: 14px; background: linear-gradient(135deg,#eef1ff,#fff); border: 1px solid #c7d0ff; border-radius: 18px; padding: 13px; margin-bottom: 18px; }
.continue-card img { width: 70px; height: 88px; object-fit: contain; border-radius: 10px; background: white; }
.continue-card div { min-width: 0; }
.continue-card span, .continue-card strong, .continue-card small { display: block; }
.continue-card span { color: var(--primary); font-weight: 800; font-size: 13px; }
.continue-card strong { margin: 5px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-card small { color: var(--muted); }
.library-toolbar { position: sticky; top: 74px; z-index: 12; background: rgba(244,247,251,.94); backdrop-filter: blur(10px); padding: 10px 0 14px; margin-bottom: 12px; }
.library-search { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 9px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 999px; padding: 8px 13px; white-space: nowrap; font-weight: 700; }
.filter-chip.active { color: white; background: var(--primary); border-color: var(--primary); }
.filter-selects { display: grid; grid-template-columns: repeat(3,minmax(130px,1fr)) auto; gap: 9px; }
.advanced-filters > summary { display: none; }
.advanced-filters .filter-selects { display: grid; }
.advanced-filters summary { list-style: none; }
.advanced-filters summary::-webkit-details-marker { display: none; }
.library-summary { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.view-toggle { display: flex; padding: 4px; border-radius: 12px; background: #e9edf5; }
.view-toggle button { border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 8px 11px; font-weight: 700; }
.view-toggle button.active { background: white; color: var(--primary); box-shadow: 0 3px 10px rgba(33,45,78,.1); }
.episode-grid { display: grid; gap: 18px; }
.episode-grid.cover-mode { grid-template-columns: repeat(4,minmax(0,1fr)); }
.episode-card { overflow: hidden; position: relative; min-width: 0; }
.episode-cover-button { display: block; width: 100%; padding: 0; border: 0; background: transparent; }
.cover-wrap { aspect-ratio: 3 / 4; background: linear-gradient(135deg,#e8ecf4,#f7f9fc); overflow: hidden; position: relative; display: block; }
.cover-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.date-tag { position: absolute; top: 9px; left: 9px; padding: 6px 8px; border-radius: 9px; background: rgba(16,24,40,.82); color: white; font-weight: 800; font-size: 12px; letter-spacing: .03em; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.learning-chip { position: absolute; right: 9px; bottom: 9px; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.92); font-size: 12px; font-weight: 800; color: var(--muted); }
.learning-chip.in_progress { color: #1849a9; }
.learning-chip.completed { color: #067647; }
.episode-body { padding: 13px; }
.channel-chip { display: inline-block; border-radius: 999px; padding: 5px 9px; background: #eef1ff; color: var(--primary-dark); font-size: 12px; font-weight: 700; }
.episode-body h2 { font-size: 18px; line-height: 1.4; margin: 10px 0 5px; min-height: 50px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.episode-en { min-height: 42px; color: var(--muted); line-height: 1.45; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.episode-actions { display: grid; gap: 8px; margin-top: 12px; }
.episode-progress-action { border: 0; background: transparent; color: var(--muted); padding: 5px; font-size: 13px; }
.locked { opacity: .72; }
.episode-grid.list-mode { grid-template-columns: 1fr; }
.list-mode .episode-card { display: grid; grid-template-columns: 112px minmax(0,1fr); }
.list-mode .cover-wrap { height: 150px; aspect-ratio: auto; }
.list-mode .episode-body h2 { min-height: auto; }
.list-mode .episode-en { min-height: auto; }
.list-mode .episode-actions { grid-template-columns: auto auto; justify-content: start; }
.load-more-wrap { display: flex; justify-content: center; padding: 24px 0; }
.library-empty { grid-column: 1 / -1; }
.cover-viewer { position: fixed; inset: 0; z-index: 200; background: rgba(9,13,24,.92); display: grid; place-items: center; padding: 54px 16px 20px; overflow: auto; }
.cover-viewer button { position: fixed; top: max(16px,env(safe-area-inset-top)); right: 18px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: white; font-size: 28px; }
.cover-viewer img { width: min(92vw,760px); height: auto; max-height: none; object-fit: contain; touch-action: pinch-zoom; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.data-list { display: grid; gap: 12px; }
.data-row { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.data-row:last-child { border-bottom: 0; padding-bottom: 0; }
.disabled-card { opacity: .58; }
.mobile-bottom-nav { display: none; }
.admin-layout { display: grid; grid-template-columns: 230px minmax(0,1fr); min-height: 100vh; }
.admin-side { background: #151527; color: white; padding: 24px 16px; }
.admin-side h1 { font-size: 18px; }
.admin-side nav { display: grid; gap: 7px; margin-top: 25px; }
.admin-side button { text-align: left; border: 0; border-radius: 10px; padding: 11px; color: rgba(255,255,255,.8); background: transparent; }
.admin-side button.active, .admin-side button:hover { background: rgba(255,255,255,.11); color: white; }
.admin-main { padding: 28px; overflow: auto; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(150px,1fr)); gap: 14px; }
.metric { padding: 18px; }
.metric strong { display: block; font-size: 29px; margin-top: 7px; }
.admin-section { display: none; margin-top: 22px; }
.admin-section.active { display: block; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; color: var(--muted); font-size: 13px; }
.status { display: inline-block; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 800; }
.status.active { background: #ecfdf3; color: #067647; }
.status.suspended, .status.revoked { background: #fef3f2; color: #b42318; }
.status-warning { display: inline-block; margin-top: 6px; color: #9a6700; font-weight: 700; }
.code-output { padding: 14px; background: #111827; color: #d1fae5; border-radius: 12px; font-family: ui-monospace,monospace; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.admin-search { grid-template-columns: minmax(220px,560px) auto; display: grid; gap: 10px; margin: 18px 0 24px; }
.admin-search input { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: white; }
.customer-actions > * { flex: 0 0 auto; }
.merged-row { opacity: .6; }
.merge-card { max-width: 900px; }

@media (max-width: 980px) {
  .episode-grid.cover-mode { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 800px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-side { min-height: 230px; padding: 34px 24px; }
  .auth-side h1 { font-size: 38px; }
  .account-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .admin-layout { display: block; }
  .admin-side { position: sticky; top: 0; z-index: 30; padding: 12px 14px; }
  .admin-side h1 { margin: 0 0 8px; }
  .admin-side nav { display: flex; overflow-x: auto; margin: 0; }
  .admin-side button { white-space: nowrap; }
  .admin-main { padding: 18px 14px 50px; }
  .hero-row { align-items: flex-start; flex-direction: column; }
  .episode-grid.cover-mode { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .filter-selects { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .library-toolbar { top: 63px; }
}
@media (max-width: 620px) {
  .entry-guide { grid-template-columns: 1fr; }
  .entry-guide button { min-height: auto; }
  .tabs { grid-template-columns: 1fr; }
  .desktop-nav { display: none; }
  .topbar-inner { min-height: 58px; }
  .page-main { padding: 22px 0 100px; }
  .library-page .hero-row { margin-bottom: 10px; flex-direction: row; align-items: center; }
  .library-page .hero-row h1 { font-size: 30px; line-height: 1.15; margin: 0; }
  .library-page .hero-row p { display: none; }
  .view-toggle { flex: 0 0 auto; padding: 3px; }
  .view-toggle button { padding: 7px 9px; font-size: 13px; }
  .continue-card { grid-template-columns: 50px minmax(0,1fr) auto; gap: 10px; padding: 10px; margin-bottom: 10px; border-radius: 14px; }
  .continue-card img { width: 50px; height: 66px; }
  .continue-card strong { font-size: 14px; margin: 3px 0; }
  .continue-card small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .continue-card .btn { grid-column: auto; min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .library-toolbar { top: 58px; padding: 7px 0 8px; margin-bottom: 8px; }
  .library-search { grid-template-columns: 1fr auto; gap: 7px; }
  .library-search input { min-height: 42px; padding: 9px 11px; font-size: 14px; }
  .library-search .btn { min-height: 42px; padding: 8px 12px; font-size: 14px; }
  .filter-chips { padding: 8px 0 7px; gap: 6px; }
  .filter-chip { padding: 7px 11px; font-size: 13px; }
  .advanced-filters { border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.82); }
  .advanced-filters > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; color: var(--ink); font-weight: 750; cursor: pointer; }
  .advanced-filters > summary small { color: var(--muted); font-size: 11px; font-weight: 500; }
  .advanced-filters > summary::after { content: "⌄"; color: var(--muted); }
  .advanced-filters[open] > summary::after { content: "⌃"; }
  .advanced-filters .filter-selects { display: none; grid-template-columns: 1fr 1fr; gap: 7px; padding: 0 8px 8px; }
  .advanced-filters[open] .filter-selects { display: grid; }
  .filter-selects select, .filter-selects .btn { min-height: 40px; padding: 8px 10px; font-size: 13px; }
  .episode-grid.cover-mode { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .episode-card { border-radius: 14px; }
  .episode-body { padding: 10px; }
  .episode-body h2 { font-size: 15px; min-height: 43px; margin: 8px 0 4px; }
  .episode-en { font-size: 12px; min-height: 35px; }
  .channel-chip { font-size: 11px; padding: 4px 7px; }
  .date-tag { top: 7px; left: 7px; padding: 5px 6px; font-size: 10px; }
  .learning-chip { right: 7px; bottom: 7px; font-size: 10px; }
  .episode-actions .btn { min-height: 38px; padding: 8px; font-size: 13px; }
  .episode-progress-action { font-size: 12px; }
  .list-mode .episode-card { grid-template-columns: 92px minmax(0,1fr); }
  .list-mode .cover-wrap { height: 126px; }
  .mobile-bottom-nav { display: grid; grid-template-columns: repeat(3,1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
  .mobile-bottom-nav a { display: grid; place-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
  .mobile-bottom-nav a span { font-size: 19px; }
  .mobile-bottom-nav a.active { color: var(--primary); }
  .metric-grid { grid-template-columns: 1fr; }
  .topbar-inner { align-items: center; padding: 10px 0; }
}

/* V8.0.3 brand image */
.auth-side .brand-mark{width:46px;height:46px;flex-basis:46px;border-radius:15px}.auth-side .brand{font-size:18px}
