*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #ffffff;
    --bg-secondary: #f6f7f8;
    --bg-card: #ffffff;
    --bg-hover: #f1f2f3;
    --text: #18191c;
    --text-muted: #9499a0;
    --accent: #fb7299;
    --accent-hover: #fc8bab;
    --accent-blue: #00aeec;
    --border: #e3e5e7;
    --radius: 6px;
    --header-h: 64px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background: var(--bg-secondary);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    height: var(--header-h);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-h);
}

.logo {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.header-nav {
    display: none;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.header-nav-link {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
}

.header-nav-link:hover {
    color: var(--accent);
    background: rgba(251, 114, 153, 0.08);
}

.header-nav-link.active {
    color: var(--accent);
    font-weight: 600;
}

.header-search {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 480px;
    margin-left: auto;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 999px;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
}

.header-search:focus-within {
    background: var(--bg);
    border-color: var(--accent);
}

.header-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
}

.header-search-input::placeholder {
    color: var(--text-muted);
}

.header-search-btn {
    padding: 8px 18px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.header-search-btn:hover {
    background: var(--accent-hover);
}

/* Main */
.site-main {
    flex: 1;
    padding: 20px 0 40px;
}

/* Filters */
.filters {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1.75fr) auto;
    gap: 12px;
    align-items: end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.filter-field-platform {
    min-width: 0;
}

.filter-field-action {
    width: 96px;
    justify-content: flex-end;
}

.filter-control {
    width: 100%;
    min-height: 38px;
}

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-row-inline {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.platform-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.platform-tabs::-webkit-scrollbar {
    display: none;
}

.platform-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.platform-tab:hover {
    background: var(--bg-hover);
}

.platform-tab.active {
    border-color: var(--accent);
    background: rgba(251, 114, 153, 0.1);
    color: var(--accent);
}

.platform-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
}

.platform-picker {
    position: relative;
    width: 100%;
}

.platform-picker-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.25;
    cursor: pointer;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
}

.platform-picker-trigger:hover {
    background: var(--bg-hover);
}

.platform-picker-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.platform-picker img.platform-picker-icon {
    display: block;
    max-width: 20px;
}

.platform-picker-icon-empty,
.platform-picker-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    flex-shrink: 0;
    font-size: 0.875rem;
    line-height: 1;
}

.platform-picker-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.platform-picker-caret {
    width: 0;
    height: 0;
    margin-left: auto;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-muted);
    flex-shrink: 0;
}

.platform-picker-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 120;
    min-width: 200px;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
}

.platform-picker-menu[hidden] {
    display: none !important;
}

.platform-picker-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
    white-space: nowrap;
}

.platform-picker-option span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.platform-picker-option:hover {
    background: var(--bg-hover);
}

.platform-picker-option.active {
    background: rgba(251, 114, 153, 0.1);
    color: var(--accent);
}

.lang-select,
.filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.875rem;
    min-height: 38px;
}

.search-input {
    width: 100%;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.875rem;
}

