:root {
    --primary-color: #1a1a1a;
    --primary-dark: #000000;
    --primary-light: #333333;
    --success-color: #2d6a4f;
    --accent-color: #d4a574;
    --bg-color: #f5f1e8;
    --bg-secondary: #faf8f3;
    --sidebar-bg: #ffffff;
    --content-bg: #faf8f3;
    --card-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e8e4db;
    --hover-bg: #f0ebe0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
    --glow: 0 0 0 2px rgba(26, 26, 26, 0.1);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 100px;
}

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

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 3rem 2rem 2rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--sidebar-bg);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    margin-bottom: 2rem;
    transition: all 0.2s ease;
}

.sidebar-header h1:hover {
    color: var(--text-secondary);
}

/* Progress Circle */
.progress-summary {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.progress-circle {
    width: 90px;
    height: 90px;
}

.circular-chart {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: #e8e4db;
    stroke-width: 2.5;
}

.circle {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 2.5;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
}

.percentage {
    fill: var(--text-primary);
    font-size: 0.5rem;
    font-weight: 600;
    text-anchor: middle;
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Navigation */
.section-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

.section-item {
    margin-bottom: 0.75rem;
}

.section-header {
    padding: 0.875rem 1.125rem;
    margin: 0 0.75rem 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
}

.section-header:hover {
    background: var(--hover-bg);
    border-color: var(--border-color);
}

.section-header.completed {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.section-header.active-section {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.section-header.active-section .section-number {
    background-color: white;
    color: var(--primary-color);
}

.section-header.active-section .section-progress,
.section-header.active-section .expand-icon {
    color: rgba(255, 255, 255, 0.85);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.section-title-text {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.section-title-text:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: translateX(2px);
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.section-header.completed .section-number {
    background: var(--success-color);
}

.expand-icon {
    transition: transform 0.3s;
    color: var(--text-secondary);
}

.section-header.expanded .expand-icon {
    transform: rotate(90deg);
}

.section-progress {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.topic-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: transparent;
    padding: 0 0.5rem;
}

.topic-list.expanded {
    max-height: 2000px;
    padding: 0.5rem 0.5rem 0.75rem 0.5rem;
}

.topic-item {
    padding: 0.625rem 1rem;
    margin: 0.25rem 0.75rem 0.25rem 2.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    position: relative;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    width: fit-content;
    max-width: calc(100% - 3.25rem);
}

.topic-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.topic-item.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.topic-item.completed {
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--text-muted);
    opacity: 0.5;
}

.topic-item.completed:hover {
    opacity: 0.7;
}

.topic-checkbox {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.topic-checkbox:hover {
    border-color: var(--primary-color);
}

.topic-item.completed .topic-checkbox {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.topic-item.completed .topic-checkbox::after {
    content: '✓';
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    padding: 2rem 3rem;
    background: var(--content-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.breadcrumb {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb-link {
    color: var(--primary-light);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.breadcrumb-link:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-weight: 400;
}

.breadcrumb-section {
    color: var(--text-secondary);
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

.btn-icon {
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.study-content {
    flex: 1;
    padding: 3rem 4rem;
    overflow-y: auto;
    background-color: var(--content-bg);
    max-width: 900px;
}

/* Welcome Screen */
.welcome {
    max-width: 900px;
    padding: 2rem 0;
}

.welcome h2 {
    font-size: 3rem;
    font-weight: 600;
    letter-spacing: -1.2px;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    line-height: 1.15;
}

.welcome > p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 4rem;
    line-height: 1.7;
}

.features {
    display: grid;
    gap: 1.5rem;
}

.feature {
    display: flex;
    gap: 1.5rem;
    align-items: start;
    padding: 2rem;
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.feature:hover {
    box-shadow: var(--shadow);
    border-color: var(--text-muted);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.feature h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.feature p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Markdown Content Styling */
.study-content h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.8px;
    margin-bottom: 2rem;
    color: var(--text-primary);
    border-bottom: none;
    padding-bottom: 0;
    line-height: 1.2;
}

.study-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.4px;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.study-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.study-content h4 {
    font-size: 1.0625rem;
    font-weight: 500;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.study-content p {
    margin-bottom: 1.25rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.study-content ul, .study-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
    line-height: 1.7;
}

.study-content li {
    margin-bottom: 0.625rem;
    color: var(--text-secondary);
}

.study-content code {
    background: #f5f2ed;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.study-content pre {
    background: #faf8f3;
    color: var(--text-primary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.study-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    border: none;
}

.study-content blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.study-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.study-content th,
.study-content td {
    padding: 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.study-content th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.study-content td {
    color: var(--text-secondary);
}

.study-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.study-content a:hover {
    border-bottom-color: var(--primary-color);
}

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

/* Notes Panel */
.notes-panel {
    width: 0;
    background: white;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
}

.notes-panel.open {
    width: 380px;
}

.notes-header {
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notes-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notes-info {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background-color: var(--hover-bg);
}

.notes-textarea {
    flex: 1;
    padding: 1.5rem;
    border: none;
    resize: none;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.6;
}

.notes-textarea:focus {
    outline: none;
}

.btn-primary {
    margin: 1rem 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-full);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Topic Footer */
.topic-footer {
    padding: 1rem 3rem;
    background: var(--content-bg);
    border-top: 1px solid var(--border-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary-color);
    border-radius: 2px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }

    .study-content {
        padding: 1.5rem;
    }

    .content-header {
        padding: 1rem 1.5rem;
    }

    .notes-panel.open {
        width: 100%;
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 10;
        box-shadow: var(--shadow-lg);
    }
}
