/* Goodies · Live collaboration (R08) — brand tokens come from index.html (:root) */

/* ---------- header button ---------- */
.live-btn{position:relative;border-radius:999px;min-height:42px;padding:6px 14px 6px 8px;gap:6px}
.live-btn .live-ic{display:inline-flex;width:30px;height:30px;align-items:center;justify-content:center;border-radius:999px;color:var(--ink-2)}
.live-btn .live-ic svg{width:19px;height:19px}
.live-btn::after{content:"";position:absolute;right:9px;top:8px;width:7px;height:7px;border-radius:50%;background:var(--ink-3);box-shadow:0 0 0 2px var(--paper);opacity:.55}
.live-btn[data-cloud=on]::after{background:#4c9a5b;opacity:1}
.live-btn[data-cloud=fail]::after{background:#c4573f;opacity:1}
.live-btn.has .live-ic{display:none}
.live-btn[aria-expanded=true]{background:var(--pink)}
.live-avs{display:flex;padding-left:6px}
.live-avs:empty{display:none}
.live-avs i{width:30px;height:30px;margin-left:-8px;border-radius:50%;background:var(--c);color:#fff;font:700 12px/30px Raleway,Arial,sans-serif;font-style:normal;text-align:center;box-shadow:0 0 0 2px var(--paper)}
.live-avs i.on{box-shadow:0 0 0 2px var(--paper),0 0 0 4px var(--c)}
.live-avs i.more{background:var(--ink-2)}
.live-count{font-size:13px;font-weight:700;color:var(--ink)}
.live-count:empty{display:none}

/* ---------- panel ---------- */
#livePanel{position:absolute;z-index:30;top:118px;right:22px;width:340px;max-width:calc(100vw - 44px);max-height:calc(100dvh - 140px);overflow:auto;border-radius:var(--r-lg);padding:18px 18px 16px;display:flex;flex-direction:column;gap:12px;overscroll-behavior:contain}
#livePanel .lp-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px}
#livePanel h2{font-size:30px;line-height:1.05;margin-top:2px}
#livePanel .eyebrow{font-size:11px;letter-spacing:.14em;text-transform:uppercase;font-weight:700;color:var(--ink-3)}
.lp-body{display:flex;flex-direction:column;gap:10px}
.lp-status{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--ink-2);background:rgba(255,255,255,.7);border-radius:12px;padding:8px 11px;box-shadow:inset 0 0 0 1px var(--line)}
.lp-status i{width:8px;height:8px;border-radius:50%;background:var(--ink-3);flex:none}
.lp-status[data-s=cloud] i{background:#4c9a5b;box-shadow:0 0 0 3px rgba(76,154,91,.18)}
.lp-status[data-s=local] i,.lp-status[data-s=local-fallback] i{background:var(--yellow)}
.lp-status[data-s=fail] i{background:#c4573f}
.lp-me{display:flex;align-items:flex-end;gap:10px}
.lp-me>i,.lp-row>i{width:38px;height:38px;flex:none;border-radius:50%;background:var(--c);color:#fff;font:700 15px/38px Raleway,Arial,sans-serif;font-style:normal;text-align:center}
.lp-me>i{margin-bottom:2px}
.lp-field{display:flex;flex-direction:column;gap:4px;font-size:11.5px;font-weight:600;color:var(--ink-3);flex:1;min-width:0}
.lp-field input{border:0;border-radius:11px;background:var(--white);box-shadow:inset 0 0 0 1px var(--line);padding:10px 12px;font-size:14px;color:var(--ink);outline:none;min-width:0;width:100%}
.lp-field input:focus{box-shadow:inset 0 0 0 1.5px var(--ink-2)}
.lp-cols{display:flex;gap:6px;flex-wrap:wrap;padding-left:48px}
.lp-cols button{width:24px;min-height:24px;height:24px;padding:0;border-radius:50%;background:var(--c)}
.lp-cols button:hover{background:var(--c);transform:scale(1.08)}
.lp-cols button.on{box-shadow:0 0 0 2px var(--paper),0 0 0 4px var(--ink)}
.lp-sec{margin-top:6px;font-size:11px;letter-spacing:.14em;text-transform:uppercase;font-weight:700;color:var(--ink-3);border-top:1px solid var(--line);padding-top:12px}
.lp-list{display:flex;flex-direction:column;gap:6px}
.lp-row{display:flex;align-items:center;gap:10px;background:rgba(255,255,255,.75);border-radius:14px;padding:8px 8px 8px 10px;box-shadow:inset 0 0 0 1px var(--line)}
.lp-row>i{width:32px;height:32px;line-height:32px;font-size:13px}
.lp-row>span{flex:1;min-width:0;display:flex;flex-direction:column}
.lp-row strong{font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lp-row small{font-size:11.5px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lp-row .mg-btn{flex:none;min-height:34px;padding:6px 10px;gap:5px}
.lp-row .mg-btn svg{width:16px;height:16px}
.lp-row .mg-btn.on{background:var(--pink)}
.lp-note{font-size:12.5px;line-height:1.45;color:var(--ink-2)}
.lp-note.bad{color:#983d46}
.lp-btns{display:flex;gap:6px;flex-wrap:wrap}
.lp-btns .mg-btn{flex:1}
.lp-btns svg,.lp-go svg{width:17px;height:17px}
.lp-text{align-self:flex-start;min-height:30px;padding:4px 2px;font-size:12px;font-weight:600;color:var(--ink-3);text-decoration:underline;text-underline-offset:3px}
.lp-text:hover{background:transparent;color:var(--ink)}
.lp-setup{display:flex;flex-direction:column;gap:8px}
.lp-setup summary{cursor:pointer;font-size:13px;font-weight:700;padding:6px 0;list-style:none}
.lp-setup summary::-webkit-details-marker{display:none}
.lp-setup summary::before{content:"+";display:inline-block;width:18px;font-weight:700}
.lp-setup[open] summary::before{content:"–"}
.lp-setup[open]{gap:8px}
.lp-setup .lp-field{margin-bottom:8px}
.lp-go{width:100%;min-height:42px;border-radius:12px}

/* ---------- follow bar ---------- */
#liveFollow{position:absolute;z-index:29;left:50%;top:84px;transform:translateX(-50%);display:flex;align-items:center;gap:10px;border-radius:999px;padding:5px 5px 5px 14px;font-size:13px;font-weight:600;box-shadow:var(--shadow),inset 0 0 0 2px var(--c)}
#liveFollow i{width:9px;height:9px;border-radius:50%;background:var(--c);animation:livePulse 1.4s ease-in-out infinite}
#liveFollow button{min-height:32px;border-radius:999px;background:var(--ink);color:var(--paper);padding:5px 14px;font-size:12.5px}
#liveFollow button:hover{background:var(--ink-2)}
@keyframes livePulse{50%{opacity:.35}}

/* ---------- labels over the 3D view ---------- */
#livePeers{position:absolute;inset:0;pointer-events:none;z-index:14;overflow:hidden}
.peer-label{position:absolute;left:0;top:0;white-space:nowrap;font:700 11.5px/1 Raleway,Arial,sans-serif;color:#fff;background:var(--c);padding:5px 9px;border-radius:999px;margin:-30px 0 0 -12px;box-shadow:0 4px 14px rgba(40,40,40,.22);will-change:transform}
.peer-label::after{content:"";position:absolute;left:10px;bottom:-4px;width:8px;height:8px;background:var(--c);transform:rotate(45deg);border-radius:1px}
.peer-label.ptr{margin:10px 0 0 12px;padding:4px 8px;font-size:11px;border-radius:8px 999px 999px 999px}
.peer-label.ptr::after{display:none}
.peer-label.sel{margin:-46px 0 0 -12px;background:var(--paper);color:var(--ink);box-shadow:0 4px 14px rgba(40,40,40,.18),inset 0 0 0 2px var(--c)}
.peer-label.sel::after{background:var(--c)}

/* ---------- toast ---------- */
#liveToast{position:absolute;z-index:40;left:50%;bottom:calc(96px + var(--safe-b));transform:translate(-50%,12px);opacity:0;pointer-events:none;background:var(--ink);color:var(--paper);font-size:13px;font-weight:600;padding:10px 16px;border-radius:999px;box-shadow:var(--shadow);transition:opacity .2s,transform .2s;max-width:calc(100vw - 32px);text-align:center}
#liveToast.on{opacity:1;transform:translate(-50%,0)}

body.placing #livePanel,body.placing #liveFollow{display:none!important}

/* ---------- phone ---------- */
@media(max-width:700px){
  .live-btn{min-height:38px;padding:4px 8px 4px 4px;gap:2px}
  .live-btn .live-ic{width:30px;height:30px}
  .live-btn::after{right:5px;top:5px}
  .live-avs{padding-left:8px}
  .live-avs i{width:26px;height:26px;line-height:26px;font-size:11px}
  .live-avs i:nth-child(n+3){display:none}
  .live-count{font-size:12px;padding-right:2px}
  #livePanel{top:auto;bottom:calc(10px + var(--safe-b));left:10px;right:10px;width:auto;max-width:none;max-height:min(78dvh,640px);border-radius:22px;padding:16px 16px 14px}
  #livePanel h2{font-size:27px}
  #liveFollow{top:auto;bottom:calc(126px + var(--safe-b))}
  #liveToast{bottom:calc(132px + var(--safe-b))}
}
@media(prefers-reduced-motion:reduce){#liveFollow i{animation:none}#liveToast{transition:none}}
#livePanel *,#livePanel *::before,#livePanel *::after,.live-btn,.live-btn *{box-sizing:border-box}
/* phone header is tight: icon + count badge only */
@media(max-width:700px){
  .live-btn,.live-btn.has{width:38px;padding:0;gap:0}
  .live-btn .live-avs{display:none}
  .live-btn.has .live-ic{display:inline-flex}
  .live-btn.has .live-ic{color:var(--ink)}
  .live-btn .live-count{position:absolute;right:-4px;top:-4px;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--ink);color:var(--paper);font-size:10.5px;line-height:18px;text-align:center}
  .live-btn.has::after{display:none}
}

/* ---------- R27 Free / Present ---------- */
.lp-seg{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.lp-seg button{display:flex;flex-direction:column;gap:3px;text-align:left;white-space:normal;align-items:stretch;justify-content:flex-start;min-width:0;border-radius:14px;padding:9px 11px;border:1.5px solid var(--line);background:rgba(255,255,255,.7);cursor:pointer;font:inherit;color:var(--ink)}
.lp-seg button b{font-size:14px}
.lp-seg button small{display:block;white-space:normal;overflow-wrap:anywhere;font-weight:500;font-size:11.5px;line-height:1.3;color:var(--ink-2)}
.lp-seg button:hover{border-color:var(--ink-2)}
.lp-seg button[aria-checked=true]{border-color:var(--ink);background:var(--pink)}
.live-btn[data-present=on]{box-shadow:0 0 0 2px #fff,0 0 0 4px #e0566f}
.live-btn[data-present=on] .live-ic{color:#e0566f}

/* R13: language settings live inside Live, not in the main header. */
#livePanel .lp-language{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:10px 0 14px;border-bottom:1px solid var(--line,#e6e2da)}
#livePanel .lp-language>label{font-size:12px;font-weight:600;padding-top:12px;color:var(--ink-2,#666)}
#livePanel #langMenu{min-width:150px;max-width:65%}
#livePanel #langButton{width:100%;min-height:40px;display:flex;align-items:center;justify-content:center;border-radius:12px}
#livePanel #langList{position:static;width:100%;min-width:0;margin-top:8px;box-shadow:none;background:var(--paper,#fffaf4)}
#livePanel #langList[hidden]{display:none!important}

/* R40 · history (Miro-style) + new-activity dot */
.lp-hist{display:flex;flex-direction:column;gap:2px;max-height:240px;overflow:auto;margin:2px 0 6px;padding-right:2px}
.lp-h{display:grid;grid-template-columns:10px 1fr;gap:8px;align-items:start;padding:6px 4px;border-radius:8px;font-size:12px;line-height:1.35}
.lp-h:hover{background:rgba(0,0,0,.04)}
.lp-h>i{width:8px;height:8px;border-radius:50%;background:var(--c);margin-top:4px}
.lp-h b{font-weight:600}.lp-h small{opacity:.55;font-size:11px}
.lp-h span{display:block;opacity:.8;word-break:break-word}
.live-btn{position:relative}
.live-btn.news::after{content:"";position:absolute;top:4px;right:4px;width:8px;height:8px;border-radius:50%;background:#E0607E;box-shadow:0 0 0 2px #fff}

/* R47 · Help sits in the Live panel next to Language */
body.help-in-live .headerActions #help{display:none!important}
/* label | language | help on one line that always fits the panel (R47.1: it was ~100 px too wide on iPad → sideways scroll) */
.lp-language{display:grid!important;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px}
.lp-language>label{padding-top:0;white-space:nowrap;min-width:0}
#livePanel .lp-language #langMenu{min-width:0!important;max-width:none!important;width:100%}
#livePanel .lp-language #langButton{min-width:0;overflow:hidden;white-space:nowrap}
.lp-help{min-height:38px;padding:6px 11px;border-radius:999px;gap:5px;font-size:13px;font-weight:600;white-space:nowrap}
/* the Live panel only scrolls up / down */
#livePanel{overflow-x:hidden!important;overflow-y:auto;touch-action:pan-y;overscroll-behavior:contain}
#livePanel>*{min-width:0;max-width:100%}
#livePanel .lp-hist,#livePanel .lp-hist *{overflow-wrap:anywhere}
.lp-help svg{width:17px;height:17px}
