/* =====================================================================
   Mi Pizarra — tokens de color, sombras y movimiento tomados de mi-qr.
   ===================================================================== */
:root{
  --accent:#0071E3;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 9px;
}
*{ box-sizing:border-box; }
[hidden]{ display:none !important; }

body{
  --paper:#F5F5F7;
  --panel:#FFFFFF;
  --ink:#1D1D1F;
  --ink-soft:#6E6E73;
  --ink-faint:#86868B;
  --rule:#D2D2D7;
  --separator: rgba(60,60,67,.14);
  --fill: rgba(118,118,128,.12);
  --fill-strong: rgba(118,118,128,.22);
  --material: rgba(250,250,252,.72);
  --material-strong: rgba(255,255,255,.82);
  --danger:#E30000;
  --scrim: rgba(0,0,0,.28);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px -8px rgba(0,0,0,.08);
  --shadow-pop: 0 0 0 .5px rgba(0,0,0,.06), 0 18px 50px -12px rgba(0,0,0,.28);
  --shadow-bar: 0 0 0 .5px rgba(0,0,0,.06), 0 8px 28px -10px rgba(0,0,0,.22);
  --focus: color-mix(in srgb, var(--accent) 38%, transparent);
  --accent-text: var(--accent);
  --accent-fill: color-mix(in srgb, var(--accent) 14%, transparent);

  margin:0; height:100vh; height:100dvh; overflow:hidden;
  background:var(--paper); color:var(--ink);
  font: 400 15px/1.47 var(--font-ui); letter-spacing:-0.009em;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  -webkit-tap-highlight-color:transparent;
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
  overscroll-behavior:none; touch-action:manipulation;
  color-scheme:light;
}
body.dark{
  --paper:#000000;
  --panel:#1C1C1E;
  --ink:#F5F5F7;
  --ink-soft:#98989D;
  --ink-faint:#8E8E93;
  --rule:#38383A;
  --separator: rgba(84,84,88,.55);
  --fill: rgba(118,118,128,.24);
  --fill-strong: rgba(118,118,128,.36);
  --material: rgba(22,22,24,.72);
  --material-strong: rgba(44,44,46,.82);
  --danger:#FF6961;
  --scrim: rgba(0,0,0,.5);
  --accent-text: color-mix(in srgb, var(--accent) 62%, #fff);
  --accent-fill: color-mix(in srgb, var(--accent) 30%, transparent);
  --shadow: none;
  --shadow-pop: 0 0 0 .5px rgba(255,255,255,.1), 0 18px 50px -12px rgba(0,0,0,.8);
  --shadow-bar: 0 0 0 .5px rgba(255,255,255,.1), 0 8px 28px -10px rgba(0,0,0,.7);
  color-scheme:dark;
}
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ transition-duration:.01ms !important; animation-duration:.01ms !important; }
}
::selection{ background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus{ outline:none; }
:focus-visible{ outline:none; box-shadow:0 0 0 4px var(--focus); }
button{ font:inherit; color:inherit; touch-action:manipulation; border:0; background:transparent; cursor:pointer; padding:0; }

canvas{ position:absolute; left:0; top:0; display:block; }
#ov{ touch-action:none; }

/* ---------- Barras flotantes (material translúcido) ---------- */
.bar{
  position:absolute; z-index:10; display:flex; align-items:center; gap:2px; padding:5px;
  background:var(--material);
  -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-radius:var(--radius-md); box-shadow:var(--shadow-bar);
}
.sep{ width:1px; height:24px; background:var(--separator); margin:0 5px; flex:none; }
#topbar{ top:12px; left:50%; transform:translateX(-50%); }
#pagebar{ bottom:calc(14px + env(safe-area-inset-bottom,0px)); left:50%; transform:translateX(-50%); }
#zoombar{ bottom:calc(14px + env(safe-area-inset-bottom,0px)); right:14px; }
.group{ display:flex; align-items:center; gap:2px; }

.ib{
  width:38px; height:38px; display:grid; place-items:center; position:relative;
  border-radius:var(--radius-sm); color:var(--ink);
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.ib svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.ib:active:not(:disabled){ transform:scale(0.97); }
.ib.on{ background:var(--accent-fill); color:var(--accent-text); }
.ib:disabled{ opacity:.3; cursor:default; }
.ib .caret{ position:absolute; right:4px; bottom:4px; width:0; height:0; border-left:4px solid transparent; border-top:4px solid currentColor; transform:rotate(-45deg); opacity:.55; }
.ib .dot{ position:absolute; top:7px; right:7px; width:6px; height:6px; border-radius:50%; background:var(--accent); }
@media (hover:hover) and (pointer:fine){
  .ib:hover:not(:disabled):not(.on){ background:var(--fill); }
}

#pageLabel{ min-width:84px; text-align:center; font:600 14px/1 var(--font-ui); font-variant-numeric:tabular-nums; color:var(--ink); }
#zoomLabel{
  min-width:58px; height:38px; border-radius:var(--radius-sm); font:600 13px/1 var(--font-ui); font-variant-numeric:tabular-nums;
  transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
#zoomLabel:active{ transform:scale(0.97); }
@media (hover:hover) and (pointer:fine){ #zoomLabel:hover{ background:var(--fill); } }

/* ---------- Marca ---------- */
#brand{
  position:absolute; top:12px; left:14px; z-index:9; height:48px; display:flex; align-items:center; gap:9px;
  padding:0 14px 0 10px; border-radius:var(--radius-md);
  background:var(--material); -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  box-shadow:var(--shadow-bar); pointer-events:none;
}
#brand img{ border-radius:7px; }
#brand span{ font:600 17px/1 var(--font-display); letter-spacing:-0.022em; color:var(--ink); white-space:nowrap; }
@media (max-width: 1320px){ #brand span{ display:none; } #brand{ padding:0 10px; } }
@media (max-width: 1100px){ #brand{ display:none; } }
body.present #brand{ display:none; }

/* ---------- Colores y grosores ---------- */
.sw{
  width:24px; height:24px; border-radius:50%; margin:0 3px; flex:none; position:relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
body.dark .sw{ box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.sw.on{ box-shadow: 0 0 0 2px var(--material-strong), 0 0 0 4px var(--accent); }
.sw:active{ transform:scale(0.9); }
.custom{ overflow:hidden; background:conic-gradient(#FF3B30,#FFCC00,#34C759,#5AC8FA,#0071E3,#AF52DE,#FF3B30); cursor:pointer; }
.custom input{ position:absolute; inset:-8px; opacity:0; cursor:pointer; width:40px; height:40px; }

.wd{ width:30px; height:38px; display:grid; place-items:center; border-radius:var(--radius-sm); transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out); }
.wd span{ display:block; border-radius:50%; background:var(--ink); transition: background-color 160ms var(--ease-out); }
.wd.on{ background:var(--accent-fill); }
.wd.on span{ background:var(--accent-text); }
.wd:active{ transform:scale(0.97); }
@media (hover:hover) and (pointer:fine){ .wd:hover:not(.on){ background:var(--fill); } }
#wVal{ font:500 12px/1 var(--font-ui); color:var(--ink-soft); min-width:22px; text-align:right; font-variant-numeric:tabular-nums; }
.muted{ font-size:12px; color:var(--ink-faint); padding:0 10px; }

input[type="range"]{ -webkit-appearance:none; appearance:none; width:86px; height:4px; margin:0 6px; border-radius:2px; background:var(--fill-strong); cursor:pointer; }
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; width:18px; height:18px; border-radius:50%; background:#fff;
  box-shadow:0 0 0 .5px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.25); transition: transform 160ms var(--ease-out);
}
input[type="range"]:active::-webkit-slider-thumb{ transform:scale(1.08); }
input[type="range"]::-moz-range-thumb{ width:18px; height:18px; border:0; border-radius:50%; background:#fff; box-shadow:0 2px 6px rgba(0,0,0,.25); }

/* Control segmentado */
.seg{ display:flex; background:var(--fill); border-radius:var(--radius-sm); padding:2px; margin-left:4px; }
.seg button{ font:500 12px/1 var(--font-ui); padding:7px 10px; border-radius:7px; color:var(--ink-soft); transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out); }
.seg button:active{ opacity:.6; }
.seg button.on{ background:var(--panel); color:var(--ink); font-weight:600; box-shadow:0 1px 3px rgba(0,0,0,.12); }
body.dark .seg button.on{ background:#636366; }

/* ---------- Menús emergentes ---------- */
.pop{
  position:absolute; z-index:30; min-width:220px; padding:6px;
  background:var(--material-strong);
  -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-radius:var(--radius-md); box-shadow:var(--shadow-pop);
  opacity:0; transform:translateY(-4px) scale(0.98); transform-origin:top left; pointer-events:none; visibility:hidden;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), visibility 0s linear 180ms;
}
.pop{ overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; }
.pop.show{ opacity:1; transform:none; pointer-events:auto; visibility:visible; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), visibility 0s; }
.pop.shapes{ display:flex; gap:2px; min-width:0; padding:5px; }
.pop .item{
  display:flex; align-items:center; gap:10px; width:100%; padding:9px 10px; text-align:left;
  font:400 14px/1.2 var(--font-ui); border-radius:8px; color:var(--ink);
  transition: background-color 120ms var(--ease-out);
}
.pop .item:active{ transform:scale(0.98); }
.pop .item.on{ color:var(--accent-text); background:var(--accent-fill); font-weight:500; }
.pop .item svg{ width:18px; height:18px; flex:none; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.pop .item kbd{ margin-left:auto; font:400 12px var(--font-ui); color:var(--ink-faint); }
@media (hover:hover) and (pointer:fine){ .pop .item:hover:not(.on){ background:var(--fill); } }
.pop h4{ margin:8px 10px 4px; font:600 11px/1 var(--font-ui); letter-spacing:.04em; text-transform:uppercase; color:var(--ink-faint); }
.pop hr{ border:0; border-top:.5px solid var(--separator); margin:5px 4px; }
.pop p.note{ margin:2px 10px 8px; font-size:12.5px; line-height:1.4; color:var(--ink-soft); max-width:260px; }
.boardsw{ display:flex; gap:8px; padding:6px 10px 8px; }
.boardsw button{ width:44px; height:30px; border-radius:8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out); }
.boardsw button.on{ box-shadow: 0 0 0 2px var(--material-strong), 0 0 0 4px var(--accent); }
.boardsw button:active{ transform:scale(0.95); }
.row.col{ flex-direction:column; align-items:flex-start; gap:8px; }
.row.col .seg{ margin-left:0; }
.pop kbd, .sheet kbd{ display:inline-block; min-width:18px; padding:1px 5px; border-radius:5px; background:var(--fill); box-shadow:inset 0 -1px 0 var(--separator); font:500 11.5px/1.5 var(--font-ui); color:var(--ink); text-align:center; }
#assistPop{ width:300px; max-height:calc(100vh - 90px); overflow:auto; }
.row{ display:flex; align-items:center; justify-content:space-between; gap:14px; padding:8px 10px; font-size:14px; }

/* Interruptor estilo iOS */
.switch{ position:relative; width:46px; height:28px; flex:none; }
.switch input{ opacity:0; width:0; height:0; position:absolute; }
.switch .slider{ position:absolute; inset:0; border-radius:14px; background:var(--fill-strong); transition: background-color 200ms var(--ease-out); cursor:pointer; }
.switch .slider::before{ content:""; position:absolute; top:2px; left:2px; width:24px; height:24px; border-radius:12px; background:#fff; box-shadow:0 2px 6px rgba(0,0,0,.2); transition: transform 200ms var(--ease-out), width 200ms var(--ease-out); }
.switch input:checked + .slider{ background:#34C759; }
.switch input:checked + .slider::before{ transform:translateX(18px); }
.switch:active .slider::before{ width:28px; }
.switch:active input:checked + .slider::before{ transform:translateX(14px); }

/* ---------- Símbolos ---------- */
#symbols{ top:66px; left:50%; transform:translateX(-50%); display:none; flex-wrap:wrap; max-width:min(860px,94vw); justify-content:center; }
#symbols.show{ display:flex; }
#symbols button{ min-width:34px; height:34px; padding:0 6px; border-radius:8px; font:400 18px/1 "Cambria Math","Segoe UI Symbol",var(--font-ui); transition: background-color 120ms var(--ease-out), transform 120ms var(--ease-out); }
#symbols button:active{ transform:scale(0.94); }
@media (hover:hover) and (pointer:fine){ #symbols button:hover{ background:var(--fill); } }

#editor{
  position:absolute; display:none; z-index:5; margin:0; padding:0; min-width:20px;
  border:1.5px dashed var(--accent); border-radius:3px; background:transparent; outline:none; resize:none; overflow:hidden; white-space:pre;
  font-family:"Segoe UI","Cambria Math",system-ui,sans-serif; user-select:text; -webkit-user-select:text;
}

/* ---------- Ventana (créditos) ---------- */
#modalBg{ position:fixed; inset:0; z-index:50; display:grid; place-items:center; background:var(--scrim); opacity:0; visibility:hidden; pointer-events:none; transition: opacity 200ms var(--ease-out), visibility 0s linear 200ms; }
#modalBg.show{ opacity:1; visibility:visible; pointer-events:auto; transition: opacity 200ms var(--ease-out), visibility 0s; }
.modal{
  width:min(400px,92vw); padding:28px 24px 20px; user-select:text;
  background:var(--panel); border-radius:var(--radius-lg); box-shadow:var(--shadow-pop);
  transform:translateY(8px) scale(0.98); transition: transform 240ms var(--ease-drawer);
}
#modalBg.show .modal{ transform:none; }
.modal.about{ text-align:center; }
.modal h3{ margin:10px 0 2px; font:600 22px/1.2 var(--font-display); letter-spacing:-0.022em; }
.modal .ver{ margin:0 0 14px; color:var(--ink-soft); font-size:13.5px; line-height:1.5; }
.modal p{ margin:0 0 10px; }
.socials{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:18px 0 6px; }
.socials a{
  display:flex; flex-direction:column; align-items:center; gap:8px; padding:14px 6px 11px;
  border-radius:var(--radius-md); background:var(--fill); color:var(--ink); text-decoration:none;
  font:500 13px/1 var(--font-ui); letter-spacing:-0.01em;
  transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.socials a:active{ transform:scale(0.97); }
@media (hover:hover) and (pointer:fine){ .socials a:hover{ background:var(--fill-strong); } }
.socials .badge{ width:40px; height:40px; border-radius:12px; display:grid; place-items:center; color:#fff; box-shadow:0 4px 12px -4px rgba(0,0,0,.3); }
.socials .badge svg{ width:21px; height:21px; }
.socials .ig .badge{ background:radial-gradient(circle at 30% 107%, #FDF497 0%, #FDF497 5%, #FD5949 45%, #D6249F 60%, #285AEB 90%); }
.socials .gh .badge{ background:#24292F; }
.socials .li .badge{ background:#0A66C2; }
body.dark .socials .gh .badge{ background:#F5F5F7; color:#111; }
.modal.about img{ border-radius:16px; }
.actions{ display:flex; justify-content:center; gap:8px; margin-top:16px; }
.actions button{
  height:40px; padding:0 22px; border-radius:980px; font:500 15px/1 var(--font-ui);
  background:var(--fill); transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.actions button:active{ transform:scale(0.97); }
.actions button.primary{ background:var(--accent); color:#fff; }

/* ---------- Bandeja de lápices ---------- */
.preset .tip{ position:absolute; left:10px; right:10px; bottom:4px; border-radius:3px; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18); pointer-events:none; }
.preset.hl .tip{ opacity:.75; }
.preset .num{ position:absolute; top:2px; right:4px; font:600 9px/1 var(--font-ui); color:var(--ink-faint); pointer-events:none; }
.ib.add{ width:26px; color:var(--ink-faint); }
.ib.add svg{ width:16px; height:16px; }
#btnStyle .swatch{ width:22px; height:22px; border-radius:50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); display:grid; place-items:center; }
#btnStyle .swatch i{ display:block; border-radius:50%; background:var(--material-strong); }
#btnStyle:disabled .swatch{ background:var(--fill-strong) !important; }

#stylePop{ width:292px; }
.kinds{ display:grid; grid-template-columns:repeat(5,1fr); gap:4px; padding:2px 6px 6px; }
.kinds button{
  display:flex; flex-direction:column; align-items:center; gap:4px; padding:8px 2px 6px; border-radius:var(--radius-sm);
  font:500 11px/1.1 var(--font-ui); color:var(--ink-soft);
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}
.kinds button svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.kinds button.on{ background:var(--accent-fill); color:var(--accent-text); }
.kinds button:active{ transform:scale(0.96); }
@media (hover:hover) and (pointer:fine){ .kinds button:hover:not(.on){ background:var(--fill); } }
.colors{ display:flex; flex-wrap:wrap; gap:8px; padding:4px 10px 10px; }
.colors .sw{ margin:0; width:26px; height:26px; }
.widths{ display:flex; align-items:center; flex-wrap:wrap; gap:2px; padding:0 6px 6px; }
.widths input[type="range"]{ flex:1; min-width:90px; }
.widths .seg{ margin:6px 4px 2px; }
.pop .item.danger{ color:var(--danger); }
.widths.opacity{ padding:0 10px 8px; }
.widths.opacity input[type="range"]{ flex:1; background:linear-gradient(90deg, var(--fill), var(--ink-soft)); }
#opVal{ font:500 12px/1 var(--font-ui); color:var(--ink-soft); min-width:36px; text-align:right; font-variant-numeric:tabular-nums; }

/* ---------- Panel de atajos ---------- */
#keysPanel{ width:min(380px, calc(100vw - 24px)); }
.kgroup{ padding:6px 2px 10px; }
.kgroup + .kgroup{ border-top:.5px solid var(--separator); }
.kgroup h4{ margin:8px 6px 8px; font:600 11px/1 var(--font-ui); letter-spacing:.04em; text-transform:uppercase; color:var(--ink-faint); }
.krow{ display:grid; grid-template-columns:132px 1fr; align-items:center; gap:12px; padding:5px 6px; border-radius:8px; font-size:13.5px; color:var(--ink); }
@media (hover:hover) and (pointer:fine){ .krow:hover{ background:var(--fill); } }
.krow .kk{ display:flex; align-items:center; gap:3px; flex-wrap:wrap; }
.krow .kk i{ font-style:normal; color:var(--ink-faint); font-size:11px; padding:0 1px; }
.sheet kbd{ min-width:22px; padding:2px 6px; font-size:12px; line-height:1.5; border-radius:6px; background:var(--panel); box-shadow:0 0 0 .5px var(--rule), 0 1px 0 var(--rule); }
.tips p{ margin:6px 6px 8px; font-size:13px; line-height:1.5; color:var(--ink-soft); }
.tips b{ color:var(--ink); font-weight:600; }

/* ---------- Panel de gráfica (hoja lateral) ---------- */
.sheet{
  position:absolute; z-index:20; top:70px; right:12px; bottom:76px; width:min(360px, calc(100vw - 24px));
  display:flex; flex-direction:column;
  background:var(--material-strong);
  -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-pop);
  opacity:0; transform:translateX(16px); visibility:hidden; pointer-events:none;
  transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-drawer), visibility 0s linear 260ms;
  user-select:text;
}
.sheet.show{ opacity:1; transform:none; visibility:visible; pointer-events:auto; transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-drawer), visibility 0s; }
.sheet header{ display:flex; align-items:center; justify-content:space-between; padding:12px 10px 4px 18px; }
.sheet h3{ margin:0; font:600 19px/1.2 var(--font-display); letter-spacing:-0.022em; }
.gp-body{ overflow:auto; padding:4px 12px 14px; flex:1; }
.gprow{ display:grid; grid-template-columns:auto 1fr auto auto; align-items:center; gap:6px; padding:5px 4px; border-radius:var(--radius-sm); }
.gprow .tag{ grid-column:1 / -1; font:500 11px/1 var(--font-ui); color:var(--ink-faint); margin:2px 0 -2px 38px; }
.gprow input[type=color]{ width:28px; height:28px; border:0; padding:0; background:none; cursor:pointer; border-radius:50%; }
.gprow input[type=color]::-webkit-color-swatch-wrapper{ padding:0; }
.gprow input[type=color]::-webkit-color-swatch{ border:0; border-radius:50%; }
.gprow input[type=color]::-moz-color-swatch{ border:0; border-radius:50%; }
.gprow input[type=text]{
  min-width:0; height:36px; padding:0 10px; border:0; border-radius:var(--radius-sm);
  background:var(--fill); color:var(--ink); font:14.5px var(--font-mono);
  transition: box-shadow 160ms var(--ease-out);
}
.gprow input[type=text]:focus{ box-shadow:0 0 0 4px var(--focus); }
.gprow.bad input[type=text]{ box-shadow:0 0 0 1.5px var(--danger); }
.gprow .mini{ width:28px; height:28px; border-radius:50%; display:grid; place-items:center; color:var(--ink-faint); transition: background-color 140ms var(--ease-out), transform 140ms var(--ease-out); }
.gprow .mini svg{ width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.gprow .mini:active{ transform:scale(0.92); }
.gprow.hidden input[type=text]{ opacity:.45; }
@media (hover:hover) and (pointer:fine){ .gprow .mini:hover{ background:var(--fill); } }
.gprow .err{ grid-column:2 / -1; color:var(--danger); font-size:12px; margin:-2px 0 2px 2px; }
.link{ color:var(--accent-text); font-size:14px; font-weight:500; padding:8px 6px; }
.gp-help{ margin:2px 4px 8px; font-size:13px; color:var(--ink-soft); }
.gp-help summary{ cursor:pointer; color:var(--ink-soft); padding:4px 2px; }
.gp-help ul{ margin:6px 0 4px; padding-left:16px; line-height:1.8; }
.gp-help code, .note code{ background:var(--fill); padding:1px 5px; border-radius:5px; font:12px var(--font-mono); color:var(--ink); }
#gpSliders:not(:empty){ margin:4px 0 6px; padding:8px 4px 2px; border-top:.5px solid var(--separator); }
.gpslider{ display:grid; grid-template-columns:22px 1fr 54px 28px; align-items:center; gap:8px; padding:4px 2px; }
.gpslider b{ font:italic 600 17px "Cambria Math", serif; text-align:center; }
.gpslider input[type=range]{ width:auto; margin:0; }
.gpslider input[type=number]{ width:54px; height:28px; border:0; border-radius:7px; padding:0 6px; background:var(--fill); color:var(--ink); font:13px var(--font-mono); }
.gpslider .lims{ grid-column:2 / 3; display:flex; justify-content:space-between; gap:6px; margin-top:-4px; }
.gpslider .lims input{ width:52px; height:22px; font-size:11px; background:transparent; color:var(--ink-faint); }
.gpslider .mini{ width:28px; height:28px; border-radius:50%; display:grid; place-items:center; color:var(--accent-text); background:var(--accent-fill); transition: transform 140ms var(--ease-out); }
.gpslider .mini svg{ width:14px; height:14px; fill:currentColor; stroke:none; }
.gpslider .mini:active{ transform:scale(0.92); }
.gp-sec{ border-top:.5px solid var(--separator); margin-top:6px; padding-top:6px; }
.gp-sec .row{ padding:7px 4px; }
.kpick{ display:flex; align-items:center; gap:6px; color:var(--ink-soft); font-size:13px; }
.kpick select{ height:30px; border:0; border-radius:8px; padding:0 6px; font:13px var(--font-ui); background:var(--fill); color:var(--ink); }
.gp-view{ display:flex; gap:6px; padding:8px 4px 4px; }
.gp-view button{
  flex:1; height:34px; border-radius:var(--radius-sm); background:var(--fill); display:grid; place-items:center; font:500 13px/1 var(--font-ui);
  transition: background-color 140ms var(--ease-out), transform 140ms var(--ease-out);
}
.gp-view button svg{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.gp-view button:active{ transform:scale(0.97); }
@media (hover:hover) and (pointer:fine){ .gp-view button:hover{ background:var(--fill-strong); } }
.gp-sec .note{ margin:8px 4px 0; font-size:12.5px; line-height:1.45; color:var(--ink-soft); }

/* ---------- Aviso ---------- */
#toast{
  position:fixed; left:50%; bottom:calc(76px + env(safe-area-inset-bottom,0px)); z-index:60; pointer-events:none;
  background:rgba(28,28,30,.97); color:#fff; padding:11px 18px; border-radius:16px;
  font:500 14px/1.35 var(--font-ui); letter-spacing:-0.01em; box-shadow:0 10px 30px -8px rgba(0,0,0,.35);
  opacity:0; transform:translate(-50%, 8px); transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}
body.dark #toast{ background:rgba(58,58,60,.97); }
#toast.show{ opacity:1; transform:translate(-50%, 0); }

/* ---------- Editor de fórmulas ---------- */
.mathpop{
  position:absolute; z-index:22; top:72px; left:50%; width:min(560px, calc(100vw - 24px));
  background:var(--material-strong); -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-pop); padding:14px 14px 12px;
  opacity:0; visibility:hidden; transform:translate(-50%, -6px) scale(0.98); pointer-events:none;
  transition: opacity 180ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
  user-select:text;
}
.mathpop.show{ opacity:1; visibility:visible; transform:translate(-50%, 0); pointer-events:auto; transition: opacity 180ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s; }
.mx-head{ display:flex; align-items:baseline; gap:10px; margin:0 4px 8px; }
.mx-head h4{ margin:0; font:600 17px/1.2 var(--font-display); letter-spacing:-0.02em; }
.mx-hint{ font-size:12px; color:var(--ink-faint); }
.mx-preview{ min-height:64px; max-height:200px; overflow:auto; display:grid; place-items:center; padding:10px; border-radius:var(--radius-md); background:var(--panel); color:var(--ink); font-size:20px; }
.mx-preview.empty{ color:var(--ink-faint); font-size:13px; }
.mx-err{ color:var(--danger); font-size:12px; min-height:16px; margin:4px 4px 2px; }
#mxInput{ width:100%; resize:vertical; min-height:44px; border:0; border-radius:var(--radius-sm); background:var(--fill); color:var(--ink); padding:10px 12px; font:14px/1.45 var(--font-mono); outline:none; transition: box-shadow 160ms var(--ease-out); }
#mxInput:focus{ box-shadow:0 0 0 4px var(--focus); }
.mx-tpl{ display:grid; grid-template-columns:repeat(12, 1fr); gap:3px; margin:10px 0 6px; }
.mx-tpl button{ height:32px; border-radius:7px; font:500 14px/1 "Cambria Math","Segoe UI Symbol",var(--font-ui); color:var(--ink); transition: background-color 120ms var(--ease-out), transform 120ms var(--ease-out); }
.mx-tpl button:active{ transform:scale(0.94); }
@media (hover:hover) and (pointer:fine){ .mx-tpl button:hover{ background:var(--fill); } }
.mx-actions{ display:flex; justify-content:flex-end; gap:8px; margin-top:6px; }
.mx-actions button{ height:36px; padding:0 18px; border-radius:980px; font:500 14px/1 var(--font-ui); background:var(--fill); transition: transform 160ms var(--ease-out); }
.mx-actions button:active{ transform:scale(0.97); }
.mx-actions .primary{ background:var(--accent); color:#fff; }
@media (max-width: 640px){ .mx-tpl{ grid-template-columns:repeat(8, 1fr); } }

/* ---------- Cortina y foco ---------- */
#curtain{
  position:absolute; left:0; right:0; bottom:0; top:120px; z-index:6;
  background: var(--ct-bg, #fff);
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,.035) 0 2px, transparent 2px 48px);
  box-shadow: 0 -10px 30px -6px rgba(0,0,0,.35);
}
.ct-handle{
  position:relative; height:46px; display:flex; align-items:center; justify-content:center; gap:12px; cursor:ns-resize; touch-action:none;
  background:var(--material-strong); -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-bottom:.5px solid var(--separator); color:var(--ink-soft); font:500 13px/1 var(--font-ui);
}
.ct-handle .grip{ width:44px; height:5px; border-radius:3px; background:var(--fill-strong); }
.ct-handle button{ position:absolute; right:10px; top:7px; width:32px; height:32px; border-radius:50%; display:grid; place-items:center; color:var(--ink-faint); transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out); }
.ct-handle button svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
.ct-handle button:active{ transform:scale(0.92); }
@media (hover:hover) and (pointer:fine){ .ct-handle button:hover{ background:var(--fill); } }
#spot{ position:absolute; inset:0; z-index:6; pointer-events:none;
  background: radial-gradient(circle at var(--sx, 50%) var(--sy, 50%), transparent 0, transparent var(--sr, 150px), rgba(0,0,0,.78) calc(var(--sr, 150px) + 1.5px)); }
#grpPop{ width:270px; }

/* ---------- Barra de selección ---------- */
#selbar{ z-index:12; }
#selbar .ib{ width:36px; height:36px; }
body.present #selbar{ display:none; }

/* ---------- Aviso de novedades ---------- */
.wn{
  position:absolute; right:14px; bottom:calc(70px + env(safe-area-inset-bottom,0px)); z-index:25;
  width:min(340px, calc(100vw - 28px)); display:flex; flex-direction:column;
  background:var(--material-strong);
  -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-radius:16px; box-shadow:var(--shadow-pop);
  animation: wnIn 320ms var(--ease-out) both;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
@keyframes wnIn{ from{ opacity:0; transform:translateY(12px) scale(0.98); } }
.wn.leaving{ opacity:0; transform:translateY(10px); pointer-events:none; }
.wn-body{ display:grid; grid-template-rows:0fr; transition: grid-template-rows 300ms var(--ease-drawer); }
.wn.open .wn-body{ grid-template-rows:1fr; }
.wn-inner{ min-height:0; overflow:hidden; }
.wn-sub{ margin:14px 16px 6px; font:600 11px/1 var(--font-ui); letter-spacing:.04em; text-transform:uppercase; color:var(--ink-faint); }
.wn ul{ list-style:none; margin:0; padding:2px 10px 6px; max-height:min(52vh, 420px); overflow:auto; }
.wn li{ display:grid; grid-template-columns:24px 1fr; gap:6px; padding:7px 6px; font-size:13.5px; line-height:1.45; color:var(--ink); border-radius:8px; }
.wn li .e{ font-size:15px; line-height:1.35; }
.wn li.wn-ver{ display:block; padding:12px 6px 4px; font:600 11px/1 var(--font-ui); letter-spacing:.04em; text-transform:uppercase; color:var(--accent-text); }
.wn li.wn-ver:first-child{ padding-top:4px; }
.wn-head{ display:flex; align-items:center; gap:2px; padding:6px; border-top:.5px solid transparent; transition: border-color 200ms var(--ease-out); }
.wn.open .wn-head{ border-top-color:var(--separator); }
.wn-toggle{
  flex:1; display:flex; align-items:center; gap:10px; min-width:0; padding:8px 8px 8px 6px; border-radius:11px; text-align:left;
  transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.wn-toggle:active{ transform:scale(0.98); }
@media (hover:hover) and (pointer:fine){ .wn-toggle:hover{ background:var(--fill); } .wn-x:hover{ background:var(--fill); } }
.wn-badge{ width:30px; height:30px; flex:none; display:grid; place-items:center; border-radius:9px; background:var(--accent-fill); font-size:15px; }
.wn-title{ flex:1; min-width:0; font:600 14px/1.25 var(--font-ui); letter-spacing:-0.01em; color:var(--ink); }
.wn-title small{ display:block; font:400 12px/1.3 var(--font-ui); color:var(--ink-soft); margin-top:2px; }
.wn-chev{ width:18px; height:18px; flex:none; fill:none; stroke:var(--ink-soft); stroke-width:2; stroke-linecap:round; stroke-linejoin:round; transition: transform 300ms var(--ease-drawer); }
.wn.open .wn-chev{ transform:rotate(180deg); }
.wn-x{ width:32px; height:32px; flex:none; display:grid; place-items:center; border-radius:50%; color:var(--ink-faint); transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out); }
.wn-x:active{ transform:scale(0.92); }
.wn-x svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
body.present .wn{ display:none; }

#fileInput{ display:none; }
body.present .bar:not(#topbar), body.present #symbols, body.present .sheet{ display:none; }

@media (max-width: 1100px){
  #topbar{ flex-wrap:wrap; justify-content:center; width:max-content; max-width:calc(100vw - 16px); top:8px; }
  #symbols{ top:116px; }
}

/* =====================================================================
   Celulares (vertical y horizontal): barra abajo al alcance del pulgar
   ===================================================================== */
@media (max-width: 760px), (max-height: 500px) and (pointer: coarse){
  #brand, #zoombar{ display:none !important; }
  #topbar{
    top:auto; bottom:calc(8px + env(safe-area-inset-bottom,0px)); left:8px; right:8px; transform:none;
    width:auto; max-width:none; flex-wrap:nowrap; justify-content:flex-start;
    overflow-x:auto; overflow-y:hidden; scrollbar-width:none; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain;
    border-radius:16px; padding:4px;
  }
  #topbar::-webkit-scrollbar{ display:none; }
  #topbar > *, #tools > *, #presets > *{ flex:none; }
  #topbar .ib, #tools .ib{ width:42px; height:42px; }
  #btnUndo{ order:-3; } #btnRedo{ order:-2; margin-right:4px; }
  #btnRedo::after{ content:""; position:absolute; right:-5px; top:9px; bottom:9px; width:1px; background:var(--separator); }
  /* sombra que indica que hay más herramientas a la derecha */
  #topbar.more{ -webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image:linear-gradient(90deg, #000 calc(100% - 28px), transparent); }

  #pagebar{ top:calc(8px + env(safe-area-inset-top,0px)); bottom:auto; padding:3px; }
  #pagebar .ib{ width:36px; height:36px; }
  #pageLabel{ min-width:58px; font-size:13px; }
  #symbols{ top:calc(58px + env(safe-area-inset-top,0px)); left:8px; right:8px; transform:none; max-width:none; flex-wrap:nowrap; justify-content:flex-start; overflow-x:auto; scrollbar-width:none; }
  #symbols::-webkit-scrollbar{ display:none; }
  #symbols button{ flex:none; }

  .pop{ max-width:calc(100vw - 16px); max-height:calc(100vh - 120px); overflow:auto; }
  #stylePop, #grpPop, #assistPop{ width:min(300px, calc(100vw - 16px)); }

  .sheet{
    top:auto; left:8px; right:8px; bottom:calc(64px + env(safe-area-inset-bottom,0px)); width:auto;
    max-height:min(62vh, 560px); border-radius:18px;
    transform:translateY(16px);
  }
  .sheet.show{ transform:none; }
  #keysPanel{ width:auto; }
  .krow{ grid-template-columns:104px 1fr; }

  .mathpop{ top:calc(8px + env(safe-area-inset-top,0px)); width:calc(100vw - 16px); padding:12px 10px 10px; }
  .mx-tpl{ grid-template-columns:repeat(9, 1fr); }
  .mx-hint{ display:none; }

  .wn{ right:8px; left:8px; width:auto; bottom:calc(66px + env(safe-area-inset-bottom,0px)); }
  #toast{ bottom:calc(74px + env(safe-area-inset-bottom,0px)); max-width:calc(100vw - 32px); text-align:center; }
  .ct-handle .ct-txt{ font-size:12px; }

  /* iOS no hace zoom al escribir si el texto mide al menos 16 px */
  input[type=text], input[type=number], textarea#mxInput, select{ font-size:16px !important; }
}
@media (pointer: coarse){ #menuPop kbd{ display:none; } }
/* Horizontal en celular: barras más bajas */
@media (max-height: 500px) and (pointer: coarse){
  #topbar .ib, #tools .ib{ width:38px; height:38px; }
  .sheet{ max-height:calc(100vh - 80px); bottom:calc(58px + env(safe-area-inset-bottom,0px)); }
}

/* ---------- Pizarra flotante ---------- */
.fpad{
  position:fixed; z-index:20; display:flex; flex-direction:column; overflow:hidden;
  border-radius:var(--radius-md); box-shadow:var(--shadow-pop);
  animation: fp-in 200ms var(--ease-out);
}
@keyframes fp-in{ from{ opacity:0; transform:translateY(6px) scale(.98); } to{ opacity:1; transform:none; } }
.fp-head, .fp-oprow{ background:var(--material-strong); -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px); }
.fp-head{ flex:none; display:flex; align-items:center; gap:1px; height:40px; padding:0 4px 0 6px; cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; }
.fpad.dragging .fp-head{ cursor:grabbing; }
.fpad.pinned .fp-head{ cursor:default; }
.fp-grip{ display:grid; place-items:center; width:18px; color:var(--ink-faint); }
.fp-grip svg{ width:16px; height:16px; fill:currentColor; stroke:none; }
.fpad.pinned .fp-grip{ opacity:.35; }
.fp-title{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font:600 13px/1 var(--font-ui); color:var(--ink-soft); padding-left:4px; }
.fpad .ib.sm{ width:32px; height:32px; }
.fpad .ib.sm svg{ width:17px; height:17px; }
.fp-canvas{ position:static; flex:1; min-height:0; width:100%; display:block; touch-action:none; cursor:crosshair; border-top:.5px solid var(--separator); }
.fp-resize{ position:absolute; right:0; bottom:0; width:22px; height:22px; cursor:nwse-resize; touch-action:none;
  background: linear-gradient(135deg, transparent 52%, var(--ink-faint) 52%, var(--ink-faint) 58%, transparent 58%, transparent 70%, var(--ink-faint) 70%, var(--ink-faint) 76%, transparent 76%);
  opacity:.7; }
.fpad.pinned .fp-resize{ display:none; }
@media (max-width: 760px), (max-height: 500px) and (pointer: coarse){
  .fp-head{ height:44px; }
  .fpad .ib.sm{ width:38px; height:38px; }
  .fp-resize{ width:30px; height:30px; }
}

/* ---------- Tarjeta de ayuda al pasar el mouse ---------- */
.tipcard{
  position:fixed; z-index:40; width:250px; padding:10px 12px; pointer-events:none;
  background:var(--material-strong);
  -webkit-backdrop-filter:saturate(180%) blur(20px); backdrop-filter:saturate(180%) blur(20px);
  border-radius:var(--radius-sm); box-shadow:var(--shadow-pop);
  opacity:0; transform:translateY(-3px); transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.tipcard.show{ opacity:1; transform:none; }
.tc-head{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:4px; font:600 13px/1.2 var(--font-ui); color:var(--ink); }
.tc-head kbd{ font:500 11px/1 var(--font-ui); padding:3px 6px; border-radius:5px; background:var(--fill); color:var(--ink-soft); }
.tipcard p{ margin:0; font:400 12.5px/1.4 var(--font-ui); color:var(--ink-soft); }

/* ---------- Grupos de herramientas ---------- */
.ib.more{ width:18px; color:var(--ink-faint); }
.ib.more svg{ width:14px; height:14px; }
#grpPop .gi{ display:flex; align-items:center; gap:2px; }
#grpPop .gi .item{ flex:1; min-width:0; }
#grpPop .gi .item span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pinb{ flex:none; width:32px; height:32px; display:grid; place-items:center; border-radius:8px; color:var(--ink-faint); opacity:.55;
  transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out), opacity 120ms var(--ease-out), transform 120ms var(--ease-out); }
.pinb svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.pinb.on{ color:var(--accent-text); background:var(--accent-fill); opacity:1; }
.pinb:active{ transform:scale(.97); }
@media (hover:hover) and (pointer:fine){ .pinb:hover{ background:var(--fill); opacity:1; } .pinb.on:hover{ background:var(--accent-fill); } }
.pi-ico{ position:relative; display:grid; place-items:center; width:20px; height:20px; }
.pi-ico i{ position:absolute; left:2px; right:2px; bottom:-2px; height:4px; border-radius:2px; }

.fp-oprow{ flex:none; display:flex; align-items:center; gap:10px; padding:4px 12px 8px; border-top:.5px solid var(--separator); font:500 12px/1 var(--font-ui); color:var(--ink-soft); }
.fp-oprow[hidden]{ display:none; }
.fp-oprow input{ flex:1; accent-color:var(--accent); }
.fp-oprow b{ width:36px; text-align:right; font-weight:600; font-variant-numeric:tabular-nums; }
.fpad.see .fp-canvas{ border-top-color:transparent; }
.fpad.see{ outline:1.5px dashed var(--ink-faint); outline-offset:-1px; }
