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

:root {
    --ink: #1a1a1a;
    --paper: #f6f6f6; /* Lichess-like background */
    --accent: #d97706;
    --accent-ink: #7c2d12;
    --muted: #6b7280;
    --border: #e5e7eb;
    --surface: #ffffff;
    --surface-2: #fcfcfb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Card Colors */
    --card-blue: #2d74c4;
    --card-orange: #d97706;
    --card-green: #16a34a;
    --card-red: #dc2626;
    --card-purple: #7c3aed;
    --card-teal: #0d9488;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

/* Force Inter font on navigation and page elements - override any Lichess fonts */
.navbar,
.navbar *,
.nav-brand,
.nav-menu,
.nav-link,
.breadcrumb,
.item-header,
.item-content,
.item-actions,
.footer {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Better defaults */
a { color: inherit; }
::selection { background: rgba(217, 119, 6, 0.18); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Navigation */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.chess-icon {
    font-size: 26px;
    line-height: 1;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0;
    align-items: center;
    height: 100%;
}

.nav-item {
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.nav-link:hover {
    color: var(--ink);
    background: rgba(0,0,0,0.03);
}

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

.nav-link.active::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}

/* Navigation Dropdown (Mega Menu) */
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 800px;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.nav-item:hover .nav-dropdown {
    display: block;
}

.nav-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.nav-dropdown-title-link {
    font-weight: 500;
    color: var(--ink);
    font-size: 0.9rem;
    margin-bottom: 0;
    display: block;
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
    background: var(--paper);
    text-align: center;
    border: 1px solid transparent;
}

.nav-dropdown-title-link:hover {
    background: #fff;
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    gap: 5px;
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
}

/* Hero */
.hero {
    padding: 60px 24px 48px;
    text-align: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    line-height: 1.1;
}

.hero p {
    font-size: 18px;
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    padding: 60px 24px 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.page-header h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}

.page-header p {
    font-size: 18px;
    color: var(--muted);
    max-width: 700px;
    margin: 0 auto;
}

/* Library Container */
.library-container {
    padding: 48px 0;
}

.library-section {
    margin-bottom: 64px;
}

.section-header {
    margin-bottom: 32px;
}

.section-header h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.section-description {
    color: var(--muted);
    font-size: 16px;
}

.category-block {
    margin-bottom: 48px;
}

.category-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    display: block;
    color: var(--ink);
}

.category-description {
    color: var(--muted);
    margin-bottom: 24px;
    font-size: 16px;
}

/* Lichess-style Card Grid for Subcategories */
.category-subs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.sub-block-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sub-block-link {
    text-decoration: none;
    display: block;
    color: inherit;
}

.sub-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0;
    display: flex;
    flex-direction: row; /* Horizontal layout */
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.sub-block:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0,0,0,0.1);
}

/* Icon Container */
.sub-icon-container {
    width: 80px;
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--muted);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    transition: all 0.2s;
}

.sub-block:hover .sub-icon-container {
    color: #fff;
}

/* Color Variants */
.sub-block.blue:hover .sub-icon-container { background: var(--card-blue); }
.sub-block.orange:hover .sub-icon-container { background: var(--card-orange); }
.sub-block.green:hover .sub-icon-container { background: var(--card-green); }
.sub-block.red:hover .sub-icon-container { background: var(--card-red); }
.sub-block.purple:hover .sub-icon-container { background: var(--card-purple); }
.sub-block.teal:hover .sub-icon-container { background: var(--card-teal); }

.sub-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.sub-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--ink);
    border-bottom: none;
    padding-bottom: 0;
}

.sub-description {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 12px;
    line-height: 1.5;
    flex-grow: 1;
}

.sub-meta {
    margin-top: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sub-block:hover .sub-meta {
    color: var(--accent);
}

.arrow {
    transition: transform 0.2s;
}

.sub-block:hover .arrow {
    transform: translateX(4px);
}

/* Subcategory Item Preview (below sub-block) */
.sub-items-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 4px;
}

.sub-item-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    font-size: 13px;
}

.sub-item-preview:hover {
    background: var(--paper);
    border-color: var(--accent);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.sub-item-thumb {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--paper);
}

.sub-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sub-item-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--paper);
    border-radius: var(--radius-sm);
}

