/* Overlays: menus and pickers, windows, notifications (docs/VIEW-DESIGN.md §4, mock 2). Markup: views/overlays.js. */
/* a picker (mock 2): the field's name on top; «Отмена» and «Сохранить» at the foot, no line above them */
.pop-title { padding: 8px 8px 6px; color: var(--text); font-size: var(--fs-body); font-weight: 600; }
.pop-foot { display: flex; align-items: center; gap: 8px; padding: 10px 6px 6px; }
.pop-foot .spacer { flex: 1; }
.pop-foot .btn { height: 32px; padding: 0 14px; }
.popover .opt .ref-num { flex: none; color: var(--text-4); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.popover .opt .opt-ic > .avatar { width: 20px; height: 20px; }
.backdrop {
  position: fixed; inset: 0; background: var(--scrim); z-index: 50; display: flex; align-items: flex-start;
  justify-content: center; padding: min(12vh, 96px) 16px 16px; animation: fade 0.12s ease-out;
}
.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - min(12vh, 96px) - 16px); display: flex; flex-direction: column; background: var(--elev); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: pop 0.14s ease-out; overflow: auto; }
.modal > .modal-head, .modal > .modal-foot { flex: none; }
.modal > .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 4px; color: var(--text-3); font-size: var(--fs-body); }
.modal-body { padding: 10px 20px 16px; }
.modal-title-input { width: 100%; border: none; outline: none; background: transparent; font-size: var(--fs-title-m); font-weight: 600; padding: 6px 0; letter-spacing: -0.01em; }
.modal-desc { width: 100%; border: none; outline: none; background: transparent; resize: none; min-height: 64px; color: var(--text-2); line-height: 1.5; font-size: var(--fs-read); }
.modal-props { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 0; }
.modal-foot .spacer { flex: 1; }
.popover {
  position: fixed; z-index: 60; width: 300px; max-height: 340px; background: var(--elev); border-radius: var(--r-md);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: pop 0.1s ease-out;
}
.popover input { border: none; border-bottom: 1px solid var(--border-soft); background: transparent; outline: none; padding: 10px 12px; }
/* the search of a picker (mock 2 .pv-in): a field of its own, 34 px, a thin frame, under the field's name */
.popover > .pop-search { flex: none; height: 34px; margin: 0 6px 4px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--base); }
.popover > .pop-search:first-child { margin-top: 6px; }
.popover .opts { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.opt { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text); cursor: pointer; }
.popover.menu button.opt { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; }
.opt.hl { background: var(--hover); }
@media (hover: hover) {
  .opt:hover, .popover.menu button.opt:hover { background: var(--hover); }
}
.opt .check { margin-left: auto; color: var(--accent-text); }
.opt > span:first-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .hint { color: var(--text-4); font-size: var(--fs-caption); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; flex: 0 1 auto; }
.opt-group { padding: 8px 8px 4px; font-size: var(--fs-caption); font-weight: 500; color: var(--text-4); letter-spacing: .04em; text-transform: uppercase; }
.opt-group:first-child { padding-top: 4px; }
.opt-empty { padding: 14px 8px; color: var(--text-4); font-size: var(--fs-body); }
#toasts { position: fixed; bottom: 16px; right: 16px; z-index: 80; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 8px; pointer-events: none; }
/* a notice (Vlad, 12.11.2026): one style for all — the frosted glass of the windows on the current theme (not a white
   sheet on a light page), the kind told by the icon's shape: a filled circle of the brand colour with a check — done, «i» — information,
   a triangle with round corners — a warning, a circle — an error; no other colours */
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(400px, calc(100vw - 32px)); padding: 9px 14px 9px 10px; border-radius: var(--r-full);
  background: color-mix(in lch, var(--elev2) 80%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.2); backdrop-filter: blur(22px) saturate(1.2);
  color: var(--text); box-shadow: var(--toast-shadow); font-size: var(--fs-body); font-weight: 500; line-height: 1.35; }
.toast.loud { padding-right: 9px; }
.toast.multi { border-radius: var(--r-lg); }
.toast-ic { flex: none; width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-2); }
.toast-ic svg { width: 18px; height: 18px; }
.toast-ic.ok { width: 18px; height: 18px; margin: 1px; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); }
.toast-ic.ok svg { width: 12px; height: 12px; stroke-width: 2; }
.toast-t { min-width: 0; overflow-wrap: anywhere; }
.toast-x { flex: none; width: 26px; height: 26px; border: 0; padding: 0; border-radius: var(--r-full); background: none; color: var(--text-3); display: grid; place-items: center; cursor: pointer; }
.toast-x .i { width: 14px; height: 14px; }
/* an action in a notice («Отменить»): a soft accent pill at the end */
.toast-act { flex: none; height: 26px; margin: -2px -5px -2px 2px; padding: 0 11px; border: 0; border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent-text); font: inherit; font-weight: 500; cursor: pointer; }
.toast-act:active { background: var(--accent-soft-2); }
.toast-x:active { background: var(--active); }
@media (hover: hover) {
  .toast-x:hover { background: var(--hover); color: var(--text-2); }
}
@media (max-width: 860px) {
  #toasts { top: calc(env(safe-area-inset-top, 0px) + 8px); bottom: auto; left: 8px; right: 8px; flex-direction: column; align-items: center; }
  .toast, .toast.loud { width: 100%; max-width: 440px; border-radius: var(--r-lg); padding: 11px 16px 11px 11px; font-size: var(--fs-body); }
  .toast-x { display: none; }
}
.modal-wide { width: min(760px, calc(100vw - 32px)); }
.modal-wide .rich-body { border: 1px solid var(--border); margin: 0; padding: 10px 12px; min-height: 140px; }
/* mock 2: the scrim is a light dim with a soft blur; a window grows from the button that opened it (scale .6 → 1,
   its transform-origin set at the press) and on closing fades and shrinks a little */
