/* Pizarra · estilos propios */
body { overflow: hidden; }
.shell { display: grid; height: 100dvh; grid-template-rows: 48px auto minmax(0, 1fr); }
.tools { display: flex; gap: 2px; margin: 0 auto; padding: 3px; border-radius: 10px; background: var(--sunken); border: 1px solid var(--border); }
.tool { display: grid; place-items: center; width: 32px; height: 30px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--text-2); }
.tool:hover { background: var(--hover); color: var(--text); }
.tool[aria-pressed="true"] { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.topbar .top-actions { margin-left: 0; }
.opts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.colors { display: flex; gap: 4px; }
.sw { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); }
.sw[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18), 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.custom { position: relative; width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); cursor: pointer; overflow: hidden; }
.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sep { width: 1px; height: 20px; background: var(--border); }
.widths { display: flex; gap: 2px; }
.wbtn { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; }
.wbtn i { display: block; border-radius: 50%; background: var(--text-2); }
.wbtn:hover { background: var(--hover); }
.wbtn[aria-pressed="true"] { background: var(--accent-soft); }
.wbtn[aria-pressed="true"] i { background: var(--accent); }
.opts .input { height: 28px; width: auto; font-size: 12px; }

.board { position: relative; overflow: hidden; touch-action: none; background-color: var(--paper, #fbfbf9); }
.board[data-pat="dots"] { background-image: radial-gradient(var(--dot, #cfcfc9) 1px, transparent 1.2px); background-size: 22px 22px; }
.board[data-pat="grid"] { background-image: linear-gradient(var(--line, #e7e7e2) 1px, transparent 1px), linear-gradient(90deg, var(--line, #e7e7e2) 1px, transparent 1px); background-size: 24px 24px; }
.paper-btn { gap: 6px; }
.paper-sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border-2); flex: none; }
.paper-in { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#cv { display: block; }
.text-in { position: absolute; z-index: 2; min-width: 120px; margin: -4px 0 0 -4px; padding: 2px 4px; border: 1px dashed var(--accent); border-radius: 4px; background: rgba(255, 255, 255, .6); font: 500 16px Inter, system-ui, sans-serif; outline: none; }
.hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 7px 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-sm); white-space: nowrap; pointer-events: none; }
.hint kbd { margin: 0 1px; }
.board[data-dark="1"] .hint { opacity: .85; }
@media (max-width: 900px) { .tools { order: 3; } .topbar { flex-wrap: wrap; height: auto; padding: 6px 10px; } .shell { grid-template-rows: auto auto minmax(0, 1fr); } .hint { white-space: normal; width: 90%; } }
.tsep { width: 1px; margin: 5px 3px; background: var(--border-2); }
.board.over { box-shadow: inset 0 0 0 3px var(--accent); }

/* Sin distracciones: solo el lienzo y una tira flotante de herramientas */
.zen-exit { display: none; }
body.zen .shell { grid-template-rows: minmax(0, 1fr); }
body.zen .opts { display: none; }
body.zen .topbar { display: flex !important; position: fixed; z-index: 4; top: 10px; left: 50%; transform: translateX(-50%); height: auto; padding: 0; border: 0; background: none; }
body.zen .topbar .brand, body.zen .topbar .top-actions { display: none; }
body.zen .tools { box-shadow: var(--shadow-md); background: var(--panel); }
body.zen .zen-exit { display: block; position: absolute; right: 14px; top: 12px; z-index: 4; padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--panel); color: var(--text-3); font-size: 12px; opacity: .7; }
body.zen .zen-exit:hover { opacity: 1; color: var(--text); }

/* ───────── Móvil: casi toda la pantalla para el lienzo ───────── */
@media (max-width: 700px) {
  .topbar { padding: 4px 8px 6px; row-gap: 4px; }
  .topbar, .opts { min-width: 0; }
  .tools { flex: 1 1 100%; min-width: 0; margin: 0; overflow-x: auto; scrollbar-width: none; justify-content: space-between; }
  .tools::-webkit-scrollbar { display: none; }
  .opts { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none; }
  .opts::-webkit-scrollbar { display: none; }
  .opts > * { flex: none; }
  .opts .sep, .opts .grow, #bgPat, #paperBtn, #zenBtn, #clear, #copyBtn, #exportBtn { display: none; }
  #moreBtn { position: sticky; right: -8px; margin-left: auto; border-radius: 0; background: var(--bg); box-shadow: -10px 0 10px var(--bg); }
  /* Deshacer y rehacer, flotando abajo a la izquierda, al alcance del pulgar */
  #undo, #redo { position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 5; width: 48px; height: 48px; border: 1px solid var(--border-2); border-radius: 50%; background: var(--panel); box-shadow: var(--shadow-md); }
  #undo { left: 14px; }
  #redo { left: 70px; }
  .hint { top: 12px; bottom: auto; }
}
:root[data-input="touch"] .tool { width: 40px; height: 40px; flex: none; }
:root[data-input="touch"] .sw { width: 32px; height: 32px; flex: none; }
:root[data-input="touch"] .custom { width: 32px; height: 32px; flex: none; }
:root[data-input="touch"] .wbtn { width: 38px; height: 38px; }
:root[data-input="touch"] .text-in { font-size: 16px; }

/* Capas */
#layersBtn b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.layers { position: absolute; z-index: 3; top: 10px; right: 10px; width: 250px; max-width: calc(100% - 20px); display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-md); }
.ly-h { display: flex; align-items: center; }
.ly-list { display: grid; gap: 2px; max-height: 240px; overflow: auto; }
.ly { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 2px; padding: 2px; border-radius: 8px; }
.ly.on { background: var(--accent-soft); }
.ly-b { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--text-2); }
.ly-b[aria-pressed="false"][data-act="vis"], .ly-b[aria-pressed="true"][data-act="lock"] { color: var(--accent); }
.ly-b:hover { background: var(--hover); }
.ly-name { display: flex; justify-content: space-between; gap: 6px; min-width: 0; padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.ly-name small { color: var(--text-3); }
.ly.on .ly-name { font-weight: 600; }
.ly-op { display: flex; align-items: center; gap: 8px; }
.ly-op input { flex: 1; }
.ly-tools { display: flex; gap: 2px; justify-content: space-between; }
.layers p { margin: 0; }
:root[data-input="touch"] .ly-b { width: 38px; height: 38px; }
:root[data-input="touch"] .ly-name { min-height: 38px; }
@media (max-width: 700px) { #svgBtn { display: none; } .layers { top: auto; bottom: 74px; right: 10px; } }

/* ───────── En directo ───────── */
.lv-btn { gap: 7px; }
.lv-btn.on { border-color: color-mix(in srgb, #2fa36b 45%, var(--border)); }
.lv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.lv-dot.ok { background: #2fa36b; box-shadow: 0 0 0 3px color-mix(in srgb, #2fa36b 25%, transparent); }
.lv-dot.wait { background: #eab308; animation: lv-blink 1s ease-in-out infinite; }
.lv-dot.off { background: var(--text-3); }
@keyframes lv-blink { 50% { opacity: .35; } }
.lv-cur { position: absolute; left: 0; top: 0; z-index: 4; display: flex; align-items: flex-start; gap: 2px; pointer-events: none; transition: transform .08s linear; }
.lv-cur svg { width: 16px; height: 16px; fill: var(--c); stroke: #fff; stroke-width: 1.5; }
.lv-cur span { margin-top: 12px; padding: 1px 6px; border-radius: 6px; background: var(--c); color: #fff; font-size: 11px; font-weight: 500; white-space: nowrap; }
.lv-m { display: grid; gap: 12px; }
.lv-m p { margin: 0; }
.lv-tabs { margin-bottom: 2px; }
.lv-tabs button { height: 30px; }
.lv-share { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 14px; align-items: start; }
.lv-qr { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.lv-qr svg { width: 100%; height: 100%; display: block; }
.lv-link { display: grid; gap: 8px; min-width: 0; }
.lv-link .input { width: 100%; font-family: var(--mono); font-size: 11.5px; }
.lv-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.lv-h { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; }
.lv-ppl { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 160px; overflow: auto; }
.lv-ppl li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lv-ppl i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.lv-ppl small { margin-left: auto; }
.lv-warn { padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, #eab308 16%, var(--panel)); color: var(--text); }
/* Solo lectura: fuera todo lo que cambia el dibujo */
body.live-ro #tools, body.live-ro #colors, body.live-ro .custom, body.live-ro #widths, body.live-ro label.check.mini, body.live-ro #tplBtn,
body.live-ro #undo, body.live-ro #redo, body.live-ro #clear, body.live-ro .ly-tools, body.live-ro #hint { display: none; }
body.live-ro #cv { cursor: default; }
@media (max-width: 700px) {
  .lv-share { grid-template-columns: 1fr; }
  .lv-qr { width: min(220px, 70vw); justify-self: center; }
  .lv-btn span { max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
  .lv-btn.on { order: -1; }   /* en una sesión, el estado siempre a la vista */
  .lv-tabs button, .lv-btns .btn { min-height: 38px; }
  .lv-m .input { font-size: 16px; }
}

/* ───────── Zona seleccionada y cubo ───────── */
.ar-mode { position: absolute; top: 10px; left: 50%; z-index: 5; transform: translateX(-50%); background: var(--panel); box-shadow: var(--shadow-md); }   /* flotando: no mueve el lienzo */
.ar-mode button { height: 26px; }
.ar-bar { position: absolute; z-index: 5; display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow-md); }
.ar-bar .btn { gap: 5px; }
.ar-bar [aria-pressed="true"] { background: color-mix(in srgb, #2f5bea 14%, var(--panel)); color: #2f5bea; }
@media (max-width: 700px) {
  .ar-mode button, .ar-bar .btn, .ar-bar .icon-btn { min-height: 38px; }
  .ar-bar { max-width: calc(100% - 8px); overflow-x: auto; scrollbar-width: none; }
}
