* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-border: #d8dee8;
    --text: #172033;
    --muted: #67758d;
    --accent: #4F46E5;
    --accent-strong: #4338CA;
    --green: #047857;
    --orange: #b45309;
    --shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
}

[data-theme="dark"] {
    --bg: #10151f;
    --panel: #171f2e;
    --panel-border: #2a374b;
    --text: #eef4fb;
    --muted: #a2b0c5;
    --accent: #8B5CF6;
    --accent-strong: #7C3AED;
    --green: #34d399;
    --orange: #f59e0b;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px;
}

.topbar,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.topbar {
    margin-bottom: 18px;
}

.title h1 {
    margin: 0 0 4px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0;
}

.title span {
    color: var(--muted);
    font-size: 14px;
}

.toolbar {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.actions,
.week-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn,
.date-input {
    min-height: 40px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 0 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-strong);
    color: #fff;
}

.btn-secondary {
    background: var(--panel);
    border-color: var(--panel-border);
    color: var(--text);
}

.btn-secondary:hover {
    background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.btn-danger-subtle {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #B91C1C;
}

[data-theme="dark"] .btn-danger-subtle {
    background: rgba(239, 68, 68, 0.13);
    border-color: rgba(239, 68, 68, 0.25);
    color: #FECACA;
}

.btn-icon-md {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 8px;
}

.btn-icon-md svg {
    width: 20px;
    height: 20px;
}

.btn-md {
    min-height: 40px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
}

.date-input {
    padding: 0 12px;
}

.status {
    min-height: 22px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
}

.schedule {
    display: grid;
    grid-template-columns: 96px repeat(7, minmax(0, 1fr));
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.corner,
.day-head,
.time-cell,
.day-cell {
    border-right: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
}

.corner,
.day-head {
    min-height: 58px;
    padding: 10px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.day-head strong {
    display: block;
}

.day-head span {
    color: var(--muted);
    font-size: 13px;
}

.time-cell {
    padding: 10px;
    color: var(--muted);
    font-size: 13px;
    background: color-mix(in srgb, var(--panel-border) 26%, transparent);
}

.day-cell {
    min-height: 118px;
    padding: 8px;
}

.lesson {
    height: 100%;
    min-height: 96px;
    border-left: 4px solid var(--green);
    border-radius: 7px;
    background: color-mix(in srgb, var(--green) 10%, transparent);
    padding: 9px;
}

.lesson-title {
    font-weight: 700;
    line-height: 1.25;
}

.lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.chip {
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    padding: 3px 8px;
    color: var(--muted);
    font-size: 12px;
    background: var(--panel);
}

.empty {
    color: var(--muted);
    font-size: 13px;
}

.error {
    color: var(--orange);
}

@media (max-width: 980px) {
    .schedule {
        display: block;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .mobile-day {
        margin-bottom: 10px;
        border: 1px solid var(--panel-border);
        border-radius: 8px;
        background: var(--panel);
        overflow: hidden;
    }

    .mobile-day .day-head {
        border-right: 0;
    }

    .mobile-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }
}

@media (max-width: 640px) {
    .shell {
        padding: 16px;
    }

    .topbar,
    .toolbar,
    .actions {
        display: grid;
        align-items: stretch;
    }

    .week-nav .btn {
        flex: 1;
    }
}

