/* === DramaBox Modern UI — Clean Dark Theme === */
:root {
  --bg: #0d0d0d;
  --bg-card: #161616;
  --bg-elevated: #1c1c1c;
  --bg-hover: #222;
  --border: #2a2a2a;
  --border-light: #333;
  --text: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;
  --accent: #e63946;
  --accent-soft: rgba(230,57,70,.12);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-full: 100px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.6);
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-tap-highlight-color: transparent; line-height: 1.5; font-size: 14px; }
a { color: inherit; text-decoration: none; }
img { display: block; }
button { font-family: inherit; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* === Topbar === */
.topbar { background: rgba(13,13,13,.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 100; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--border); }
.topbar-row { display: flex; align-items: center; gap: 8px; padding: 10px 16px; max-width: 1200px; margin: 0 auto; }

/* Logo */
.topbar-logo { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.5px; white-space: nowrap; flex-shrink: 0; }

/* Spacer (mobile) */
.topbar-spacer { display: none; }

/* Icon buttons */
.topbar-icon { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: transparent; border: none; color: var(--accent); cursor: pointer; font-size: 20px; flex-shrink: 0; -webkit-tap-highlight-color: transparent; transition: background var(--transition); }
.topbar-icon:active { background: var(--accent-soft); }

/* Search */
.search-box { display: flex; flex: 1; min-width: 0; gap: 8px; position: relative; }
.search-box .search-back { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; background: transparent; border: none; color: var(--text); font-size: 22px; cursor: pointer; flex-shrink: 0; border-radius: 50%; }
.search-box .search-back:active { background: var(--bg-hover); }
.search-box input { flex: 1; min-width: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 10px 16px; color: var(--text); font-size: 14px; outline: none; transition: border-color var(--transition), box-shadow var(--transition); -webkit-appearance: none; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box button[type="submit"] { background: var(--accent); border: none; border-radius: var(--radius-full); padding: 0 18px; color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; min-height: 40px; transition: opacity var(--transition), transform var(--transition); }
.search-box button[type="submit"]:hover { opacity: .9; }
.search-box button[type="submit"]:active { transform: scale(.96); }

/* Language */
.lang-select { flex-shrink: 0; position: relative; }
.lang-btn { display: flex; align-items: center; gap: 5px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 8px 14px; color: var(--accent); cursor: pointer; min-height: 40px; font-size: 18px; transition: border-color var(--transition); }
.lang-btn:hover { border-color: var(--border-light); }
.lang-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 6px; min-width: 200px; max-height: 340px; overflow-y: auto; z-index: 300; box-shadow: var(--shadow-lg); display: none; grid-template-columns: 1fr 1fr; gap: 2px; overscroll-behavior: contain; scrollbar-width: none; }
.lang-dropdown::-webkit-scrollbar { display: none; }
.lang-dropdown.open { display: grid; animation: fadeIn .15s ease; }
.lang-opt { display: flex; align-items: center; gap: 8px; padding: 10px; background: transparent; border: none; color: var(--text-secondary); font-size: 13px; cursor: pointer; border-radius: 8px; transition: background var(--transition), color var(--transition); white-space: nowrap; }
.lang-opt:hover { background: var(--bg-hover); color: var(--text); }
.lang-opt.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lang-opt-code { font-weight: 700; min-width: 22px; }
.lang-opt-name { overflow: hidden; text-overflow: ellipsis; }

/* Suggest */
#suggestBox { display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); max-height: 70vh; overflow-y: auto; overscroll-behavior: contain; z-index: 200; box-shadow: var(--shadow-lg); -webkit-overflow-scrolling: touch; }
.suggest-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: var(--bg-hover); }
.suggest-cover { width: 52px; min-width: 52px; aspect-ratio: 2/3; border-radius: 6px; object-fit: cover; }
.suggest-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.suggest-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.suggest-cast, .suggest-tags { font-size: 12px; color: var(--text-secondary); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.kw-hl { color: var(--accent); }

/* === Tabs === */
nav.tabs { display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; max-width: 1200px; margin: 0 auto; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { color: var(--text-muted); font-size: 13px; font-weight: 500; white-space: nowrap; padding: 8px 14px; border-radius: var(--radius-full); transition: all var(--transition); flex-shrink: 0; }
nav.tabs a:hover { color: var(--text-secondary); background: var(--bg-elevated); }
nav.tabs a.active { color: var(--text); background: var(--bg-elevated); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }

/* === Sections === */
.section { margin: 24px 0; }
.section h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; letter-spacing: -.2px; }

/* === Grid Cards === */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--bg-card); transition: transform var(--transition), box-shadow var(--transition); }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.card .views { position: absolute; bottom: 86px; left: 8px; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.9); display: flex; align-items: center; gap: 3px; }
.card .views::before { content: '▶'; font-size: 9px; }
.card .info { padding: 10px; }
.card .title { font-size: 13px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 11px; color: var(--text-secondary); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: 8px; right: 8px; padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: .3px; backdrop-filter: blur(4px); }
.tag-pill { display: inline-block; background: var(--bg-hover); border: none; padding: 3px 10px; border-radius: var(--radius-full); font-size: 11px; color: var(--text-secondary); cursor: pointer; transition: all var(--transition); }
.tag-pill:hover { background: var(--border-light); color: var(--text); }

