* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Hero */
.hero {
    background: linear-gradient(to bottom, #0d47a1, #1a73e8);
    color: #fff;
    padding: 0 0 50px;
    text-align: center;
}
.hero .container {
    padding-top: max(40px, calc(14px + env(safe-area-inset-top)));
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.hero .subtitle {
    font-size: 1.05rem;
    opacity: 0.85;
    margin-bottom: 28px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 9999px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn-telegram,
.btn-telegram:visited,
.btn-telegram:hover,
.btn-telegram:active {
    background: #fff;
    color: #1a73e8;
    font-weight: 600;
}

.btn-telegram:hover {
    background: #e8f0fe;
}

.btn-about,
.btn-about:visited,
.btn-about:hover,
.btn-about:active {
    background: #fff;
    color: #1a73e8;
    font-weight: 600;
}

.btn-about:hover {
    background: #e8f0fe;
}

.btn-period,
.btn-period:visited {
    background: #e8f0fe;
    color: #1a73e8;
    font-weight: 500;
}

.btn-period.active,
.btn-period.active:visited {
    background: #1a73e8;
    color: #fff;
}

.btn-period:hover:not(.active) {
    background: #d2e3fc;
}

/* Schedule section */
.schedule-section {
    padding: 40px 0;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.type-toggle {
    display: flex;
    gap: 0;
    background: #e8f0fe;
    border-radius: 12px;
    padding: 4px;
}

.type-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: transparent;
    color: #555;
    transition: all 0.2s;
}

.type-btn.active {
    background: #1a73e8;
    color: #fff;
    box-shadow: 0 2px 6px rgba(26,115,232,0.3);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.teacher-search-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.teacher-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.teacher-keywords {
    min-width: min(680px, 100%);
    padding: 2px 0;
}

.keyword-input {
    padding: 9px 12px;
    border: 2px solid #dde1e6;
    border-radius: 11px;
    font-size: 0.92rem;
    font-family: inherit;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.keyword-input:focus {
    border-color: #1a73e8;
}

.btn-search {
    min-width: 118px;
    padding: 10px 16px;
    margin-left: 4px;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    background: linear-gradient(135deg, #1a73e8 0%, #0d5bd3 100%);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(26, 115, 232, 0.18);
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
    white-space: nowrap;
}

.btn-search:hover {
    filter: brightness(1.04);
    box-shadow: 0 8px 18px rgba(26, 115, 232, 0.22);
}

.btn-search:active {
    transform: translateY(1px) scale(0.99);
}

.select-group {
    flex: 1;
    min-width: 160px;
}

.select-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.select-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #dde1e6;
    border-radius: 12px;
    font-size: 0.95rem;
    background: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.select-group select:focus {
    outline: none;
    border-color: #1a73e8;
}

.period-buttons {
    display: flex;
    gap: 8px;
}

.teacher-week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    margin-top: 0;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
    border: 1px solid #d7e4fb;
    box-shadow: 0 4px 14px rgba(26, 115, 232, 0.09);
}

.teacher-week-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 11px;
    background: linear-gradient(135deg, #1a73e8 0%, #0d5bd3 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 12px rgba(26, 115, 232, 0.18);
    transition: background 0.2s, transform 0.15s, opacity 0.2s, box-shadow 0.2s, filter 0.2s;
}

.teacher-week-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 14px rgba(26, 115, 232, 0.22);
}

.teacher-week-btn:active {
    transform: scale(0.96);
}

.teacher-week-btn:disabled {
    background: linear-gradient(135deg, #d3def4 0%, #c5d4ef 100%);
    box-shadow: none;
    cursor: default;
    opacity: 0.78;
}

.teacher-week-label {
    flex: 1;
    text-align: center;
    padding: 7px 10px;
    border-radius: 11px;
    background: rgba(26, 115, 232, 0.08);
    border: 1px solid rgba(26, 115, 232, 0.12);
    font-size: 0.88rem;
    font-weight: 700;
    color: #1a2a44;
    line-height: 1.2;
}

/* Error */
.error {
    text-align: center;
    padding: 20px;
    color: #d32f2f;
    background: #fde7e7;
    border-radius: 8px;
    margin-bottom: 16px;
}

.hidden {
    display: none;
}

/* Schedule cards */
.schedule-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.day-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.day-header {
    background: #1a73e8;
    color: #fff;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-header .date {
    opacity: 0.85;
    font-weight: 400;
}

/* Today card — purple gradient */
.day-card--today > .day-header {
    background: linear-gradient(135deg, #4527a0 0%, #6d28d9 50%, #7c3aed 100%);
}

.badge-today {
    display: inline-block;
    background: rgba(255,255,255,0.28);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 9999px;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.lesson {
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 12px;
    align-items: start;
}

.lesson:last-child {
    border-bottom: none;
}

.lesson-time {
    font-weight: 700;
    color: #1a73e8;
    font-size: 0.95rem;
    padding-top: 2px;
}

.lesson-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.lesson-subject {
    font-weight: 600;
    font-size: 0.95rem;
}

.lesson-type {
    display: inline-block;
    background: #e8f0fe;
    color: #1a73e8;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    width: fit-content;
}

.lesson-meta {
    font-size: 0.85rem;
    color: #666;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Current lesson highlight */
.lesson--current {
    background: linear-gradient(90deg, #7c3aed 0%, #7c3aed 3px, #f3f0ff 3px, #f3f0ff 100%);
    border-bottom-color: #e8e0ff;
}
.lesson--current .lesson-time {
    color: #6d28d9;
}
.badge-current {
    display: inline-block;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.3px;
    animation: pulse-current 2s ease-in-out infinite;
}
@keyframes pulse-current {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.no-lessons {
    text-align: center;
    padding: 50px 20px;
    color: #888;
    font-size: 1.1rem;
}

/* Footer */
footer {
    margin-top: auto;
    background: #1a1a2e;
    color: #aaa;
    padding: 20px 0;
    text-align: center;
    font-size: 0.85rem;
}

footer a {
    color: #7db4ff;
    text-decoration: none;
}

footer a:visited {
    color: #7db4ff;
}

a:visited {
    color: inherit;
}

body.pwa .btn-telegram {
    display: none;
}

/* ── Gear button ─────────────────────────────────────────────────────────── */
.gear-btn {
    position: fixed;
    top: max(14px, calc(14px + env(safe-area-inset-top)));
    right: 16px;
    background: rgba(13, 71, 161, 0.85);
    border: 1.5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.gear-btn:active {
    background: rgba(13, 71, 161, 1);
    transform: scale(0.95);
}

/* ── Gear menu ───────────────────────────────────────────────────────────── */
.gear-menu {
    position: fixed;
    top: calc(max(14px, calc(14px + env(safe-area-inset-top))) + 50px);
    right: 16px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    z-index: 300;
    overflow: hidden;
    min-width: 190px;
}

.gear-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 15px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    color: #1a1a2e;
    text-decoration: none;
    transition: background 0.1s;
}

.gear-menu-item:hover {
    background: #f5f7fa;
}

.gear-menu-item + .gear-menu-item {
    border-top: 1px solid #f0f0f0;
}

/* ── Settings overlay ────────────────────────────────────────────────────── */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: #f5f7fa;
    z-index: 400;
    overflow-y: auto;
}

.settings-page {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.settings-header {
    background: linear-gradient(to bottom, #0d47a1, #1a73e8);
    color: #fff;
    padding: max(16px, calc(16px + env(safe-area-inset-top))) 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.settings-back-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.settings-back-btn:active {
    background: rgba(255,255,255,0.35);
}

.settings-body {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-type-row {
    display: flex;
    gap: 12px;
}

.settings-type-btn {
    flex: 1;
    padding: 14px 10px;
    border: 2px solid #dde1e6;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    font-family: inherit;
    transition: all 0.15s;
}

.settings-type-btn.active {
    border-color: #1a73e8;
    color: #1a73e8;
    background: #e8f0fe;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
}

.settings-select,
.settings-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #dde1e6;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.settings-select:focus,
.settings-input:focus {
    border-color: #1a73e8;
}

.settings-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.settings-save-btn {
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
    margin-top: 4px;
}

.settings-save-btn:hover {
    background: #1557b0;
}

.settings-save-btn:active {
    transform: scale(0.98);
}

/* Responsive */
@media (max-width: 600px) {
    .hero {
        padding: 0 0 35px;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .controls {
        flex-direction: column;
    }

    .select-group {
        min-width: 100%;
    }

    .teacher-search-row {
        width: 100%;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .btn-search {
        width: 100%;
        margin-left: 0;
    }

    .period-buttons {
        width: 100%;
        justify-content: center;
    }

    .teacher-week-nav {
        gap: 8px;
        padding: 9px;
    }

    .teacher-week-label {
        font-size: 0.82rem;
        line-height: 1.25;
    }

    .lesson {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .day-header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
}
