/* Mobile Optimizations - Compact Scale Without Truncation */

@media (max-width: 768px) {
  .header {
    display: none;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
  }

  body {
    padding-top: 0;
    font-size: 12px;
    background: #FBF6F1;
  }

  .stats-container {
    display: block !important;
    margin: 0 0 0.75rem 0;
    background: white;
    border-radius: 14px;
    padding: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid rgba(183,77,63,0.1);
  }

  .stats-toggle-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    padding: 0.6rem 1rem;
    background: white;
    border: 1.5px solid rgba(183,77,63,0.2);
    border-radius: 12px;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    gap: 0.5rem;
    margin: 0 0 0.5rem 0;
    height: auto;
    width: auto;
  }

  .week-stats-divider {
    display: none;
  }

  .week-navigation {
    display: none !important;
  }

  .stats-toggle-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
  }

  .stats-toggle-btn.expanded svg {
    transform: rotate(180deg);
  }

  .stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    padding: 0.5rem;
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s, padding 0.3s;
  }

  .stats-bar.has-room-capacity {
    grid-template-columns: repeat(5, 1fr);
  }

  .stats-bar.collapsed {
    max-height: 0;
    padding: 0 0.5rem;
    opacity: 0;
  }

  .stat-item {
    flex-direction: column;
    text-align: center;
    gap: 0.25rem;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
    margin: 0 auto;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .stat-label {
    font-size: 0.55rem;
  }

  .week-controls,
  .week-today-btn {
    display: none !important;
  }

  .mobile-settings-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(183,77,63,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .mobile-settings-toggle:active {
    transform: scale(0.90);
    box-shadow: 0 1px 4px rgba(183,77,63,0.30);
  }

  .mobile-settings-toggle svg {
    width: 24px;
    height: 24px;
  }

  .settings-card {
    position: fixed;
    top: 0;
    left: 0.6rem;
    right: 0.6rem;
    z-index: 998;
    padding: 1rem;
    margin: 0;
    border-radius: 20px;
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
    /* Анимация: скользит сверху */
    transform: translateY(0) scale(1);
    opacity: 1;
    transition:
      transform 0.30s cubic-bezier(0.34,1.2,0.64,1),
      opacity   0.22s ease;
    box-shadow: 0 12px 40px rgba(0,0,0,0.28);
    background: white;
    border: 1px solid rgba(183,77,63,0.12);
    -webkit-overflow-scrolling: touch;
  }

  /* Скрытое состояние — улетает вверх */
  .settings-card.hidden {
    transform: translateY(calc(-100% - 60px)) scale(0.97);
    opacity: 0;
    pointer-events: none;
  }

  .settings-card h2 {
    font-size: 0.95rem;
    margin-bottom: 0.7rem;
    text-align: center;
    color: var(--primary);
  }

  .role-selector {
    margin-bottom: 0.9rem;
    background: #F7F1EC;
    border-radius: 12px;
    padding: 0.4rem;
  }

  .role-selector > label {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
    color: var(--text-light);
    display: block;
    text-align: center;
    font-weight: 600;
  }

  .role-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .role-option {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.7rem;
    font-size: 0.85rem;
    background: white;
    border-radius: 10px;
    border: 1.5px solid #e0e0e0;
    transition: all 0.2s;
    cursor: pointer;
  }

  .role-option:hover {
    border-color: var(--primary);
    background: #F4E8E7;
  }

  .role-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin-right: 0.7rem;
    accent-color: var(--primary);
  }

  .role-option label {
    flex: 1;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
  }

  .role-option::after {
    content: "→";
    color: var(--primary);
    opacity: 0.5;
    font-size: 0.9rem;
  }

  .role-option:has(input:checked) {
    border-color: var(--primary);
    background: linear-gradient(135deg, #F4E8E7 0%, #ffe5e5 100%);
  }

  .role-option:has(input:checked)::after {
    opacity: 1;
  }

  .filters-section.visible .filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .filter-group {
    margin-bottom: 0;
  }

  .filter-group label {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
    display: block;
  }

  .filter-group select {
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    width: 100%;
    border-radius: 10px;
    border: 1.5px solid #e0e0e0;
    background: white;
  }

  .search-box {
    margin-bottom: 0.6rem;
  }

  .search-input {
    padding: 0.5rem 0.7rem 0.5rem 2.3rem;
    font-size: 0.8rem;
    border-radius: 10px;
  }

  .search-icon {
    left: 0.7rem;
    font-size: 0.95rem;
  }

  .close-settings-btn {
    position: sticky;
    bottom: -1rem;
    width: 100%;
    padding: 0.7rem;
    margin: 0.9rem -1rem -1rem -1rem;
    width: calc(100% + 2rem);
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.15);
    border-radius: 0 0 20px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: block;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.02em;
  }

  .close-settings-btn:active {
    opacity: 0.85;
    transform: scale(0.99);
  }

  .week-switcher {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 990;
    background: white;
    padding: 0.5rem 0.7rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    border-bottom: 1px solid rgba(183,77,63,0.1);
  }

  .week-nav-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(183,77,63,0.3);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .week-nav-btn:active {
    transform: scale(0.95);
    background: var(--primary-dark);
  }

  .week-nav-btn svg {
    width: 20px;
    height: 20px;
  }

  .week-info {
    flex: 1;
    text-align: center;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    background: none;
    border: none;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease;
    font-family: inherit;
  }

  .week-info:active {
    background: rgba(183,77,63,0.08);
  }

  .current-week {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
  }

  .week-range {
    font-size: 0.65rem;
    color: var(--text-light);
    margin-top: 0.1rem;
  }

  .today-btn {
    display: none;
  }

  .container {
    padding: 0.4rem;
  }

  #week-navigation {
    display: none !important;
  }

  .schedule-wrapper {
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid rgba(183,77,63,0.08);
    margin-top: 0;
  }

  .schedule-wrapper::-webkit-scrollbar {
    height: 3px;
  }

  .schedule-wrapper::-webkit-scrollbar-track {
    background: #F0E8E3;
  }

  .schedule-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
  }

  /* КОМПАКТНЫЙ МАСШТАБ БЕЗ ОБРЕЗАНИЯ СЛОВ */
  .schedule-grid {
    min-width: 820px;
    font-size: 0.68rem;
    border: none;
    grid-template-columns: 70px repeat(7, 1fr);
  }

  .schedule-cell {
    min-height: 80px;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
  }

  .time-header {
    padding: 0.5rem 0.2rem;
    font-size: 0.65rem;
    background: linear-gradient(135deg, #202020 0%, #202020 100%);
    color: white;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
  }

  .time-header br {
    display: none;
  }

  .time-cell {
    font-size: 0.6rem;
    padding: 0.4rem 0.2rem;
    background: #FBF6F1;
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
  }

  .time-cell br {
    display: none;
  }

  .day-header {
    padding: 0.4rem 0.2rem;
    background: linear-gradient(135deg, #B74D3F 0%, #B74D3F 100%);
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .day-name {
    font-size: 0.7rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    line-height: 1.2;
    font-weight: 700;
  }

  .day-date {
    font-size: 0.62rem;
    white-space: nowrap;
  }

  .today-indicator {
    width: 5px;
    height: 5px;
    margin-left: 3px;
    display: inline-block;
    vertical-align: middle;
  }

  .lesson-cell {
    padding: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .lesson {
    padding: 0.4rem 0.35rem;
    border-left-width: 3px;
    font-size: 0.62rem;
    border-radius: 5px;
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s;
    white-space: normal;
    line-height: 1.3;
    word-break: normal;
    overflow-wrap: break-word;
  }

  .lesson:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(183,77,63,0.15);
  }

  .lesson:active {
    transform: scale(0.98);
  }

  .lesson-subject {
    font-size: 0.66rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
    line-height: 1.3;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    color: var(--text);
  }

  .lesson-info {
    font-size: 0.58rem;
    line-height: 1.3;
    color: var(--text-light);
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
  }

  .lesson-teacher {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    margin-bottom: 0.1rem;
    font-weight: 500;
  }

  .lesson-type {
    font-size: 0.52rem;
    padding: 0.1rem 0.3rem;
    margin-bottom: 0.15rem;
    display: inline-block;
    border-radius: 3px;
    font-weight: 700;
    white-space: normal;
  }

  .lesson-info div:last-child {
    font-size: 0.52rem;
    margin-top: 0.1rem;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    color: var(--primary);
    font-weight: 500;
  }

  .lesson-info div:last-child strong {
    font-weight: 700;
    color: var(--text);
  }

  .message {
    padding: 1.2rem 0.8rem;
    background: white;
    border-radius: 10px;
  }

  .message-icon {
    font-size: 1.8rem;
  }

  .message h3 {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
  }

  .message p {
    font-size: 0.75rem;
    color: var(--text-light);
  }

  /* УЛУЧШЕННЫЙ ВИДЖЕТ ПОДДЕРЖКИ С ЭФФЕКТОМ */
  .support-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: "Inter", sans-serif;
  }

  .support-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(183,77,63,0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .support-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(183,77,63,0.5);
  }

  .support-button:active {
    transform: scale(0.95);
  }

  .support-button svg {
    width: 26px;
    height: 26px;
    fill: white;
  }

  .support-chat {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: calc(100vw - 40px);
    max-width: 340px;
    max-height: 60vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: suckIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .support-chat.active {
    display: flex;
    animation: suckOut 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  @keyframes suckOut {
    0% {
      opacity: 0;
      transform: scale(0.3);
    }
    50% {
      opacity: 0.5;
      transform: scale(1.05);
    }
    100% {
      opacity: 1;
      transform: scale(1);
    }
  }

  @keyframes suckIn {
    0% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.5;
      transform: scale(1.05);
    }
    100% {
      opacity: 0;
      transform: scale(0.3);
    }
  }

  .support-chat-header {
    padding: 1rem 1.2rem;
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
  }

  .support-chat-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.2rem 0;
  }

  .support-chat-header p {
    font-size: 0.75rem;
    opacity: 0.9;
    margin: 0;
  }

  .support-chat-body {
    padding: 1.2rem;
    overflow-y: auto;
    flex: 1;
  }

  .support-form-group {
    margin-bottom: 1rem;
  }

  .support-form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
    display: block;
  }

  .support-form-group select,
  .support-form-group textarea {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid #E8DDD9;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: "Inter", sans-serif;
    transition: border-color 0.2s;
    background: #FBF6F1;
  }

  .support-form-group select:focus,
  .support-form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
  }

  .support-form-group textarea {
    resize: vertical;
    min-height: 100px;
  }

  .support-submit {
    width: 100%;
    padding: 0.8rem;
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
  }

  .support-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(183, 77, 63, 0.3);
  }

  .support-submit:active {
    transform: scale(0.98);
  }

  .support-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

  .support-success {
    text-align: center;
    padding: 1.5rem;
  }

  .support-success-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    background: #DCA44E;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .support-success h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
  }

  .support-success p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 1.2rem;
  }

  /* ===== TEACHER MODAL — мобильные поправки ===== */
  .teacher-modal.active {
    padding: 0.5rem;
  }

  .teacher-modal-content {
    border-radius: 28px;
    max-height: 96vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 50px rgba(183, 77, 63, 0.35);
  }

  /* Фото без рамок — border-radius wrapper совпадает с карточкой */
  .teacher-photo-wrapper {
    border-radius: 28px 28px 0 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  .teacher-photo {
    height: 70vw;
    max-height: 420px;
    border-radius: 0;
    width: 100%;
    display: block;
  }

  .teacher-modal-body {
    padding: 0.65rem 1rem 1rem;
  }

  .teacher-modal-name {
    margin-bottom: 0.15rem;
  }

  .tm-surname {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
  }

  .tm-nameparts {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-light);
  }

  .teacher-position {
    font-size: 0.6rem;
    margin-bottom: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .teacher-contacts {
    gap: 0.28rem;
    margin-bottom: 0.55rem;
  }

  .teacher-contact-item {
    border-radius: 10px;
    padding: 0.4rem 0.7rem;
    gap: 0.55rem;
  }

  .teacher-contact-item svg {
    width: 14px;
    height: 14px;
  }

  .teacher-contact-item:active {
    background: #eeecec;
    transform: translateX(3px);
  }

  .teacher-contact-link,
  .teacher-contact-item span {
    font-size: 0.74rem;
  }

  .teacher-profile-btn {
    border-radius: 12px;
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
  }

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

  /* УЛУЧШЕННЫЙ КАЛЕНДАРЬ */
  .calendar-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  .calendar-popup.active {
    opacity: 1;
    pointer-events: all;
  }

  .calendar-popup .calendar-container {
    background: white;
    border-radius: 28px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px rgba(183, 77, 63, 0.4);
    max-width: 420px;
    width: 92%;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 0 auto;
  }

  .calendar-popup.active .calendar-container {
    transform: scale(1);
  }

  .calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid rgba(183, 77, 63, 0.15);
  }

  .calendar-nav-btn {
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }

  .calendar-nav-btn:active {
    transform: scale(0.95);
  }

  .calendar-month-year {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
  }

  .calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3rem;
    margin-bottom: 0.5rem;
  }

  .calendar-weekday {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    padding: 0.6rem 0;
  }

  .calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
  }

  .calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    border: 2px solid transparent;
    background: #F7F1EC;
  }

  .calendar-day:not(.other-month):active {
    transform: scale(0.95);
    background: rgba(183,77,63,0.15);
  }

  .calendar-day.other-month {
    background: transparent;
    color: #B8ACAA;
    cursor: default;
  }

  .calendar-day.today {
    background: linear-gradient(135deg, #DCA44E 0%, #A07828 100%);
    color: white;
    font-weight: 700;
  }

  .calendar-day.selected {
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
  }

  .calendar-day.has-lessons {
    position: relative;
    font-weight: 700;
  }

  .calendar-day.has-lessons::after {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
  }

  .calendar-day.has-lessons.today::after,
  .calendar-day.has-lessons.selected::after {
    background: white;
  }

  .calendar-close {
    margin-top: 1.5rem;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #B74D3F 0%, #8C3530 100%);
    color: white;
    border: none;
    border-radius: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
  }

  .calendar-close:active {
    transform: scale(0.98);
  }
}

