:root {
    --color-not-studied: #e0e0e0;
    --color-studied: #2e7d32;
    --min-column-width: 120px;
    --max-columns-per-row: 12;
    --primary-color: #1976d2;
    --hover-color: #1565c0;
    --active-color: #0d47a1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

.top-nav {
    background-color: white;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-nav a {
    color: #333;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.top-nav a:hover {
    background-color: #f5f5f5;
    color: var(--primary-color);
}

.top-nav a.active {
    background-color: var(--primary-color);
    color: white;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1 {
    color: #333;
    margin-bottom: 2rem;
}

/* Heatmap Grid Styles */
.heatmap-grid {
    display: grid;
    gap: 12px;
    background: #ffffff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    grid-auto-flow: column;
    grid-auto-columns: minmax(var(--min-column-width), 1fr);
}

.subject-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    min-width: var(--min-column-width);
}

.subject-header {
    padding: 12px 8px;
    background: #f8f9fa;
    font-weight: bold;
    text-align: center;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1em;
    position: relative;
}

.subject-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, 
        var(--color-studied) 0%, 
        var(--color-studied) var(--completion), 
        var(--color-not-studied) var(--completion), 
        var(--color-not-studied) 100%);
    opacity: 0.2;
    z-index: 0;
}

.subject-header span {
    position: relative;
    z-index: 1;
}

.topics-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topic-cell {
    flex: 1;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    min-height: 55px;
    word-break: break-word;
    font-size: 0.95em;
    position: relative;
    overflow: hidden;
    background-color: white;
}

.topic-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, 
        var(--color-studied) 0%, 
        var(--color-studied) var(--completion), 
        var(--color-not-studied) var(--completion), 
        var(--color-not-studied) 100%);
    opacity: 0.2;
    z-index: 0;
}

.topic-cell > * {
    position: relative;
    z-index: 1;
}

.topic-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Modal Styles */
.detail-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
}

.detail-modal.active {
    display: block;
}

.detail-modal p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.5;
}

.detail-modal .time-info {
    color: #555;
    font-weight: 500;
}

.detail-modal .time-value {
    color: var(--primary-color);
    font-weight: bold;
}

.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.modal-backdrop.active {
    display: block;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.view-works-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.view-works-btn:hover {
    background-color: #45a049;
}

.time-usage-chart {
    width: 100%;
    height: 150px;
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --min-column-width: 100px;
    }
    
    .container {
        padding: 10px;
        margin: 1rem auto;
    }
    
    .heatmap-grid {
        padding: 10px;
        gap: 10px;
    }

    .top-nav {
        padding: 0.5rem;
        gap: 1rem;
    }

    .top-nav a {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}