.btn-search {
    width: 100%;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-search:hover {
    background: var(--accent-hover);
}

/* List */
.list-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.total-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-cover-wrap {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
}

.card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.corner-mark {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}

.corner-mark.hot {
    background: var(--accent);
}

.corner-mark.new {
    background: var(--accent-blue);
}

.card-body {
    padding: 10px;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-platform-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.page-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 0.875rem;
    transition: background 0.2s;
}

.page-btn:hover {
    background: var(--bg-hover);
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Empty & Error */
.empty-state,
.error-page {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.error-page h1 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 12px;
}

.btn-back {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
}

/* Detail */
.detail-page {
    max-width: 1200px;
    margin: 0 auto;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
}

.detail-left {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-right {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.player-wrap {
    position: relative;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 0 auto 20px;
}

.player-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.player-loading.hidden {
    display: none;
}

.player-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.detail-platform-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.tag-badge {
    padding: 2px 8px;
    background: var(--accent);
    color: #fff;
    border-radius: 4px;
    font-size: 0.75rem;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tag {
    padding: 4px 10px;
    background: var(--bg-hover);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detail-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 12px;
}

.theater-link {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--accent);
    margin-bottom: 20px;
}

.episodes {
    margin-bottom: 0;
    width: 100%;
}

.episodes-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.episode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.episode-btn {
    padding: 10px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
}

.episode-btn:hover {
    background: var(--bg-hover);
}

.episode-btn.active {
    border-color: var(--accent);
    background: rgba(251, 114, 153, 0.1);
    color: var(--accent);
}

/* Promotion guide */
.promotion-guide {
    margin-bottom: 0;
    padding: 20px;
    background: linear-gradient(135deg, rgba(251, 114, 153, 0.06), rgba(0, 174, 236, 0.04));
    border: 1px solid rgba(251, 114, 153, 0.2);
    border-radius: var(--radius);
}

.promotion-skeleton {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.promotion-placeholder {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.promotion-guide-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.promotion-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.promotion-guide-title {
    font-size: 1.0625rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.promotion-guide-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.promotion-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.promo-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 10px;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.promo-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.promo-btn-primary {
    background: linear-gradient(135deg, #fb7299, #fc8bab);
    color: #fff;
}

.promo-btn-secondary {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text);
}

.promo-btn-icon {
    font-size: 1.5rem;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.promo-btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.promo-btn-text strong {
    font-size: 0.9375rem;
}

.promo-btn-text small {
    font-size: 0.75rem;
    opacity: 0.85;
}

.promo-code-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.promo-code-info strong {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.promo-code-info small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Share buttons */
.share-section {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.share-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.share-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, opacity 0.15s;
}

.share-btn:hover {
    transform: translateY(-1px);
    opacity: 0.92;
}

.share-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 700;
}

.share-btn-facebook {
    background: #1877f2;
    color: #fff;
}

.share-btn-facebook .share-btn-icon {
    background: rgba(255, 255, 255, 0.2);
    font-family: Georgia, serif;
}

.share-btn-tiktok {
    background: #010101;
    color: #fff;
    border: 1px solid var(--border);
}

.share-btn-tiktok .share-btn-icon {
    background: linear-gradient(135deg, #25f4ee, #fe2c55);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1rem;
}

.share-feedback {
    margin-top: 10px;
    font-size: 0.8125rem;
    color: var(--accent);
}

/* Book detail */
.book-layout {
    display: grid;
    gap: 20px;
}

.book-cover-wrap {
    max-width: 220px;
    margin: 0 auto 16px;
}

.book-cover {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.book-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.book-author {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.book-chapters {
    margin-top: 20px;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 4px;
}

.chapter-btn {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
}

.chapter-btn:hover,
.chapter-btn.active {
    border-color: var(--accent);
    background: rgba(251, 114, 153, 0.1);
    color: var(--accent);
}

.chapter-content {
    display: none;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.chapter-content.active {
    display: block;
}

.chapter-content-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.chapter-content-body {
    white-space: pre-wrap;
    line-height: 1.75;
    font-size: 0.9375rem;
    color: var(--text);
}

.promo-code-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: rgba(251, 114, 153, 0.06);
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
}

.promo-code-btn:hover {
    background: rgba(251, 114, 153, 0.12);
}

.promo-code-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.promo-code-value {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
}

.promo-code-action {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Footer */
.site-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Responsive */
@media (min-width: 768px) {
    .header-nav {
        display: flex;
    }
}
@media (max-width: 768px) {
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .filter-field-search {
        grid-column: 1;
    }

    .filter-field-action {
        grid-column: 2;
        width: 100%;
        align-self: end;
    }
}

@media (max-width: 480px) {
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-field:nth-child(3) {
        grid-column: 1 / -1;
    }

    .platform-picker-menu {
        min-width: 100%;
        width: max-content;
        max-width: min(280px, calc(100vw - 32px));
    }
}

@media (min-width: 640px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 900px) {
    .detail-layout,
    .book-layout {
        grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
        gap: 24px;
    }

    .detail-left {
        align-items: stretch;
    }

    .book-left {
        position: sticky;
        top: calc(var(--header-h) + 16px);
        align-self: start;
    }

    .player-wrap {
        max-width: none;
        margin: 0 0 20px;
    }

    .detail-right {
        position: sticky;
        top: calc(var(--header-h) + 16px);
    }
}

@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

    .page-title {
        font-size: 1.5rem;
    }
}
