:root {
    /* Premium Dark Theme Colors */
    --bg-base: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-blue-hover: #0ea5e9;
    --accent-pink: #f472b6;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(15, 23, 42, 0.4);

    /* Variables */
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* Background Atmosphere Particles */
.glass-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: drift 20s infinite alternate;
}

.pink-sphere {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, rgba(244, 114, 182, 0.1) 100%);
    top: -10%;
    left: -10%;
}

.blue-sphere {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.2) 0%, rgba(56, 189, 248, 0.1) 100%);
    bottom: -20%;
    right: -10%;
    animation-delay: -5s;
}

.purple-sphere {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.2) 0%, rgba(139, 92, 246, 0) 100%);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* App Container */
.app-container {
    width: 95vw;
    height: 90vh;
    max-width: 1400px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-area h1 span {
    color: var(--accent-blue);
}

.logo-area p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Category Tabs (Top Right) */
.category-tabs {
    display: flex;
    gap: 12px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--accent-blue);
    color: var(--bg-base);
    border-color: var(--accent-blue);
}

/* Main Layout */
.app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar (Tree List) */
.sidebar {
    width: 340px;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
}

.search-box {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    background: rgba(0, 0, 0, 0.1);
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.05);
}

.search-box svg {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.topic-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Tree Structure styling */
.subject-group {
    margin-bottom: 8px;
}

.subject-header {
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    user-select: none;
    border: 1px solid transparent;
}

.subject-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.subject-header span.toggle-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.subject-group.collapsed .subject-header span.toggle-icon {
    transform: rotate(-90deg);
}

.subject-group.collapsed .topic-items-container {
    display: none;
}

.topic-items-container {
    padding-left: 12px;
    padding-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    margin-left: 16px;
}

.topic-item {
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
}

.topic-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

.topic-item.active {
    color: var(--accent-blue);
    font-weight: 600;
}

.topic-item.active::before {
    content: '';
    position: absolute;
    left: -13px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--accent-blue);
    border-radius: 4px;
}

/* Topic Viewer Area */
.topic-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
    scroll-behavior: smooth;
}

.topic-viewer::-webkit-scrollbar,
.topic-list::-webkit-scrollbar {
    width: 6px;
}

.topic-viewer::-webkit-scrollbar-track,
.topic-list::-webkit-scrollbar-track {
    background: transparent;
}

.topic-viewer::-webkit-scrollbar-thumb,
.topic-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.topic-viewer::-webkit-scrollbar-thumb:hover,
.topic-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-state h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.5);
}

/* Viewer Content Elements */
.content-header {
    margin-bottom: 32px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--accent-pink);
    margin-bottom: 8px;
    font-weight: 600;
}

.content-header h2 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--glass-border);
}

.badge {
    padding: 4px 12px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.theory-section {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--glass-border);
    margin-bottom: 40px;
    line-height: 1.8;
    font-size: 15px;
}

.theory-section p {
    margin-bottom: 16px;
}

.theory-section p:last-child {
    margin-bottom: 0;
}

.theory-section strong {
    color: var(--accent-blue);
}

.theory-section ul {
    margin-left: 20px;
    margin-bottom: 16px;
}

.theory-section li {
    margin-bottom: 8px;
}

.problems-heading {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.problems-heading::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--accent-pink);
    border-radius: 2px;
}

.problems-section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.problem-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: var(--border-radius-md);
    transition: var(--transition);
}

.problem-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.pc-meta {
    font-size: 12px;
    color: var(--accent-pink);
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.pc-desc {
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.6;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    .app-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
    }

    .logo-area h1 {
        font-size: 18px;
    }

    .logo-area p {
        display: none;
        /* Hide subtitle on mobile to save vertical space */
    }

    .category-tabs {
        width: auto;
        gap: 8px;
    }

    .tab-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .app-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 200px;
        /* Reduced from 250px to provide more content room */
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .topic-list {
        padding: 8px;
    }

    .topic-viewer {
        flex: 1;
        padding: 16px;
    }

    .content-header h2 {
        font-size: 24px;
    }

    .problems-section {
        grid-template-columns: 1fr;
    }
}