/* ──────────────────────────────────────────────────────────────
   Оверлеи: шторки, диалоги, контекстные меню, тосты.
   На ПК — карточка по центру, на телефоне — шторка снизу.
   ────────────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease);
}
.scrim[data-open="true"] { opacity: 1; }

/* ── шторка / диалог ─────────────────────────────────────────── */
.sheet {
  position: fixed;
  z-index: calc(var(--z-overlay) + 1);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(.985);
  transition: opacity var(--dur-med) var(--ease), transform var(--dur-med) var(--ease-out);
}

.scrim[data-open="true"] + .sheet,
.sheet[data-open="true"] {
  opacity: 1;
  transform: none;
}

/* ПК: карточка по центру */
@media (min-width: 861px) {
  .sheet {
    left: 50%;
    top: 50%;
    transform: translate(-50%, calc(-50% + 10px)) scale(.985);
    width: min(560px, calc(100vw - 48px));
    max-height: min(760px, calc(100dvh - 80px));
    border-radius: var(--r-lg);
  }
  .scrim[data-open="true"] + .sheet,
  .sheet[data-open="true"] { transform: translate(-50%, -50%); }

  .sheet--sm { width: min(400px, calc(100vw - 48px)); }
  .sheet--lg { width: min(860px, calc(100vw - 48px)); height: min(720px, calc(100dvh - 72px)); }
  .sheet--menu { width: min(300px, calc(100vw - 32px)); }
}

/* Телефон: шторка снизу */
@media (max-width: 860px) {
  .sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: calc(100dvh - 42px);
    padding-bottom: var(--safe-b);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    transform: translateY(100%);
    transition: transform var(--dur-long) var(--ease-out), opacity var(--dur-med) var(--ease);
  }
  .sheet[data-open="true"],
  .scrim[data-open="true"] + .sheet { transform: translateY(0); }

  .sheet--full {
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding-top: var(--safe-t);
  }
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  flex: none;
}
.sheet__title {
  font-size: 1.08em;
  font-weight: 750;
  letter-spacing: -.015em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet__close { flex: none; }

.sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet__body--flush { padding: 0 0 12px; }
.sheet__foot {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.sheet__foot--stack { flex-direction: column; }

/* заголовок раздела внутри шторки */
.sheet-section {
  margin-top: 18px;
}
.sheet-section:first-child { margin-top: 6px; }
.sheet-section__title {
  margin-bottom: 8px;
  padding: 0 2px;
  font-size: .76em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.sheet-section__note {
  margin: -2px 2px 10px;
  font-size: .84em;
  color: var(--text-2);
  line-height: 1.45;
}

/* ── список действий (меню) ──────────────────────────────────── */
.menu-list { display: flex; flex-direction: column; gap: 1px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--text);
  font-size: .96em;
  font-weight: 550;
  transition: background var(--dur) var(--ease);
}
.menu-item:hover { background: var(--panel-2); }
.menu-item:active { background: var(--panel-3); }
.menu-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: var(--text-3);
  flex: none;
}
.menu-item__icon svg { width: 18px; height: 18px; }
.menu-item__label { flex: 1; min-width: 0; }
.menu-item__hint { font-size: .8em; color: var(--text-3); }
.menu-item--danger { color: var(--danger); }
.menu-item--danger .menu-item__icon { color: var(--danger); }
.menu-item[aria-checked="true"] .menu-item__check { color: var(--accent); }

/* ── контекстное меню (ПК) ───────────────────────────────────── */
.ctx {
  position: fixed;
  z-index: calc(var(--z-overlay) + 2);
  min-width: 208px;
  max-width: 260px;
  padding: 5px;
  border-radius: var(--r-md);
  background: var(--elev);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: scale(.96);
  transform-origin: top left;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}
.ctx[data-open="true"] { opacity: 1; transform: none; }
.ctx .menu-item { padding: 8px 10px; font-size: .92em; }
.ctx .menu-item__icon { width: 18px; }
.ctx .menu-item__icon svg { width: 16px; height: 16px; }

/* ── тосты ───────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--elev);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-size: .88em;
  font-weight: 500;
  animation: toast-in var(--dur-med) var(--ease-out) both;
}
.toast--out { animation: toast-out var(--dur) var(--ease) both; }
.toast svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.toast--error svg { color: var(--danger); }
.toast--ok svg { color: var(--ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px) scale(.97); }
}

/* ── простое подтверждение ───────────────────────────────────── */
.dialog-text {
  font-size: .95em;
  color: var(--text-2);
  line-height: 1.5;
  padding: 2px 0 4px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}
.dialog-actions .btn { min-width: 96px; }

@media (max-width: 860px) {
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; }
  .toasts { bottom: calc(14px + var(--safe-b)); }
}
