:root {
    --bg-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #333333;
    --primary-color: #1a73e8;
    --accent-color: #e8f0fe;
    --border-color: #dee2e6;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --font-base: 16px;
    --header-height: 64px;
    --sidebar-width: 280px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark-mode {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #e9ecef;
    --primary-color: #8ab4f8;
    --accent-color: #2d2e31;
    --border-color: #343a40;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: var(--font-base);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    min-height: 100vh;
}

/* AppBar */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--surface-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow);
    z-index: 1100;
}

.app-bar-left,
.app-bar-right {
    display: flex;
    align-items: center;
}

.app-bar-left {
    gap: 12px;
}

.app-bar-right {
    gap: 8px;
}

.app-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--primary-color);
}

/* Icons and Buttons */
.icon-button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-button:hover {
    background-color: var(--accent-color);
}

.back-button {
    background-color: var(--primary-color) !important;
    /* Celeste */
    color: #ffffff !important;
    text-decoration: none !important;
}

.back-button:hover {
    background-color: #0099cc !important;
}

.font-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.font-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.body.dark-mode .font-button {
    color: var(--text-color);
}

.font-button:hover {
    background-color: var(--primary-color);
    color: #ffffff !important;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--surface-color);
    transition: var(--transition);
    padding-top: var(--header-height);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    pointer-events: none;
    opacity: 0;
}

.sidebar.open {
    left: 0;
    opacity: 1;
    pointer-events: all;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 24px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: var(--text-color);
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--accent-color);
    color: var(--primary-color);
}

.sidebar-footer {
    margin-top: auto;
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-footer a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.6;
}

.sidebar-footer a:hover {
    opacity: 1;
    color: var(--primary-color);
}

/* Main Content Area */
.content-area {
    margin-top: var(--header-height);
    padding: 0 16px 16px 16px;
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.content-header {
    text-align: center;
    margin-bottom: 10px;
    width: 100%;
    max-width: 900px;
}

.class-title-display {
    font-size: 1.4rem;
    /* Match app-bar title */
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.subject-name {
    color: var(--primary-color);
}

.title-separator {
    opacity: 0.5;
    font-weight: 400;
}

.welcome-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    margin-top: 0;
    width: 100%;
}

.card {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    aspect-ratio: 1 / 1;
}

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

.card .material-icons,
.card i {
    font-size: 3rem;
    color: var(--primary-color);
}

.card h3 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 600;
}

.card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.02);
}

.card.disabled:hover {
    transform: none;
}

.breadcrumb {
    align-self: flex-start;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.subject-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    z-index: 1150;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Responsiveness */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }

    .card {
        padding: 24px 16px;
    }

    .card .material-icons {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.2rem;
    }

    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .card {
        padding: 16px;
    }

    .card .material-icons,
    .card i {
        font-size: 2.2rem;
    }

    .content-area {
        padding: 12px;
    }
}