
@font-face {
  font-family: "Nunito";
  src: url("./fonts/nunito-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --panel: #f4f7fb;
  --card: #ffffff;
  --ink: #1f2a37;
  --text-soft: #3d4a5c;
  --muted: #6b7686;
  --line: #e3e9f1;          /* cuadrícula del lienzo */
  --edge: #d6dee9;
  --accent: #2b6cb0;
  --accent-dark: #225a94;
  --accent-soft: #dbe8f6;
  --accent-ink: #ffffff;
  --hover: #e8eef6;
  --track: #d8e1ec;
  --shadow: 0 10px 30px rgba(31, 42, 55, .16), 0 1px 3px rgba(31, 42, 55, .12);
  --radius: 8px;
  --font: "Nunito", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --top: 46px;
  --strip: 80px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--paper); color: var(--ink); font: 15px/1.35 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; background: transparent; border: 0; border-radius: var(--radius); padding: 8px 12px; font-weight: 700; transition: background .12s, color .12s; }
button:hover { background: var(--hover); }
button:disabled { opacity: .35; cursor: default; background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; }
.solid { background: var(--accent); color: var(--accent-ink); }
.solid:hover { background: var(--accent-dark); }
.linkbtn { display: inline-flex; align-items: center; padding: 8px 12px; border-radius: var(--radius); font-weight: 700; color: var(--ink); text-decoration: none; }
.linkbtn:hover { background: var(--hover); }
.linkbtn.solid, .linkbtn.solid:hover { color: var(--accent-ink); }

.top { height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 14px 0 16px; background: var(--paper); border-bottom: 1px solid var(--edge); position: relative; z-index: 3; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 21px; color: var(--ink); text-decoration: none; letter-spacing: -.3px; }
.brand img { width: 30px; height: 30px; object-fit: contain; flex: none; }
:root[data-theme="oscuro"] .brand img, :root[data-theme="nocherosa"] .brand img, :root[data-theme="nocheverde"] .brand img, :root[data-theme="nochemorada"] .brand img { filter: invert(1); }
#connection { color: var(--muted); font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.top-actions { display: flex; gap: 6px; }

main { position: relative; height: calc(100dvh - var(--top)); }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; -webkit-touch-callout: none; user-select: none; }
#overlay { pointer-events: none; }

.tools { position: absolute; top: 0; bottom: 0; left: 0; width: var(--strip); background: var(--panel); border-right: 1px solid var(--edge); overflow-y: auto; display: flex; flex-direction: column; padding: 6px 6px; gap: 2px; }
.tools button { flex-direction: column; gap: 3px; width: 100%; min-height: 56px; padding: 7px 2px; font-size: 11.5px; font-weight: 700; line-height: 1.1; color: var(--text-soft); border-radius: 10px; }
.tools button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.tools button:disabled { opacity: .4; }
.tools i { display: block; height: 1px; background: var(--edge); margin: 4px 8px; flex: none; }

.flyout { position: absolute; left: calc(var(--strip) + 10px); top: 8px; max-width: min(520px, calc(100% - var(--strip) - 24px)); background: var(--card); border: 1px solid var(--edge); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; z-index: 4; display: flex; flex-direction: column; gap: 6px; }
.flyout::before { content: ""; position: absolute; left: -7px; top: var(--notch, 28px); width: 12px; height: 12px; background: var(--card); border-left: 1px solid var(--edge); border-bottom: 1px solid var(--edge); transform: translateY(-50%) rotate(45deg); }
.fly-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.fly-group + .fly-group { border-top: 1px solid var(--line); padding-top: 6px; }
.fly-group > b { display: none; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.chips button { padding: 4px 10px; background: var(--panel); font-size: 13px; color: var(--text-soft); border-radius: 7px; }
.chips button:hover { background: var(--hover); }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.fly-range { display: grid; grid-template-columns: 76px 120px 52px; grid-template-areas: "l s o"; align-items: center; gap: 0 8px; font-size: 13px; font-weight: 700; color: var(--text-soft); }
.fly-range > span { grid-area: l; }
.fly-range > input { grid-area: s; }
.fly-range > output { grid-area: o; text-align: right; }
output { font-family: var(--mono); color: var(--muted); font-size: 12px; font-weight: 400; }
.fly-hint { max-width: 250px; font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--track) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }

