:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-2: #eeeeef;
    --border: #d4d4d7;
    --text: #1f1f22;
    --text-muted: #68686f;
    --accent: #2f8a5a;
    --accent-2: #439a6c;
    --accent-rgb: 47, 138, 90;
    --accent-contrast: #ffffff;

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(20, 20, 22, 0.05);
    --shadow: 0 4px 12px rgba(20, 20, 22, 0.08);
    --shadow-lg: 0 12px 28px rgba(20, 20, 22, 0.14);
}

[data-theme="dark"] {
    --bg: #17171a;
    --surface: #222226;
    --surface-2: #2a2a2f;
    --border: #38383f;
    --text: #eaeaec;
    --text-muted: #97979e;
    --accent: #4ea67d;
    --accent-2: #63b28d;
    --accent-rgb: 78, 166, 125;
    --accent-contrast: #0e150f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    color: inherit;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    margin: 0 0 20px;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

h2 {
    font-weight: 700;
}

/* Top bar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.topbar__brand {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: scale(0.94);
}

.theme-toggle__icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.theme-toggle__icon--sun {
    display: none;
}

[data-theme="dark"] .theme-toggle__icon--moon {
    display: none;
}

[data-theme="dark"] .theme-toggle__icon--sun {
    display: block;
}

/* Shell: sidebar + content */

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 64px);
}

.sidebar {
    flex: 0 0 240px;
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 22px 14px;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar__link::-webkit-details-marker {
    display: none;
}

.sidebar__link::marker {
    content: '';
}

.sidebar__link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.sidebar__link--active {
    background: rgba(var(--accent-rgb), 0.16);
    color: var(--accent);
}

.sidebar__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
}

.sidebar__icon svg {
    width: 17px;
    height: 17px;
}

.sidebar__chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}

.sidebar__dropdown[open] > .sidebar__link .sidebar__chevron {
    transform: rotate(180deg);
}

.sidebar__sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 6px 28px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}

.sidebar__sublink {
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar__sublink:hover {
    background: var(--surface-2);
    color: var(--text);
}

.sidebar__sublink--active {
    background: var(--surface-2);
    color: var(--accent);
    font-weight: 700;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 32px 36px 56px;
}

@media (max-width: 860px) {
    .app-shell {
        flex-direction: column;
        min-height: 0;
    }

    .sidebar {
        position: static;
        height: auto;
        width: 100%;
        flex: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar__nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar__dropdown {
        position: relative;
    }

    .sidebar__sub {
        position: absolute;
        top: 100%;
        left: 0;
        margin: 4px 0 0;
        padding: 8px;
        border-left: none;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow);
        z-index: 10;
        min-width: 200px;
    }

    .content {
        padding: 20px 18px 40px;
    }
}

/* Search */

.search-form {
    display: flex;
    gap: 10px;
}

.search-form input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 260px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
}

.search-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.search-form button {
    padding: 12px 24px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast, #fff);
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.search-form button:hover {
    background: var(--accent-2);
    border-color: var(--accent-2);
}

.search-form button:active {
    transform: translateY(1px);
}

.search-form--page {
    margin: 0 0 24px;
}

.search-form--inline {
    margin: 16px 0;
}

/* Subject / task lists */

.subject-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 10px;
}

.subject-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.subject-list li:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.subject-list a {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
}

.subject-list .count {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 400;
    white-space: nowrap;
}

.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.task-card__image {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}

.task-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(0, 0, 0, 0.8);
    cursor: zoom-out;
}

.lightbox[hidden] {
    display: none;
}

.lightbox__img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.task-card__title {
    padding: 12px 14px 0;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.task-card__meta {
    padding: 4px 14px 14px;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Study: table */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th,
.data-table td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table th {
    position: sticky;
    top: 64px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
    z-index: 5;
}

.data-table thead tr:first-child th:first-child {
    border-top-left-radius: var(--radius);
}

.data-table thead tr:first-child th:last-child {
    border-top-right-radius: var(--radius);
}

.data-table tbody tr:hover {
    background: rgba(var(--accent-rgb), 0.08);
}

/* The comment cell uses rowspan to visually cover several rows, but it's
   really a DOM child of just the first one — without this, hovering that
   first row alone would highlight the whole tall comment cell too. */
.data-table tbody tr:hover td.schedule-comment-cell {
    background: var(--surface);
}

.muted {
    color: var(--text-muted);
}

/* Study: subject info */

.info-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 22px;
    box-shadow: var(--shadow-sm);
}

.info-list__row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.info-list__row:last-child {
    border-bottom: none;
}

.info-list dt {
    font-weight: 700;
    color: var(--text);
    flex: 0 0 260px;
}

.info-list dd {
    margin: 0;
    flex: 1 1 200px;
    color: var(--text-muted);
}

.info-list dd a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.info-list dd a:hover {
    text-decoration: underline;
}

.accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.accordion__item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.accordion__summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1.02rem;
    cursor: pointer;
    list-style: none;
}

.accordion__summary::-webkit-details-marker {
    display: none;
}

.accordion__summary::marker {
    content: '';
}

.accordion__summary:hover {
    background: var(--surface-2);
}

.accordion__chevron {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.accordion__item[open] .accordion__chevron {
    transform: rotate(180deg);
}

.accordion__body {
    padding: 0 20px 18px;
}

.accordion__body .info-list {
    border: none;
    box-shadow: none;
    padding: 4px 0 0;
}

.accordion__body .table-wrap {
    border: none;
    box-shadow: none;
    border-radius: 0;
    margin-top: 4px;
}

.schedule-table {
    table-layout: fixed;
}

.data-table td.schedule-comment-cell {
    vertical-align: middle;
    text-align: center;
}

.schedule-header {
    display: grid;
    grid-template-columns: 30% 15% 15% 17% 23%;
    padding: 13px 16px 13px 36px;
    margin-bottom: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 64px;
    z-index: 5;
}

.schedule-header span {
    padding-right: 10px;
}
