:root {
  --panel: #FFFFFF; --panel2: #F7F7F5; --line: #E8E6E3; --line2: #F0EEEB; --tx: #1E1E1E; --tx2: #7A7772; --tx3: #A8A49E;
  --blue: #0D99FF; --blue-soft: rgba(13,153,255,.12); --pink: #F24822; --canvas: #ECEAE6; --ink: #24211E;
  --lw: 252px; --rw: 268px; --th: 44px;
  font-family: "Arquette", -apple-system, system-ui, sans-serif; font-size: 12px; color: var(--tx);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--canvas); overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* Top bar */
#topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--th); background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 10px; gap: 8px; z-index: 50; }
#topbar .logo { width: 28px; height: 28px; border-radius: 8px; overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; }
#topbar .logo img { width: 40px; height: 40px; }
.menu-btn { height: 30px; padding: 0 8px; border-radius: 7px; display: flex; align-items: center; gap: 6px; }
.menu-btn:hover, .menu-btn.on { background: var(--panel2); }
#filetitle { font-weight: 500; font-size: 13px; }
#filetitle span { color: var(--tx2); font-weight: 400; }
#topbar .sp { flex: 1; }
.pbtn { height: 30px; padding: 0 12px; border-radius: 8px; background: var(--ink); color: #fff; display: flex; align-items: center; gap: 7px; font-weight: 500; }
.pbtn:hover { background: #3a3632; }
#zoombtn { min-width: 64px; justify-content: center; font-variant-numeric: tabular-nums; }

/* Dropdown menus */
.dd { position: fixed; min-width: 236px; background: #1E1E1E; color: #fff; border-radius: 10px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.28); z-index: 200; font-size: 12px; }
.dd .it { display: flex; align-items: center; justify-content: space-between; gap: 18px; height: 28px; padding: 0 10px 0 26px; border-radius: 6px; position: relative; cursor: default; }
.dd .it:hover { background: var(--blue); }
.dd .it .k { color: rgba(255,255,255,.5); }
.dd .it:hover .k { color: rgba(255,255,255,.85); }
.dd .it.chk::before { content: "✓"; position: absolute; left: 9px; }
.dd .it.dis { opacity: .35; pointer-events: none; }
.dd .sep { height: 1px; background: rgba(255,255,255,.12); margin: 5px 4px; }
.dd .hd { padding: 6px 10px 4px; color: rgba(255,255,255,.45); font-size: 11px; }

/* Panels */
#left, #right { position: fixed; top: var(--th); bottom: 0; background: var(--panel); z-index: 40; display: flex; flex-direction: column; }
#left { left: 0; width: var(--lw); border-right: 1px solid var(--line); }
#right { right: 0; width: var(--rw); border-left: 1px solid var(--line); }
.ph-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px; font-weight: 500; font-size: 12px; }
.ph-title .act { color: var(--tx2); }
#pages { padding: 0 6px 8px; border-bottom: 1px solid var(--line); }
.pg { height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 7px; cursor: default; }
.pg:hover { background: var(--panel2); }
.pg.on { background: var(--panel2); font-weight: 500; }
.pg .ck { width: 12px; color: var(--tx); opacity: 0; }
.pg.on .ck { opacity: 1; }
#layers { flex: 1; overflow: auto; padding: 0 6px 20px; }
.ly { height: 28px; display: flex; align-items: center; gap: 6px; padding-right: 6px; border-radius: 6px; cursor: default; white-space: nowrap; position: relative; }
.ly:hover { box-shadow: inset 0 0 0 1px var(--blue); }
.ly.sel { background: var(--blue-soft); }
.ly.child { padding-left: 22px; }
.ly .car { width: 14px; text-align: center; color: var(--tx3); font-size: 9px; }
.ly .gl { width: 14px; height: 14px; flex: none; color: var(--tx2); display: flex; align-items: center; justify-content: center; }
.ly .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ly .nm[contenteditable="true"] { background: #fff; outline: 1px solid var(--blue); padding: 0 3px; text-overflow: clip; }
.ly .tg { opacity: 0; width: 20px; height: 20px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--tx2); }
.ly:hover .tg, .ly .tg.on { opacity: 1; }
.ly.hid .nm, .ly.hid .gl { opacity: .4; }
.ly.sec { font-weight: 500; }

/* Right panel */
#rtabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
#rtabs button { height: 32px; padding: 0 10px; color: var(--tx2); font-weight: 500; border-bottom: 2px solid transparent; }
#rtabs button.on { color: var(--tx); border-bottom-color: var(--tx); }
#rbody { flex: 1; overflow: auto; }
.sec-p { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sec-p h4 { margin: 0 0 10px; font-size: 12px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fld { display: flex; align-items: center; height: 30px; border-radius: 6px; background: var(--panel2); border: 1px solid transparent; padding: 0 8px; gap: 6px; }
.fld:focus-within { border-color: var(--blue); background: #fff; }
.fld label { color: var(--tx3); width: 12px; cursor: ew-resize; user-select: none; }
.fld input { border: 0; background: transparent; outline: 0; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.fld input[type=color] { width: 20px; height: 20px; padding: 0; border-radius: 4px; flex: none; }
.row-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.ib { width: 30px; height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--tx); }
.ib:hover { background: var(--panel2); }
.ib.on { background: var(--blue-soft); color: var(--blue); }
.wbtn { height: 30px; border-radius: 7px; border: 1px solid var(--line); padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.wbtn:hover { background: var(--panel2); }
.muted { color: var(--tx2); line-height: 17px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; background: var(--panel2); border-radius: 6px; padding: 8px; line-height: 16px; word-break: break-all; color: #3d3a36; white-space: pre-wrap; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.flow { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 8px; border-radius: 6px; }
.flow:hover { background: var(--panel2); }
.flow .pl { color: var(--blue); font-weight: 500; }
.lk { display: flex; gap: 6px; align-items: center; padding: 4px 0; color: var(--tx2); cursor: pointer; }
.lk:hover { color: var(--blue); }
.chipx { display: inline-block; padding: 2px 7px; border-radius: 999px; background: var(--panel2); margin: 0 4px 4px 0; color: var(--tx2); }

/* Viewport */
#viewport { position: fixed; top: var(--th); left: var(--lw); right: var(--rw); bottom: 0; overflow: hidden; background-color: var(--canvas); touch-action: none; }
body.noui #viewport { top: 0; left: 0; right: 0; }
body.noui #topbar, body.noui #left, body.noui #right, body.noui #toolbar { display: none; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; --inv: 1; }
#world.moving { will-change: transform; }
#viewport.grab, #viewport.grab * { cursor: grab !important; }
#viewport.grabbing, #viewport.grabbing * { cursor: grabbing !important; }
#viewport.cross, #viewport.cross * { cursor: crosshair !important; }
#viewport.texting, #viewport.texting * { cursor: text !important; }
#viewport.commenting, #viewport.commenting * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M3 21V11a8 8 0 1 1 8 8H3z' fill='%23fff' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") 3 21, crosshair !important; }

.obj { position: absolute; }
.obj.section { background: rgba(255,255,255,.55); border: 1px solid rgba(0,0,0,.07); border-radius: 18px; }
.obj .sec-title { position: absolute; left: 0; bottom: 100%; transform-origin: 0 100%; transform: scale(min(var(--inv), 4)); padding: 0 0 8px; white-space: nowrap; }
.obj .sec-title span { display: inline-block; background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 7px; padding: 5px 10px; font-weight: 500; font-size: 13px; color: var(--tx); cursor: default; }
.obj.frame > .flabel, .obj.image > .flabel { position: absolute; left: 0; bottom: 100%; transform-origin: 0 100%; transform: scale(var(--inv)); padding-bottom: 6px; font-size: 12px; color: var(--tx2); white-space: nowrap; max-width: calc(100% / var(--inv)); overflow: hidden; text-overflow: ellipsis; }
.obj.frame.sel > .flabel, .obj.image.sel > .flabel { color: var(--blue); }
.obj.frame { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 30px rgba(0,0,0,.06); }
.obj.frame > .ph { pointer-events: none; }
.obj.frame.wide > .ph { width: 100%; height: 100%; }
.obj.image { background: #fff; border-radius: 0; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 30px rgba(0,0,0,.06); }
.obj.image img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.obj.image .ph-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--tx3); text-align: center; padding: 20px; font-size: 13px; line-height: 18px; }
.obj.sticky { padding: 18px; font-size: 15px; line-height: 21px; color: #2b2723; box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 8px 20px rgba(0,0,0,.07); border-radius: 4px; overflow: hidden; white-space: pre-wrap; outline: none; }
.obj.text { white-space: pre-wrap; outline: none; color: var(--ink); line-height: 1.15; }
.obj.text.h1 { font-family: "Restora"; font-weight: 200; letter-spacing: -0.02em; }
.obj.rect { border-radius: 0; }
.obj[contenteditable="true"] { cursor: text; user-select: text; box-shadow: 0 0 0 2px var(--blue); }
.obj.hid { display: none; }

/* Overlay (screen space) */
#overlay { position: absolute; inset: 0; pointer-events: none; }
#ovsvg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.selbox { position: absolute; border: 1px solid var(--blue); }
.selbox.multi { border-style: solid; }
.hov { position: absolute; border: 2px solid var(--blue); }
.hnd { position: absolute; width: 8px; height: 8px; background: #fff; border: 1px solid var(--blue); margin: -4px 0 0 -4px; pointer-events: auto; }
.badge { position: absolute; transform: translateX(-50%); background: var(--blue); color: #fff; font-size: 11px; padding: 2px 5px; border-radius: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.red { background: var(--pink); }
.marq { position: absolute; border: 1px solid var(--blue); background: rgba(13,153,255,.08); }
.pin { position: absolute; width: 30px; height: 30px; margin: -30px 0 0 0; border-radius: 15px 15px 15px 2px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; font-weight: 500; pointer-events: auto; cursor: pointer; border: 2px solid var(--ink); }
.pin.res { opacity: .45; }
.pop { position: absolute; width: 280px; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.2); padding: 12px; pointer-events: auto; z-index: 5; }
.pop textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-height: 64px; resize: vertical; outline: none; }
.pop textarea:focus { border-color: var(--blue); }
.pop .bt { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.pop .meta { color: var(--tx3); margin-bottom: 6px; }

/* Rulers */
.ruler { position: absolute; background: rgba(255,255,255,.92); pointer-events: none; z-index: 3; }
#rulerX { left: 0; top: 0; height: 20px; width: 100%; border-bottom: 1px solid var(--line); }
#rulerY { left: 0; top: 0; width: 20px; height: 100%; border-right: 1px solid var(--line); }

/* Minimap */
#minimap { position: absolute; right: 14px; bottom: 14px; width: 200px; height: 130px; background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.08); cursor: pointer; z-index: 4; }

/* Toolbar */
#toolbar { position: fixed; bottom: 16px; left: calc(var(--lw) + (100vw - var(--lw) - var(--rw)) / 2); transform: translateX(-50%); background: var(--panel); border-radius: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 8px 30px rgba(0,0,0,.12); display: flex; padding: 5px; gap: 2px; z-index: 45; }
#toolbar .tb { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; position: relative; }
#toolbar .tb:hover { background: var(--panel2); }
#toolbar .tb.on { background: var(--blue); color: #fff; }
#toolbar .vs { width: 1px; background: var(--line); margin: 6px 4px; }
.tip { position: fixed; background: #1E1E1E; color: #fff; padding: 5px 8px; border-radius: 6px; font-size: 11px; pointer-events: none; z-index: 300; white-space: nowrap; }
.tip .k { color: rgba(255,255,255,.5); margin-left: 6px; }

/* Present */
#present { position: fixed; inset: 0; background: #1A1918; z-index: 500; display: flex; flex-direction: column; }
#pstage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.device { position: relative; border-radius: 56px; overflow: hidden; box-shadow: 0 0 0 11px #0c0b0a, 0 0 0 13px #3a3734, 0 40px 120px rgba(0,0,0,.6); transform-origin: center; background: #fff; }
.device.wide { border-radius: 16px; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
.device .ph [data-go] { cursor: pointer; }
.device .ph.flash [data-go] { outline: 2px solid rgba(13,153,255,.9); outline-offset: 2px; background-color: rgba(13,153,255,.12); }
.device img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pfade { animation: pfade .26s cubic-bezier(.22,1,.36,1); }
@keyframes pfade { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
#pbar { height: 56px; display: flex; align-items: center; justify-content: center; gap: 14px; color: rgba(255,255,255,.8); font-size: 13px; }
#pbar button { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.08); color: #fff; display: flex; align-items: center; justify-content: center; }
#pbar button:hover { background: rgba(255,255,255,.16); }
#pbar .nm { min-width: 300px; text-align: center; }
#pbar .nm small { display: block; color: rgba(255,255,255,.4); font-size: 11px; }
#pclose { position: absolute; top: 14px; right: 16px; }

/* Quick actions */
#quick { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,.12); display: flex; justify-content: center; padding-top: 14vh; }
#quick .box { width: 520px; max-height: 60vh; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; display: flex; flex-direction: column; }
#quick input { border: 0; outline: 0; padding: 16px 18px; font-size: 15px; border-bottom: 1px solid var(--line); }
#qlist { overflow: auto; padding: 6px; }
.qi { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 12px; border-radius: 8px; cursor: default; }
.qi.on { background: var(--blue); color: #fff; }
.qi small { color: var(--tx3); }
.qi.on small { color: rgba(255,255,255,.75); }

/* Shortcuts sheet */
#keys { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; }
#keys .box { width: min(980px, 92vw); max-height: 84vh; overflow: auto; background: #1E1E1E; color: #fff; border-radius: 16px; padding: 26px 30px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 34px; }
#keys h3 { grid-column: 1 / -1; margin: 0 0 12px; font-weight: 500; font-size: 16px; display: flex; justify-content: space-between; }
#keys h5 { margin: 14px 0 6px; color: rgba(255,255,255,.45); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#keys .kr { display: flex; justify-content: space-between; height: 24px; align-items: center; }
#keys kbd { font: inherit; color: rgba(255,255,255,.6); }

/* Context menu reuses .dd */
#toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); background: #1E1E1E; color: #fff; padding: 8px 14px; border-radius: 9px; z-index: 600; font-size: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.on { opacity: 1; }

/* ---- riquadri vivi: una pagina vera dentro un frame (il prototipo v3) ---- */
.obj.frame.embed { background: #0c0b0a; overflow: visible; }
.obj.frame.embed > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #F5EEE1; pointer-events: none; }
.obj.frame.embed.live > iframe { pointer-events: auto; }
.obj.frame.embed.live { outline: calc(2px * var(--inv)) solid var(--blue); outline-offset: calc(4px * var(--inv)); }
.obj.frame.embed.live > .flabel { color: var(--blue); }

/* un riquadro vivo ancora spento: superficie quieta con una riga sola. La pagina dentro si carica quando ci si avvicina (board.js, syncEmbeds) */
.obj.frame.embed > .eph { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; container-type: size; background: #E4DFD6; color: #8A847B; text-align: center; pointer-events: none; overflow: hidden; }
.obj.frame.embed.cold > .eph { display: flex; }
.obj.frame.embed > .eph span { font-size: min(calc(12px * var(--inv)), 7cqw); line-height: 1.3; padding: 0 6cqw; }
.obj.frame.embed.cold > iframe { visibility: hidden; }

/* ---------------------------------------------------------------- multi (15/11): la board a più mani.
   Persone in alto, cursori con il nome, selezione degli altri, cornice quando segui qualcuno. Niente ombre. */
#people { display: flex; align-items: center; gap: 4px; margin: 0 4px; }
.pa { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--pc, #5B5BD6); color: #fff; font-weight: 600; font-size: 11px; letter-spacing: .02em; display: flex; align-items: center; justify-content: center; position: relative; outline: 2px solid transparent; outline-offset: 2px; }
.pa:hover { outline-color: var(--line); }
.pa.on, .pa.on:hover { outline-color: var(--pc); }
.pa.me { border: 2px solid rgba(255,255,255,.6); background-clip: padding-box; outline-color: var(--line); }
.pa.off { opacity: .4; }
.pa.pmore { background: var(--panel2); color: var(--tx2); border: 1px solid var(--line); }
.pa.eye::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 8px; height: 8px; border-radius: 50%; background: #fff; border: 2px solid var(--pc); }
#mlayer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
.mcur { position: absolute; left: 0; top: 0; transition: transform .09s linear; will-change: transform; }
.mcur svg { display: block; margin: -2px 0 0 -2px; }
.mlab { position: absolute; left: 13px; top: 15px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.mtag { background: var(--pc); color: #fff; font-weight: 500; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 3px 10px 10px 10px; white-space: nowrap; }
.msay { background: var(--pc); color: #fff; font-size: 14px; line-height: 20px; padding: 5px 10px; border-radius: 3px 14px 14px 14px; max-width: 260px; width: max-content; overflow-wrap: anywhere; }
.msel { position: absolute; border: 2px solid; pointer-events: none; }
#mfollow { position: absolute; inset: 0; pointer-events: none; z-index: 6; display: none; }
#mfollow.on { display: block; }
#mfollow .mfr { position: absolute; inset: 0; border: 3px solid var(--pc); }
#mfollow .mpill { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); height: 32px; border-radius: 16px; padding: 0 5px 0 14px; background: var(--pc); color: #fff; font-weight: 500; display: flex; align-items: center; gap: 10px; white-space: nowrap; pointer-events: auto; }
#mfollow .mpill button { height: 22px; padding: 0 10px; border-radius: 11px; background: rgba(255,255,255,.24); color: #fff; font-weight: 500; }
#mfollow .mpill button:hover { background: rgba(255,255,255,.38); }
#msayin { position: fixed; z-index: 220; width: 210px; height: 30px; border: 0; outline: none; border-radius: 3px 15px 15px 15px; background: var(--pc); color: #fff; padding: 0 12px; font-size: 14px; }
#msayin::placeholder { color: rgba(255,255,255,.7); }
#mname { position: fixed; top: calc(var(--th) + 8px); right: 12px; width: 264px; z-index: 210; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 8px; }
#mname b { font-weight: 600; font-size: 14px; }
#mname p { margin: 0; color: var(--tx2); line-height: 1.4; }
#mname input { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; outline: none; font-size: 13px; }
#mname input:focus { border-color: var(--blue); }
#mname .bt { display: flex; justify-content: flex-end; gap: 6px; }
#mname .wbtn.ok { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .mcur { transition: none; } }