/* === List Cards === */
.list-card { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); transition: opacity var(--transition); }
.list-card:hover { opacity: .85; }
.list-card-cover { position: relative; width: 100px; min-width: 100px; border-radius: var(--radius); overflow: hidden; }
.list-card-cover img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.list-card-cover .badge { top: 6px; left: 6px; right: auto; }
.list-card-cover .views { position: absolute; bottom: 6px; left: 6px; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); display: flex; align-items: center; gap: 3px; }
.list-card-cover .views::before { content: '▶'; font-size: 9px; }
.list-card-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.list-card-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.list-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.list-card-meta { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.list-card-ep { font-size: 11px; color: var(--text-muted); }

/* === Search === */
.search-empty { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.search-list { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.search-card { display: flex; gap: 14px; }
.search-card-cover { position: relative; width: 110px; min-width: 110px; border-radius: var(--radius); overflow: hidden; }
.search-card-cover img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.search-card-cover .badge { top: 6px; left: 6px; right: auto; }
.search-card-cover .views { position: absolute; bottom: 6px; left: 6px; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); display: flex; align-items: center; gap: 3px; }
.search-card-cover .views::before { content: '▶'; font-size: 9px; }
.search-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.search-card-title { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-card-cast { font-size: 12px; color: var(--text-secondary); }
.search-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.search-card-tags { font-size: 12px; color: var(--text-secondary); margin-top: auto; }

/* === Detail Page === */
.book-header { display: flex; gap: 16px; padding: 20px 0 14px; }
.book-header-cover { width: 100px; min-width: 100px; aspect-ratio: 2/3; border-radius: var(--radius); object-fit: cover; box-shadow: var(--shadow); }
.book-header-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.book-header-title { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.3; letter-spacing: -.3px; }
.book-header-meta { font-size: 13px; color: var(--text-secondary); }
.book-header-rating { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.book-header-rating .star { color: #f4a623; }
.book-header-rating .count { color: var(--text-muted); }
.detail-tabs { display: flex; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.detail-tabs a { color: var(--text-muted); font-size: 15px; font-weight: 500; position: relative; padding: 4px 0; transition: color var(--transition); }
.detail-tabs a.active { color: var(--text); font-weight: 700; }
.detail-tabs a.active::after { content: ''; position: absolute; bottom: -15px; left: 0; right: 0; height: 2px; background: var(--accent); border-radius: 2px; }
.tab-pane { display: none; padding: 16px 0; }
.tab-pane.active { display: block; }
.book-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.7; white-space: pre-wrap; }
.book-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.book-tag { background: var(--bg-elevated); padding: 6px 14px; border-radius: var(--radius-full); font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: all var(--transition); border: 1px solid var(--border); }
.book-tag:hover { background: var(--bg-hover); color: var(--text); }
.actor-section { margin: 20px 0; }
.actor-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.actor-row { display: flex; gap: 18px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.actor-row::-webkit-scrollbar { display: none; }
.actor-card { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.actor-card img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.actor-card .actor-name { font-size: 13px; color: var(--text); }
.section-divider { display: flex; align-items: center; gap: 12px; margin: 28px 0 16px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.section-divider::before, .section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Episodes */
.ep-ranges { display: flex; gap: 20px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ep-ranges::-webkit-scrollbar { display: none; }
.ep-ranges a { color: var(--text-muted); font-size: 14px; font-weight: 600; padding: 4px 0; flex-shrink: 0; transition: color var(--transition); }
.ep-ranges a.active { color: var(--text); }
.ep-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ep-cell { position: relative; aspect-ratio: 1/1; background: var(--bg-elevated); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--text); font-size: 16px; font-weight: 600; transition: all var(--transition); border: 1px solid transparent; }
.ep-cell:hover { background: var(--bg-hover); border-color: var(--border); }
.ep-cell.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* === Rank === */
.rank-pills { display: flex; gap: 8px; margin: 16px 0 20px; flex-wrap: wrap; }
.rank-pill { padding: 8px 18px; border-radius: var(--radius-full); border: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; font-weight: 500; transition: all var(--transition); white-space: nowrap; }
.rank-pill:hover { color: var(--text); border-color: var(--border-light); }
.rank-pill.active { background: var(--bg-elevated); border-color: var(--border-light); color: var(--text); font-weight: 600; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--bg-card); border-radius: var(--radius-lg); transition: background var(--transition); border: 1px solid var(--border); }
.rank-item:hover { background: var(--bg-elevated); }
.rank-num { font-size: 20px; font-weight: 800; min-width: 28px; text-align: center; color: var(--text-muted); font-style: italic; }
.rank-item:nth-child(1) .rank-num { color: var(--accent); }
.rank-item:nth-child(2) .rank-num { color: #f4a623; }
.rank-item:nth-child(3) .rank-num { color: #e8912e; }
.rank-cover { width: 60px; min-width: 60px; aspect-ratio: 2/3; border-radius: 8px; object-fit: cover; }
.rank-info { flex: 1; min-width: 0; }
.rank-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 4px; }
.rank-tags { font-size: 12px; color: var(--text-secondary); }
.rank-heat { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.rank-heat::before { content: '🔥'; font-size: 13px; }
.rank-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* === Category === */
.cat-filters { margin: 12px 0 20px; display: flex; flex-direction: column; gap: 6px; }
.cat-filter-row { display: flex; gap: 8px; padding: 6px 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.cat-filter-row::-webkit-scrollbar { display: none; }
.cat-pill { padding: 7px 16px; border-radius: var(--radius-full); font-size: 13px; color: var(--text-secondary); font-weight: 500; transition: all var(--transition); flex-shrink: 0; }
.cat-pill:hover { color: var(--text); }
.cat-pill.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cat-pagination { display: flex; justify-content: center; gap: 12px; margin: 28px 0; }

/* === Player === */
body.no-chrome { overflow: hidden; background: #000; }
.fs-player { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; z-index: 50; }
.fs-top, .fs-rail, .fs-bottom, .fs-progress { transition: opacity .25s ease; }
.fs-player.controls-hidden .fs-top,
.fs-player.controls-hidden .fs-rail,
.fs-player.controls-hidden .fs-bottom,
.fs-player.controls-hidden .fs-progress { opacity: 0; pointer-events: none; }
.fs-video-wrap { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
.fs-video-wrap video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.fs-video-wrap video::cue { font-size: 1px; color: transparent; background: transparent; }
.fs-subtitle { position: absolute; left: 10%; right: 10%; top: 65%; transform: translateY(-50%); text-align: center; font-size: 20px; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.7); line-height: 1.4; pointer-events: none; z-index: 3; }
.fs-video-wrap .fs-video-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: #666; font-size: 14px; }
.fs-top { position: absolute; top: 0; left: 0; right: 0; padding: env(safe-area-inset-top) 14px 24px; padding-top: calc(env(safe-area-inset-top, 0) + 12px); display: flex; align-items: center; gap: 12px; background: linear-gradient(to bottom, rgba(0,0,0,.7), transparent); z-index: 5; pointer-events: none; }
.fs-top > * { pointer-events: auto; }
.fs-back { color: #fff; font-size: 18px; font-weight: 600; padding: 6px 8px; min-width: 44px; min-height: 44px; display: flex; align-items: center; gap: 4px; }
.fs-back::before { content: '‹'; font-size: 28px; line-height: 1; margin-right: 4px; }
.fs-top-spacer { flex: 1; }
.fs-top-action { color: #fff; font-size: 13px; padding: 8px 10px; min-height: 44px; display: flex; align-items: center; gap: 4px; background: transparent; border: none; cursor: pointer; }
.fs-top-action.icon { font-size: 20px; min-width: 44px; justify-content: center; }
.fs-speed::before { content: '⏲'; }
.fs-rail { position: absolute; right: 8px; bottom: 180px; display: flex; flex-direction: column; gap: 22px; z-index: 5; align-items: center; }
.fs-rail button { background: transparent; border: none; color: #fff; cursor: pointer; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; min-height: 56px; }
.fs-rail .ico { font-size: 28px; line-height: 1; filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)); }
.fs-rail .lbl { font-size: 11px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.fs-bottom { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0) + 40px); padding: 0 14px 8px; z-index: 4; pointer-events: none; }
.fs-bottom > * { pointer-events: auto; }
.fs-title { color: #fff; font-size: 16px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; cursor: pointer; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.fs-title::after { content: ' ›'; opacity: .7; }
.fs-desc { color: #ccc; font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.fs-desc-more { color: #fff; font-weight: 600; }
.fs-progress { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0) + 4px); height: 32px; padding: 4px 12px; cursor: pointer; z-index: 5; touch-action: none; display: flex; align-items: center; gap: 10px; user-select: none; -webkit-user-select: none; }
.fs-progress-track { flex: 1; height: 3px; background: rgba(255,255,255,.2); position: relative; border-radius: 2px; transition: height .15s; }
.fs-progress:hover .fs-progress-track, .fs-progress.dragging .fs-progress-track { height: 5px; }
.fs-progress-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); width: 0; border-radius: 2px; }
.fs-progress-knob { position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%); width: 14px; height: 14px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity .15s, transform .15s; box-shadow: 0 0 6px rgba(0,0,0,.5); }
.fs-progress:hover .fs-progress-knob, .fs-progress.dragging .fs-progress-knob { opacity: 1; }
.fs-progress.dragging .fs-progress-knob { transform: translate(-50%, -50%) scale(1.2); }
.fs-time { color: #fff; font-size: 12px; font-weight: 500; min-width: 36px; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.7); flex-shrink: 0; }
.fs-time-cur { text-align: right; }
.fs-time-dur { text-align: left; opacity: .8; }
@media (pointer: coarse) {
  .fs-progress-knob { opacity: 1; width: 12px; height: 12px; }
}
.fs-speed-menu, .fs-quality-menu { position: absolute; top: 60px; right: 14px; background: rgba(20,20,20,.95); border-radius: var(--radius); padding: 6px 0; z-index: 10; min-width: 90px; box-shadow: var(--shadow-lg); }
.fs-speed-menu[hidden], .fs-quality-menu[hidden] { display: none; }
.fs-speed-menu button, .fs-quality-menu button { display: block; width: 100%; padding: 10px 18px; background: transparent; border: none; color: #fff; font-size: 14px; cursor: pointer; text-align: left; }
.fs-speed-menu button.active, .fs-quality-menu button.active { color: var(--accent); font-weight: 700; }

/* Bottom sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; opacity: 0; transition: opacity .25s; pointer-events: none; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; background: var(--bg-elevated); border-radius: 16px 16px 0 0; z-index: 101; transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; background: rgba(255,255,255,.3); border-radius: 2px; margin: 8px auto 0; }
.sheet-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; border: none; font-size: 18px; cursor: pointer; z-index: 1; }
.sheet-content { overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 20px; -webkit-overflow-scrolling: touch; }
.share-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none; }
.share-backdrop.open { opacity: 1; pointer-events: auto; }
.share-sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg-elevated); border-radius: 16px 16px 0 0; z-index: 201; transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); padding: 0 14px calc(env(safe-area-inset-bottom, 0) + 24px); }
.share-sheet.open { transform: translateY(0); }
.share-title { color: var(--text); font-size: 16px; font-weight: 700; text-align: center; padding: 14px 0 18px; }
.share-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; padding-bottom: 8px; }
.share-opt { background: transparent; border: none; color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0; font-size: 12px; font-weight: 500; }
.share-opt[hidden] { display: none; }
.share-opt:active { opacity: .7; }
.share-ico { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; font-weight: 700; }
.share-toast { position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: var(--radius-full); font-size: 13px; z-index: 300; }
.share-toast[hidden] { display: none; }
@media (max-width: 360px) { .share-grid { grid-template-columns: repeat(4, 1fr); } }

.episodes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 6px; margin: 12px 0; }
.ep-btn { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; font-size: 13px; cursor: pointer; transition: all var(--transition); display: block; color: var(--text); }
.ep-btn:hover, .ep-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.detail-hero { display: flex; gap: 20px; margin: 20px 0; }
.detail-hero img { width: 180px; border-radius: var(--radius); aspect-ratio: 2/3; object-fit: cover; }
.detail-info h1 { font-size: 20px; margin-bottom: 8px; }
.detail-info p { color: var(--text-secondary); font-size: 13px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.detail-info .tags { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.detail-info .tag { background: var(--bg-elevated); padding: 4px 10px; border-radius: var(--radius-full); font-size: 11px; color: var(--text-secondary); }
.empty { text-align: center; padding: 48px; color: var(--text-muted); }

/* Responsive */

/* Mobile (<768px): compact navbar with icons */
@media (max-width: 767px) {
  .topbar-row { padding: 8px 12px; gap: 4px; }
  .topbar-logo { font-size: 20px; }
  .topbar-spacer { display: block; flex: 1; }
  .search-btn { display: flex; }
  .topbar-icon { display: flex; }
  .lang-btn { width: 40px; height: 40px; border-radius: 50%; padding: 0; background: transparent; border: none; min-height: auto; font-size: 20px; }
  .search-box { display: none; }
  .search-box.open { display: flex; position: fixed; inset: 0; z-index: 200; background: var(--bg); padding: calc(env(safe-area-inset-top, 0) + 12px) 16px 12px; border-bottom: 1px solid var(--border); align-items: center; gap: 8px; top: 0; }
  .search-box.open .search-back { display: flex; }
  .search-box.open button[type="submit"] { display: none; }
  #suggestBox { position: fixed; top: calc(env(safe-area-inset-top, 0) + 60px); left: 0; right: 0; margin: 0 16px; max-height: calc(100vh - 80px); }
}

/* Desktop (>=768px) */
@media (min-width: 768px) {
  .topbar-row { padding: 12px 16px; gap: 14px; }
  .topbar-logo { margin-right: 8px; }
  .search-btn { display: none; }
  .profile-btn { display: flex; }
  .lang-btn { font-size: 13px; font-weight: 600; display: flex; }
  .search-box .search-back { display: none !important; }
  .search-box input { font-size: 15px; padding: 11px 20px; }
  nav.tabs { padding: 8px 16px; gap: 4px; }
  nav.tabs a { font-size: 14px; padding: 9px 16px; }
  .grid { grid-template-columns: repeat(5, 1fr); gap: 14px; }
  .ep-grid { grid-template-columns: repeat(10, 1fr); }
  .book-header-cover { width: 120px; min-width: 120px; }
  .book-header-title { font-size: 22px; }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(6, 1fr); gap: 16px; }
}

/* === Auth (Login) === */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 140px); padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: rgba(22,22,22,.7); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 20px; padding: 40px 28px; box-shadow: 0 8px 48px rgba(0,0,0,.5); position: relative; overflow: hidden; }
.auth-card::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 120px; height: 3px; background: var(--accent); border-radius: 0 0 4px 4px; }
.auth-logo { font-size: 28px; font-weight: 800; text-align: center; letter-spacing: -.5px; }
.auth-logo span { color: var(--accent); }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin: 6px 0 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); letter-spacing: .3px; text-transform: uppercase; }
.auth-field input { background: var(--bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px; color: var(--text); font-size: 15px; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.auth-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-field input::placeholder { color: var(--text-muted); font-size: 14px; }
.auth-submit { background: var(--accent); border: none; border-radius: 12px; padding: 14px; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity var(--transition), transform var(--transition); margin-top: 4px; }
.auth-submit:active { opacity: .85; transform: scale(.98); }
.auth-submit:disabled { opacity: .5; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-alt-btn { background: transparent; border: 1.5px solid var(--border); border-radius: 12px; padding: 13px; color: var(--text-secondary); font-size: 14px; font-weight: 600; cursor: pointer; width: 100%; transition: all var(--transition); }
.auth-alt-btn:active { background: var(--bg-elevated); border-color: var(--border-light); color: var(--text); }
.auth-msg { text-align: center; font-size: 13px; margin-top: 16px; min-height: 20px; font-weight: 500; }
.auth-msg.err { color: var(--accent); }
.auth-msg.ok { color: #2ecc71; }

/* === Profile === */
.profile-page { padding: 24px 0; }
.profile-header { display: flex; flex-direction: column; align-items: center; padding: 24px 0 20px; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; color: var(--text-muted); margin-bottom: 12px; border: 2px solid var(--border); }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-id { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.profile-stats { display: flex; gap: 12px; margin-bottom: 24px; }
.profile-stat { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; text-align: center; }
.profile-stat-num { display: block; font-size: 24px; font-weight: 800; color: var(--text); }
.profile-stat-label { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.profile-section { margin-bottom: 24px; }
.profile-section-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.profile-section-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.profile-empty { text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px; }

/* Redeem */
.redeem-form { margin-bottom: 4px; }
.redeem-row { display: flex; gap: 8px; }
.redeem-input { flex: 1; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--text); font-size: 16px; letter-spacing: 2px; text-transform: uppercase; outline: none; transition: border-color var(--transition); }
.redeem-input:focus { border-color: var(--accent); }
.redeem-btn { background: var(--accent); border: none; border-radius: var(--radius); padding: 0 24px; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity var(--transition); }
.redeem-btn:active { opacity: .85; }
.redeem-btn:disabled { opacity: .6; }
.redeem-msg { text-align: center; font-size: 13px; margin-top: 10px; min-height: 20px; }
.redeem-msg.err { color: var(--accent); }
.redeem-msg.ok { color: #2ecc71; }
.redeem-history { display: flex; flex-direction: column; gap: 8px; }
.redeem-item { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.redeem-item-code { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 1px; min-width: 80px; }
.redeem-item-info { flex: 1; }
.redeem-item-reward { display: block; font-size: 13px; color: var(--text); }
.redeem-item-date { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.profile-logout { width: 100%; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--transition); margin-top: 8px; }
.profile-logout:active { background: var(--accent-soft); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* === Recommend Grid === */
.rec-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.rec-tag-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; grid-column: 1 / -1; align-items: stretch; }
.rec-tag-panel { border-radius: var(--radius-lg); padding: 10px; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.rec-tag-label { font-size: 13px; font-weight: 700; display: inline-block; padding: 4px 10px; background: rgba(255,255,255,.08); border-radius: 8px; margin-bottom: 6px; align-self: flex-start; }
.rec-tag-item { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.05); border-radius: 8px; padding: 5px 8px; transition: background var(--transition); }
.rec-tag-item:hover { background: rgba(255,255,255,.1); }
.rec-tag-item img { width: 40px; height: 54px; border-radius: 5px; object-fit: cover; flex-shrink: 0; }
.rec-tag-item span { font-size: 13px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