@media (max-width: 360px) {
  .week-nav-btn {
    width: 32px;
    height: 32px;
  }

  .week-nav-btn svg {
    width: 18px;
    height: 18px;
  }

  .current-week {
    font-size: 0.8rem;
  }

  .week-range {
    font-size: 0.6rem;
  }

  /* КОМПАКТНЫЙ МАСШТАБ ДЛЯ ОЧЕНЬ МАЛЕНЬКИХ ЭКРАНОВ */
  .schedule-grid {
    min-width: 780px;
    grid-template-columns: 65px repeat(7, 1fr);
  }

  .stat-item {
    padding: 0.1rem;
  }

  .stat-icon {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
  }

  .stat-value {
    font-size: 0.85rem;
  }

  .stat-label {
    font-size: 0.5rem;
  }

  .lesson-subject {
    font-size: 0.64rem;
  }

  .lesson-info {
    font-size: 0.56rem;
  }

  /* Модальное окно для очень маленьких экранов */
  .teacher-modal-body {
    padding: 1rem 1.2rem 1.5rem;
  }

  .teacher-photo {
    height: 170px;
  }

  .tm-surname {
    font-size: 1.35rem;
  }

  .tm-nameparts {
    font-size: 1rem;
  }

  .teacher-contact-item {
    padding: 0.65rem 0.9rem;
    gap: 0.75rem;
  }

  .teacher-contact-link,
  .teacher-contact-item span {
    font-size: 0.88rem;
  }

  .teacher-profile-btn {
    padding: 0.85rem;
    font-size: 0.95rem;
    border-radius: 16px;
  }

  .support-chat {
    max-width: 300px;
  }
}
/* ===== MOBILE TIME FORMAT TOGGLE BTN ===== */
@media (max-width: 768px) {
  .today-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(183, 77, 63, 0.1);
    color: var(--primary);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
  }

  .today-btn:active {
    background: rgba(183, 77, 63, 0.2);
    transform: scale(0.95);
  }

  /* Кликабельная колонка времени — переключает формат */
  .mobile-time {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.15s;
  }

  .mobile-time:active {
    background: rgba(183, 77, 63, 0.08);
  }

  /* Подсветка когда активен нумерованный режим */
  .mobile-time.time-numbered .slot-start {
    color: var(--primary);
  }

  .mobile-time.time-numbered .slot-end {
    color: var(--primary);
    opacity: 0.7;
  }
}

  /* ===== LIQUID GLASS MOBILE ===== */
  .theme-toggle {
    width: 90px;
    height: 40px;
  }

  .theme-toggle-thumb {
    width: 28px;
    height: 28px;
    top: 6px;
    left: 6px;
  }

  .theme-icon {
    width: 13px;
    height: 13px;
  }

  .theme-toggle.is-dark .theme-toggle-thumb {
    transform: translateX(50px);
  }

  .theme-toggle.is-dark:hover .theme-toggle-thumb {
    transform: translateX(50px);
  }

