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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    color: #2c2c2c;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #3a3a3a 0%, #5a5a5a 100%);
    color: #ffffff;
    padding: 60px 0;
    margin-bottom: 50px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.header-text {
    flex: 1;
}

header h1 {
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: -1px;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.home-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 1rem;
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    transition: background 0.2s, border-color 0.2s;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    margin-bottom: 60px;
}

/* Sidebar */
.sidebar {
    background: #f8f8f8;
    padding: 25px;
    border-radius: 8px;
    height: fit-content;
    position: sticky;
    top: 20px;
    border: 1px solid #e5e5e5;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #3a3a3a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hierarchy Tree */
.hierarchy-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hierarchy-tree ul {
    list-style: none;
    padding-left: 16px;
    margin: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.hierarchy-tree ul.collapsed {
    max-height: 0;
}

.hierarchy-tree ul.expanded {
    max-height: 1000px;
}

.hierarchy-tree li {
    margin-bottom: 4px;
}

.tree-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #3a3a3a;
    padding: 6px 0;
    width: 100%;
    text-align: left;
    transition: color 0.2s;
}

.tree-toggle:hover {
    color: #5a5a5a;
}

.tree-toggle .arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #5a5a5a;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.tree-toggle.collapsed .arrow {
    transform: rotate(-90deg);
}

.tree-page-link {
    display: block;
    color: #5a5a5a;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 5px 0 5px 16px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    line-height: 1.4;
}

.tree-page-link:hover {
    background: #e5e5e5;
    color: #2c2c2c;
}

.tree-page-link.active {
    background: #3a3a3a;
    color: #ffffff;
}

/* Search */
.search-section {
    margin-bottom: 40px;
}

.search-bar {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.05rem;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    background: white;
    color: #2c2c2c;
    transition: border-color 0.2s;
}

.search-bar:focus {
    outline: none;
    border-color: #5a5a5a;
}

.search-bar::placeholder {
    color: #9a9a9a;
}

/* Content Area */
.content-area {
    min-height: 400px;
}

/* Topic Cards */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

.topic-card {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.topic-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.topic-info {
    padding: 24px;
}

.topic-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5a5a5a;
    margin-bottom: 10px;
}

.topic-title {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: #2c2c2c;
    line-height: 1.3;
}

.topic-description {
    font-size: 0.95rem;
    color: #5a5a5a;
    line-height: 1.6;
    margin-bottom: 16px;
}

.topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: #f0f0f0;
    color: #4a4a4a;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #7a7a7a;
    font-size: 1.1rem;
}

/* Footer */
footer {
    background: #f8f8f8;
    padding: 40px 0;
    margin-top: 60px;
    border-top: 1px solid #e5e5e5;
    text-align: center;
    color: #7a7a7a;
    font-size: 0.9rem;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* Responsive */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
        margin-bottom: 30px;
    }

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

@media (max-width: 768px) {
    .header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .topic-grid {
        grid-template-columns: 1fr;
    }
}
