@font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 100 700;
    src: url(./fonts/a.woff2) format('woff2');
}

/* ===== 1. RESET & BASE STYLES ===== */
* {
    box-sizing: border-box;
    overscroll-behavior: none;
    scrollbar-width: thin;
    scrollbar-color: rgb(var(--mdui-color-primary)) transparent;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --font-family: 'Noto Sans SC', system-ui;
    --reader-toolbar-padding-block: 1rem;
    --reader-toolbar-padding-inline: 1rem;
    --reader-toolbar-border-size: 0.0625rem;
    --reader-toolbar-border-color: rgba(0, 0, 0, 0.1);
    --reader-toolbar-z: 2005;
}

html {
    height: 100dvh !important;
}

body,
p,
h1,
h2,
h3,
h4,
h5,
h6,
button,
input,
textarea,
select,
option,
ul,
li {
    margin: 0;
    padding: 0;
}

::selection {
    background-color: rgb(var(--mdui-color-primary));
    color: white;
}

/* ===== 2. UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

*::part(menu) {
    overflow: auto;
    max-height: 50dvh;
    height: 100%;
}

mdui-dialog {
    padding: 0.5rem;
}

mdui-dialog::part(panel) {
    width: 35rem;
}

mdui-dialog::part(body) {
    margin-top: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgb(var(--mdui-color-primary)) transparent;
}

mdui-dialog::part(action) {
    padding-top: 1rem;
}

mdui-icon,
mdui-button,
mdui-chip,
mdui-button-icon {
    user-select: none;
}

mdui-tab::part(container) {
    gap: 0.5rem;
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
}

.text-center {
    text-align: center;
}

.flex {
    display: flex;
}

/* ===== 3. LAYOUT & STRUCTURE ===== */
html,
body {
    font-size: 1rem !important;
}

body {
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
    --navigation-bar-height: 5rem;
    --video-player-bottom: 0rem;
    --iframe-video-player-bottom: 0rem;
    padding-bottom: 0 !important;
    font-family: var(--font-family, 'Noto Sans SC', system-ui);
}

button,
input,
textarea,
select,
option {
    font-family: inherit;
}

/* Page Container */
.page {
    padding: 1rem;
    box-sizing: border-box;
}

.page-hidden {
    display: none !important;
}

.page-visible {
    position: relative;
    display: block;
    width: 100%;
    min-height: 100dvh;
    box-sizing: border-box;
    pointer-events: auto;
    z-index: 1;
    margin: auto;
    padding-bottom: calc(1rem + var(--navigation-bar-height)) !important;
}

.bottom-nav .box,
.batch-toolbar .box,
.panel-header .box,
.book-content,
.reader-bottom-bar .box,
.chapters-panel-box,
.settings-box {
    width: 100%;
    margin: auto;
    display: flex;
}

.book-content,
.chapters-panel-box,
.settings-box {
    display: block;
}

@media (min-width: 67.5rem) {
    .page-visible {
        max-width: 60rem;
    }

    .bottom-nav .box,
    .batch-toolbar .box,
    .panel-header .box,
    .book-content,
    .reader-bottom-bar .box,
    .chapters-panel-box,
    .settings-box {
        width: 60rem;
    }

    .book-content,
    .book-bottom .box {
        max-width: 60rem;
    }

}

/* Sticky Headers */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    padding: 1rem 0 1rem 0;
    background: rgb(var(--mdui-color-surface));
}

/* ===== 4. COMMON COMPONENTS ===== */
/* Loading Indicator */
.loading {
    overflow: hidden;
}

#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    background-color: rgb(var(--mdui-color-surface));
    transition: opacity 0.3s ease;
}

#loadingOverlay.hidden {
    display: flex !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

#loadingOverlay .text-center mdui-circular-progress {
    margin-bottom: 1rem;
}

#loadingOverlay .text-center #loadingText {
    width: 12.5rem;
    max-width: 12.5rem;
}

#loadingOverlay .text-center .import-progress-container,
#loadingOverlay .text-center #importProgress {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 12.5rem;
    max-width: 12.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

mdui-linear-progress {
    border-radius: 100rem;
}

.import-progress-bar {
    height: 1rem;
    border-radius: 100rem;
}

.import-progress-bar::part(indicator) {
    border-radius: 100rem;
    min-width: 1rem;
}

.import-progress-bar::part(indicator)::before,
.import-progress-bar::part(indicator)::after {
    border-radius: 100rem;
}

/* Search Bar */
.search-bar {
    position: relative;
}

.search-input {
    width: 100%;
}

/* Filters */
.filter-buttons {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    margin-right: 0.5rem;
}

.select-mode-btn {
    margin-left: auto;
}

/* Page Headers */
.page-header,
.page-toolbar,
.page-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    display: flex;
    align-items: center;
}

.page-title mdui-icon,
.page-title mdui-button-icon,
.folder-icon {
    color: rgb(var(--mdui-color-primary));
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page-title h1,
.page-title h2 {
    font-size: 1.25rem;
    color: rgb(var(--mdui-color-primary));
    font-weight: normal;
}

/* ===== 5. LIBRARY PAGE ===== */
#libraryPage .library-actions,
#foldersPage .folder-actions,
#importPage .import-actions,
#aiChatPage .ai-chat-actions {
    display: flex;
    gap: 0.5rem;
}

.empty-library {
    text-align: center;
    padding: 4rem 0;
}

.empty-library-content {
    max-width: 20rem;
    margin: 0 auto;
    padding: 1.5rem;
}

.empty-library-icon {
    font-size: 4rem;
    color: rgb(var(--mdui-color-primary));
    margin-bottom: 1rem;
}

.empty-library-text {
    font-size: 1.125rem;
    color: rgb(var(--mdui-color-primary));
    margin-bottom: 1.25rem;
}

/* Book Grid View */
#bookGridView {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.375rem, 1fr));
    gap: 0.5rem;
}

@media (max-width: 37.5rem) {

    #bookGridView {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Book Cards */
.book-card {
    transition: all 0.2s;
    position: relative;
    user-select: none;
}

.book-cover {
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.2s;
    aspect-ratio: 2/3;
    background-size: cover;
    background-position: center;
    background-color: rgb(var(--mdui-color-primary));
}

.mdui-theme-dark .book-cover {
    background-color: rgb(var(--mdui-color-primary-container));
}

.book-card:active {
    transform: scale(0.98);
}

.book-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 0.25rem;
    background-color: rgb(var(--mdui-color-primary));
}

.book-cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.7) 100%);
    display: flex;
    padding: 0.625rem;
    flex-direction: column;
    justify-content: flex-end;
}

.book-title {
    color: white;
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.4em;
    max-height: calc(1.4em * 5);
    overflow: hidden;
    width: 100%;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 5;
    -webkit-box-orient: vertical;
}

.book-flex {
    display: flex;
    justify-content: space-between;
    margin-top: 0.125rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
}

.book-flex span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-info {
    padding: 0.75rem;
}

.book-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #666;
}

.mdui-theme-dark .book-stats {
    color: #aaa;
}

/* Book Selection */
.book-select-checkbox {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 20;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: white;
    transition: all 0.2s;
    opacity: 0;
}

.book-card.selectable .book-select-checkbox {
    opacity: 1;
}

.mdui-theme-dark .book-select-checkbox {
    background-color: rgba(0, 0, 0, 0.5);
    border-color: #374151;
}

.book-card.selected .book-select-checkbox {
    background-color: rgb(var(--mdui-color-primary));
    border-color: rgb(var(--mdui-color-primary));
}