/* ================================================================
   DARK MODE — МОБИЛЬНЫЙ ПОЛНЫЙ ИСПРАВЛЕННЫЙ БЛОК
   ================================================================ */

/* Фон страницы */
body.dark-mode {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,77,109,0.14) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 5%,  rgba(192,68,255,0.11) 0%, transparent 38%),
    #0a0812 !important;
  background-attachment: fixed !important;
}

@media (max-width: 768px) {

  /* ── КНОПКА «НАСТРОЙКИ» ── */
  body.dark-mode .mobile-settings-toggle {
    background: linear-gradient(135deg,
      rgba(220,60,80,0.92) 0%, rgba(160,16,40,0.96) 100%
    ) !important;
    border: 1px solid rgba(255,130,150,0.28) !important;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.16),
      0 0 22px rgba(255,77,109,0.40),
      0 4px 18px rgba(0,0,0,0.50) !important;
    color: #fff !important;
    backdrop-filter: blur(16px) !important;
  }

  /* ── OVERLAY ── */
  body.dark-mode .settings-overlay {
    background: rgba(4,1,12,0.80) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
  }

  /* ── ПАНЕЛЬ НАСТРОЕК ── */
  body.dark-mode .settings-card {
    position: fixed !important;  /* восстанавливаем fixed (dark.css ставит relative) */
    background: rgba(14,7,28,0.97) !important;
    backdrop-filter: blur(32px) saturate(1.8) !important;
    -webkit-backdrop-filter: blur(32px) saturate(1.8) !important;
    border: 1px solid rgba(192,68,255,0.25) !important;
    box-shadow:
      inset 0 1.5px 0 rgba(255,255,255,0.09),
      0 0 50px rgba(192,68,255,0.20),
      0 24px 70px rgba(0,0,0,0.75) !important;
  }

  body.dark-mode .settings-card h2 {
    color: #ff4d6d !important;
    text-shadow: 0 0 18px rgba(255,77,109,0.50) !important;
  }

  /* ── ВЫБОР РОЛИ ── */
  body.dark-mode .role-selector {
    background: rgba(10,4,22,0.85) !important;
    border-radius: 12px !important;
    border: 1px solid rgba(120,80,200,0.18) !important;
  }

  body.dark-mode .role-selector > label {
    color: rgba(144,128,184,0.75) !important;
  }

  body.dark-mode .role-option {
    background: rgba(20,10,36,0.92) !important;
    border: 1.5px solid rgba(120,80,200,0.25) !important;
  }

  body.dark-mode .role-option label,
  body.dark-mode .role-option {
    color: rgba(200,185,240,0.92) !important;
  }

  body.dark-mode .role-option::after {
    color: rgba(144,128,184,0.45) !important;
  }

  body.dark-mode .role-option:has(input:checked) {
    background: rgba(255,77,109,0.12) !important;
    border-color: rgba(255,77,109,0.55) !important;
    box-shadow: 0 0 16px rgba(255,77,109,0.16) !important;
  }

  body.dark-mode .role-option:has(input:checked)::after {
    color: rgba(255,100,120,0.85) !important;
    opacity: 1 !important;
  }

  body.dark-mode .role-option input[type="radio"] {
    accent-color: #ff4d6d !important;
  }

  /* ── ФИЛЬТРЫ В ПАНЕЛИ ── */
  body.dark-mode .filter-group select,
  body.dark-mode .search-input {
    background: rgba(10,4,22,0.88) !important;
    color: #f0ecff !important;
    border: 1.5px solid rgba(120,80,200,0.28) !important;
  }

  body.dark-mode .filter-group label {
    color: rgba(144,128,184,0.75) !important;
  }

  /* ── КНОПКА ЗАКРЫТЬ ── */
  body.dark-mode .close-settings-btn {
    background: linear-gradient(135deg,
      rgba(220,60,80,0.90) 0%, rgba(160,16,40,0.96) 100%
    ) !important;
    border-top: 1px solid rgba(255,130,150,0.22) !important;
    border-radius: 0 0 20px 20px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 0 24px rgba(255,77,109,0.32) !important;
    color: #fff !important;
  }

  body.dark-mode .close-settings-btn:active {
    opacity: 0.80 !important;
    transform: scale(0.99) !important;
  }

  /* ── WEEK SWITCHER ── */
  body.dark-mode .week-switcher {
    position: sticky !important;
    top: 0 !important;
    background: rgba(8,4,18,0.97) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border-bottom: 1px solid rgba(255,77,109,0.12) !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.65) !important;
    position: relative !important;
  }

  /* RGB линия под week-switcher */
  body.dark-mode .week-switcher::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1.5px;
    background: linear-gradient(90deg,
      transparent 0%, #ff4d6d 20%, #c044ff 50%, #4dc8ff 80%, transparent 100%
    );
    background-size: 200% 100%;
    animation: rgb-h 4s linear infinite;
    pointer-events: none;
  }

  body.dark-mode .current-week {
    color: #ff4d6d !important;
    text-shadow: 0 0 14px rgba(255,77,109,0.55) !important;
  }

  body.dark-mode .week-range {
    color: rgba(144,128,184,0.65) !important;
  }

  body.dark-mode .week-nav-btn {
    background: linear-gradient(135deg,
      rgba(220,60,80,0.78) 0%, rgba(160,16,40,0.90) 100%
    ) !important;
    border: 1px solid rgba(255,130,150,0.20) !important;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.14),
      0 0 16px rgba(255,77,109,0.38) !important;
  }

  body.dark-mode .week-nav-btn:active {
    transform: scale(0.93) !important;
    background: rgba(255,77,109,0.55) !important;
  }

  /* ── ИКОНКА КАЛЕНДАРЯ В WEEK-SWITCHER ── */
  body.dark-mode .today-btn {
    background: rgba(22,10,40,0.85) !important;
    color: #ff4d6d !important;
    border: 1px solid rgba(255,77,109,0.28) !important;
    box-shadow: 0 0 12px rgba(255,77,109,0.20) !important;
  }

  body.dark-mode .today-btn svg {
    color: #ff4d6d !important;
    filter: drop-shadow(0 0 4px rgba(255,77,109,0.50)) !important;
  }

  body.dark-mode .today-btn:active {
    background: rgba(255,77,109,0.22) !important;
    transform: scale(0.94) !important;
  }

  /* ── СТАТИСТИКА (мобильная) ── */
  body.dark-mode .stats-container {
    background: rgba(14,7,28,0.90) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255,255,255,0.07) !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.60) !important;
  }

  /* Убираем двойной фон в stats-bar внутри container */
  body.dark-mode .stats-container .stats-bar {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* ── КОНТЕЙНЕР ── */
  body.dark-mode .container {
    background: transparent !important;
  }

  /* schedule-wrapper прозрачный в тёмной теме */
  body.dark-mode .schedule-wrapper {
    background: transparent !important;
    border-color: rgba(120,80,200,0.14) !important;
    box-shadow: none !important;
  }

  /* ── MOBILE-TIME TOGGLE ── */
  body.dark-mode .mobile-time:active {
    background: rgba(192,68,255,0.10) !important;
  }

  body.dark-mode .mobile-time.time-numbered .slot-start,
  body.dark-mode .mobile-time.time-numbered .slot-end {
    color: #ff4d6d !important;
  }

}

