/* =================================================================
   Reading Page - 阅读记录页面
   ================================================================= */

.reading-section {
    padding-bottom: 8px;
}

.reading-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.mobile-category-bar {
    display: none;
}

.mobile-category-trigger {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    color: var(--text-primary);
}

.mobile-category-caption {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 900;
    color: var(--text-tertiary);
}

.mobile-category-current {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-category-chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-tertiary);
    border-bottom: 2px solid var(--text-tertiary);
    transform: rotate(45deg);
    transform-origin: center;
    transition: transform 0.2s ease, border-color 0.2s ease;
    flex: 0 0 auto;
}

.reading-layout.mobile-category-open .mobile-category-chevron {
    transform: rotate(-135deg);
    border-color: var(--text-secondary);
}

.reading-sidebar {
    width: 300px;
    flex: 0 0 auto;
    position: sticky;
    top: 76px; /* 56px navbar + spacing */
    max-height: calc(100vh - 96px);
    overflow: auto;
}

.reading-main {
    flex: 1;
    min-width: 0;
}

.sidebar-card,
.main-card {
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.sidebar-card {
    padding: 14px;
}

.main-card {
    padding: 16px;
}

.reading-loading,
.reading-error {
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.reading-error {
    color: var(--danger-color);
}

.reading-empty {
    padding: 28px 24px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    text-align: center;
}

.reading-login {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.reading-login-title {
    font-size: 28px;
    font-weight: 950;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.reading-login-desc {
    max-width: 52ch;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.reading-login-btn {
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;

    background: var(--primary-color);
    color: var(--text-white);
    box-shadow: var(--shadow-primary);
}

.reading-login-btn:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-primary-hover);
}

.reading-empty-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.reading-empty-desc {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.reading-empty .reading-btn-primary,
.reading-empty .reading-btn-secondary {
    margin-top: 14px;
}

.sep {
    opacity: 0.7;
}

.progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.progress-track.small {
    height: 6px;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    width: 0;
    transition: width 0.3s ease;
}

.reading-btn-primary {
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    border: none;
    background: var(--primary-color);
    color: var(--text-white);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reading-btn-primary:hover {
    background: var(--primary-hover);
}

.reading-btn-secondary {
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reading-btn-secondary:hover {
    background: var(--nav-hover);
    color: var(--text-primary);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 900;
    color: var(--text-primary);
}

.sidebar-refresh {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
}

.sidebar-refresh:hover {
    background: var(--nav-hover);
    color: var(--text-primary);
}

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

.tree-group {
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.tree-group:first-child {
    padding-top: 0;
    border-top: none;
}

.tree-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 10px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-primary);
}

.tree-item:hover {
    background: var(--nav-hover);
}

.tree-item.active {
    background: rgba(0, 102, 255, 0.12);
    color: var(--primary-color);
}

[data-theme="dark"] .tree-item.active {
    background: rgba(59, 130, 246, 0.18);
}

.tree-item.group {
    font-weight: 900;
}

.tree-item.subject {
    font-weight: 800;
}

.tree-item.chapter {
    font-weight: 700;
    font-size: 13px;
    padding: 8px 10px;
}

.tree-left {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-stat {
    font-size: 12px;
    color: var(--text-tertiary);
}

.tree-item.active .tree-stat {
    color: var(--primary-color);
}

.tree-children {
    margin-top: 6px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tree-children.inner {
    margin-left: 14px;
}

.tree-subject-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-subject-row .tree-item.subject {
    flex: 1;
}

.tree-expand {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    position: relative;
    font-size: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.tree-expand::before,
.tree-expand::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    background: currentColor;
    border-radius: 999px;
    transform: translate(-50%, -50%);
}

.tree-expand::before {
    width: 12px;
    height: 2px;
}

.tree-expand[aria-expanded="false"]::after {
    width: 2px;
    height: 12px;
}

.tree-expand[aria-expanded="true"]::after {
    display: none;
}

.tree-expand:hover {
    background: var(--nav-hover);
    color: var(--text-primary);
}

.records-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.records-title {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    color: var(--text-primary);
}

.records-meta {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
}

.records-crumb {
    color: var(--text-tertiary);
}

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

.records-loading,
.records-error,
.records-empty {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 10px 8px;
}

.records-error {
    color: var(--danger-color);
}

.record-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
}

.record-num {
    display: inline-block;
    min-width: 32px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: #fff;
    background: var(--primary-color);
    border-radius: 4px;
    flex: 0 0 auto;
}

.record-title-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-sub {
    display: none;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.record-percent {
    font-size: 12px;
    color: var(--text-secondary);
    display: inline-block;
    width: 48px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    flex: 0 0 auto;
}

.record-finished {
    font-size: 12px;
    color: var(--success-color);
    background: var(--success-light);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    flex: 0 0 auto;
}

.record-unfinished {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 700;
}

.records-table {
    margin-top: 14px;
}

.records-row {
    display: grid;
    grid-template-columns: 1fr 160px 190px 110px 120px;
    gap: 12px;
    align-items: center;
    padding: 12px 8px;
}

.records-row.header {
    border-bottom: 1px solid var(--border-color);
}

.records-row.header > div {
    text-align: center;
}

.records-row.item {
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
}

.records-row.item:last-child {
    border-bottom: none;
}

.records-row.item:hover {
    background: var(--bg-secondary);
}

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

.progress-inline .progress-track.small {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.col-title {
    min-width: 0;
}

.col-chapter {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-finished {
    display: flex;
    align-items: center;
    justify-content: center;
}

.col-time {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: right;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .reading-layout {
        gap: 14px;
    }

    .reading-sidebar {
        width: 260px;
    }

    .sidebar-card {
        padding: 12px;
    }

    .main-card {
        padding: 14px;
    }

    .records-row {
        grid-template-columns: 1fr 140px 180px 90px 100px;
        gap: 10px;
        padding: 12px 6px;
    }
}

@media (max-width: 767px) {
    .reading-layout {
        flex-direction: column;
    }

    .mobile-category-bar {
        display: block;
    }

    .reading-sidebar {
        display: none;
        width: 100%;
        position: relative;
        top: auto;
        max-height: 60vh;
    }

    .reading-layout.mobile-category-open .reading-sidebar {
        display: block;
    }

    .records-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px 10px;
    }

    .records-row.header {
        display: none;
    }

    .col-chapter {
        display: none;
    }

    .record-sub {
        display: block;
    }

    .col-time {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .record-title-text {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}