.book-card.selected .book-select-checkbox:after {
    content: "check";
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.875rem;
    font-family: 'Material Icons' !important;
}

/* Book Actions */
.book-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.book-actions mdui-button-icon {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    aspect-ratio: 1 / 1;
    font-size: 0.875rem;
    backdrop-filter: blur(1rem);
}

.book-card:hover .book-actions,
.book-card.active .book-actions,
.book-card.selected .book-actions {
    opacity: 1;
    pointer-events: auto;
}

/* Book List View */
.book-list-item {
    display: flex;
    margin-bottom: 1rem;
    position: relative;
    user-select: none;
}

.book-list-cover {
    width: 4.25rem;
    aspect-ratio: 2 / 3;
    border-radius: 0.5rem;
    margin-right: 0.5rem;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    background-color: rgb(var(--mdui-color-primary));
}

.mdui-theme-dark .book-list-cover {
    background-color: rgb(var(--mdui-color-primary-container));
}

.book-list-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-list-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    overflow: hidden;
    width: 100%;
    max-height: calc(1.3rem * 4);
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 4;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.book-list-author {
    font-size: 0.75rem;
    color: #666;
}

.mdui-theme-dark .book-list-author {
    color: #aaa;
}

.book-list-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #666;
}

.mdui-theme-dark .book-list-bottom {
    color: #aaa;
}

/* List Selection */
.book-list-checkbox {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background-color: white;
    border: 0.125rem solid #ddd;
    transition: all 0.2s;
    opacity: 0;
}

.mdui-theme-dark .book-list-checkbox {
    background-color: rgba(0, 0, 0, 0.5);
    border-color: #374151;
}

.book-list-item.selectable {
    padding-left: 1.875rem;
}

.book-list-item.selectable .book-list-checkbox {
    opacity: 1;
}

.book-list-item.selectable .book-tag {
    left: 3.625rem;
}

.book-list-item.selected .book-list-checkbox {
    background-color: rgb(var(--mdui-color-primary));
    border-color: rgb(var(--mdui-color-primary));
}

.book-list-item.selected .book-list-checkbox:after {
    content: "check";
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.875rem;
    font-family: 'Material Icons' !important;
}

/* Book Tags */
.book-tag {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    color: white;
    backdrop-filter: blur(0.5rem);
    font-size: 0.75rem;
    z-index: 10;
}

.book-tag mdui-icon {
    font-size: 0.75rem;
    margin-right: 0.25rem;
}

.book-list-tag mdui-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.tag-favorite {
    background-color: rgba(255, 179, 0, 0.4);
}

.tag-recent {
    background-color: rgba(0, 191, 165, 0.4);
}

/* Batch Toolbar */
.batch-toolbar {
    position: fixed;
    bottom: 5rem;
    left: 0;
    right: 0;
    opacity: 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, bottom 0.3s ease;
    pointer-events: none;
    border-radius: var(--shape-corner) var(--shape-corner) 0 0;
    background-color: rgba(var(--mdui-color-surface));
    box-shadow: var(--mdui-elevation-level2);
    padding: 0;
}

.batch-toolbar .box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    gap: 0.5rem;
}

.batch-toolbar[hide] {
    bottom: 0;
    opacity: 0;
    transform: translateY(100%);
}

.batch-toolbar.visible {
    opacity: 1;
    transform: translateY(0);
    display: flex;
    pointer-events: auto;
}

/* Pagination Navigation */
.pagination-nav {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 1rem 0 0;
}

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-numbers {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem;
}

.pagination-numbers .page-number {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    position: relative;
}

.pagination-numbers .page-number:hover {
    background-color: rgba(var(--mdui-color-primary), 0.1);
}

.pagination-numbers .page-number.active {
    background-color: rgb(var(--mdui-color-primary));
    color: white;
}

.pagination-numbers .page-ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    font-size: 0.875rem;
    opacity: 0.7;
}

.pagination-numbers .page-ellipsis::after {
    content: "...";
    margin-left: 0.125rem;
    margin-right: 0.125rem;
}

@media (max-width: 25rem) {
    .pagination-numbers .page-ellipsis::after {
        content: "";
        margin-left: 0;
        margin-right: 0;
    }
}

.pagination-info {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.mdui-theme-dark .pagination-info {
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

/* ===== 6. FOLDERS PAGE ===== */
#currentFolderInfo {
    margin-bottom: 1rem;
}

.folder-breadcrumb {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    color: rgb(var(--mdui-color-primary));
    text-decoration: none;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
    color: #666;
}

.mdui-theme-dark .breadcrumb-separator {
    color: #aaa;
}

.folder-item,
#chapterRulesContent .card {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.folder-item:hover,
#chapterRulesContent .card:hover {
    background-color: rgb(var(--mdui-color-secondary-container));
}

.folder-info {
    flex: 1;
}

.folder-count {
    font-size: 0.75rem;
    color: #666;
}

.mdui-theme-dark .folder-count {
    color: #aaa;
}

.page-toolbar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-toolbar-title h1,
.page-toolbar-title h2 {
    font-weight: normal;
    margin: 0;
    font-size: 1.35rem;
    color: rgb(var(--mdui-color-on-surface));
}

.page-toolbar-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
}

.page-toolbar mdui-icon {
    color: rgb(var(--mdui-color-primary));
}

.folder-header,
.page-header-bar {
    position: sticky;
    top: 0;
    z-index: 90;
    background-color: rgba(var(--mdui-color-background));
    width: 100%;
    padding: 1rem 0;
    margin: -1rem 0 0 0;
}

.video-header {
    padding-bottom: 0;
}

/* ===== 6.5 AI CHAT PAGE ===== */
#aiChatPage {
    display: flex;
    flex-direction: column;
    padding: 1rem !important;
}

.ai-chat-page-title h1 {
    margin: 0;
    font-size: 1.35rem;
}

.ai-chat-page-title p {
    margin: 0;
    color: rgba(var(--mdui-color-on-surface), 0.65);
    font-size: 0.9rem;
}

.ai-chat-page-actions {
    display: flex;
    gap: 0.35rem;
}

#aiChatPage .ai-chat-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-chat-conversation-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-chat-conversation {
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 0.0625rem solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.ai-chat-conversation:hover {
    border-color: rgba(var(--mdui-color-primary), 0.4);
}

.ai-chat-conversation.active {
    border-color: rgb(var(--mdui-color-primary));
    background-color: rgba(var(--mdui-color-primary), 0.1);
}

.ai-chat-conversation-info {
    flex: 1;
    min-width: 0;
}

.ai-chat-conversation-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-conversation-meta {
    font-size: 0.75rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.ai-chat-conversation-actions {
    display: flex;
    gap: 0.25rem;
}

.ai-conversation-dialog-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ai-conversation-dialog-toolbar mdui-button {
    flex: none;
}

.ai-chat-sidebar-empty {
    text-align: center;
    padding: 1.5rem 1rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ai-chat-sidebar-empty mdui-icon {
    font-size: 2.2rem;
    color: rgba(var(--mdui-color-primary), 0.8);
}

.ai-chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.ai-chat-panel-header {
    top: 4.5rem;
    position: sticky;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: rgb(var(--mdui-color-background));
    z-index: 5;
    padding-bottom: 1rem;
}

#aiChatPage .ai-chat-title {
    flex: 1;
    display: flex;
    align-items: center;
}

#aiChatPage .ai-chat-title>mdui-icon {
    font-size: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#aiChatPage .ai-chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: calc(100dvh - 9rem);
}

