/* Слои поверх экрана: листы (телефон) и модалки (планшет, десктоп), подтверждения, поповеры, тосты.
   Один компонент листа: на телефоне выезжает снизу с ручкой, на широком экране становится модалкой по центру. */

.layer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 95; animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes pin { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- модалка (>= 768) */
.sheet { position: fixed; z-index: 96; left: 50%; top: 9vh; transform: translateX(-50%); width: min(var(--sheet-w, 440px), calc(100vw - 32px)); max-height: 82vh;
  display: flex; flex-direction: column; border-radius: 18px; background: var(--glass); overflow: hidden;
  -webkit-backdrop-filter: blur(36px) saturate(1.5); backdrop-filter: blur(36px) saturate(1.5);
  box-shadow: 0 0 0 1px var(--sep), 0 30px 80px var(--shadow); animation: pin .16s ease-out; }
.sheet.solid { background: var(--surface); }
.sheet .grab { display: none; }
.sheet-top { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 18px; }
.sheet-top .ttl { font-weight: 650; font-size: 15px; flex: 1; min-width: 0; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 18px 18px; font-size: 13px; line-height: 1.5; color: var(--fg2); }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 18px 16px; }

/* действия (меню в листе, подтверждение) */
.acts { display: flex; flex-direction: column; gap: 2px; }
.act { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 9px; text-align: left; font-size: 13px; color: var(--fg); }
.act:hover { background: var(--accent-soft); }
.act .hint { margin-left: auto; color: var(--fg3); font-size: 12px; }
.act.danger { color: var(--red); }
.act:disabled { opacity: .4; pointer-events: none; }

/* ---------- поповер */
.pop-wrap { position: relative; display: inline-flex; }
.pop-catch { position: fixed; inset: 0; z-index: 129; }
.pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 130; min-width: 220px; max-width: 340px; max-height: 520px; overflow-y: auto; padding: 6px;
  border-radius: 14px; background: var(--glass); -webkit-backdrop-filter: blur(30px) saturate(1.6); backdrop-filter: blur(30px) saturate(1.6);
  box-shadow: 0 0 0 1px var(--sep), 0 16px 44px var(--shadow); animation: pin .14s ease-out; }
.pop.right { left: auto; right: 0; }
.ph5 { font-size: 11px; font-weight: 600; color: var(--fg3); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px 4px; }

/* ---------- тосты */
.toasts { position: fixed; left: calc(var(--side-w) + 24px); bottom: 22px; z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none; }
.side-collapsed .toasts { left: calc(var(--rail-w) + 24px); }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 14px; max-width: 560px; pointer-events: auto;
  background: var(--toast-bg); color: var(--toast-fg); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); font-size: 12.5px;
  box-shadow: 0 10px 30px var(--shadow); animation: pin .2s; }
.toast .tx { flex: 1; min-width: 0; }
.toast .undo { color: var(--toast-link); font-weight: 650; }
.toast .x { opacity: .7; padding: 2px 4px; }

@media (min-width: 768px) and (max-width: 1279.98px) {
  .toasts { left: calc(var(--rail-w) + 24px); }
}

/* ---------- телефон: лист снизу с ручкой, тост над таб-баром */
@media (max-width: 767.98px) {
  .layer-scrim { background: rgba(0,0,0,.28); }
  .sheet { left: 0; right: 0; top: auto; bottom: 0; width: auto; transform: none; max-height: calc(100dvh - 54px);
    border-radius: 30px 30px 0 0; background: var(--screen); -webkit-backdrop-filter: none; backdrop-filter: none;
    box-shadow: 0 -10px 40px var(--glass-shadow); animation: up .38s cubic-bezier(.2,.9,.25,1);
    padding-bottom: env(safe-area-inset-bottom, 0px); touch-action: pan-y; }
  .sheet.full { max-height: 100dvh; height: 100dvh; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); }
  .sheet.small { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom, 0px)); border-radius: 30px; padding-bottom: 0;
    --gbg: var(--g3); --gblur: var(--b3); background: linear-gradient(180deg, var(--g-hi), rgba(255,255,255,0) 55%), var(--gbg);
    -webkit-backdrop-filter: blur(var(--gblur)) saturate(var(--gsat)); backdrop-filter: blur(var(--gblur)) saturate(var(--gsat));
    box-shadow: inset 0 1px 0 var(--g-hi-line), inset 0 0 0 .5px var(--g-rim), 0 0 0 .5px var(--g-outline), 0 -10px 40px var(--glass-shadow); }
  .sheet .grab { display: flex; justify-content: center; padding: 8px 0 4px; cursor: pointer; touch-action: none; }
  .sheet .grab i { width: 38px; height: 5px; border-radius: 3px; background: var(--fg3); }
  .sheet-top { padding: 2px 14px 6px 20px; }
  .sheet-top .ttl { font-size: 16px; font-weight: 600; }
  .sheet-body { padding: 0 20px 24px; font-size: 15px; scrollbar-width: none; }
  .sheet-foot { padding: 0 20px 20px; }
  .sheet-foot .btn { flex: 1; }
  .act { min-height: 48px; font-size: 16px; padding: 10px 14px; border-radius: 14px; }
  .act.strong { font-weight: 600; justify-content: center; background: var(--surface); }
  .toasts { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); align-items: stretch; }
  .toast { max-width: none; border-radius: 20px; padding: 12px 14px 12px 16px; font-size: 15px; color: var(--fg);
    --gbg: var(--g2); background: linear-gradient(180deg, var(--g-hi), rgba(255,255,255,0) 55%), var(--gbg);
    -webkit-backdrop-filter: blur(var(--b2)) saturate(var(--gsat)); backdrop-filter: blur(var(--b2)) saturate(var(--gsat));
    box-shadow: inset 0 1px 0 var(--g-hi-line), inset 0 0 0 .5px var(--g-rim), 0 0 0 .5px var(--g-outline), 0 8px 28px var(--glass-shadow); }
  .toast .undo { color: var(--accent); font-weight: 600; }
  .pop { position: fixed; left: 8px; right: 8px; top: auto; bottom: max(8px, env(safe-area-inset-bottom, 0px)); max-width: none; border-radius: 22px; }
}
@keyframes up { from { transform: translateY(105%); } }
@media (prefers-reduced-transparency: reduce) {
  .sheet, .sheet.small, .pop, .toast { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .toast { color: var(--fg); }
}

/* ---------- сбой Blazor: полоса снизу, показывает сам Blazor (style="display:block") */
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: 10px max(16px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--red-s); color: var(--fg); box-shadow: 0 -1px 0 var(--sep); font-size: 13px; }
#blazor-error-ui .reload { color: var(--accent); font-weight: 600; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 8px; }