.sub-item-title {
    flex: 1;
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-item-more {
    display: block;
    text-align: center;
    padding: 8px 12px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sub-item-more:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Items List Grid (Lichess-style) */
.items-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); /* Wider cards */
    gap: 20px;
    margin-top: 24px;
}

.item-block-link {
    text-decoration: none;
    display: block;
    height: 100%;
    color: inherit;
}

.item-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: row;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.item-block:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0,0,0,0.1);
}

.item-icon-container {
    width: 70px; /* Slightly smaller than sub */
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--muted);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    transition: all 0.2s;
}

.item-block:hover .item-icon-container {
    color: #fff;
}

/* Item Colors */
.item-block.blue:hover .item-icon-container { background: var(--card-blue); }
.item-block.red:hover .item-icon-container { background: var(--card-red); }
.item-block.purple:hover .item-icon-container { background: var(--card-purple); }
.item-block.orange:hover .item-icon-container { background: var(--card-orange); }
.item-block.green:hover .item-icon-container { background: var(--card-green); }
.item-block.teal:hover .item-icon-container { background: var(--card-teal); }
.item-block.yellow:hover .item-icon-container { background: #eab308; }

.item-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--ink);
}

.item-description {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 12px;
    line-height: 1.5;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-meta {
    margin-top: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.meta-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.meta-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-type-badge {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
    background: var(--paper);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.skill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.skill-beginner { background-color: #10b981; }
.skill-intermediate { background-color: #f59e0b; }
.skill-advanced { background-color: #ef4444; }
.skill-expert { background-color: #7f1d1d; }

.item-block:hover .arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* ===== Thumbnail Styles ===== */

/* Thumbnail on sub.php item blocks (side layout) */
.item-block .item-thumbnail-side {
    width: 160px;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #f6f6f6 0%, #e8e8e8 100%);
    position: relative;
}

.item-block .item-thumbnail-side::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.02) 100%);
    z-index: 2;
    pointer-events: none;
}

.item-block .item-thumbnail-side img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.item-block:hover .item-thumbnail-side img {
    transform: scale(1.08);
}

/* Thumbnail on index.php item cards (vertical layout) */
.item-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: rgba(0,0,0,0.12);
}

.item-card .item-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #f6f6f6 0%, #e8e8e8 100%);
    flex-shrink: 0;
    display: block;
    position: relative;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.item-card .item-thumbnail::before {
    content: '';
    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.02) 100%);
    z-index: 2;
    pointer-events: none;
}

.item-card .item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.item-card:hover .item-thumbnail img {
    transform: scale(1.08);
}

.item-card .item-icon {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, #f6f6f6 0%, #e8e8e8 100%);
    flex-shrink: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.item-card:hover .item-icon {
    opacity: 1;
}

.item-card .item-card-body {
    padding: 18px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-card .item-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--ink);
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.item-card .item-description {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    line-height: 1.6;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-card .item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

/* ===== Simple Rectangular Card Layout (sub.php) ===== */
.items-grid-wrapper {
    width: 100%;
    max-width: 1600px;
    margin: 32px auto 0 auto;
    padding: 0 40px;
    box-sizing: border-box;
}

.items-grid-simple {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    width: 100%;
}

.item-card-simple {
    text-decoration: none;
    color: inherit;
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
}

.item-card-simple::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.item-card-simple:hover {
    transform: translateY(-8px);
    border-color: rgba(0,0,0,0.15);
}

.item-card-simple:hover::before {
    opacity: 1;
}

.item-thumbnail-rect {
    width: 100%;
    height: 0;
    padding-bottom: 50%; /* 2:1 aspect ratio - wider rectangle */
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

.item-thumbnail-rect::after {
    content: '';
    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.03) 100%);
    pointer-events: none;
    z-index: 1;
}

.item-thumbnail-rect img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

.item-card-simple:hover .item-thumbnail-rect img {
    transform: scale(1.08);
}

.item-thumbnail-placeholder {
    background: linear-gradient(135deg, #f6f6f6 0%, #e8e8e8 100%);
    position: relative;
}

.item-thumbnail-placeholder i {
    font-size: 64px;
    color: var(--muted);
    opacity: 0.5;
    transition: all 0.3s ease;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.item-card-simple:hover .item-thumbnail-placeholder i {
    opacity: 0.8;
    transform: scale(1.1);
}

.item-title-simple {
    padding: 24px 20px;
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
    line-height: 1.5;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    position: relative;
    z-index: 2;
}

.item-card-simple:hover .item-title-simple {
    color: var(--accent);
}


@media (max-width: 1200px) {
    .items-grid-wrapper {
        max-width: 100%;
        padding: 0 24px;
    }
    
    .items-grid-simple {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }
}

@media (max-width: 768px) {
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }
    
    .item-card .item-thumbnail {
        height: 160px;
    }
    
    .items-grid-simple {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .item-thumbnail-rect {
        padding-bottom: 50%; /* Maintain 2:1 aspect ratio on mobile */
    }
    
    .item-title-simple {
        padding: 20px 16px;
        font-size: 16px;
        min-height: 56px;
    }
}

/* View Page */
.view-container {
    padding: 48px 0;
}

.view-container > .container {
    max-width: 95%;
    width: 100%;
    padding: 0 2%;
}

.view-container.has-chapters {
    padding: 0;
}

.view-container.has-chapters > .container {
    max-width: 100%;
    padding: 0;
}

@media (min-width: 1400px) {
    .view-container > .container {
        max-width: 1600px;
        padding: 0 40px;
    }
    
    .view-container.has-chapters > .container {
        max-width: 100%;
        padding: 0;
    }
}

.breadcrumb {
    margin-bottom: 32px;
    color: var(--muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: var(--ink);
}

.item-view {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 48px;
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin: 0 auto;
    overflow: hidden;
}

@media (min-width: 1200px) {
    .item-view {
        padding: 64px;
    }
}

@media (min-width: 1600px) {
    .item-view {
        padding: 80px;
    }
}

/* Thumbnail banner on the view page */
.item-view-thumbnail {
    margin: -48px -48px 32px -48px;
    height: 280px;
    overflow: hidden;
    background: var(--paper);
}

.item-view-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-header {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
    align-items: flex-start;
}

.item-icon-large {
    font-size: 56px;
    line-height: 1;
}

.item-header-content h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
    line-height: 1.2;
}

.item-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
    color: var(--muted);
}

.item-type-badge {
    padding: 6px 12px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
    border-radius: 999px;
}

.item-content {
    border-top: 1px solid var(--border);
    padding-top: 32px;
    margin: 32px 0;
    line-height: 1.8;
    font-size: 16px;
}

/* Markdown Content Styles */
.markdown-content {
    color: var(--ink);
}

.markdown-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: var(--ink);
}

.markdown-content h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
    color: var(--ink);
}

.markdown-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    color: var(--ink);
}