.ai-chat-history {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-chat-message {
    display: flex;
    gap: 0.25rem;
    align-items: stretch;
    position: relative;
    flex-direction: column;
}

.ai-chat-bubble {
    width: 100%;
    white-space: normal;
    line-height: 1.5;
    word-break: break-word;
}

.ai-chat-message-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

.ai-chat-message-actions mdui-button-icon {
    width: 2rem;
    height: 2rem;
}

.ai-chat-message-actions mdui-button-icon::part(icon) {
    font-size: 1rem;
}

.ai-chat-bubble-body-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-chat-meta-bar {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.ai-chat-bubble-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
}

.ai-chat-markdown {
    line-height: 1.5;
}

.ai-typing-cursor {
    display: inline-block;
    width: 0.65ch;
    height: 1.1em;
    margin-left: 0.1rem;
    background: rgba(var(--mdui-color-on-surface), 0.9);
    animation: typing-blink 1s steps(2, jump-none) infinite;
    border-radius: 0.125rem;
}

@keyframes typing-blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.ai-delay-meter {
    align-self: flex-start;
    font-size: 0.85rem;
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

.ai-variant-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    align-self: flex-start;
}

.ai-variant-index {
    font-size: 0.85rem;
    color: rgba(var(--mdui-color-on-surface), 0.65);
}

.ai-inline-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-inline-editor-input {
    width: 100%;
}

.ai-inline-editor-input::part(container) {
    min-height: 20rem;
    border-radius: 0.75rem;
}

.ai-inline-editor-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.ai-chat-subtitle {
    font-size: 0.9rem;
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

.ai-chat-placeholder {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 0.0625rem dashed rgba(var(--mdui-color-on-surface), 0.15);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
    font-size: 0.9rem;
}

.ai-chat-placeholder mdui-icon {
    color: rgb(var(--mdui-color-primary));
}

.ai-chat-input {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    align-items: center;
    z-index: 5;
    background: rgb(var(--mdui-color-background));
    padding-bottom: calc(1rem + var(--video-player-bottom));
    margin-bottom: -1rem;
    border-radius: 2rem 2rem 0 0;
}

.ai-chat-textarea::part(container) {
    border-radius: 2rem;
    padding-right: 3.5rem;
}

.ai-chat-input-actions {
    display: flex;
    justify-content: flex-end;
    position: absolute;
    right: 0;
}

.ai-chat-input-actions mdui-button,
.ai-chat-input-actions mdui-button-icon {
    width: 3.5rem;
    height: 3.5rem;
}

.ai-chat-submit {
    align-self: flex-end;
}

.ai-settings-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-radius: 1rem;
    border: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.08);
    background-color: rgba(var(--mdui-color-on-surface), 0.02);
}

.ai-settings-meta {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

.modal-stack {
    display: flex;
    flex-direction: column;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem;
}

.modal-actions mdui-button {
    flex: 0 0 auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.section-header--start {
    align-items: flex-start;
}

.section-header h3,
.section-header h4 {
    margin: 0;
}

.section-header p {
    margin: 0;
    color: rgba(var(--mdui-color-on-surface), 0.65);
    font-size: 0.9rem;
}

.ai-settings-section {
    display: flex;
    flex-direction: column;
}

.ai-settings-section-header {
    gap: 1rem;
    align-items: flex-start;
}

.ai-settings-section-header h3 {
    font-size: 1rem;
}

.ai-settings-section-header p {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
}

.ai-global-prompt-active {
    font-size: 0.9rem;
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

.ai-global-prompt-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-global-prompt-card {
    border: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.08);
    border-radius: 0.85rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-global-prompt-card.active {
    border-color: rgb(var(--mdui-color-primary));
}

.ai-global-prompt-card-header {
    gap: 0.5rem;
}

.ai-global-prompt-preview {
    color: rgba(var(--mdui-color-on-surface), 0.75);
    line-height: 1.5;
}

.ai-global-prompt-card-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.ai-settings-tip {
    font-size: 0.85rem;
    color: rgba(var(--mdui-color-on-surface), 0.65);
}

.ai-conversation-type-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-conversation-type-panel h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: normal;
}

.rpg-tag-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    max-height: 4rem;
    overflow: hidden;
}

.rpg-tag-suggestions {
    display: flex;
    flex-wrap: wrap;
}

.rpg-tag-button {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.25rem;
    border: 0;
    background: transparent;
    border-radius: 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.rpg-tag-button:hover {
    background-color: rgba(var(--mdui-color-primary), 0.1);
    color: rgb(var(--mdui-color-primary));
}

.rpg-tag-button .md-tag-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background-color: rgba(var(--mdui-color-primary), 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.md-content p {
    margin: 0 0 0.75rem;
}

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
    margin: 0 0 0.75rem;
}

.md-content ul,
.md-content ol {
    padding-left: 1.25rem;
    margin: 0 0 0.75rem;
}

.md-content li {
    margin-bottom: 0.35rem;
}

.md-content p>.icon,
.md-content li .icon {
    margin-left: 0.25rem;
    margin-right: 0.25rem;
}

.md-content pre {
    background-color: rgba(var(--mdui-color-on-surface), 0.08);
    border-radius: 0.75rem;
    padding: 0.75rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.45;
}

.md-content code {
    font-family: Consolas, "SFMono-Regular", Menlo, Monaco, monospace;
    background-color: rgba(var(--mdui-color-on-surface), 0.08);
    padding: 0.25rem 0.6rem;
    border-radius: 0.35rem;
    font-size: 0.85rem;
}

.md-content pre code {
    background-color: transparent;
    padding: 0;
}

.md-content blockquote {
    margin: 0 0 0.75rem;
    padding-left: 0.75rem;
    border-left: 0.1875rem solid rgba(var(--mdui-color-primary), 0.4);
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

/* ===== 7. READER PAGE ===== */
.reader-page,
#readerChaptersPage,
#readerSettingsPage {
    padding-top: 0rem !important;
    padding-bottom: 0rem !important;
    padding-left: 0rem !important;
    padding-right: 0rem !important;
    max-width: 100% !important;
}

#readerChaptersPage,
#readerSettingsPage {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

#readerPage {
    overflow: hidden;
}

.reader-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.panel-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding-block: var(--reader-toolbar-padding-block);
    padding-inline: var(--reader-toolbar-padding-inline);
    z-index: var(--reader-toolbar-z);
    background: var(--bg-color);
    backdrop-filter: blur(0.25rem);
}

.panel-header .box {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mdui-theme-dark .panel-header {
    --reader-toolbar-border-color: rgba(255, 255, 255, 0.1);
}

#readerChaptersPage .panel-header .box,
#readerSettingsPage .panel-header .box {
    justify-content: flex-start;
}

#readerChaptersPage .panel-header .box h3,
#readerSettingsPage .panel-header .box h3 {
    font-weight: normal;
}

#readerChaptersPage .chapters-panel-box {
    padding-top: 2.5rem;
}

.book-content {
    width: 100%;
    height: calc(100dvh - var(--page-padding-top, 1.5rem) - var(--page-padding-bottom, 2.5rem));
    margin-top: var(--page-padding-top, 1.5rem);
    padding-right: var(--page-padding-right, 1rem);
    margin-bottom: var(--page-padding-bottom, 2.5rem);
    padding-left: var(--page-padding-left, 1rem);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    will-change: scroll-position;
    transform: translateZ(0);
}

