/* МелМК — карточки, виджеты, модалки, empty */
.now-widget {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface-grad);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  animation: fade-up 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.now-widget::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--hero-grad);
  border-radius: 4px 0 0 4px;
}

.now-widget__label {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.now-widget__title {
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  margin-top: var(--space-1);
  letter-spacing: -0.03em;
}

.now-widget__meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
  font-weight: 500;
}

.now-widget__timer {
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  font-weight: 700;
  color: var(--now);
  margin-top: var(--space-2);
}

.now-widget__grid {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 600px) {
  .now-widget__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.lesson-card {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--transition),
    background var(--transition),
    transform 160ms ease,
    box-shadow var(--transition);
  animation: fade-up 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow: hidden;
}

.lesson-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--hero-grad);
}

.lesson-card:active {
  transform: scale(0.995);
}

.lesson-card.is-now {
  border-color: color-mix(in srgb, var(--now) 55%, var(--border));
  box-shadow: var(--shadow-glow);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 8%, var(--bg-elev)),
    var(--bg-elev) 55%
  );
}

.lesson-card.is-now::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--now);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--now) 50%, transparent);
  animation: mm-pulse 1.8s ease-out infinite;
}

.lesson-card.is-changed {
  background: var(--changed);
  border-color: color-mix(in srgb, var(--accent-3) 35%, var(--border));
}

.lesson-card__time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  padding-right: var(--space-3);
  gap: 2px;
}

.lesson-card__pair {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.04em;
}

.lesson-card__subject {
  font-weight: 800;
  font-size: clamp(0.95rem, 3.2vw, 1.05rem);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.lesson-card__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lesson-card__row > span:not(.badge) {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}


.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-muted);
  color: var(--text-muted);
  border: 1px solid transparent;
}

.badge--lecture { background: color-mix(in srgb, var(--type-lecture) 16%, transparent); color: var(--type-lecture); }
.badge--practice { background: color-mix(in srgb, var(--type-practice) 16%, transparent); color: var(--type-practice); }
.badge--lab { background: color-mix(in srgb, var(--type-lab) 16%, transparent); color: var(--type-lab); }
.badge--exam { background: color-mix(in srgb, var(--type-exam) 16%, transparent); color: var(--type-exam); }
.badge--consult { background: color-mix(in srgb, var(--type-consult) 16%, transparent); color: var(--type-consult); }
.badge--replaced {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  animation: fade-up 420ms ease both;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  border: 1px dashed var(--border);
}

.empty-state__art {
  width: min(220px, 70vw);
  height: auto;
  margin: 0 auto var(--space-4);
  filter: drop-shadow(0 12px 24px rgb(91 77 255 / 20%));
}

.empty-state__title {
  font-size: clamp(1.15rem, 4vw, 1.4rem);
  margin-bottom: var(--space-2);
}

.empty-state__text {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  max-width: 360px;
  margin-inline: auto;
  font-weight: 500;
}

.empty-state__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 320px;
  margin: 0 auto;
}

/* Модалка → bottom-sheet на мобиле */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  padding-bottom: 0;
  animation: fade-in 200ms ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: var(--space-4);
  }
}

.modal {
  width: min(100%, 540px);
  max-height: min(90dvh, 760px);
  overflow: auto;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 28px 28px 0 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-5) + var(--safe-bottom));
  box-shadow: var(--shadow-md);
  animation: slide-up 280ms cubic-bezier(0.22, 1, 0.36, 1);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  position: relative;
}

.modal::before {
  content: "";
  display: block;
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 14px;
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-lg);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: var(--space-4);
  }
  .modal::before {
    display: none;
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.modal__title {
  font-size: 1.2rem;
}

.stats-panel {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat-box {
  text-align: center;
  padding: var(--space-3);
  background: linear-gradient(180deg, var(--accent-soft), var(--bg-muted));
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border));
}

.stat-box__value {
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent);
}

.stat-box__label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.chart-wrap svg {
  width: 100%;
  height: auto;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--touch);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: none;
}

.section-title {
  font-size: clamp(1.1rem, 3.5vw, 1.25rem);
  margin-bottom: var(--space-3);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.chip {
  min-height: 40px;
  min-width: 44px;
  padding: 0 var(--space-3);
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: transform 120ms ease, background var(--transition), color var(--transition);
  box-shadow: var(--shadow-sm);
}

.chip:active {
  transform: scale(0.97);
}

.chip.is-active {
  background: var(--hero-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 30%, transparent);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  overflow-x: auto;
  display: block;
  border-radius: var(--radius-md);
}

.preview-table th,
.preview-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.preview-table th {
  background: var(--bg-muted);
  position: sticky;
  top: 0;
}

.map-grid {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .map-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 380px) {
  .lesson-card {
    grid-template-columns: 60px 1fr;
    padding: var(--space-3);
  }
  .stats-grid {
    gap: var(--space-2);
  }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(28px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mm-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--now) 45%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .lesson-card.is-now::after {
    animation: none;
  }
}