.markdown-content p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

/* Prevent chessboard from being affected by paragraph styles */
.markdown-content p .chess-board-container,
.markdown-content .chess-board-container {
    margin-bottom: 0;
    display: block;
}

/* Ensure chessboard is never inside a paragraph */
.markdown-content p:has(.chess-board-container) {
    display: contents;
}

/* Fallback for browsers that don't support :has() */
.markdown-content .chess-board-container {
    display: block;
    margin: 2rem auto;
}

.markdown-content ul,
.markdown-content ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
}

.markdown-content li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.markdown-content code {
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

.markdown-content pre {
    background: var(--surface-2);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--border);
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: var(--ink);
}

.markdown-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--muted);
    font-style: italic;
}

.markdown-content a {
    color: var(--accent);
    text-decoration: underline;
}

.markdown-content a:hover {
    color: var(--accent-ink);
}

.markdown-content hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2rem 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
}

/* Chess board in markdown - MINIMAL CSS, let chessboard.js handle everything */
.markdown-content .chess-board-container {
    margin: 2rem auto;
    clear: both;
    width: 100%;
    max-width: 600px;
}

/* Only ensure board wrapper doesn't get affected by markdown text styles */
.markdown-content .board-wrapper {
    display: block;
    clear: both;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Ensure board element maintains 600px size - override any other styles */
.markdown-content .board-wrapper > div[id^="board-"] {
    width: 600px !important;
    height: 600px !important;
    min-width: 600px !important;
    min-height: 600px !important;
    max-width: 600px !important;
    max-height: 600px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

/* CRITICAL: Reset markdown img styles for chess piece images */
/* chessboard.js uses <img> for pieces - they must NOT inherit markdown styles */
.markdown-content .chess-board-container img,
.markdown-content .board-wrapper img {
    max-width: none !important;
    height: auto !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline !important;
}

/* NO CSS for board element or internal structure - let chessboard.js handle it */

.item-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 32px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    cursor: pointer;
    border: 2px solid var(--ink);
    border-radius: 6px;
}

.btn-primary {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.btn-primary:hover {
    background: transparent;
    color: var(--ink);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--ink);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Skill Level Badges */
.skill-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 4px;
}

.skill-badge.skill-beginner {
    background: #d1fae5;
    color: #065f46;
}

.skill-badge.skill-intermediate {
    background: #fef3c7;
    color: #92400e;
}

.skill-badge.skill-advanced {
    background: #fed7aa;
    color: #7c2d12;
}

.skill-badge.skill-expert {
    background: #fecaca;
    color: #991b1b;
}

.premium-badge {
    padding: 4px 10px;
    background: #fbbf24;
    color: #78350f;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 4px;
}

.content-note {
    color: var(--accent);
    font-weight: 500;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    margin: 0 auto;
    max-width: 600px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
    display: block;
}

.no-items, .no-subs, .no-categories, .no-content {
    color: var(--muted);
    font-style: italic;
    padding: 16px 0;
}

/* Footer */
.footer {
    background: var(--ink);
    color: rgba(255, 255, 255, 0.7);
    padding: 40px 24px;
    text-align: center;
    margin-top: 80px;
    border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 1024px) {
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .category-subs-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .nav-dropdown {
        left: 0;
        transform: none;
        width: 100%;
        max-width: none;
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: 0 0 0 16px;
        display: none !important;
    }
}

@media (max-width: 768px) {
    .navbar .container {
        height: auto;
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 60px;
        flex-direction: column;
        background: #fff;
        width: 100%;
        height: calc(100vh - 60px);
        text-align: left;
        transition: left 0.3s;
        border-bottom: 1px solid var(--border);
        padding: 24px;
        gap: 0;
        align-items: flex-start;
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }
    
    .nav-item {
        height: auto;
        width: 100%;
        display: block;
    }
    
    .nav-link {
        height: auto;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }
    
    .nav-link.active::after {
        display: none;
    }

    .nav-toggle {
        display: flex;
    }

    .hero h1 {
        font-size: 32px;
    }

    .hero p {
        font-size: 17px;
    }

    .page-header h1 {
        font-size: 32px;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .items-list-grid {
        grid-template-columns: 1fr;
    }

    .item-view {
        padding: 32px 24px;
    }
    
    /* On tablets, allow board to be responsive but maintain minimum size */
    .markdown-content .chess-board-container {
        min-width: 500px;
        max-width: 100%;
    }
    
    .markdown-content .board-wrapper {
        min-width: 500px;
        max-width: 100%;
    }
    
    .markdown-content .board-wrapper > div[id^="board-"] {
        min-width: 500px !important;
        min-height: 500px !important;
        width: 100% !important;
        max-width: 500px !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
    }

    .item-header {
        flex-direction: column;
    }

    .item-header-content h1 {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 28px;
    }

    .category-title {
        font-size: 20px;
    }

    .btn {
        width: 100%;
        text-align: center;
    }
}

/* Lichess-style Chapter Navigation */
.article-with-chapters {
    display: grid;
    grid-template-columns: 260px 1fr 400px;
    gap: 0;
    background: var(--surface);
    border: none;
    border-radius: 0;
    overflow: visible;
    min-height: 600px;
    box-shadow: none;
}

.chapter-sidebar {
    background: var(--paper);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    padding: 0;
}

.chapter-sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--paper);
    position: sticky;
    top: 0;
    z-index: 10;
}