.book-content pre {
    white-space: pre-line;
    font-size: var(--font-size);
    line-height: var(--line-spacing);
    color: var(--font-color);
    transition: color var(--transition-speed);
    font-family: var(--font-family);
    text-indent: var(--first-line-indent);
    text-align: var(--reader-text-align, left);
    margin-bottom: var(--paragraph-spacing);
    word-break: break-word;
}

.book-content h1.chapter-title {
    font-size: calc(var(--font-size) * 1.2);
    line-height: calc(var(--line-spacing) * 1.2);
    color: var(--font-color);
    transition: color var(--transition-speed);
    font-family: var(--font-family);
    text-align: var(--reader-text-align, left);
    margin-bottom: var(--paragraph-spacing);
    word-break: break-word;
    font-weight: normal;
}

.book-content p {
    font-size: var(--font-size);
    line-height: var(--line-spacing);
    color: var(--font-color);
    transition: color var(--transition-speed);
    font-family: var(--font-family);
    text-indent: var(--first-line-indent);
    text-align: var(--reader-text-align, left);
    margin-bottom: var(--paragraph-spacing);
    word-break: break-word;
}

.book-bottom {
    position: fixed;
    bottom: calc(var(--page-padding-bottom, 2.5rem) - 1.25rem);
    left: 0;
    right: 0;
    font-size: 0.75rem;
    display: flex;
    height: 0.8rem;
    line-height: 1.5rem;
    color: var(--font-color);
    font-family: var(--font-family);
    align-items: center;
    justify-content: center;
}

.book-bottom .box {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-left: var(--page-padding-left, 1rem);
    padding-right: var(--page-padding-right, 1rem);
}

.book-chapter {
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2005;
    font-size: 0.75rem;
    gap: 0.5rem;
    border-top: 0.0625rem solid rgba(0, 0, 0, 0.1);
    background: var(--bg-color);
    padding-bottom: 1rem;
    flex-direction: column;
}

.reader-bottom-bar .box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.mdui-theme-dark #readerPage .reader-bottom-bar {
    border-top: 0.0625rem solid rgba(255, 255, 255, 0.1);
}

.reader-bottom-bar .box>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.reader-bottom-bar .box>div #prevChapterBtn,
.reader-bottom-bar .box>div #nextChapterBtn {
    position: relative;
    overflow: hidden;
    width: 33.33333333%;
}

.reader-header {
    top: calc(-4.5rem - 0.0625rem) !important;
    transition: top 0.15s ease-in-out;
}

.reader-bottom-bar {
    bottom: calc(-7.5rem - 0.0625rem) !important;
    transition: bottom 0.15s ease-in-out;
}

.reader-header.show {
    top: 0 !important;
}

.reader-bottom-bar.show {
    bottom: 0 !important;
}

/* Chapters Panel */
#readerChaptersPage {
    padding-bottom: 1rem !important;
}

.mdui-theme-dark #readerChaptersPage .panel-header,
.mdui-theme-dark #readerSettingsPage .panel-header {
    border-bottom: 0.0625rem solid rgba(255, 255, 255, 0.1);
}

#readerChaptersPage mdui-text-field,
#readerSettingsPage mdui-text-field {
    width: 100%;
    margin: 1rem 0;
}


#readerChaptersPage .chapters-panel-box>ul {
    list-style: none;
    display: flex;
    flex-direction: column;
}

#readerChaptersPage .chapters-panel-box>ul li {
    line-height: 2em;
    padding: 0.5rem 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
}

#readerChaptersPage .chapters-panel-box>ul li:hover {
    background-color: rgb(var(--mdui-color-secondary-container), 0.8)
}

#readerChaptersPage .chapters-panel-box>ul li.active {
    background-color: rgb(var(--mdui-color-secondary-container), 0.8)
}

#readerChaptersPage .chapters-panel-box>ul li .chapter-cached-indicator {
    margin-left: auto;
}

#readerSettingsPage .settings-box {
    margin-top: 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#readerSettingsPage .flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

#readerSettingsPage .flex mdui-slider {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

#readerSettingsPage .settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding: 0;
}

#readerSettingsPage .color-theme {
    border: 0.125rem solid transparent;
    border-radius: 1rem;
    padding: 0.5rem;
    cursor: pointer;
    min-height: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    font-size: 0.75rem;
}

#readerSettingsPage .color-theme a {
    text-align: center;
    color: inherit;
    font-size: 0.75rem;
    line-height: 0.75rem;
    margin-top: 0.25rem;
    text-decoration: none;
    background: rgb(var(--mdui-color-background));
    border-radius: 1rem;
    padding: 0.25rem;
}

#readerSettingsPage .color-theme:active {
    transform: scale(0.95);
}

#readerSettingsPage .color-theme.active {
    border-color: var(--primary-color);
}

#readerSettingsPage .color-theme-preview {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    margin-bottom: 0.5rem;
    border: 0.0625rem solid rgba(0, 0, 0, 0.1);
    font-size: 0.75rem;
}

.mdui-theme-dark #readerSettingsPage .color-theme-preview {
    border: 0.0625rem solid rgba(255, 255, 255, 0.1);
}

#readerSettingsPage .form-input {
    font-family: var(--font-family);
}

#readerSettingsPage .alignment-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(3.75rem, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#readerSettingsPage mdui-button.alignment-option {
    width: 100%;
    --mdui-button-height: 2.5rem;
}

#readerSettingsPage mdui-button.alignment-option.active {
    outline: 0.125rem solid rgb(var(--mdui-color-primary));
    outline-offset: 0.125rem;
}

#readerSettingsPage .margin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13.75rem, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

#readerSettingsPage .margin-control label {
    display: block;
    font-size: 0.9rem;
    color: rgba(var(--mdui-color-on-background), 0.8);
    margin-bottom: 0.3rem;
}

.mdui-theme-dark #readerSettingsPage .margin-control label {
    color: rgba(255, 255, 255, 0.7);
}

#readerSettingsPage .margin-control .flex {
    gap: 0.5rem;
    align-items: center;
}

.save-settings-box {
    position: sticky;
    bottom: 0;
    padding: 1rem;
    margin: -1rem;
    background: var(--bg-color);
    z-index: 5;
}

/* ===== 8. THEMES ===== */
.theme-default {
    --bg-color: rgb(var(--mdui-color-background));
    --font-color: rgb(var(--mdui-color-on-background));
}

.theme-eyecare {
    --bg-color: #E3EDCD;
    --font-color: #333333;
}

.mdui-theme-dark.theme-eyecare {
    --bg-color: #0a140f;
    --font-color: #E3EDCD;
}

.mdui-theme-dark.theme-warm {
    --bg-color: #2D2019;
    --font-color: #E0C9A6;
}

.theme-paper {
    --bg-color: #F7EEE3;
    --font-color: #473C33;
}

.mdui-theme-dark.theme-paper {
    --bg-color: #232121;
    --font-color: #D1C4B1;
}

.theme-blue {
    --bg-color: #e9eff5;
    --font-color: #1f282b;
}

.mdui-theme-dark.theme-blue {
    --bg-color: #1f282b;
    --font-color: #e9eff5;
}

.theme-white {
    --bg-color: #FFFFFF;
    --font-color: #000000;
}

.mdui-theme-dark.theme-white {
    --bg-color: #232121;
    --font-color: #ffffff;
}

.theme-paper-image {
    --bg-color: #F7EEE3;
    --bg-image: url('./bg/bg1-b.jpg');
    --font-color: #473C33;
}