/* Мобильная кнопка темы отключена */
.theme-toggle-stats { display: none !important; }


@media (max-width: 768px) {
  .mobile-room-capacity-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    height: 38px;
    border: 2px solid var(--primary, #B74D3F);
    border-radius: 10px;
    background: white;
    color: var(--primary, #B74D3F);
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .mobile-room-capacity-lbl {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.75;
    margin-top: 1px;
  }

  body.dark-mode .mobile-room-capacity-badge {
    background: #1e1624;
    border-color: #c9756a;
    color: #c9756a;
  }

  /* Скрыть блок "Мест" из сетки статистики — показывается только кнопкой справа */
  #stat-room-capacity-block {
    display: none !important;
  }

  /* Унифицировать толщину рамок кнопок — 1.5px */
  #export-ics-btn,
  #export-print-btn,
  #mobile-theme-btn {
    border-width: 1.5px !important;
  }

  #mobile-theme-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 2px solid var(--primary);
    border-radius: 10px;
    background: white;
    color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
  }

  #mobile-theme-btn:active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
  }

  body.dark-mode #mobile-theme-btn {
    background: rgba(30,20,50,0.8);
    border-color: rgba(183,77,63,0.6);
    color: rgba(220,180,170,0.9);
  }

  .stats-toggle-mobile-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    margin-bottom: 0;
  }
  .stats-toggle-mobile-btn svg { transition: transform 0.3s; }
  .stats-toggle-mobile-btn.expanded svg { transform: rotate(180deg); }

}