/* One overlay layer, independent of cards, sidebars and page scrolling. */
:root{--overlay-top:0px;--overlay-left:0px;--overlay-width:100vw;--overlay-height:100dvh}
#modal-root{position:relative;z-index:100}
.modal-backdrop{position:fixed;inset:auto;top:var(--overlay-top);left:var(--overlay-left);width:var(--overlay-width);height:var(--overlay-height);z-index:100;display:grid;place-items:center;overflow:hidden;padding:24px 24px 84px;background:rgb(19 46 37 / .48);backdrop-filter:blur(4px)}
.modal{position:relative;display:flex;flex-direction:column;width:min(620px,100%);max-width:100%;max-height:calc(var(--overlay-height) - 108px);margin:0;overflow:hidden;border:1px solid rgb(255 255 255 / .7);border-radius:18px;box-shadow:0 24px 80px #10261b40;min-width:0}
.modal>.card-head{position:relative;top:auto;display:flex;flex-wrap:nowrap;align-items:center;flex-shrink:0;gap:16px;padding:18px 22px;z-index:2;background:white}
.modal>.card-head h2{flex:1;min-width:0;margin:0;font-size:19px;line-height:1.45;overflow-wrap:anywhere}
.modal>.card-head .close{display:grid;place-items:center;flex-shrink:0;width:40px;height:40px;margin:0;padding:0;border:1px solid var(--line);border-radius:10px;font-size:25px;line-height:1;color:#62736b;background:#f7f9f3}
.modal>.card-head .close:hover{background:#edf2e6;color:var(--ink)}
.modal>.card-body{flex:1;min-height:0;padding:22px;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable}
.modal form{min-width:0}.modal .form-grid{min-width:0}.modal .field{min-width:0}.modal input,.modal select,.modal textarea{min-width:0;max-width:100%;box-sizing:border-box}
.modal form>.actions{position:sticky;bottom:-22px;display:flex;flex-wrap:wrap;justify-content:flex-end;gap:10px;margin:12px -22px -22px;padding:16px 22px;background:white;border-top:1px solid var(--line);box-shadow:0 -8px 18px #ffffffd9;z-index:1}
.modal form>.actions .btn{min-height:44px}.modal .error:empty{display:none}.modal .error:not(:empty){padding:11px 13px;background:#fff3ef;border:1px solid #f0d5cb;border-radius:9px;margin-bottom:16px;overflow-wrap:anywhere}
.dialog-open{overflow:hidden}.dialog-open .topbar{pointer-events:none}
#toast{position:fixed;inset:auto;top:auto;right:auto;bottom:calc(18px + env(safe-area-inset-bottom,0px));left:calc(var(--overlay-left) + var(--overlay-width) / 2);transform:translateX(-50%);z-index:150;width:max-content;max-width:min(460px,calc(var(--overlay-width) - 32px));min-width:0;margin:0;padding:0;border:1px solid #50715c;background:#234e3e;color:#fff;border-radius:12px;box-shadow:0 8px 28px #14321e30;font-size:13px;line-height:1.6;display:none;overflow:hidden}
#toast.visible{display:flex;align-items:center;gap:12px;padding:12px 14px;animation:toast-in .16s ease-out}
.toast-message{min-width:0;overflow-wrap:anywhere}.toast-mark{display:grid;place-items:center;width:23px;height:23px;flex-shrink:0;border-radius:50%;background:#ffffff20;font-weight:600;font-size:14px}.toast-close{display:grid;place-items:center;width:32px;height:32px;padding:0;flex-shrink:0;border-radius:8px;color:#fff;font-size:21px;background:#ffffff0c}.toast-close:hover{background:#ffffff20}.toast-close:focus-visible{outline:2px solid var(--lime);outline-offset:-3px}
@keyframes toast-in{from{opacity:0;transform:translateX(-50%) translateY(5px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}
@media(max-width:760px){.modal-backdrop{padding:16px 16px 80px}.modal{max-height:calc(var(--overlay-height) - 96px);border-radius:16px}.modal>.card-head{padding:15px 18px}.modal>.card-head h2{font-size:18px}.modal>.card-body{padding:18px}.modal form>.actions{bottom:-18px;margin:12px -18px -18px;padding:14px 18px}}
@media(max-width:420px){.modal-backdrop{padding:12px 12px 78px}.modal{max-height:calc(var(--overlay-height) - 90px);border-radius:14px}.modal>.card-head{padding:13px 15px;gap:10px}.modal>.card-head h2{font-size:17px}.modal>.card-body{padding:16px;scrollbar-gutter:auto}.modal form>.actions{bottom:-16px;margin:12px -16px -16px;padding:12px 16px}.modal form>.actions>.btn{flex:1;min-width:0;white-space:normal}.modal .confirm-actions{flex-wrap:wrap}.modal .confirm-actions>.btn{flex:1}.modal>.card-head .close{width:38px;height:38px}.modal .field{margin-bottom:14px}#toast{max-width:calc(var(--overlay-width) - 24px);bottom:calc(14px + env(safe-area-inset-bottom,0px));font-size:13px}#toast.visible{gap:9px;padding:10px 11px}.toast-close{width:30px;height:30px}}
@media(max-height:480px){.modal-backdrop{padding-top:10px;padding-bottom:70px}.modal{max-height:calc(var(--overlay-height) - 80px)}.modal>.card-head{padding-top:9px;padding-bottom:9px}.modal>.card-head .close{height:34px}.modal>.card-body{padding-top:14px}#toast.visible{padding-top:8px;padding-bottom:8px}}
@media(prefers-reduced-motion:reduce){#toast.visible{animation:none}}
/* Position against the visual viewport instead of the obscured keyboard area. */
#toast{bottom:auto;top:calc(var(--overlay-top) + var(--overlay-height) - 18px - env(safe-area-inset-bottom,0px));transform:translate(-50%,-100%)}
@media(max-width:420px){#toast{bottom:auto;top:calc(var(--overlay-top) + var(--overlay-height) - 14px - env(safe-area-inset-bottom,0px))}}
@keyframes toast-in{from{opacity:0;transform:translateX(-50%) translateY(calc(-100% + 5px))}to{opacity:1;transform:translate(-50%,-100%)}}
@media print{#toast,#modal-root{display:none!important}}
/* Symmetric centering; feedback inside a dialog cannot cover its actions. */
.modal-backdrop{padding:24px;grid-template-columns:minmax(0,1fr);justify-items:center}.modal{width:min(620px,calc(var(--overlay-width) - 48px));max-width:100%;max-height:calc(var(--overlay-height) - 112px)}
.dialog-feedback{display:flex;align-items:center;gap:10px;flex-shrink:0;padding:12px 20px;background:#edf5e8;color:#365c3d;border-bottom:1px solid #d7e5cd;font-size:13px;line-height:1.55;overflow-wrap:anywhere}.dialog-feedback[data-kind="error"]{background:#fff0ea;color:#954538;border-color:#eed0c4}.dialog-feedback .toast-close{margin-left:auto;color:inherit;background:#00000008}.dialog-feedback .toast-message{flex:1}
#toast[data-kind="error"]{background:#873f35;border-color:#a76960}
@media(max-width:760px){.modal-backdrop{padding:16px}.modal{width:min(620px,calc(var(--overlay-width) - 32px));max-height:calc(var(--overlay-height) - 96px)}}
@media(max-width:420px){.modal-backdrop{padding:12px}.modal{width:min(620px,calc(var(--overlay-width) - 24px));max-height:calc(var(--overlay-height) - 84px)}.dialog-feedback{padding:11px 15px}}
@media(max-height:480px){.modal-backdrop{padding:10px}.modal{max-height:calc(var(--overlay-height) - 40px)}}
.modal>.card-body{scroll-padding-bottom:90px}.modal input,.modal textarea,.modal select{scroll-margin-bottom:85px}
#toast.visible{animation:none}

/* Narrow dialog actions keep whole words and usable touch targets. */
@media(max-width:420px){.modal form>.actions{display:grid;grid-template-columns:1fr}.modal form>.actions>.btn{width:100%;white-space:normal;overflow-wrap:normal;word-break:normal;min-height:44px}.modal>.card-body{scroll-padding-bottom:125px}}

/* Keep dialog controls reachable without shrinking labels or touch targets. */
.modal>.card-head .close{width:44px;height:44px;min-width:44px;min-height:44px}
.modal>.card-head h2{word-break:normal;overflow-wrap:break-word}
.modal>.card-head h2:focus{outline:none}
.modal label{font-size:14px}
.modal input,.modal select,.modal textarea{font-size:16px;line-height:1.45}
.modal .btn{line-height:1.4;white-space:normal;min-height:44px}
.dialog-feedback{font-size:14px}
.toast-close{width:40px;height:40px;min-width:40px;min-height:40px}
#toast{font-size:14px}
.modal.video-modal{width:min(880px,calc(var(--overlay-width) - 48px))}
.video-modal>.card-body{scroll-padding-bottom:24px}
.video-modal .video-stage{aspect-ratio:16/9;max-height:360px;margin:16px 0;background:#15392f}
.video-placeholder{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:20px;text-align:center;color:#e9f2e9;pointer-events:none}
.video-placeholder strong{font-size:17px;line-height:1.4}
.video-placeholder>span:last-child{font-size:14px;line-height:1.5;color:#c4d7ca;max-width:300px}
.video-placeholder-icon svg{display:block;width:40px;height:40px}
.video-stage.has-remote .video-placeholder{display:none}
.video-stage #local-video{z-index:1;width:26%;height:30%;min-width:64px;min-height:46px}
.local-video-label{position:absolute;right:20px;bottom:18px;padding:2px 6px;border-radius:4px;background:#16372ecc;color:white;font-size:11px;line-height:1.4;z-index:2}
.video-modal>.call-controls{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;flex-shrink:0;padding:16px 22px;background:#fff;border-top:1px solid var(--line)}
.video-modal .call-controls>.btn{min-width:0;width:100%;min-height:46px;font-size:14px;white-space:normal;word-break:normal;line-height:1.35;padding:10px 12px}
.video-modal .care-notice{margin:14px 0}
@media(max-width:760px){
  .modal.video-modal{width:min(880px,calc(var(--overlay-width) - 32px))}
  .video-modal .video-stage{max-height:280px}
  .video-modal>.call-controls{padding:14px 18px}
}
@media(max-width:420px){
  .modal.video-modal{width:calc(var(--overlay-width) - 24px)}
  .video-modal .video-stage{aspect-ratio:4/3;max-height:210px}
  .video-placeholder{padding:16px 12px;gap:7px}
  .video-placeholder strong{font-size:15px}
  .video-placeholder>span:last-child{font-size:13px;max-width:180px}
  .video-placeholder-icon svg{width:30px;height:30px}
  .video-modal>.call-controls{grid-template-columns:repeat(2,minmax(0,1fr));padding:12px 16px;gap:8px}
  .video-modal .call-controls>.btn{min-height:46px;padding:9px 7px;font-size:13px}
  .video-modal .sub{font-size:13px;line-height:1.55}
}
@media(max-height:480px){
  .video-modal .video-stage{max-height:160px}
  .video-modal>.call-controls{padding-top:10px;padding-bottom:10px}
}