.chapter-header-info {
    margin-bottom: 4px;
}

.chapter-count {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chapter-sidebar-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
}

.chapter-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chapter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-list li {
    margin: 0;
}

.chapter-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--ink);
    transition: background-color 0.1s ease;
    font-size: 13px;
    line-height: 1.4;
    border-left: none;
}

.chapter-list a:hover {
    background: rgba(0, 0, 0, 0.04);
}

.chapter-list li.active a {
    background: #3b82f6;
    color: white;
    font-weight: 500;
}

.chapter-name {
    display: block;
    flex: 1;
}

.chapter-number {
    display: inline-block;
    min-width: 18px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    color: inherit;
}

.chapter-list li.active .chapter-number {
    color: white;
    font-weight: 600;
}

.chapter-board {
    background: var(--paper);
    padding: 24px;
    overflow-x: hidden;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border-right: 1px solid var(--border);
    min-height: calc(100vh - 64px);
    padding-top: 32px;
}

.chapter-board .chess-board-container {
    margin: 0;
    max-width: 100%;
    width: 100%;
}

.chapter-board .board-wrapper {
    max-width: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
}

.chapter-board .board-wrapper > div[id^="board-"] {
    width: 100% !important;
    max-width: 500px !important;
    height: auto !important;
    aspect-ratio: 1;
    margin: 0 auto;
}

