/* Тосты, переключатели, адаптив.
   Часть styles.css; порядок подключения в HTML = порядок каскада, менять нельзя. */

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(9, 12, 16, 0.96);
  box-shadow: var(--shadow);
}

.toast.error {
  border-color: rgba(239, 102, 102, 0.35);
}

.toast.success {
  border-color: rgba(47, 125, 255, 0.35);
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  display: inline-flex;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.switch span::before {
  content: "";
  position: absolute;
  box-sizing: border-box;
  top: 50%;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transform: translateY(-50%);
  transition: 180ms ease;
}

:root[data-theme="light"] .switch span {
  background: #e4e9f0;
  border-color: rgba(15, 23, 42, 0.18);
}

:root[data-theme="light"] .switch span::before {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.switch input:checked + span {
  background: rgba(47, 125, 255, 0.24);
}

:root[data-theme="light"] .switch input:checked + span {
  background: rgba(31, 111, 255, 0.26);
  border-color: rgba(31, 111, 255, 0.34);
}

.switch input:checked + span::before {
  transform: translate(18px, -50%);
  background: var(--accent-strong);
}

@keyframes shimmer {
  to {
    background-position-x: -200%;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.84;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .workspace {
    min-height: auto;
    height: auto;
  }

  body {
    height: auto;
    overflow: auto;
  }

  .sidebar {
    position: static;
    overflow: visible;
  }
}

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

  .workspace,
  .panel {
    padding: 14px;
  }

  .reference-card {
    width: 100%;
  }

  .workspace-header,
  .workspace-meta,
  .thread-activity,
  .workspace-toolbar,
  .panel-header,
  .generation-group-header,
  .field-row,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .thread-activity-users {
    justify-content: stretch;
  }

  .thread-user {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    width: 100%;
  }

  .workspace-toolbar {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .theme-toggle,
  .limit-ribbon,
  .logout-button,
  .workspace-toolbar .header-actions {
    justify-self: stretch;
    width: 100%;
  }

  .theme-toggle {
    justify-self: end;
    width: 36px;
  }

  .limit-ribbon {
    justify-content: center;
    overflow-x: auto;
  }

  .generation-group-title {
    font-size: 1.18rem;
  }

  .generation-dialog-panel {
    width: min(100% - 20px, 460px);
    margin-top: 72px;
    padding: 16px 14px 14px;
  }

  .generation-dialog-actions {
    flex-direction: column-reverse;
  }

  .generation-dialog-confirm,
  .generation-dialog-actions .ghost-button {
    width: 100%;
  }

  .media-viewer-shell {
    padding: 10px;
  }

  .media-viewer-stage {
    padding: 0 44px;
  }

  .media-viewer-nav {
    width: 40px;
    height: 40px;
  }

  .media-viewer-image {
    max-width: 100%;
    max-height: calc(100vh - 280px);
  }

  .media-viewer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  /* Тулбар остаётся компактной строкой поверх картинки даже на узких экранах. */
  .media-viewer-topbar {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .media-viewer-submeta {
    justify-content: flex-start;
  }
}