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

:root {
    --bg: #f5f5f5;
    --surface: #fff;
    --surface-hover: #f9fafb;
    --border: #e2e5e9;
    --text: #111;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --accent-dark: #1d4ed8;
    --green: #059669;
    --orange: #d97706;
    --red: #dc2626;
    --blue: #2563eb;
    --blue-light: #93c5fd;
    --slate: #475569;
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    min-height: 100vh;
    font-size: 1rem;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem 2rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 2px;
    transition: color 0.1s;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--text);
}

.nav-links a.active {
    color: var(--accent);
    background: var(--accent-light);
}

.btn-refresh {
    margin-left: auto;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.1s, border-color 0.1s;
}

.btn-refresh:hover {
    color: var(--text);
    border-color: var(--text);
}

/* Sidebar TOC */
.sidebar-toc {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: 180px;
    z-index: 90;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-toggle {
    display: none;
}

.sidebar-content {
    opacity: 1;
    visibility: visible;
}

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    font-weight: 600;
}

.sidebar-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-content li {
    margin-bottom: 0.4rem;
}

.sidebar-content a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
    padding: 0.5rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: all 0.1s;
}

.sidebar-content a:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--surface);
}

/* Container — full width with sidebar offset */
.container {
    margin-left: 180px;
    padding: 2rem 3rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    margin-bottom: 2.5rem;
    border: 1px solid var(--border);
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    transition: background 0.1s;
}

.stat-card:hover {
    background: var(--surface-hover);
}

.stat-card .label {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-card .value.movies,
.stat-card .value.shows,
.stat-card .value.anime,
.stat-card .value.total {
    color: var(--text);
}

/* Section */
.section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    border: 1px solid var(--border);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: var(--surface);
    transition: background 0.1s;
}

.activity-item:hover {
    background: var(--surface-hover);
}

.activity-poster {
    width: 60px;
    height: 84px;
    border-radius: 2px;
    object-fit: cover;
    background: var(--border);
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-weight: 500;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    gap: 0.8rem;
    margin-top: 0.15rem;
}

.activity-type {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.type-movie { color: var(--text-muted); }
.type-show { color: var(--text-muted); }
.type-anime { color: var(--text-muted); }

/* Progress items (Currently Watching) */
.progress-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: var(--surface);
    transition: background 0.1s;
}

.progress-item.clickable {
    cursor: pointer;
}

.progress-item.clickable:hover {
    background: var(--accent-light);
}

.progress-item .progress-info {
    flex: 1;
    min-width: 0;
}

.progress-item .progress-title {
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-item .progress-meta {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 0.15rem;
}

/* Progress bar */
.progress-bar {
    height: 2px;
    background: var(--border);
    margin-top: 0.4rem;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--accent);
}

/* Library Filters */
.library-filters {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.4rem 0.7rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.75rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
    transition: all 0.1s;
    white-space: nowrap;
}

.filter-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Library Grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1px;
    border: 1px solid var(--border);
}

.library-card {
    background: var(--surface);
    overflow: hidden;
    transition: background 0.1s;
    display: block;
}

.library-card:hover {
    background: var(--surface-hover);
}

.library-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: var(--border);
    display: block;
}

.library-card .card-info {
    padding: 0.8rem;
}

.library-card .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-card .card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.library-card .card-rating {
    font-size: 0.8rem;
    color: var(--orange);
    margin-top: 0.2rem;
    font-weight: 500;
}

.library-card .card-stars {
    display: flex;
    gap: 0px;
    margin-top: 0.3rem;
}

.library-card .card-stars .star {
    font-size: 0.85rem;
    color: var(--border);
    cursor: pointer;
    transition: color 0.1s;
    user-select: none;
}

.library-card .card-stars .star.filled {
    color: var(--orange);
}

.library-card .card-stars .star:hover {
    color: var(--orange);
    opacity: 0.7;
}

/* Chart Container */
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container canvas {
    max-height: 280px;
}

/* Heatmap */
.heatmap-container {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.5rem;
    overflow-x: auto;
}

.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 12px);
    grid-auto-flow: column;
    gap: 2px;
}

.heatmap-cell {
    width: 12px;
    height: 12px;
    background: var(--border);
}

.heatmap-cell.level-1 { background: #dbeafe; }
.heatmap-cell.level-2 { background: #93c5fd; }
.heatmap-cell.level-3 { background: #3b82f6; }
.heatmap-cell.level-4 { background: #1d4ed8; }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.8rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.heatmap-legend .swatch {
    width: 12px;
    height: 12px;
}

/* Detail Hero (fanart background) */
.detail-hero {
    position: absolute;
    top: 60px;
    left: 180px;
    right: 0;
    height: 300px;
    background-size: cover;
    background-position: center top;
    opacity: 0.15;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    pointer-events: none;
}

/* Star Rating Widget */
.star-rating {
    display: flex;
    gap: 1px;
}

.star-rating .star {
    font-size: 1rem;
    color: var(--border);
    cursor: pointer;
    transition: color 0.1s;
    user-select: none;
}

.star-rating .star.filled {
    color: var(--orange);
}

.star-rating .star.hover {
    color: var(--orange);
    opacity: 0.6;
}

/* Toggle Button (Watched/Unwatched) */
.btn-toggle {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.3rem 0.7rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all 0.1s;
}

.btn-toggle.watched {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-toggle:hover {
    border-color: var(--accent);
}

/* Navigation buttons */
.btn-nav {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
    transition: all 0.1s;
}

.btn-nav:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
}

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

/* Show Progress Cards */
.show-progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1px;
    border: 1px solid var(--border);
}

.show-progress-card {
    display: flex;
    gap: 0.8rem;
    padding: 1rem;
    background: var(--surface);
    transition: background 0.1s;
}

.show-progress-card:hover {
    background: var(--surface-hover);
}

.show-progress-card img {
    width: 44px;
    height: 66px;
    border-radius: 2px;
    object-fit: cover;
    background: var(--border);
    flex-shrink: 0;
}

.show-progress-card .sp-info {
    flex: 1;
    min-width: 0;
}

.show-progress-card .sp-title {
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.show-progress-card .sp-meta {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 0.15rem;
}

.show-progress-card .sp-bar {
    height: 2px;
    background: var(--border);
    margin-top: 0.4rem;
    overflow: hidden;
}

.show-progress-card .sp-bar .fill {
    height: 100%;
    background: var(--text);
}

.show-progress-card .sp-pct {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 0.3rem;
}

/* Settings toggles */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
}

.toggle-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--text);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination a, .pagination span {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.1s;
}

.pagination a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.pagination .active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination .disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar-toc {
        display: none;
    }

    .container {
        margin-left: 0;
        padding: 1.5rem 1rem;
    }

    .nav {
        padding: 0.8rem 1rem;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .detail-hero {
        left: 0;
    }
}
