:root {
    --bg: hsl(220 20% 98%);
    --surface: hsl(0 0% 100%);
    --surface2: hsl(220 18% 96%);
    --text: hsl(220 18% 16%);
    --muted: hsl(220 10% 45%);
    --border: hsl(220 14% 86%);
    --accent: hsl(222 84% 55%);
    --accent2: hsl(222 84% 45%);
    --shadow: 0 12px 30px hsla(220, 18%, 12%, 0.10);
    --shadow2: 0 6px 18px hsla(220, 18%, 12%, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: auto;
}

body {
    margin: 0;
    font-family: system-ui;
    font-size: 16px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    padding: 0 16px;
}

main,
header#mainHeader,
footer {
    max-width: 1100px;
    margin: 0 auto;
}

#mainHeader {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 16px 0;
    background: hsla(220, 20%, 98%, 0.85);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

#appBranding {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

#appBranding:hover {
    color: var(--accent);
}

#appBranding:active {
    transform: scale(0.98);
}

nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

a {
    text-decoration: none;
    color: inherit;
    font-size: 0.95rem;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    box-shadow: none;
}

.nav-link:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-link[aria-current="page"] {
    background: var(--accent);
    color: white;
}

.nav-link[aria-current="page"]:hover {
    background: var(--accent2);
}

#themeToggle {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    box-shadow: none;
    margin-left: 8px;
}

#themeToggle:hover {
    background: var(--surface2);
    transform: scale(1.1);
}

#themeToggle:active {
    transform: scale(0.95);
}

.theme-icon {
    display: block;
    line-height: 1;
}

section {
    margin: 0;
    padding: 24px 0;
    border-radius: 0;
    background: transparent;
    border: none;
}

section>header h2 {
    margin: 0 0 20px;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.view {
    display: none !important;
}

.view.active {
    display: block !important;
}

article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0;
    box-shadow: var(--shadow2);
}

article h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

fieldset {
    border: 1px solid var(--muted);
    border-radius: 16px;
    padding: 14px;
}

legend {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
}

label {
    display: grid;
    gap: 6px;
    margin: 12px 0;
    color: var(--muted);
    font-size: 0.95rem;
}

input,
select {
    width: min(520px, 100%);
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
}

select {
    cursor: pointer;
}

input::placeholder {
    color: hsl(220 10% 60%);
}

input:focus,
select:focus {
    outline: 3px solid hsla(222, 84%, 55%, 0.25);
    border-color: hsla(222, 84%, 55%, 0.6);
}

button {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    box-shadow: 0 2px 4px hsla(222, 84%, 55%, 0.2);
}

button:hover {
    background: var(--accent2);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px hsla(222, 84%, 55%, 0.25);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px hsla(222, 84%, 55%, 0.2);
}

.editBtn {
    background: hsl(200 70% 50%);
    box-shadow: 0 1px 3px hsla(200, 70%, 50%, 0.2);
    padding: 8px 14px;
    font-size: 0.85rem;
    margin-left: 4px;
}

.editBtn:hover {
    background: hsl(200 70% 45%);
    box-shadow: 0 4px 8px hsla(200, 70%, 50%, 0.25);
}

.delBtns,
#clearData {
    background: hsl(0 70% 50%);
    box-shadow: 0 1px 3px hsla(0, 70%, 50%, 0.2);
    padding: 8px 14px;
    font-size: 0.85rem;
    margin-left: 2px;
}

.delBtns:hover,
#clearData:hover {
    background: hsl(0 70% 45%);
    box-shadow: 0 4px 8px hsla(0, 70%, 50%, 0.25);
}

#taskList,
#dashboardSubjectsList,
#dashboardStudySlots,
#upcomingDeadlines,
#subjectList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#taskList li,
#dashboardSubjectsList li,
#dashboardStudySlots li,
#upcomingDeadlines li,
#subjectList li {
    padding: 10px 12px;
    margin: 8px 0;
    background: var(--surface2);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

#taskList li:hover,
#dashboardSubjectsList li:hover,
#dashboardStudySlots li:hover,
#upcomingDeadlines li:hover,
#subjectList li:hover {
    background: var(--surface);
    border-color: var(--accent);
}

#taskList li {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

#taskList li input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
}

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 12px;
}

th {
    background: hsl(220 20% 97%);
    text-align: left;
    color: var(--muted);
    font-weight: 700;
}

tr:last-child td {
    border-bottom: none;
}

footer {
    text-align: center;
    color: var(--muted);
    padding: 2px 0 10px;
    font-size: 1.2rem;
}

/* Dark mode */

body.dark {
    --bg: hsl(220 20% 7%);
    --surface: hsl(220 18% 10%);
    --surface2: hsl(220 18% 12%);
    --text: hsl(220 20% 92%);
    --muted: hsl(220 10% 70%);
    --border: hsl(220 14% 22%);
    --shadow: 0 14px 34px hsla(0, 0%, 0%, 0.35);
    --shadow2: 0 8px 20px hsla(0, 0%, 0%, 0.28);
}

body.dark #mainHeader {
    background: hsla(220, 20%, 7%, 0.85);
}

body.dark nav a {
    background: var(--surface);
}

body.dark th {
    background: hsl(220 18% 14%);
}

@media (min-width: 950px) {
    #dashboard {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }

    #dashboard>header {
        grid-column: 1 / -1;
    }
}

.progressWrap {
    width: 100%;
    height: 20px;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progressBar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 200ms ease;
}

/* Charts */
.charts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    justify-content: center;
}

.chart-wrapper {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow2);
}

.chart-wrapper h4 {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
}

canvas {
    max-width: 100%;
    height: auto;
}

#chartLegend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

#chartsContainer {
    display: none;
}

#statusDistributionHeading {
    text-align: center;
    margin-bottom: 10px;
}

#taskCountsHeading {
    text-align: center;
    margin-bottom: 10px
}

/* Error Messages */
.error-message {
    color: hsl(0, 80%, 60%);
    background: hsla(0, 80%, 60%, 0.1);
    border: 1px solid hsla(0, 80%, 60%, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    display: none;
    text-align: center;
}

/* Edit Buttons */
.editBtn {
    background: hsl(222, 84%, 55%);
    box-shadow: 0 10px 22px hsla(222, 84%, 55%, 0.18);
    margin: 10px 5px 10px 0;
}

.editBtn:hover {
    background: hsl(222, 84%, 45%);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: hsla(0, 0%, 0%, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    margin: 10% auto;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 16px;
    width: min(500px, 90%);
    box-shadow: var(--shadow);
}

.modal-content h3 {
    margin: 0 0 16px;
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

#cancelEdit {
    background: var(--muted);
    box-shadow: none;
}

#cancelEdit:hover {
    background: hsl(220, 10%, 35%);
}