:root {
    color-scheme: dark;
    /* Base Colors - Deep Blue/Black Theme */
    --bg-app: #090b10;
    --bg-sidebar: rgba(22, 27, 34, 0.6);
    /* More transparent */
    --bg-sidebar-secondary: rgba(13, 17, 23, 0.4);
    --bg-content: transparent;
    /* Let body gradient show through slightly or keep dark */

    --border-color: rgba(48, 54, 61, 0.4);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;

    --accent-color: #2f81f7;
    /* Brighter Blue */
    --accent-hover: #58a6ff;

    --hover-bg: rgba(110, 118, 129, 0.1);
    --active-bg: rgba(47, 129, 247, 0.15);

    --glass-bg: rgba(22, 27, 34, 0.6);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);

    --header-bg: rgba(9, 11, 16, 0.8);

    /* Content */
    --table-head-bg: rgba(255, 255, 255, 0.05);
    --table-row-alt-bg: rgba(255, 255, 255, 0.02);
    --blockquote-bg: rgba(255, 255, 255, 0.05);
    --inline-code-bg: rgba(110, 118, 129, 0.2);
    --highlight-bg: rgba(210, 153, 34, 0.3);
    --highlight-hover-bg: rgba(210, 153, 34, 0.5);
    --highlight-border: #d29922;

    --tooltip-bg: #2d333b;
    --tooltip-text: #ffffff;
    --spoiler-bg: rgba(255, 255, 255, 0.1);

    --scrollbar-thumb-hover: #484f58;
    --on-accent: #ffffff;

    --fab-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --fab-tooltip-bg: rgba(0, 0, 0, 0.9);
    --fab-tooltip-text: #ffffff;

    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    --font-zh: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --bg-app: #f6f8fa;
        --bg-sidebar: rgba(255, 255, 255, 0.7);
        --bg-sidebar-secondary: rgba(246, 248, 250, 0.6);
        --bg-content: transparent;

        --border-color: rgba(210, 217, 223, 0.8);
        --text-primary: #1F2328;
        --text-secondary: #656d76;

        --accent-color: #0969da;
        --accent-hover: #0550ae;

        --hover-bg: rgba(208, 215, 222, 0.3);
        --active-bg: rgba(9, 105, 218, 0.1);

        --glass-bg: rgba(255, 255, 255, 0.75);
        --glass-border: 1px solid rgba(0, 0, 0, 0.05);
        --header-bg: rgba(255, 255, 255, 0.85);

        --table-head-bg: rgba(246, 248, 250, 1);
        --table-row-alt-bg: #ffffff;
        --blockquote-bg: rgba(246, 248, 250, 1);
        --inline-code-bg: rgba(175, 184, 193, 0.2);
        --highlight-bg: rgba(255, 216, 0, 0.4);
        --highlight-hover-bg: rgba(255, 216, 0, 0.6);
        --highlight-border: #eac54f;

        --tooltip-bg: #24292f;
        --tooltip-text: #ffffff;
        --spoiler-bg: rgba(36, 41, 47, 0.08);

        --scrollbar-thumb-hover: #8c959f;
        --on-accent: #ffffff;
        --fab-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background: var(--bg-app);
    /* Subtle gradient background for depth */
    background-image: radial-gradient(circle at 10% 20%, rgba(9, 105, 218, 0.03) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(210, 153, 34, 0.02) 0%, transparent 20%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebars */
.sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 20;
}

.series-list {
    width: 260px;
    z-index: 21;
}

.episode-list {
    width: 320px;
    background-color: var(--bg-sidebar-secondary);
    z-index: 20;
    border-right: 1px solid var(--border-color);
}

.app-container.immersive-mode .series-list,
.app-container.immersive-mode .episode-list {
    width: 0 !important;
    min-width: 0;
    border-right: 0;
    opacity: 0;
    transform: translateX(-20px);
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 0;
    /* Cleaner look without hard border */
    min-height: 80px;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.sidebar-header h2,
.sidebar-header h3 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px 20px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(110, 118, 129, 0.3);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* List Items */
.list-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    /* Softer corners */
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    border-left: 0;
    /* Remove old style */
}

.list-item .icon {
    font-size: 16px;
    opacity: 0.7;
    transition: transform 0.2s;
}

.list-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.list-item:hover .icon {
    transform: scale(1.1);
    opacity: 1;
}

.list-item.active {
    background-color: var(--active-bg);
    color: var(--accent-color);
    font-weight: 600;
}

/* Optional: Add a small pill indicator for active state instead of border */
.list-item.active::before {
    content: '';
    display: block;
    position: absolute;
    left: -8px;
    /* Outside the padding */
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 0 4px 4px 0;
    opacity: 0;
    /* Hide for now, prefer full background */
}

.file-size {
    font-size: 10px;
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(110, 118, 129, 0.1);
    color: var(--text-secondary);
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-content);
    min-width: 0;
}