.chapter-main {
    background: var(--paper);
    padding: 40px 48px;
    overflow-x: hidden;
    position: relative;
    overflow-y: auto;
    max-height: calc(100vh - 64px);
    height: calc(100vh - 64px);
    box-sizing: border-box;
}

@media (min-width: 1200px) {
    .chapter-main {
        padding: 32px 48px;
    }
    
    .chapter-board {
        padding: 32px;
    }
}

@media (min-width: 1600px) {
    .chapter-main {
        padding: 40px 64px;
    }
    
    .chapter-board {
        padding: 40px;
    }
}

.chapter-content {
    max-width: 100%;
    margin: 0;
}

.chapter-header {
    margin-bottom: 24px;
    padding-bottom: 0;
    border-bottom: none;
}

.chapter-header h1 {
    margin: 0 0 24px 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.chapter-main .item-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--ink);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.chapter-main .item-content h2 {
    margin-top: 32px;
    margin-bottom: 16px;
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.chapter-main .item-content h3 {
    margin-top: 28px;
    margin-bottom: 12px;
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.4;
    letter-spacing: -0.005em;
}

.chapter-main .item-content p {
    margin-bottom: 20px;
    color: var(--ink);
    font-weight: 400;
}

.chapter-main .item-content p:first-of-type {
    margin-top: 0;
}

.chapter-main .item-content ul,
.chapter-main .item-content ol {
    margin-bottom: 20px;
    padding-left: 24px;
}

.chapter-main .item-content li {
    margin-bottom: 8px;
    line-height: 1.7;
}

.chapter-nav-footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    gap: 8px;
}

.chapter-nav-footer .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.chapter-nav-footer .btn-secondary {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.chapter-nav-footer .btn-secondary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.chapter-nav-footer .btn-primary {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.chapter-nav-footer .btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

@media (max-width: 1024px) {
    .article-with-chapters {
        grid-template-columns: 240px 1fr 350px;
    }
    
    .chapter-main {
        padding: 24px 32px;
    }
    
    .chapter-board {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .article-with-chapters {
        grid-template-columns: 1fr;
    }
    
    .chapter-sidebar {
        position: relative;
        top: 0;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .chapter-sidebar-header {
        padding: 12px 16px;
    }
    
    .chapter-sidebar-header h2 {
        font-size: 14px;
    }
    
    .chapter-board {
        min-height: auto;
        padding: 24px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .chapter-board .board-wrapper > div[id^="board-"] {
        max-width: 100% !important;
    }
    
    .chapter-main {
        padding: 20px 24px;
        max-height: none;
    }
    
    .chapter-content {
        max-width: 100%;
    }
    
    .chapter-header {
        margin-bottom: 20px;
    }
    
    .chapter-header h1 {
        font-size: 22px;
    }
    
    .chapter-main .item-content {
        font-size: 15px;
        line-height: 1.75;
    }
    
    .chapter-main .item-content h2 {
        font-size: 20px;
        margin-top: 28px;
        margin-bottom: 14px;
    }
    
    .chapter-main .item-content h3 {
        font-size: 18px;
        margin-top: 24px;
        margin-bottom: 10px;
    }
    
    .chapter-nav-footer {
        flex-direction: column;
        margin-top: 24px;
        padding-top: 16px;
    }
    
    .chapter-nav-footer .btn {
        width: 100%;
        justify-content: center;
    }
    
    .chapter-list a {
        padding: 8px 14px;
    }
}