@media (max-width: 52.5rem) {
    .theme-paper-image {
        --bg-image: url('./bg/bg1-m.jpg');
    }
}

.mdui-theme-dark.theme-paper-image {
    --bg-color: #232121;
}

.theme-watercolor-image {
    --bg-color: #fff2f2;
    --bg-image: url('./bg/bg2-b.jpg');
    --font-color: #333e47;
}

.mdui-theme-dark.theme-watercolor-image {
    --bg-color: #212123;
}

@media (max-width: 52.5rem) {
    .theme-watercolor-image {
        --bg-image: url('./bg/bg2-m.jpg');
    }
}

.theme-pink-image {
    --bg-color: #f3e9ed;
    --bg-image: url('./bg/bg3-b.jpg');
    --font-color: #2e2023;
}

@media (max-width: 52.5rem) {
    .theme-pink-image {
        --bg-image: url('./bg/bg3-m.jpg');
    }
}

.mdui-theme-dark.theme-pink-image {
    --bg-color: #212123;
}

html.reader-open.theme-paper-image body::before,
html.reader-open.theme-watercolor-image body::before,
html.reader-open.theme-pink-image body::before,
html.reader-open.theme-green-image body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    z-index: -1;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: scroll;
}

/* ===== 9. LOGIN/REGISTER PAGES ===== */
#loginPage,
#registerPage {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2010;
    background-color: rgb(var(--mdui-color-background));
    width: 100%;
    padding-bottom: 1rem !important;
}

#loginPage .text-center h1,
#registerPage .text-center h1 {
    margin-bottom: 0.25rem;
    font-weight: normal;
}

#loginPage .text-center a,
#registerPage .text-center a {
    text-decoration: none;
    color: rgb(var(--mdui-color-primary));
}

#loginForm,
#registerForm {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
    width: 100%;
    max-width: 25rem;
}

.about-logo {
    width: 5rem;
    height: 5rem;
    border-radius: 1.25rem;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background-image: url('./app.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#registerDisabledMessage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem;
    text-align: center;
    box-sizing: border-box;
}

#registerDisabledMessage mdui-icon {
    font-size: 2.5rem;
}

#registerDisabledMessage h2 {
    font-size: 1.25rem;
}

#registerDisabledMessage p {
    font-size: 1rem;
}

/* ===== 10. IMPORT PAGE ===== */
#importPage,
#chapterRulesPage {
    z-index: 2010;
    background-color: rgb(var(--mdui-color-background));
    width: 100%;
    padding-bottom: 1rem !important;
}

#importPage .card,
#importPage #singleBookForm,
#importPage #batchImportOptions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#importPage .card .flex {
    display: flex;
}

#importPage .book-file-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 8rem;
    padding: 1.5rem 1rem;
    border: 0.125rem dashed #d1d5db;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.875rem;
}

#importPage .book-file-dropzone mdui-icon {
    margin-bottom: 0.5rem;
}

#importPage .book-file-dropzone.border-primary {
    border-color: rgb(var(--mdui-color-primary));
}

.mdui-theme-dark #importPage .book-file-dropzone {
    background-color: #242424;
    border-color: #6b7280;
}

#importPage .card .flex mdui-button-icon,
#importPage .card .flex mdui-button {
    margin-left: 0.5rem;
}

#importPage .card .flex mdui-icon {
    margin-right: 0.5rem;
}

/* ===== 11. SETTINGS PAGE ===== */
#settingsPage .card {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    gap: 1rem;
}

#settingsPage .card h3,
#readerSettingsPage .settings-box h3 {
    font-size: 1rem !important;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: normal;
}

#settingsPage .card .flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#settingsPage .card .flex span {
    width: max-content;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#settingsPage .card .flex span:first-child {
    padding-right: 1rem;
}

.import-export-btns {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.import-export-btns mdui-button {
    display: inline-block;
    width: calc(50% - 0.25rem);
}

.ai-settings-panel {
    border: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.08);
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: rgba(var(--mdui-color-on-surface), 0.02);
}

.ai-settings-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-settings-row label {
    color: rgba(var(--mdui-color-on-surface), 0.7);
}

.ai-system-prompt-input {
    width: 100%;
    border: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.14);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 7.5rem;
    background-color: rgba(var(--mdui-color-on-surface), 0.02);
    color: rgba(var(--mdui-color-on-surface), 0.9);
}

.ai-settings-flag {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border: 0.0625rem dashed rgba(var(--mdui-color-primary), 0.3);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

.ai-settings-flag p {
    margin: 0;
    color: rgba(var(--mdui-color-on-surface), 0.6);
    font-size: 0.85rem;
}

.ai-provider-section {
    border: 0.0625rem dashed rgba(var(--mdui-color-on-surface), 0.2);
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-provider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.ai-provider-header p {
    margin: 0;
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.ai-provider-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-provider-item {
    border: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-provider-item strong {
    font-size: 0.95rem;
}

.ai-provider-meta {
    display: flex;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: rgba(var(--mdui-color-on-surface), 0.65);
}

.ai-provider-meta span+span::before {
    content: '•';
    color: rgba(var(--mdui-color-on-surface), 0.45);
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.ai-provider-actions {
    display: flex;
    gap: 0.3rem;
    justify-content: flex-end;
}

.ai-provider-empty {
    text-align: center;
    color: rgba(var(--mdui-color-on-surface), 0.55);
    font-size: 0.9rem;
}

.ai-provider-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-provider-model-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.ai-provider-model-row mdui-select {
    flex: 1;
}

.ai-provider-model-row mdui-button-icon {
    flex: none;
}

.ai-provider-model-status {
    font-size: 0.8rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
    min-height: 1.2rem;
}

.ai-provider-model-status.muted {
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.ai-provider-model-status.loading {
    color: rgba(var(--mdui-color-on-surface), 0.75);
}

.ai-provider-model-status.success {
    color: rgba(var(--mdui-color-on-surface), 0.85);
}

.ai-provider-model-status.error {
    color: rgba(var(--mdui-color-error), 0.9);
}


#settingsPage .card>mdui-button,
#settingsPage #logoutButton {
    width: 100%;
}

#settingsPage .card mdui-button::part(button),
#settingsPage #logoutButton::part(button) {
    display: inline-flex;
    text-align: left;
    justify-content: flex-start;
}

#settingsPage .card mdui-button::part(end-icon),
#settingsPage #logoutButton::part(end-icon) {
    margin-left: auto;
}

.admin-list>.flex>.flex:first-child {
    width: 100%;
}

.admin-list>.flex>.flex:last-child {
    margin-left: 0.5rem;
}

.admin-card {
    border: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.08);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: rgba(var(--mdui-color-on-surface), 0.01);
}

.admin-card-header {
    align-items: flex-start;
}

.admin-users-badge {
    padding: 0.2rem 0.75rem;
    border-radius: 62.4375rem;
    background-color: rgba(var(--mdui-color-primary), 0.12);
    color: rgb(var(--mdui-color-primary));
    font-size: 0.85rem;
}

.admin-divider {
    height: 0.0625rem;
    width: 100%;
    background-color: rgba(var(--mdui-color-on-surface), 0.08);
}

.admin-toggle {
    padding: 0.65rem 0;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 0.0625rem solid rgba(var(--mdui-color-on-surface), 0.06);
}

.admin-toggle:last-of-type {
    border-bottom: none;
}

.admin-toggle strong {
    display: block;
}

.admin-toggle p {
    margin: 0;
    color: rgba(var(--mdui-color-on-surface), 0.6);
    font-size: 0.85rem;
}

.color-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.custom-color-picker {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-color-picker.active {
    border-color: rgb(var(--mdui-color-primary));
}

.custom-color-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.custom-color-inputs {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.custom-color-inputs input[type="color"] {
    width: 3rem;
    height: 3rem;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    position: relative;
}

.custom-color-picker.active .custom-color-inputs input[type="color"]::after {
    content: "check";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Material Icons';
    color: #fff;
}

.custom-color-inputs input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.custom-color-inputs input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    border: 0.0625rem solid rgba(0, 0, 0, 0.1);
}

.custom-color-inputs #customPrimaryColorText {
    flex: 1;
}

.color-option {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    border: 0.125rem solid transparent;
    transition: all 0.2s;
    border: 0.0625rem solid rgba(0, 0, 0, 0.1);
    position: relative;
    justify-self: center;
}

.mdui-theme-dark .color-option {
    border: 0.0625rem solid rgba(255, 255, 255, 0.1);
}

.color-option.active::after {
    content: "check";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Material Icons';
    color: #fff;
}

.color-option:hover {
    transform: scale(1.1);
}

#aiExploreDownloadBtn {
    --progress-width: 0%;
}

#aiExploreDownloadBtn::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: var(--progress-width);
    height: 100%;
    background-color: rgba(var(--mdui-color-primary), 0.25);
    z-index: 1;
    border-radius: 100rem;
    transition: all 0.2s;
}