.content-header {
    height: 70px;
    padding: 0 40px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--header-bg);
    backdrop-filter: blur(5px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.content-header h1 {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-btn {
    width: auto;
    min-width: 88px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 500;
}

/* Markdown Container */
.markdown-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 60px 40px;
    max-width: 800px;
    /* Narrower for lyrics focus */
    margin: 0 auto;
    width: 100%;
    color: var(--text-primary);
    line-height: 2.2;
    /* Larger line height for lyrics */
    font-family: var(--font-zh), var(--font-main);
    font-size: 18px;
    /* Larger font size */
    -webkit-user-select: text;
    user-select: text;
    text-align: center;
    /* Center lyrics */
}

.markdown-body.touch-inking {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (max-width: 768px) {
    .content-header {
        padding: 0 16px;
    }

    .actions {
        gap: 8px;
    }

    .mode-btn {
        min-width: 72px;
        padding: 0 8px;
        font-size: 11px;
    }

    .markdown-body {
        padding: 30px 20px;
        font-size: 16px;
        /* Slightly smaller on mobile but still readable */
    }
}

/* Markdown Elements */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    border-bottom: none;
    /* Clean look */
    color: var(--text-primary);
    margin-top: 2em;
    margin-bottom: 1em;
    line-height: 1.4;
    font-weight: 700;
}

.markdown-body h1 {
    font-size: 2em;
    margin-bottom: 1.5em;
    color: var(--accent-color);
    /* Highlight Title */
}

.markdown-body h2 {
    font-size: 1.5em;
    opacity: 0.9;
}

.markdown-body p {
    margin-bottom: 1.5em;
    word-break: break-word;
    /* Safer word wrap */
    /* Maintain readability */
    max-width: 100%;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.markdown-body th,
.markdown-body td {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}

.markdown-body th {
    background-color: var(--table-head-bg);
    font-weight: 600;
}

.markdown-body tr:nth-child(2n) {
    background-color: var(--table-row-alt-bg);
}

.markdown-body blockquote {
    color: var(--text-secondary);
    border-left: 4px solid var(--border-color);
    background: var(--blockquote-bg);
    padding: 1em 1em 1em 1.5em;
    margin: 1.5em 0;
    border-radius: 0 4px 4px 0;
}

.markdown-body hr {
    height: 1px;
    background-color: var(--border-color);
    border: 0;
    margin: 2em 0;
}

.markdown-body code {
    background-color: var(--inline-code-bg);
    border-radius: 6px;
    padding: 0.2em 0.4em;
    font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace;
    font-size: 90%;
}

/* Highlights */
.user-highlight {
    background-color: var(--highlight-bg);
    border-bottom: 2px solid var(--highlight-border);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: text;
    user-select: text;
}

.user-highlight:hover {
    background-color: var(--highlight-hover-bg);
    position: relative;
    z-index: 1;
}

.user-highlight:hover::after {
    content: "点击移除";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 100;
}

/* Spoiler Mode (Learning Mode) */
.markdown-body em.spoiler {
    filter: blur(8px);
    user-select: none;
    cursor: pointer;
    transition: all 0.4s ease;
    opacity: 0.6;
    background: var(--spoiler-bg);
    border-radius: 4px;
    padding: 0 4px;
    font-style: normal;
    /* Optional: reset italic if desired, but keeping it is fine */
    color: transparent;
    /* Hide text color under blur */
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    /* Enhance blur */
}

.markdown-body em.spoiler:hover {
    filter: blur(4px);
    opacity: 0.8;
}

.markdown-body em.spoiler.revealed {
    filter: none;
    user-select: text;
    cursor: text;
    background: transparent;
    opacity: 1;
    color: var(--text-secondary);
    /* Restore text color */
    text-shadow: none;
}

/* Make sure the toggle button shows active state */
.mode-btn.active {
    background-color: var(--active-bg);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Floating Action Button */
.fab-copy {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--fab-shadow);
    cursor: pointer;
    z-index: 1000;
    border: none;
    transition: transform 0.2s;
}

.fab-copy:hover {
    transform: scale(1.1);
    background-color: var(--accent-hover);
}

.fab-copy:active {
    transform: scale(0.95);
}

.fab-copy svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.fab-copy::after {
    content: "复制高亮";
    position: absolute;
    right: 70px;
    background: var(--fab-tooltip-bg);
    color: var(--fab-tooltip-text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.fab-copy:hover::after {
    opacity: 1;
}

/* Nav Buttons */
.nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nav-btn:hover:not(:disabled) {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.content-footer {
    padding: 20px 60px 40px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.footer-nav-btn {
    flex: 1;
    padding: 15px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.footer-nav-btn:hover {
    background: var(--bg-sidebar-secondary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--accent-color);
    color: var(--on-accent);
    padding: 10px 20px;
    border-radius: 20px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    opacity: 0.5;
}