.fly-check, .check { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.fly-check input, .check input { -webkit-appearance: none; appearance: none; position: relative; width: 36px; height: 20px; border-radius: 10px; background: #c9d4e2; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.fly-check input::after, .check input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.fly-check input:checked, .check input:checked { background: var(--accent); }
.fly-check input:checked::after, .check input:checked::after { transform: translateX(16px); }

.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-now { width: 30px; height: 30px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--swatch, #000); box-shadow: 0 0 0 1px var(--edge), 0 1px 4px rgba(0, 0, 0, .18); }
.color-now:hover { background: var(--swatch, #000); box-shadow: 0 0 0 2px var(--accent), 0 1px 4px rgba(0, 0, 0, .18); }
.recents { display: flex; gap: 5px; flex-wrap: wrap; max-width: 330px; }
.swatch { width: 20px; height: 20px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 1px var(--edge); }
.swatch:hover { background: var(--swatch); box-shadow: 0 0 0 2px var(--accent); }
.wheel { display: flex; flex-direction: column; gap: 10px; width: 156px; margin-top: 4px; }
.wheel-disc { position: static; inset: auto; width: 156px; height: 156px; border-radius: 50%; touch-action: none; cursor: crosshair; box-shadow: 0 0 0 1px var(--edge); }
.wheel input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(to right, #000, var(--tint, #fff)); }
.wheel input[type=range]::-moz-range-track { background: linear-gradient(to right, #000, var(--tint, #fff)); }
.wheel-hex { width: 100%; padding: 6px 10px; border: 1px solid var(--edge); border-radius: 8px; font-family: var(--mono); font-size: 13px; background: var(--card); }

.selbar { position: absolute; left: calc(50% + var(--strip) / 2); top: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--edge); border-radius: 12px; box-shadow: var(--shadow); padding: 6px 8px 6px 14px; z-index: 4; white-space: nowrap; }
.seg { display: inline-flex; gap: 2px; background: var(--panel); border-radius: 10px; padding: 3px; }
.selbar .seg button { padding: 6px 12px; font-size: 13px; background: transparent; color: var(--text-soft); }
.selbar .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.selbar > button { padding: 7px 14px; font-size: 14px; background: var(--panel); }
.selbar > button:hover { background: var(--hover); }
.selbar .solid { background: var(--accent); }
.selbar .solid:hover { background: var(--accent-dark); }

#empty { position: absolute; left: calc(50% + var(--strip) / 2); top: 40%; transform: translate(-50%, -50%); max-width: 360px; margin: 0; text-align: center; color: var(--muted); font-size: 17px; pointer-events: none; }

.bar { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; align-items: center; }
.zoomset { display: flex; align-items: center; background: var(--card); border: 1px solid var(--edge); border-radius: 10px; box-shadow: 0 2px 8px rgba(31, 42, 55, .08); padding: 2px; }
.zoomset button { padding: 6px 10px; font-size: 14px; border-radius: 8px; }
.bar > .solid { padding: 9px 16px; border-radius: 10px; box-shadow: 0 2px 8px rgba(43, 108, 176, .3); }
#reset { min-width: 62px; font-family: var(--mono); font-size: 13px; font-weight: 400; }
.foot { position: absolute; left: calc(var(--strip) + 14px); bottom: 14px; max-width: 40%; font-size: 13px; color: var(--muted); pointer-events: none; }
#status { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; background: var(--paper); color: var(--ink); border: 0; border-radius: 14px; box-shadow: var(--shadow); }
dialog::backdrop { background: #1f2a3788; }
dialog h2 { margin: 0 0 8px; font-size: 21px; font-weight: 800; }
dialog h3 { margin: 18px 0 6px; font-size: 14px; font-weight: 800; }
dialog p { color: var(--muted); font-size: 14px; }
dialog label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 4px; }
dialog input:not([type=checkbox]), dialog textarea, dialog select { width: 100%; padding: 9px 10px; background: var(--card); border: 1px solid var(--edge); border-radius: 8px; }
dialog .close { position: absolute; right: 10px; top: 10px; font-size: 22px; padding: 2px 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions button:not(.solid) { border: 1px solid var(--edge); }
.stack { display: grid; gap: 6px; }
.settings-btn { margin-top: auto; }
#keys-list { display: grid; gap: 4px; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.key-row button { min-width: 150px; padding: 4px 10px; font-family: var(--mono); font-size: 13px; font-weight: 400; border: 1px solid var(--edge); background: var(--card); }
.key-row button:hover { background: var(--hover); }
@media (pointer: coarse) {
  .chips button { padding: 9px 14px; }
  .swatch { width: 28px; height: 28px; }
  .color-now { width: 38px; height: 38px; }
  input[type=range] { height: 30px; }
}
.stack button, #room-list button { justify-content: flex-start; border: 1px solid var(--edge); background: var(--card); }
#room-list { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
#room-list button { color: var(--ink); justify-content: space-between; width: 100%; }
#safety-list p, #safety-admin p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; color: var(--ink); }
#safety-list button, #safety-admin button { padding: 3px 9px; font-size: 13px; border: 1px solid var(--edge); background: var(--card); }

.tools-toggle { display: none; }
@media (max-width: 760px) {
  :root { --top: 44px; }
  .top { padding: 0 8px 0 12px; gap: 8px; }
  .brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 21px; color: var(--ink); text-decoration: none; letter-spacing: -.3px; }
.brand img { width: 30px; height: 30px; object-fit: contain; flex: none; }
:root[data-theme="oscuro"] .brand img, :root[data-theme="nocherosa"] .brand img, :root[data-theme="nocheverde"] .brand img, :root[data-theme="nochemorada"] .brand img { filter: invert(1); }
  .top-actions { gap: 4px; }
  .top-actions > * { padding: 6px 9px; font-size: 14px; white-space: nowrap; }
  /* Barra de herramientas flotante en la esquina izquierda, con una pestaña para esconderla. */
  :root { --strip: 0px; --tw: 62px; }
  .tools { top: 8px; left: 8px; right: auto; bottom: 52px; width: var(--tw); flex-direction: column; overflow-x: hidden; overflow-y: auto; border: 1px solid var(--edge); border-radius: 16px; box-shadow: var(--shadow); padding: 5px 4px; gap: 1px; z-index: 5;
    transition: transform .32s cubic-bezier(.3, .9, .3, 1), opacity .22s ease, visibility 0s; }
  .tools button { width: 100%; min-width: 0; min-height: 46px; flex: none; font-size: 10.5px; padding: 5px 0; gap: 2px; }
  .tools i { width: auto; height: 1px; margin: 3px 8px; flex: none; }
  .tools-toggle { display: flex; position: absolute; z-index: 6; top: 12px; left: calc(var(--tw) + 14px); width: 24px; height: 52px; padding: 0; align-items: center; justify-content: center; background: var(--card); color: var(--text-soft); border: 1px solid var(--edge); border-radius: 0 12px 12px 0; box-shadow: var(--shadow);
    transition: left .32s cubic-bezier(.3, .9, .3, 1); }
  .tools-toggle svg { width: 18px; height: 18px; transition: transform .32s cubic-bezier(.3, .9, .3, 1); }
  .tools-hidden .tools-toggle { left: 0; }
  .tools-hidden .tools-toggle svg { transform: rotate(180deg); }
  .tools-hidden .tools { transform: translateX(calc(-100% - 16px)); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .32s cubic-bezier(.5, 0, .7, .3), opacity .22s ease, visibility 0s .32s; }
  .flyout { left: calc(var(--tw) + 16px); right: 8px; top: 8px; bottom: auto; max-width: none; max-height: calc(100% - 60px); overflow-y: auto; padding: 8px 10px; }
  .flyout::before { display: none; }
  .fly-range { grid-template-columns: 70px 1fr 50px; width: 100%; }
  .settings-btn { margin-top: auto; }
  .selbar { left: 50%; top: 8px; max-width: calc(100% - 16px); overflow-x: auto; }
  .bar { right: 8px; bottom: 12px; }
  .foot { left: 12px; bottom: 16px; max-width: 40%; }
  #empty { left: 50%; top: 36%; padding: 0 24px; }
}
/* Temas */
:root[data-theme="oscuro"] { --paper: #1b1d22; --panel: #23262c; --card: #2a2d34; --ink: #e8eaee; --text-soft: #c3c8d2; --muted: #98a0ad; --line: #2a2e36; --edge: #3a3f49; --accent: #6aa9ee; --accent-dark: #8bbcf2; --accent-soft: #2d4260; --accent-ink: #0f1a2a; --hover: #343840; --track: #3a3f49; --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); color-scheme: dark; }
:root[data-theme="rosa"] { --paper: #fff6f9; --panel: #fdeaf1; --card: #fffafc; --ink: #3a2a33; --text-soft: #5a4350; --muted: #8d7380; --line: #f3dce6; --edge: #efcddb; --accent: #d9558a; --accent-dark: #b93f72; --accent-soft: #fbd9e7; --hover: #fbe0ea; --track: #f1d3df; }
:root[data-theme="menta"] { --paper: #f4fbf7; --panel: #e5f5ec; --card: #fbfffd; --ink: #1f3329; --text-soft: #38564a; --muted: #6c8a7c; --line: #d8ede2; --edge: #c5e3d3; --accent: #2f9e6f; --accent-dark: #247d58; --accent-soft: #cdeede; --hover: #d9f0e4; --track: #c9e4d6; }
:root[data-theme="crema"] { --paper: #fbf6ea; --panel: #f3ead5; --card: #fffdf6; --ink: #33291b; --text-soft: #554734; --muted: #8a7b63; --line: #eadfc6; --edge: #decfae; --accent: #b8742a; --accent-dark: #975c1d; --accent-soft: #f2dcba; --hover: #efe3c8; --track: #e2d4b4; }
:root[data-theme="azul"] { --paper: #f3f8ff; --panel: #e4effc; --card: #fbfdff; --ink: #1f2f45; --text-soft: #3a4f6b; --muted: #6a809c; --line: #d9e7f7; --edge: #c6daf1; --accent: #4f8fd8; --accent-dark: #3a75b8; --accent-soft: #cfe3f8; --hover: #dbe9f8; --track: #c9dcf1; }
:root[data-theme="lavanda"] { --paper: #f8f5ff; --panel: #eee8fb; --card: #fdfcff; --ink: #2f2a45; --text-soft: #4d4569; --muted: #7d7699; --line: #e6e0f5; --edge: #d8d0ee; --accent: #8b6fd6; --accent-dark: #6f54ba; --accent-soft: #e0d6f7; --hover: #e8e0f7; --track: #d8d0ee; }
:root[data-theme="nocherosa"] { --paper: #1f1a1e; --panel: #292227; --card: #30282d; --ink: #f3e8ee; --text-soft: #d9c3cf; --muted: #a58f9b; --line: #2c242a; --edge: #43363e; --accent: #f06fa4; --accent-dark: #f58bb7; --accent-soft: #4a2a3b; --accent-ink: #2a0d1b; --hover: #382d34; --track: #43363e; --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); color-scheme: dark; }
:root[data-theme="nocheverde"] { --paper: #181f1b; --panel: #202a24; --card: #26312a; --ink: #e6f1ea; --text-soft: #bfd3c6; --muted: #8fa89a; --line: #232d27; --edge: #34443a; --accent: #4fd18b; --accent-dark: #72dca4; --accent-soft: #234a35; --accent-ink: #0c2417; --hover: #2d3a32; --track: #34443a; --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); color-scheme: dark; }
:root[data-theme="nochemorada"] { --paper: #1c1a24; --panel: #25222f; --card: #2b2836; --ink: #ece8f5; --text-soft: #cbc3de; --muted: #9d94b4; --line: #272432; --edge: #3b3749; --accent: #a58bff; --accent-dark: #bba6ff; --accent-soft: #3a3060; --accent-ink: #170f33; --hover: #33303f; --track: #3b3749; --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4); color-scheme: dark; }
.set-tabs { display: flex; gap: 4px; margin: 10px 0 4px; background: var(--panel); border-radius: 10px; padding: 3px; }
.set-tabs button { flex: 1; padding: 7px 10px; font-size: 14px; color: var(--text-soft); }
.set-tabs button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.themes button { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; border: 2px solid var(--edge); background: var(--card); font-size: 13px; }
.themes button[aria-pressed="true"] { border-color: var(--accent); }
.themes i { display: flex; height: 38px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(128, 128, 128, .3); }
.themes i b { flex: 1; }
.online { display: grid; gap: 6px; }
.person { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.person .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; flex: none; }
.person .who { flex: 1; min-width: 120px; display: grid; line-height: 1.2; }
.person .who small { color: var(--muted); font-size: 12px; }
.person button { padding: 4px 10px; font-size: 13px; border: 1px solid var(--edge); background: var(--card); }
#connection.live { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