/* ===== 12. DIALOGS & FORMS ===== */
.modal-stack>* {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0.5rem 0;
}

.modal-stack .flex {
    display: flex;
    align-items: center;
}

.modal-stack p {
    font-size: 1rem;
}

.modal-stack mdui-tabs::part(container) {
    background-color: inherit;
}

.modal-stack mdui-tab-panel[active] {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
}

.locked,
.loading {
    overflow: hidden;
}

.locked .app-container,
.locked .progress-bar,
.locked .bottom-nav,
.locked .batch-toolbar,
.locked #loadingOverlay {
    visibility: hidden;
}

#lockScreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgb(var(--mdui-color-background));
    z-index: 9999999999999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
}

#lockScreen.active {
    opacity: 1;
    visibility: visible;
}

.locked #standardLockScreen,
.locked #disguiseLockScreen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgb(var(--mdui-color-background));
}

.locked #disguiseLockScreen {
    background-color: #f5f5f5;
}

.locked #disguiseLockScreen.hidden {
    display: none;
}

.locked #disguiseFrame {
    width: 100%;
    height: 100%;
    border: none;
}

.locked #lockScreen .lock-icon {
    display: flex;
    color: rgb(var(--mdui-color-primary));
}

.locked #lockScreen .lock-title {
    font-size: 1.5rem;
    text-align: center;
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}

.locked #lockScreen .password-container {
    width: 100%;
    max-width: 18.75rem;
    margin-bottom: 1.5rem;
}

.locked #lockScreen .password-dots {
    display: flex;
    justify-content: center;
}

.locked #lockScreen .password-dot {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background-color: rgba(var(--mdui-color-on-surface), 0.2);
    margin: 0 0.5rem;
}

.locked #lockScreen .password-dot.filled {
    background-color: rgb(var(--mdui-color-primary));
}

.locked #lockScreen .numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    justify-items: center;
}

.locked #lockScreen .numpad-button {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    background-color: rgba(var(--mdui-color-on-surface), 0.05);
    cursor: pointer;
    user-select: none;
}

.locked #lockScreen .numpad-button:active {
    background-color: rgba(var(--mdui-color-on-surface), 0.15);
}

.locked #lockScreen .numpad-button[data-value="enter"] {
    background-color: rgba(var(--mdui-color-primary), 1);
    color: rgba(var(--mdui-color-on-primary), 1);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-0.3125rem);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(0.3125rem);
    }
}

/* ===== 14. USER PROFILE ===== */
.user-profile {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
}

.user-profile>.flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.user-profile>.flex>div {
    border-radius: 1.25rem;
    background-color: rgb(var(--mdui-color-secondary-container));
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    color: rgb(var(--mdui-color-on-secondary-container));
    display: flex;
    align-items: flex-start;
    flex-direction: row-reverse;
    justify-content: space-between;
    gap: 0.5rem;
}

.user-profile>.flex>div>*:nth-child(1) {
    font-size: 0.95rem;
}

.user-profile>.flex>div>*:nth-child(2) {
    display: flex;
    align-items: center;
}

.user-profile>.flex>div>*:nth-child(2) mdui-icon {
    margin-right: 0.25rem;
    font-size: 1em;
}

/* ===== 15. CHAPTER RULES ===== */
#chapterRulesContent {
    display: flex;
    flex-direction: column;
}

#chapterRulesContent .card>div {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* ===== 16. iphone 设备样式 ===== */
.pwa-full-screen {
    --navigation-bar-height: 6rem;
    --video-player-bottom: 1rem;
    --iframe-video-player-bottom: 0.5rem;
}

.pwa-full-screen mdui-navigation-bar {
    height: var(--navigation-bar-height);
    padding-bottom: 1rem !important;
}

.pwa-full-screen .reader-bottom-bar {
    padding-bottom: calc(1rem + var(--video-player-bottom)) !important;
}

.pwa-full-screen .save-settings-box {
    padding-bottom: calc(1rem + var(--video-player-bottom)) !important;
}

/* 视频模块核心样式 */
.video-player-main mdui-button-icon {
    color: white;
}

/* 视频页面样式 */
.video-title {
    display: flex;
    align-items: center;
}

.video-title mdui-icon {
    font-size: 1.5rem;
}

.video-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.video-content {}

.video-tabs {
    display: flex;
    margin-top: 1rem;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.video-modal-tabs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.video-modal-tab-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.video-modal-tab-buttons button {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.9rem;
}

.video-modal-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.video-modal-panel.hidden {
    display: none;
}

.api-search-footer {
    display: flex;
    justify-content: flex-end;
}

.api-search-results-container .empty-state {
    padding: 0;
    text-align: center;
}

.m3u8-actions {
    display: flex;
    justify-content: flex-end;
}

.web-video-actions {
    display: flex;
    justify-content: flex-end;
}

/* 搜索结果标题 */
.search-results-title {
    margin: 1rem 0;
}

.search-results-title h2 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: normal;
}

.search-results-subtitle {
    font-size: 0.8rem;
    color: #666;
    margin: 0.25rem 0 0 0;
    opacity: 0.8;
}

.mdui-theme-dark .search-results-subtitle {
    color: #aaa;
}

/* 视频网格和卡片 */
.video-grid {
    position: relative;
    display: block;
    min-height: 0;
    overflow: hidden;
}

.video-card {
    position: relative;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.7) 100%);
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    display: block;
    width: auto;
    margin: 0;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    -moz-column-break-inside: avoid;
}

.video-card-cover {
    position: relative;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(var(--mdui-color-surface-container-highest), 0.16);
    transition: background-color 0.2s ease;
}

.video-card-default-icon {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.video-card-default-icon mdui-icon {
    font-size: 3rem;
    color: rgb(var(--mdui-color-primary));
}

.video-card-cover img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity 0.35s ease, transform 0.4s ease;
}

.video-card-cover img.loaded {
    opacity: 1;
    transform: scale(1);
}

.video-card-cover.image-loaded {
    background-color: rgba(0, 0, 0, 0.6);
}