.backdrop { background: var(--scrim-modal); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade var(--t) var(--ease); }
.backdrop:has(> .cmdk) { background: var(--scrim); }
.modal { animation: modal-in var(--t-slow) var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: scale(.6); } }
.backdrop.out { opacity: 0; transition: opacity 140ms var(--ease); }
.backdrop.out > .modal { opacity: 0; transform: scale(.97); transition: opacity 140ms var(--ease), transform 140ms var(--ease); }
@media (max-width: 860px) {
  .backdrop.out > .modal { opacity: 1; transform: translateY(105%); transition: transform 180ms var(--ease); }
}
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }
.toast { animation: toast-in var(--t) var(--ease); }
@media (max-width: 860px) {
  .toast { animation-name: toast-drop; }
}
.toast.out { animation: fade-out 160ms var(--ease) forwards; }
@media (max-width: 860px) {
  .backdrop { align-items: flex-end !important; padding: 0 !important; }
  .backdrop > .modal { width: 100% !important; max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92dvh; overflow: auto; animation: sheet-up 420ms var(--spring); padding-bottom: env(safe-area-inset-bottom); }
  .backdrop > .modal::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 0; }
}
.popover { min-width: 260px; max-width: min(380px, calc(100vw - 16px)); width: auto; }
.popover.menu { width: auto; min-width: 210px; max-width: min(300px, calc(100vw - 16px)); }
.popover.menu .opts { padding: 6px; }
.popover.menu .opt { min-height: 34px; padding: 0 8px; gap: 9px; font-size: var(--fs-body); }
.popover.menu .opt-l { flex: 1 1 auto; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popover.menu .m-ic { display: inline-flex; color: var(--icon); flex: none; }
.popover.menu .m-kbd { display: inline-flex; gap: 3px; margin-left: 12px; flex: none; }
.popover.menu .opt.danger .opt-l, .popover.menu .opt.danger .m-ic { color: var(--red, #d64545); }
.popover.menu .m-sep { height: 1px; background: var(--border-soft); margin: 4px -4px; }
.popover.menu .m-head { display: flex; align-items: center; gap: 9px; padding: 6px 8px; min-width: 0; }
.popover.menu .m-head > span:not(.avatar) { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.popover.menu .m-head b { font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover.menu .m-head b + span { font-size: var(--fs-caption); color: var(--text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover.dpk { width: 264px; min-width: 0; padding: 6px; max-height: calc(100dvh - 16px); overflow-y: auto; }
.modal-head .spacer { flex: 1; }
.modal-head .btn.ic { width: 28px; height: 28px; padding: 0; justify-content: center; color: var(--text-3); }
.modal-desc-ed { margin-top: 2px; }
.modal-desc-ed .rich-body { min-height: 72px; margin: 0; padding: 4px 0; font-size: var(--fs-read); }
.modal-desc-ed.rich.editable .rich-body:focus { background: transparent; box-shadow: none; }
@media (hover: hover) {
  .modal-desc-ed.rich.editable .rich-body:hover { background: transparent; box-shadow: none; }
}
.modal .composer-files { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.modal .composer-files:empty { display: none; }
.modal-foot .btn.ic { width: 30px; padding: 0; justify-content: center; color: var(--text-3); }
.backdrop:has(> .modal.modal-full) { align-items: center; padding: 32px 16px; }
.modal.modal-full { width: min(1100px, calc(100vw - 32px)); height: calc(100dvh - 64px); max-height: calc(100dvh - 64px); }
.modal.modal-full > .modal-body { display: flex; flex-direction: column; }
.modal.modal-full .modal-desc-ed { flex: 1 1 auto; display: flex; flex-direction: column; }
.modal.modal-full .modal-desc-ed .rich-body { flex: 1 1 auto; }
.modal.modal-full .modal-title-input { font-size: var(--fs-title-l); }
@media (max-width: 860px) {
  .backdrop > .modal.modal-full { height: 100dvh; max-height: 100dvh; border-radius: 0; }
}
.popover.menu .m-head > .avatar { width: 28px; height: 28px; font-size: var(--fs-caption); }
.sheet-opts { display: grid; gap: 2px; }
.backdrop > .modal.sheet-back { transition: transform .2s var(--ease); }
@media (pointer: coarse) {
  .popover.menu .opt { min-height: 44px; }
}
@media (max-width: 860px) {
  .modal-foot:has(> .access-switch) { flex-wrap: wrap; }
}
.popover, .modal { background: color-mix(in lch, var(--elev) 88%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.2); backdrop-filter: blur(22px) saturate(1.2); }
.popover.wait-pop { width: auto; min-width: 280px; max-width: min(420px, calc(100vw - 32px)); }
.popover .opt .opt-ic { display: inline-flex; flex: none; align-items: center; justify-content: center; min-width: 16px; color: var(--text-3); }
.popover .opt .opt-ic svg, .popover .opt .opt-ic .i { width: 15px; height: 15px; }
.popover.help-pop { width: min(340px, calc(100vw - 32px)); max-height: none; padding: 12px 14px; gap: 6px; }
.popover.value-pop { width: 260px; max-height: none; }
.popover.value-pop input { border: none; border-bottom: 0; padding: 6px 12px 10px; font-size: var(--fs-body); color: var(--text); }
@media (max-width: 860px) {
  .modal-foot .create-hint { display: none; }
}

/* the agent's screen on a computer: notices stay at the bottom right, but no wider than the column of chats there —
   a wider one would lie over «Отправить» of the message field (a long text wraps instead) */
@media (min-width: 861px) {
  body:has(#content > .agent) .toast { max-width: 292px; }
}
