:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --card-radius: 16px;
}

/* Dark Mode Support (Basic) */
/* Dark Mode Support */
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    --glass-bg: rgba(31, 41, 55, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
}

/* Smooth Transition */
body,
.glass,
button,
input,
select,
textarea {
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

/* Theme Toggle Button */
#btn-theme-toggle {
    font-size: 1.2rem;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#btn-theme-toggle:hover svg {
    transform: rotate(15deg) scale(1.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container {
    flex: 1;
    /* Pushes footer to the bottom */
    width: 100%;
    max-width: 800px;
    /* Restored compact size */
    margin: 0 auto;
    padding: 1rem;
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    position: sticky;
    top: 10px;
    z-index: 100;
}

.logo {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-controls {
    display: flex;
    align-items: center;
}

/* Mobile Styles (Phones Only) */
@media (max-width: 640px) {
    .navbar {
        flex-direction: row;
        /* Horizontal */
        padding: 0.8rem 0.5rem;
        /* Reduced horizontal padding */
        padding-top: max(0.8rem, env(safe-area-inset-top));
        /* Handle Notch */
        align-items: center;
        /* Vertically align */
        justify-content: space-between;
        /* Logo Left, Icons Right */
        gap: 0.2rem;
        /* Min Gap */
    }

    .nav-right {
        display: flex;
        /* Ensure flex behavior */
        justify-content: flex-end;
        align-items: center;
        flex: 1;
        /* Take all remaining space */
    }

    .nav-links {
        display: flex;
        position: static;
        width: auto;
        padding: 0;
        margin-left: auto;
        /* Force to right side */
        align-items: center;

        justify-content: flex-end;
        /* Icons to the right */
        gap: 0.3rem;
        /* Ultra tight grouping */
    }

    .nav-links .nav-btn {
        width: auto;
        padding: 4px;
        justify-content: center;
    }

    /* Stack only responsive rows (Study Time) on mobile */
    /* Stack only responsive rows (Study Time) on mobile */
    .responsive-row {
        flex-direction: column;
        gap: 0.2rem;
        /* Tight gap */
        margin-bottom: 1rem;
    }

    .responsive-row .form-group {
        margin-bottom: 0;
        /* Remove margin so gap controls spacing */
    }

    /* Mixed Row (Priority/Strength | Mood) on mobile */
    .mixed-row {
        flex-wrap: wrap;
        /* Allow grouping */
        gap: 0.5rem;
        margin-bottom: 1rem;
        /* Restore gap to button */
    }

    .mixed-row .form-group:nth-child(1),
    .mixed-row .form-group:nth-child(2) {
        flex: 1 1 45%;
        /* Share top row */
        margin-bottom: 0;
    }

    .mixed-row .form-group:nth-child(3) {
        flex: 1 1 100%;
        /* Mood takes full bottom row */
        margin-bottom: 0;
    }



    /* Reduce margins on mobile for tighter fit */
    .form-group {
        margin-bottom: 0.8rem;
    }



    .nav-links .nav-btn span {
        display: none;
        /* Hide Text on Mobile */
    }

    /* Ensure icons are big enough to tap */
    .nav-links .nav-btn svg {
        width: 24px;
        height: 24px;
    }

    .nav-controls {
        display: none;
        /* Just in case */
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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




.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s;
    /* Flex for Icon+Text */
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn.active {
    color: var(--primary);
    font-weight: 700;
}

/* Common Components */
.card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

#section-profile .card {
    padding-top: 1rem;
    /* Move text up */
}

#section-profile .card h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    /* Tighten gap between title and form */
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 0.95rem 1.5rem;
    /* Increased from 0.75rem */
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--primary);
    /* Blue (Same as Save) */
    border: none;
    color: white;
    padding: 0.95rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    width: 100%;
    transition: transform 0.2s, background 0.2s;
}

.btn-secondary:hover {
    background: var(--primary-hover);
    /* Match Save Button Hover */
    transform: translateY(-2px);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}



input,
select {
    width: 100%;
    /* Shared styles continue below */
    padding: 0.8rem;
    border-radius: 10px;
    width: 100%;
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    /* Gray border for visibility */
    background: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.9);
    /* More opaque by default for readability */
    color: #1f2937;
    /* Always dark text on light background */
    font-size: 1rem;
    transition: all 0.2s;
}

select,
input[type="time"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    /* Space for the arrow */
    background-color: rgba(255, 255, 255, 0.9);
    /* Ensure bg color is kept */
}

/* Hide default calendar indicator to use custom arrow */
input[type="time"]::-webkit-calendar-picker-indicator {
    background: transparent;
    color: transparent;
    cursor: pointer;
}

input:focus,
select:focus {
    outline: none;
    border-color: #9ca3af;
    /* Gray Focus Border */
    background: white;
    color: #1f2937;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
    /* Gray Glow */
    accent-color: #6b7280;
    /* Gray Picker Color */
}

/* Sections */
/* ... (existing sections logic, skipped in this replace block for brevity if I could, but I need to clear the old media query) ... */
/* Actually, I need to remove the OLD media query block and append the NEW one at the end. 
   Since `replace_file_content` works on contiguous blocks, I have to be careful.
   The old media query was around line 168.
   I will Remove it here by replacing the block that contained it with just the standard styles.
*/


/* Sections */
.hidden {
    display: none;
}

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

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

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

/* Dashboard */
.header-section h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

canvas {
    max-width: 100%;
}

/* Timetable Grid */
.timetable-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slot-card {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-left: 5px solid var(--primary);
    transition: transform 0.2s;
}

.slot-card:hover {
    transform: scale(1.02);
}

.slot-time {
    font-weight: 700;
    margin-right: 1.5rem;
    min-width: 80px;
    font-size: 0.9rem;
}

.slot-content h4 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.slot-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.slot-break {
    background: rgba(0, 0, 0, 0.03);
    border-left-color: #9ca3af;
    opacity: 0.7;
}

/* Mobile Tweaks */
@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Subject List */
.subject-item {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.subject-name {
    font-weight: 600;
}

.subject-tags span {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    margin-left: 5px;
}

/* --- New Timetable Styles --- */
.table-container-scroll {
    overflow-x: auto;
    border-radius: var(--card-radius);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
}

.timetable-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.timetable-table th,
.timetable-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.timetable-table th {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.timetable-table td {
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.timetable-table td:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Slot Styling inside cell */
.slot-cell-content {
    display: flex;
    flex-direction: column;
}

.slot-cell-subject {
    font-weight: 600;
}

.slot-cell-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cell-break {
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-muted);
    font-style: italic;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    background: white;
    /* fallback */
    background: var(--glass-bg);
    padding: 2rem;
    border-radius: var(--card-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Subject List Styles */
#subject-list {
    margin-top: 1rem;
    /* Reduced from 2rem */
}

.subject-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    /* Match input border */
    margin-bottom: 0.8rem;
    transition: transform 0.2s;
}

.subject-item:hover {
    transform: translateY(-2px);
}

.subject-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.subject-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.subject-tags span {
    font-size: 0.75rem;
    /* Reduced from 0.85rem */
    padding: 0.3rem 0.6rem;
    /* Reduced padding */
    border-radius: 6px;
    font-weight: 500;
}

/* Tag Specific Colors (Optional enhancement) */
.subject-tags span:nth-child(1) {
    background: #e0e7ff;
    color: #4338ca;
}

/* Priority */
.subject-tags span:nth-child(2) {
    background: #dbeafe;
    color: #1e40af;
}

/* Strength */
.subject-tags span:nth-child(3) {
    background: #fae8ff;
    color: #86198f;
}

/* Mobile-Specific Subject List Tweaks */
@media (max-width: 600px) {
    .subject-item {
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: flex-start;
        padding-bottom: 1rem;
    }

    /* Name takes most space, but leaves room for buttons */
    .subject-name {
        flex: 1 1 70%;
        order: 1;
    }

    /* Buttons go to the right of Name */
    .subject-item>div:last-child {
        flex: 0 0 auto;
        order: 2;
    }

    /* Tags drop to the next line */
    .subject-tags {
        flex: 1 1 100%;
        order: 3;
        margin-top: 0.2rem;
        gap: 0.4rem;
    }

    /* Ensure tags are slightly smaller on mobile to fit */
    .subject-tags span {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Enforce consistent borders in Dark Mode */
[data-theme="dark"] .subject-item,
[data-theme="dark"] input,
[data-theme="dark"] select {
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Softer white border for dark mode */
}


/* Mood */