.video-card-cover--fallback {
    background-color: rgba(var(--mdui-color-surface-container-highest), 0.3);
    min-height: 12rem;
}

.video-card-cover--fallback .video-card-default-icon,
.video-card-cover:not(.image-loaded) .video-card-default-icon {
    opacity: 1;
    visibility: visible;
}

.video-card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    flex-direction: column;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-card:hover .video-card-actions {
    opacity: 1;
}

.video-card-actions mdui-button-icon {
    width: 1.5rem;
    height: 1.5rem;
    aspect-ratio: 1 / 1;
    font-size: 0.875rem;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(1rem);
    margin-bottom: 0.25rem;
    color: white;
}

.video-card-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 25%, transparent 100%);
    color: white;
}

.video-card-added-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 62.4375rem;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 6;
}

.video-card-added-indicator mdui-icon {
    color: #4caf50;
    font-size: 1.35rem;
}

.video-card--added .video-card-added-indicator {
    opacity: 1;
    transform: scale(1);
}

.video-card--added .video-card-cover {
    outline: 0.125rem solid rgba(var(--mdui-color-primary), 0.55);
    outline-offset: -0.125rem;
}

.video-card-title {
    width: 100%;
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.video-card-details {
    width: 100%;
    display: flex;
    font-size: 0.75rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-card-source,
.video-card-year,
.video-card-date {
    display: inline-block;
    margin-right: 0.5rem;
}

.video-card-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    z-index: 2;
    max-width: 50%;
    overflow: hidden;
}

/* 添加视频表单 */
.add-video-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.add-video-types {
    display: flex;
    gap: 1rem;
}

.add-video-type {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background-color: rgb(var(--mdui-color-surface-container-lowest));
    cursor: pointer;
    flex: 1;
    transition: background-color 0.2s ease;
}

.add-video-type.active {
    background-color: rgb(var(--mdui-color-primary-container));
    color: rgb(var(--mdui-color-on-primary-container));
}

.add-video-type mdui-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.form-input {
    width: 100%;
}

.hidden {
    display: none;
}

/* 视频源管理 */
.global-cors-settings {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.global-cors-controls {
    display: flex;
    gap: 0.5rem;
}

.global-cors-controls mdui-select {
    flex: 1;
}

.cors-api-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cors-api-empty {
    margin: 0;
    padding: 0.25rem 0;
    font-size: 0.9rem;
    color: rgb(var(--mdui-color-on-surface-variant));
}

.cors-api-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.cors-api-name {
    font-weight: 500;
    color: rgb(var(--mdui-color-on-surface));
}

.cors-api-endpoint {
    font-size: 0.85rem;
    word-break: break-all;
    color: rgb(var(--mdui-color-on-surface-variant));
}

.video-sources-list-container {}

.video-sources-list-container .flex {
    gap: 0.5rem;
    align-items: stretch;
    flex-direction: column;
}

/* 视频播放器 */
.video-player-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background-color: #000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
    padding: 0;
}

.video-player-main {
    position: relative;
    flex: 1;
    background-color: #000;
    overflow: hidden;
}

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

.video-player-main video.changing-episode {
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.video-player-overlay {
    position: absolute;
    inset: 0;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0) 40%), linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0) 20%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
    padding-bottom: calc(1rem + var(--video-player-bottom));
}

.video-player-main.controls-visible .video-player-overlay {
    opacity: 1;
    pointer-events: auto;
}

.video-player-main.controls-visible>video {
    pointer-events: none;
}

.video-player-chrome {
    display: flex;
    flex-direction: column;
    color: white;
    pointer-events: auto;
    height: 100%;
}

.video-chrome-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
}

.video-chrome-top {
    align-items: flex-start;
    margin-bottom: auto;
}

.video-chrome-top.hidden {
    opacity: 0;
    pointer-events: none;
}

.video-chrome-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.video-session-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.video-player-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-chrome-right {
    display: flex;
    gap: 0.5rem;
}

.video-chrome-middle {
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.video-primary-controls {
    display: flex;
    gap: 0.5rem;
}

.video-secondary-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 13.75rem;
}

