* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-border: #dbe3ef;
    --text: #162033;
    --muted: #66758f;
    --accent: #4F46E5;
    --accent-strong: #4338CA;
    --blue: #2563eb;
    --warning: #b45309;
    --shadow: 0 12px 34px rgba(22, 32, 51, 0.08);
}

[data-theme="dark"] {
    --bg: #0e131d;
    --panel: #151d2b;
    --panel-border: #263449;
    --text: #edf3fb;
    --muted: #9cadc5;
    --accent: #8B5CF6;
    --accent-strong: #7C3AED;
    --blue: #60a5fa;
    --warning: #f59e0b;
    --shadow: 0 18px 44px 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 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    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;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn,
.select,
.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;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.select,
.date-input {
    width: 100%;
    padding: 0 12px;
}

.week-nav {
    display: flex;
    gap: 8px;
}

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

.schedule {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.day {
    min-height: 260px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.day-head {
    padding: 12px;
    border-bottom: 1px solid var(--panel-border);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.day-name {
    font-weight: 700;
}

.day-date {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

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

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

.lesson-time {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.lesson-title {
    margin-top: 5px;
    font-weight: 700;
    line-height: 1.25;
}

.lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    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 {
    padding: 16px 10px;
    color: var(--muted);
    font-size: 13px;
}

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

@media (max-width: 980px) {
    .schedule {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .topbar,
    .actions,
    .toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .topbar,
    .actions {
        display: grid;
    }

    .week-nav {
        justify-content: stretch;
    }

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

    .schedule {
        grid-template-columns: 1fr;
    }
}