.video-control-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.video-control-popover {
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 0;
    min-width: 10rem;
    padding: 0.6rem;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 0.75rem;
    box-shadow: 0 0.375rem 1.125rem rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(0.625rem);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.video-control-popover.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.volume-popover {
    min-width: 12.5rem;
}

.speed-group .video-control-popover {
    right: 0;
    left: auto;
}

.speed-group {
    margin-left: auto;
}

.play-pause-btn,
.video-fullscreen-btn,
.video-chrome-right mdui-button-icon,
.volume-button,
.speed-button {
    --mdui-button-icon-icon-size: 1.75rem;
    color: white;
}

.video-volume-slider {
    width: 100%;
}

.video-speed-menu {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.video-speed-item {
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.1rem 0.4rem;
    border-radius: 62.4375rem;
    transition: background-color 0.2s ease;
}

.video-speed-item.active {
    background-color: rgba(var(--mdui-color-primary), 0.9);
    color: #fff;
}

.video-progress-container {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.video-progress-slider {
    width: 100%;
    margin: 0;
    padding: 0 0.75rem;
}

.video-progress-slider::part(track-active) {
    border-radius: var(--mdui-shape-corner-full);
}

.video-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.video-time-display {
    display: flex;
    gap: 0.35rem;
}

.video-player-info {
    text-align: right;
    max-width: 60%;
}

.video-player-info h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: normal;
}

.video-player-info p {
    margin: 0.2rem 0 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
}

.video-player-info.no-episodes {
    opacity: 0.75;
}

.episodes-drawer-content {
    max-height: 30vh;
    overflow-y: auto;
}

.video-info-dialog {
    --mdui-dialog-max-width: 32.5rem;
}

.video-info-dialog-content {
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.video-info-list {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.video-info-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.video-info-label {
    font-size: 0.8rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.video-info-value {
    font-size: 0.95rem;
    line-height: 1.4;
    color: rgba(var(--mdui-color-on-surface), 0.9);
}

/* 剧集抽屉 */
.episodes-drawer {
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 15;
    pointer-events: auto;
    margin-right: auto;
}

.episodes-drawer.expanded {
    max-width: calc(100% - 2rem);
    width: 20rem;
    max-height: calc(45% - 2rem);
    height: 14rem;
    min-height: 5rem;
    border-radius: 1rem;
    background-color: rgba(0, 0, 0, 0.8);
}

.episodes-drawer-header {
    padding: 0 0.5rem;
    height: 2.5rem;
    cursor: pointer;
    color: white;
    font-weight: 500;
    user-select: none;
}

.episodes-drawer-header mdui-icon {
    transition: transform 0.3s ease;
    margin-left: 0.5rem;
    font-size: 1.2rem;
}

.episodes-drawer.expanded .episodes-drawer-header mdui-icon {
    transform: rotate(180deg);
    margin-left: auto;
}

.episodes-drawer-content {
    flex: 1;
    overflow-y: auto;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-bottom: 0.5rem;
   scrollbar-width: thin;
    display: none;
    height: 0;
    opacity: 0;
}

@keyframes showEpisodesContent {
    0% {
        height: 0;
        opacity: 0;
    }

    100% {
        height: auto;
        opacity: 1;
        animation-fill-mode: forwards;
    }
}

.episodes-drawer.expanded .episodes-drawer-content {
    display: flex;
    animation: showEpisodesContent 0.3s ease forwards;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
}

.episodes-drawer-content::-webkit-scrollbar {
    display: none;
    /* 隐藏滚动条 */
}

.episode-button {
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 100rem;
    font-size: 0.85rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.episode-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.episode-button.playing {
    background-color: rgb(var(--mdui-color-primary));
    font-weight: 500;
}

/* 通知吐司 */
.video-toast {
    position: fixed;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    z-index: 9999;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.3);
}

.video-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* iframe播放器 */
.iframe-player-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background-color: #000;
    display: flex;
    flex-direction: column;
}

.iframe-player-frame {
    flex: 1;
    width: 100%;
    height: calc(100% - var(--iframe-video-player-bottom));
    max-height: calc(100% - var(--iframe-video-player-bottom));
    border: none;
}

.iframe-player-buttons {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.iframe-player-button {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
}

.empty-state p {
    margin: 0 0 1rem 0;
    color: rgba(var(--mdui-color-on-surface), 0.6);
}

.empty-state mdui-button {
    margin-top: 0.5rem;
}

/* iOS补充样式 */
@supports (-webkit-touch-callout: none) {
    .video-player-main video {
        position: relative;
        z-index: 1;
    }
}

/* 视频源列表样式 */
.source-list {
    padding: 0;
}

.source-list-item,
.cors-api-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: rgb(var(--mdui-color-surface-container-lowest));
    border-radius: 0.5rem;
    width: 100%;
}

.source-list-content {
    flex: 1;
    overflow: hidden;
}

.source-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.source-url {
    font-size: 0.85rem;
    color: rgba(var(--mdui-color-on-surface), 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.source-filter-info {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    color: rgba(var(--mdui-color-on-surface), 0.7);
    line-height: 1.4;
}

.filter-badge {
    display: inline-block;
    background-color: rgb(var(--mdui-color-secondary-container));
    color: rgb(var(--mdui-color-on-secondary-container));
    padding: 0.1rem 0.4rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    margin-right: 0.25rem;
}

.source-list-actions {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

/* 筛选设置表单样式 */
.filter-settings-form {
    padding: 0.5rem 0;
}

.filter-section {
    margin-bottom: 1.5rem;
}

.filter-section h3 {
    font-size: 1rem;
    margin: 0 0 0.75rem 0;
    font-weight: 500;
    font-weight: normal;
}

.filter-mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-values-container {
    margin-bottom: 1rem;
}

.filter-help-text {
    font-size: 0.8rem;
    color: rgba(var(--mdui-color-on-surface), 0.6);
    line-height: 1.4;
}

/* google */
.picker-dialog,
.picker-dialog-bg {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border: 0 !important;
    z-index: 99999999999 !important;
}

.picker-dialog-frame,
.picker-dialog-content {
    width: 100dvw;
    height: 100dvh;
    border: 0;
    overflow: hidden;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    position: fixed;
}

/* AI Chat Styles */
.ai-chat-markdown button[send] {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5rem 0.5rem;
    border-radius: 2rem;
    border: none;
    background-color: transparent;
    color: rgb(var(--mdui-color-on-surface));
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    line-height: 1.2;
    margin-left: -0.5rem;
    margin-right: 0.5rem;
}

.ai-chat-markdown button[send]:hover {
    background-color: rgb(var(--mdui-color-primary));
    color: #fff;
}

.ai-chat-markdown button[send] .icon,
.ai-chat-markdown .icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    font-weight: 400;
    font-family: "Material Icons";
    font-style: normal;
    line-height: 1;
    direction: ltr;
    letter-spacing: normal;
    white-space: nowrap;
    text-transform: none;
    overflow-wrap: normal;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizelegibility;
    font-size: 1rem;
}

.ai-chat-markdown details summary::before {
    content: 'expand_more';
    display: inline-block;
    width: 1em;
    height: 1em;
    font-weight: 400;
    font-family: "Material Icons";
    font-style: normal;
    line-height: 1;
    direction: ltr;
    letter-spacing: normal;
    white-space: nowrap;
    text-transform: none;
    overflow-wrap: normal;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizelegibility;
    font-size: 1.5rem;
}

.ai-chat-markdown details[open] summary::before {
    content: 'expand_less';
    transform: rotate(0deg);
}


.ai-chat-markdown .red {
    color: #ff0037;
}

.ai-chat-markdown .blue {
    color: #2196f3;
}

.ai-chat-markdown .green {
    color: #4caf50;
}

.ai-chat-markdown .orange {
    color: #ff9800;
}

.ai-chat-markdown .purple {
    color: #9c27b0;
}

.ai-chat-markdown .pink {
    color: #e91e63;
}

.ai-chat-markdown details {
    margin: 0 0 0.75rem;
    padding-left: 2rem;
}

.ai-chat-markdown details summary {
    cursor: pointer;
    margin-left: -2rem;
}

.ai-chat-markdown details[open] summary {
    margin-bottom: 0.75rem;
}

.ai-chat-markdown details summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
}

.ai-chat-markdown form {
    display: flex;
    flex-direction: column;
}

.ai-chat-markdown form label {
    display: block;
    font-weight: 500;
    color: rgb(var(--mdui-color-on-surface));
}

.ai-chat-markdown .red .icon,
.ai-chat-markdown .blue:has(.icon),
.ai-chat-markdown .green:has(.icon),
.ai-chat-markdown .orange:has(.icon),
.ai-chat-markdown .purple:has(.icon),
.ai-chat-markdown .pink:has(.icon) {
    line-height: 1.5;
}

label:has(span.icon),
.ai-chat-markdown form button[type="submit"]:has(span.icon),
.ai-chat-markdown details summary:has(span.icon) {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}


.ai-chat-markdown form input,
.ai-chat-markdown form textarea,
.ai-chat-markdown form select {
    width: 100%;
    padding: 0.5rem;
    border: 0.0625rem solid rgb(var(--mdui-color-outline));
    border-radius: 0.5rem;
    background-color: rgb(var(--mdui-color-surface));
    color: rgb(var(--mdui-color-on-surface));
    font-family: inherit;
}

.ai-chat-markdown form input:focus,
.ai-chat-markdown form textarea:focus,
.ai-chat-markdown form select:focus {
    outline: 0.125rem solid rgb(var(--mdui-color-primary));
    outline-offset: 0.1rem;
}

.ai-chat-markdown form button {
    display: inline-block;
    padding: 0.5rem;
    border: none;
    border-radius: 2rem;
    background-color: rgb(var(--mdui-color-primary-container));
    color: rgb(var(--mdui-color-on-primary-container));
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    margin: 0;
}

.ai-chat-markdown form button:hover {
    background-color: rgb(var(--mdui-color-primary));
    color: rgb(var(--mdui-color-on-primary));
}

.ai-chat-markdown form input[type="checkbox"],
.ai-chat-markdown form input[type="radio"] {
    width: auto;
    margin-right: 0.35rem;
    margin-bottom: 0;
}

.ai-chat-markdown form input[type="color"] {
    padding: 0;
    height: 2.5rem;
}

.ai-chat-markdown form input[type="range"] {
    accent-color: rgb(var(--mdui-color-primary));
}

.ai-chat-markdown form button[type="submit"] {
    align-self: flex-start;
}

.md-content hr {
    display: block;
    height: 0.0625rem;
    background-color: rgb(var(--mdui-color-surface-variant));
    border: 0;
}

/* Iframes in AI Messages */
.ai-chat-markdown iframe,
.ai-chat-markdown .ai-html-iframe {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 1rem;
}
